<?php // $Id$
-require_once('../config.php');
-require_once($CFG->dirroot . '/admin/adminlib.php');
-
-admin_externalpage_setup('editusers');
-admin_externalpage_print_header();
-
+ require_once('../config.php');
$newuser = optional_param('newuser', 0, PARAM_BOOL);
$delete = optional_param('delete', 0, PARAM_INT);
if ($newuser && confirm_sesskey()) { // Create a new user
- if (!has_capability('moodle/user:create', $context->id)) {
+ if (!has_capability('moodle/user:create', $context)) {
error('You do not have the required permission to create new users.');
}
} else { // List all users for editing
- if (!has_capability('moodle/user:update', $context->id)) {
+ if (!has_capability('moodle/user:update', $context)) {
error('You do not have the required permission to edit users.');
}
$strsearch = get_string("search");
$strshowallusers = get_string("showallusers");
+ if ($firstinitial or $lastinitial or $search or $page) {
+ print_header("$site->shortname: $stredituser", $site->fullname,
+ "<a href=\"index.php\">$stradministration</a> -> ".
+ "<a href=\"users.php\">$strusers</a> -> ".
+ "<a href=\"user.php\">$stredituser</a>");
+ } else {
+ print_header("$site->shortname: $stredituser", $site->fullname,
+ "<a href=\"index.php\">$stradministration</a> -> ".
+ "<a href=\"users.php\">$strusers</a> -> $stredituser");
+ }
if ($confirmuser and confirm_sesskey()) {
if (!$user = get_record("user", "id", "$confirmuser")) {
} else if ($delete and confirm_sesskey()) { // Delete a selected user, after confirmation
- if (!has_capability('moodle/user:delete', $context->id)) {
+ if (!has_capability('moodle/user:delete', $context)) {
error('You do not have the required permission to delete a user.');
}
if ($user->id == $USER->id or $user->username == "changeme") {
$deletebutton = "";
} else {
- if (has_capability('moodle/user:delete', $context->id)) {
+ if (has_capability('moodle/user:delete', $context)) {
$deletebutton = "<a href=\"user.php?delete=$user->id&sesskey=$USER->sesskey\">$strdelete</a>"; } else {
$deletebutton ="";
}
}
$fullname = fullname($user, true);
- if (has_capability('moodle/user:edit', $context->id)) {
+ if (has_capability('moodle/user:edit', $context)) {
$table->data[] = array ("<a href=\"../user/view.php?id=$user->id&course=$site->id\">$fullname</a>",
"$user->email",
echo "</form>";
echo "</td></tr></table>";
- if (has_capability('moodle/user:create', $context->id)) {
+ if (has_capability('moodle/user:create', $context)) {
print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
}
if (!empty($table)) {
print_paging_bar($usercount, $page, $perpage,
"user.php?sort=$sort&dir=$dir&perpage=$perpage".
"&firstinitial=$firstinitial&lastinitial=$lastinitial&search=".urlencode(stripslashes($search))."&");
- if (has_capability('moodle/user:create', $context->id)) {
+ if (has_capability('moodle/user:create', $context)) {
print_heading("<a href=\"user.php?newuser=true&sesskey=$USER->sesskey\">".get_string("addnewuser")."</a>");
}
}
- admin_externalpage_print_footer();
+ print_footer();
}
-?>
\ No newline at end of file
+?>