]> git.mjollnir.org Git - moodle.git/commitdiff
- Fixed a problem when showing the icons in entries with inline images.
authorwillcast <willcast>
Sat, 18 Oct 2003 13:33:46 +0000 (13:33 +0000)
committerwillcast <willcast>
Sat, 18 Oct 2003 13:33:46 +0000 (13:33 +0000)
- Fixed a bug when deleting entries without attachments.

mod/glossary/deleteentry.php
mod/glossary/lib.php

index ef773ecb7cc69da07fd562790b02880d6d94723a..08eac8072770dd3ac2f3900009ff09428c1adc15 100644 (file)
@@ -1,7 +1,7 @@
 <?PHP // $Id$
 
-       require_once("../../config.php");
-       require_once("lib.php");
+    require_once("../../config.php");
+    require_once("lib.php");
 
     require_variable($id);    // course module ID
     require_variable($mode);  // edit or delete
 /// If data submitted, then process and store.
     
     if ($mode == "edit" or $mode == "delete" ) {
-       echo "<p>";
-       if ( isteacher($cm->id) or $glossary->studentcanpost ) {
-               if ($go) {      // the operation was confirmed.
-                       if ( $mode == "delete") {
-                           // if it is an imported entry, just delete the relation
-                           $entry = get_record("glossary_entries","id", $entry);
-                           if ( $entry->sourceglossaryid ) {
-                               $entry->glossaryid = $entry->sourceglossaryid;
-                               $entry->sourceglossaryid = 0;
+        echo "<p>";
+        if ( isteacher($cm->id) or $glossary->studentcanpost ) {
+            if ($go) { // the operation was confirmed.
+                if ( $mode == "delete") {
+                    // if it is an imported entry, just delete the relation
+                    $entry = get_record("glossary_entries","id", $entry);
+                    if ( $entry->sourceglossaryid ) {
+                        $entry->glossaryid = $entry->sourceglossaryid;
+                        $entry->sourceglossaryid = 0;
                         if (! update_record("glossary_entries", $entry)) {
                                error("Could not update your glossary");
-                               }
-                           } else {
-                                   glossary_delete_old_attachments($entry->id);
-                                   delete_records("glossary_entries","id", $entry->id);                                
-                           }
-                       
+                        }
+                    } else {
+                        if ( $entry->attachment ) {
+                            glossary_delete_old_attachments($entry->id);
+                        }
+                        delete_records("glossary_entries","id", $entry->id);                           
+                    }
+
+                    print_simple_box_start("center","40%", "#FFBBBB");
+                    echo "<center>$entrydeleted"; //CAMBIAR
+                    echo "</center>";
+                    print_simple_box_end();
+                }
+                print_footer($course);
+                add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&currentview=$currentview&cat=$cat", $entry);
+                redirect("view.php?id=$cm->id&currentview=$currentview&cat=$cat");
+            } else {        // the operation has not been confirmed yet so ask the user to do so
+                if ( $mode == "delete") {                              
                     print_simple_box_start("center","40%", "#FFBBBB");
-                               echo "<center>$entrydeleted"; //CAMBIAR
-                               echo "</center>";
-                               print_simple_box_end();
-                       }
-                               print_footer($course);
-                      add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&currentview=$currentview&cat=$cat", $entry);
-                       redirect("view.php?id=$cm->id&currentview=$currentview&cat=$cat");
-               } else {                // the operation has not been confirmed yet so ask the user to do so
-                       if ( $mode == "delete") {                               
-                               print_simple_box_start("center","40%", "#FFBBBB");
-                               echo "<center><b>$entryfields->concept</b><br>$strareyousuredelete";
-                               
-                               ?>
+                    echo "<center><b>$entryfields->concept</b><br>$strareyousuredelete";
+
+                    ?>
                         <form name="form" method="post" action="deleteentry.php">
 
                         <input type="hidden" name=id              value="<?php p($cm->id) ?>">
                         </form>
                        </center>
                        <?php
-                               print_simple_box_end();
-                       }
-               }
-       } else {
-               error("You are not allowed to edit or delete entries");
-       }
+                    print_simple_box_end();
+                }
+            }
+        } else {
+            error("You are not allowed to edit or delete entries");
+        }
     }
     print_footer($course);
 ?>
index 70a1fc64e68c501c6e3a6874a3779854736c1d1c..a1725a5aba3e7c740af44c5b6202cfc3864dc8b6 100644 (file)
@@ -232,11 +232,11 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview
     global $THEME, $USER;
 
     $importedentry = ($entry->sourceglossaryid == $glossary->id);
-    $isteacher = isteacher($course->id);
+    $isteacher = isteacher($course->id) or isadmin($course->id);
     $ismainglossary = $glossary->mainglossary;
-    
-    echo "<table width=100% border=0>";    
-    echo "<tr><td>";
+       
+    echo "<p align=\"right\">";
+
     $count = count_records("glossary_comments","entryid",$entry->id);
     if ($count) {
         echo "<font size=1><a href=\"comments.php?id=$cm->id&eid=$entry->id\">$count ";
@@ -245,18 +245,15 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview
         } else {
             print_string("comments", "glossary");
         }
-        echo "</a></font>";
+        echo "</a></font> ";
     }
-    echo "</td><td align=\"right\">";
 
-    echo "<td align=\"right\">";
     if ( $glossary->allowcomments ) {
         echo "<a href=\"comment.php?id=$cm->id&eid=$entry->id\"><img  alt=\"" . get_string("addcomment","glossary") . "\" src=\"comment.gif\" height=16 width=16 border=0></a> ";
     }
 
     if ($isteacher or $glossary->studentcanpost and $entry->userid == $USER->id) {
         // only teachers can export entries so check it out
-
         if ($isteacher and !$ismainglossary and !$importedentry) {
             $mainglossary = get_record("glossary","mainglossary",1,"course",$course->id);
             if ( $mainglossary ) {  // if there is a main glossary defined, allow to export the current entry
@@ -283,7 +280,6 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry,$currentview
             echo "<font size=-1>" . get_string("exportedentry","glossary") . "</font>";
         }
     }
-    echo "</td></tr></table>";
 }
 
 function glossary_search_entries($searchterms, $glossary, $includedefinition) {