From 072f753331af62de56c676eb17acf84d281c6c44 Mon Sep 17 00:00:00 2001 From: willcast Date: Tue, 2 Dec 2003 14:35:39 +0000 Subject: [PATCH] - Some fixes when deleting entries and glossaries. - Changing the way the comments are shown - Saving a couple of lines in the Add Entry screen. --- lang/en/glossary.php | 2 +- mod/glossary/deleteentry.php | 4 ++ mod/glossary/edit.html | 130 ++++++++++++++++++----------------- mod/glossary/lib.php | 53 ++++++++------ 4 files changed, 102 insertions(+), 87 deletions(-) diff --git a/lang/en/glossary.php b/lang/en/glossary.php index d31d5acbb0..73d6d70a2d 100644 --- a/lang/en/glossary.php +++ b/lang/en/glossary.php @@ -96,7 +96,7 @@ $string['exportentries'] = 'Export entries'; $string['exporttomainglossary'] = 'Export to main glossary'; $string['filetoimport'] = 'File to import'; $string['fillfields'] = 'Concept and definition are mandatory fields.'; -$string['fullmatch'] = 'Match whole words only
(when automatically linked)'; +$string['fullmatch'] = 'Match whole words only'; $string['glossarytype'] = 'Glossary Type'; $string['glosssaryexported'] = 'Glossary exported.'; $string['importcategories'] = 'Import categories'; diff --git a/mod/glossary/deleteentry.php b/mod/glossary/deleteentry.php index 4dffa32ea5..32520812e0 100644 --- a/mod/glossary/deleteentry.php +++ b/mod/glossary/deleteentry.php @@ -65,6 +65,10 @@ if ( $entry->attachment ) { glossary_delete_old_attachments($entry); } + delete_records("glossary_comments", "entryid",$entry->id); + delete_records("glossary_alias", "entryid", $entry->id); + delete_records("glossary_ratings", "entryid", $entry->id); + delete_records("glossary_entries","id", $entry->id); } diff --git a/mod/glossary/edit.html b/mod/glossary/edit.html index 28ab077d95..6e5e93f5db 100644 --- a/mod/glossary/edit.html +++ b/mod/glossary/edit.html @@ -17,18 +17,42 @@ if (isset($errors)) {

:

- + + + +
+ +usedynalink ) { + echo ''; + echo ''; + echo ''; + } else { + echo '' . get_string("entryusedynalink","glossary") . ':'; + echo ''; + $selected = ""; + if ( isset($newentry->usedynalink) ) { + if ($newentry->usedynalink) { + $selected = "checked"; + } + } elseif ( $CFG->glossary_linkentries ) { + $selected = "checked"; + } + echo ' ' . helpbutton("usedynalink", strip_tags(get_string("usedynalink", "glossary")), "glossary"); + } +?> +

:

