function lp_upload_quiz_main() { // variable initialisation $lp_id = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : null; $form = new FormValidator('upload', 'POST', api_get_self() . '?' . api_get_cidreq() . '&lp_id=' . $lp_id, '', array('enctype' => 'multipart/form-data')); $form->addElement('header', get_lang('ImportExcelQuiz')); $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload')); $link = '<a href="../exercice/quiz_template.xls">' . Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate')) . get_lang('DownloadExcelTemplate') . '</a>'; $form->addElement('label', '', $link); $table = new HTML_Table(array('class' => 'table')); $tableList = array(UNIQUE_ANSWER => get_lang('UniqueSelect'), MULTIPLE_ANSWER => get_lang('MultipleSelect'), FILL_IN_BLANKS => get_lang('FillBlanks'), MATCHING => get_lang('Matching'), FREE_ANSWER => get_lang('FreeAnswer'), GLOBAL_MULTIPLE_ANSWER => get_lang('GlobalMultipleAnswer')); $table->setHeaderContents(0, 0, get_lang('QuestionType')); $table->setHeaderContents(0, 1, '#'); $row = 1; foreach ($tableList as $key => $label) { $table->setCellContents($row, 0, $label); $table->setCellContents($row, 1, $key); $row++; } $table = $table->toHtml(); $form->addElement('label', get_lang('QuestionType'), $table); $form->addElement('checkbox', 'user_custom_score', null, get_lang('UseCustomScoreForAllQuestions'), array('id' => 'user_custom_score')); $form->addElement('html', '<div id="options" style="display:none">'); $form->addElement('text', 'correct_score', get_lang('CorrectScore')); $form->addElement('text', 'incorrect_score', get_lang('IncorrectScore')); $form->addElement('html', '</div>'); $form->addRule('user_upload_quiz', get_lang('ThisFieldIsRequired'), 'required'); $form->add_progress_bar(); $form->addButtonUpload(get_lang('Upload'), 'submit_upload_quiz'); // Display the upload field $form->display(); }
function lp_upload_quiz_main() { // variable initialisation $lp_id = Security::remove_XSS($_GET['lp_id']); $form = new FormValidator('upload', 'POST', api_get_self() . '?' . api_get_cidreq() . '&lp_id=' . $lp_id, '', array('enctype' => 'multipart/form-data')); $form->addElement('header', get_lang('ImportExcelQuiz')); $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload')); $link = '<a href="../exercice/quiz_template.xls">' . Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate'), null, 16) . get_lang('DownloadExcelTemplate'); $form->addElement('advanced_settings', $link); //button send document $form->addElement('style_submit_button', 'submit_upload_quiz', get_lang('Send'), 'class="upload"'); // Display the upload field $form->display(); }
function lp_upload_quiz_main() { // variable initialisation $lp_id = isset($_GET['lp_id']) ? Security::remove_XSS($_GET['lp_id']) : null; $form = new FormValidator('upload', 'POST', api_get_self() . '?' . api_get_cidreq() . '&lp_id=' . $lp_id, '', array('enctype' => 'multipart/form-data')); $form->addElement('header', get_lang('ImportExcelQuiz')); $form->addElement('file', 'user_upload_quiz', get_lang('FileUpload')); $link = '<a href="../exercice/quiz_template.xls">' . Display::return_icon('export_excel.png', get_lang('DownloadExcelTemplate')) . get_lang('DownloadExcelTemplate') . '</a>'; $form->addElement('label', '', $link); $form->addElement('checkbox', 'user_custom_score', null, get_lang('UseCustomScoreForAllQuestions'), array('id' => 'user_custom_score')); $form->addElement('html', '<div id="options" style="display:none">'); $form->addElement('text', 'correct_score', get_lang('CorrectScore')); $form->addElement('text', 'incorrect_score', get_lang('IncorrectScore')); $form->addElement('html', '</div>'); $form->addRule('user_upload_quiz', get_lang('ThisFieldIsRequired'), 'required'); $form->add_progress_bar(); $form->addButtonUpload(get_lang('Send'), 'submit_upload_quiz'); // Display the upload field $form->display(); }
$arrid[] = $questionId; $feedback_form = new FormValidator('frmcomments' . $questionId, 'post', ''); $feedback_form->addElement('html', '<br>'); $renderer =& $feedback_form->defaultRenderer(); $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>'); $renderer->setCustomElementTemplate('<div align="left">{element}</div>'); $comnt = Event::get_comments($id, $questionId); $default = array('comments_' . $questionId => $comnt); if ($useAdvancedEditor) { $feedback_form->addElement('html_editor', 'comments_' . $questionId, null, null, array('ToolbarSet' => 'TestAnswerFeedback', 'Width' => '100%', 'Height' => '120')); } else { $feedback_form->addElement('textarea', 'comments_' . $questionId); } $feedback_form->addElement('html', '<br>'); $feedback_form->setDefaults($default); $feedback_form->display(); echo '</div>'; } else { $comnt = Event::get_comments($id, $questionId); echo '<br />'; if (!empty($comnt)) { echo '<b>' . get_lang('Feedback') . '</b>'; echo '<div id="question_feedback">' . $comnt . '</div>'; } } if ($is_allowedToEdit && $isFeedbackAllowed) { if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { $marksname = "marksName" . $questionId; echo '<div id="' . $marksname . '" style="display:none">'; echo '<form name="marksform_' . $questionId . '" method="post" action="">'; $arrmarks[] = $questionId;
/** * Display the search form for the forum and display the search results * @return void display an HTML search results * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version march 2008, dokeos 1.8.5 */ function forum_search() { // Initialize the object. $form = new FormValidator('forumsearch', 'post', 'forumsearch.php?' . api_get_cidreq()); // Setting the form elements. $form->addElement('header', '', get_lang('ForumSearch')); $form->addElement('text', 'search_term', get_lang('SearchTerm'), array('autofocus')); $form->applyFilter('search_term', 'html_filter'); $form->addElement('static', 'search_information', '', get_lang('ForumSearchInformation')); $form->addButtonSearch(get_lang('Search')); // Setting the rules. $form->addRule('search_term', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('search_term', get_lang('TooShort'), 'minlength', 3); // Validation or display. if ($form->validate()) { $values = $form->exportValues(); $form->setDefaults($values); $form->display(); // Display the search results. display_forum_search_results(stripslashes($values['search_term'])); } else { $form->display(); } }
function display_ical_import_form() { $form = new FormValidator('frm_import_ical', 'post', api_get_self() . '?action=' . Security::remove_XSS($_GET['action']), array('enctype' => 'multipart/form-data')); $form->addElement('header', get_lang('ICalFileImport')); $form->addElement('file', 'ical_import', get_lang('ICalFileImport')); $form->addRule('ical_import', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('button', 'ical_submit', get_lang('Import')); $form->display(); }
$tool_name = get_lang('AddUsersToACourse'); $interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin')); $htmlHeadXtra[] = ' <script type="text/javascript"> function validate_filter() { document.formulaire.form_sent.value=0; document.formulaire.submit(); } </script>'; // displaying the header Display::display_header($tool_name); $link_add_group = '<a href="usergroups.php">' . Display::return_icon('multiple.gif', get_lang('RegistrationByUsersGroups')) . get_lang('RegistrationByUsersGroups') . '</a>'; echo '<div class="actions">' . $link_add_group . '</div>'; $form = new FormValidator('subscribe_user2course'); $form->addElement('header', '', $tool_name); $form->display(); //checking for extra field with filter on $extra_field_list = UserManager::get_extra_fields(); $new_field_list = array(); if (is_array($extra_field_list)) { foreach ($extra_field_list as $extra_field) { //if is enabled to filter and is a "<select>" field type if ($extra_field[8] == 1 && $extra_field[2] == 4) { $new_field_list[] = array('name' => $extra_field[3], 'variable' => $extra_field[1], 'data' => $extra_field[9]); } } } /* React on POSTed request */ if (isset($_POST['form_sent']) && $_POST['form_sent']) { $form_sent = $_POST['form_sent']; $users = is_array($_POST['UserList']) ? $_POST['UserList'] : array();
/** * form to add a category * @todo move to TestCategory.class.php * @param string $action */ function add_category_form($action) { $action = Security::remove_XSS($action); // initiate the object $form = new FormValidator('note', 'post', api_get_self() . '?action=' . $action); // Setting the form elements $form->addElement('header', get_lang('AddACategory')); $form->addElement('text', 'category_name', get_lang('CategoryName'), array('size' => '95')); $form->addHtmlEditor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Height' => '200')); $form->addButtonCreate(get_lang('AddTestCategory'), 'SubmitNote'); // setting the rules $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required'); // The validation or display if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $values = $form->exportValues(); $v_name = Security::remove_XSS($values['category_name'], COURSEMANAGER); $v_description = Security::remove_XSS($values['category_description'], COURSEMANAGER); $objcat = new TestCategory(0, $v_name, $v_description); if ($objcat->addCategoryInBDD()) { Display::display_confirmation_message(get_lang('AddCategoryDone')); } else { Display::display_confirmation_message(get_lang('AddCategoryNameAlreadyExists')); } } Security::clear_token(); } else { display_goback(); $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); $form->display(); } }
/** * Blog admin | Display the form to edit a blog. * */ public static function display_edit_blog_form($blog_id) { $course_id = api_get_course_int_id(); $blog_id = intval($blog_id); $tbl_blogs = Database::get_course_table(TABLE_BLOGS); $sql = "SELECT blog_id, blog_name, blog_subtitle FROM {$tbl_blogs} WHERE c_id = {$course_id} AND blog_id = '" . $blog_id . "'"; $result = Database::query($sql); $blog = Database::fetch_array($result); // the form contained errors but we do not want to lose the changes the user already did if ($_POST) { $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']); $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']); } $form = new FormValidator('edit_blog', 'post', 'blog_admin.php?action=edit&blog_id=' . intval($_GET['blog_id'])); $form->addElement('header', get_lang('EditBlog')); $form->addElement('text', 'blog_name', get_lang('Title')); $form->addElement('textarea', 'blog_subtitle', get_lang('SubTitle')); $form->addElement('hidden', 'edit_blog_submit', 'true'); $form->addElement('hidden', 'blog_id', $blog['blog_id']); $form->addButtonSave(get_lang('Save')); $defaults = array(); $defaults['blog_name'] = $blog['blog_name']; $defaults['blog_subtitle'] = $blog['blog_subtitle']; $form->setDefaults($defaults); $form->display(); }
function display() { parent::display(); }
/** * this function displays the form to upload a new item to the dropbox. * * @author Patrick Cool <*****@*****.**>, Ghent University * @version march 2006 */ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategory, $view) { $course_info = api_get_course_info(); $_user = api_get_user_info(); $is_courseAdmin = api_is_course_admin(); $is_courseTutor = api_is_course_tutor(); $origin = isset($_GET['origin']) ? $_GET['origin'] : null; $token = Security::get_token(); $dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); $form = new FormValidator('sent_form', 'post', api_get_self() . '?view_received_category=' . $viewReceivedCategory . '&view_sent_category=' . $viewSentCategory . '&view=' . $view . '&' . api_get_cidreq(), null, array('enctype' => 'multipart/form-data', 'onsubmit' => 'javascript: return checkForm(this);')); $form->addElement('header', get_lang('UploadNewFile')); $form->addElement('hidden', 'MAX_FILE_SIZE', dropbox_cnf('maxFilesize')); $form->addElement('hidden', 'dropbox_unid', $dropbox_unid); $form->addElement('hidden', 'sec_token', $token); $form->addElement('hidden', 'origin', $origin); $form->addElement('file', 'file', get_lang('UploadFile'), array('onChange' => 'javascript: checkfile(this.value);')); if (dropbox_cnf('allowOverwrite')) { $form->addElement('checkbox', 'cb_overwrite', null, get_lang('OverwriteFile'), array('id' => 'cb_overwrite')); } // List of all users in this course and all virtual courses combined with it if (api_get_session_id()) { $complete_user_list_for_dropbox = array(); if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) { $complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id()); } $complete_user_list2 = CourseManager::get_coach_list_from_course_code($course_info['code'], api_get_session_id()); $complete_user_list_for_dropbox = array_merge($complete_user_list_for_dropbox, $complete_user_list2); } else { if (api_get_setting('dropbox_allow_student_to_student') == 'true' || $_user['status'] != STUDENT) { $complete_user_list_for_dropbox = CourseManager::get_user_list_from_course_code($course_info['code'], api_get_session_id()); } else { $complete_user_list_for_dropbox = CourseManager::get_teacher_list_from_course_code($course_info['code'], false); } } if (!empty($complete_user_list_for_dropbox)) { foreach ($complete_user_list_for_dropbox as $k => $e) { $complete_user_list_for_dropbox[$k] = $e + array('lastcommafirst' => api_get_person_name($e['firstname'], $e['lastname'])); } $complete_user_list_for_dropbox = TableSort::sort_table($complete_user_list_for_dropbox, 'lastcommafirst'); } /* Create the options inside the select box: List all selected users their user id as value and a name string as display */ $current_user_id = ''; $options = array(); foreach ($complete_user_list_for_dropbox as $current_user) { if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin || dropbox_cnf('allowStudentToStudent') || $current_user['status'] != 5 || $current_user['tutor_id'] == 1) && $current_user['user_id'] != $_user['user_id']) { // Don't include yourself. if ($current_user['user_id'] == $current_user_id) { continue; } $full_name = $current_user['lastcommafirst']; $current_user_id = $current_user['user_id']; $options['user_' . $current_user_id] = $full_name; //echo '<option value="user_' . $current_user_id . '">' . $full_name . '</option>'; } } /* * Show groups */ if (($dropbox_person->isCourseTutor || $dropbox_person->isCourseAdmin) && dropbox_cnf('allowGroup') || dropbox_cnf('allowStudentToStudent')) { $complete_group_list_for_dropbox = GroupManager::get_group_list(null, dropbox_cnf('courseId')); if (count($complete_group_list_for_dropbox) > 0) { foreach ($complete_group_list_for_dropbox as $current_group) { if ($current_group['number_of_members'] > 0) { //echo '<option value="group_'.$current_group['id'].'">G: '.$current_group['name'].' - '.$current_group['number_of_members'].' '.get_lang('Users').'</option>'; $options['group_' . $current_group['id']] = 'G: ' . $current_group['name'] . ' - ' . $current_group['number_of_members'] . ' ' . get_lang('Users'); } } } } if (dropbox_cnf('allowJustUpload')) { //echo '<option value="upload">'.get_lang('JustUploadInSelect').'</option>'; //echo '<option value="user_'.$_user['user_id'].'">'.get_lang('JustUploadInSelect').'</option>'; $options['user_' . $_user['user_id']] = get_lang('JustUploadInSelect'); } $form->addElement('select', 'recipients', get_lang('SendTo'), $options, array('multiple' => 'multiple', 'size' => '10', 'class' => 'span4')); $form->addElement('button', 'submitWork', get_lang('Upload')); $form->display(); }
function show_form_send_message() { global $isAdmin; global $ticket; global $subject; global $plugin; Display::div('', array('span2')); $form = new FormValidator('send_ticket', 'POST', api_get_self() . '?ticket_id=' . $ticket['ticket']['ticket_id'], '', array('enctype' => 'multipart/form-data', 'onsubmit' => 'return validate()', 'class' => 'span9 offset1 form-horizontal')); $form->addElement('text', 'subject', get_lang('Subject'), array('for' => 'subject', 'value' => $subject, 'style' => 'width: 540px;')); $form->addElement('hidden', 'ticket_id', $_GET['ticket_id']); $form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '550', 'Height' => '250')); if ($isAdmin) { $form->addElement('checkbox', 'confirmation', null, $plugin->get_lang('RequestConfirmation')); } $form->addElement('html', '<span id="filepaths">'); $form->addElement('html', '<div id="filepath_1">'); $form->addElement('file', 'attach_1', get_lang('FilesAttachment')); $form->addElement('html', '</div>'); $form->addElement('html', '</span>'); $form->addElement('html', '<div class="controls">'); $form->addElement('html', '<span id="link-more-attach" >'); $form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>'); $form->addElement('html', '</span>'); $form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')'); $form->addElement('html', '<br/>'); $form->addElement('button', 'compose', get_lang('SendMessage'), null, null, null, 'save'); $form->display(); }
/** * Add (or edit) a template. This function displays the form and also takes care of uploading the image and storing the information in the database * * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version August 2008 * @since Dokeos 1.8.6 */ function add_edit_template() { // initiate the object $form = new FormValidator('template', 'post', 'settings.php?category=Templates&action=' . $_GET['action'] . '&id=' . $_GET['id']); // settting the form elements: the header if ($_GET['action'] == 'add') { $title = get_lang('AddTemplate'); } else { $title = get_lang('EditTemplate'); } $form->addElement('header', '', $title); // settting the form elements: the title of the template $form->add_textfield('title', get_lang('Title'), false); // settting the form elements: the content of the template (wysiwyg editor) $form->addElement('html_editor', 'template_text', get_lang('Text')); // settting the form elements: the form to upload an image to be used with the template $form->addElement('file', 'template_image', get_lang('Image'), ''); // settting the form elements: a little bit information about the template image $form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70')); // getting all the information of the template when editing a template if ($_GET['action'] == 'edit') { // Database table definition $table_system_template = Database::get_main_table('system_template'); $sql = "SELECT * FROM {$table_system_template} WHERE id = '" . Database::escape_string($_GET['id']) . "'"; $result = api_sql_query($sql, __FILE__, __LINE__); $row = Database::fetch_array($result); $defaults['template_id'] = $_GET['id']; $defaults['template_text'] = $row['content']; $defaults['title'] = $row['title']; // adding an extra field: a hidden field with the id of the template we are editing $form->addElement('hidden', 'template_id'); // adding an extrra field: a preview of the image that is currently used if (!empty($row['image'])) { $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_PATH) . 'home/default_platform_document/' . $row['image'] . '" alt="' . get_lang('TemplatePreview') . '"/>'); } else { $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_PATH) . 'home/default_platform_document/noimage.gif" alt="' . get_lang('NoTemplatePreview') . '"/>'); } // setting the information of the template that we are editing $form->setDefaults($defaults); } // settting the form elements: the submit button $form->addElement('style_submit_button', 'submit', get_lang('Ok'), 'class="save"'); // setting the rules: the required fields $form->addRule('title', '<div class="required">' . get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('template_text', '<div class="required">' . get_lang('ThisFieldIsRequired'), 'required'); // if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed) if ($form->validate()) { // exporting the values $values = $form->exportValues(); // upload the file if (!empty($_FILES['template_image']['name'])) { include_once api_get_path(LIBRARY_PATH) . 'fileUpload.lib.php'; $upload_ok = process_uploaded_file($_FILES['template_image']); if ($upload_ok) { // Try to add an extension to the file if it hasn't one $new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']); // upload dir $upload_dir = api_get_path(SYS_PATH) . 'home/default_platform_document/'; // create dir if not exists if (!is_dir($upload_dir)) { $perm = api_get_setting('permissions_for_new_directories'); $perm = octdec(!empty($perm) ? $perm : '0770'); $res = @mkdir($upload_dir, $perm); } // resize image to max default and upload require_once api_get_path(LIBRARY_PATH) . 'image.lib.php'; $temp = new image($_FILES['template_image']['tmp_name']); $picture_infos = @getimagesize($_FILES['template_image']['tmp_name']); $max_width_for_picture = 100; if ($picture_infos[0] > $max_width_for_picture) { $thumbwidth = $max_width_for_picture; if (empty($thumbwidth) or $thumbwidth == 0) { $thumbwidth = $max_width_for_picture; } $new_height = round($thumbwidth / $picture_infos[0] * $picture_infos[1]); $temp->resize($thumbwidth, $new_height, 0); } $type = $picture_infos[2]; switch (!empty($type)) { case 2: $temp->send_image('JPG', $upload_dir . $new_file_name); break; case 3: $temp->send_image('PNG', $upload_dir . $new_file_name); break; case 1: $temp->send_image('GIF', $upload_dir . $new_file_name); break; } } } // store the information in the database (as insert or as update) $table_system_template = Database::get_main_table('system_template'); if ($_GET['action'] == 'add') { $sql = "INSERT INTO {$table_system_template} (title, content, image) VALUES ('" . Database::escape_string($values['title']) . "','" . Database::escape_string($values['template_text']) . "','" . Database::escape_string($new_file_name) . "')"; $result = api_sql_query($sql, __FILE__, __LINE__); // display a feedback message Display::display_confirmation_message('TemplateAdded'); echo '<a href="settings.php?category=Templates&action=add">' . Display::return_icon('add_template.gif', get_lang('AddTemplate')) . get_lang('AddTemplate') . '</a>'; } else { $sql = "UPDATE {$table_system_template} set title = '" . Database::escape_string($values['title']) . "',\n\t\t\t\t\t\t\t\t\t\t\t \t\t content = '" . Database::escape_string($values['template_text']) . "'"; if (!empty($new_file_name)) { $sql .= ", image = '" . Database::escape_string($new_file_name) . "'"; } $sql .= " WHERE id='" . Database::escape_string($_GET['id']) . "'"; $result = api_sql_query($sql, __FILE__, __LINE__); // display a feedback message Display::display_confirmation_message('TemplateEdited'); } display_templates(); } else { // display the form $form->display(); } }
/** * This function displays the form to add a new category. * * @param $category_name this parameter is the name of the category (used when no section is selected) * @param $id this is the id of the category we are editing. * * @author Patrick Cool <*****@*****.**>, Ghent University @author Julio Montoya UI changes * * @version march 2006 */ function display_addcategory_form($category_name = '', $id = '', $action) { $dropbox_cnf = getDropboxConf(); $course_id = api_get_course_int_id(); $title = get_lang('AddNewCategory'); if (isset($id) && $id != '') { // retrieve the category we are editing $sql = "SELECT * FROM " . $dropbox_cnf['tbl_category'] . "\n WHERE c_id = {$course_id} AND cat_id = " . intval($id) . ""; $result = Database::query($sql); $row = Database::fetch_array($result); if (empty($category_name)) { // after an edit with an error we do not want to return to the // original name but the name we already modified. // (happens when createinrecievedfiles AND createinsentfiles are not checked) $category_name = $row['cat_name']; } if ($row['received'] == '1') { $target = 'received'; } if ($row['sent'] == '1') { $target = 'sent'; } $title = get_lang('EditCategory'); } if ($action == 'addreceivedcategory') { $target = 'received'; } if ($action == 'addsentcategory') { $target = 'sent'; } if ($action == 'editcategory') { $text = get_lang('ModifyCategory'); } elseif ($action == 'addreceivedcategory' || $action == 'addsentcategory') { $text = get_lang('CreateCategory'); } $form = new FormValidator('add_new_category', 'post', api_get_self() . '?' . api_get_cidreq() . '&view=' . Security::remove_XSS($_GET['view'])); $form->addElement('header', $title); if (isset($id) && $id != '') { $form->addElement('hidden', 'edit_id', intval($id)); } $form->addElement('hidden', 'action', Security::remove_XSS($action)); $form->addElement('hidden', 'target', Security::remove_XSS($target)); $form->addElement('text', 'category_name', get_lang('CategoryName')); $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required'); $form->addButtonSave($text, 'StoreCategory'); $defaults = array(); $defaults['category_name'] = $category_name; $form->setDefaults($defaults); $form->display(); }
/** * Display the search form for the forum and display the search results * @return void display an HTML search results * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version march 2008, dokeos 1.8.5 */ function forum_search() { global $origin; // Initialize the object. $form = new FormValidator('forumsearch', 'post', 'forumsearch.php?origin=' . $origin . ''); // Settting the form elements. $form->addElement('header', '', get_lang('ForumSearch')); $form->addElement('text', 'search_term', get_lang('SearchTerm'), 'class="input_titles" id="search_title"'); $form->applyFilter('search_term', 'html_filter'); $form->addElement('static', 'search_information', '', get_lang('ForumSearchInformation')); $form->addElement('style_submit_button', null, get_lang('Search'), 'class="search"'); // Setting the rules. $form->addRule('search_term', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('search_term', get_lang('TooShort'), 'minlength', 3); // Validation or display. if ($form->validate()) { $values = $form->exportValues(); $form->setDefaults($values); $form->display(); // Display the search results. display_forum_search_results(stripslashes($values['search_term'])); } else { $form->display(); } }
function add_category_form($in_action, $type = 'simple') { $in_action = Security::remove_XSS($in_action); // Initiate the object $form = new FormValidator('note', 'post', api_get_self() . '?' . api_get_cidreq() . '&action=' . $in_action . "&type=" . $type); // Setting the form elements $form->addElement('header', get_lang('AddACategory')); $form->addElement('text', 'category_name', get_lang('CategoryName'), array('class' => 'span6')); $form->add_html_editor('category_description', get_lang('CategoryDescription'), false, false, array('ToolbarSet' => 'test_category', 'Width' => '90%', 'Height' => '200')); $form->addElement('select', 'parent_id', get_lang('Parent'), array(), array('id' => 'parent_id')); $form->addElement('style_submit_button', 'SubmitNote', get_lang('AddTestCategory'), 'class="add"'); // Setting the rules $form->addRule('category_name', get_lang('ThisFieldIsRequired'), 'required'); // The validation or display if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $values = $form->getSubmitValues(); $parent_id = isset($values['parent_id']) && isset($values['parent_id'][0]) ? $values['parent_id'][0] : null; $objcat = new Testcategory(0, $values['category_name'], $values['category_description'], $parent_id, $type, api_get_course_int_id()); if ($objcat->addCategoryInBDD()) { Display::display_confirmation_message(get_lang('AddCategoryDone')); } else { Display::display_confirmation_message(get_lang('AddCategoryNameAlreadyExists')); } } Security::clear_token(); display_add_category($type); display_categories($type); } else { display_goback($type); $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); $form->display(); } }
/** * */ function show_form_send_ticket() { global $types, $plugin; echo '<div class="divTicket">'; //Category List $categoryList = array(); foreach ($types as $type) { $categoryList[$type['category_id']] = $type['name'] . ": " . $type['description']; } //End Category List //Status List $statusList = array(); $statusAttributes = array('style' => 'display: none;', 'id' => 'status_id', 'for' => 'status_id'); $statusList[NEWTCK] = $plugin->get_lang('StatusNew'); if (api_is_platform_admin()) { $statusAttributes = array('id' => 'status_id', 'for' => 'status_id', 'style' => 'width: 562px;'); $statusList[PENDING] = $plugin->get_lang('StatusPending'); $statusList[UNCONFIRMED] = $plugin->get_lang('StatusUnconfirmed'); $statusList[CLOSE] = $plugin->get_lang('StatusClose'); $statusList[REENVIADO] = $plugin->get_lang('StatusForwarded'); } //End Status List //Source List $sourceList = array(); $sourceAttributes = array('style' => 'display: none;', 'id' => 'source_id', 'for' => 'source_id'); $sourceList[SRC_PLATFORM] = $plugin->get_lang('SrcPlatform'); if (api_is_platform_admin()) { $sourceAttributes = array('id' => 'source_id', 'for' => 'source_id', 'style' => 'width: 562px;'); $sourceList[SRC_EMAIL] = $plugin->get_lang('SrcEmail'); $sourceList[SRC_PHONE] = $plugin->get_lang('SrcPhone'); $sourceList[SRC_PRESC] = $plugin->get_lang('SrcPresential'); } //End Source List //Priority List $priorityList = array(); $priorityList[NORMAL] = $plugin->get_lang('PriorityNormal'); $priorityList[HIGH] = $plugin->get_lang('PriorityHigh'); $priorityList[LOW] = $plugin->get_lang('PriorityLow'); //End Priority List $form = new FormValidator('send_ticket', 'POST', api_get_self(), "", array('enctype' => 'multipart/form-data', 'onsubmit' => 'return validate()', 'class' => 'span8 offset1 form-horizontal')); $form->addElement('hidden', 'user_id_request', '', array('id' => 'user_id_request')); $form->addElement('hidden', 'project_id', '', array('id' => 'project_id')); $form->addElement('hidden', 'other_area', '', array('id' => 'other_area')); $form->addElement('hidden', 'email', '', array('id' => 'email')); $form->addElement('select', 'category_id', get_lang('Category'), $categoryList, array('onchange' => 'changeType()', 'id' => 'category_id', 'for' => 'category_id', 'style' => 'width: 562px;')); $form->addElement('html', Display::div('', array('id' => 'user_request'))); $form->addElement('select', 'status_id', get_lang('Status'), $statusList, $statusAttributes); $form->addElement('select', 'source_id', $plugin->get_lang('Source'), $sourceList, $sourceAttributes); $form->addElement('text', 'subject', get_lang('Subject'), array('id' => 'subject', 'style' => 'width: 550px;')); $form->addElement('text', 'personal_email', $plugin->get_lang('PersonalEmail'), array('id' => 'personal_email', 'style' => 'width: 550px;')); $form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Profile', 'Width' => '600', 'Height' => '250')); $form->addElement('text', 'phone', get_lang('Phone') . ' (' . $plugin->get_lang('Optional') . ')', array('id' => 'phone')); $form->addElement('select', 'priority_id', $plugin->get_lang('Priority'), $priorityList, array('id' => 'priority_id', 'for' => 'priority_id')); $form->addElement('html', '<span id="filepaths">'); $form->addElement('html', '<div id="filepath_1">'); $form->addElement('file', 'attach_1', get_lang('FilesAttachment')); $form->addElement('html', '</div>'); $form->addElement('html', '</span>'); $form->addElement('html', '<div class="controls">'); $form->addElement('html', '<span id="link-more-attach" >'); $form->addElement('html', '<span class="label label-info" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</span>'); $form->addElement('html', '</span>'); $form->addElement('html', '(' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message_max_upload_filesize'))) . ')'); $form->addElement('html', '<br/>'); $form->addElement('button', 'compose', get_lang('SendMessage'), null, null, null, 'save', array('id' => 'btnsubmit')); $form->display(); }
/** * @param string $action */ public function getSearchPages($action) { echo '<div class="actions">' . get_lang('SearchPages') . '</div>'; if (isset($_GET['mode_table'])) { if (!isset($_GET['SearchPages_table_page_nr'])) { $_GET['search_term'] = isset($_POST['search_term']) ? $_POST['search_term'] : ''; $_GET['search_content'] = isset($_POST['search_content']) ? $_POST['search_content'] : ''; $_GET['all_vers'] = isset($_POST['all_vers']) ? $_POST['all_vers'] : ''; } self::display_wiki_search_results($_GET['search_term'], $_GET['search_content'], $_GET['all_vers']); } else { // initiate the object $form = new FormValidator('wiki_search', 'post', api_get_self() . '?cidReq=' . api_get_course_id() . '&action=' . api_htmlentities($action) . '&session_id=' . api_get_session_id() . '&group_id=' . api_get_group_id() . '&mode_table=yes1'); // Setting the form elements $form->addText('search_term', get_lang('SearchTerm'), true, array('autofocus' => 'autofocus')); $form->addElement('checkbox', 'search_content', null, get_lang('AlsoSearchContent')); $form->addElement('checkbox', 'all_vers', null, get_lang('IncludeAllVersions')); $form->addButtonSearch(get_lang('Search'), 'SubmitWikiSearch'); // setting the rules $form->addRule('search_term', get_lang('TooShort'), 'minlength', 3); //TODO: before fixing the pagination rules worked, not now if ($form->validate()) { $form->display(); $values = $form->exportValues(); self::display_wiki_search_results($values['search_term'], $values['search_content'], $values['all_vers']); } else { $form->display(); } } }
echo Security::remove_XSS($_SESSION['gradebook_dest']) . '?' . $my_api_cidreq; ?> &selectcat=<?php echo $my_selectcat; ?> "> <?php echo Display::return_icon('back.png', get_lang('FolderView'), '', ICON_SIZE_MEDIUM); ?> </a> </div> <?php $form->display(); $formNormal = new FormValidator('normal_weight', 'post', $currentUrl); $formNormal->addHeader(get_lang('EditWeight')); $formNormal->display(); //$warning_message = sprintf(get_lang('TotalWeightMustBeX'), $masked_total); $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $original_total); Display::display_warning_message($warning_message, false); ?> <form method="post" action="gradebook_edit_all.php?<?php echo $my_api_cidreq; ?> &selectcat=<?php echo $my_selectcat; ?> "> <table class="data_table"> <tr class="row_odd"> <th style="width: 35px;"><?php echo get_lang('Type');
/** * Add (or edit) a template. This function displays the form and also takes * care of uploading the image and storing the information in the database * * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version August 2008 * @since Dokeos 1.8.6 */ function add_edit_template() { // Initialize the object. $id = isset($_GET['id']) ? '&id=' . Security::remove_XSS($_GET['id']) : ''; $form = new FormValidator('template', 'post', 'settings.php?category=Templates&action=' . Security::remove_XSS($_GET['action']) . $id); // Setting the form elements: the header. if ($_GET['action'] == 'add') { $title = get_lang('AddTemplate'); } else { $title = get_lang('EditTemplate'); } $form->addElement('header', '', $title); // Setting the form elements: the title of the template. $form->addText('title', get_lang('Title'), false); // Setting the form elements: the content of the template (wysiwyg editor). $form->addHtmlEditor('template_text', get_lang('Text'), false, false, array('ToolbarSet' => 'AdminTemplates', 'Width' => '100%', 'Height' => '400')); // Setting the form elements: the form to upload an image to be used with the template. $form->addElement('file', 'template_image', get_lang('Image'), ''); // Setting the form elements: a little bit information about the template image. $form->addElement('static', 'file_comment', '', get_lang('TemplateImageComment100x70')); // Getting all the information of the template when editing a template. if ($_GET['action'] == 'edit') { // Database table definition. $table_system_template = Database::get_main_table('system_template'); $sql = "SELECT * FROM {$table_system_template} WHERE id = " . intval($_GET['id']) . ""; $result = Database::query($sql); $row = Database::fetch_array($result); $defaults['template_id'] = intval($_GET['id']); $defaults['template_text'] = $row['content']; // Forcing get_lang(). $defaults['title'] = get_lang($row['title']); // Adding an extra field: a hidden field with the id of the template we are editing. $form->addElement('hidden', 'template_id'); // Adding an extra field: a preview of the image that is currently used. if (!empty($row['image'])) { $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_APP_PATH) . 'home/default_platform_document/template_thumb/' . $row['image'] . '" alt="' . get_lang('TemplatePreview') . '"/>'); } else { $form->addElement('static', 'template_image_preview', '', '<img src="' . api_get_path(WEB_APP_PATH) . 'home/default_platform_document/template_thumb/noimage.gif" alt="' . get_lang('NoTemplatePreview') . '"/>'); } // Setting the information of the template that we are editing. $form->setDefaults($defaults); } // Setting the form elements: the submit button. $form->addButtonSave(get_lang('Ok'), 'submit'); // Setting the rules: the required fields. $form->addRule('template_image', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('title', get_lang('ThisFieldIsRequired'), 'required'); $form->addRule('template_text', get_lang('ThisFieldIsRequired'), 'required'); // if the form validates (complies to all rules) we save the information, else we display the form again (with error message if needed) if ($form->validate()) { $check = Security::check_token('post'); if ($check) { // Exporting the values. $values = $form->exportValues(); // Upload the file. if (!empty($_FILES['template_image']['name'])) { $upload_ok = process_uploaded_file($_FILES['template_image']); if ($upload_ok) { // Try to add an extension to the file if it hasn't one. $new_file_name = add_ext_on_mime(stripslashes($_FILES['template_image']['name']), $_FILES['template_image']['type']); // The upload directory. $upload_dir = api_get_path(SYS_APP_PATH) . 'home/default_platform_document/template_thumb/'; // Create the directory if it does not exist. if (!is_dir($upload_dir)) { mkdir($upload_dir, api_get_permissions_for_new_directories()); } // Resize the preview image to max default and upload. $temp = new Image($_FILES['template_image']['tmp_name']); $picture_info = $temp->get_image_info(); $max_width_for_picture = 100; if ($picture_info['width'] > $max_width_for_picture) { $temp->resize($max_width_for_picture); } $temp->send_image($upload_dir . $new_file_name); } } // Store the information in the database (as insert or as update). $table_system_template = Database::get_main_table('system_template'); if ($_GET['action'] == 'add') { $content_template = Security::remove_XSS($values['template_text'], COURSEMANAGERLOWSECURITY); $params = ['title' => $values['title'], 'content' => $content_template, 'image' => $new_file_name]; Database::insert($table_system_template, $params); // Display a feedback message. Display::display_confirmation_message(get_lang('TemplateAdded')); echo '<a href="settings.php?category=Templates&action=add">' . Display::return_icon('new_template.png', get_lang('AddTemplate'), '', ICON_SIZE_MEDIUM) . '</a>'; } else { $content_template = '<head>{CSS}<style type="text/css">.text{font-weight: normal;}</style></head><body>' . Database::escape_string($values['template_text']) . '</body>'; $sql = "UPDATE {$table_system_template} set title = '" . Database::escape_string($values['title']) . "', content = '" . $content_template . "'"; if (!empty($new_file_name)) { $sql .= ", image = '" . Database::escape_string($new_file_name) . "'"; } $sql .= " WHERE id = " . intval($_GET['id']) . ""; Database::query($sql); // Display a feedback message. Display::display_confirmation_message(get_lang('TemplateEdited')); } } Security::clear_token(); display_templates(); } else { $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); // Display the form. $form->display(); } }
} $xajax->processRequests(); Display::display_header($tool_name); if ($add_type == 'multiple') { $link_add_type_unique = '<a href="' . api_get_self() . '?add=' . $add . '&add_type=unique">' . Display::return_icon('single.gif') . get_lang('SessionAddTypeUnique') . '</a>'; $link_add_type_multiple = Display::return_icon('multiple.gif') . get_lang('SessionAddTypeMultiple'); } else { $link_add_type_unique = Display::return_icon('single.gif') . get_lang('SessionAddTypeUnique'); $link_add_type_multiple = '<a href="' . api_get_self() . '?add=' . $add . '&add_type=multiple">' . Display::return_icon('multiple.gif') . get_lang('SessionAddTypeMultiple') . '</a>'; } echo '<div class="actions">'; echo '<a href="usergroups.php">' . Display::return_icon('back.png', get_lang('Back'), array(), ICON_SIZE_MEDIUM) . '</a>'; echo Display::url(get_lang('AdvancedSearch'), '#', array('class' => 'advanced_options', 'id' => 'advanced_search')); echo '</div>'; echo '<div id="advanced_search_options" style="display:none">'; $searchForm->display(); echo '</div>'; ?> <form name="formulaire" method="post" action="<?php echo api_get_self(); ?> ?id=<?php echo $id; if (!empty($_GET['add'])) { echo '&add=true'; } ?> " style="margin:0px;" <?php if ($ajax_search) { echo ' onsubmit="valide();"';
$number_of_users = count($obj->get_users_by_usergroup($class['id'])); echo '<li>'; echo $class['name']; echo ' (' . $number_of_users . ' ' . get_lang('Users') . ')'; echo '</li>'; } echo '</ul>'; $create_class_groups_form = new FormValidator('create_class_groups_form'); $create_class_groups_form->addElement('hidden', 'action'); if (api_get_setting('allow_group_categories') == 'true') { $group_categories = GroupManager::get_categories(); $cat_options = array(); foreach ($group_categories as $index => $category) { // Don't allow new groups in the virtual course category! if ($category['id'] != GroupManager::VIRTUAL_COURSE_CATEGORY) { $cat_options[$category['id']] = $category['title']; } } $create_class_groups_form->addElement('select', 'group_category', null, $cat_options); } else { $create_class_groups_form->addElement('hidden', 'group_category'); } $create_class_groups_form->addElement('submit', 'submit', get_lang('Ok')); $defaults['group_category'] = GroupManager::DEFAULT_GROUP_CATEGORY; $defaults['action'] = 'create_class_groups'; $create_class_groups_form->setDefaults($defaults); $create_class_groups_form->display(); echo '</blockquote>'; } } Display::display_footer();
/** * Displays a form with all the additionally defined user fields of the profile * and give you the opportunity to include these in the CSV export * * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version 1.8.6 * @since November 2008 */ public static function display_user_overview_export_options() { $message = ''; // include the user manager and formvalidator library if (isset($_GET['export']) && $_GET['export'] == 'options') { // get all the defined extra fields $extrafields = UserManager::get_extra_fields(0, 50, 5, 'ASC', false, 1); // creating the form with all the defined extra fields $form = new FormValidator('exportextrafields', 'post', api_get_self() . "?view=" . Security::remove_XSS($_GET['view']) . '&display=' . Security::remove_XSS($_GET['display']) . '&export=' . Security::remove_XSS($_GET['export'])); if (is_array($extrafields) && count($extrafields) > 0) { foreach ($extrafields as $key => $extra) { $form->addElement('checkbox', 'extra_export_field' . $extra[0], '', $extra[3]); } $form->addButtonSave(get_lang('Ok'), 'submit'); // setting the default values for the form that contains all the extra fields if (is_array($_SESSION['additional_export_fields'])) { foreach ($_SESSION['additional_export_fields'] as $key => $value) { $defaults['extra_export_field' . $value] = 1; } } $form->setDefaults($defaults); } else { $form->addElement('html', Display::display_warning_message(get_lang('ThereAreNotExtrafieldsAvailable'))); } if ($form->validate()) { // exporting the form values $values = $form->exportValues(); // re-initialising the session that contains the additional fields that need to be exported $_SESSION['additional_export_fields'] = array(); // adding the fields that are checked to the session $message = ''; foreach ($values as $field_ids => $value) { if ($value == 1 && strstr($field_ids, 'extra_export_field')) { $_SESSION['additional_export_fields'][] = str_replace('extra_export_field', '', $field_ids); } } // adding the fields that will be also exported to a message string if (is_array($_SESSION['additional_export_fields'])) { foreach ($_SESSION['additional_export_fields'] as $key => $extra_field_export) { $message .= '<li>' . $extrafields[$extra_field_export][3] . '</li>'; } } // Displaying a feedback message if (!empty($_SESSION['additional_export_fields'])) { Display::display_confirmation_message(get_lang('FollowingFieldsWillAlsoBeExported') . ': <br /><ul>' . $message . '</ul>', false); } else { Display::display_confirmation_message(get_lang('NoAdditionalFieldsWillBeExported'), false); } } else { $form->display(); } } else { if (!empty($_SESSION['additional_export_fields'])) { // get all the defined extra fields $extrafields = UserManager::get_extra_fields(0, 50, 5, 'ASC'); foreach ($_SESSION['additional_export_fields'] as $key => $extra_field_export) { $message .= '<li>' . $extrafields[$extra_field_export][3] . '</li>'; } Display::display_normal_message(get_lang('FollowingFieldsWillAlsoBeExported') . ': <br /><ul>' . $message . '</ul>', false); } } }
function form_special_export() { $form = new FormValidator('special_exports', 'post'); $renderer = $form->defaultRenderer(); $renderer->setCustomElementTemplate('<div>{element}</div> '); $form->addElement('radio', 'backup_option', '', get_lang('SpecialCreateFullBackup'), 'full_backup'); $form->addElement('radio', 'backup_option', '', get_lang('SpecialLetMeSelectItems'), 'select_items'); $form->addElement('html', '<br />'); $form->addButtonExport(get_lang('CreateBackup')); $form->add_progress_bar(); $values['backup_option'] = 'full_backup'; $form->setDefaults($values); $form->display(); }
/** * Shows statistics about the time of last visit to each course. */ static function print_course_last_visit() { $access_url_rel_course_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $current_url_id = api_get_current_access_url_id(); $columns[0] = 'c_id'; $columns[1] = 'access_date'; $sql_order[SORT_ASC] = 'ASC'; $sql_order[SORT_DESC] = 'DESC'; $per_page = isset($_GET['per_page']) ? intval($_GET['per_page']) : 10; $page_nr = isset($_GET['page_nr']) ? intval($_GET['page_nr']) : 1; $column = isset($_GET['column']) ? intval($_GET['column']) : 0; $date_diff = isset($_GET['date_diff']) ? intval($_GET['date_diff']) : 60; if (!in_array($_GET['direction'], array(SORT_ASC, SORT_DESC))) { $direction = SORT_ASC; } else { $direction = isset($_GET['direction']) ? $_GET['direction'] : SORT_ASC; } $form = new FormValidator('courselastvisit', 'get'); $form->addElement('hidden', 'report', 'courselastvisit'); $form->add_textfield('date_diff', get_lang('Days'), true); $form->addRule('date_diff', 'InvalidNumber', 'numeric'); $form->addElement('style_submit_button', 'submit', get_lang('Search'), 'class="search"'); if (!isset($_GET['date_diff'])) { $defaults['date_diff'] = 60; } else { $defaults['date_diff'] = Security::remove_XSS($_GET['date_diff']); } $form->setDefaults($defaults); $form->display(); $values = $form->exportValues(); $date_diff = $values['date_diff']; $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); $tableCourse = Database::get_main_table(TABLE_MAIN_COURSE); if (api_is_multiple_url_enabled()) { $sql = "SELECT access_date, c.code FROM {$table} s , {$access_url_rel_course_table} u, {$tableCourse} c\n WHERE c.id = u.c_id AND c.id = s.c_id AND access_url_id='" . $current_url_id . "' " . "GROUP BY access_cours_code " . "HAVING s.c_id <> '' " . "AND DATEDIFF( '" . date('Y-m-d h:i:s') . "' , access_date ) <= " . $date_diff; } else { $sql = "SELECT access_date, c.code FROM {$table} , {$tableCourse} c\n WHERE c_id = c.id\n GROUP BY c_id\n HAVING c_id <> ''AND\n DATEDIFF( '" . date('Y-m-d h:i:s') . "' , access_date ) <= " . $date_diff; } $res = Database::query($sql); $number_of_courses = Database::num_rows($res); $sql .= ' ORDER BY ' . $columns[$column] . ' ' . $sql_order[$direction]; $from = ($page_nr - 1) * $per_page; $sql .= ' LIMIT ' . $from . ',' . $per_page; echo '<p>' . get_lang('LastAccess') . ' >= ' . $date_diff . ' ' . get_lang('Days') . '</p>'; $res = Database::query($sql); if (Database::num_rows($res) > 0) { $courses = array(); while ($obj = Database::fetch_object($res)) { $course = array(); $course[] = '<a href="' . api_get_path(WEB_PATH) . 'courses/' . $obj->code . '">' . $obj->code . ' <a>'; //Allow sort by date hiding the numerical date $course[] = '<span style="display:none;">' . $obj->access_date . '</span>' . api_convert_and_format_date($obj->access_date); $courses[] = $course; } $parameters['date_diff'] = $date_diff; $parameters['report'] = 'courselastvisit'; $table_header[] = array(get_lang("CourseCode"), true); $table_header[] = array(get_lang("LastAccess"), true); Display::display_sortable_table($table_header, $courses, array('column' => $column, 'direction' => $direction), array(), $parameters); } else { echo get_lang('NoSearchResults'); } }
$content_heading_form = new FormValidator('content_heading_form'); $content_heading_form->addElement('hidden', 'cntId'); $content_heading_form->addElement('hidden', 'catId'); $content_heading_form->addElement('hidden', 'uInfo'); $content_heading_form->addElement('static', null, $catToEdit['title'], htmlize($catToEdit['comment'])); if ($catToEdit['nbline'] == 1) { $content_heading_form->addElement('text', 'content', null, array ('size' => 80)); } else { $content_heading_form->addElement('textarea', 'content', null, array ('cols' => 60, 'rows' => $catToEdit['nbline'])); } $content_heading_form->addElement('submit', 'submitContent', get_lang('Ok')); $defaults = $catToEdit; $defaults['cntId'] = $catToEdit['contentId']; $defaults['uInfo'] = $userIdViewed; $content_heading_form->setDefaults($defaults); $content_heading_form->display(); } elseif ($displayMode == "viewMainInfoEdit") { /* CATEGORIES MAIN INFO : EDIT */ $mainUserInfo = get_main_user_info($userIdViewed, $courseCode); if ($mainUserInfo) { ($mainUserInfo['status'] == COURSEMANAGER) ? $courseAdminChecked = "checked" : $courseAdminChecked = ""; if ($current_session_id) { ($is_session_course_coach)? $tutorChecked = "checked" : $tutorChecked = ""; } else { ($mainUserInfo['tutor_id'] == 1) ? $tutorChecked = "checked" : $tutorChecked = ""; }