]> git.mjollnir.org Git - moodle.git/commitdiff
More robust creator adding/removing, using new functions in moodlelib.php
authormoodler <moodler>
Sun, 17 Aug 2003 08:58:18 +0000 (08:58 +0000)
committermoodler <moodler>
Sun, 17 Aug 2003 08:58:18 +0000 (08:58 +0000)
admin/creators.php

index 3505abab0176a66949eebadb58302528a3b4a21f..5c0055c3ae3d20441a2fb82fd5a6fc023f5ea1bd 100755 (executable)
                  "<a href=\"index.php\">$stradministration</a> -> <a href=\"users.php\">$strusers</a> ->
                   $strassigncreators", "");
 
-/// Get all existing creators
-    $creators = get_creators();
+/// Add a creator if one is specified
 
-/// Add an creator if one is specified
-    if ($add) {
-        $user = @get_record("user", "id", $add) or
-            error("That account (id = $add) doesn't exist");
-
-        if ($creators) {
-            foreach ($creators as $aa) {
-                if ($aa->id == $user->id) {
-                    error("That user is already a creator .");
-                }            
-            }
+    if (!empty($_GET['add'])) {
+        if (! add_creator($add)) {
+            error("Could not add that creator!");
         }
-
-        $creator->userid = $user->id;
-        $creator->id = insert_record("user_coursecreators", $creator);
-        $creators[] = $user;
     }
 
-/// Remove an creator if one is specified.
-    if ($remove) {
-        $user = @get_record("user", "id", $remove) or 
-            error("That account (id = $remove) doesn't exist");
-
-        if ($creators) {
-            foreach ($creators as $key => $aa) {
-                if ($aa->id == $user->id) {
-                        delete_records("user_coursecreators","userid",$user->id);
-                        unset($creators[$key]);
-                } 
-            }
+/// Remove a creator if one is specified.
+
+    if (!empty($_GET['remove'])) {
+        if (! remove_creator($remove)) {
+            error("Could not remove that creator!");
         }
     }
 
+/// Get all existing creators
+    $creators = get_creators();
 
 /// Print the lists of existing and potential creators
     echo "<table cellpadding=2 cellspacing=10 align=center>";