diff --git a/admin/dbperformance.php b/admin/dbperformance.php index e3080608ce1..648a2ec8c95 100644 --- a/admin/dbperformance.php +++ b/admin/dbperformance.php @@ -12,7 +12,7 @@ require_login(); - require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); $strdatabaseperformance = get_string("databaseperformance"); $stradministration = get_string("administration"); diff --git a/admin/delete.php b/admin/delete.php index afc7ea9933e..55f52c8e09d 100644 --- a/admin/delete.php +++ b/admin/delete.php @@ -13,7 +13,7 @@ $sure = optional_param('sure', 0, PARAM_BOOL); $reallysure = optional_param('reallysure', 0, PARAM_BOOL); - require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); $deletedir = $CFG->dataroot; // The directory to delete! diff --git a/admin/health.php b/admin/health.php index 4ad667da05c..e9fe728ed77 100644 --- a/admin/health.php +++ b/admin/health.php @@ -24,7 +24,7 @@ $solution = optional_param('solution', 0, PARAM_SAFEDIR); //in fact it is class name alhanumeric and _ require_login(); - require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); $site = get_site(); diff --git a/admin/index.php b/admin/index.php index 3800408e829..1ed262cb73e 100644 --- a/admin/index.php +++ b/admin/index.php @@ -545,7 +545,7 @@ /// Check for valid admin user - no guest autologin require_login(0, false); - $context = get_context_instance(CONTEXT_SYSTEM, SITEID); + $context = get_context_instance(CONTEXT_SYSTEM); require_capability('moodle/site:config', $context); diff --git a/admin/innodb.php b/admin/innodb.php index 77cbe205141..e7d82ac2b44 100644 --- a/admin/innodb.php +++ b/admin/innodb.php @@ -9,7 +9,7 @@ require_login(); - require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); admin_externalpage_print_header(); print_heading('Convert all MySQL tables from MYISAM to InnoDB'); diff --git a/admin/lang.php b/admin/lang.php index 84930877dfc..43157369cfc 100644 --- a/admin/lang.php +++ b/admin/lang.php @@ -14,7 +14,7 @@ admin_externalpage_setup('langedit'); - $context = get_context_instance(CONTEXT_SYSTEM, SITEID); + $context = get_context_instance(CONTEXT_SYSTEM); define('LANG_SUBMIT_REPEAT', 1); // repeat displaying submit button? define('LANG_SUBMIT_REPEAT_EVERY', 20); // if so, after how many lines? diff --git a/admin/pagelib.php b/admin/pagelib.php index 7870020e6f6..971ae09d3d3 100644 --- a/admin/pagelib.php +++ b/admin/pagelib.php @@ -51,7 +51,7 @@ class page_admin extends page_base { // seems reasonable that the only people that can edit blocks on the admin pages // are the admins... but maybe we want a role for this? function user_allowed_editing() { - return has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID)); + return has_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM)); } // has to be fixed. i know there's a "proper" way to do this diff --git a/admin/register.php b/admin/register.php index bb0ce172665..f213c6322ed 100644 --- a/admin/register.php +++ b/admin/register.php @@ -5,7 +5,7 @@ require_login(); - require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); if (!$site = get_site()) { redirect("index.php"); diff --git a/admin/report/backups/index.php b/admin/report/backups/index.php index 4591676982a..a332670fc0e 100644 --- a/admin/report/backups/index.php +++ b/admin/report/backups/index.php @@ -11,7 +11,7 @@ $courseid = optional_param('courseid', 0, PARAM_INT); - require_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM)); /// Scheduled backups are disabled by the server admin if (!empty($CFG->disablescheduledbackups)) { diff --git a/admin/report/courseoverview/index.php b/admin/report/courseoverview/index.php index 7bbd95c4911..3977d3ab969 100644 --- a/admin/report/courseoverview/index.php +++ b/admin/report/courseoverview/index.php @@ -12,7 +12,7 @@ $time = optional_param('time', 0, PARAM_INT); $numcourses = optional_param('numcourses', 20, PARAM_INT); - require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM, SITEID)); // needed? + require_capability('moodle/site:viewreports', get_context_instance(CONTEXT_SYSTEM)); // needed? if (empty($CFG->enablestats)) { redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=stats", get_string('mustenablestats', 'admin'), 3); diff --git a/admin/report/simpletest/index.php b/admin/report/simpletest/index.php index 974966e4196..635a7f66f14 100644 --- a/admin/report/simpletest/index.php +++ b/admin/report/simpletest/index.php @@ -17,7 +17,7 @@ require_once('ex_simple_test.php'); require_once('ex_reporter.php'); require_login(); -require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); +require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); /* The UNITTEST constant can be checked elsewhere if you need to know * when your code is being run as part of a unit test. */ diff --git a/admin/roles/allowassign.php b/admin/roles/allowassign.php index 0827a6a1b4c..5657b0a230c 100755 --- a/admin/roles/allowassign.php +++ b/admin/roles/allowassign.php @@ -13,7 +13,7 @@ admin_externalpage_setup('defineroles'); - $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); + $sitecontext = get_context_instance(CONTEXT_SYSTEM); require_capability('moodle/role:manage', $sitecontext); /// form processiong here diff --git a/admin/roles/allowoverride.php b/admin/roles/allowoverride.php index 17c28c68c62..4bb41fe5997 100755 --- a/admin/roles/allowoverride.php +++ b/admin/roles/allowoverride.php @@ -11,7 +11,7 @@ admin_externalpage_setup('defineroles'); - $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); + $sitecontext = get_context_instance(CONTEXT_SYSTEM); require_capability('moodle/role:manage', $sitecontext); /// form processiong here diff --git a/admin/stickyblocks.php b/admin/stickyblocks.php index 9c6103e8bb6..c2aefae6e9a 100644 --- a/admin/stickyblocks.php +++ b/admin/stickyblocks.php @@ -24,7 +24,7 @@ require_login(); - require_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:manageblocks', get_context_instance(CONTEXT_SYSTEM)); // first thing to do is print the dropdown menu diff --git a/admin/timezone.php b/admin/timezone.php index 73a9d24e6cb..94993cc644e 100644 --- a/admin/timezone.php +++ b/admin/timezone.php @@ -6,7 +6,7 @@ require_login(); - require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); $strtimezone = get_string("timezone"); $strsavechanges = get_string("savechanges"); diff --git a/admin/uploadpicture.php b/admin/uploadpicture.php index e39111e1029..54aace9d457 100644 --- a/admin/uploadpicture.php +++ b/admin/uploadpicture.php @@ -32,7 +32,7 @@ admin_externalpage_setup('uploadpictures', $adminroot); require_login(); -require_capability('moodle/site:uploadusers', get_context_instance(CONTEXT_SYSTEM, SITEID)); +require_capability('moodle/site:uploadusers', get_context_instance(CONTEXT_SYSTEM)); if (!$site = get_site()) { print_error('cannotfindsite', 'error'); diff --git a/admin/xmldb/index.php b/admin/xmldb/index.php index 58964ccccf6..88ceae5a1d6 100644 --- a/admin/xmldb/index.php +++ b/admin/xmldb/index.php @@ -79,7 +79,7 @@ } require_login(); - require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)); /// Body of the script, based on action, we delegate the work $action = optional_param ('action', 'main_view', PARAM_ALPHAEXT); diff --git a/auth/mnet/auth.php b/auth/mnet/auth.php index d9e89e167c4..2381ca70fe8 100644 --- a/auth/mnet/auth.php +++ b/auth/mnet/auth.php @@ -171,7 +171,7 @@ class auth_plugin_mnet extends auth_plugin_base { require_once $CFG->dirroot . '/mnet/xmlrpc/client.php'; // check remote login permissions - if (! has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM, SITEID)) + if (! has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM)) or is_mnet_remote_user($USER) or $USER->username == 'guest' or empty($USER->id)) { diff --git a/auth/shibboleth/index.php b/auth/shibboleth/index.php index e01489458cc..3cf39a78495 100644 --- a/auth/shibboleth/index.php +++ b/auth/shibboleth/index.php @@ -21,7 +21,7 @@ // Check whether Shibboleth is configured properly if (empty($pluginconfig->user_attribute)) { - error(get_string( 'shib_not_set_up_error', 'auth')); + print_error('shib_not_set_up_error', 'auth'); } /// If we can find the Shibboleth attribute, save it in session and return to main login page @@ -66,7 +66,7 @@ } /// Go to my-moodle page instead of homepage if mymoodleredirect enabled - if (!has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM, SITEID)) and !empty($CFG->mymoodleredirect) and !isguest()) { + if (!has_capability('moodle/site:config',get_context_instance(CONTEXT_SYSTEM)) and !empty($CFG->mymoodleredirect) and !isguest()) { if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot.'/' or $urltogo == $CFG->wwwroot.'/index.php') { $urltogo = $CFG->wwwroot.'/my/'; } @@ -88,9 +88,9 @@ // If we can find any (user independent) Shibboleth attributes but no user // attributes we probably didn't receive any user attributes elseif (!empty($_SERVER['HTTP_SHIB_APPLICATION_ID'])) { - error(get_string( 'shib_no_attributes_error', 'auth' , '\''.$pluginconfig->user_attribute.'\', \''.$pluginconfig->field_map_firstname.'\', \''.$pluginconfig->field_map_lastname.'\' and \''.$pluginconfig->field_map_email.'\'')); + print_error('shib_no_attributes_error', 'auth' , '', '\''.$pluginconfig->user_attribute.'\', \''.$pluginconfig->field_map_firstname.'\', \''.$pluginconfig->field_map_lastname.'\' and \''.$pluginconfig->field_map_email.'\''); } else { - error(get_string( 'shib_not_set_up_error', 'auth')); + print_error('shib_not_set_up_error', 'auth'); } ?> diff --git a/backup/backup_check.html b/backup/backup_check.html index 62469cc3372..f17be59115a 100644 --- a/backup/backup_check.html +++ b/backup/backup_check.html @@ -15,7 +15,7 @@ } } } else { - if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) { print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } diff --git a/backup/backup_execute.html b/backup/backup_execute.html index 65fada8ab77..2e754d7ab67 100644 --- a/backup/backup_execute.html +++ b/backup/backup_execute.html @@ -15,7 +15,7 @@ } } } else { - if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (!has_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM))) { print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } diff --git a/backup/backuplib.php b/backup/backuplib.php index c93c72732c9..ccdaaf92cef 100644 --- a/backup/backuplib.php +++ b/backup/backuplib.php @@ -641,7 +641,7 @@ fwrite ($bf, start_tag('ROLES', 1, true)); $roles = backup_fetch_roles($preferences); - $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); + $sitecontext = get_context_instance(CONTEXT_SYSTEM); foreach ($roles as $role) { fwrite ($bf,start_tag('ROLE',2,true)); diff --git a/backup/log.php b/backup/log.php index 48e02509384..7ef38b1591e 100644 --- a/backup/log.php +++ b/backup/log.php @@ -6,7 +6,7 @@ require_login(); - require_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:backup', get_context_instance(CONTEXT_SYSTEM)); redirect("$CFG->wwwroot/$CFG->admin/report/backups/index.php", '', 'admin', 1); diff --git a/backup/restore.php b/backup/restore.php index 475054aba7d..37f1328fe20 100644 --- a/backup/restore.php +++ b/backup/restore.php @@ -62,7 +62,7 @@ } } } else { - if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) { print_error("cannotuseadmin", '', "$CFG->wwwroot/login/index.php"); } } @@ -122,7 +122,7 @@ } //Print header - if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) { $navlinks[] = array('name' => basename($file), 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); diff --git a/backup/restore_check.html b/backup/restore_check.html index 746b846dfb3..3210bd184d9 100644 --- a/backup/restore_check.html +++ b/backup/restore_check.html @@ -192,7 +192,7 @@ print_error("You need to be a teacher or admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } else { - if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) { print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } diff --git a/backup/restore_execute.html b/backup/restore_execute.html index d87a8fc9d98..58757595d37 100644 --- a/backup/restore_execute.html +++ b/backup/restore_execute.html @@ -33,7 +33,7 @@ } } } else { - if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) { print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } diff --git a/backup/restore_precheck.html b/backup/restore_precheck.html index a63ab169380..b0e052de49d 100644 --- a/backup/restore_precheck.html +++ b/backup/restore_precheck.html @@ -25,7 +25,7 @@ } } } else { - if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) { print_error("You need to be an admin user to use this page.", '', "$CFG->wwwroot/login/index.php"); } } diff --git a/backup/restorelib.php b/backup/restorelib.php index f8b4919ff8f..0cac2801f69 100644 --- a/backup/restorelib.php +++ b/backup/restorelib.php @@ -8127,7 +8127,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); if ($CFG->creatornewroleid) { role_assign($CFG->creatornewroleid, $USER->id, 0, $newcontext->id); } else { - if ($legacyteachers = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if ($legacyteachers = get_roles_with_capability('moodle/legacy:editingteacher', CAP_ALLOW, get_context_instance(CONTEXT_SYSTEM))) { if ($legacyteacher = array_shift($legacyteachers)) { role_assign($legacyteacher->id, $USER->id, 0, $newcontext->id); } @@ -8273,7 +8273,7 @@ define('RESTORE_GROUPS_GROUPINGS', 3); } $info = restore_read_xml_roles($xmlfile); - $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); + $sitecontext = get_context_instance(CONTEXT_SYSTEM); // the following code creates new roles // but we could use more intelligent detection, and role mapping diff --git a/backup/try.php b/backup/try.php index a845a6c3c4d..ec4fc821d4c 100644 --- a/backup/try.php +++ b/backup/try.php @@ -7,7 +7,7 @@ require_login(); - require_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM, SITEID)); + require_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM)); //Check site if (!$site = get_site()) { diff --git a/blocks/blog_menu/block_blog_menu.php b/blocks/blog_menu/block_blog_menu.php index 6625303a026..04aed2e2e8e 100755 --- a/blocks/blog_menu/block_blog_menu.php +++ b/blocks/blog_menu/block_blog_menu.php @@ -51,7 +51,7 @@ class block_blog_menu extends block_base { $addentrylink = ''; $coursearg = ''; - $sitecontext = get_context_instance(CONTEXT_SYSTEM, SITEID); + $sitecontext = get_context_instance(CONTEXT_SYSTEM); if ($COURSE->id != SITEID) { diff --git a/blocks/blog_tags/block_blog_tags.php b/blocks/blog_tags/block_blog_tags.php index d3508888c3e..b7c6a44a92f 100644 --- a/blocks/blog_tags/block_blog_tags.php +++ b/blocks/blog_tags/block_blog_tags.php @@ -80,7 +80,7 @@ class block_blog_tags extends block_base { $sql .= 'AND p.id = ti.itemid '; // admins should be able to read all tags - if (!has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_SYSTEM, SITEID))) { + if (!has_capability('moodle/user:readuserblogs', get_context_instance(CONTEXT_SYSTEM))) { $sql .= 'AND (p.publishstate = \'site\' or p.publishstate=\'public\') '; } $sql .= "AND ti.timemodified > {$timewithin} "; diff --git a/blocks/rss_client/block_rss_client_action.php b/blocks/rss_client/block_rss_client_action.php index 5339b7cb676..bfe3aa5eef5 100644 --- a/blocks/rss_client/block_rss_client_action.php +++ b/blocks/rss_client/block_rss_client_action.php @@ -63,7 +63,7 @@ if (!empty($id)) { $context = get_context_instance(CONTEXT_COURSE, $id); } } else { - $context = get_context_instance(CONTEXT_SYSTEM, SITEID); + $context = get_context_instance(CONTEXT_SYSTEM); } diff --git a/enrol/database/config.html b/enrol/database/config.html index 6d2bea35e92..2387823db0c 100644 --- a/enrol/database/config.html +++ b/enrol/database/config.html @@ -156,7 +156,7 @@