From fdfefb6700d27af4c88e4a20f8f9ac3a48d69249 Mon Sep 17 00:00:00 2001 From: moodler Date: Thu, 5 Aug 2004 09:24:16 +0000 Subject: [PATCH] New interfaces for managing creators and admins --- admin/admin.html | 86 ++++++++++++++++++++++++++++ admin/admin.php | 134 ++++++++++++++++---------------------------- admin/creators.html | 80 ++++++++++++++++++++++++++ admin/creators.php | 130 ++++++++++++++++-------------------------- 4 files changed, 261 insertions(+), 169 deletions(-) create mode 100644 admin/admin.html create mode 100644 admin/creators.html diff --git a/admin/admin.html b/admin/admin.html new file mode 100644 index 0000000000..81d60d8702 --- /dev/null +++ b/admin/admin.html @@ -0,0 +1,86 @@ + +
+ + + + + + + + + + + + +
+ + + +
+ +
+ +
+ +
+
+ +
+ + + + '."\n"; + } + ?> +
+
+ + diff --git a/admin/admin.php b/admin/admin.php index cb0f3b554d..50324f3492 100644 --- a/admin/admin.php +++ b/admin/admin.php @@ -32,16 +32,11 @@ "assignadmins", "administration", "existingadmins", - "noexistingadmins", "potentialadmins", - "nopotentialadmins", - "addadmin", - "removeadmin", "search", - "searchagain", - "toomanytoshow", "users", - "searchresults" + "searchresults", + "showall" ); foreach ($stringstoload as $stringtoload){ @@ -49,107 +44,74 @@ $$strstringtoload = get_string($stringtoload); } - if ($search) { - $searchstring = $strsearchagain; - } else { - $searchstring = $strsearch; - } - print_header("$site->shortname: $strassignadmins", "$site->fullname", - "$stradministration -> $strusers -> $strassignadmins", ""); + "$stradministration -> $strusers -> $strassignadmins", "adminform.searchtext"); -/// 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)) { + if (!$frm = data_submitted()) { 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 = ""; +/// A form was submitted so process the input + } 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\">"; + if (!empty($frm->add) and !empty($frm->addselect)) { + foreach ($frm->addselect as $addadmin) { + if (! add_admin($addadmin)) { + error("Could not add admin with user id $addadmin!"); + } } - echo "

"; + } else if (!empty($frm->remove) and !empty($frm->removeselect)) { + $admins = get_admins(); + if (count($admins) > count($frm->removeselect)) { + foreach ($frm->removeselect as $removeadmin) { + if (! remove_admin($removeadmin)) { + error("Could not remove admin with user id $removeadmin!"); + } + } + } + } else if (!empty($frm->showall)) { + unset($frm->searchtext); + $frm->previoussearch = 0; } - - $adminlist = implode(",",$adminarray); - unset($adminarray); } - echo "
"; +/// Is there a current search? + $previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ; -/// Print list of potential admins +/// Get all existing admins + $admins = get_admins(); - $usercount = get_users(false, $search, true, $adminlist); - if ($usercount == 0) { - echo "

$strnopotentialadmins

"; + $adminarray = array(); + foreach ($admins as $admin) { + $adminarray[] = $admin->id; + } + $adminlist = implode(',', $adminarray); - } else if ($usercount > MAX_USERS_PER_PAGE) { - echo "

$strtoomanytoshow ($usercount)

"; + unset($adminarray); - } else { - if ($search) { - echo "

($strsearchresults : $search)

"; - } - - if (!$users = get_users(true, $search, true, $adminlist)) { - error("Could not get users!"); - } +/// Get search results excluding any current admins + if (!empty($frm->searchtext) and $previoussearch) { + $searchusers = get_users(true, $frm->searchtext, true, $adminlist, 'firstname ASC, lastname ASC', + '', '', 0, 99999, 'id, firstname, lastname, email'); + $usercount = get_users(false, '', true, $adminlist); + } - foreach ($users as $user) { - echo "

id\"". - "title=\"$straddadmin\">  ".fullname($user).", $user->email"; +/// If no search results then get potential users excluding current admins + if (empty($searchusers)) { + if (!$users = get_users(true, '', true, $adminlist, 'firstname ASC, lastname ASC', '', '', + 0, 99999, 'id, firstname, lastname, email') ) { + $users = array(); } + $usercount = count($users); } - if ($search or $usercount > MAX_USERS_PER_PAGE) { - echo "

