diff --git a/backup/restorelib.php b/backup/restorelib.php
index 7d3d5d569d4..f1f37afc585 100644
--- a/backup/restorelib.php
+++ b/backup/restorelib.php
@@ -5349,7 +5349,7 @@
$course = get_record("course","id",$restore->course_id);
fix_course_sortorder();
//Make the user a teacher if the course hasn't teachers (bug 2381)
- if (!isadmin()) {
+ if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
if (!$checktea = get_records('user_teachers','course', $restore->course_id)) {
//Add the teacher to the course
$status = add_teacher($USER->id, $restore->course_id);
diff --git a/course/category.php b/course/category.php
index 6298381e94a..ca3d215bc9f 100644
--- a/course/category.php
+++ b/course/category.php
@@ -37,7 +37,7 @@
$navbaritem = update_category_button($category->id);
$creatorediting = !empty($USER->categoryediting);
- $adminediting = (isadmin() and $creatorediting);
+ $adminediting = (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)) and $creatorediting);
} else {
if (!$category->visible) {
@@ -49,7 +49,7 @@
}
- if (isadmin()) {
+ if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
/// Rename the category if requested
if (!empty($rename) and confirm_sesskey()) {
$category->name = $rename;
@@ -412,7 +412,7 @@
echo '
';
- if (isadmin() and $numcourses > 1) { /// Print button to re-sort courses by name
+ if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM, SITEID)) and $numcourses > 1) { /// Print button to re-sort courses by name
unset($options);
$options['id'] = $category->id;
$options['resort'] = 'name';
diff --git a/course/index.php b/course/index.php
index 93ff5b72ecf..7a79f85403f 100644
--- a/course/index.php
+++ b/course/index.php
@@ -25,7 +25,7 @@
require_login();
}
- if (isadmin()) {
+ if (has_capability('moodle/category:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
if ($categoryedit !== -1) {
$USER->categoryediting = $categoryedit;
}
@@ -58,13 +58,15 @@
}
echo "
";
- if (isloggedin() and !isguest() and !isadmin() and !iscreator()) { // Print link to request a new course
+
+ /// I am not sure this context in the next has_capability call is correct.
+ if (isloggedin() and !isguest() and !has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID))) { // Print link to request a new course
print_single_button("request.php", NULL, get_string("courserequest"), "get");
}
if (iscreator()) { // Print link to create a new course
print_single_button("edit.php", NULL, get_string("addnewcourse"), "get");
}
- if (isadmin() and !empty($CFG->enablecourserequests)) {
+ if (has_capability('moodle/site:approvecourse' get_context_instance(CONTEXT_SYSTEM, SITEID)), and !empty($CFG->enablecourserequests)) {
print_single_button('pending.php',NULL, get_string('coursespending'),"get");
}
echo "
";
diff --git a/course/lib.php b/course/lib.php
index d5b99996d48..927b6aaf3b3 100644
--- a/course/lib.php
+++ b/course/lib.php
@@ -43,7 +43,7 @@ function print_recent_selector_form($course, $advancedfilter=0, $selecteduser=0,
$users[$guest->id] = fullname($guest);
}
- if (isadmin()) {
+ if (has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
if ($ccc = get_records("course", "", "", "fullname")) {
foreach ($ccc as $cc) {
if ($cc->category) {
@@ -144,7 +144,7 @@ function print_recent_selector_form($course, $advancedfilter=0, $selecteduser=0,
echo "
";
echo "
";
- if (isadmin()) {
+ if (has_capability('moodle/course:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
echo "
" />
diff --git a/login/index.php b/login/index.php
index 6c1c47b8cb6..26d35670fe2 100644
--- a/login/index.php
+++ b/login/index.php
@@ -180,7 +180,7 @@
}
/// Go to my-moodle page instead of homepage if mymoodleredirect enabled
- if (!isadmin() and !empty($CFG->mymoodleredirect) and !isguest()) {
+ if (!has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM, SITEID)) and !empty($CFG->mymoodleredirect) and !isguest()) {
if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot.'/' or $urltogo == $CFG->wwwroot.'/index.php') {
$urltogo = $CFG->wwwroot.'/my/';
}
diff --git a/message/history.php b/message/history.php
index 8954763fdc3..322cf2358e4 100644
--- a/message/history.php
+++ b/message/history.php
@@ -20,7 +20,7 @@
error("User ID 1 was incorrect");
}
- if (isadmin()) { // Able to see any discussion
+ if (has_capability('moodle/site:readmessages', get_context_instance(CONTEXT_SYSTEM, SITEID))) { // Able to see any discussion
$userid2 = optional_param('user2', $USER->id, PARAM_INT);
if (! $user2 = get_record("user", "id", $userid2)) { // Check
error("User ID 2 was incorrect");
diff --git a/message/search.html b/message/search.html
index 84fd00c57e5..0d14aac0216 100644
--- a/message/search.html
+++ b/message/search.html
@@ -43,7 +43,7 @@
-
+
diff --git a/message/send.php b/message/send.php
index 0ff850cd0f5..eed40347f09 100644
--- a/message/send.php
+++ b/message/send.php
@@ -46,7 +46,7 @@
/// Check that the user is not blocking us!!
if ($contact = get_record('message_contacts', 'userid', $user->id, 'contactid', $USER->id)) {
- if ($contact->blocked and !isadmin()) {
+ if ($contact->blocked and !has_capability('moodle/site:readmessages', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
print_heading(get_string('userisblockingyou', 'message'));
exit;
}
diff --git a/my/pagelib.php b/my/pagelib.php
index 2195da844c4..a126458a07e 100644
--- a/my/pagelib.php
+++ b/my/pagelib.php
@@ -12,7 +12,7 @@ class page_my_moodle extends page_base {
page_id_and_class($id,$class);
if ($id == PAGE_MY_MOODLE) {
return true;
- } else if (isadmin() && defined('ADMIN_STICKYBLOCKS')) {
+ } else if (has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID)) && defined('ADMIN_STICKYBLOCKS')) {
return true;
}
return false;
@@ -20,7 +20,7 @@ class page_my_moodle extends page_base {
function user_is_editing() {
global $USER;
- if (isadmin() && defined('ADMIN_STICKYBLOCKS')) {
+ if (has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID)) && defined('ADMIN_STICKYBLOCKS')) {
return true;
}
return (!empty($USER->editing));