wwwroot/$CFG->admin/index.php"); } require_login(); if (!isadmin()) { error("You must be an administrator to use this page."); } $primaryadmin = get_admin(); /// If you want any administrator to have the ability to assign admin /// rights, then comment out the following if statement if ($primaryadmin->id != $USER->id) { error("You must be the primary administrator to use this page."); } /// assign all of the configurable language strings $stringstoload = array ( "assigncreators", "administration", "existingcreators", "noexistingcreators", "potentialcreators", "nopotentialcreators", "addcreator", "removecreator", "search", "searchagain", "toomanytoshow", ); foreach ($stringstoload as $stringtoload){ $strstringtoload = "str" . $stringtoload; $$strstringtoload = get_string($stringtoload); } if ($search) { $searchstring = $strsearchagain; } else { $searchstring = $strsearch; } print_header("$site->shortname: $strassigncreators", "$site->fullname", "$stradministration -> $strassigncreators", ""); /// Get all existing creators $creators = get_creators(); /// 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 ."); } } } $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]); } } } } /// Print the lists of existing and potential creators echo "
$strexistingcreators | $strpotentialcreators |
---|---|
";
/// First, show existing creators
if (! $creators) {
echo " $strnoexistingcreators"; $creatorlist = ""; } else { $creatorarray = array(); foreach ($creators as $creator) { $creatorarray[] = $creator->id; echo " $creator->firstname $creator->lastname, $creator->email "; echo "id\" title=\"$strremovecreator\">"; echo " "; } $creatorlist = implode(",",$creatorarray); unset($creatorarray); } echo " | ";
/// Print list of potential creators
$usercount = get_users(false, $search, true, $creatorlist);
if ($usercount == 0) {
echo " $strnopotentialcreators "; } else if ($usercount > MAX_USERS_PER_PAGE) { echo "$strtoomanytoshow "; } else { if ($search) { echo "($strsearchresults : $search) "; } if (!$users = get_users(true, $search, true, $creatorlist)) { error("Could not get users!"); } foreach ($users as $user) { echo "id\"". "title=\"$straddcreator\"> $user->firstname $user->lastname, $user->email"; } } if ($search or $usercount > MAX_USERS_PER_PAGE) { echo " "; } echo " |