]> git.mjollnir.org Git - moodle.git/commitdiff
By no means finished but at least no loose ends with groups editing
authormoodler <moodler>
Sat, 7 Feb 2004 17:44:10 +0000 (17:44 +0000)
committermoodler <moodler>
Sat, 7 Feb 2004 17:44:10 +0000 (17:44 +0000)
course/group.php
lang/en/moodle.php

index 3fb065b4c16c1bf0605b74e2e326d187bf9afdfe..d68412fcdf285909451ffc0c49323f20cd13a815 100644 (file)
     }
 
     if (isteacheredit($course->id) or (isteacher($course->id) and ismember($group->id) ) ) {
-        if (isset($edit)) {
-            if ($edit == "on") {
-                $USER->groupediting = true;
-            } else if ($edit == "off") {
-                $USER->groupediting = false;
-            }
-        }
+        $edit = isset($_GET['edit']);
+        $editbutton = $edit ? "" : update_group_button($course->id, $group->id);
     } else {
-        $USER->groupediting = false;
+        $edit = false;
+        $editbutton = "";
     }
 
 
@@ -51,7 +47,7 @@
         print_header("$strgroup : $group->name", "$course->fullname", 
                      "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> 
                       -> <a href=\"groups.php?id=$course->id\">$strgroups</a> -> $group->name", 
-                      "", "", true, update_group_button($course->id), $loggedinas);
+                      "", "", true, $editbutton, $loggedinas);
     } else {
         print_header("$strgroup : $group->name", "$course->fullname", 
                      "<a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">$course->shortname</a> 
     }
 
 
-/// Display the current group information
 
-    if ($USER->groupediting) {          // Make an editing form for group information
-        print_heading($group->name);
-        echo '<div align="center">';
-        print_group_picture($group, $course->id, true, false, false);
-        echo '</div>';
-        if ($group->description) {
-            print_simple_box($group->description, 'center', '50%');
+/// If data submitted, then process and store.
+
+    if ($form = data_submitted()) { 
+
+        if (empty($form->name)) {
+            $edit = true;
+            $err['name'] = get_string("missingname");
+
+        } else {
+            $group->name = $form->name;
+            $group->description = $form->description;
+            if (!update_record("groups", $group)) {
+                notify("A strange error occurred while trying to save ");
+            } else {
+                redirect("group.php?id=$course->id&group=$group->id", get_string("changessaved"));
+            }
+        }
+    }
+
+
+/// Are we editing?  If so, handle it.
+
+    if ($edit) {          // We are editing a group's information
+        if ($usehtmleditor = can_use_richtext_editor()) {
+            $defaultformat = FORMAT_HTML;
+        } else {
+            $defaultformat = FORMAT_MOODLE;
         }
 
-    } else {                            // Just display the information 
-        print_heading($group->name);
-        echo '<div align="center">';
-        print_group_picture($group, $course->id, true, false, false);
-        echo '</div>';
-        if ($group->description) {
-            print_simple_box($group->description, 'center', '50%');
+        include('group-edit.html');
+
+        if ($usehtmleditor) {
+            use_html_editor();
         }
+
+        print_footer();
+        exit;
+    }
+    
+/// Just display the information 
+
+    print_heading($group->name);
+    echo '<div align="center">';
+    print_group_picture($group, $course->id, true, false, false);
+    echo '</div>';
+    if ($group->description) {
+        print_simple_box($group->description, 'center', '50%');
     }
 
     echo '<br />';
index 696f1d8e73df6bc072f6c9fe6eaf17f4bad5e5be..f1952ecaf96844e0e9dc23d60fc94b1fd381890c 100644 (file)
@@ -523,6 +523,7 @@ $string['missingemail'] = 'Missing email address';
 $string['missingfirstname'] = 'Missing given name';
 $string['missingfullname'] = 'Missing full name';
 $string['missinglastname'] = 'Missing surname';
+$string['missingname'] = 'Missing name';
 $string['missingnewpassword'] = 'Missing new password';
 $string['missingpassword'] = 'Missing password';
 $string['missingshortname'] = 'Missing short name';