- + -
+ id); - echo ""; echo " - - + + - - -
+ - '; + echo ''; + echo ''; } // end-if !$usedynalink + echo '
+ usedynalink ) { - echo ''; - echo ''; - echo ''; - } else { -?> - - - '; + echo '
: - -usedynalink) ) { - if ($newentry->usedynalink) { - $selected = "checked"; - } - } elseif ( $CFG->glossary_linkentries ) { - $selected = "checked"; - } -?> - onclick="return lockoptions('form','usedynalink', items)"> -
: -casesensitive) ) { - if ($newentry->casesensitive) { + if ( $glossary->usedynalink ) { + + echo ''; + echo ''; + echo ' - '; + echo ' -
' . get_string("aliases","glossary") . ' '; + helpbutton("aliases", strip_tags(get_string("aliases", "glossary")), "glossary"); + echo '

' . get_string("casesensitive","glossary") . ':'; + + $selected = ""; + if ( isset($newentry->casesensitive) ) { + if ($newentry->casesensitive) { + $selected = "checked"; + } + } elseif ( $CFG->glossary_casesensitive ) { $selected = "checked"; } - } elseif ( $CFG->glossary_casesensitive ) { - $selected = "checked"; - } -?> - > -
: -fullmatch) ) { - if ($newentry->fullmatch) { + echo ' ' . helpbutton("casesensitive", strip_tags(get_string("casesensitive", "glossary")), "glossary"); + echo '
' . get_string("fullmatch","glossary") . ':'; + + $selected = ""; + if ( isset($newentry->fullmatch) ) { + if ($newentry->fullmatch) { + $selected = "checked"; + } + } elseif ( $CFG->glossary_fullmatch ) { $selected = "checked"; } - } elseif ( $CFG->glossary_fullmatch ) { - $selected = "checked"; - } -?> - > -
-
'; + + echo '
'; + echo ''; + echo '
'; ?> -
-
-
- -
-
diff --git a/mod/glossary/lib.php b/mod/glossary/lib.php index f3e0da2846..b6683fdcdd 100644 --- a/mod/glossary/lib.php +++ b/mod/glossary/lib.php @@ -121,7 +121,13 @@ function glossary_delete_instance($id) { if ( $entries = get_records("glossary_entries", "glossaryid", $glossary->id) ) { $ents = ""; foreach ( $entries as $entry ) { - $ents .= "$entry->id,"; + if ( $entry->sourceglossaryid ) { + $entry->glossaryid = $entry->sourceglossaryid; + $entry->sourceglossaryid = 0; + update_record("glossary_entries",$entry); + } else { + $ents .= "$entry->id,"; + } } $ents = substr($ents,0,-1); if ($ents) { @@ -130,7 +136,7 @@ function glossary_delete_instance($id) { delete_records_select("glossary_ratings", "entryid in ($ents)"); } } - glossary_delete_glossary_attachments($glossary); + glossary_delete_attachments($glossary); delete_records("glossary_entries", "glossaryid", "$glossary->id"); } @@ -806,7 +812,7 @@ function glossary_delete_old_attachments($entry, $exception="") { } } } -function glossary_delete_glossary_attachments($glossary) { +function glossary_delete_attachments($glossary) { // Deletes all the user files in the attachments area for the glossary if ( $entries = get_records("glossary_entries","glossaryid",$glossary->id) ) { $deleted = 0; @@ -1394,37 +1400,40 @@ function glossary_print_comment($course, $cm, $glossary, $entry, $comment) { $user = get_record("user", "id", $comment->userid); $strby = get_string("writtenby","glossary"); - echo "\n
"; + echo ''; + echo ""; - echo "\n
"; - - echo "\n"; + echo " $fullname
"; + echo "   (".get_string("lastedited").": ".userdate($comment->timemodified).")"; + echo ""; - echo ""; + echo ""; - echo "
cellheading\" WIDTH=25% VALIGN=TOP align=right >"; + $fullname = fullname($user, isteacher($course->id)); + + echo "cellheading\" class=\"forumpostheader\" width=\"100%\">"; + echo "

"; print_user_picture($user->id, $course->id, $user->picture); - echo "
$strby $user->firstname $user->lastname"; - echo "
(".get_string("lastedited").": ".userdate($comment->timemodified).")
"; - echo "

cellcontent\">"; - if ($comment) { - echo format_text($comment->comment, $comment->format); - } else { - echo "
"; - print_string("nocomment", "glossary"); - echo "
"; - } - echo "

"; + echo "

cellcontent\" class=\"forumpostmessage\">\n"; + + echo format_text($comment->comment, $comment->format); + + echo "

"; + + echo "

"; + + echo "

"; 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) ) { echo "id&eid=$entry->id&cid=$comment->id&action=delete\">\"""; } - echo "

\n"; + echo "

"; + echo ""; + echo "
\n\n"; - echo ""; } function glossary_print_entry_ratings($course, $entry, $ratings = NULL) { -- 2.39.5