]> git.mjollnir.org Git - moodle.git/commitdiff
- Some fixes when deleting entries and glossaries.
authorwillcast <willcast>
Tue, 2 Dec 2003 14:35:39 +0000 (14:35 +0000)
committerwillcast <willcast>
Tue, 2 Dec 2003 14:35:39 +0000 (14:35 +0000)
- Changing the way the comments are shown
- Saving a couple of lines in the Add Entry screen.

lang/en/glossary.php
mod/glossary/deleteentry.php
mod/glossary/edit.html
mod/glossary/lib.php

index d31d5acbb0cb0d15364e654d85cb47fcb7d3120f..73d6d70a2d7250aba27b5da43cf235b464a384b5 100644 (file)
@@ -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<br><small>(when automatically linked)</small>';
+$string['fullmatch'] = 'Match whole words only';
 $string['glossarytype'] = 'Glossary Type';
 $string['glosssaryexported'] = 'Glossary exported.';
 $string['importcategories'] = 'Import categories';
index 4dffa32ea5b047a26f991d082a78e792e60639ed..32520812e09c686e5c7e6d94a49011310b3825f0 100644 (file)
                         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);                           
                     }
 
index 28ab077d950a54ea7f343dc940d630902199a62f..6e5e93f5dbc57d8ba2a7415ec2dd065c0d4c6343 100644 (file)
@@ -17,18 +17,42 @@ if (isset($errors)) {
 <tr valign=top>
     <td align=right><p><b><?php echo get_string("concept","glossary") ?>:</b></p></td>
     <td>
-        <INPUT type="text" name="concept" size=30 value="<?php p($newentry->concept) ?>">
+       <table boder="0" width="100%">
+           <tr>
+               <td>
+        <INPUT type="text" name="concept" size=30 value="<?php p($newentry->concept) ?>"></td>
+           <td align="right">
+<?PHP 
+    if ( !$glossary->usedynalink ) {
+       echo '<input type="hidden" name=usedynalink value="0">';
+       echo '<input type="hidden" name=casesensitive value="0">';
+       echo '<input type="hidden" name=fullmatch value="0">';
+    } else {
+        echo '<small>' . get_string("entryusedynalink","glossary") . ':</small>';
+        echo '<script>var items = [\'casesensitive\',\'fullmatch\'];</script>';
+        $selected = "";
+        if ( isset($newentry->usedynalink) ) {
+            if ($newentry->usedynalink) {
+                $selected = "checked";
+            }
+        } elseif ( $CFG->glossary_linkentries ) {
+            $selected = "checked";
+        }
+        echo '<input type="checkbox" name="usedynalink" value=1 ' . $selected . ' onclick="return lockoptions(\'form\',\'usedynalink\', items)"> ' . helpbutton("usedynalink", strip_tags(get_string("usedynalink", "glossary")), "glossary"); 
+    }
+?> 
+       </td></tr></table>
     </td>
 </tr>
 <tr valign=top>
     <td align=right><p><b><?php echo get_string("categories","glossary") ?>:</b></p></td>
-    <td>
+    <td valign="top">
     <table border=0>
     <tr>
-    <td>
+    <td valign="top">
     <?php
         $categories = get_records("glossary_categories","glossaryid",$glossary->id);
-        echo "<select size=\"8\" name=\"categories[]\" multiple=\"yes\">";
+        echo "<select size=\"5\" name=\"categories[]\" multiple=\"yes\">";
         echo "<option value=\"0\">" . get_string("notcategorised","glossary") . "</optioon>";
 
         if ( $categories ) {
@@ -44,75 +68,53 @@ if (isset($errors)) {
         }
     ?>
     </select>
-    <td>
-    <td width=100%>
-    <table border=0>
+    </td>
+    <td width="100%" valign="top">
+    <table border="0">
         <tr>
-        <td align=center width=58%>
+        <td align="center" width="58%" valign="top">
 <?PHP 
-    if ( !$glossary->usedynalink ) {
-       echo '<input type="hidden" name=usedynalink value="0">';
-       echo '<input type="hidden" name=casesensitive value="0">';
-       echo '<input type="hidden" name=fullmatch value="0">';
-    } else {
-?>
-    <table border=0 width=100%>
-        <tr><td align=right width=80%><small><?php echo get_string("entryusedynalink","glossary") ?>:</small></td><td width=20%>
-    <script>
-        var items = ['casesensitive','fullmatch'];
-    </script>
-<?php
-    $selected = "";
-    if ( isset($newentry->usedynalink) ) {
-        if ($newentry->usedynalink) {
-            $selected = "checked";
-        }
-    } elseif ( $CFG->glossary_linkentries ) {
-        $selected = "checked";
-    }
-?> 
-    <input type="checkbox" name="usedynalink" value=1 <?php p($selected) ?> onclick="return lockoptions('form','usedynalink', items)"> <?php helpbutton("usedynalink", strip_tags(get_string("usedynalink", "glossary")), "glossary") ?>
-        </td></tr>
-        <tr><td align=right width=80%><small><?php echo get_string("casesensitive","glossary") ?>:</small></td><td width=20%>
-<?php
-    $selected = "";
-    if ( isset($newentry->casesensitive) ) {
-        if ($newentry->casesensitive) {
+    if ( $glossary->usedynalink ) {
+        
+        echo '<table border="0" width="100%">';
+       echo '<tr><td colspan="2" align="right"><small><strong> ' . get_string("aliases","glossary") . ' ';
+        helpbutton("aliases", strip_tags(get_string("aliases", "glossary")), "glossary");
+        echo '</strong><p></td></tr>';
+        echo '<tr><td align="right" width="80%" valign="top"><small> ' . get_string("casesensitive","glossary") . ':</small></td><td width=20%>';
+
+        $selected = "";
+        if ( isset($newentry->casesensitive) ) {
+            if ($newentry->casesensitive) {
+                $selected = "checked";
+            }
+        } elseif ( $CFG->glossary_casesensitive ) {
             $selected = "checked";
         }
-    } elseif ( $CFG->glossary_casesensitive ) {
-        $selected = "checked";
-    }
-?> 
-    <input type="checkbox" name="casesensitive" value=1 <?php p($selected) ?>> <?php helpbutton("casesensitive", strip_tags(get_string("casesensitive", "glossary")), "glossary") ?>
-        </td></tr>
-        <tr><td align=right width=80%><small><?php echo get_string("fullmatch","glossary") ?>:</small></td><td width=20%>
-<?php
-    $selected = "";
-    if ( isset($newentry->fullmatch) ) {
-        if ($newentry->fullmatch) {
+        echo '<input type="checkbox" name="casesensitive" value=1 ' . $selected . '> ' . helpbutton("casesensitive", strip_tags(get_string("casesensitive", "glossary")), "glossary");
+        echo '</td></tr>';
+        echo '<tr><td align="right" width="80%" valign="top"><small>' . get_string("fullmatch","glossary") . ':</small></td><td width=20%>';
+
+        $selected = "";
+        if ( isset($newentry->fullmatch) ) {
+            if ($newentry->fullmatch) {
+                $selected = "checked";
+            }
+        } elseif ( $CFG->glossary_fullmatch ) {
             $selected = "checked";
         }
-    } elseif ( $CFG->glossary_fullmatch ) {
-        $selected = "checked";
-    }
-?> 
-    <input type="checkbox" name="fullmatch" value=1 <?php p($selected) ?>> <?php helpbutton("fullmatch", strip_tags(get_string("fullmatch", "glossary")), "glossary") ?>
-        </td></tr>
-    </table>
-<?PHP 
+        echo '<input type="checkbox" name="fullmatch" value=1 ' .  $selected . ' ' . helpbutton("fullmatch", strip_tags(get_string("fullmatch", "glossary")), "glossary");
+        echo '</td></tr>';
+        echo '</table>';
+
+        echo '</td>';
+        echo '<td align="center" width="42%" valign="top">';
+        echo '<textarea rows="5" name="aliases" cols="20">' . $newentry->aliases . '</textarea>';
+        echo '</td>';
+        echo '</tr>';
     }  // end-if !$usedynalink
+    echo '</td></tr></table>';
 ?>
 
-        </td>
-        <td align=center width=42% valign=top>
-            <small><strong><?PHP p(get_string("aliases","glossary")) ?> <?php helpbutton("aliases", strip_tags(get_string("aliases", "glossary")), "glossary") ?></strong><small><br>
-            <font size=1><?PHP p(get_string("onebyline","glossary")) ?></font><br>
-            <textarea rows="5" name="aliases" cols="20"><?PHP p($newentry->aliases) ?></textarea>
-        </td>
-        </tr>
-    </table>
-
     </td>
     </tr>
     </table>
index f3e0da2846e20a3248d5f6ff07584089934a3f9b..b6683fdcdd5f13625d00d175a1aa9c8085ef0215 100644 (file)
@@ -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 "<table class=\"generalbox\"  BORDER=1 CELLSPACING=0 valign=top cellpadding=0 width=70% border=0><tr><td>";
+    echo '<table border="0" width="70%" cellpadding="3" cellspacing="0" class="forumpost">';
+    echo "<tr>";
 
-    echo "\n<TABLE width=\"100%\" BORDER=0 CELLSPACING=0 valign=top cellpadding=5><tr>";
-  
-    echo "\n<TD BGCOLOR=\"$THEME->cellheading\" WIDTH=25% VALIGN=TOP align=right >";
+    $fullname = fullname($user, isteacher($course->id));
+
+    echo "<td bgcolor=\"$THEME->cellheading\" class=\"forumpostheader\" width=\"100%\">";
+    echo "<p>";
     print_user_picture($user->id, $course->id, $user->picture);
-    echo "<br><FONT SIZE=2>$strby $user->firstname $user->lastname</font>";
-    echo "<br><FONT SIZE=1>(".get_string("lastedited").": ".userdate($comment->timemodified).")</FONT></small><br>";
-    echo "</TD>";
+    echo "<font size=3>&nbsp;<b>$fullname</b></font><br \>";
+    echo "<FONT SIZE=1>&nbsp;&nbsp;&nbsp;(".get_string("lastedited").": ".userdate($comment->timemodified).")</FONT></small>";
+    echo "<font size=2>";
 
-    echo "<TD valign=top WIDTH=75% BGCOLOR=\"$THEME->cellcontent\">";
-    if ($comment) {
-        echo format_text($comment->comment, $comment->format);
-    } else {
-      echo "<center>";
-        print_string("nocomment", "glossary");
-      echo "</center>";
-    }
 
-    echo "<p align=right>";
+    echo "</font></p></td></tr>";
+    echo "<tr><td bgcolor=\"$THEME->cellcontent\" class=\"forumpostmessage\">\n";
+
+    echo format_text($comment->comment, $comment->format);
+
+    echo "<p align=right><font size=-1>";
+
+    echo "</p>";
+
+    echo "<div align=right><p align=right>";
     if ( (time() - $comment->timemodified <  $CFG->maxeditingtime and $USER->id == $comment->userid)  or isteacher($course->id) ) {
         echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id&cid=$comment->id&action=edit\"><img  alt=\"" . get_string("edit") . "\" src=\"../../pix/t/edit.gif\" height=11 width=11 border=0></a> ";
     }
     if ( $USER->id == $comment->userid or isteacher($course->id) ) {
         echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id&cid=$comment->id&action=delete\"><img  alt=\"" . get_string("delete") . "\" src=\"../../pix/t/delete.gif\" height=11 width=11 border=0></a>";
     }
-    echo "</td>";
     
-    echo "</tr></TABLE>\n";
+    echo "</p>";
+    echo "</div>";
+    echo "</td></tr>\n</table>\n\n";
 
-    echo "</td></tr></table>";
 }
 
 function  glossary_print_entry_ratings($course, $entry, $ratings = NULL) {