From 359f27588bf48e0c9f45af86ac18df1268f5f7cd Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 26 Aug 2004 15:21:57 +0000 Subject: [PATCH] Merged from stable --- mod/forum/lib.php | 39 ++++++++++++++++++-------------------- mod/glossary/lib.php | 20 +++++++++++++++++++ mod/glossary/showentry.php | 21 ++++++++++---------- mod/glossary/view.php | 1 + 4 files changed, 49 insertions(+), 32 deletions(-) diff --git a/mod/forum/lib.php b/mod/forum/lib.php index 669f100792..2f07bc05da 100644 --- a/mod/forum/lib.php +++ b/mod/forum/lib.php @@ -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 "

"; + $commands = array(); if ($post->parent) { if ($threadedmode) { - echo "wwwroot/mod/forum/discuss.php?d=$post->discussion&parent=$post->parent\">$strparent | "; + $commands[] = "wwwroot/mod/forum/discuss.php?d=$post->discussion&parent=$post->parent\">$strparent"; } else { - echo "wwwroot/mod/forum/discuss.php?d=$post->discussion#$post->parent\">$strparent | "; + $commands[] = "wwwroot/mod/forum/discuss.php?d=$post->discussion#$post->parent\">$strparent"; } } $age = time() - $post->created; if ($ownpost or $adminedit) { if (($age < $CFG->maxeditingtime) or $adminedit) { - echo "wwwroot/mod/forum/post.php?edit=$post->id\">$stredit | "; + $commands[] = "wwwroot/mod/forum/post.php?edit=$post->id\">$stredit"; } } if (isteacheredit($courseid) and $post->parent) { - echo "wwwroot/mod/forum/post.php?prune=$post->id\" title=\"$strpruneheading\">$strprune | "; + $commands[] = "wwwroot/mod/forum/post.php?prune=$post->id\" title=\"$strpruneheading\">$strprune"; } if (($ownpost and $age < $CFG->maxeditingtime) or $isteacher) { - echo "wwwroot/mod/forum/post.php?delete=$post->id\">$strdelete"; - if ($reply) { - echo " | "; - } else { - echo "  "; - } + $commands[] = "wwwroot/mod/forum/post.php?delete=$post->id\">$strdelete"; } + if ($reply) { - echo "wwwroot/mod/forum/post.php?reply=$post->id\">$strreply"; - echo "  "; + $commands[] = "wwwroot/mod/forum/post.php?reply=$post->id\">$strreply"; } - echo "

"; + echo "

"; + echo implode(' | ', $commands).'  '; + echo "

"; echo "

"; diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index 210b2d06c9..322888596a 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -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; } diff --git a/mod/glossary/showentry.php b/mod/glossary/showentry.php index d8fe45765f..42b26dea23 100644 --- a/mod/glossary/showentry.php +++ b/mod/glossary/showentry.php @@ -12,19 +12,18 @@ } 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 = "

» 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

"; // Could not get this to work satisfactorily in all cases - Martin + $entries[$key]->footer = "

» wwwroot/mod/glossary/view.php?g=$entry->glossaryid\">$entry->glossaryname

"; } if (!empty($courseid)) { @@ -38,10 +37,10 @@ $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", "wwwroot/course/view.php?id=$course->id\">$course->shortname -> $strglossaries -> $strsearch", "", "", true, " ", " "); } else { - print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname", + print_header(strip_tags("$course->shortname: $strglossaries $strsearch"), "$course->fullname", "$strglossaries -> $strsearch", "", "", true, " ", " "); } diff --git a/mod/glossary/view.php b/mod/glossary/view.php index 42b3e05dfa..0497bb0200 100644 --- a/mod/glossary/view.php +++ b/mod/glossary/view.php @@ -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"); } -- 2.39.5