"; - echo ""; - echo ""; - echo "
"; - } + $searchtext = (isset($frm->searchtext)) ? $frm->searchtext : ""; + $previoussearch = ($previoussearch) ? '1' : '0'; - echo "
"; + include('./admin.html'); print_footer(); diff --git a/admin/creators.html b/admin/creators.html new file mode 100644 index 0000000000..09e6023d67 --- /dev/null +++ b/admin/creators.html @@ -0,0 +1,80 @@ + +
+ + + + + + + + + + + + +
+ + + +
+ +
+ +
+ +
+
+ +
+ + + + '."\n"; + } + ?> +
+
+ + diff --git a/admin/creators.php b/admin/creators.php index 5a5b03f6d7..a1a5da4455 100755 --- a/admin/creators.php +++ b/admin/creators.php @@ -26,16 +26,11 @@ "assigncreators", "administration", "existingcreators", - "noexistingcreators", "potentialcreators", - "nopotentialcreators", - "addcreator", - "removecreator", "search", - "searchagain", "users", - "toomanytoshow", - "searchresults" + "searchresults", + "showall" ); foreach ($stringstoload as $stringtoload){ @@ -43,105 +38,74 @@ $$strstringtoload = get_string($stringtoload); } - if ($search) { - $searchstring = $strsearchagain; - } else { - $searchstring = $strsearch; - } - print_header("$site->shortname: $strassigncreators", "$site->fullname", "$stradministration -> $strusers -> - $strassigncreators", ""); - -/// Add a creator if one is specified - - if (!empty($_GET['add'])) { - if (! add_creator($add)) { - error("Could not add that creator!"); - } - } + $strassigncreators", "creatorsform.searchtext"); -/// Remove a creator if one is specified. - if (!empty($_GET['remove'])) { - if (! remove_creator($remove)) { - error("Could not remove that creator!"); - } - } - -/// Print a help notice about this page - if (empty($add) and empty($remove) and empty($search)) { + if (!$frm = data_submitted()) { print_simple_box("
".get_string("adminhelpassigncreators")."
", "center", "50%"); - } - -/// Get all existing creators - $creators = get_creators(); -/// Print the lists of existing and potential creators - echo ""; - echo ""; - echo "
$strexistingcreators$strpotentialcreators
"; - -/// First, show existing creators - - if (! $creators) { - echo "

$strnoexistingcreators"; - - $creatorlist = ""; +/// A form was submitted so process the input } else { - $creatorarray = array(); - foreach ($creators as $creator) { - $creatorarray[] = $creator->id; - echo "

".fullname($creator, true).", $creator->email    "; - echo "id\" - title=\"$strremovecreator\">"; - echo "

"; + if (!empty($frm->add) and !empty($frm->addselect)) { + foreach ($frm->addselect as $addcreator) { + if (! add_creator($addcreator)) { + error("Could not add course creator with user id $addcreator!"); + } + } + } else if (!empty($frm->remove) and !empty($frm->removeselect)) { + foreach ($frm->removeselect as $removecreator) { + if (! remove_creator($removecreator)) { + error("Could not remove course creator with user id $removecreator!"); + } + } + } else if (!empty($frm->showall)) { + unset($frm->searchtext); + $frm->previoussearch = 0; } - $creatorlist = implode(",",$creatorarray); - unset($creatorarray); } - echo "
"; +/// Is there a current search? + $previoussearch = (!empty($frm->search) or ($frm->previoussearch == 1)) ; -/// Print list of potential creators - $usercount = get_users(false, $search, true, $creatorlist); - - if ($usercount == 0) { - echo "

$strnopotentialcreators

"; +/// Get all existing creators + if (! $creators = get_creators()) { + $creators = array(); + } - } else if ($usercount > MAX_USERS_PER_PAGE) { - echo "

$strtoomanytoshow ($usercount)

"; + $creatorsarray = array(); + foreach ($creators as $creator) { + $creatorsarray[] = $creator->id; + } + $creatorlist = implode(',', $creatorsarray); - } else { + unset($creatorarray); - if ($search) { - echo "

($strsearchresults : $search)

"; - } - if (!$users = get_users(true, $search, true, $creatorlist)) { - error("Could not get users!"); - } +/// Get search results excluding any current admins + if (!empty($frm->searchtext) and $previoussearch) { + $searchusers = get_users(true, $frm->searchtext, true, $creatorlist, 'firstname ASC, lastname ASC', + '', '', 0, 99999, 'id, firstname, lastname, email'); + $usercount = get_users(false, '', true, $creatorlist); + } - foreach ($users as $user) { - $fullname = fullname($user, TRUE); - echo "

id\"". - "title=\"$straddcreator\">  $fullname, $user->email"; +/// If no search results then get potential users excluding current creators + if (empty($searchusers)) { + if (!$users = get_users(true, '', true, $creatorlist, 'firstname ASC, lastname ASC', '', '', + 0, 99999, 'id, firstname, lastname, email') ) { + $users = array(); } + $usercount = count($users); } - if ($search or $usercount > MAX_USERS_PER_PAGE) { - echo "

"; - echo ""; - echo ""; - echo "
"; - } + $searchtext = (isset($frm->searchtext)) ? $frm->searchtext : ""; + $previoussearch = ($previoussearch) ? '1' : '0'; - echo "
"; + include('./creators.html'); print_footer(); -- 2.39.5