- id) {
- echo " id\">";
+ id)) {
+ echo " id\">";
}
?>
-
+
+
">
">
diff --git a/mod/glossary/edit.php b/mod/glossary/edit.php
index f9a45b00b5..8c8bec9334 100644
--- a/mod/glossary/edit.php
+++ b/mod/glossary/edit.php
@@ -6,8 +6,9 @@ require_once("lib.php");
require_variable($id); // Course Module ID
optional_variable($e); // EntryID
+optional_variable($confirm,0); // proceed. Edit the edtry
-optional_variable($currentview); // categories if by category?
+optional_variable($tab); // categories if by category?
optional_variable($cat); // CategoryID
if (! $cm = get_record("course_modules", "id", $id)) {
@@ -27,124 +28,121 @@ if (isguest()) {
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
error("Course module is incorrect");
}
-
-if ($e) {
- $form = get_record("glossary_entries", "id", $e);
-
- $newentry->id = $form->id;
- $newentry->concept = $form->concept;
- $newentry->definition = $form->definition;
- $newentry->format = $form->format;
- $newentry->timemodified = time();
-
- $entry->id = $form->id;
- $entry->text = $form->definition;
- $entry->format = $form->format;
-} else {
- if ($form = data_submitted()) {
- /// If data submitted, then process and store.
- $timenow = time();
-
- $form->text = clean_text($form->text, $form->format);
-
- if ($entry) {
- $newentry->id = $entry;
- $newentry->course = $glossary->course;
- $newentry->glossaryid = $glossary->id;
- $newentry->concept = $form->concept;
- $newentry->definition = $form->text;
- $newentry->format = $form->format;
- $newentry->usedynalink = $form->usedynalink;
- $newentry->casesensitive = $form->casesensitive;
- $newentry->fullmatch = $form->fullmatch;
- $newentry->timemodified = time();
- $newentry->teacherentry = isteacher($course->id,$USER->id);
-
- $permissiongranted = 1;
- if ( !$glossary->allowduplicatedentries ) {
- $dupentries = get_records("glossary_entries","UCASE(concept)", strtoupper($newentry->concept));
- if ($dupentries) {
- foreach ($dupentries as $curentry) {
- if ( $glossary->id == $curentry->glossaryid ) {
- if ( $curentry->id != $entry ) {
- $permissiongranted = 0;
- }
- }
- }
- }
- }
- if ( $permissiongranted ) {
- $newentry->attachment = $_FILES["attachment"];
- if ($newfilename = glossary_add_attachment($newentry, $newentry->attachment)) {
- $newentry->attachment = $newfilename;
- } else {
- unset($newentry->attachment);
- }
- if (! update_record("glossary_entries", $newentry)) {
- error("Could not update your glossary");
- } else {
- add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&eid=$newentry->id", "$newentry->id");
- }
- } else {
- error("Could not update this glossary entry because this concept already exist.");
- }
- } else {
- $newentry->userid = $USER->id;
- $newentry->course = $glossary->course;
- $newentry->glossaryid = $glossary->id;
- $newentry->concept = $form->concept;
- $newentry->definition = $form->text;
- $newentry->format = $form->format;
- $newentry->timecreated = time();
- $newentry->usedynalink = $form->usedynalink;
- $newentry->casesensitive = $form->casesensitive;
- $newentry->fullmatch = $form->fullmatch;
- $newentry->timemodified = time();
- $newentry->teacherentry = isteacher($course->id,$USER->id);
- $newentry->sourceglossaryid = 0;
-
- $permissiongranted = 1;
- if ( !$glossary->allowduplicatedentries ) {
- $dupentries = get_record("glossary_entries","UCASE(concept)", strtoupper($newentry->concept), "glossaryid", $glossary->id);
- if ($dupentries) {
- $permissiongranted = 0;
+if ( $confirm ) {
+ $form = data_submitted();
+
+ $timenow = time();
+ $form->text = clean_text($form->text, $form->format);
+
+ $newentry->course = $glossary->course;
+ $newentry->glossaryid = $glossary->id;
+
+ $newentry->concept = $form->concept;
+ $newentry->definition = $form->text;
+ $newentry->format = $form->format;
+ $newentry->usedynalink = $form->usedynalink;
+ $newentry->casesensitive = $form->casesensitive;
+ $newentry->fullmatch = $form->fullmatch;
+ $newentry->timemodified = $timenow;
+
+ if ($e) {
+ $newentry->id = $e;
+
+ $permissiongranted = 1;
+ if ( !$glossary->allowduplicatedentries ) {
+ if ($dupentries = get_records("glossary_entries","UCASE(concept)", strtoupper($newentry->concept))) {
+ foreach ($dupentries as $curentry) {
+ if ( $glossary->id == $curentry->glossaryid ) {
+ if ( $curentry->id != $entry ) {
+ $permissiongranted = 0;
+ break;
}
+ }
}
- if ( $permissiongranted ) {
- if (! $newentry->id = insert_record("glossary_entries", $newentry)) {
- error("Could not insert this new entry");
- } else {
- $newentry->attachment = $_FILES["attachment"];
- if ($newfilename = glossary_add_attachment($newentry, $newentry->attachment)) {
- $newentry->attachment = $newfilename;
- } else {
- unset($newentry->attachment);
- }
- set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id);
-
- add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&eid=$newentry->id¤tview=$currentview&cat=$cat", "$newentry->id");
- }
+ }
+ }
+
+ if ( $permissiongranted ) {
+ $newentry->attachment = $_FILES["attachment"];
+ if ($newfilename = glossary_add_attachment($newentry, $newentry->attachment)) {
+ $newentry->attachment = $newfilename;
+ } else {
+ unset($newentry->attachment);
+ }
+ if (! update_record("glossary_entries", $newentry)) {
+ error("Could not update your glossary");
+ } else {
+ add_to_log($course->id, "glossary", "update entry", "view.php?id=$cm->id&eid=$newentry->id&tab=$tab&cat=$cat", "$newentry->id");
+ }
+ } else {
+ error("Could not update this glossary entry because this concept already exist.");
+ }
+ } else {
+ $newentry->userid = $USER->id;
+ $newentry->timecreated = $timenow;
+ $newentry->sourceglossaryid = 0;
+ $newentry->approved = $glossary->defaultapproval or isteacher($course->id);
+ $newentry->teacherentry = isteacher($course->id);
+
+ $permissiongranted = 1;
+ if ( !$glossary->allowduplicatedentries ) {
+ if ($dupentries = get_record("glossary_entries","UCASE(concept)", strtoupper($newentry->concept), "glossaryid", $glossary->id)) {
+ $permissiongranted = 0;
+ }
+ }
+ if ( $permissiongranted ) {
+ if (! $newentry->id = insert_record("glossary_entries", $newentry)) {
+ error("Could not insert this new entry");
+ } else {
+ $newentry->attachment = $_FILES["attachment"];
+ if ($newfilename = glossary_add_attachment($newentry, $newentry->attachment)) {
+ $newentry->attachment = $newfilename;
} else {
- error("Could not insert this glossary entry because this concept already exist.");
- }
- }
-
- delete_records("glossary_entries_categories","entryid",$entry);
-
- if ( $categories ) {
- $newcategory->entryid = $newentry->id;
- foreach ($categories as $category) {
- if ( $category > 0 ) {
- $newcategory->categoryid =$category;
- insert_record("glossary_entries_categories",$newcategory);
- } else {
- break;
- }
+ unset($newentry->attachment);
}
- }
- redirect("view.php?id=$cm->id&eid=$newentry->id");
- die;
- }
+ set_field("glossary_entries", "attachment", $newfilename, "id", $newentry->id);
+ add_to_log($course->id, "glossary", "add entry", "view.php?id=$cm->id&eid=$newentry->id&tab=$tab&cat=$cat", "$newentry->id");
+ }
+ } else {
+ error("Could not insert this glossary entry because this concept already exist.");
+ }
+ }
+
+ delete_records("glossary_entries_categories","entryid",$e);
+
+ if ( $categories ) {
+ $newcategory->entryid = $newentry->id;
+ foreach ($categories as $category) {
+ if ( $category > 0 ) {
+ $newcategory->categoryid =$category;
+ insert_record("glossary_entries_categories",$newcategory);
+ } else {
+ break;
+ }
+ }
+ }
+ redirect("view.php?id=$cm->id&eid=$newentry->id");
+ die;
+} else {
+ if ($e) {
+ $form = get_record("glossary_entries", "id", $e);
+
+ $newentry->id = $form->id;
+ $newentry->concept = $form->concept;
+ $newentry->definition = $form->definition;
+ $newentry->format = $form->format;
+ $newentry->timemodified = time();
+ $newentry->approved = $glossary->defaultapproval or isteacher($course->id);
+ $newentry->usedynalink = $form->usedynalink;
+ $newentry->casesensitive = $form->casesensitive;
+ $newentry->fullmatch = $form->fullmatch;
+ } else {
+ $newentry->concept = "";
+ $newentry->definition = "";
+ $newentry->usedynalink = 1;
+ $newentry->casesensitive = 0;
+ $newentry->fullmatch = 1;
+ }
}
/// Otherwise fill and print the form.
@@ -160,11 +158,6 @@ if ($usehtmleditor = can_use_richtext_editor()) {
$onsubmit = "";
}
-if (empty($entry)) {
- $entry->text = "";
- $entry->format = $defaultformat;
-}
-
print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
"wwwroot/course/view.php?id=$course->id\">$course->shortname ->
id\">$strglossaries ->
diff --git a/mod/glossary/formats/2.php b/mod/glossary/formats/2.php
index 7b6717de90..17d8b0fd38 100644
--- a/mod/glossary/formats/2.php
+++ b/mod/glossary/formats/2.php
@@ -1,6 +1,6 @@
cellheading2;
@@ -16,7 +16,10 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $curren
print_user_picture($user->id, $course->id, $user->picture);
}
echo "
";
- echo "cellheading\" class=\"forumpostheader\">";
+ echo " cellheading\" class=\"forumpostheader\">";
+ if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
+ echo "id&eid=$entry->id&tab=$tab\"> ";
+ }
if ($entry->attachment) {
$entry->course = $glossary->course;
echo "";
@@ -36,7 +39,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $curren
echo "\n cellcontent\" class=\"forumpostmessage\">";
if ($entry) {
echo format_text($entry->definition, $entry->format);
- glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
+ glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
} else {
echo "";
diff --git a/mod/glossary/formats/3.php b/mod/glossary/formats/3.php
index 082451d220..0c2155e798 100644
--- a/mod/glossary/formats/3.php
+++ b/mod/glossary/formats/3.php
@@ -1,6 +1,6 @@
cellheading2;
@@ -16,8 +16,11 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $curren
print_user_picture($user->id, $course->id, $user->picture);
}
echo " ";
- echo "cellheading\" class=\"forumpostheader\">";
+ echo " cellheading\" class=\"forumpostheader\">";
if ($entry) {
+ if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
+ echo "id&eid=$entry->id&tab=$tab\"> ";
+ }
echo "$entry->concept ";
echo "$strby $user->firstname $user->lastname ";
echo " (".get_string("lastedited").": ".
@@ -27,7 +30,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $curren
echo "\n";
echo "\n ";
- echo "\ncellcontent\" class=\"forumpostmessage\">";
+ echo "\n cellcontent\" class=\"forumpostmessage\">";
if ($entry) {
if ($entry->attachment) {
$entry->course = $course->id;
@@ -42,7 +45,7 @@ function glossary_print_entry_by_format($course, $cm, $glossary, $entry, $curren
}
echo format_text($entry->definition, $entry->format);
- glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
+ glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
} else {
echo "";
diff --git a/mod/glossary/formats/4.php b/mod/glossary/formats/4.php
new file mode 100644
index 0000000000..58769a1295
--- /dev/null
+++ b/mod/glossary/formats/4.php
@@ -0,0 +1,38 @@
+cellheading2;
+
+ echo "\n";
+
+ echo "\n";
+ echo "";
+ $entry->course = $course->id;
+ if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
+ echo "id&eid=$entry->id&tab=$tab\"> ";
+ }
+ if ($entry->attachment) {
+ echo "";
+ echo glossary_print_attachments($entry, "html");
+ echo "
";
+ }
+ echo "" . get_string("question","glossary") . ": $entry->concept ";
+ echo " ".get_string("lastedited").": ".userdate($entry->timemodified)." ";
+ echo "\ncellcontent\">";
+ echo "" . get_string("answer","glossary") . ": " . format_text($entry->definition, $entry->format);
+
+ glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat);
+ echo "
\n";
+
+ } else {
+ echo "";
+ print_string("noentry", "glossary");
+ echo " ";
+ }
+
+}
+
+?>
diff --git a/mod/glossary/formats/5.php b/mod/glossary/formats/5.php
new file mode 100644
index 0000000000..0e798470b5
--- /dev/null
+++ b/mod/glossary/formats/5.php
@@ -0,0 +1,44 @@
+cellheading2;
+
+ echo "\n";
+
+ echo "\n";
+ echo "";
+ if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
+ echo "id&eid=$entry->id&tab=$tab\"> ";
+ }
+ if ($entry->attachment) {
+ $entry->course = $course->id;
+ echo "";
+ echo glossary_print_attachments($entry, "html");
+ echo "
";
+ }
+ echo "$entry->concept ";
+ if ($entry) {
+ echo " ".get_string("lastedited").": ".userdate($entry->timemodified)." ";
+ }
+ echo " ";
+
+ echo "\ncellcontent\">";
+ if ($entry) {
+ echo format_text($entry->definition, $entry->format);
+
+ glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat);
+
+ } else {
+ echo "";
+ print_string("noentry", "glossary");
+ echo " ";
+ }
+ echo " ";
+
+ echo "
\n";
+
+}
+
+?>
diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php
index eac6a65870..3ddd5d4810 100644
--- a/mod/glossary/lib.php
+++ b/mod/glossary/lib.php
@@ -7,8 +7,10 @@ require_once("$CFG->dirroot/files/mimetypes.php");
define("GLOSSARY_SHOW_ALL_CATEGORIES", 0);
define("GLOSSARY_SHOW_NOT_CATEGORISED", -1);
+
define("GLOSSARY_STANDARD_VIEW", 0);
define("GLOSSARY_CATEGORY_VIEW", 1);
+define("GLOSSARY_APPROVAL_VIEW", 2);
define("GLOSSARY_FORMAT_SIMPLE", 0);
define("GLOSSARY_FORMAT_CONTINUOUS", 1);
@@ -184,49 +186,79 @@ function glossary_get_entries($glossaryid, $entrylist) {
WHERE glossaryid = '$glossaryid'
AND id IN ($entrylist)");
}
+function glossary_get_entries_sorted($glossary, $where="", $orderby="") {
+global $CFG;
+ if ($where) {
+ $where = " and $where";
+ }
+ if ($orderby) {
+ $orderby = " ORDER BY $orderby";
+ }
+ return get_records_sql("SELECT *
+ FROM {$CFG->prefix}glossary_entries
+ WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id) $where $orderby");
+}
+
+function glossary_get_entries_by_category($glossary, $cat, $where="", $orderby="") {
+global $CFG;
+ if ($where) {
+ $where = " and $where";
+ }
+ if ($orderby) {
+ $orderby = " ORDER BY $orderby";
+ }
+ return get_records_sql("SELECT ge.*
+ FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories c
+ WHERE (ge.id = c.entryid and c.categoryid = $cat) and
+ (ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where $orderby");
+}
-function glossary_print_entry($course, $cm, $glossary, $entry, $currentview="",$cat="") {
+function glossary_print_entry($course, $cm, $glossary, $entry, $tab="",$cat="") {
global $THEME, $USER, $CFG;
-
- $permissiongranted = 0;
- $formatfile = "$CFG->dirroot/mod/glossary/formats/$glossary->displayformat.php";
- $functionname = "glossary_print_entry_by_format";
-
- $basicformat = ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE or
- $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS);
- if ( !$basicformat ) {
- if ( file_exists($formatfile) ) {
- include_once($formatfile);
- if (function_exists($functionname) ) {
- $permissiongranted = 1;
- }
+
+ if ($entry->approved or $USER->id == $entry->userid or $tab == GLOSSARY_APPROVAL_VIEW) {
+ $permissiongranted = 0;
+ $formatfile = "$CFG->dirroot/mod/glossary/formats/$glossary->displayformat.php";
+ $functionname = "glossary_print_entry_by_format";
+
+ $basicformat = ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE or
+ $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS);
+ if ( !$basicformat ) {
+ if ( file_exists($formatfile) ) {
+ include_once($formatfile);
+ if (function_exists($functionname) ) {
+ $permissiongranted = 1;
+ }
+ }
+ } else {
+ $permissiongranted = 1;
}
- } else {
- $permissiongranted = 1;
- }
- if ( !$basicformat and $permissiongranted ) {
- glossary_print_entry_by_format($course, $cm, $glossary, $entry,$currentview,$cat);
- } else {
- switch ( $glossary->displayformat ) {
- case GLOSSARY_FORMAT_SIMPLE:
- glossary_print_entry_by_default($course, $cm, $glossary, $entry,$currentview,$cat);
- break;
- case GLOSSARY_FORMAT_CONTINUOUS:
- glossary_print_entry_continuous($course, $cm, $glossary, $entry,$currentview,$cat);
- break;
+ if ( !$basicformat and $permissiongranted ) {
+ glossary_print_entry_by_format($course, $cm, $glossary, $entry,$tab,$cat);
+ } else {
+ switch ( $glossary->displayformat ) {
+ case GLOSSARY_FORMAT_SIMPLE:
+ glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab,$cat);
+ break;
+ case GLOSSARY_FORMAT_CONTINUOUS:
+ glossary_print_entry_continuous($course, $cm, $glossary, $entry,$tab,$cat);
+ break;
+ }
}
}
-
}
-function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$currentview="",$cat="") {
+function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$tab="",$cat="") {
global $THEME, $USER;
$colour = $THEME->cellheading2;
echo "\n";
- echo "";
+ echo " ";
+ if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
+ echo "id&eid=$entry->id&tab=$tab\"> ";
+ }
if ($entry->attachment) {
$entry->course = $course->id;
echo "";
@@ -235,14 +267,17 @@ function glossary_print_entry_by_default($course, $cm, $glossary, $entry,$curren
}
echo "$entry->concept : ";
echo format_text($entry->definition, $entry->format);
- glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview,$cat);
+ glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab,$cat);
echo " ";
echo " ";
}
-function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$currentview="",$cat="") {
+function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$tab="",$cat="") {
global $THEME, $USER;
if ($entry) {
+ if ( $tab == GLOSSARY_APPROVAL_VIEW ) {
+ echo "id&eid=$entry->id&tab=$tab\"> ";
+ }
if ($entry->attachment) {
$entry->course = $course->id;
echo "";
@@ -252,31 +287,34 @@ function glossary_print_entry_continuous($course, $cm, $glossary, $entry,$curren
echo " $entry->concept ";
echo format_text($entry->definition, $entry->format);
- glossary_print_entry_icons($course, $cm, $glossary, $entry, $currentview, $cat);
+ glossary_print_entry_icons($course, $cm, $glossary, $entry, $tab, $cat);
}
}
-function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview="",$cat="") {
+function glossary_print_entry_icons($course, $cm, $glossary, $entry,$tab="",$cat="") {
global $THEME, $USER;
$importedentry = ($entry->sourceglossaryid == $glossary->id);
$isteacher = isteacher($course->id);
$ismainglossary = $glossary->mainglossary;
- echo "";
+ echo "
";
+ if (!$entry->approved) {
+ echo get_string("entryishidden","glossary");
+ }
$count = count_records("glossary_comments","entryid",$entry->id);
if ($count) {
- echo "id&eid=$entry->id\">$count ";
+ echo " id&eid=$entry->id\">$count ";
if ($count == 1) {
print_string("comment", "glossary");
} else {
print_string("comments", "glossary");
}
- echo " ";
+ echo "";
}
-
+ echo " ";
if ( $glossary->allowcomments ) {
- echo "id&eid=$entry->id\"> ";
+ echo " id&eid=$entry->id\"> ";
}
if ($isteacher or $glossary->studentcanpost and $entry->userid == $USER->id) {
@@ -285,7 +323,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview
$mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);
if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry
- echo "id&entry=$entry->id¤tview=$currentview&cat=$cat\"> ";
+ echo " id&entry=$entry->id&tab=$tab&cat=$cat\"> ";
}
}
@@ -298,13 +336,13 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview
// Exported entries can be updated/deleted only by teachers in the main glossary
if ( !$importedentry and ($isteacher or !$ismainglossary) ) {
- echo "id&mode=delete&entry=$entry->id¤tview=$currentview&cat=$cat\"> id&mode=delete&entry=$entry->id&tab=$tab&cat=$cat\"> ";
- echo "id&e=$entry->id¤tview=$currentview&cat=$cat\"> ";
+ echo " id&e=$entry->id&tab=$tab&cat=$cat\"> ";
} elseif ( $importedentry ) {
- echo "" . get_string("exportedentry","glossary") . " ";
+ echo " " . get_string("exportedentry","glossary") . " ";
}
}
}
@@ -376,12 +414,12 @@ function glossary_search_entries($searchterms, $glossary, $includedefinition) {
{$CFG->prefix}glossary g $onlyvisibletable
WHERE ($conceptsearch OR $definitionsearch)
AND (e.glossaryid = g.id or e.sourceglossaryid = g.id) $onlyvisible
- AND g.id = $glossary->id";
+ AND g.id = $glossary->id AND e.approved != 0";
- $totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
+// $totalcount = count_records_sql("SELECT COUNT(*) FROM $selectsql");
- return get_records_sql("SELECT e.concept, e.definition, e.userid, e.timemodified, e.id, e.format FROM
- $selectsql ORDER BY e.concept ASC $limit");
+ return get_records_sql("SELECT e.concept, e.definition, e.userid, e.timemodified, e.id, e.format
+ FROM $selectsql ORDER BY e.concept ASC $limit");
}
function glossary_file_area_name($entry) {
@@ -710,39 +748,135 @@ function glossary_print_tabbed_table_end() {
echo "
";
}
-function glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder = "") {
-global $CFG, $THEME;
- $strselectletter = get_string("selectletter", "glossary");
- $strspecial = get_string("special", "glossary");
- $strallentries = get_string("allentries", "glossary");
- $strsort = get_string("sortchronogically", "glossary");
- $strsortbycreation = get_string("sortbycreation", "glossary");
- $strsortbylastupdate = get_string("sortbylastupdate", "glossary");
+function glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder = "",$tab=GLOSSARY_STANDARD_VIEW) {
+ $entriesawaiting = get_string("entriesawaitingapproval", "glossary");
+ echo "$entriesawaiting";
- $output = "";
- if ($glossary->showalphabet) {
- $output .= get_string("explainalphabet","glossary").' ';
+ if ($glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
+ echo '
' . get_string("explainalphabet","glossary") . '';
}
+ glossary_print_special_links($cm, $glossary,$l, $tab);
+
+ glossary_print_alphabet_links($cm, $glossary,$l, $tab);
+
+ glossary_print_all_links($cm, $glossary,$l, $tab);
+
+ glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab);
+}
+
+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);
+
+ glossary_print_alphabet_links($cm, $glossary,$l, $tab);
+
+ glossary_print_all_links($cm, $glossary,$l, $tab);
+
+ glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab);
+}
+
+function glossary_print_categories_menu($course, $cm, $glossary, $cat, $category) {
+global $CFG, $THEME;
+ 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 "";
+
+ $menu[GLOSSARY_SHOW_ALL_CATEGORIES] = get_string("allcategories","glossary");
+ $menu[GLOSSARY_SHOW_NOT_CATEGORISED] = get_string("notcategorised","glossary");
- echo " $output";
+ $categories = get_records("glossary_categories", "glossaryid", $glossary->id, "name ASC");
+ $selected = "";
+ if ( $categories ) {
+ foreach ($categories as $currentcategory) {
+ $url = $currentcategory->id;
+ if ( $category ) {
+ if ($currentcategory->id == $category->id) {
+ $selected = $url;
+ }
+ }
+ $menu[$url] = $currentcategory->name;
+ }
+ }
+ if ( !$selected ) {
+ $selected = GLOSSARY_SHOW_NOT_CATEGORISED;
+ }
+
+ if ( $category ) {
+ echo $category->name;
+ } else {
+ if ( $cat == GLOSSARY_SHOW_NOT_CATEGORISED ) {
+
+ echo get_string("entrieswithoutcategory","glossary");
+ $selected = GLOSSARY_SHOW_NOT_CATEGORISED;
+
+ } elseif ( $cat == GLOSSARY_SHOW_ALL_CATEGORIES ) {
+
+ echo get_string("allcategories","glossary");
+ $selected = GLOSSARY_SHOW_ALL_CATEGORIES;
+
+ }
+ }
+ echo "
";
+ echo "";
+
+ echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id&tab=" . GLOSSARY_CATEGORY_VIEW . "&cat=", $menu, "catmenu", $selected, "",
+ "", "", false);
- if ( $glossary->showspecial ) {
+ echo " ";
+ echo " ";
+
+ 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" ) {
+ echo "$strallentries ";
+ } else {
+ $strexplainall = strip_tags(get_string("explainall","glossary"));
+ echo "wwwroot/mod/glossary/view.php?id=$cm->id&l=ALL&tab=$tab\">$strallentries ";
+ }
+ }
+}
+
+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" ) {
echo "$strspecial | ";
} else {
$strexplainspecial = strip_tags(get_string("explainspecial","glossary"));
- echo "wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL\">$strspecial | ";
+ echo "wwwroot/mod/glossary/view.php?id=$cm->id&l=SPECIAL&tab=$tab\">$strspecial | ";
}
}
+}
- if ( $glossary->showalphabet ) {
+function glossary_print_alphabet_links($cm, $glossary,$l, $tab) {
+global $CFG;
+ if ( $glossary->showalphabet and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS ) {
$alphabet = explode("|", get_string("alphabet","glossary"));
$letters_by_line = 14;
for ($i = 0; $i < count($alphabet); $i++) {
if ( $l == $alphabet[$i] and $l) {
echo "$alphabet[$i] ";
} else {
- echo "wwwroot/mod/glossary/view.php?id=$cm->id&l=$alphabet[$i]\">$alphabet[$i] ";
+ 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 " | ";
@@ -751,15 +885,14 @@ global $CFG, $THEME;
}
}
}
+}
+
+function glossary_print_sorting_links($cm, $sortkey,$sortorder, $tab) {
+global $CFG;
+ $strsort = get_string("sortchronogically", "glossary");
+ $strsortbycreation = get_string("sortbycreation", "glossary");
+ $strsortbylastupdate = get_string("sortbylastupdate", "glossary");
- if ( $glossary->showall ) {
- if ( $l == "ALL" ) {
- echo "$strallentries ";
- } else {
- $strexplainall = strip_tags(get_string("explainall","glossary"));
- echo "wwwroot/mod/glossary/view.php?id=$cm->id&l=ALL\">$strallentries ";
- }
- }
$neworder = "";
if ( $sortorder ) {
if ( $sortorder == "asc" ) {
@@ -808,71 +941,8 @@ global $CFG, $THEME;
$cordertitle = get_string("ascending","glossary");
$uordertitle = get_string("ascending","glossary");
}
- echo " $strsort: $ubtagwwwroot/mod/glossary/view.php?id=$cm->id&sortkey=UPDATE$uneworder\">$strsortbylastupdate$uicon $uendbtag | ".
- "$cbtagwwwroot/mod/glossary/view.php?id=$cm->id&sortkey=CREATION$cneworder\">$strsortbycreation$cicon $cendbtag";
-}
-
-function glossary_print_categories_menu($course, $cm, $glossary, $cat, $category) {
-global $CFG, $THEME;
- 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 "";
-
- $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");
- if ( $categories ) {
- foreach ($categories as $currentcategory) {
- $url = $currentcategory->id;
- if ( $category ) {
- if ($currentcategory->id == $category->id) {
- $selected = $url;
- }
- }
- $menu[$url] = $currentcategory->name;
- }
- }
- if ( !$selected ) {
- $selected = GLOSSARY_SHOW_NOT_CATEGORISED;
- }
-
- if ( $category ) {
- echo $category->name;
- } else {
- if ( $cat == GLOSSARY_SHOW_NOT_CATEGORISED ) {
-
- echo get_string("entrieswithoutcategory","glossary");
- $selected = GLOSSARY_SHOW_NOT_CATEGORISED;
-
- } elseif ( $cat == GLOSSARY_SHOW_ALL_CATEGORIES ) {
-
- echo get_string("allcategories","glossary");
- $selected = GLOSSARY_SHOW_ALL_CATEGORIES;
-
- }
- }
- echo " ";
- echo "";
-
- echo popup_form("$CFG->wwwroot/mod/glossary/view.php?id=$cm->id¤tview=categories&cat=", $menu, "catmenu", $selected, "",
- "", "", false);
-
- echo " ";
- echo " ";
-
- echo " ";
- echo "
";
+ echo " $strsort: $ubtagwwwroot/mod/glossary/view.php?id=$cm->id&sortkey=UPDATE$uneworder&tab=$tab\">$strsortbylastupdate$uicon $uendbtag | ".
+ "$cbtagwwwroot/mod/glossary/view.php?id=$cm->id&sortkey=CREATION$cneworder&tab=$tab\">$strsortbycreation$cicon $cendbtag";
}
function glossary_sort_entries ( $entry0, $entry1 ) {
diff --git a/mod/glossary/mod.html b/mod/glossary/mod.html
index 490ac019c2..5716431e9e 100644
--- a/mod/glossary/mod.html
+++ b/mod/glossary/mod.html
@@ -131,6 +131,25 @@ if (!$mainglossary or $mainglossary->id == $form->instance ) {
+
+ :
+
+
+ defaultapproval ) {
+ echo "selected";
+ }
+ ?>
+ >
+ defaultapproval ) {
+ echo "selected";
+ }
+ ?>>
+
+
+
+
diff --git a/mod/glossary/version.php b/mod/glossary/version.php
index e15d5aa72d..1b01d94ac4 100644
--- a/mod/glossary/version.php
+++ b/mod/glossary/version.php
@@ -5,7 +5,7 @@
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2003101800; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2003102000; // The current module version (Date: YYYYMMDDXX)
$module->cron = 0; // Period for cron to check this module (secs)
$release = "0.5 development"; // User-friendly version number
diff --git a/mod/glossary/view.php b/mod/glossary/view.php
index 02d7d0dbac..3c654efb91 100644
--- a/mod/glossary/view.php
+++ b/mod/glossary/view.php
@@ -10,7 +10,7 @@
optional_variable($search, ""); // search string
optional_variable($includedefinition); // include definition in search function?
- optional_variable($currentview,""); // browsing entries by categories?
+ optional_variable($tab); // browsing entries by categories?
optional_variable($cat); // categoryID
optional_variable($sortkey,""); // Sorted view: CREATION or UPDATE
@@ -36,19 +36,41 @@
add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id");
- if ( $sortorder ) {
- $sortorder = strtolower($sortorder);
+/// checking for valid values for sortorder and sortkey
+ if ( $sortorder = strtolower($sortorder) ) {
if ($sortorder != "asc" and $sortorder != "desc") {
$sortorder = "";
+ } else {
+ $l = "";
+ $search ="";
}
}
- if ( $sortorder ) {
- $l = "";
- $search ="";
+ if ( $sortkey = strtoupper($sortkey) ) {
+ if ($sortkey != "CREATION" and $sortkey != "UPDATE") {
+ $sortkey = "";
+ }
}
- $search = trim(strip_tags($search));
- if ($search and !$entryid) {
+ if ( $sortkey or $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
+ if ( !$sortkey and $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
+ $sortkey = "CREATION";
+ $sortorder = "asc";
+ }
+ if ( !$sortorder ) {
+ $sortorder = "asc";
+ }
+ if ($sortkey == "CREATION") {
+ $orderby = "timecreated $sortorder";
+ } else {
+ $orderby = "timemodified $sortorder";
+ }
+ } else {
+ $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
foreach ($searchterms as $key => $searchterm) {
@@ -57,27 +79,26 @@
}
}
$search = trim(implode(" ", $searchterms));
- $currentview = "";
+ $tab = GLOSSARY_STANDARD_VIEW;
} elseif ($eid) {
$search = "";
}
-
+
$alphabet = explode("|", get_string("alphabet","glossary"));
- if ($l == "" and $search == "" and $sortkey == "" and ($eid == "" or $eid == 0)) {
+ if ($l == "" and $search == "" and $sortkey == "" and !$eid) {
+ // if the user is just entering the glossary...
$l = $alphabet[0];
} elseif ($eid) {
$l = "";
}
- if ($currentview) {
+ $category = "";
+ if ($tab == GLOSSARY_CATEGORY_VIEW) {
$l = "";
- $currentview = strtolower($currentview);
- if ($currentview) {
- if ($cat > 0) {
- $category = get_record("glossary_categories", "id", $cat);
- if (!$category) {
- $cat = "";
- }
+ if ($cat > 0) {
+ $category = get_record("glossary_categories", "id", $cat);
+ if (!$category) {
+ $cat = "";
}
}
}
@@ -107,20 +128,21 @@
/// Info box
if ( $glossary->intro ) {
- print_simple_box_start("center","70%");
+ print_simple_box_start("center","70%");
echo '';
echo $glossary->intro;
echo '
';
print_simple_box_end();
- }
+ }
/// Add button
-
- if (isteacher($course->id) or ($glossary->studentcanpost) and !isguest($course->id)) {
- $options = array ("id" => "$cm->id");
- echo '';
- print_single_button("edit.php", $options, $straddentry);
- echo '
';
+ if (!isguest()) {
+ if ( isteacher($course->id) or $glossary->studentcanpost ) {
+ $options = array ("id" => "$cm->id");
+ echo '';
+ print_single_button("edit.php", $options, $straddentry);
+ echo '
';
+ }
}
@@ -141,18 +163,6 @@
/// Tabbed browsing sections
- echo '
';
- $data[0]->link = "view.php?id=$id";
- $data[0]->caption = get_string("standardview", "glossary");
-
- $data[1]->link = "view.php?id=$id¤tview=categories";
- $data[1]->caption = get_string("categoryview", "glossary");
-
- if ($currentview) {
- $currenttab = GLOSSARY_CATEGORY_VIEW; //1;
- } else {
- $currenttab = GLOSSARY_STANDARD_VIEW; //0;
- }
$glossary_tCFG->TabTableBGColor = $THEME->cellheading;
$glossary_tCFG->ActiveTabColor = $THEME->cellheading;
$glossary_tCFG->InactiveTabColor = $THEME->cellcontent2;
@@ -162,113 +172,140 @@
$glossary_tCFG->TabsPerRow = 5;
$glossary_tCFG->TabSeparation = 4;
- glossary_print_tabbed_table_start($data, $currenttab, $glossary_tCFG);
- echo "
";
- if ($currentview) {
- glossary_print_categories_menu($course, $cm, $glossary, $cat, $category);
- $currentcategory = "";
+ echo '';
+ $data[0]->link = "view.php?id=$id";
+ $data[0]->caption = get_string("standardview", "glossary");
+
+ $data[1]->link = "view.php?id=$id&tab=".GLOSSARY_CATEGORY_VIEW;
+ $data[1]->caption = get_string("categoryview", "glossary");
+
+ if (isteacher($course->id)) {
+ $data[2]->link = "view.php?id=$id&tab=".GLOSSARY_APPROVAL_VIEW;
+ $data[2]->caption = get_string("waitingapproval", "glossary");
+ }
- } else {
- glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder);
- if ($l or $sortkey) {
- $currentletter = "";
- } elseif ($search) {
- echo "
$strsearch: $search ";
- }
- echo " ";
+ if ($tab == GLOSSARY_APPROVAL_VIEW and !isteacher($course->id)) {
+ $tab = GLOSSARY_STANDARD_VIEW;
+ }
+
+/// printing header of the current tab
+ 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:
+ glossary_print_approval_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+ break;
+ case GLOSSARY_STANDARD_VIEW:
+ default:
+ glossary_print_alphabet_menu($cm, $glossary, $l, $sortkey, $sortorder,$tab);
+ if ($search) {
+ echo "$strsearch: $search ";
+ }
+ break;
}
+ echo " ";
/// Printing the entries
- if ($search) { // looking for a term
- $allentries = glossary_search_entries($searchterms, $glossary, $includedefinition);
- } elseif ($eid) { // looking for an entry
- $allentries = get_records("glossary_entries", "id", $eid);
- } elseif ($currentview and $cat == GLOSSARY_SHOW_ALL_CATEGORIES) { // Browsing all categories
- $sql = "SELECT gec.id gecid, gc.name, gc.id CID, ge.*
- FROM {$CFG->prefix}glossary_entries ge,
- {$CFG->prefix}glossary_entries_categories gec,
- {$CFG->prefix}glossary_categories gc
- WHERE (ge.glossaryid = '$glossary->id' or ge.sourceglossaryid = '$glossary->id') AND
- gec.entryid = ge.id AND
- gc.id = gec.categoryid ";
- if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
- $sql .= "ORDER BY gc.name, ge.timecreated";
- } else {
- $sql .= "ORDER BY gc.name, ge.concept";
- }
- $allentries = get_records_sql($sql);
- } else { // looking for terms that begin with a specify letter or entries with no category associated
- if ( $sortkey == "CREATION" or $sortkey == "UPDATE" or $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
- if ( !$sortkey and $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
- $sortkey = "CREATION";
- $sortorder = "asc";
- }
- if ( !$sortorder ) {
- $sortorder = "asc";
+ switch ($tab) {
+ case GLOSSARY_CATEGORY_VIEW:
+ if ($cat == GLOSSARY_SHOW_ALL_CATEGORIES) {
+ $sql = "SELECT gec.id gecid, gc.name, gc.id CID, ge.*
+ FROM {$CFG->prefix}glossary_entries ge,
+ {$CFG->prefix}glossary_entries_categories gec,
+ {$CFG->prefix}glossary_categories gc
+ WHERE (ge.glossaryid = '$glossary->id' or ge.sourceglossaryid = '$glossary->id') AND
+ gec.entryid = ge.id AND
+ gc.id = gec.categoryid";
+
+ if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+ $sql .= " ORDER BY gc.name, ge.timecreated";
+ } else {
+ $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);
+ } else {
+ $allentries = glossary_get_entries_by_category($glossary, $cat, "",$orderby);
+ }
}
- if ($sortkey == "CREATION") {
- $orderby = "timecreated $sortorder";
- } else {
- $orderby = "timemodified $sortorder";
- }
- } else {
- $orderby = "concept ASC";
- }
- $ownentries = get_records("glossary_entries", "glossaryid", $glossary->id, $orderby);
- $importedentries = get_records("glossary_entries", "sourceglossaryid", $glossary->id, $orderby);
-
- if ($ownentries and $importedentries) {
- $allentries = array_merge($ownentries, $importedentries);
- usort($allentries, glossary_sort_entries);
- } elseif ($importedentries) {
- $allentries = $importedentries;
- } elseif ($ownentries) {
- $allentries = $ownentries;
- }
+ $currentcategory = "";
+ break;
+ case GLOSSARY_APPROVAL_VIEW:
+ $allentries = glossary_get_entries_sorted($glossary, "approved = 0",$orderby);
+ $currentletter = "";
+ break;
+ case GLOSSARY_STANDARD_VIEW:
+ 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") {
+ switch ($CFG->dbtype) {
+ case "postgres7":
+ $where = "substr(ucase(concept),1," . strlen($l) . ") = '" . strtoupper($l) . "'";
+ break;
+ case "mysql":
+ $where = "left(ucase(concept)," . strlen($l) . ") = '$l'";
+ break;
+ default:
+ $where = "";
+ }
+ }
+ $allentries = glossary_get_entries_sorted($glossary, $where,$orderby);
+ }
+ $currentletter = "";
+ break;
}
+ $dumpeddefinitions = 0;
if ($allentries) {
if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
echo "";
}
- $dumpeddefinitions = 0;
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 ($currentletter != $firstletter[0]) {
- $currentletter = $firstletter[0];
+ if ($entry->approved or $USER->id == $entry->userid or $tab == GLOSSARY_APPROVAL_VIEW) {
+ $currentletter = $firstletter[0];
- if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
- if ($dumpeddefinitions > 0) {
- echo "
";
+ if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
+ if ($dumpeddefinitions > 0) {
+ echo "
";
+ }
+ echo "\n
cellheading2\">";
+ }
+ if ($l == "ALL" and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
+ echo "$currentletter ";
}
- echo "\ncellheading2\">";
- }
- if ($l == "ALL" and $glossary->displayformat != GLOSSARY_FORMAT_CONTINUOUS) {
- echo "$currentletter ";
- }
- if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
- echo "\n
";
- if ($dumpeddefinitions > 0) {
- echo "\n";
+ if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
+ echo "\n
";
+ if ($dumpeddefinitions > 0) {
+ echo "\n";
+ }
}
}
- }
- $dumptoscreen = 1;
+ $dumptoscreen = 1;
+ }
} elseif ($l == "SPECIAL" and ord($firstletter) != ord("Ñ") and
(ord($firstletter) < ord("A") or ord($firstletter) > ord("Z"))) {
$dumptoscreen = 1;
}
} else {
- if ($currentview) {
+ if ($tab == GLOSSARY_CATEGORY_VIEW) {
if ($category) { // if we are browsing a category
- if (record_exists("glossary_entries_categories", "entryid", $entry->id, "categoryid", $category->id)) {
$dumptoscreen = 1;
- }
} else {
if ($cat == GLOSSARY_SHOW_NOT_CATEGORISED) { // Not categorized
if (! record_exists("glossary_entries_categories", "entryid", $entry->id)) {
@@ -276,19 +313,22 @@
}
} else { // All categories
if ($currentcategory != $entry->CID) {
- $currentcategory = $entry->CID;
- if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
- if ($dumpeddefinitions > 0) {
- echo "
";
+ if ($entry->approved or $USER->id == $entry->userid or $tab == GLOSSARY_APPROVAL_VIEW) {
+ $currentcategory = $entry->CID;
+ if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
+ if ($dumpeddefinitions > 0) {
+ echo "
";
+ }
+ echo "\n
cellheading2\">";
}
- echo "\ncellheading2\">";
- }
- if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
- echo "";
- }
- echo "$entry->name ";
- if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
- echo " ";
+ if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+ echo "
";
+ }
+ echo "$entry->name ";
+ if ( $glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS ) {
+ echo " ";
+ }
+ $dumptoscreen = 1;
}
}
@@ -323,7 +363,7 @@
$entry->definition = highlight($search, $definition);
}
- glossary_print_entry($course, $cm, $glossary, $entry, $currentview, $cat);
+ glossary_print_entry($course, $cm, $glossary, $entry, $tab, $cat);
if ($glossary->displayformat != GLOSSARY_FORMAT_SIMPLE) {
echo "
";
@@ -342,11 +382,13 @@
}
print_simple_box_end();
} else {
- if ($glossary->displayformat == GLOSSARY_FORMAT_CONTINUOUS) {
- echo "
";
- }
- if ($glossary->displayformat == GLOSSARY_FORMAT_SIMPLE) {
- echo "\n
";
+ switch ($glossary->displayformat) {
+ case GLOSSARY_FORMAT_CONTINUOUS:
+ echo "
";
+ break;
+ case GLOSSARY_FORMAT_SIMPLE:
+ echo "\n";
+ break;
}
}