Minor - format code, add flash message, remove unused code.

pull/3023/head
Julio Montoya 6 years ago
parent 3bc5a7b57d
commit 447c582623
  1. 3
      main/inc/lib/document.lib.php
  2. 84
      main/lp/learnpath.class.php
  3. 14
      main/work/add_user.php
  4. 4
      main/work/work_list_all.php

@ -1594,8 +1594,7 @@ class DocumentManager
$course_id = $course['real_id'];
// note the extra / at the end of doc_path to match every path in
// the document table that is part of the document path
$session_id = intval($session_id);
$session_id = (int) $session_id;
$condition = "AND d.session_id IN ('$session_id', '0') ";
// The " d.filetype='file' " let the user see a file even if the folder is hidden see #2198

@ -1557,90 +1557,6 @@ class learnpath
return true;
}
/**
* Gets all the chapters belonging to the same parent as the item/chapter given
* Can also be called as abstract method.
*
* @deprecated not used
*
* @param int $id Item ID
*
* @return array A list of all the "brother items" (or an empty array on failure)
*/
public function getSiblingDirectories($id)
{
$course_id = api_get_course_int_id();
if (empty($id) || $id != strval(intval($id))) {
return [];
}
$lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql_parent = "SELECT * FROM $lp_item
WHERE iid = $id AND item_type='dir'";
$res_parent = Database::query($sql_parent);
if (Database::num_rows($res_parent) > 0) {
$row_parent = Database::fetch_array($res_parent);
$parent = $row_parent['parent_item_id'];
$sql = "SELECT * FROM $lp_item
WHERE
parent_item_id = $parent AND
iid = $id AND
item_type='dir'
ORDER BY display_order";
$res_bros = Database::query($sql);
$list = [];
while ($row_bro = Database::fetch_array($res_bros)) {
$list[] = $row_bro;
}
return $list;
}
return [];
}
/**
* Gets all the items belonging to the same parent as the item given
* Can also be called as abstract method.
*
* @deprecated not used
*
* @param int $id Item ID
*
* @return array A list of all the "brother items" (or an empty array on failure)
*/
public function get_brother_items($id)
{
$course_id = api_get_course_int_id();
if (empty($id) || $id != strval(intval($id))) {
return [];
}
$lp_item = Database::get_course_table(TABLE_LP_ITEM);
$sql_parent = "SELECT * FROM $lp_item
WHERE iid = $id";
$res_parent = Database::query($sql_parent);
if (Database::num_rows($res_parent) > 0) {
$row_parent = Database::fetch_array($res_parent);
$parent = $row_parent['parent_item_id'];
$sql = "SELECT * FROM $lp_item
WHERE c_id = $course_id AND parent_item_id = $parent
ORDER BY display_order";
$res_bros = Database::query($sql);
$list = [];
while ($row_bro = Database::fetch_array($res_bros)) {
$list[] = $row_bro;
}
return $list;
}
return [];
}
/**
* Get the specific prefix index terms of this learning path.
*

@ -8,8 +8,8 @@ require_once 'work.lib.php';
$current_course_tool = TOOL_STUDENTPUBLICATION;
$workId = isset($_GET['id']) ? intval($_GET['id']) : null;
$userId = isset($_GET['user_id']) ? intval($_GET['user_id']) : null;
$workId = isset($_GET['id']) ? (int) $_GET['id'] : null;
$userId = isset($_GET['user_id']) ? (int) $_GET['user_id'] : null;
$action = isset($_GET['action']) ? $_GET['action'] : null;
$sessionId = api_get_session_id();
@ -22,8 +22,6 @@ if (empty($my_folder_data)) {
api_not_allowed(true);
}
$work_data = get_work_assignment_by_id($workId);
if (!api_is_allowed_to_edit()) {
api_not_allowed(true);
}
@ -47,12 +45,15 @@ switch ($action) {
addUserToWork($userId, $workId, api_get_course_int_id());
}
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?id='.$workId.'&'.api_get_cidreq();
Display::addFlash(Display::return_message(get_lang('Added')));
header('Location: '.$url);
exit;
break;
case 'delete':
if (!empty($workId) && !empty($userId)) {
deleteUserToWork($userId, $workId, api_get_course_int_id());
Display::addFlash(Display::return_message(get_lang('Deleted')));
$url = api_get_path(WEB_CODE_PATH).'work/add_user.php?id='.$workId.'&'.api_get_cidreq();
header('Location: '.$url);
exit;
@ -60,7 +61,7 @@ switch ($action) {
break;
}
Display :: display_header(null);
Display::display_header(null);
$items = getAllUserToWork($workId, api_get_course_int_id());
$usersAdded = [];
@ -83,10 +84,9 @@ if (!empty($items)) {
echo '</ul>';
}
$status = 0;
if (empty($sessionId)) {
$status = STUDENT;
} else {
$status = 0;
}
$userList = CourseManager::get_user_list_from_course_code(

@ -33,18 +33,14 @@ if (!($is_allowed_to_edit || $isDrhOfCourse)) {
api_not_allowed(true);
}
$tool_name = get_lang('StudentPublications');
$group_id = api_get_group_id();
$courseInfo = api_get_course_info();
$courseCode = $courseInfo['code'];
$sessionId = api_get_session_id();
$htmlHeadXtra[] = api_get_jqgrid_js();
$user_id = api_get_user_id();
if (!empty($group_id)) {
$group_properties = GroupManager::get_group_properties($group_id);
$show_work = false;
if (api_is_allowed_to_edit(false, true)) {
$show_work = true;
} else {

Loading…
Cancel
Save