/** * @param array $group_list * @param int $category_id */ static function process_groups($group_list, $category_id = null) { global $origin, $charset; $category_id = intval($category_id); $totalRegistered = 0; $group_data = array(); $user_info = api_get_user_info(); $session_id = api_get_session_id(); $user_id = $user_info['user_id']; $orig = isset($origin) ? $origin : null; foreach ($group_list as $this_group) { // Validation when belongs to a session $session_img = api_get_session_image($this_group['session_id'], $user_info['status']); // All the tutors of this group $tutorsids_of_group = self::get_subscribed_tutors($this_group['id'], true); // Create a new table-row $row = array(); // Checkbox if (api_is_allowed_to_edit(false, true) && count($group_list) > 1) { $row[] = $this_group['id']; } // Group name if ((api_is_allowed_to_edit(false, true) || in_array($user_id, $tutorsids_of_group) || $this_group['is_member'] || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_FORUM) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_DOCUMENTS) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_CALENDAR) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_ANNOUNCEMENT) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WORK) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WIKI)) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) { $group_name = '<a href="group_space.php?cidReq=' . api_get_course_id() . '&origin=' . $orig . '&gidReq=' . $this_group['id'] . '">' . Security::remove_XSS($this_group['name']) . '</a> '; if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) { $group_name .= Display::label(get_lang('OneMyGroups'), 'success'); } elseif ($this_group['is_member']) { $group_name .= Display::label(get_lang('MyGroup'), 'success'); } if (api_is_allowed_to_edit() && !empty($this_group['session_name'])) { $group_name .= ' (' . $this_group['session_name'] . ')'; } $group_name .= $session_img; $row[] = $group_name . '<br />' . stripslashes(trim($this_group['description'])); } else { $row[] = $this_group['name'] . '<br />' . stripslashes(trim($this_group['description'])); } // Tutor name $tutor_info = null; if (count($tutorsids_of_group) > 0) { foreach ($tutorsids_of_group as $tutor_id) { $tutor = api_get_user_info($tutor_id); $username = api_htmlentities(sprintf(get_lang('LoginX'), $tutor['username']), ENT_QUOTES); if (api_get_setting('show_email_addresses') == 'true') { $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', '; } else { if (api_is_allowed_to_edit()) { $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', '; } else { $tutor_info .= Display::tag('span', api_get_person_name($tutor['firstName'], $tutor['lastName']), array('title' => $username)) . ', '; } } } } $tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2); $row[] = $tutor_info; // Max number of members in group $max_members = $this_group['maximum_number_of_members'] == self::MEMBER_PER_GROUP_NO_LIMIT ? ' ' : ' / ' . $this_group['maximum_number_of_members']; // Number of members in group $row[] = $this_group['number_of_members'] . $max_members; // Self-registration / unregistration if (!api_is_allowed_to_edit(false, true)) { if (self::is_self_registration_allowed($user_id, $this_group['id'])) { $row[] = '<a class = "btn" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&action=self_reg&group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfRegInf') . '</a>'; } elseif (self::is_self_unregistration_allowed($user_id, $this_group['id'])) { $row[] = '<a class = "btn" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&action=self_unreg&group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfUnRegInf') . '</a>'; } else { $row[] = '-'; } } $url = api_get_path(WEB_CODE_PATH) . 'group/'; // Edit-links if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) { $edit_actions = '<a href="' . $url . 'settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '" title="' . get_lang('Edit') . '">' . Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL) . '</a> '; $edit_actions .= '<a href="' . $url . 'member_settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '" title="' . get_lang('GroupMembers') . '">' . Display::return_icon('user.png', get_lang('GroupMembers'), '', ICON_SIZE_SMALL) . '</a> '; $edit_actions .= '<a href="' . $url . 'group_overview.php?action=export&type=xls&' . api_get_cidreq(true, false) . '&id=' . $this_group['id'] . '" title="' . get_lang('ExportUsers') . '">' . Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_SMALL) . '</a> '; /*$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=empty_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'. Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).'</a> ';*/ $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=fill_one&id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('FillGroup') . '">' . Display::return_icon('fill.png', get_lang('FillGroup'), '', ICON_SIZE_SMALL) . '</a> '; $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=delete_one&id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('Delete') . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a> '; $row[] = $edit_actions; } if (!empty($this_group['nbMember'])) { $totalRegistered = $totalRegistered + $this_group['nbMember']; } $group_data[] = $row; } // end loop $table = new SortableTableFromArrayConfig($group_data, 1, 20, 'group_category_' . $category_id); $table->set_additional_parameters(array('category' => $category_id)); $column = 0; if (api_is_allowed_to_edit(false, true) and count($group_list) > 1) { $table->set_header($column++, '', false); } $table->set_header($column++, get_lang('Groups')); $table->set_header($column++, get_lang('GroupTutor')); $table->set_header($column++, get_lang('Registered'), false); if (!api_is_allowed_to_edit(false, true)) { // If self-registration allowed $table->set_header($column++, get_lang('GroupSelfRegistration'), false); } if (api_is_allowed_to_edit(false, true)) { // Only for course administrator $table->set_header($column++, get_lang('Modify'), false); $form_actions = array(); $form_actions['fill_selected'] = get_lang('FillGroup'); $form_actions['empty_selected'] = get_lang('EmptyGroup'); $form_actions['delete_selected'] = get_lang('Delete'); if (count($group_list) > 1) { $table->set_form_actions($form_actions, 'group'); } } $table->display(); }
$interbreadcrumb[] = array('url' => $_SESSION['gradebook_dest'] . '?selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('Details')); $interbreadcrumb[] = array('url' => 'gradebook_showlog_eval.php?visiblelog=' . Security::remove_XSS($_GET['visiblelog']) . '&selectcat=' . Security::remove_XSS($_GET['selectcat']), 'name' => get_lang('GradebookQualifyLog')); $this_section = SECTION_COURSES; Display::display_header(''); echo Display::page_header(get_lang('GradebookQualifyLog')); $t_linkeval_log = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG); $t_user = Database::get_main_table(TABLE_MAIN_USER); $visible_log = Security::remove_XSS($_GET['visiblelog']); $evaledit = Evaluation::load($visible_log); $sql = "SELECT le.name,le.description,le.weight,le.visible,le.type,le.created_at,us.username FROM " . $t_linkeval_log . " le INNER JOIN " . $t_user . " us\n ON le.user_id_log=us.user_id where id_linkeval_log=" . $evaledit[0]->get_id() . " and type='evaluation';"; $result = Database::query($sql); $list_info = array(); while ($row = Database::fetch_row($result)) { $list_info[] = $row; } foreach ($list_info as $key => $info_log) { $list_info[$key][5] = $info_log[5] ? api_convert_and_format_date($info_log[5]) : 'N/A'; $list_info[$key][3] = $info_log[3] == 1 ? get_lang('GradebookVisible') : get_lang('GradebookInvisible'); } $parameters = array('visiblelog' => $visible_log, 'selectcat' => intval($_GET['selectcat'])); $table = new SortableTableFromArrayConfig($list_info, 1, 20, 'gradebookeval'); $table->set_additional_parameters($parameters); $table->set_header(0, get_lang('GradebookNameLog')); $table->set_header(1, get_lang('GradebookDescriptionLog')); $table->set_header(2, get_lang('GradebookPreviousWeight')); $table->set_header(3, get_lang('GradebookVisibilityLog')); $table->set_header(4, get_lang('ResourceType')); $table->set_header(5, get_lang('Date')); $table->set_header(6, get_lang('GradebookWhoChangedItLog')); $table->display(); Display::display_footer();
if ($active == '1') { $action = 'lock'; $image = 'right'; } if ($active == '0') { $action = 'unlock'; $image = 'wrong'; } // you cannot lock the default if ($row['id'] == '1') { $status = Display::return_icon($image . '.gif', get_lang(ucfirst($action))); } else { $status = '<a href="access_urls.php?action=' . $action . '&url_id=' . $row['id'] . '">' . Display::return_icon($image . '.gif', get_lang(ucfirst($action))) . '</a>'; } // Actions $url_id = $row['id']; $actions = Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), "access_url_edit.php?url_id={$url_id}"); if ($url_id != '1') { $actions .= '<a href="access_urls.php?action=delete_url&url_id=' . $url_id . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } $urls[] = array($url, $description, $status, $actions); } $table = new SortableTableFromArrayConfig($urls, 2, 50, 'urls'); $table->set_additional_parameters($parameters); //$table->set_header(0, ''); $table->set_header(0, 'URL'); $table->set_header(1, get_lang('Description')); $table->set_header(2, get_lang('Active')); $table->set_header(3, get_lang('Modify'), false); $table->display(); Display::display_footer();
/** * Blog admin | Returns table with blogs in this course */ public static function display_blog_list() { global $charset; $_user = api_get_user_info(); $course_id = api_get_course_int_id(); // Init $counter = 0; $tbl_blogs = Database::get_course_table(TABLE_BLOGS); //condition for the session $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id, false); $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id\n\t\t\t\tFROM {$tbl_blogs} WHERE c_id = {$course_id}\n\t\t\t\tORDER BY date_creation DESC"; $result = Database::query($sql); $list_info = array(); if (Database::num_rows($result)) { while ($row_project = Database::fetch_row($result)) { $list_info[] = $row_project; } } $list_content_blog = array(); $list_body_blog = array(); $_user = api_get_user_info(); if (is_array($list_info)) { foreach ($list_info as $key => $info_log) { // Validation when belongs to a session $session_img = api_get_session_image($info_log[4], $_user['status']); $url_start_blog = 'blog.php' . "?" . "blog_id=" . $info_log[3] . "&" . api_get_cidreq(); $title = $info_log[0]; $image = '<img src="../img/blog.gif" border="0" align="absmiddle" alt="' . $title . '">'; $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="' . $url_start_blog . '">' . $image . '</a></div><a href="' . $url_start_blog . '">' . $title . '</a>' . $session_img; $list_body_blog[] = $list_name; $list_body_blog[] = $info_log[1]; $visibility_icon = $info_log[2] == 0 ? 'invisible' : 'visible'; $visibility_info = $info_log[2] == 0 ? 'Visible' : 'Invisible'; $my_image = '<a href="' . api_get_self() . '?action=edit&blog_id=' . $info_log[3] . '">'; $my_image .= '<img src="../img/edit.gif" border="0" title="' . get_lang('EditBlog') . '" />'; $my_image .= "</a>\n"; $my_image .= '<a href="' . api_get_self() . '?action=delete&blog_id=' . $info_log[3] . '" '; $my_image .= 'onclick="javascript:if(!confirm(\'' . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . '\')) return false;" >'; $my_image .= '<img src="../img/delete.gif" border="0" title="' . get_lang('DeleteBlog') . '" />'; $my_image .= "</a>\n"; $my_image .= '<a href="' . api_get_self() . '?action=visibility&blog_id=' . $info_log[3] . '">'; $my_image .= '<img src="../img/' . $visibility_icon . '.gif" border="0" title="' . get_lang($visibility_info) . '" />'; $my_image .= "</a>\n"; $list_body_blog[] = $my_image; $list_content_blog[] = $list_body_blog; $list_body_blog = array(); } $parameters = ''; //$parameters=array('action'=>Security::remove_XSS($_GET['action'])); $table = new SortableTableFromArrayConfig($list_content_blog, 1, 20, 'project'); //$table->set_additional_parameters($parameters); $table->set_header(0, get_lang('Title')); $table->set_header(1, get_lang('SubTitle')); $table->set_header(2, get_lang('Modify')); $table->display(); } }
$tableName = $is_allowed_to_edit ? 'teacher_table' : 'student_table'; $table = new SortableTableFromArrayConfig($sortable_data, $default_column, 20, $tableName, $column_show, $column_order, 'ASC', true); $query_vars = array(); if (isset($_GET['keyword'])) { $query_vars['keyword'] = Security::remove_XSS($_GET['keyword']); } else { $query_vars['curdirpath'] = $curdirpath; } if ($groupId) { $query_vars['gidReq'] = $groupId; } $query_vars['cidReq'] = api_get_course_id(); $table->set_additional_parameters($query_vars); $column = 0; if (($is_allowed_to_edit || $group_member_with_upload_rights) && count($documentAndFolders) > 1) { $table->set_header($column++, '', false, array('style' => 'width:12px;')); } $table->set_header($column++, get_lang('Type'), true, array('style' => 'width:30px;')); $table->set_header($column++, get_lang('Name')); $table->set_header($column++, get_lang('Size'), true, array('style' => 'width:50px;')); $table->set_header($column++, get_lang('Date'), true, array('style' => 'width:150px;')); // Admins get an edit column if ($is_allowed_to_edit || $group_member_with_upload_rights || DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)) { $table->set_header($column++, get_lang('Actions'), false, array('class' => 'td_actions')); } // Actions on multiple selected documents // TODO: Currently only delete action -> take only DELETE permission into account if (count($documentAndFolders) > 1) { if ($is_allowed_to_edit || $group_member_with_upload_rights) { $form_actions = array(); $form_action['set_invisible'] = get_lang('SetInvisible');
$obj_text = '<textarea rows="10" cols="40" name="txt|' . $name_variable . '|' . $language_files_to_load_keys[$lang_file] . '" id="txtid_' . $language_files_to_load_keys[$lang_file] . '_' . $name_variable . '" >' . $sub_language_name_variable . '</textarea>'; $obj_button = '<button class="save" type="button" name="btn|' . $name_variable . '|' . $language_files_to_load_keys[$lang_file] . '" id="btnid_' . $name_variable . '" />' . get_lang('Save') . '</button>'; //loading variable from the english array $english_name_variable = $english_language_array[$lang_file][$name_variable]; $list_info[] = array($lang_file . '.inc.php', $name_variable, $english_name_variable, $parent_variable_value, $obj_text, $obj_button); } } } } $list_info = ArrayClass::array_unique_dimensional($list_info); return $list_info; } // Allow see data in sort table $list_info = array(); if (isset($_REQUEST['txt_search_word'])) { //@todo fix to accept a char with 1 char if (strlen(trim($_REQUEST['txt_search_word'])) > 2) { $list_info = search_language_term($_REQUEST['txt_search_word'], true, true, true, true); } } $parameters = array('id' => intval($_GET['id']), 'sub_language_id' => intval($_GET['sub_language_id']), 'txt_search_word' => $txt_search_word); $table = new SortableTableFromArrayConfig($list_info, 1, 20, 'data_info'); $table->set_additional_parameters($parameters); $table->set_header(0, get_lang('LanguageFile')); $table->set_header(1, get_lang('LanguageVariable')); $table->set_header(2, get_lang('EnglishName')); $table->set_header(3, get_lang('OriginalName')); $table->set_header(4, get_lang('SubLanguage'), false); $table->set_header(5, get_lang('Edit'), false); $table->display(); Display::display_footer();
$interbreadcrumb[] = array('url' => 'specific_fields.php', 'name' => get_lang('SpecificSearchFields')); $libpath = api_get_path(LIBRARY_PATH); require_once $libpath . 'sortable_table.class.php'; include_once $libpath . 'specific_fields_manager.lib.php'; // Create an add-field box $form = new FormValidator('add_field', 'post', '', '', null, false); $renderer =& $form->defaultRenderer(); $renderer->setElementTemplate('<span>{element}</span> '); $form->addElement('static', 'search_advanced_link', null, '<a href="specific_fields_add.php">' . Display::return_icon('fieldadd.gif') . get_lang('AddSpecificSearchField') . '</a>'); // Create a sortable table with specific fields data $column_show = array(1, 1, 1, 1); $column_order = array(3, 2, 1, 4); $extra_fields = get_specific_field_list(); $number_of_extra_fields = count($extra_fields); $table = new SortableTableFromArrayConfig($extra_fields, 2, 50, '', $column_show, $column_order); $table->set_header(0, '', false, null, 'width="2%"', 'style="display:none"'); $table->set_header(1, get_lang('Code'), TRUE, 'width="10%"'); $table->set_header(2, get_lang('Name')); $table->set_header(3, get_lang('Modify'), true, 'width="10%"'); $table->set_column_filter(3, 'edit_filter'); function edit_filter($id, $url_params, $row) { global $charset; $return = '<a href="specific_fields_add.php?action=edit&field_id=' . $row[0] . '">' . Display::return_icon('edit.gif', get_lang('Edit')) . '</a>'; $return .= ' <a href="' . api_get_self() . '?action=delete&field_id=' . $row[0] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . Display::return_icon('delete.gif', get_lang('Delete')) . '</a>'; return $return; } if ($_REQUEST['action'] == 'delete') { delete_specific_field($_REQUEST['field_id']); header('Location: specific_fields.php?message=' . get_lang('FieldRemoved')); }
/** * Displays a table with a special configuration * @param array $header Titles for the table header * each item in this array can contain 3 values * - 1st element: the column title * - 2nd element: true or false (column sortable?) * - 3th element: additional attributes for * th-tag (eg for column-width) * - 4the element: additional attributes for the td-tags * @param array $content 2D-array with the tables content * @param array $sorting_options Keys are: * 'column' = The column to use as sort-key * 'direction' = SORT_ASC or SORT_DESC * @param array $paging_options Keys are: * 'per_page_default' = items per page when switching from * full- list to per-page-view * 'per_page' = number of items to show per page * 'page_nr' = The page to display * @param array $query_vars Additional variables to add in the query-string * @param array $column_show Array of binaries 1= show columns 0. hide a column * @param array $column_order An array of integers that let us decide how the columns are going to be sort. * i.e: $column_order=array('1''4','3','4'); The 2nd column will be order like the 4th column * @param array $form_actions Set optional forms actions * * @author Julio Montoya */ public static function display_sortable_config_table($table_name, $header, $content, $sorting_options = array(), $paging_options = array(), $query_vars = null, $column_show = array(), $column_order = array(), $form_actions = array()) { global $origin; $column = isset($sorting_options['column']) ? $sorting_options['column'] : 0; $default_items_per_page = isset($paging_options['per_page']) ? $paging_options['per_page'] : 20; $table = new SortableTableFromArrayConfig($content, $column, $default_items_per_page, $table_name, $column_show, $column_order); if (is_array($query_vars)) { $table->set_additional_parameters($query_vars); } // Show or hide the columns header if (is_array($column_show)) { for ($i = 0; $i < count($column_show); $i++) { if (!empty($column_show[$i])) { $val0 = isset($header[$i][0]) ? $header[$i][0] : null; $val1 = isset($header[$i][1]) ? $header[$i][1] : null; $val2 = isset($header[$i][2]) ? $header[$i][2] : null; $val3 = isset($header[$i][3]) ? $header[$i][3] : null; $table->set_header($i, $val0, $val1, $val2, $val3); } } } $table->set_form_actions($form_actions); $table->display(); }
if ($active == '0') { $action = 'unlock'; $image = 'wrong'; } // you cannot lock the default if ($row['id'] == '1') { $status = Display::return_icon($image . '.gif', get_lang(ucfirst($action))); } else { $status = '<a href="access_urls.php?action=' . $action . '&url_id=' . $row['id'] . '&sec_token=' . Security::getCurrentToken() . '">' . Display::return_icon($image . '.gif', get_lang(ucfirst($action))) . '</a>'; } //Actions $url_id = $row['id']; $actions = Display::url(Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL), "access_url_edit.php?url_id={$url_id}"); if ($url_id != '1') { $actions .= '<a href="access_urls.php?action=delete_url&url_id=' . $url_id . '&sec_token=' . Security::getCurrentToken() . '" onclick="javascript:if(!confirm(' . "'" . addslashes(get_lang("ConfirmYourChoice")) . "'" . ')) return false;">' . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; } $urls[] = array($url, $name, $type, $tech, $contact, $status, $actions); } $table = new SortableTableFromArrayConfig($urls, 2, 50, 'urls'); $table->set_additional_parameters($parameters); //$table->set_header(0, ''); $table->set_header(0, 'URL'); $table->set_header(1, get_lang('Name')); $table->set_header(2, get_lang('URLType')); $table->set_header(3, 'Dl/Ul/Delay in Kbit/s'); $table->set_header(4, get_lang('Contact')); $table->set_header(5, get_lang('Active')); $table->set_header(6, get_lang('Modify'), false); $table->display(); /* FOOTER */ Display::display_footer();
/** * Most visited */ public function getMostVisited() { $tbl_wiki = $this->tbl_wiki; $course_id = $this->course_id; $groupfilter = $this->groupfilter; $condition_session = $this->condition_session; $_course = $this->courseInfo; echo '<div class="actions">' . get_lang('MostVisitedPages') . '</div>'; if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { //only by professors if page is hidden $sql = 'SELECT *, SUM(hits) AS tsum FROM ' . $tbl_wiki . ' WHERE c_id = ' . $course_id . ' AND ' . $groupfilter . $condition_session . ' GROUP BY reflink'; } else { $sql = 'SELECT *, SUM(hits) AS tsum FROM ' . $tbl_wiki . ' WHERE c_id = ' . $course_id . ' AND ' . $groupfilter . $condition_session . ' AND visibility=1 GROUP BY reflink'; } $allpages = Database::query($sql); //show table if (Database::num_rows($allpages) > 0) { $rows = array(); while ($obj = Database::fetch_object($allpages)) { //get type assignment icon $ShowAssignment = ''; if ($obj->assignment == 1) { $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL); } elseif ($obj->assignment == 2) { $ShowAssignment = $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL); } elseif ($obj->assignment == 0) { $ShowAssignment = Display::return_icon('px_transparent.gif'); } $row = array(); $row[] = $ShowAssignment; $row[] = '<a href="' . api_get_self() . '?cidReq=' . $_course['code'] . '&action=showpage&title=' . api_htmlentities(urlencode($obj->reflink)) . '&session_id=' . api_htmlentities($_GET['session_id']) . '&group_id=' . api_htmlentities($_GET['group_id']) . '">' . api_htmlentities($obj->title) . '</a>'; $row[] = $obj->tsum; $rows[] = $row; } $table = new SortableTableFromArrayConfig($rows, 2, 10, 'MostVisitedPages_table', '', '', 'DESC'); $table->set_additional_parameters(array('cidReq' => Security::remove_XSS($_GET['cidReq']), 'action' => Security::remove_XSS($this->action), 'session_id' => intval($_GET['session_id']), 'group_id' => intval($_GET['group_id']))); $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;')); $table->set_header(1, get_lang('Title'), true); $table->set_header(2, get_lang('Visits'), true); $table->display(); } }
$allow_add_term_sub_language = " <a href='sub_language.php?action=registersublanguage&id=" . Security::remove_XSS($all_information_of_sub_language['parent_id']) . "&sub_language_id=" . Security::remove_XSS($row['id']) . "'>" . Display::return_icon('2rightarrow.gif', get_lang('AddWordForTheSubLanguage'), array('width' => ICON_SIZE_SMALL, 'height' => ICON_SIZE_SMALL)) . "</a>"; $allow_delete_sub_language = " <a href='sub_language_add.php?action=deletesublanguage&id=" . Security::remove_XSS($all_information_of_sub_language['parent_id']) . "&sub_language_id=" . Security::remove_XSS($row['id']) . "'>" . Display::return_icon('delete.png', get_lang('DeleteSubLanguage'), array('width' => ICON_SIZE_SMALL, 'height' => ICON_SIZE_SMALL)) . "</a>"; } } else { $allow_use_sub_language = ''; $allow_add_term_sub_language = ''; } if ($row['english_name'] == $row_lang['selected_value']) { $row_td[] = Display::return_icon('visible.png', get_lang('Visible')) . "<a href='" . api_get_self() . "?action=edit&id=" . $row['id'] . "#value'>" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a>\n " . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language; } else { if ($row['available'] == 1) { $row_td[] = "<a class=\"make_visible_and_invisible\" id=\"linktool_" . $row['id'] . "\" href='" . api_get_self() . "?action=makeunavailable&id=" . $row['id'] . "'>" . Display::return_icon('visible.png', get_lang('MakeUnavailable'), array('id' => 'imglinktool_' . $row['id']), ICON_SIZE_SMALL) . "</a> <a href='" . api_get_self() . "?action=edit&id=" . $row['id'] . "#value'>" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a> " . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language; } else { $row_td[] = "<a class=\"make_visible_and_invisible\" id=\"linktool_" . $row['id'] . "\" href='" . api_get_self() . "?action=makeavailable&id=" . $row['id'] . "'>" . Display::return_icon('invisible.png', get_lang('MakeAvailable'), array('id' => 'imglinktool_' . $row['id']), ICON_SIZE_SMALL) . "</a> <a href='" . api_get_self() . "?action=edit&id=" . $row['id'] . "#value'>" . Display::return_icon('edit.png', get_lang('Edit'), '', ICON_SIZE_SMALL) . "</a> " . $setplatformlanguage . $allow_use_sub_language . $allow_add_term_sub_language . $allow_delete_sub_language; } } $language_data[] = $row_td; } $table = new SortableTableFromArrayConfig($language_data, 1, count($language_data)); $table->set_header(0, ''); $table->set_header(1, get_lang('OriginalName')); $table->set_header(2, get_lang('EnglishName')); $table->set_header(3, get_lang('LMSFolder')); $table->set_header(4, get_lang('Properties')); $form_actions = array(); $form_actions['makeavailable'] = get_lang('MakeAvailable'); $form_actions['makeunavailable'] = get_lang('MakeUnavailable'); $table->set_form_actions($form_actions); echo '<div id="id_content_message"> </div>'; $table->display(); Display::display_footer();
/** * Displays the results of a wiki search * @param string Search term * @param int Whether to search the contents (1) or just the titles (0) */ function display_wiki_search_results($search_term, $search_content = 0, $all_vers = 0) { global $tbl_wiki, $groupfilter, $MonthsLong, $condition_session; echo '<legend>' . get_lang('WikiSearchResults') . '</legend>'; $_clean['group_id'] = (int) $_SESSION['_gid']; $session_id = api_get_session_id(); $course_id = api_get_course_int_id(); //only by professors when page is hidden if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { if ($all_vers == '1') { if ($search_content == '1') { $sql = "SELECT * FROM " . $tbl_wiki . "\n\t\t\t\t\t\tWHERE c_id = {$course_id} AND title LIKE '%" . Database::escape_string($search_term) . "%' OR content LIKE '%" . Database::escape_string($search_term) . "%' AND " . $groupfilter . $condition_session . ""; //search all pages and all versions } else { $sql = "SELECT * FROM " . $tbl_wiki . "\n\t\t\t\t\t\tWHERE c_id = {$course_id} AND title LIKE '%" . Database::escape_string($search_term) . "%' AND " . $groupfilter . $condition_session . ""; //search all pages and all versions } } else { if ($search_content == '1') { $sql = "SELECT * FROM " . $tbl_wiki . " s1\n\t\t\t\t\t\tWHERE s1.c_id = {$course_id} AND title LIKE '%" . Database::escape_string($search_term) . "%' OR content LIKE '%" . Database::escape_string($search_term) . "%' AND\n\t\t\t \t\t\tid=(SELECT MAX(s2.id) FROM " . $tbl_wiki . " s2 WHERE s2.c_id = {$course_id} AND s1.reflink = s2.reflink AND " . $groupfilter . $condition_session . ")"; // warning don't use group by reflink because don't return the last version } else { $sql = " SELECT * FROM " . $tbl_wiki . " s1\n\t\t\t \t\t\tWHERE s1.c_id = {$course_id} AND title LIKE '%" . Database::escape_string($search_term) . "%' AND\n\t\t\t \t\t\tid=(SELECT MAX(s2.id) FROM " . $tbl_wiki . " s2 WHERE s2.c_id = {$course_id} AND s1.reflink = s2.reflink AND " . $groupfilter . $condition_session . ")"; // warning don't use group by reflink because don't return the last version } } } else { if ($all_vers == '1') { if ($search_content == '1') { $sql = "SELECT * FROM " . $tbl_wiki . " WHERE c_id = {$course_id} AND visibility=1 AND title LIKE '%" . Database::escape_string($search_term) . "%' OR content LIKE '%" . Database::escape_string($search_term) . "%' AND " . $groupfilter . $condition_session . ""; //search all pages and all versions } else { $sql = "SELECT * FROM " . $tbl_wiki . " WHERE c_id = {$course_id} AND visibility=1 AND title LIKE '%" . Database::escape_string($search_term) . "%' AND " . $groupfilter . $condition_session . ""; //search all pages and all versions } } else { if ($search_content == '1') { $sql = " SELECT * FROM " . $tbl_wiki . " s1\n\t\t\t \t\t WHERE s1.c_id = {$course_id} AND visibility=1 AND title LIKE '%" . Database::escape_string($search_term) . "%' OR content LIKE '%" . Database::escape_string($search_term) . "%' AND\n\t\t\t \t\t\tid=(SELECT MAX(s2.id) FROM " . $tbl_wiki . " s2 WHERE s2.c_id = {$course_id} AND s1.reflink = s2.reflink AND " . $groupfilter . $condition_session . ")"; // warning don't use group by reflink because don't return the last version } else { $sql = " SELECT * FROM " . $tbl_wiki . " s1\n\t\t\t \t\t\tWHERE s1.c_id = {$course_id} AND visibility=1 AND title LIKE '%" . Database::escape_string($search_term) . "%' AND\n\t\t\t \t\t\tid=(SELECT MAX(s2.id) FROM " . $tbl_wiki . " s2 WHERE s2.c_id = {$course_id} AND s1.reflink = s2.reflink AND " . $groupfilter . $condition_session . ")"; // warning don't use group by reflink because don't return the last version } } } $result = Database::query($sql); //show table if (Database::num_rows($result) > 0) { $row = array(); while ($obj = Database::fetch_object($result)) { //get author $userinfo = api_get_user_info($obj->user_id); //get time $year = substr($obj->dtime, 0, 4); $month = substr($obj->dtime, 5, 2); $day = substr($obj->dtime, 8, 2); $hours = substr($obj->dtime, 11, 2); $minutes = substr($obj->dtime, 14, 2); $seconds = substr($obj->dtime, 17, 2); //get type assignment icon if ($obj->assignment == 1) { $ShowAssignment = Display::return_icon('wiki_assignment.png', get_lang('AssignmentDesc'), '', ICON_SIZE_SMALL); } elseif ($obj->assignment == 2) { $ShowAssignment = Display::return_icon('wiki_work.png', get_lang('AssignmentWork'), '', ICON_SIZE_SMALL); } elseif ($obj->assignment == 0) { $ShowAssignment = '<img src="../img/px_transparent.gif" />'; } $row = array(); $row[] = $ShowAssignment; if ($all_vers == '1') { $row[] = '<a href="' . api_get_self() . '?cidReq=' . $_course['id'] . '&action=showpage&title=' . api_htmlentities(urlencode($obj->reflink)) . '&view=' . $obj->id . '&session_id=' . api_htmlentities(urlencode($_GET['$session_id'])) . '&group_id=' . api_htmlentities(urlencode($_GET['group_id'])) . '">' . api_htmlentities($obj->title) . '</a>'; } else { $row[] = '<a href="' . api_get_self() . '?cidReq=' . $_course[id] . '&action=showpage&title=' . api_htmlentities(urlencode($obj->reflink)) . '&session_id=' . api_htmlentities($_GET['session_id']) . '&group_id=' . api_htmlentities($_GET['group_id']) . '">' . $obj->title . '</a>'; } $row[] = $obj->user_id != 0 ? '<a href="../user/userInfo.php?uInfo=' . $userinfo['user_id'] . '">' . api_htmlentities($userinfo['complete_name']) . '</a>' : get_lang('Anonymous') . ' (' . $obj->user_ip . ')'; $row[] = $year . '-' . $month . '-' . $day . ' ' . $hours . ":" . $minutes . ":" . $seconds; if ($all_vers == '1') { $row[] = $obj->version; } else { if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { $showdelete = ' <a href="' . api_get_self() . '?cidReq=' . $_course[id] . '&action=delete&title=' . api_htmlentities(urlencode($obj->reflink)) . '&group_id=' . api_htmlentities($_GET['group_id']) . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL); } $row[] = '<a href="' . api_get_self() . '?cidReq=' . $_course[id] . '&action=edit&title=' . api_htmlentities(urlencode($obj->reflink)) . '&group_id=' . api_htmlentities($_GET['group_id']) . '">' . Display::return_icon('edit.png', get_lang('EditPage'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?cidReq=' . $_course[id] . '&action=discuss&title=' . api_htmlentities(urlencode($obj->reflink)) . '&session_id=' . api_htmlentities($_GET['session_id']) . '&group_id=' . api_htmlentities($_GET['group_id']) . '">' . Display::return_icon('discuss.png', get_lang('Discuss'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?cidReq=' . $_course[id] . '&action=history&title=' . api_htmlentities(urlencode($obj->reflink)) . '&session_id=' . api_htmlentities($_GET['session_id']) . '&group_id=' . api_htmlentities($_GET['group_id']) . '">' . Display::return_icon('history.png', get_lang('History'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?cidReq=' . $_course[id] . '&action=links&title=' . api_htmlentities(urlencode($obj->reflink)) . '&group_id=' . api_htmlentities($_GET['group_id']) . '">' . Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL) . '</a>' . $showdelete; } $rows[] = $row; } $table = new SortableTableFromArrayConfig($rows, 1, 10, 'SearchPages_table', '', '', 'ASC'); $table->set_additional_parameters(array('cidReq' => $_GET['cidReq'], 'action' => $_GET['action'], 'group_id' => Security::remove_XSS($_GET['group_id']), 'mode_table' => 'yes2', 'search_term' => $search_term, 'search_content' => $search_content, 'all_vers' => $all_vers)); $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;')); $table->set_header(1, get_lang('Title'), true); if ($all_vers == '1') { $table->set_header(2, get_lang('Author'), true); $table->set_header(3, get_lang('Date'), true); $table->set_header(4, get_lang('Version'), true); } else { $table->set_header(2, get_lang('Author') . ' (' . get_lang('LastVersion') . ')', true); $table->set_header(3, get_lang('Date') . ' (' . get_lang('LastVersion') . ')', true); $table->set_header(4, get_lang('Actions'), false, array('style' => 'width:130px;')); } $table->display(); } else { echo get_lang('NoSearchResults'); } }
$row[] = '<a href="../user/userInfo.php?uInfo=' . $userinfo['user_id'] . '">' . Display::tag('span', api_htmlentities($userinfo['complete_name_login_as'])) . '</a>'; } else { $row[] = get_lang('Anonymous') . ' (' . api_htmlentities($obj->user_ip) . ')'; } $row[] = api_get_local_time($obj->dtime, null, date_default_timezone_get()); if (api_is_allowed_to_edit(false, true) || api_is_platform_admin()) { $showdelete = ' <a href="' . api_get_self() . '?cidReq=' . $_course['id'] . '&action=delete&title=' . Security::remove_XSS($obj->reflink) . '&session_id=' . Security::remove_XSS($_GET['session_id']) . '&group_id=' . Security::remove_XSS($_GET['group_id']) . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL); } if (api_is_allowed_to_session_edit(false, true)) { $row[] = '<a href="' . api_get_self() . '?cidReq=' . $_course['id'] . '&action=edit&title=' . Security::remove_XSS($obj->reflink) . '&session_id=' . Security::remove_XSS($_GET['session_id']) . '&group_id=' . Security::remove_XSS($_GET['group_id']) . '">' . Display::return_icon('edit.png', get_lang('EditPage'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?cidReq=' . $_course['id'] . '&action=discuss&title=' . Security::remove_XSS($obj->reflink) . '&group_id=' . Security::remove_XSS($_GET['group_id']) . '">' . Display::return_icon('discuss.png', get_lang('Discuss'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?cidReq=' . $_course['id'] . '&action=history&title=' . api_htmlentities(urlencode($obj->reflink)) . '&session_id=' . Security::remove_XSS($_GET['session_id']) . '&group_id=' . Security::remove_XSS($_GET['group_id']) . '">' . Display::return_icon('history.png', get_lang('History'), '', ICON_SIZE_SMALL) . '</a> <a href="' . api_get_self() . '?cidReq=' . $_course['id'] . '&action=links&title=' . api_htmlentities(urlencode($obj->reflink)) . '&session_id=' . Security::remove_XSS($_GET['session_id']) . '&group_id=' . Security::remove_XSS($_GET['group_id']) . '">' . Display::return_icon('what_link_here.png', get_lang('LinksPages'), '', ICON_SIZE_SMALL) . '</a>' . $showdelete; } $rows[] = $row; } $table = new SortableTableFromArrayConfig($rows, 1, 10, 'AllPages_table', '', '', 'ASC'); $table->set_additional_parameters(array('cidReq' => Security::remove_XSS($_GET['cidReq']), 'action' => Security::remove_XSS($_GET['action']), 'group_id' => Security::remove_XSS($_GET['group_id']))); $table->set_header(0, get_lang('Type'), true, array('style' => 'width:30px;')); $table->set_header(1, get_lang('Title'), true); $table->set_header(2, get_lang('Author') . ' (' . get_lang('LastVersion') . ')', true); $table->set_header(3, get_lang('Date') . ' (' . get_lang('LastVersion') . ')', true); if (api_is_allowed_to_session_edit(false, true)) { $table->set_header(4, get_lang('Actions'), true, array('style' => 'width:130px;')); } $table->display(); } } // Discuss pages if ($_GET['action'] == 'discuss') { if (api_get_session_id() != 0 && api_is_allowed_to_session_edit(false, true) == false) { api_not_allowed(); } if (!$_GET['title']) {