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 ( "assignadmins", "administration", "existingadmins", "noexistingadmins", "potentialadmins", "nopotentialadmins", "addadmin", "removeadmin", "search", "searchagain", "toomanytoshow", "users", "searchresults" ); foreach ($stringstoload as $stringtoload){ $strstringtoload = "str" . $stringtoload; $$strstringtoload = get_string($stringtoload); } if ($search) { $searchstring = $strsearchagain; } else { $searchstring = $strsearch; } print_header("$site->shortname: $strassignadmins", "$site->fullname", "$stradministration -> $strusers -> $strassignadmins", ""); /// Add an admin if one is specified if (!empty($_GET['add'])) { if (! add_admin($add)) { error("Could not add that admin!"); } } /// Remove an admin if one is specified. if (!empty($_GET['remove'])) { if (! remove_admin($remove)) { error("Could not remove that admin!"); } } /// Print a help notice about this page if (empty($add) and empty($remove) and empty($search)) { print_simple_box("
".get_string("adminhelpassignadmins")."
", "center", "50%"); } /// Get all existing admins $admins = get_admins(); /// Print the lists of existing and potential admins echo ""; echo ""; echo "
$strexistingadmins$strpotentialadmins
"; /// First, show existing admins if (! $admins) { echo "

$strnoexistingadmins

"; $adminlist = ""; } else { $adminarray = array(); foreach ($admins as $admin) { $adminarray[] = $admin->id; echo "

".fullname($admin, true).", $admin->email    "; if ($primaryadmin->id == $admin->id){ print_spacer(10, 9, false); } else { echo "id\" title=\"$strremoveadmin\">"; } echo "

"; } $adminlist = implode(",",$adminarray); unset($adminarray); } echo "
"; /// Print list of potential admins $usercount = get_users(false, $search, true, $adminlist); if ($usercount == 0) { echo "

$strnopotentialadmins

"; } else if ($usercount > MAX_USERS_PER_PAGE) { echo "

$strtoomanytoshow ($usercount)

"; } else { if ($search) { echo "

($strsearchresults : $search)

"; } if (!$users = get_users(true, $search, true, $adminlist)) { error("Could not get users!"); } foreach ($users as $user) { echo "

id\"". "title=\"$straddadmin\">  ".fullname($user).", $user->email"; } } if ($search or $usercount > MAX_USERS_PER_PAGE) { echo "

"; echo ""; echo ""; echo "
"; } echo "
"; print_footer(); ?>