From c197e6070b78202c095e9dbed3093e01afa0eaa7 Mon Sep 17 00:00:00 2001 From: willcast Date: Wed, 22 Oct 2003 04:15:08 +0000 Subject: [PATCH] - Added a new frame: Browse by date. - Removing unnecesary double quotes (not all of them yet) --- lang/en/glossary.php | 3 +- mod/glossary/approve.php | 2 +- mod/glossary/dynalink.php | 8 +- mod/glossary/edit.php | 2 +- mod/glossary/editcategories.html | 5 +- mod/glossary/editcategories.php | 2 +- mod/glossary/lib.php | 129 +++++++++++---------- mod/glossary/view.php | 186 +++++++++++++++++-------------- 8 files changed, 176 insertions(+), 161 deletions(-) diff --git a/lang/en/glossary.php b/lang/en/glossary.php index 770cb11a11..287ac27608 100644 --- a/lang/en/glossary.php +++ b/lang/en/glossary.php @@ -27,6 +27,7 @@ $string['comments'] = "Comments"; $string['commentson'] = "Comments on"; $string['concept'] = "Concept"; $string['concepts'] = "Concepts"; +$string['dateview'] = "Browse by date"; $string['deletingcomment'] = "Deleting comment"; $string['defaultapproval'] = "Default approval status"; $string['definition'] = "Definition"; @@ -45,10 +46,10 @@ $string['editcategories'] = "Edit categories"; $string['editentry'] = "Edit entry"; $string['editingcomment'] = "Editing comment"; $string['entries'] = "Entries"; -$string['entriesawaitingapproval'] = "All these entries are waiting for approval."; $string['entrieswithoutcategory'] = "Entries without category"; $string['entry'] = "Entry"; $string['entryalreadyexist'] = "Entry already exists"; +$string['entryapproved'] = "This entry has been approved"; $string['entrydeleted'] = "Entry deleted"; $string['entryishidden'] = "(this entry is currently hidden)"; $string['entryusedynalink'] = "This entry should be
automatically linked"; diff --git a/mod/glossary/approve.php b/mod/glossary/approve.php index d65c9e31e7..5254bb70f2 100644 --- a/mod/glossary/approve.php +++ b/mod/glossary/approve.php @@ -33,6 +33,6 @@ } else { add_to_log($course->id, "glossary", "approve entry", "showentry.php?id=$cm->id&eid=$eid", "$eid"); } - redirect("view.php?id=$cm->id&tab=$tab"); + redirect("view.php?id=$cm->id&tab=$tab&l=ALL",get_string("entryapproved","glossary"),1); die; ?> \ No newline at end of file diff --git a/mod/glossary/dynalink.php b/mod/glossary/dynalink.php index 4cba386706..21504fbc2b 100644 --- a/mod/glossary/dynalink.php +++ b/mod/glossary/dynalink.php @@ -38,7 +38,7 @@ $categories = get_records_select("glossary_categories", "glossaryid IN ($glossaries)", "$cbylenght glossaryid,id","id,glossaryid,name concept, 1 casesensitive,$GLOSSARY_CONCEPT_IS_CATEGORY category, 1 fullmatch"); if ( $entries and $categories ) { $concepts = array_merge($entries, $categories); - usort($concepts,glossary_sort_entries_by_lenght); + usort($concepts,'glossary_sort_entries_by_lenght'); } elseif ( $categories ) { $concepts = $categories; } elseif ( $entries ) { @@ -61,7 +61,7 @@ } $cm = get_coursemodule_from_instance("glossary", $glossary->id, $courseid); $title = strip_tags("$glossary->name: " . get_string("category","glossary"). " $category->name"); - $href_tag_begin = "wwwroot/mod/glossary/view.php?id=$cm->id¤tview=categories&cat=$concept->id\">"; + $href_tag_begin = "wwwroot/mod/glossary/view.php?id=$cm->id&tab=1&cat=$concept->id\">"; } else { $title = strip_tags("$glossary->name: $concept->concept"); $href_tag_begin = "wwwroot/mod/glossary/showentry.php?courseid=$courseid&concept=$concept->concept\" ". @@ -159,9 +159,9 @@ function glossary_sort_entries_by_lenght ( $entry0, $entry1 ) { if ( strlen(trim($entry0->concept)) < strlen(trim($entry1->concept)) ) { - return -1; - } elseif ( strlen(trim($entry0->concept)) > strlen(trim($entry1->concept)) ) { return 1; + } elseif ( strlen(trim($entry0->concept)) > strlen(trim($entry1->concept)) ) { + return -1; } else { return 0; } diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php index 8415287323..76c8fcb8b3 100644 --- a/mod/glossary/edit.php +++ b/mod/glossary/edit.php @@ -53,7 +53,7 @@ if ( $confirm ) { if ($dupentries = get_records("glossary_entries","UCASE(concept)", strtoupper($newentry->concept))) { foreach ($dupentries as $curentry) { if ( $glossary->id == $curentry->glossaryid ) { - if ( $curentry->id != $entry ) { + if ( $curentry->id != $e ) { $permissiongranted = 0; break; } diff --git a/mod/glossary/editcategories.html b/mod/glossary/editcategories.html index 278776cfd3..d5943d24af 100644 --- a/mod/glossary/editcategories.html +++ b/mod/glossary/editcategories.html @@ -1,10 +1,9 @@ -
action="editcategories.php"> + diff --git a/mod/glossary/editcategories.php b/mod/glossary/editcategories.php index 47714b799a..1c50206d98 100644 --- a/mod/glossary/editcategories.php +++ b/mod/glossary/editcategories.php @@ -163,7 +163,7 @@

- action="editcategories.php"> +

:

diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 91dd3a53e0..76fb8c2f05 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -10,7 +10,8 @@ define("GLOSSARY_SHOW_NOT_CATEGORISED", -1); define("GLOSSARY_STANDARD_VIEW", 0); define("GLOSSARY_CATEGORY_VIEW", 1); -define("GLOSSARY_APPROVAL_VIEW", 2); +define("GLOSSARY_DATE_VIEW", 2); +define("GLOSSARY_APPROVAL_VIEW", 3); define("GLOSSARY_FORMAT_SIMPLE", 0); define("GLOSSARY_FORMAT_CONTINUOUS", 1); @@ -216,7 +217,7 @@ global $CFG; function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="") { global $THEME, $USER, $CFG; - if ($entry->approved or $USER->id == $entry->userid or $tab == GLOSSARY_APPROVAL_VIEW) { + if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $tab == GLOSSARY_APPROVAL_VIEW) { $permissiongranted = 0; $formatfile = "$CFG->dirroot/mod/glossary/formats/$glossary->displayformat.php"; $functionname = "glossary_print_entry_by_format"; @@ -313,7 +314,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat echo ""; } echo ""; - if ( $glossary->allowcomments ) { + if ( $glossary->allowcomments and !isguest()) { echo " id&eid=$entry->id\">\"" "; } @@ -382,9 +383,6 @@ function glossary_search_entries($searchterms, $glossary, $includedefinition) { foreach ($searchterms as $searchterm) { -/* if (strlen($searchterm) < 2) { - continue; - }*/ if ($conceptsearch) { $conceptsearch.= " OR "; } @@ -416,8 +414,6 @@ function glossary_search_entries($searchterms, $glossary, $includedefinition) { AND (e.glossaryid = g.id or e.sourceglossaryid = g.id) $onlyvisible AND g.id = $glossary->id AND e.approved != 0"; -// $totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql"); - return get_records_sql("SELECT e.* FROM $selectsql ORDER BY e.concept ASC"); } @@ -749,11 +745,8 @@ function glossary_print_tabbed_table_end() { } function glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder = "",$tab=GLOSSARY_STANDARD_VIEW) { - $entriesawaiting = get_string("entriesawaitingapproval", "glossary"); - echo "
$entriesawaiting

"; - if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) { - echo '

' . get_string("explainalphabet","glossary") . '

'; + echo '

' . get_string("explainalphabet","glossary") . '

'; } glossary_print_special_links($cm, $glossary,$l, $tab); @@ -765,39 +758,42 @@ function glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder = } function glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder = "", $tab=GLOSSARY_STANDARD_VIEW) { - if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) { - echo '

' . get_string("explainalphabet","glossary") . '

'; - } - glossary_print_special_links($cm, $glossary,$l, $tab); + if ( $tab != GLOSSARY_DATE_VIEW ) { + if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) { + echo '

' . get_string("explainalphabet","glossary") . '

'; + } - glossary_print_alphabet_links($cm, $glossary,$l, $tab); + glossary_print_special_links($cm, $glossary,$l, $tab); - glossary_print_all_links($cm, $glossary,$l, $tab); - - glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab); + glossary_print_alphabet_links($cm, $glossary,$l, $tab); + + glossary_print_all_links($cm, $glossary,$l, $tab); + } else { + glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab); + } } function glossary_print_categories_menu($course, $cm, $glossary, $cat, $category) { global $CFG, $THEME; - echo ""; - echo ""; + echo '
'; + echo ''; - echo ""; + echo ''; - echo ""; - echo "'; + echo '"; - echo ""; + echo ''; + echo ''; - echo ""; - echo "
"; + echo ''; if ( isteacher($course->id) ) { $options['id'] = $cm->id; $options['cat'] = $cat; echo print_single_button("editcategories.php", $options, get_string("editcategories","glossary"), "get"); } - echo ""; - echo ""; + echo ''; + echo ''; $menu[GLOSSARY_SHOW_ALL_CATEGORIES] = get_string("allcategories","glossary"); $menu[GLOSSARY_SHOW_NOT_CATEGORISED] = get_string("notcategorised","glossary"); $categories = get_records("glossary_categories", "glossaryid", $glossary->id, "name ASC"); - $selected = ""; + $selected = ''; if ( $categories ) { foreach ($categories as $currentcategory) { $url = $currentcategory->id; @@ -828,24 +824,23 @@ global $CFG, $THEME; } } - echo ""; + echo ''; echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&tab=" . GLOSSARY_CATEGORY_VIEW . "&cat=", $menu, "catmenu", $selected, "", "", "", false); - echo "

"; + echo '

'; } function glossary_print_all_links($cm, $glossary, $l, $tab) { global $CFG; if ( $glossary->showall and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) { $strallentries = get_string("allentries", "glossary"); - if ( $l == "ALL" ) { + if ( $l == 'ALL' ) { echo "$strallentries"; } else { $strexplainall = strip_tags(get_string("explainall","glossary")); @@ -858,7 +853,7 @@ function glossary_print_special_links($cm, $glossary, $l, $tab) { global $CFG; if ( $glossary->showspecial and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) { $strspecial = get_string("special", "glossary"); - if ( $l == "SPECIAL" ) { + if ( $l == 'SPECIAL' ) { echo "$strspecial | "; } else { $strexplainspecial = strip_tags(get_string("explainspecial","glossary")); @@ -879,9 +874,9 @@ global $CFG; echo "
wwwroot/mod/glossary/view.php?id=$cm->id&l=$alphabet[$i]&tab=$tab\">$alphabet[$i]"; } if ((int) ($i % $letters_by_line) != 0 or $i == 0) { - echo " | "; + echo ' | '; } else { - echo "
"; + echo '
'; } } } @@ -893,50 +888,50 @@ global $CFG; $strsortbycreation = get_string("sortbycreation", "glossary"); $strsortbylastupdate = get_string("sortbylastupdate", "glossary"); - $neworder = ""; + $neworder = ''; if ( $sortorder ) { - if ( $sortorder == "asc" ) { - $neworder = "&sortorder=desc"; + if ( $sortorder == 'asc' ) { + $neworder = '&sortorder=desc'; $ordertitle = get_string("descending","glossary"); } else { - $neworder = "&sortorder=asc"; + $neworder = '&sortorder=asc'; $ordertitle = get_string("ascending","glossary"); } $icon = " "; } else { - if ( $sortkey != "CREATION" and $sortkey != "UPDATE" ) { + if ( $sortkey != 'CREATION' and $sortkey != 'UPDATE' ) { $icon = ""; $ordertitle = get_string("ascending","glossary"); } else { $ordertitle = get_string("descending","glossary"); - $neworder = "&sortorder=desc"; - $icon = " "; + $neworder = '&sortorder=desc'; + $icon = ' '; } } - $cicon = ""; - $cneworder = ""; - $cbtag = ""; - $cendbtag = ""; + $cicon = ''; + $cneworder = ''; + $cbtag = ''; + $cendbtag = ''; - $uicon = ""; - $uneworder = ""; - $ubtag = ""; - $uendbtag = ""; + $uicon = ''; + $uneworder = ''; + $ubtag = ''; + $uendbtag = ''; - if ( $sortkey == "CREATION" ) { + if ( $sortkey == 'CREATION' ) { $cicon = $icon; $cneworder = $neworder; $cordertitle = $ordertitle; $uordertitle = get_string("ascending","glossary"); - $cbtag = ""; - $cendbtag = ""; - } elseif ($sortkey == "UPDATE") { + $cbtag = ''; + $cendbtag = ''; + } elseif ($sortkey == 'UPDATE') { $uicon = $icon; $uneworder = $neworder; $cordertitle = get_string("ascending","glossary"); $uordertitle = $ordertitle; - $ubtag = ""; - $uendbtag = ""; + $ubtag = ''; + $uendbtag = ''; } else { $cordertitle = get_string("ascending","glossary"); $uordertitle = get_string("ascending","glossary"); @@ -976,25 +971,25 @@ function glossary_print_comment($course, $cm, $glossary, $entry, $comment) { echo "
$strby $user->firstname $user->lastname"; echo "
(".get_string("lastedited").": ".userdate($comment->timemodified).")
"; echo ""; - + echo "cellcontent\">"; if ($comment) { - echo format_text($comment->comment, $comment->format); + echo format_text($comment->comment, $comment->format); } else { - echo "
"; + echo "
"; print_string("nocomment", "glossary"); - echo "
"; + echo "
"; } echo "

"; - if ( (time() - $comment->timemodified < $CFG->maxeditingtime and $USER->id == $comment->userid) or isteacher($course->id) ) { + if ( (time() - $comment->timemodified < $CFG->maxeditingtime and $USER->id == $comment->userid) or isteacher($course->id) ) { echo "id&eid=$entry->id&cid=$comment->id&action=edit\">\"" "; - } - if ( $USER->id == $comment->userid or isteacher($course->id) ) { + } + if ( $USER->id == $comment->userid or isteacher($course->id) ) { echo "id&eid=$entry->id&cid=$comment->id&action=delete\">\"""; - } + } echo ""; - + echo "\n"; echo ""; diff --git a/mod/glossary/view.php b/mod/glossary/view.php index f5b2786b24..ac4ac238ae 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -29,76 +29,74 @@ } require_login($course->id); - if (!$cm->visible and !isteacher($course->id)) { notice(get_string("activityiscurrentlyhidden")); } + add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id&tab=$tab", "$glossary->id"); - add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id"); - + /// checking for valid values for sortorder and sortkey if ( $sortorder = strtolower($sortorder) ) { - if ($sortorder != "asc" and $sortorder != "desc") { - $sortorder = ""; + if ($sortorder != 'asc' and $sortorder != 'desc') { + $sortorder = ''; } else { - $l = ""; - $search =""; + $l = ''; + $search = ''; } } if ( $sortkey = strtoupper($sortkey) ) { - if ($sortkey != "CREATION" and $sortkey != "UPDATE") { - $sortkey = ""; + if ($sortkey != 'CREATION' and $sortkey != 'UPDATE') { + $sortkey = ''; } } if ( $sortkey or $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) { if ( !$sortkey and $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) { - $sortkey = "CREATION"; - $sortorder = "asc"; + $sortkey = 'CREATION'; + $sortorder = 'asc'; } if ( !$sortorder ) { - $sortorder = "asc"; - } - if ($sortkey == "CREATION") { - $orderby = "timecreated $sortorder"; - } else { - $orderby = "timemodified $sortorder"; + $sortorder = 'asc'; } } else { - $orderby = "concept ASC"; + $orderby = 'concept ASC'; } // creating matrix of words to search if apply $search = trim(strip_tags($search)); if ($search and !$eid) { - $l = ""; - $searchterms = explode(" ", $search); // Search for words independently + $l = ''; + $searchterms = explode(' ', $search); // Search for words independently foreach ($searchterms as $key => $searchterm) { if (strlen($searchterm) < 2) { unset($searchterms[$key]); } } - $search = trim(implode(" ", $searchterms)); + $search = trim(implode(' ', $searchterms)); $tab = GLOSSARY_STANDARD_VIEW; } elseif ($eid) { - $search = ""; + $search = ''; } - $alphabet = explode("|", get_string("alphabet","glossary")); - if ($l == "" and $search == "" and $sortkey == "" and !$eid) { + $alphabet = explode('|', get_string("alphabet","glossary")); + if ($l == '' and $search == '' and $sortkey == '' and !$eid) { // if the user is just entering the glossary... - $l = $alphabet[0]; + if ($tab != GLOSSARY_APPROVAL_VIEW) { + $l = $alphabet[0]; + } else { + $l = 'ALL'; + } } elseif ($eid) { - $l = ""; + $l = ''; } - $category = ""; + $category = ''; if ($tab == GLOSSARY_CATEGORY_VIEW) { - $l = ""; + $l = ''; if ($cat > 0) { $category = get_record("glossary_categories", "id", $cat); if (!$category) { - $cat = ""; + $cat = ''; } } } @@ -128,7 +126,7 @@ /// Info box if ( $glossary->intro ) { - print_simple_box_start("center","70%"); + print_simple_box_start('center','70%'); echo '

'; echo $glossary->intro; echo '

'; @@ -141,10 +139,10 @@ $options = array ("id" => "$cm->id"); echo '

'; print_single_button("edit.php", $options, $straddentry); - echo '

'; + echo '

'; } } - + echo '

'; /// Search box @@ -162,42 +160,56 @@ /// Tabbed browsing sections - + echo '

'; $glossary_tCFG->TabTableBGColor = $THEME->cellheading; $glossary_tCFG->ActiveTabColor = $THEME->cellheading; $glossary_tCFG->InactiveTabColor = $THEME->cellcontent2; $glossary_tCFG->InactiveFontColor= $THEME->hidden; - $glossary_tCFG->TabTableWidth = "70%"; - $glossary_tCFG->TabsPerRow = 5; + $glossary_tCFG->TabsPerRow = 4; $glossary_tCFG->TabSeparation = 4; - echo '

'; - $data[0]->link = "view.php?id=$id"; - $data[0]->caption = get_string("standardview", "glossary"); + $data[GLOSSARY_STANDARD_VIEW]->link = "view.php?id=$id"; + $data[GLOSSARY_STANDARD_VIEW]->caption = get_string("standardview", "glossary"); - $data[1]->link = "view.php?id=$id&tab=".GLOSSARY_CATEGORY_VIEW; - $data[1]->caption = get_string("categoryview", "glossary"); + $data[GLOSSARY_CATEGORY_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_CATEGORY_VIEW; + $data[GLOSSARY_CATEGORY_VIEW]->caption = get_string("categoryview", "glossary"); + $data[GLOSSARY_DATE_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_DATE_VIEW; + $data[GLOSSARY_DATE_VIEW]->caption = get_string("dateview", "glossary"); + if (isteacher($course->id)) { - $data[2]->link = "view.php?id=$id&tab=".GLOSSARY_APPROVAL_VIEW; - $data[2]->caption = get_string("waitingapproval", "glossary"); - } + $data[GLOSSARY_APPROVAL_VIEW]->caption = get_string("waitingapproval", "glossary"); + $data[GLOSSARY_APPROVAL_VIEW]->link = ""; - if ($tab == GLOSSARY_APPROVAL_VIEW and !isteacher($course->id)) { + $hiddenentries = get_records_select("glossary_entries","glossaryid = $glossary->id and approved = 0"); + if ($hiddenentries) { + $data[GLOSSARY_APPROVAL_VIEW]->caption .= "
(" . count($hiddenentries) . " " . get_string("entries","glossary") . ")"; + $data[GLOSSARY_APPROVAL_VIEW]->link = "view.php?id=$id&tab=".GLOSSARY_APPROVAL_VIEW; + } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) { + $tab = GLOSSARY_STANDARD_VIEW; + } + } elseif ( $tab == GLOSSARY_APPROVAL_VIEW ) { $tab = GLOSSARY_STANDARD_VIEW; } /// printing header of the current tab - echo "

"; + echo '
'; glossary_print_tabbed_table_start($data, $tab, $glossary_tCFG); switch ($tab) { case GLOSSARY_CATEGORY_VIEW: glossary_print_categories_menu($course, $cm, $glossary, $cat, $category); break; - case GLOSSARY_APPROVAL_VIEW: + case GLOSSARY_APPROVAL_VIEW: glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab); break; + case GLOSSARY_DATE_VIEW: + if (!$sortkey) { + $sortkey = 'UPDATE'; + } + if (!$sortorder) { + $sortorder = 'desc'; + } case GLOSSARY_STANDARD_VIEW: default: glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab); @@ -206,7 +218,7 @@ } break; } - echo "
"; + echo '
'; /// Printing the entries @@ -222,84 +234,92 @@ gc.id = gec.categoryid"; if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) { - $sql .= " ORDER BY gc.name, ge.timecreated"; + $sql .= ' ORDER BY gc.name, ge.timecreated'; } else { - $sql .= " ORDER BY gc.name, ge.concept"; + $sql .= ' ORDER BY gc.name, ge.concept'; } $allentries = get_records_sql($sql); } else { if ( $cat == GLOSSARY_SHOW_NOT_CATEGORISED ) { - $allentries = glossary_get_entries_sorted($glossary, "",$orderby); + $allentries = glossary_get_entries_sorted($glossary, '',$orderby); } else { - $allentries = glossary_get_entries_by_category($glossary, $cat, "",$orderby); + $allentries = glossary_get_entries_by_category($glossary, $cat, '',$orderby); } } $currentcategory = ""; break; case GLOSSARY_APPROVAL_VIEW: - $allentries = glossary_get_entries_sorted($glossary, "approved = 0",$orderby); - $currentletter = ""; + $allentries = glossary_get_entries_sorted($glossary, 'approved = 0',$orderby); + $currentletter = ''; break; + case GLOSSARY_DATE_VIEW: + $l = 'ALL'; case GLOSSARY_STANDARD_VIEW: + default: if ($search) { // looking for a term $allentries = glossary_search_entries($searchterms, $glossary, $includedefinition); } elseif ($eid) { // looking for an entry $allentries = get_records_select("glossary_entries", "id = $eid"); } elseif ( $l or $sortkey ) { - $where = ""; - if ($l != "ALL" and $l != "SPECIAL") { + if ($sortkey == 'CREATION') { + $orderby = "timecreated $sortorder"; + } else { + $orderby = "timemodified $sortorder"; + } + $where = ''; + if ($l != 'ALL' and $l != 'SPECIAL') { switch ($CFG->dbtype) { - case "postgres7": - $where = "substr(ucase(concept),1," . strlen($l) . ") = '" . strtoupper($l) . "'"; + case 'postgres7': + $where = 'substr(ucase(concept),1,' . strlen($l) . ') = \'' . strtoupper($l) . '\''; break; - case "mysql": - $where = "left(ucase(concept)," . strlen($l) . ") = '$l'"; + case 'mysql': + $where = 'left(ucase(concept),' . strlen($l) . ") = '$l'"; break; default: - $where = ""; + $where = ''; } } $allentries = glossary_get_entries_sorted($glossary, $where,$orderby); } - $currentletter = ""; + $currentletter = ''; break; } $dumpeddefinitions = 0; if ($allentries) { if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) { - echo "
"; + echo '
'; } foreach ($allentries as $entry) { $dumptoscreen = 0; $firstletter = strtoupper(substr(ltrim($entry->concept), 0, strlen($l))); if ($l) { - if ($l == "ALL" or $sortkey == "CREATION" or $sortkey == "UPDATE" or $firstletter == $l) { + if ($l == 'ALL' or $sortkey == 'CREATION' or $sortkey == 'UPDATE' or $firstletter == $l) { if ($currentletter != $firstletter[0]) { - if ($entry->approved or $USER->id == $entry->userid or $tab == GLOSSARY_APPROVAL_VIEW) { + if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $tab == GLOSSARY_APPROVAL_VIEW) { $currentletter = $firstletter[0]; if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) { if ($dumpeddefinitions > 0) { - echo "

"; + echo '

'; } echo "\n

cellheading2\">"; } - if ($l == "ALL" and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) { + if ($l == 'ALL' and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) { echo "$currentletter"; } if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) { - echo "\n
"; + echo '
'; if ($dumpeddefinitions > 0) { - echo "\n
"; + echo '
'; } } } } $dumptoscreen = 1; - } elseif ($l == "SPECIAL" and ord($firstletter) != ord("Ñ") and - (ord($firstletter) < ord("A") or ord($firstletter) > ord("Z"))) { + } elseif ($l == 'SPECIAL' and ord($firstletter) != ord('Ñ') and + (ord($firstletter) < ord('A') or ord($firstletter) > ord('Z'))) { $dumptoscreen = 1; } } else { @@ -313,29 +333,29 @@ } } else { // All categories if ($currentcategory != $entry->CID) { - if ($entry->approved or $USER->id == $entry->userid or $tab == GLOSSARY_APPROVAL_VIEW) { + if ($entry->approved or ($USER->id == $entry->userid and !isteacher($course->id)) or $tab == GLOSSARY_APPROVAL_VIEW) { $currentcategory = $entry->CID; if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) { if ($dumpeddefinitions > 0) { - echo "

"; + echo '

'; } echo "\n

cellheading2\">"; } if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) { - echo "
"; + echo '
'; } echo "$entry->name"; if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) { - echo "

"; + echo '

'; } } } $dumptoscreen = 1; if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) { - echo "\n

"; + echo ''; if ($dumpeddefinitions > 0) { - echo "\n
"; + echo '
'; } } @@ -355,7 +375,7 @@ if ($dumpeddefinitions == 1) { if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) { - echo "\n
"; + echo '
'; } } if ($search) { @@ -366,7 +386,7 @@ glossary_print_entry($course, $cm, $glossary, $entry, $tab, $cat); if ($glossary->displayformat != GLOSSARY_FORMAT_SIMPLE) { - echo "

"; + echo '

'; } } } @@ -376,23 +396,23 @@ if (!$search) { echo "

$strnoentries
"; } else { - echo "
"; + echo '
'; print_string("searchhelp"); - echo "
"; + echo '
'; } print_simple_box_end(); } else { switch ($glossary->displayformat) { case GLOSSARY_FORMAT_CONTINUOUS: - echo "
"; + echo ''; break; case GLOSSARY_FORMAT_SIMPLE: - echo "\n
"; + echo ''; break; } } - echo ""; + echo ''; glossary_print_tabbed_table_end(); /// Finish the page -- 2.39.5