From: moodler Date: Sun, 17 Aug 2003 08:58:18 +0000 (+0000) Subject: More robust creator adding/removing, using new functions in moodlelib.php X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=aa34b7869ef7444345e04f8d836f4a989194a0f4;p=moodle.git More robust creator adding/removing, using new functions in moodlelib.php --- diff --git a/admin/creators.php b/admin/creators.php index 3505abab01..5c0055c3ae 100755 --- a/admin/creators.php +++ b/admin/creators.php @@ -59,42 +59,24 @@ "$stradministration -> $strusers -> $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 "";