]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from stable
authormoodler <moodler>
Thu, 26 Aug 2004 15:21:57 +0000 (15:21 +0000)
committermoodler <moodler>
Thu, 26 Aug 2004 15:21:57 +0000 (15:21 +0000)
mod/forum/lib.php
mod/glossary/lib.php
mod/glossary/showentry.php
mod/glossary/view.php

index 669f1007920ce4d21884ec92830ecc7a2a477e02..2f07bc05da237f6eecf3dff90a778cea32cd6eb7 100644 (file)
@@ -1407,15 +1407,15 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
 
     global $THEME, $USER, $CFG;
 
-    static $stredit, $strdelete, $strreply, $strparent, $threadedmode, $isteacher, $adminedit;
+    static $stredit, $strdelete, $strreply, $strparent, $strprune, $strpruneheading, $threadedmode, $isteacher, $adminedit;
 
     if (empty($stredit)) {
-        $stredit = get_string("edit", "forum");
-        $strdelete = get_string("delete", "forum");
-        $strreply = get_string("reply", "forum");
-        $strparent = get_string("parent", "forum");
-        $strprune = get_string("prune", "forum");
-        $strpruneheading = get_string("pruneheading", "forum");
+        $stredit = get_string('edit', 'forum');
+        $strdelete = get_string('delete', 'forum');
+        $strreply = get_string('reply', 'forum');
+        $strparent = get_string('parent', 'forum');
+        $strpruneheading = get_string('pruneheading', 'forum');
+        $strprune = get_string('prune', 'forum');
         $threadedmode = (!empty($USER->mode) and ($USER->mode == FORUM_MODE_THREADED));
         $isteacher = isteacher($courseid);
         $adminedit = (isadmin() and !empty($CFG->admineditalways));
@@ -1486,40 +1486,37 @@ function forum_print_post(&$post, $courseid, $ownpost=false, $reply=false, $link
         echo $attachedimages;
     }
 
-    echo "<p align=right><font size=-1>";
+    $commands = array();
 
     if ($post->parent) {
         if ($threadedmode) {
-            echo "<a href=\"$CFG->wwwroot/mod/forum/discuss.php?d=$post->discussion&parent=$post->parent\">$strparent</a> | ";
+            $commands[] = "<a href=\"$CFG->wwwroot/mod/forum/discuss.php?d=$post->discussion&parent=$post->parent\">$strparent</a>";
         } else {
-            echo "<a href=\"$CFG->wwwroot/mod/forum/discuss.php?d=$post->discussion#$post->parent\">$strparent</a> | ";
+            $commands[] = "<a href=\"$CFG->wwwroot/mod/forum/discuss.php?d=$post->discussion#$post->parent\">$strparent</a>";
         }
     }
 
     $age = time() - $post->created;
     if ($ownpost or $adminedit) {
         if (($age < $CFG->maxeditingtime) or $adminedit) {
-            echo "<a href=\"$CFG->wwwroot/mod/forum/post.php?edit=$post->id\">$stredit</a> | ";
+            $commands[] =  "<a href=\"$CFG->wwwroot/mod/forum/post.php?edit=$post->id\">$stredit</a>";
         }
     }
 
     if (isteacheredit($courseid) and $post->parent) {
-        echo "<a href=\"$CFG->wwwroot/mod/forum/post.php?prune=$post->id\" title=\"$strpruneheading\">$strprune</a> | ";
+        $commands[] = "<a href=\"$CFG->wwwroot/mod/forum/post.php?prune=$post->id\" title=\"$strpruneheading\">$strprune</a>";
     }
 
     if (($ownpost and $age < $CFG->maxeditingtime) or $isteacher) {
-        echo "<a href=\"$CFG->wwwroot/mod/forum/post.php?delete=$post->id\">$strdelete</a>";
-        if ($reply) {
-            echo " | ";
-        } else {
-            echo "&nbsp;&nbsp;";
-        }
+        $commands[] = "<a href=\"$CFG->wwwroot/mod/forum/post.php?delete=$post->id\">$strdelete</a>";
     }
+
     if ($reply) {
-        echo "<a href=\"$CFG->wwwroot/mod/forum/post.php?reply=$post->id\">$strreply</a>";
-        echo "&nbsp;&nbsp;";
+        $commands[] = "<a href=\"$CFG->wwwroot/mod/forum/post.php?reply=$post->id\">$strreply</a>";
     }
-    echo "</p>";
+    echo "<p align=right><font size=-1>";
+    echo implode(' | ', $commands).'&nbsp;&nbsp;';
+    echo "</font></p>";
 
     echo "<div align=right><p align=right>";
 
index 210b2d06c98e469c7edd9fc99ddf07737ecd08ae..322888596a8fe0978e7423a620933305856e8ccb 100644 (file)
@@ -478,6 +478,23 @@ function glossary_get_entries($glossaryid, $entrylist, $pivot = "") {
                             WHERE glossaryid = '$glossaryid'
                             AND id IN ($entrylist)");
 }
+
+function glossary_get_entries_search($concept, $courseid) {
+    global $CFG;
+
+    $conceptupper = strtoupper(trim($concept));
+
+    return get_records_sql("SELECT e.*, g.name as glossaryname
+                              FROM {$CFG->prefix}glossary_entries e, 
+                                   {$CFG->prefix}glossary g
+                             WHERE e.glossaryid = g.id 
+                               AND (    (e.casesensitive != 0 and UPPER(concept) = '$conceptupper')
+                                     OR (e.casesensitive = 0 and concept = '$concept'))
+                               AND (g.course = '$courseid' OR g.globalglossary = 1)
+                               AND e.usedynalink != 0 
+                               AND g.usedynalink != 0");
+}
+
 function glossary_get_entries_sorted($glossary, $where="", $orderby="", $pivot = "") {
 global $CFG;
     if ($where) {
@@ -586,6 +603,9 @@ function glossary_print_entry_definition($entry) {
     if (!empty($entry->highlight)) {
         $text = highlight($entry->highlight, $text);
     }
+    if (isset($entry->footer)) {   // Unparsed footer info
+        $text .= $entry->footer;
+    }
     echo $text;
 }
 
index d8fe45765f41fbf20e129886dc08ea6165cf70fe..42b26dea23b2c6bbc1edabbd62564d262bd59c68 100644 (file)
     }
 
     if ($eid) {
-        $entries[] = get_record("glossary_entries", "id", $eid);
+        $entry = get_record("glossary_entries", "id", $eid);
+        $glossary = get_record('glossary','id',$entry->glossaryid);
+        $entry->glossaryname = $glossary->name;
+        $entries[] = $entry;
 
     } else if ($concept) {
-        $entries = get_records_sql("select e.* from {$CFG->prefix}glossary_entries e, {$CFG->prefix}glossary g".
-                                  " where e.glossaryid = g.id and".
-                                      " (e.casesensitive != 0 and ucase(concept) = '" . strtoupper(trim($concept)). "' or".
-                                      " e.casesensitive = 0 and concept = '$concept') and".
-                                      " (g.course = $courseid or g.globalglossary) and".
-                                      " e.usedynalink != 0 and g.usedynalink != 0");
+        $entries = glossary_get_entries_search($concept, $courseid);
     }
 
-    foreach ($entries as $entry) {
-        $glossary = get_record('glossary','id',$entry->glossaryid);
+    foreach ($entries as $key => $entry) {
+        //$entries[$key]->footer = "<p align=\"right\">&raquo;&nbsp;<a onClick=\"if (window.opener) {window.opener.location.href='$CFG->wwwroot/mod/glossary/view.php?g=$entry->glossaryid'; return false;} else {openpopup('/mod/glossary/view.php?g=$entry->glossaryid', 'glossary', 'menubar=1,location=1,toolbar=1,scrollbars=1,directories=1,status=1,resizable=1', 0); return false;}\" href=\"$CFG->wwwroot/mod/glossary/view.php?g=$entry->glossaryid\" target=\"_blank\">$entry->glossaryname</a></p>";  // Could not get this to work satisfactorily in all cases  - Martin
+        $entries[$key]->footer = "<p align=\"right\">&raquo;&nbsp;<a target=\"_blank\" href=\"$CFG->wwwroot/mod/glossary/view.php?g=$entry->glossaryid\">$entry->glossaryname</a></p>";
     }
 
     if (!empty($courseid)) {
 
         $CFG->framename = "newwindow";
         if ($course->category) {
-            print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
+            print_header(strip_tags("$course->shortname: $strglossaries $strsearch"), "$course->fullname",
             "<a target=\"newwindow\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> -> $strglossaries -> $strsearch", "", "", true, "&nbsp;", "&nbsp;");
         } else {
-            print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
+            print_header(strip_tags("$course->shortname: $strglossaries $strsearch"), "$course->fullname",
             "$strglossaries -> $strsearch", "", "", true, "&nbsp;", "&nbsp;");
         }
 
index 42b3e05dfa8bda8291109d0429192be71c6387fd..0497bb02003c2a3046e3d8e5920850b63fd57bd0 100644 (file)
@@ -49,6 +49,7 @@
         if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id, $course->id)) {
             error("Could not determine which course module this belonged to!");
         }
+        $id = $cm->id;
     } else {
         error("Must specify glossary ID or course module ID");
     }