]> git.mjollnir.org Git - moodle.git/commitdiff
Fixes bug MDL-8434, "group administration - can't delete groups".
authornfreear <nfreear>
Tue, 6 Feb 2007 15:34:09 +0000 (15:34 +0000)
committernfreear <nfreear>
Tue, 6 Feb 2007 15:34:09 +0000 (15:34 +0000)
group/group.php
group/grouping.php
lang/en_utf8/group.php

index 430228cff803a87c0072a031852fee802389e196..06bb18f53fabcb790963d5011319d96dddbcf595 100644 (file)
@@ -34,6 +34,10 @@ if (! $course) {
     $success = false;
     print_error('invalidcourse'); //'The course ID is invalid'
 }
+if ($delete && !$groupid) {
+    $success = false;
+    print_error('errorinvalidgroup', 'group', groups_home_url($courseid));
+}
 
 if ($success) {
     // Make sure that the user has permissions to manage groups.
@@ -52,7 +56,11 @@ if ($success) {
             redirect(groups_home_url($courseid, $groupid, $groupingid, false));
         }
         elseif (isset($frm->confirmdelete)) {
-            ///TODO:
+            if ($success = groups_delete_group($groupid)) {
+                redirect(groups_home_url($courseid, null, $groupingid, false));
+            } else {
+                print_error('erroreditgroup', 'group', groups_home_url($courseid));
+            }
         }
         elseif (empty($frm->name)) {
             $err['name'] = get_string('missingname');
@@ -83,7 +91,7 @@ if ($success) {
                 redirect(groups_home_url($courseid, $groupid, $groupingid, false));
             }
             else {
-                print_error('erroreditgrouping', 'group', groups_home_url($courseid));
+                print_error('erroreditgroup', 'group', groups_home_url($courseid));
             }
         }
     }
@@ -94,7 +102,7 @@ if ($success) {
         // Form to edit existing group.
         $group = groups_get_group_settings($groupid);
         if (! $group) {
-            print_error('The group ID is invalid.');
+            print_error('errorinvalidgroup', 'group', groups_home_url($courseid));
         }
         $strname = s($group->name);
         $strdesc = s($group->description);
@@ -147,10 +155,10 @@ if ($success) {
         choose_from_menu_yesno('confirmdelete', false, '', true);*/
 ?>
 
-        <p>Are you sure you want to delete group '<?php p($strname) ?>'?</p>
+        <p><?php print_string('deletegroupconfirm', 'group', $strname); ?></p>
         <input type="hidden" name="delete" value="1" />
-        <input type="submit" name="confirmdelete" value="Yes" />
-        <input type="submit" name="cancel" value="<?php print_string('cancel', 'group'); ?>" />
+        <input type="submit" name="confirmdelete" value="<?php print_string('yes'); ?>" />
+        <input type="submit" name="cancel" value="<?php print_string('no'); ?>" />
 <?php
     } else {
 ?>
index ede13cdb18c9843ac2810c524c19d00a463370db..16cebb6339a39b55881d8aab06f1d60c068432f2 100644 (file)
@@ -20,6 +20,8 @@ $groupingid = optional_param('grouping', false, PARAM_INT);
 $groupingsettings->name       = optional_param('name', PARAM_ALPHANUM);
 $groupingsettings->description= optional_param('description', PARAM_ALPHANUM);
 
+$delete = optional_param('delete', false, PARAM_BOOL);
+
 // Get the course information so we can print the header and
 // check the course id is valid
 $course = groups_get_course_info($courseid);
@@ -47,6 +49,13 @@ if ($success) {
         if (isset($frm->cancel)) {
             redirect(groups_home_url($courseid, null, $groupingid, false));
         }
+        elseif (isset($frm->confirmdelete)) {
+            if ($success = groups_delete_grouping($groupingid)) {
+                redirect(groups_home_url($courseid));
+            } else {
+                print_error('erroreditgrouping', 'group', groups_home_url($courseid));
+            }
+        }
         elseif (empty($frm->name)) {
             $err['name'] = get_string('missingname');
         }
@@ -62,7 +71,7 @@ if ($success) {
                 redirect(groups_home_url($courseid, null, $groupingid, false));
             }
             else {
-                print_error('erroreditgroup', 'group', groups_home_url($courseid));
+                print_error('erroreditgrouping', 'group', groups_home_url($courseid));
             }
         }
     }
@@ -88,6 +97,9 @@ if ($success) {
     }
     $strgroups = get_string('groups');
     $strparticipants = get_string('participants');
+    if ($delete) {
+        $strheading = get_string('deletegrouping', 'group');
+    }
 
 /// Print the page and form
 
@@ -108,6 +120,18 @@ if ($success) {
     if ($groupingid) {
         echo '<input type="hidden" name="grouping" value="'. $groupingid .'" />';
     }
+
+    if ($delete) {
+        /*echo 'Are you sure you want to delete grouping X ?';
+        choose_from_menu_yesno('confirmdelete', false, '', true);*/
+?>
+
+        <p><?php print_string('deletegroupingconfirm', 'group', $strname); ?></p>
+        <input type="hidden" name="delete" value="1" />
+        <input type="submit" name="confirmdelete" value="<?php print_string('yes'); ?>" />
+        <input type="submit" name="cancel" value="<?php print_string('no'); ?>" />
+<?php
+    } else {
 ?>
 
 <div class="f-item">
@@ -139,6 +163,9 @@ if ($success) {
     <input type="submit" name="cancel" value="<?php print_string('cancel', 'group'); ?>" />
   </span>
 </p>
+
+<?php } //IF($delete) ?>
+
 <span class="clearer">&nbsp;</span>
 
 </form>
index 22f3816412b762e6a3e5693eb12099fba0911e18..29cc42c8b55ad8945349a6245631c1b5cf4a4736 100644 (file)
@@ -32,6 +32,9 @@ $string['showgroupsingrouping'] = 'Show groups in grouping';
 $string['showmembersforgroup'] = 'Show members for group';
 $string['databaseupgradegroups'] = 'Groups version is now $a';
 
+$string['deletegroupingconfirm'] = 'Are you sure you want to delete grouping \'$a\'? (Groups in the grouping are not deleted.)';
+$string['deletegroupconfirm'] = 'Are you sure you want to delete group \'$a\'?';
+
 $string['editgroupingsettings'] = 'Edit grouping settings';
 $string['editgroupingpermissions'] = 'Edit grouping permissions';
 $string['deletegrouping'] = 'Delete grouping';