$form->applyFilter('title', 'html_filter'); $form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'TrainingDescription', 'Width' => '100%', 'Height' => '200')); // Adavanced Parameters if (Gradebook::is_active()) { if (!empty($attendance_qualify_title) || !empty($attendance_weight)) { $form->addElement('advanced_settings', 'id_qualify', get_lang('AdvancedParameters')); $form->addElement('html', '<div id="id_qualify_options" style="display:block">'); $form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), array('checked' => 'true', 'onclick' => 'javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}')); $form->addElement('html', '<div id="options_field" style="display:block">'); } else { $form->addElement('advanced_settings', 'id_qualify', get_lang('AdvancedParameters')); $form->addElement('html', '<div id="id_qualify_options" style="display:none">'); $form->addElement('checkbox', 'attendance_qualify_gradebook', '', get_lang('QualifyAttendanceGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"'); $form->addElement('html', '<div id="options_field" style="display:none">'); } load_gradebook_select_in_tool($form); $form->addElement('text', 'attendance_qualify_title', get_lang('TitleColumnGradebook')); $form->applyFilter('attendance_qualify_title', 'html_filter'); $form->addElement('text', 'attendance_weight', get_lang('QualifyWeight'), 'value="0.00" Style="width:40px" onfocus="javascript: this.select();"'); $form->applyFilter('attendance_weight', 'html_filter'); $form->addElement('html', '</div>'); $form->addElement('html', '</div>'); } $form->addElement('style_submit_button', null, get_lang('Save'), 'class="save"'); // set default values $default['title'] = Security::remove_XSS($title); $default['description'] = Security::remove_XSS($description, STUDENT); $default['attendance_qualify_title'] = $attendance_qualify_title; $default['attendance_weight'] = $attendance_weight; $link_info = is_resource_in_course_gradebook(api_get_course_id(), 7, $attendance_id, api_get_session_id()); $default['category_id'] = $link_info['category_id'];
/** * Display the list of student publications, taking into account the user status * * @param $origin - typically empty or 'learnpath' */ function display_student_publications_list($id, $my_folder_data, $work_parents, $origin, $add_in_where_query = '', $userList = array()) { global $gradebook; $_course = api_get_course_info(); // Database table names $work_table = Database::get_course_table(TABLE_STUDENT_PUBLICATION); $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); $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id); $course_id = api_get_course_int_id(); $course_info = api_get_course_info(api_get_course_id()); $sort_params = array(); if (isset($_GET['column'])) { $sort_params[] = 'column=' . Security::remove_XSS($_GET['column']); } if (isset($_GET['page_nr'])) { $sort_params[] = 'page_nr=' . Security::remove_XSS($_GET['page_nr']); } if (isset($_GET['per_page'])) { $sort_params[] = 'per_page=' . Security::remove_XSS($_GET['per_page']); } if (isset($_GET['direction'])) { $sort_params[] = 'direction=' . Security::remove_XSS($_GET['direction']); } $sort_params = implode('&', $sort_params); $my_params = $sort_params; $origin = Security::remove_XSS($origin); $qualification_exists = false; if (!empty($my_folder_data['qualification']) && intval($my_folder_data['qualification']) > 0) { $qualification_exists = true; } $edit_dir = isset($_GET['edit_dir']) ? intval($_GET['edit_dir']) : ''; $table_header = array(); $table_has_actions_column = false; $table_header[] = array(get_lang('Type'), false, 'style="width:40px"'); $table_header[] = array(get_lang('Title'), true); if (!empty($id)) { $table_header[] = array(get_lang('FirstName'), true); $table_header[] = array(get_lang('LastName'), true); } $table_header[] = array(get_lang('HandOutDateLimit'), true, 'style="width:200px"'); if ($is_allowed_to_edit) { $table_header[] = array(get_lang('HandedOut'), false); $table_header[] = array(get_lang('Actions'), false, 'style="width:90px"', array('class' => 'td_actions')); $table_has_actions_column = true; if ($qualification_exists) { $table_header[] = array(get_lang('Qualification'), true); } } else { // All users if ($course_info['show_score'] == 0) { $table_header[] = array(get_lang('Others'), false); } } $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) { $sql_select_directory = "SELECT\n\t\t\t title,\n\t\t\t url,\n\t\t\t prop.insert_date,\n\t\t\t prop.lastedit_date,\n\t\t\t work.id, author,\n\t\t\t has_properties,\n\t\t\t view_properties,\n\t\t\t description,\n\t\t\t qualification,\n\t\t\t weight,\n\t\t\t allow_text_assignment\n FROM " . $iprop_table . " prop INNER JOIN " . $work_table . " work ON (prop.ref=work.id AND prop.c_id = {$course_id})\n 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}"; $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 $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); // form edit directory 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); } // save original value for later $utc_expiry_time = $homework['expires_on']; if ($is_allowed_to_edit && $locked == false) { if (!empty($edit_dir) && $edit_dir == $id2) { $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; $form_folder->addElement('advanced_settings', 'work', get_lang('AdvancedParameters')); $form_folder->addElement('html', '<div id="work_options" style="display: none;">'); if (empty($default)) { $default = api_get_local_time(); } $parts = explode(' ', $default); list($d_year, $d_month, $d_day) = explode('-', $parts[0]); list($d_hour, $d_minute) = explode(':', $parts[1]); $qualification_input[] = $form_folder->createElement('text', 'qualification'); $form_folder->addGroup($qualification_input, 'qualification', get_lang('QualificationNumeric')); if (Gradebook::is_active()) { $link_info = is_resource_in_course_gradebook(api_get_course_id(), LINK_STUDENTPUBLICATION, $id2); $form_folder->addElement('checkbox', 'make_calification', null, get_lang('MakeQualifiable'), 'onclick="javascript: if(this.checked){document.getElementById(\'option3\').style.display = \'block\';}else{document.getElementById(\'option3\').style.display = \'none\';}"'); if (!empty($link_info)) { $form_folder->addElement('html', '<div id=\'option3\' style="display:block">'); } else { $form_folder->addElement('html', '<div id=\'option3\' style="display:none">'); } //Loading gradebook select load_gradebook_select_in_tool($form_folder); $weight_input2[] = $form_folder->createElement('text', 'weight'); $form_folder->addGroup($weight_input2, 'weight', get_lang('WeightInTheGradebook'), 'size="10"'); $form_folder->addElement('html', '</div>'); $defaults['weight[weight]'] = $link_info['weight']; if (!empty($link_info)) { $defaults['category_id'] = $link_info['category_id']; $defaults['make_calification'] = 1; } } else { $defaults['category_id'] = ''; } if ($homework['expires_on'] != '0000-00-00 00:00:00') { $homework['expires_on'] = api_get_local_time($homework['expires_on']); $there_is_a_expire_date = true; $defaults['enableExpiryDate'] = true; $form_folder->addElement('checkbox', 'enableExpiryDate', null, get_lang('EnableExpiryDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display = \'block\';}else{document.getElementById(\'option1\').style.display = \'none\';}"'); $form_folder->addElement('html', '<div id=\'option1\' style="display:block">'); $form_folder->addGroup(create_group_date_select(), 'expires', get_lang('ExpiresAt')); $form_folder->addElement('html', '</div>'); } else { $homework['expires_on'] = api_get_local_time(); $expires_date_array = convert_date_to_array(api_get_local_time(), 'expires'); $defaults = array_merge($defaults, $expires_date_array); $there_is_a_expire_date = false; $form_folder->addElement('checkbox', 'enableExpiryDate', null, get_lang('EnableExpiryDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option1\').style.display = \'block\';}else{document.getElementById(\'option1\').style.display = \'none\';}"'); $form_folder->addElement('html', '<div id=\'option1\' style="display:none">'); $form_folder->addGroup(create_group_date_select(), 'expires', get_lang('ExpiresAt')); $form_folder->addElement('html', '</div>'); } if ($homework['ends_on'] != '0000-00-00 00:00:00') { $homework['ends_on'] = api_get_local_time($homework['ends_on']); $there_is_a_end_date = true; $defaults['enableEndDate'] = true; $form_folder->addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display = \'block\';}else{document.getElementById(\'option2\').style.display = \'none\';}"'); $form_folder->addElement('html', '<div id=\'option2\' style="display:block">'); $form_folder->addGroup(create_group_date_select(), 'ends', get_lang('EndsAt')); $form_folder->addElement('html', '</div>'); $form_folder->addRule(array('expires', 'ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate'); } else { $homework['ends_on'] = api_get_local_time(); $expires_date_array = convert_date_to_array(api_get_local_time(), 'ends'); $defaults = array_merge($defaults, $expires_date_array); $there_is_a_end_date = false; $form_folder->addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'onclick="javascript: if(this.checked){document.getElementById(\'option2\').style.display = \'block\';}else{document.getElementById(\'option2\').style.display = \'none\';}"'); $form_folder->addElement('html', '<div id=\'option2\' style="display:none">'); $form_folder->addGroup(create_group_date_select(), 'ends', get_lang('EndsAt')); $form_folder->addElement('html', '</div>'); $form_folder->addRule(array('expires', 'ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate'); } if ($there_is_a_expire_date && $there_is_a_end_date) { $form_folder->addRule(array('expires', 'ends'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate'); } $form_folder->addElement('checkbox', 'allow_text_assignment', null, get_lang('AllowTextAssignments')); $form_folder->addElement('html', '</div>'); $form_folder->addElement('style_submit_button', 'submit', get_lang('ModifyDirectory'), 'class="save"'); if ($there_is_a_end_date) { $end_date_array = convert_date_to_array($homework['ends_on'], 'ends'); $defaults = array_merge($defaults, $end_date_array); } if ($there_is_a_expire_date) { $expires_date_array = convert_date_to_array($homework['expires_on'], 'expires'); $defaults = array_merge($defaults, $expires_date_array); } if (!empty($row['qualification'])) { $defaults = array_merge($defaults, array('qualification[qualification]' => $row['qualification'])); } $defaults['allow_text_assignment'] = $row['allow_text_assignment']; $form_folder->setDefaults($defaults); $display_edit_form = true; if ($form_folder->validate()) { if ($_POST['enableExpiryDate'] == '1') { $there_is_a_expire_date = true; } else { $there_is_a_expire_date = false; } if ($_POST['enableEndDate'] == '1') { $there_is_a_end_date = true; } else { $there_is_a_end_date = false; } $values = $form_folder->exportValues(); $work_id = $values['work_id']; $dir_name = replace_dangerous_char($values['dir_name']); $dir_name = disable_dangerous_file($dir_name); $edit_check = false; $work_data = get_work_data_by_id($work_id); if (!empty($work_data)) { $edit_check = true; } else { $edit_check = true; } if ($edit_check) { $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA); $expires_query = ' SET expires_on = ' . "'" . ($there_is_a_expire_date ? api_get_utc_datetime(get_date_from_group('expires')) : '0000-00-00 00:00:00') . "'"; Database::query('UPDATE ' . $work_assigment . $expires_query . ' WHERE c_id = ' . $course_id . ' AND id = ' . "'" . $row['has_properties'] . "'"); $sql_add_publication = "UPDATE " . $work_table . " SET has_properties = '" . $row['has_properties'] . "', view_properties=1 WHERE c_id = {$course_id} AND id ='" . $row['id'] . "'"; Database::query($sql_add_publication); $ends_query = ' SET ends_on = ' . "'" . ($there_is_a_end_date ? api_get_utc_datetime(get_date_from_group('ends')) : '0000-00-00 00:00:00') . "'"; Database::query('UPDATE ' . $work_assigment . $ends_query . ' WHERE c_id = ' . $course_id . ' AND id = ' . "'" . $row['has_properties'] . "'"); $sql_add_publication = "UPDATE " . $work_table . " SET has_properties = '" . $row['has_properties'] . "', view_properties=1 WHERE c_id = {$course_id} AND id ='" . $row['id'] . "'"; Database::query($sql_add_publication); $qualification_value = isset($_POST['qualification']['qualification']) && !empty($_POST['qualification']['qualification']) ? intval($_POST['qualification']['qualification']) : 0; $enable_qualification = !empty($qualification_value) ? 1 : 0; $sql_add_publication = "UPDATE " . $work_assigment . " SET enable_qualification = '" . $enable_qualification . "' WHERE c_id = {$course_id} AND publication_id ='" . $row['id'] . "'"; Database::query($sql_add_publication); $sql = 'UPDATE ' . $work_table . ' SET allow_text_assignment = ' . "'" . intval($_POST['allow_text_assignment']) . "'" . ' , title = ' . "'" . Database::escape_string($_POST['dir_name']) . "'" . ', description = ' . "'" . Database::escape_string($_POST['description']) . "'" . ', qualification = ' . "'" . Database::escape_string($_POST['qualification']['qualification']) . "'" . ', weight = ' . "'" . Database::escape_string($_POST['weight']['weight']) . "'" . ' WHERE c_id = ' . $course_id . ' AND id = ' . $row['id']; Database::query($sql); require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/gradebook_functions.inc.php'; require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be/gradebookitem.class.php'; require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be/evaluation.class.php'; require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/be/abstractlink.class.php'; $link_info = is_resource_in_course_gradebook(api_get_course_id(), LINK_STUDENTPUBLICATION, $row['id'], api_get_session_id()); $link_id = null; if (!empty($link_info)) { $link_id = $link_info['id']; } if (isset($_POST['make_calification']) && $_POST['make_calification'] == 1 && !empty($_POST['category_id'])) { if (empty($link_id)) { add_resource_to_course_gradebook($_POST['category_id'], api_get_course_id(), LINK_STUDENTPUBLICATION, $row['id'], $_POST['dir_name'], (double) $_POST['weight']['weight'], (double) $_POST['qualification']['qualification'], $_POST['description'], 1, api_get_session_id(), $link_id); } else { update_resource_from_course_gradebook($link_id, api_get_course_id(), $_POST['weight']['weight']); } } else { //Delete everything of the gradebook remove_resource_from_course_gradebook($link_id); } update_dir_name($work_data, $dir_name, $values['dir_name']); $dir = $dir_name; $display_edit_form = false; // gets calendar_id from student_publication_assigment $sql = "SELECT add_to_calendar FROM {$work_assigment} WHERE c_id = {$course_id} AND publication_id ='" . $row['id'] . "'"; $res = Database::query($sql); $calendar_id = Database::fetch_row($res); $dir_name = sprintf(get_lang('HandingOverOfTaskX'), $dir_name); $end_date = $row['insert_date']; if ($_POST['enableExpiryDate'] == '1') { $end_date = Database::escape_string(api_get_utc_datetime(get_date_from_group('expires'))); } // update from agenda if it exists if (!empty($calendar_id[0])) { $sql = "UPDATE " . $TABLEAGENDA . "\n\t\t\t\t\t\t\t\t\t\tSET title='" . $values['dir_name'] . "',\n\t\t\t\t\t\t\t\t\t\t\tcontent = '" . Database::escape_string($_POST['description']) . "',\n\t\t\t\t\t\t\t\t\t\t\tstart_date = '" . $end_date . "',\n\t\t\t\t\t\t\t\t\t\t\tend_date = '" . $end_date . "'\n\t\t\t\t\t\t\t\t\t\tWHERE c_id = {$course_id} AND id='" . $calendar_id[0] . "'"; Database::query($sql); } Display::display_confirmation_message(get_lang('FolderEdited')); } else { Display::display_warning_message(get_lang('FileExists')); } } } } $work_data = get_work_data_by_id($work_parent->id); $action = ''; $row = array(); $class = ''; $course_id = api_get_course_int_id(); $session_id = api_get_session_id(); if (api_is_allowed_to_edit()) { $cant_files = get_count_work($work_data['id']); } else { $isSubscribed = userIsSubscribedToWork(api_get_user_id(), $work_data['id'], $course_id); if ($isSubscribed == false) { continue; } $cant_files = get_count_work($work_data['id'], api_get_user_id()); } $text_file = get_lang('FilesUpload'); if ($cant_files == 1) { $text_file = api_strtolower(get_lang('FileUpload')); } $icon = Display::return_icon('work.png', get_lang('Assignment'), array(), ICON_SIZE_SMALL); if (!empty($display_edit_form) && !empty($edit_dir) && $edit_dir == $id2) { $row[] = $icon; $row[] = '<span class="invisible" style="display:none">' . $dir . '</span>' . $form_folder->toHtml(); // form to edit the directory's name } else { $row[] = '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&origin=' . $origin . '&gradebook=' . $gradebook . '">' . $icon . '</a>'; $add_to_name = ''; require_once api_get_path(SYS_CODE_PATH) . 'gradebook/lib/gradebook_functions.inc.php'; $link_info = is_resource_in_course_gradebook(api_get_course_id(), 3, $id2, api_get_session_id()); $link_id = $link_info['id']; $count = 0; if ($link_info !== false) { $gradebook_data = get_resource_from_course_gradebook($link_id); $count = $gradebook_data['weight']; } if ($count > 0) { $add_to_name = Display::label(get_lang('IncludedInEvaluation'), 'info'); } else { $add_to_name = ''; } $work_title = !empty($work_data['title']) ? $work_data['title'] : basename($work_data['url']); // Work name if ($cant_files > 0) { $zip = '<a href="downloadfolder.inc.php?id=' . $work_data['id'] . '">' . Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'), ICON_SIZE_SMALL) . '</a>'; } $link = 'work_list.php'; if (api_is_allowed_to_edit()) { $link = 'work_list_all.php'; } $url = $zip . '<a href="' . api_get_path(WEB_CODE_PATH) . 'work/' . $link . '?' . api_get_cidreq() . '&origin=' . $origin . '&gradebook=' . Security::remove_XSS($_GET['gradebook']) . '&id=' . $work_data['id'] . '"' . $class . '>' . $work_title . '</a> ' . $add_to_name . '<br />' . $cant_files . ' ' . $text_file . $dirtext; $row[] = $url; } if ($count_files != 0) { $row[] = ''; } if (!empty($homework)) { // use original utc value saved previously to avoid doubling the utc-to-local conversion ($homework['expires_on'] might have been tainted) $row[] = !empty($utc_expiry_time) && $utc_expiry_time != '0000-00-00 00:00:00' ? api_get_local_time($utc_expiry_time) : '-'; } else { $row[] = '-'; } if (!$is_allowed_to_edit) { if ($course_info['show_score'] == 0) { $url = api_get_path(WEB_CODE_PATH) . 'work/work_list_others.php?' . api_get_cidreq() . '&id=' . $work_parent->id; $row[] = Display::url(Display::return_icon('group.png', get_lang('Others')), $url); } } if ($origin != 'learnpath') { if ($is_allowed_to_edit) { $cant_files_per_user = getUniqueStudentAttempts($work_data['id'], $group_id, $course_id, api_get_session_id(), null, $userList); $row[] = $cant_files_per_user . '/' . count($userList); if (api_resource_is_locked_by_gradebook($id2, LINK_STUDENTPUBLICATION)) { $action .= Display::return_icon('edit_na.png', get_lang('Edit'), array(), ICON_SIZE_SMALL); $action .= Display::return_icon('delete_na.png', get_lang('Delete'), array(), ICON_SIZE_SMALL); } else { $action .= '<a href="' . api_get_self() . '?cidReq=' . api_get_course_id() . '&origin=' . $origin . '&gradebook=' . $gradebook . '&edit_dir=' . $id2 . '">' . Display::return_icon('edit.png', get_lang('Modify'), array(), ICON_SIZE_SMALL) . '</a>'; $action .= ' <a href="' . api_get_self() . '?' . api_get_cidreq() . '&origin=' . $origin . '&gradebook=' . $gradebook . '&delete_dir=' . $id2 . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('DirDelete') . '" >' . Display::return_icon('delete.png', get_lang('DirDelete'), '', ICON_SIZE_SMALL) . '</a>'; } $row[] = $action; } else { $row[] = ''; } } //$row[] = $direc_date_local; $row[] = $work_data['title']; $table_data[] = $row; } } $sorting_options = array(); $sorting_options['column'] = 1; // Here we change the way how the columns are going to be sorted // in this case the the column of LastResent ( 4th element in $column_header) we will be order like the column RealDate // because in the column RealDate we have the days in a correct format "2008-03-12 10:35:48" $column_order = array(); $i = 0; foreach ($table_header as $item) { $column_order[$i] = $i; $i++; } if (empty($my_folder_data)) { $column_order[1] = 5; } else { $column_order[2] = 2; } // An array with the setting of the columns -> 1: columns that we will show, 0:columns that will be hide $column_show = array(); $column_show[] = 1; // type 0 $column_show[] = 1; // title 1 if (!empty($my_folder_data)) { $column_show[] = 1; // 2 $column_show[] = 1; // 3 if ($qualification_exists) { $column_show[] = 1; // 4 } } $column_show[] = 1; //date if ($table_has_actions_column) { $column_show[] = 1; // modify } $column_show[] = 1; //real date in correct format $column_show[] = 0; //real date in correct format $paging_options = array(); if (isset($_GET['curdirpath'])) { $my_params = array('curdirpath' => Security::remove_XSS($_GET['curdirpath'])); } $my_params = array('id' => isset($_GET['id']) ? $_GET['id'] : null); if (isset($_GET['edit_dir'])) { $my_params = array('edit_dir' => intval($_GET['edit_dir'])); } $my_params['origin'] = $origin; Display::display_sortable_config_table('work', $table_header, $table_data, $sorting_options, $paging_options, $my_params, $column_show, $column_order); }
/** * @param FormValidator $form * @param array $defaults * @return FormValidator */ function getFormWork($form, $defaults = array()) { if (!empty($defaults)) { if (isset($defaults['submit'])) { unset($defaults['submit']); } } // Create the form that asks for the directory name $form->addElement('text', 'new_dir', get_lang('AssignmentName')); $form->addRule('new_dir', get_lang('ThisFieldIsRequired'), 'required'); $form->add_html_editor('description', get_lang('Description'), false, false, getWorkDescriptionToolbar()); $form->addElement( 'advanced_settings', '<a href="javascript: void(0);" onclick="javascript: return plus();"> <span id="plus">'. Display::return_icon( 'div_show.gif', get_lang('AdvancedParameters'), array('style' => 'vertical-align:center') ). ' '.get_lang('AdvancedParameters'). '</span></a>' ); if (!empty($defaults) && (isset($defaults['enableEndDate']) || isset($defaults['enableExpiryDate']))) { $form->addElement('html', '<div id="options" style="display: block;">'); } else { $form->addElement('html', '<div id="options" style="display: none;">'); } // QualificationOfAssignment $form->addElement('text', 'qualification', get_lang('QualificationNumeric')); if ((api_get_session_id() != 0 && Gradebook::is_active()) || api_get_session_id() == 0) { $form->addElement( 'checkbox', 'make_calification', null, get_lang('MakeQualifiable'), array( 'id' =>'make_calification_id', 'onclick' => "javascript: if(this.checked) { document.getElementById('option1').style.display='block';}else{document.getElementById('option1').style.display='none';}" ) ); } else { // QualificationOfAssignment $form->addElement('hidden', 'make_calification', false); } if (!empty($defaults) && isset($defaults['category_id'])) { $form->addElement('html', '<div id=\'option1\' style="display:block">'); } else { $form->addElement('html', '<div id=\'option1\' style="display:none">'); } // Loading Gradebook select load_gradebook_select_in_tool($form); $form->addElement('text', 'weight', get_lang('WeightInTheGradebook')); $form->addElement('html', '</div>'); $form->addElement('checkbox', 'enableExpiryDate', null, get_lang('EnableExpiryDate'), 'id="expiry_date"'); if (isset($defaults['enableExpiryDate']) && $defaults['enableExpiryDate']) { $form->addElement('html', '<div id="option2" style="display: block;">'); } else { $form->addElement('html', '<div id="option2" style="display: none;">'); } $currentDate = substr(api_get_local_time(), 0, 10); if (!isset($defaults['expires_on'])) { $date = substr($currentDate, 0, 10); $defaults['expires_on'] = $date.' 23:59'; } if (!isset($defaults['ends_on'])) { $date = substr($currentDate, 0, 10); $defaults['ends_on'] = $date.' 23:59'; } $form->addElement('date_time_picker', 'expires_on', get_lang('ExpiresAt')); $form->addElement('html', '</div>'); $form->addElement('checkbox', 'enableEndDate', null, get_lang('EnableEndDate'), 'id="end_date"'); if (isset($defaults['enableEndDate']) && $defaults['enableEndDate']) { $form->addElement('html', '<div id="option3" style="display: block;">'); } else { $form->addElement('html', '<div id="option3" style="display: none;">'); } $form->addElement('date_time_picker', 'ends_on', get_lang('EndsAt')); $form->addElement('html', '</div>'); $form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar')); $form->addElement('select', 'allow_text_assignment', get_lang('DocumentType'), getUploadDocumentType()); $form->addElement('html', '</div>'); if (isset($defaults['enableExpiryDate']) && isset($defaults['enableEndDate'])) { $form->addRule(array('expires_on', 'ends_on'), get_lang('DateExpiredNotBeLessDeadLine'), 'comparedate'); } if (!empty($defaults)) { $form->setDefaults($defaults); } return $form; }
/** * This function displays the form that is used to edit a post. This can be a new thread or a reply. * @param array contains all the information about the current post * @param array contains all the information about the current thread * @param array contains all info about the current forum (to check if attachments are allowed) * @param array contains the default values to fill the form * @return void * * @author Patrick Cool <*****@*****.**>, Ghent University * @version february 2006, dokeos 1.8 */ function show_edit_post_form($forum_setting, $current_post, $current_thread, $current_forum, $form_values = '', $id_attach = 0) { // Initialize the object. $form = new FormValidator('edit_post', 'post', api_get_self() . '?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($_GET['forum']) . '&thread=' . Security::remove_XSS($_GET['thread']) . '&post=' . Security::remove_XSS($_GET['post'])); $form->addElement('header', get_lang('EditPost')); // Setting the form elements. $form->addElement('hidden', 'post_id', $current_post['post_id']); $form->addElement('hidden', 'thread_id', $current_thread['thread_id']); $form->addElement('hidden', 'id_attach', $id_attach); if ($current_post['post_parent_id'] == 0) { $form->addElement('hidden', 'is_first_post_of_thread', '1'); } $form->addElement('text', 'post_title', get_lang('Title'), 'class="input_titles"'); $form->applyFilter('post_title', 'html_filter'); $form->addElement('html_editor', 'post_text', get_lang('Text'), null, api_is_allowed_to_edit(null, true) ? array('ToolbarSet' => 'Forum', 'Width' => '100%', 'Height' => '400') : array('ToolbarSet' => 'ForumStudent', 'Width' => '100%', 'Height' => '400', 'UserStatus' => 'student')); $form->addRule('post_text', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('advanced_settings', '<a href="javascript://" onclick="return advanced_parameters()"><span id="img_plus_and_minus">' . Display::return_icon('div_show.gif', get_lang('Show'), array('style' => 'vertical-align:middle')) . '' . get_lang('AdvancedParameters') . '</span></a>'); $form->addElement('html', '<div id="id_qualify" style="display:none">'); if (!isset($_GET['edit'])) { if (Gradebook::is_active()) { $form->addElement('label', '<strong>' . get_lang('AlterQualifyThread') . '</strong>'); $form->addElement('checkbox', 'thread_qualify_gradebook', '', get_lang('QualifyThreadGradebook'), 'onclick="javascript: if(this.checked){document.getElementById(\'options_field\').style.display = \'block\';}else{document.getElementById(\'options_field\').style.display = \'none\';}"'); $link_info = is_resource_in_course_gradebook(api_get_course_id(), 5, $_GET['thread'], api_get_session_id()); if (!empty($link_info)) { $defaults['thread_qualify_gradebook'] = true; $defaults['category_id'] = $link_info['category_id']; } else { $defaults['thread_qualify_gradebook'] = false; $defaults['category_id'] = ''; } } else { $form->addElement('hidden', 'thread_qualify_gradebook', false); $defaults['thread_qualify_gradebook'] = false; } if (!empty($defaults['thread_qualify_gradebook'])) { $form->addElement('html', '<div id="options_field" style="display:block">'); } else { $form->addElement('html', '<div id="options_field" style="display:none">'); } //Loading gradebook select load_gradebook_select_in_tool($form); $form->addElement('text', 'numeric_calification', get_lang('QualificationNumeric'), 'value="' . $current_thread['thread_qualify_max'] . '" style="width:40px"'); $form->applyFilter('numeric_calification', 'html_filter'); $form->addElement('text', 'calification_notebook_title', get_lang('TitleColumnGradebook'), 'value="' . $current_thread['thread_title_qualify'] . '"'); $form->applyFilter('calification_notebook_title', 'html_filter'); $form->addElement('text', 'weight_calification', array(get_lang('QualifyWeight'), null, ''), 'value="' . $current_thread['thread_weight'] . '" style="width:40px"'); $form->applyFilter('weight_calification', 'html_filter'); $form->addElement('html', '</div>'); } if ($forum_setting['allow_post_notification']) { $form->addElement('checkbox', 'post_notification', '', get_lang('NotifyByEmail') . ' (' . $current_post['email'] . ')'); } if ($forum_setting['allow_sticky'] && api_is_allowed_to_edit(null, true) && $current_post['post_parent_id'] == 0) { // The sticky checkbox only appears when it is the first post of a thread. $form->addElement('checkbox', 'thread_sticky', '', get_lang('StickyPost')); if ($current_thread['thread_sticky'] == 1) { $defaults['thread_sticky'] = true; } } if ($current_forum['allow_attachments'] == '1' || api_is_allowed_to_edit(null, true)) { if (empty($form_values) && !isset($_POST['SubmitPost'])) { //edit_added_resources('forum_post', $current_post['post_id']); } } $form->addElement('html', '</div>'); $form->addElement('style_submit_button', 'SubmitPost', get_lang('ModifyThread'), 'class="save"'); // Setting the default values for the form elements. $defaults['post_title'] = $current_post['post_title']; $defaults['post_text'] = $current_post['post_text']; if ($current_post['post_notification'] == 1) { $defaults['post_notification'] = true; } if (!empty($form_values)) { $defaults['post_notification'] = Security::remove_XSS($form_values['post_notification']); $defaults['thread_sticky'] = Security::remove_XSS($form_values['thread_sticky']); } $form->setDefaults($defaults); // The course admin can make a thread sticky (=appears with special icon and always on top). $form->addRule('post_title', get_lang('ThisFieldIsRequired'), 'required'); // Validation or display if ($form->validate()) { $values = $form->exportValues(); if ($values['thread_qualify_gradebook'] == '1' && empty($values['weight_calification'])) { Display::display_error_message(get_lang('YouMustAssignWeightOfQualification') . ' <a href="javascript:window.back()">' . get_lang('Back') . '</a>', false); return false; } return $values; } else { // Delete from $_SESSION forum attachment from other posts clearAttachedFiles($current_post['post_id']); // Get forum attachment ajax table to add it to form $fileData = getAttachmentsAjaxTable($current_post['post_id'], $current_forum['forum_id']); $form->addElement('html', $fileData); $form->display(); } }