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));
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 " ";
- }
+ $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 " ";
+ $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).' ';
+ echo "</font></p>";
echo "<div align=right><p align=right>";
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) {
if (!empty($entry->highlight)) {
$text = highlight($entry->highlight, $text);
}
+ if (isset($entry->footer)) { // Unparsed footer info
+ $text .= $entry->footer;
+ }
echo $text;
}
}
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\">» <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\">» <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, " ", " ");
} else {
- print_header(strip_tags("$course->shortname: $glossary->name"), "$course->fullname",
+ print_header(strip_tags("$course->shortname: $strglossaries $strsearch"), "$course->fullname",
"$strglossaries -> $strsearch", "", "", true, " ", " ");
}
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");
}