diff --git a/main/work/work.lib.php b/main/work/work.lib.php
index 3df01582f4..8a11130857 100644
--- a/main/work/work.lib.php
+++ b/main/work/work.lib.php
@@ -26,16 +26,16 @@ require_once api_get_path(SYS_CODE_PATH).'gradebook/lib/gradebook_functions.inc.
*/
function display_action_links($id, $cur_dir_path, $show_tool_options, $display_upload_link, $action) {
global $gradebook;
-
+
$id = $my_back_id = intval($id);
if ($action == 'list') {
$my_back_id = 0;
}
-
+
$display_output = '';
- $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
-
- if (!empty($id)) {
+ $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : '';
+
+ if (!empty($id)) {
$display_output .= ''.Display::return_icon('back.png', get_lang('BackToWorksList'),'',ICON_SIZE_MEDIUM).'';
}
@@ -68,7 +68,7 @@ function display_action_links($id, $cur_dir_path, $show_tool_options, $display_u
if (api_is_allowed_to_edit(null, true)) {
global $token;
-
+
if (!empty($id)) {
if (empty($_GET['list']) or Security::remove_XSS($_GET['list']) == 'with') {
$display_output .= ''.
@@ -106,12 +106,12 @@ function display_action_links($id, $cur_dir_path, $show_tool_options, $display_u
*
* @param $uploadvisibledisabled
* @param $origin
-
+
*/
function display_tool_options($uploadvisibledisabled, $origin) {
global $gradebook;
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
-
+
if (!$is_allowed_to_edit) {
return;
}
@@ -178,10 +178,10 @@ function display_studentsdelete_form() {
+
@@ -283,14 +283,14 @@ function get_work_count_by_student($user_id, $work_id) {
$work_id = intval($work_id);
$course_id = api_get_course_int_id();
$session_id = api_get_session_id();
-
+
$work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
- $sql = "SELECT COUNT(*) as count FROM $work_table
+ $sql = "SELECT COUNT(*) as count FROM $work_table
WHERE c_id = $course_id AND parent_id = $work_id AND user_id = $user_id AND active = 1 AND session_id = $session_id ";
$result = Database::query($sql);
$return = 0;
if (Database::num_rows($result)) {
- $return = Database::fetch_row($result,'ASSOC');
+ $return = Database::fetch_row($result,'ASSOC');
$return = intval($return[0]);
}
return $return;
@@ -324,17 +324,17 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$iprop_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$work_assigment = Database::get_course_table(TABLE_STUDENT_PUBLICATION_ASSIGNMENT);
-
+
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
-
- $user_id = api_get_user_id();
+
+ $user_id = api_get_user_id();
$session_id = api_get_session_id();
- $condition_session = api_get_session_condition($session_id);
+ $condition_session = api_get_session_condition($session_id);
$course_id = api_get_course_int_id();
$group_id = api_get_group_id();
-
+
$course_info = api_get_course_info(api_get_course_id());
-
+
$sort_params = array();
if (isset($_GET['column'])) {
@@ -353,66 +353,66 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$my_params = $sort_params;
$origin = Security::remove_XSS($origin);
- // Getting the work data
- $my_folder_data = get_work_data_by_id($id);
-
+ // Getting the work data
+ $my_folder_data = get_work_data_by_id($id);
+
$qualification_exists = false;
if (!empty($my_folder_data['qualification']) && intval($my_folder_data['qualification']) > 0) {
$qualification_exists = true;
- }
-
- $work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/work';
+ }
+
+ $work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/work';
if (!empty($my_folder_data)) {
$work_dir = api_get_path(SYS_COURSE_PATH).$_course['path'].'/work'.$my_folder_data['url'];
}
-
+
if (empty($my_folder_data)) {
$link_info = is_resource_in_course_gradebook(api_get_course_id(), 3 , $id, api_get_session_id());
$work_in_gradebook_link_id = $link_info['id'];
-
+
if ($work_in_gradebook_link_id) {
if ($is_allowed_to_edit)
if (intval($my_folder_data['qualification']) == 0) {
Display::display_warning_message(get_lang('MaxWeightNeedToBeProvided'));
}
- }
- $contains_file_query = '';
-
+ }
+ $contains_file_query = '';
+
//Get list from database
if ($is_allowed_to_edit) {
- $active_condition = ' active IN (0, 1)';
+ $active_condition = ' active IN (0, 1)';
$sql_get_publications_list = "SELECT * FROM $work_table ".
" WHERE c_id = $course_id $add_in_where_query $condition_session AND $active_condition AND ".
" ( parent_id = 0) ".
" $contains_file_query ".
" ORDER BY sent_date DESC";
- } else {
+ } else {
if (!empty($group_id)) {
$group_query = " WHERE c_id = $course_id AND post_group_id = '".$group_id."' "; // set to select only messages posted by the user's group
$subdirs_query = "AND parent_id = 0";
} else {
$group_query = " WHERE c_id = $course_id AND post_group_id = '0' ";
$subdirs_query = "AND parent_id = 0";
- }
- //@todo how we can active or not an assignment?
- $active_condition = ' AND active IN (1,0)';
- $sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query $add_in_where_query $active_condition $condition_session ORDER BY title";
+ }
+ //@todo how we can active or not an assignment?
+ $active_condition = ' AND active IN (1,0)';
+ $sql_get_publications_list = "SELECT * FROM $work_table $group_query $subdirs_query $add_in_where_query $active_condition $condition_session ORDER BY title";
}
-
- $work_parents = array();
-
+
+ $work_parents = array();
+
$sql_result = Database::query($sql_get_publications_list);
- if (Database::num_rows($sql_result)) {
+ if (Database::num_rows($sql_result)) {
while ($work = Database::fetch_object($sql_result)) {
if ($work->parent_id == 0) {
$work_parents[] = $work;
}
}
- }
- }
-
- $edit_dir = isset($_GET['edit_dir']) ? $_GET['edit_dir'] : '';
-
+ }
+ }
+
+ $edit_dir = isset($_GET['edit_dir']) ? $_GET['edit_dir'] : '';
+
$table_header = array();
$table_has_actions_column = false;
$table_header[] = array(get_lang('Type'), false, 'style="width:40px"');
@@ -425,7 +425,7 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$table_header[] = array(get_lang('Qualification'), true);
}
}
-
+
$table_header[] = array(get_lang('Date'), true, 'style="width:200px"');
if ($is_allowed_to_edit) {
@@ -438,83 +438,83 @@ function display_student_publications_list($id, $link_target_parameter, $dateFor
$table_data = array();
// List of all folders if no id was provided
-
+
$group_id = api_get_group_id();
-
- if (is_array($work_parents)) {
- foreach ($work_parents as $work_parent) {
+
+ if (is_array($work_parents)) {
+ foreach ($work_parents as $work_parent) {
$sql_select_directory = "SELECT title, url, prop.insert_date, prop.lastedit_date, work.id, author, has_properties, view_properties, description, qualification, weight, allow_text_assignment ".
" FROM ".$iprop_table." prop INNER JOIN ".$work_table." work ON (prop.ref=work.id AND prop.c_id = $course_id ) ".
" WHERE active IN (0, 1) AND ";
-
+
if (!empty($group_id)) {
$sql_select_directory .= " work.post_group_id = '".$group_id."' "; // set to select only messages posted by the user's group
} else {
$sql_select_directory .= " work.post_group_id = '0' ";
- }
+ }
$sql_select_directory .= " AND ".
" work.c_id = $course_id AND ".
" work.id = ".$work_parent->id." AND ".
" work.filetype = 'folder' AND ".
- " prop.tool='work' $condition_session";
+ " prop.tool='work' $condition_session";
$result = Database::query($sql_select_directory);
$row = Database::fetch_array($result, 'ASSOC');
-
+
if (!$row) {
// the folder belongs to another session
continue;
}
- $direc_date = $row['lastedit_date']; //directory's date
- $author = $row['author']; //directory's author
+ $direc_date = $row['lastedit_date']; //directory's date
+ $author = $row['author']; //directory's author
$view_properties = $row['view_properties'];
$is_assignment = $row['has_properties'];
$id2 = $row['id']; //work id
$locked = api_resource_is_locked_by_gradebook($id2, LINK_STUDENTPUBLICATION);
-
+
if ($is_allowed_to_edit && $locked == false) {
// form edit directory
-
+
if (!empty($edit_dir) && $edit_dir == $id2) {
-
+
if (!empty($row['has_properties'])) {
$sql = Database::query('SELECT * FROM '.$work_assigment.' WHERE c_id = '.$course_id.' AND id = "'.$row['has_properties'].'" LIMIT 1');
$homework = Database::fetch_array($sql);
}
- $form_folder = new FormValidator('edit_dir', 'post', api_get_self().'?origin='.$origin.'&gradebook='.$gradebook.'&edit_dir='.$id2);
- $form_folder->addElement('text', 'dir_name', get_lang('Title'));
+ $form_folder = new FormValidator('edit_dir', 'post', api_get_self().'?origin='.$origin.'&gradebook='.$gradebook.'&edit_dir='.$id2);
+ $form_folder->addElement('text', 'dir_name', get_lang('Title'));
$form_folder->addElement('hidden', 'work_id', $id2);
$form_folder -> addRule('dir_name', get_lang('ThisFieldIsRequired'), 'required');
-
+
$my_title = !empty($row['title']) ? $row['title'] : basename($row['url']);
-
+
$defaults = array('dir_name' => Security::remove_XSS($my_title), 'description' => Security::remove_XSS($row['description']));
$form_folder->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'work', 'Width' => '80%', 'Height' => '200'));
- $there_is_a_end_date = false;
+ $there_is_a_end_date = false;
$form_folder -> addElement('advanced_settings', '
'.get_lang('AdvancedParameters').'
');
$form_folder->addElement('html', '