From 183185d12b43f174b52f1c36a0d0cd7c33ba2f0b Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sat, 24 Mar 2007 00:41:43 +0000 Subject: [PATCH] One default was causing author view not being able to sortby firstname or lastname. Backported from MOODLE_18_STABLE --- mod/glossary/view.php | 67 ++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 7b37e267868..5c3d6f8e74b 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -13,7 +13,7 @@ $mode = optional_param('mode', '', PARAM_ALPHA); // term entry cat date letter search author approval $hook = optional_param('hook', '', PARAM_CLEAN); // the term, entry, cat, etc... to look for based on mode $fullsearch = optional_param('fullsearch', 0,PARAM_INT); // full search (concept and definition) when searching? - $sortkey = optional_param('sortkey', 'CREATION', PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME... + $sortkey = optional_param('sortkey', '', PARAM_ALPHA);// Sorted view: CREATION | UPDATE | FIRSTNAME | LASTNAME... $sortorder = optional_param('sortorder', 'ASC', PARAM_ALPHA); // it defines the order of the sorting (ASC or DESC) $offset = optional_param('offset', 0,PARAM_INT); // entries to bypass (for paging purposes) $page = optional_param('page', 0,PARAM_INT); // Page to show (for paging purposes) @@ -44,6 +44,8 @@ error("Must specify glossary ID or course module ID"); } + $context = get_context_instance(CONTEXT_MODULE, $cm->id); + if ($CFG->forcelogin) { require_login(); } @@ -112,11 +114,11 @@ } /// Processing standard security processes $navigation = ""; - if ($course->category) { + if ($course->id != SITEID) { $navigation = "id\">$course->shortname ->"; require_login($course->id); } - if (!$cm->visible and !isteacher($course->id)) { + if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) { print_header(); notice(get_string("activityiscurrentlyhidden")); } @@ -249,8 +251,8 @@ /// the "Print" icon $printicon = ''; if ( $isuserframe and $mode != 'search') { - if (isteacher($course->id) or $glossary->allowprintview) { - $printicon = " id&mode=$mode&hook=$hook&sortkey=$sortkey&sortorder=$sortorder&offset=$offset\">\"\""; + if (has_capability('mod/glossary:manageentries', $context) or $glossary->allowprintview) { + $printicon = " id&mode=$mode&hook=".urlencode($hook)."&sortkey=$sortkey&sortorder=$sortorder&offset=$offset\">\""."; } } print_heading(format_string($glossary->name).$printicon); @@ -258,11 +260,10 @@ /// Info box if ( $glossary->intro ) { - print_simple_box(format_text($glossary->intro), 'center', '70%', '', 5, 'generalbox', 'intro'); + print_box(format_text($glossary->intro), 'generalbox', 'intro'); } /// Search box - echo '
'; echo ''; @@ -286,9 +287,26 @@ echo '
'; echo '
'; + echo '
'; - include("tabs.html"); +/// Show the add entry button if allowed + if (has_capability('mod/glossary:write', $context)) { + echo '
'; + echo "
wwwroot/mod/glossary/edit.php\">"; + echo '
'; + echo "id\" />"; + echo ''; + echo '
'; + echo '
'; + echo "
\n"; + } + + echo '
'; + + include("tabs.php"); include_once("sql.php"); @@ -320,24 +338,24 @@ $ratings->assesstimestart = $glossary->assesstimestart; $ratings->assesstimefinish = $glossary->assesstimefinish; } - if ($glossary->assessed == 2 and !isteacher($course->id)) { + if ($glossary->assessed == 2 and !has_capability('mod/glossary:rate', $context)) { $ratings->allow = false; } else { $ratings->allow = true; } - echo "
"; + echo ""; echo "id\" />"; } foreach ($allentries as $entry) { // Setting the pivot for the current entry - $pivot = $entry->pivot; - $upperpivot = $textlib->strtoupper($pivot, current_charset()); + $pivot = $entry->glossarypivot; + $upperpivot = $textlib->strtoupper($pivot); // Reduce pivot to 1cc if necessary if ( !$fullpivot ) { - $upperpivot = $textlib->substr($upperpivot, 0, 1, current_charset()); + $upperpivot = $textlib->substr($upperpivot, 0, 1); } // if there's a group break @@ -348,17 +366,17 @@ $currentpivot = $upperpivot; echo '
'; - echo ''; + echo '
'; echo ''; $pivottoshow = $currentpivot; - if ( isset($entry->uid) ) { + if ( isset($entry->userispivot) ) { // printing the user icon if defined (only when browsing authors) echo '
'; - $user = get_record("user","id",$entry->uid); + $user = get_record("user","id",$entry->userid); print_user_picture($user->id, $course->id, $user->picture); - $pivottoshow = fullname($user, isteacher($course->id));; + $pivottoshow = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id))); } else { echo ''; } @@ -402,18 +420,18 @@ } } if ( !$entriesshown ) { - print_simple_box('
' . get_string("noentries","glossary") . '
',"center","95%"); + print_simple_box('
' . get_string("noentries","glossary") . '
',"center","95%"); } if ($ratingsmenuused) { - echo "
"; + echo "
"; if ($glossary->scale < 0) { if ($scale = get_record("scale", "id", abs($glossary->scale))) { print_scale_menu_helpbutton($course->id, $scale ); } } - echo "
"; + echo ""; echo ""; } @@ -424,16 +442,7 @@ echo ''; } echo '
'; - echo ''; glossary_print_tabbed_table_end(); - if ( !empty($debug) and isadmin() ) { - echo '

'; - print_simple_box("$sqlselect
$sqlfrom
$sqlwhere
$sqlorderby
$sqllimit","center","85%"); - - echo "

"; - echo microtime_diff($CFG->startpagetime, microtime()); - echo "

"; - } /// Finish the page