Commit 0d71fbab authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Implemented AdminUsers and StaffUsers. AdminUsers will need a little bit of

work later to make sure that the user with ID 1 is never involved in the
admin page, as they should always be an admin.
parent 2983ab81
......@@ -24,13 +24,54 @@
*
*/
// NOTE: This script is VERY SIMILAR to the staffusers.php script, a bug fixed
// here might need to be fixed there too.
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'usermanagement');
define('SUBMENUITEM', 'adminusers');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('form.php');
$smarty = smarty();
// Get users who are currently administrators
// @todo later, exclude the user with uid 1
$adminusers = get_column('usr', 'id', 'admin', 1);
$form = array(
'name' => 'adminusers',
'method' => 'post',
'action' => '',
'elements' => array(
'users' => array(
'type' => 'userlist',
'title' => get_string('adminusers', 'admin'),
'defaultvalue' => $adminusers,
'filter' => false
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('submit'), get_string('cancel'))
)
)
);
function adminusers_submit($values) {
global $SESSION;
db_begin();
execute_sql('UPDATE usr
SET admin = 0
WHERE admin = 1');
execute_sql('UPDATE usr
SET admin = 1
WHERE id IN (' . join(',', $values['users']) . ')');
db_commit();
$SESSION->add_ok_msg(get_string('adminusersupdated', 'admin'));
redirect(get_config('wwwroot') . 'admin/usermanagement/adminusers.php');
}
$smarty->assign('adminusersform', form($form));
$smarty->display('admin/usermanagement/adminusers.tpl');
?>
......@@ -24,13 +24,53 @@
*
*/
// NOTE: This script is VERY SIMILAR to the adminusers.php script, a bug fixed
// here might need to be fixed there too.
define('INTERNAL', 1);
define('ADMIN', 1);
define('MENUITEM', 'usermanagement');
define('SUBMENUITEM', 'staffusers');
require(dirname(dirname(dirname(__FILE__))) . '/init.php');
require_once('form.php');
$smarty = smarty();
// Get users who are currently staff
$staffusers = get_column('usr', 'id', 'staff', 1);
$form = array(
'name' => 'staffusers',
'method' => 'post',
'action' => '',
'elements' => array(
'users' => array(
'type' => 'userlist',
'title' => get_string('staffusers', 'admin'),
'defaultvalue' => $staffusers,
'filter' => false
),
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('submit'), get_string('cancel'))
)
)
);
function staffusers_submit($values) {
global $SESSION;
db_begin();
execute_sql('UPDATE usr
SET staff = 0
WHERE staff = 1');
execute_sql('UPDATE usr
SET staff = 1
WHERE id IN (' . join(',', $values['users']) . ')');
db_commit();
$SESSION->add_ok_msg(get_string('staffusersupdated', 'admin'));
redirect(get_config('wwwroot') . 'admin/usermanagement/staffusers.php');
}
$smarty->assign('staffusersform', form($form));
$smarty->display('admin/usermanagement/staffusers.tpl');
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment