]> git.mjollnir.org Git - moodle.git/commitdiff
Confirmation for deleting course categories
authormjollnir_ <mjollnir_>
Tue, 16 Nov 2004 02:21:31 +0000 (02:21 +0000)
committermjollnir_ <mjollnir_>
Tue, 16 Nov 2004 02:21:31 +0000 (02:21 +0000)
course/index.php
lang/en/moodle.php

index 9cf55e185ae813912529df080b048c62ed1e5af6..085a50cbd96293527aa0a7045eb11cc1d2ec1e90 100644 (file)
 
     if (isset($delete) and confirm_sesskey()) {
         if ($deletecat = get_record("course_categories", "id", $delete)) {
-
-            /// Send the children categories to live with their grandparent
-            if ($childcats = get_records("course_categories", "parent", $deletecat->id)) {
-                foreach ($childcats as $childcat) {
-                    if (! set_field("course_categories", "parent", $deletecat->parent, "id", $childcat->id)) {
-                        error("Could not update a child category!", "index.php");
+            if (!empty($sure) && $sure == md5($deletecat->timemodified)) {
+                /// Send the children categories to live with their grandparent
+                if ($childcats = get_records("course_categories", "parent", $deletecat->id)) {
+                    foreach ($childcats as $childcat) {
+                        if (! set_field("course_categories", "parent", $deletecat->parent, "id", $childcat->id)) {
+                            error("Could not update a child category!", "index.php");
+                        }
                     }
                 }
-            }
-
-            ///  If the grandparent is a valid (non-zero) category, then 
-            ///  send the children courses to live with their grandparent as well
-            if ($deletecat->parent) {
-                if ($childcourses = get_records("course", "category", $deletecat->id)) {
-                    foreach ($childcourses as $childcourse) {
-                        if (! set_field("course", "category", $deletecat->parent, "id", $childcourse->id)) {
-                            error("Could not update a child course!", "index.php");
+                
+                ///  If the grandparent is a valid (non-zero) category, then 
+                ///  send the children courses to live with their grandparent as well
+                if ($deletecat->parent) {
+                    if ($childcourses = get_records("course", "category", $deletecat->id)) {
+                        foreach ($childcourses as $childcourse) {
+                            if (! set_field("course", "category", $deletecat->parent, "id", $childcourse->id)) {
+                                error("Could not update a child course!", "index.php");
+                            }
                         }
                     }
                 }
+                
+                /// Finally delete the category itself
+                if (delete_records("course_categories", "id", $deletecat->id)) {
+                    notify(get_string("categorydeleted", "", $deletecat->name));
+                }
             }
-           
-            /// Finally delete the category itself
-            if (delete_records("course_categories", "id", $deletecat->id)) {
-                notify(get_string("categorydeleted", "", $deletecat->name));
+            else {
+                $strdeletecategorycheck = get_string("deletecategorycheck","",$deletecat->name);
+                notice_yesno("$strdeletecategorycheck",
+                             "index.php?delete=$delete&amp;sure=".md5($deletecat->timemodified)."&amp;sesskey=$USER->sesskey",
+                             "index.php?sesskey=$USER->sesskey");
+                exit();
             }
         }
     }
index 086aed12179415157554f2616af4718df4cef4a2..d9921b710d3d3d17246110a656b6b313dc0a5a03 100644 (file)
@@ -300,6 +300,7 @@ $string['defaultcourseteacher'] = 'Teacher';
 $string['defaultcourseteachers'] = 'Teachers';
 $string['delete'] = 'Delete';
 $string['deleteall'] = 'Delete all';
+$string['deletecategorycheck'] = 'Are you absolutely sure you want to completely delete this category <b>\'$a\'</b>?<br />This will move all courses into the parent category if there is one, or into Miscellaneous.';
 $string['deletecheck'] = 'Delete $a ?';
 $string['deletecheckfiles'] = 'Are you absolutely sure you want to delete these files?';
 $string['deletecheckfull'] = 'Are you absolutely sure you want to completely delete $a ?';