]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-9118: The group/edit page now fetches the groupingid for the selected group if...
authornicolasconnault <nicolasconnault>
Fri, 30 Mar 2007 07:52:56 +0000 (07:52 +0000)
committernicolasconnault <nicolasconnault>
Fri, 30 Mar 2007 07:52:56 +0000 (07:52 +0000)
group/edit.php
group/lib/clientlib.js

index af5295afbc84540787148a3cae55179fcdce0eb4..6c4c5da70e7a1fd68d77ca044b0814560592afa8 100755 (executable)
@@ -20,9 +20,6 @@ $id          = optional_param('id', false, PARAM_INT);
 $groupingid  = optional_param('grouping', false, PARAM_INT);
 $newgrouping = optional_param('newgrouping', false, PARAM_INT);
 $courseid    = required_param('courseid', PARAM_INT);
-if ($groupingid === false) {
-    $groupingid = -1;
-}
 
 $delete = optional_param('delete', false, PARAM_BOOL);
 
@@ -43,6 +40,16 @@ if ($id) {
     } 
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
     require_capability('moodle/course:managegroups', $context);
+    
+    // If group given but no groupingid, retrieve grouping id
+    if (empty($groupingid)) {
+        $groupings = groups_get_groupings_for_group($id);
+        if (empty($groupings)) {
+            $groupingid = -1;
+        } else {
+            $groupingid = $groupings[0];
+        }
+    } 
 }
 
 /// First create the form
index 88058e25c984540b4e31581c30d0c664b6aa772a..9ce0ad2f7893caac7cd2b16e945882e0747e7b5d 100644 (file)
@@ -116,10 +116,15 @@ function UpdatableMembersCombo(wwwRoot, courseId) {
 
                if (o.responseText !== undefined) {
                 var selectEl = document.getElementById("members");
-
                    if (selectEl && o.responseText) {
                        var members = eval("("+o.responseText+")");
 
+                    // Clear the members combo box.
+                    if (selectEl) {
+                        while (selectEl.firstChild) {
+                            selectEl.removeChild(selectEl.firstChild);
+                        }
+                    }
                        // Populate the members combo box.
                     for (var i=0; i<members.length; i++) {
                         var optionEl = document.createElement("option");
@@ -151,9 +156,9 @@ function UpdatableMembersCombo(wwwRoot, courseId) {
 UpdatableMembersCombo.prototype.refreshMembers = function (groupId) {
     // Add the loader gif image.
     createLoaderImg("membersloader", "memberslabel", this.wwwRoot);
+    var selectEl = document.getElementById("members");
 
     // Clear the members combo box.
-    var selectEl = document.getElementById("members");
     if (selectEl) {
         while (selectEl.firstChild) {
             selectEl.removeChild(selectEl.firstChild);
@@ -164,7 +169,7 @@ UpdatableMembersCombo.prototype.refreshMembers = function (groupId) {
     document.getElementById("showeditgroupsettingsform").disabled = false;
     document.getElementById("deletegroup").disabled = false;
     var sUrl = this.wwwRoot+"/group/index.php?id="+this.courseId+"&group="+groupId+"&act_ajax_getmembersingroup";
-    YAHOO.util.Connect.asyncRequest("GET", sUrl, this.connectCallback, null);
+    YAHOO.util.Connect.asyncRequest("GET", sUrl, this.connectCallback, null); 
 };