mirror of
https://github.com/moodle/moodle.git
synced 2025-01-16 13:09:21 +01:00
MDL-71062 core: Step 1 deprecation of print_error function
This commit is contained in:
parent
a23f0bff3e
commit
73d604369d
@ -28,7 +28,7 @@ if (empty($CFG->auth)) {
|
||||
}
|
||||
|
||||
if (!empty($auth) and !exists_auth_plugin($auth)) {
|
||||
print_error('pluginnotinstalled', 'auth', $returnurl, $auth);
|
||||
throw new \moodle_exception('pluginnotinstalled', 'auth', $returnurl, $auth);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -55,7 +55,7 @@ switch ($action) {
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth plugin is valid
|
||||
if ($key === false) {
|
||||
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
|
||||
throw new \moodle_exception('pluginnotenabled', 'auth', $returnurl, $auth);
|
||||
}
|
||||
// move down the list
|
||||
if ($key < (count($authsenabled) - 1)) {
|
||||
@ -72,7 +72,7 @@ switch ($action) {
|
||||
$key = array_search($auth, $authsenabled);
|
||||
// check auth is valid
|
||||
if ($key === false) {
|
||||
print_error('pluginnotenabled', 'auth', $returnurl, $auth);
|
||||
throw new \moodle_exception('pluginnotenabled', 'auth', $returnurl, $auth);
|
||||
}
|
||||
// move up the list
|
||||
if ($key >= 1) {
|
||||
|
@ -75,7 +75,7 @@
|
||||
/// Get and sort the existing blocks
|
||||
|
||||
if (!$blocks = $DB->get_records('block', array(), 'name ASC')) {
|
||||
print_error('noblocks', 'error'); // Should never happen
|
||||
throw new \moodle_exception('noblocks', 'error'); // Should never happen.
|
||||
}
|
||||
|
||||
$incompatible = array();
|
||||
|
@ -41,11 +41,11 @@ $adminroot = admin_get_root(); // need all settings
|
||||
$settingspage = $adminroot->locate($category, true);
|
||||
|
||||
if (empty($settingspage) or !($settingspage instanceof admin_category)) {
|
||||
print_error('categoryerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
|
||||
throw new \moodle_exception('categoryerror', 'error', "$CFG->wwwroot/$CFG->admin/");
|
||||
}
|
||||
|
||||
if (!($settingspage->check_access())) {
|
||||
print_error('accessdenied', 'admin');
|
||||
throw new \moodle_exception('accessdenied', 'admin');
|
||||
}
|
||||
|
||||
$hassiteconfig = has_capability('moodle/site:config', $PAGE->context);
|
||||
|
@ -69,15 +69,15 @@ if ($options['showdebugging']) {
|
||||
}
|
||||
|
||||
if (!$admin = get_admin()) {
|
||||
print_error('noadmins');
|
||||
throw new \moodle_exception('noadmins');
|
||||
}
|
||||
|
||||
if (!file_exists($options['file'])) {
|
||||
print_error('filenotfound');
|
||||
throw new \moodle_exception('filenotfound');
|
||||
}
|
||||
|
||||
if (!$category = $DB->get_record('course_categories', ['id' => $options['categoryid']], 'id')) {
|
||||
print_error('invalidcategoryid');
|
||||
throw new \moodle_exception('invalidcategoryid');
|
||||
}
|
||||
|
||||
$backupdir = "restore_" . uniqid();
|
||||
@ -102,7 +102,7 @@ try {
|
||||
} catch (Exception $e) {
|
||||
cli_heading(get_string('cleaningtempdata'));
|
||||
fulldelete($path);
|
||||
print_error('generalexceptionmessage', 'error', '', $e->getMessage());
|
||||
throw new \moodle_exception('generalexceptionmessage', 'error', '', $e->getMessage());
|
||||
}
|
||||
|
||||
cli_heading(get_string('restoredcourseid', 'backup', $courseid));
|
||||
|
@ -42,7 +42,7 @@ $plugins = core_plugin_manager::instance()->get_plugins_of_type('contenttype');
|
||||
$sortorder = array_flip(array_keys($plugins));
|
||||
|
||||
if (!isset($plugins[$name])) {
|
||||
print_error('contenttypenotfound', 'error', $return, $name);
|
||||
throw new \moodle_exception('contenttypenotfound', 'error', $return, $name);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
|
@ -41,7 +41,7 @@ $formatplugins = core_plugin_manager::instance()->get_plugins_of_type('format');
|
||||
$sortorder = array_flip(array_keys($formatplugins));
|
||||
|
||||
if (!isset($formatplugins[$formatname])) {
|
||||
print_error('courseformatnotfound', 'error', $return, $formatname);
|
||||
throw new \moodle_exception('courseformatnotfound', 'error', $return, $formatname);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
|
@ -58,7 +58,7 @@ require_once($CFG->libdir.'/cronlib.php');
|
||||
// check if execution allowed
|
||||
if (!empty($CFG->cronclionly)) {
|
||||
// This script can only be run via the cli.
|
||||
print_error('cronerrorclionly', 'admin');
|
||||
throw new \moodle_exception('cronerrorclionly', 'admin');
|
||||
exit;
|
||||
}
|
||||
// This script is being called via the web, so check the password if there is one.
|
||||
@ -66,7 +66,7 @@ if (!empty($CFG->cronremotepassword)) {
|
||||
$pass = optional_param('password', '', PARAM_RAW);
|
||||
if ($pass != $CFG->cronremotepassword) {
|
||||
// wrong password.
|
||||
print_error('cronerrorpassword', 'admin');
|
||||
throw new \moodle_exception('cronerrorpassword', 'admin');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ $customfieldplugins = core_plugin_manager::instance()->get_plugins_of_type('cust
|
||||
$sortorder = array_flip(array_keys($customfieldplugins));
|
||||
|
||||
if (!isset($customfieldplugins[$customfieldname])) {
|
||||
print_error('customfieldnotfound', 'error', $return, $customfieldname);
|
||||
throw new \moodle_exception('customfieldnotfound', 'error', $return, $customfieldname);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
|
@ -42,7 +42,7 @@ $plugins = core_plugin_manager::instance()->get_plugins_of_type('dataformat');
|
||||
$sortorder = array_flip(array_keys($plugins));
|
||||
|
||||
if (!isset($plugins[$name])) {
|
||||
print_error('courseformatnotfound', 'error', $return, $name);
|
||||
throw new \moodle_exception('courseformatnotfound', 'error', $return, $name);
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
|
@ -55,11 +55,11 @@ if ($action == 'updatecomponent' && confirm_sesskey()) {
|
||||
$a = new stdClass();
|
||||
$a->url = 'https://download.moodle.org/environment/environment.zip';
|
||||
$a->dest = $CFG->dataroot . '/';
|
||||
print_error($cd->get_error(), 'error', $PAGE->url, $a);
|
||||
throw new \moodle_exception($cd->get_error(), 'error', $PAGE->url, $a);
|
||||
die();
|
||||
|
||||
} else {
|
||||
print_error($cd->get_error(), 'error', $PAGE->url);
|
||||
throw new \moodle_exception($cd->get_error(), 'error', $PAGE->url);
|
||||
die();
|
||||
}
|
||||
|
||||
|
@ -174,15 +174,17 @@ $documentationlink = '<a href="http://docs.moodle.org/en/Installation">Installat
|
||||
// Check some PHP server settings
|
||||
|
||||
if (ini_get_bool('session.auto_start')) {
|
||||
print_error('phpvaroff', 'debug', '', (object)array('name'=>'session.auto_start', 'link'=>$documentationlink));
|
||||
throw new \moodle_exception('phpvaroff', 'debug', '',
|
||||
(object)array('name' => 'session.auto_start', 'link' => $documentationlink));
|
||||
}
|
||||
|
||||
if (!ini_get_bool('file_uploads')) {
|
||||
print_error('phpvaron', 'debug', '', (object)array('name'=>'file_uploads', 'link'=>$documentationlink));
|
||||
throw new \moodle_exception('phpvaron', 'debug', '',
|
||||
(object)array('name' => 'file_uploads', 'link' => $documentationlink));
|
||||
}
|
||||
|
||||
if (is_float_problem()) {
|
||||
print_error('phpfloatproblem', 'admin', '', $documentationlink);
|
||||
throw new \moodle_exception('phpfloatproblem', 'admin', '', $documentationlink);
|
||||
}
|
||||
|
||||
// Set some necessary variables during set-up to avoid PHP warnings later on this page
|
||||
@ -203,7 +205,7 @@ require("$CFG->dirroot/version.php"); // defines $version, $release, $bran
|
||||
$CFG->target_release = $release; // used during installation and upgrades
|
||||
|
||||
if (!$version or !$release) {
|
||||
print_error('withoutversion', 'debug'); // without version, stop
|
||||
throw new \moodle_exception('withoutversion', 'debug'); // Without version, stop.
|
||||
}
|
||||
|
||||
if (!core_tables_exist()) {
|
||||
@ -275,7 +277,7 @@ if (!core_tables_exist()) {
|
||||
if (!$DB->setup_is_unicodedb()) {
|
||||
if (!$DB->change_db_encoding()) {
|
||||
// If could not convert successfully, throw error, and prevent installation
|
||||
print_error('unicoderequired', 'admin');
|
||||
throw new \moodle_exception('unicoderequired', 'admin');
|
||||
}
|
||||
}
|
||||
|
||||
@ -297,7 +299,7 @@ $stradministration = get_string('administration');
|
||||
$PAGE->set_context(context_system::instance());
|
||||
|
||||
if (empty($CFG->version)) {
|
||||
print_error('missingconfigversion', 'debug');
|
||||
throw new \moodle_exception('missingconfigversion', 'debug');
|
||||
}
|
||||
|
||||
// Detect config cache inconsistency, this happens when you switch branches on dev servers.
|
||||
@ -748,7 +750,7 @@ if (during_initial_install()) {
|
||||
redirect("index.php?sessionstarted=1&sessionverify=1&lang=$CFG->lang");
|
||||
} else {
|
||||
if (empty($SESSION->sessionverify)) {
|
||||
print_error('installsessionerror', 'admin', "index.php?sessionstarted=1&lang=$CFG->lang");
|
||||
throw new \moodle_exception('installsessionerror', 'admin', "index.php?sessionstarted=1&lang=$CFG->lang");
|
||||
}
|
||||
unset($SESSION->sessionverify);
|
||||
}
|
||||
@ -765,7 +767,7 @@ if (during_initial_install()) {
|
||||
if ($adminuser->password === 'adminsetuppending') {
|
||||
// prevent installation hijacking
|
||||
if ($adminuser->lastip !== getremoteaddr()) {
|
||||
print_error('installhijacked', 'admin');
|
||||
throw new \moodle_exception('installhijacked', 'admin');
|
||||
}
|
||||
// login user and let him set password and admin details
|
||||
$adminuser->newadminuser = 1;
|
||||
|
@ -15,7 +15,7 @@ $action = trim(strtolower(optional_param('action', '', PARAM_ALPHA)));
|
||||
admin_externalpage_setup('ssoaccesscontrol');
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
throw new \moodle_exception('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
$sitecontext = context_system::instance();
|
||||
@ -35,13 +35,13 @@ if (!empty($action) and confirm_sesskey()) {
|
||||
|
||||
// boot if insufficient permission
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
print_error('nomodifyacl','mnet');
|
||||
throw new \moodle_exception('nomodifyacl', 'mnet');
|
||||
}
|
||||
|
||||
// fetch the record in question
|
||||
$id = required_param('id', PARAM_INT);
|
||||
if (!$idrec = $DB->get_record('mnet_sso_access_control', array('id'=>$id))) {
|
||||
print_error('recordnoexists','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
throw new \moodle_exception('recordnoexists', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
|
||||
switch ($action) {
|
||||
@ -56,7 +56,7 @@ if (!empty($action) and confirm_sesskey()) {
|
||||
// require the access parameter, and it must be 'allow' or 'deny'
|
||||
$accessctrl = trim(strtolower(required_param('accessctrl', PARAM_ALPHA)));
|
||||
if ($accessctrl != 'allow' and $accessctrl != 'deny') {
|
||||
print_error('invalidaccessparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
throw new \moodle_exception('invalidaccessparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
|
||||
if (mnet_update_sso_access_control($idrec->username, $idrec->mnet_host_id, $accessctrl)) {
|
||||
@ -71,7 +71,7 @@ if (!empty($action) and confirm_sesskey()) {
|
||||
break;
|
||||
|
||||
default:
|
||||
print_error('invalidactionparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
throw new \moodle_exception('invalidactionparam', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ if ($form = data_submitted() and confirm_sesskey()) {
|
||||
|
||||
// check permissions and verify form input
|
||||
if (!has_capability('moodle/user:delete', $sitecontext)) {
|
||||
print_error('nomodifyacl','mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
throw new \moodle_exception('nomodifyacl', 'mnet', "$CFG->wwwroot/$CFG->admin/mnet/access_control.php");
|
||||
}
|
||||
if (empty($form->username)) {
|
||||
$formerror['username'] = get_string('enterausername','mnet');
|
||||
|
@ -17,13 +17,13 @@
|
||||
if (!extension_loaded('openssl')) {
|
||||
echo $OUTPUT->header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
throw new \moodle_exception('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
echo $OUTPUT->header();
|
||||
set_config('mnet_dispatcher_mode', 'off');
|
||||
print_error('nocurl', 'mnet');
|
||||
throw new \moodle_exception('nocurl', 'mnet');
|
||||
}
|
||||
|
||||
if (!isset($CFG->mnet_dispatcher_mode)) {
|
||||
@ -37,7 +37,7 @@
|
||||
if (set_config('mnet_dispatcher_mode', $form->mode)) {
|
||||
redirect('index.php', get_string('changessaved'));
|
||||
} else {
|
||||
print_error('invalidaction', '', 'index.php');
|
||||
throw new \moodle_exception('invalidaction', '', 'index.php');
|
||||
}
|
||||
}
|
||||
} elseif (!empty($form->submit) && $form->submit == get_string('delete')) {
|
||||
@ -63,13 +63,13 @@
|
||||
|
||||
if($time < time() - 60) {
|
||||
// fail - you're out of time.
|
||||
print_error ('deleteoutoftime', 'mnet', 'index.php');
|
||||
throw new \moodle_exception ('deleteoutoftime', 'mnet', 'index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($key != md5(sha1($mnet->keypair['keypair_PEM']))) {
|
||||
// fail - you're being attacked?
|
||||
print_error ('deletewrongkeyvalue', 'mnet', 'index.php');
|
||||
throw new \moodle_exception ('deletewrongkeyvalue', 'mnet', 'index.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
@ -54,15 +54,15 @@ admin_externalpage_setup($adminsection);
|
||||
$deprecatenotify = mnet_get_deprecation_notice();
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet');
|
||||
throw new \moodle_exception('requiresopenssl', 'mnet');
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init') ) {
|
||||
print_error('nocurl', 'mnet');
|
||||
throw new \moodle_exception('nocurl', 'mnet');
|
||||
}
|
||||
|
||||
if (!function_exists('xmlrpc_encode_request')) {
|
||||
print_error('xmlrpc-missing', 'mnet');
|
||||
throw new \moodle_exception('xmlrpc-missing', 'mnet');
|
||||
}
|
||||
|
||||
if (!isset($CFG->mnet_dispatcher_mode)) {
|
||||
@ -176,7 +176,7 @@ if ($formdata = $reviewform->get_data()) {
|
||||
if ($mnet_peer->commit()) {
|
||||
redirect(new moodle_url('/admin/mnet/peers.php', array('hostid' => $mnet_peer->id)), get_string('changessaved'));
|
||||
} else {
|
||||
print_error('invalidaction', 'error', 'index.php');
|
||||
throw new \moodle_exception('invalidaction', 'error', 'index.php');
|
||||
}
|
||||
} else if ($reviewform->is_submitted()) { // submitted, but errors
|
||||
echo $OUTPUT->header();
|
||||
|
@ -18,7 +18,7 @@ require_once($CFG->libdir.'/adminlib.php');
|
||||
include_once($CFG->dirroot.'/mnet/lib.php');
|
||||
|
||||
if ($CFG->mnet_dispatcher_mode === 'off') {
|
||||
print_error('mnetdisabled', 'mnet');
|
||||
throw new \moodle_exception('mnetdisabled', 'mnet');
|
||||
}
|
||||
|
||||
admin_externalpage_setup('mnettestclient');
|
||||
@ -27,7 +27,7 @@ error_reporting(DEBUG_ALL);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
if (!extension_loaded('openssl')) {
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
throw new \moodle_exception('requiresopenssl', 'mnet', '', null, true);
|
||||
}
|
||||
|
||||
// optional drilling down parameters
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
if (!extension_loaded('openssl')) {
|
||||
echo $OUTPUT->header();
|
||||
print_error('requiresopenssl', 'mnet', '', NULL, true);
|
||||
throw new \moodle_exception('requiresopenssl', 'mnet', '', null, true);
|
||||
}
|
||||
|
||||
$site = get_site();
|
||||
|
@ -62,7 +62,7 @@
|
||||
/// Get and sort the existing modules
|
||||
|
||||
if (!$modules = $DB->get_records('modules', array(), 'name ASC')) {
|
||||
print_error('moduledoesnotexist', 'error');
|
||||
throw new \moodle_exception('moduledoesnotexist', 'error');
|
||||
}
|
||||
|
||||
/// Print the table of all modules
|
||||
|
@ -116,13 +116,13 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
$instance = portfolio_instance($portfolio);
|
||||
if ($sure) {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', '', $baseurl);
|
||||
throw new \moodle_exception('confirmsesskeybad', '', $baseurl);
|
||||
}
|
||||
if ($instance->delete()) {
|
||||
$deletedstr = get_string('instancedeleted', 'portfolio');
|
||||
redirect($baseurl, $deletedstr, 1);
|
||||
} else {
|
||||
print_error('instancenotdeleted', 'portfolio', $baseurl);
|
||||
throw new \moodle_exception('instancenotdeleted', 'portfolio', $baseurl);
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
|
@ -84,7 +84,7 @@ if (!empty($config->disabledbehaviours)) {
|
||||
// Disable.
|
||||
if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($behaviours[$disable])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $disable);
|
||||
throw new \moodle_exception('unknownbehaviour', 'question', $thispageurl, $disable);
|
||||
}
|
||||
|
||||
if (array_search($disable, $disabledbehaviours) === false) {
|
||||
@ -97,11 +97,11 @@ if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey(
|
||||
// Enable.
|
||||
if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($behaviours[$enable])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $enable);
|
||||
throw new \moodle_exception('unknownbehaviour', 'question', $thispageurl, $enable);
|
||||
}
|
||||
|
||||
if (!$archetypal[$enable]) {
|
||||
print_error('cannotenablebehaviour', 'question', $thispageurl, $enable);
|
||||
throw new \moodle_exception('cannotenablebehaviour', 'question', $thispageurl, $enable);
|
||||
}
|
||||
|
||||
if (($key = array_search($enable, $disabledbehaviours)) !== false) {
|
||||
@ -114,7 +114,7 @@ if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey())
|
||||
// Move up in order.
|
||||
if (($up = optional_param('up', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($behaviours[$up])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $up);
|
||||
throw new \moodle_exception('unknownbehaviour', 'question', $thispageurl, $up);
|
||||
}
|
||||
|
||||
// This function works fine for behaviours, as well as qtypes.
|
||||
@ -126,7 +126,7 @@ if (($up = optional_param('up', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
// Move down in order.
|
||||
if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($behaviours[$down])) {
|
||||
print_error('unknownbehaviour', 'question', $thispageurl, $down);
|
||||
throw new \moodle_exception('unknownbehaviour', 'question', $thispageurl, $down);
|
||||
}
|
||||
|
||||
// This function works fine for behaviours, as well as qtypes.
|
||||
|
@ -106,7 +106,7 @@ $sortedqtypes = question_bank::sort_qtype_array($sortedqtypes, $config);
|
||||
// Disable.
|
||||
if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($qtypes[$disable])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $disable);
|
||||
throw new \moodle_exception('unknownquestiontype', 'question', $thispageurl, $disable);
|
||||
}
|
||||
|
||||
$class = \core_plugin_manager::resolve_plugininfo_class('qtype');
|
||||
@ -117,11 +117,11 @@ if (($disable = optional_param('disable', '', PARAM_PLUGIN)) && confirm_sesskey(
|
||||
// Enable.
|
||||
if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($qtypes[$enable])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $enable);
|
||||
throw new \moodle_exception('unknownquestiontype', 'question', $thispageurl, $enable);
|
||||
}
|
||||
|
||||
if (!$qtypes[$enable]->menu_name()) {
|
||||
print_error('cannotenable', 'question', $thispageurl, $enable);
|
||||
throw new \moodle_exception('cannotenable', 'question', $thispageurl, $enable);
|
||||
}
|
||||
|
||||
$class = \core_plugin_manager::resolve_plugininfo_class('qtype');
|
||||
@ -132,7 +132,7 @@ if (($enable = optional_param('enable', '', PARAM_PLUGIN)) && confirm_sesskey())
|
||||
// Move up in order.
|
||||
if (($up = optional_param('up', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($qtypes[$up])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $up);
|
||||
throw new \moodle_exception('unknownquestiontype', 'question', $thispageurl, $up);
|
||||
}
|
||||
|
||||
$neworder = question_reorder_qtypes($sortedqtypes, $up, -1);
|
||||
@ -143,7 +143,7 @@ if (($up = optional_param('up', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
// Move down in order.
|
||||
if (($down = optional_param('down', '', PARAM_PLUGIN)) && confirm_sesskey()) {
|
||||
if (!isset($qtypes[$down])) {
|
||||
print_error('unknownquestiontype', 'question', $thispageurl, $down);
|
||||
throw new \moodle_exception('unknownquestiontype', 'question', $thispageurl, $down);
|
||||
}
|
||||
|
||||
$neworder = question_reorder_qtypes($sortedqtypes, $down, +1);
|
||||
|
@ -152,7 +152,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($baseurl);
|
||||
} else {
|
||||
print_error('instancenotsaved', 'repository', $baseurl);
|
||||
throw new \moodle_exception('instancenotsaved', 'repository', $baseurl);
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
@ -183,14 +183,14 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
}
|
||||
} else if ($action == 'show') {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', '', $baseurl);
|
||||
throw new \moodle_exception('confirmsesskeybad', '', $baseurl);
|
||||
}
|
||||
$class = \core_plugin_manager::resolve_plugininfo_class('repository');
|
||||
$class::enable_plugin($repository, 1);
|
||||
$return = true;
|
||||
} else if ($action == 'hide') {
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', '', $baseurl);
|
||||
throw new \moodle_exception('confirmsesskeybad', '', $baseurl);
|
||||
}
|
||||
$class = \core_plugin_manager::resolve_plugininfo_class('repository');
|
||||
$class::enable_plugin($repository, 0);
|
||||
@ -200,7 +200,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
if ($sure) {
|
||||
$PAGE->set_pagetype('admin-repository-' . $repository);
|
||||
if (!confirm_sesskey()) {
|
||||
print_error('confirmsesskeybad', '', $baseurl);
|
||||
throw new \moodle_exception('confirmsesskeybad', '', $baseurl);
|
||||
}
|
||||
|
||||
if ($repositorytype->delete($downloadcontents)) {
|
||||
@ -209,7 +209,7 @@ if (($action == 'edit') || ($action == 'new')) {
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($baseurl);
|
||||
} else {
|
||||
print_error('instancenotdeleted', 'repository', $baseurl);
|
||||
throw new \moodle_exception('instancenotdeleted', 'repository', $baseurl);
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
|
@ -104,7 +104,7 @@ if (!empty($edit) || !empty($new)) {
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($parenturl);
|
||||
} else {
|
||||
print_error('instancenotsaved', 'repository', $parenturl);
|
||||
throw new \moodle_exception('instancenotsaved', 'repository', $parenturl);
|
||||
}
|
||||
exit;
|
||||
} else {
|
||||
@ -134,7 +134,7 @@ if (!empty($edit) || !empty($new)) {
|
||||
core_plugin_manager::reset_caches();
|
||||
redirect($parenturl, $deletedstr, 3);
|
||||
} else {
|
||||
print_error('instancenotdeleted', 'repository', $parenturl);
|
||||
throw new \moodle_exception('instancenotdeleted', 'repository', $parenturl);
|
||||
}
|
||||
exit;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ $classformode = array(
|
||||
'view' => 'core_role_allow_view_page'
|
||||
);
|
||||
if (!isset($classformode[$mode])) {
|
||||
print_error('invalidmode', '', '', $mode);
|
||||
throw new \moodle_exception('invalidmode', '', '', $mode);
|
||||
}
|
||||
|
||||
$baseurl = new moodle_url('/admin/roles/allow.php', array('mode'=>$mode));
|
||||
|
@ -75,7 +75,7 @@ if ($roleid && !isset($assignableroles[$roleid])) {
|
||||
$a = new stdClass;
|
||||
$a->roleid = $roleid;
|
||||
$a->context = $contextname;
|
||||
print_error('cannotassignrolehere', '', $context->get_url(), $a);
|
||||
throw new \moodle_exception('cannotassignrolehere', '', $context->get_url(), $a);
|
||||
}
|
||||
|
||||
// Work out an appropriate page title.
|
||||
|
@ -48,7 +48,7 @@ if ($course) {
|
||||
// Security first.
|
||||
require_login($course, false, $cm);
|
||||
if (!has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride', 'moodle/role:override', 'moodle/role:manage'), $context)) {
|
||||
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'core_role'));
|
||||
throw new \moodle_exception('nopermissions', 'error', '', get_string('checkpermissions', 'core_role'));
|
||||
}
|
||||
|
||||
navigation_node::override_active_url($url);
|
||||
|
@ -68,7 +68,7 @@ $confirmed = (optional_param('confirm', false, PARAM_BOOL) && data_submitted() &
|
||||
switch ($action) {
|
||||
case 'delete':
|
||||
if (isset($undeletableroles[$roleid])) {
|
||||
print_error('cannotdeletethisrole', '', $baseurl);
|
||||
throw new \moodle_exception('cannotdeletethisrole', '', $baseurl);
|
||||
}
|
||||
if (!$confirmed) {
|
||||
// Show confirmation.
|
||||
@ -89,7 +89,7 @@ switch ($action) {
|
||||
}
|
||||
if (!delete_role($roleid)) {
|
||||
// The delete failed.
|
||||
print_error('cannotdeleterolewithid', 'error', $baseurl, $roleid);
|
||||
throw new \moodle_exception('cannotdeleterolewithid', 'error', $baseurl, $roleid);
|
||||
}
|
||||
// Deleted a role sitewide...
|
||||
redirect($baseurl);
|
||||
@ -108,10 +108,10 @@ switch ($action) {
|
||||
}
|
||||
}
|
||||
if (is_null($thisrole) || is_null($prevrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
throw new \moodle_exception('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
if (!switch_roles($thisrole, $prevrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
throw new \moodle_exception('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,10 +131,10 @@ switch ($action) {
|
||||
}
|
||||
}
|
||||
if (is_null($nextrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
throw new \moodle_exception('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
if (!switch_roles($thisrole, $nextrole)) {
|
||||
print_error('cannotmoverolewithid', 'error', '', $roleid);
|
||||
throw new \moodle_exception('cannotmoverolewithid', 'error', '', $roleid);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ $PAGE->set_title($title);
|
||||
$PAGE->navbar->add($straction);
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_SYSTEM:
|
||||
print_error('cannotoverridebaserole', 'error');
|
||||
throw new \moodle_exception('cannotoverridebaserole', 'error');
|
||||
break;
|
||||
case CONTEXT_USER:
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
|
||||
@ -124,7 +124,7 @@ if (empty($overridableroles[$roleid])) {
|
||||
$a = new stdClass;
|
||||
$a->roleid = $roleid;
|
||||
$a->context = $contextname;
|
||||
print_error('cannotoverriderolehere', '', $context->get_url(), $a);
|
||||
throw new \moodle_exception('cannotoverriderolehere', '', $context->get_url(), $a);
|
||||
}
|
||||
|
||||
// If we are actually overriding a role, create the table object, and save changes if appropriate.
|
||||
|
@ -100,7 +100,7 @@ $PAGE->set_title($title);
|
||||
$PAGE->activityheader->disable();
|
||||
switch ($context->contextlevel) {
|
||||
case CONTEXT_SYSTEM:
|
||||
print_error('cannotoverridebaserole', 'error');
|
||||
throw new \moodle_exception('cannotoverridebaserole', 'error');
|
||||
break;
|
||||
case CONTEXT_USER:
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', $context));
|
||||
|
@ -55,7 +55,7 @@ if ($course->id == SITEID) {
|
||||
$canview = has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
|
||||
'moodle/role:override', 'moodle/role:manage'), $usercontext);
|
||||
if (!$canview) {
|
||||
print_error('nopermissions', 'error', '', get_string('checkpermissions', 'core_role'));
|
||||
throw new \moodle_exception('nopermissions', 'error', '', get_string('checkpermissions', 'core_role'));
|
||||
}
|
||||
|
||||
if ($userid != $USER->id) {
|
||||
|
@ -23,13 +23,13 @@ if (empty($settingspage) or !($settingspage instanceof admin_settingpage)) {
|
||||
if (moodle_needs_upgrading()) {
|
||||
redirect(new moodle_url('/admin/index.php'));
|
||||
} else {
|
||||
print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
|
||||
throw new \moodle_exception('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
|
||||
}
|
||||
die;
|
||||
}
|
||||
|
||||
if (!($settingspage->check_access())) {
|
||||
print_error('accessdenied', 'admin');
|
||||
throw new \moodle_exception('accessdenied', 'admin');
|
||||
die;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ $pageurl = new moodle_url('/' . $CFG->admin . '/tool/availabilityconditions/');
|
||||
if (($plugin = optional_param('plugin', '', PARAM_PLUGIN))) {
|
||||
require_sesskey();
|
||||
if (!array_key_exists($plugin, $plugins)) {
|
||||
print_error('invalidcomponent', 'error', $pageurl);
|
||||
throw new \moodle_exception('invalidcomponent', 'error', $pageurl);
|
||||
}
|
||||
$action = required_param('action', PARAM_ALPHA);
|
||||
switch ($action) {
|
||||
|
@ -44,7 +44,7 @@ class export extends \moodleform {
|
||||
|
||||
// The export button only appears if a local lang is present.
|
||||
if (!check_dir_exists($langdir) || !count(glob("$langdir/*"))) {
|
||||
print_error('nolocallang', 'tool_customlang');
|
||||
throw new \moodle_exception('nolocallang', 'tool_customlang');
|
||||
}
|
||||
|
||||
$langfiles = scandir($langdir);
|
||||
|
@ -46,7 +46,7 @@ $PAGE->navbar->add(get_string('editlangpack', 'tool_customlang'), $PAGE->url);
|
||||
|
||||
if (empty($lng)) {
|
||||
// PARAM_LANG validation failed
|
||||
print_error('missingparameter');
|
||||
throw new \moodle_exception('missingparameter');
|
||||
}
|
||||
|
||||
// pre-output processing
|
||||
|
@ -47,7 +47,7 @@ if ($action === 'checkout') {
|
||||
require_sesskey();
|
||||
require_capability('tool/customlang:edit', context_system::instance());
|
||||
if (empty($lng)) {
|
||||
print_error('missingparameter');
|
||||
throw new \moodle_exception('missingparameter');
|
||||
}
|
||||
|
||||
$PAGE->set_cacheable(false); // progress bar is used here
|
||||
@ -70,7 +70,7 @@ if ($action === 'checkin') {
|
||||
require_sesskey();
|
||||
require_capability('tool/customlang:edit', context_system::instance());
|
||||
if (empty($lng)) {
|
||||
print_error('missingparameter');
|
||||
throw new \moodle_exception('missingparameter');
|
||||
}
|
||||
|
||||
if (!$confirm) {
|
||||
|
@ -53,7 +53,7 @@ class page_helper {
|
||||
|
||||
require_login();
|
||||
if (isguestuser()) {
|
||||
print_error('noguest');
|
||||
throw new \moodle_exception('noguest');
|
||||
}
|
||||
|
||||
// TODO Check that data privacy is enabled.
|
||||
|
@ -35,7 +35,7 @@ $PAGE->set_url($url);
|
||||
|
||||
require_login();
|
||||
if (isguestuser()) {
|
||||
print_error('noguest');
|
||||
throw new \moodle_exception('noguest');
|
||||
}
|
||||
|
||||
// Return URL and context.
|
||||
|
@ -36,7 +36,7 @@ $PAGE->set_url($url);
|
||||
|
||||
require_login();
|
||||
if (isguestuser()) {
|
||||
print_error('noguest');
|
||||
throw new \moodle_exception('noguest');
|
||||
}
|
||||
|
||||
$usercontext = context_user::instance($USER->id);
|
||||
|
@ -186,7 +186,7 @@ class tool_generator_testplan_backend extends tool_generator_backend {
|
||||
$planusers = self::$users[$size] ?? 0;
|
||||
$users = get_enrolled_users($coursecontext, '', 0, 'u.id, u.username, u.auth', 'u.username ASC', 0, $planusers);
|
||||
if (!$users) {
|
||||
print_error('coursewithoutusers', 'tool_generator');
|
||||
throw new \moodle_exception('coursewithoutusers', 'tool_generator');
|
||||
}
|
||||
|
||||
$lines = array();
|
||||
@ -196,7 +196,7 @@ class tool_generator_testplan_backend extends tool_generator_backend {
|
||||
if ($updateuserspassword) {
|
||||
$userauth = get_auth_plugin($user->auth);
|
||||
if (!$userauth->user_update_password($user, $CFG->tool_generator_users_password)) {
|
||||
print_error('errorpasswordupdate', 'auth');
|
||||
throw new \moodle_exception('errorpasswordupdate', 'auth');
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,19 +249,19 @@ class tool_generator_testplan_backend extends tool_generator_backend {
|
||||
|
||||
// Getting the first page module instance.
|
||||
if (!$pages = $courseinfo->get_instances_of('page')) {
|
||||
print_error('error_nopageinstances', 'tool_generator');
|
||||
throw new \moodle_exception('error_nopageinstances', 'tool_generator');
|
||||
}
|
||||
$data->pageid = reset($pages)->id;
|
||||
|
||||
// Getting the first forum module instance and it's first discussion and reply as well.
|
||||
if (!$forums = $courseinfo->get_instances_of('forum')) {
|
||||
print_error('error_noforuminstances', 'tool_generator');
|
||||
throw new \moodle_exception('error_noforuminstances', 'tool_generator');
|
||||
}
|
||||
$forum = reset($forums);
|
||||
|
||||
// Getting the first discussion (and reply).
|
||||
if (!$discussions = forum_get_discussions($forum, 'd.timemodified ASC', false, -1, 1)) {
|
||||
print_error('error_noforumdiscussions', 'tool_generator');
|
||||
throw new \moodle_exception('error_noforumdiscussions', 'tool_generator');
|
||||
}
|
||||
$discussion = reset($discussions);
|
||||
|
||||
|
@ -152,14 +152,14 @@ class manager {
|
||||
if ($action == self::ACTION_CREATE) {
|
||||
// Check that license shortname isn't already in use.
|
||||
if (!empty(license_manager::get_license_by_shortname($data->shortname))) {
|
||||
print_error('duplicatelicenseshortname', 'tool_licensemanager',
|
||||
throw new \moodle_exception('duplicatelicenseshortname', 'tool_licensemanager',
|
||||
helper::get_licensemanager_url(),
|
||||
$data->shortname);
|
||||
}
|
||||
$license->shortname = $data->shortname;
|
||||
} else {
|
||||
if (empty(license_manager::get_license_by_shortname($licenseshortname))) {
|
||||
print_error('licensenotfoundshortname', 'license',
|
||||
throw new \moodle_exception('licensenotfoundshortname', 'license',
|
||||
helper::get_licensemanager_url(),
|
||||
$licenseshortname);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ require_once($CFG->dirroot . '/admin/tool/mobile/lib.php');
|
||||
require_once($CFG->dirroot . '/webservice/lib.php');
|
||||
|
||||
if (!$CFG->enablemobilewebservice) {
|
||||
print_error('enablewsdescription', 'webservice');
|
||||
throw new \moodle_exception('enablewsdescription', 'webservice');
|
||||
}
|
||||
|
||||
require_login(null, false);
|
||||
|
@ -30,11 +30,11 @@ admin_externalpage_setup('mobileappsubscription', '', null, '');
|
||||
|
||||
// Check Mobile web services enabled. This page should not be linked in that case, but avoid just in case.
|
||||
if (!$CFG->enablemobilewebservice) {
|
||||
print_error('enablewsdescription', 'webservice');
|
||||
throw new \moodle_exception('enablewsdescription', 'webservice');
|
||||
}
|
||||
// Check is this feature is globaly disabled.
|
||||
if (!empty($CFG->disablemobileappsubscription)) {
|
||||
print_error('disabled', 'admin');
|
||||
throw new \moodle_exception('disabled', 'admin');
|
||||
}
|
||||
|
||||
$subscriptiondata = \tool_mobile\api::get_subscription_information();
|
||||
|
@ -46,7 +46,7 @@ if (empty($courseid)) {
|
||||
$choose = true;
|
||||
} else {
|
||||
// return error.
|
||||
print_error('rulenopermission', 'tool_monitor');
|
||||
throw new \moodle_exception('rulenopermission', 'tool_monitor');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -38,7 +38,7 @@ require_once(__DIR__ . '/../../../config.php');
|
||||
|
||||
// The integration must be enabled for this import endpoint to be active.
|
||||
if (!get_config('tool_moodlenet', 'enablemoodlenet')) {
|
||||
print_error('moodlenetnotenabled', 'tool_moodlenet');
|
||||
throw new \moodle_exception('moodlenetnotenabled', 'tool_moodlenet');
|
||||
}
|
||||
|
||||
$resourceurl = required_param('resourceurl', PARAM_URL);
|
||||
@ -82,4 +82,4 @@ if (!empty($_POST)) {
|
||||
}
|
||||
|
||||
// Invalid or missing POST data. Show an error to the user.
|
||||
print_error('missinginvalidpostdata', 'tool_moodlenet');
|
||||
throw new \moodle_exception('missinginvalidpostdata', 'tool_moodlenet');
|
||||
|
@ -44,7 +44,7 @@ if ($importinfo->get_config()->course) {
|
||||
require_capability('moodle/course:manageactivities', context_course::instance($importinfo->get_config()->course));
|
||||
}
|
||||
if (!get_config('tool_moodlenet', 'enablemoodlenet')) {
|
||||
print_error('moodlenetnotenabled', 'tool_moodlenet');
|
||||
throw new \moodle_exception('moodlenetnotenabled', 'tool_moodlenet');
|
||||
}
|
||||
|
||||
// Handle the form submits.
|
||||
@ -73,7 +73,7 @@ if ($cancel) {
|
||||
$context = import_backup_helper::get_context_for_user($USER->id);
|
||||
|
||||
if (is_null($context)) {
|
||||
print_error('nopermissions', 'error', '', get_string('restore:uploadfile', 'core_role'));
|
||||
throw new \moodle_exception('nopermissions', 'error', '', get_string('restore:uploadfile', 'core_role'));
|
||||
}
|
||||
} else {
|
||||
$context = context_course::instance($importinfo->get_config()->course);
|
||||
|
@ -59,7 +59,7 @@ if (!isset($config->course)) {
|
||||
require_login($config->course, false);
|
||||
require_capability('moodle/course:manageactivities', context_course::instance($config->course));
|
||||
if (!get_config('tool_moodlenet', 'enablemoodlenet')) {
|
||||
print_error('moodlenetnotenabled', 'tool_moodlenet');
|
||||
throw new \moodle_exception('moodlenetnotenabled', 'tool_moodlenet');
|
||||
}
|
||||
|
||||
// If the user cancelled, break early.
|
||||
|
@ -31,7 +31,7 @@ $id = required_param('id', PARAM_ALPHANUM);
|
||||
// Access control.
|
||||
require_login();
|
||||
if (!get_config('tool_moodlenet', 'enablemoodlenet')) {
|
||||
print_error('moodlenetnotenabled', 'tool_moodlenet');
|
||||
throw new \moodle_exception('moodlenetnotenabled', 'tool_moodlenet');
|
||||
}
|
||||
|
||||
if (is_null($importinfo = import_info::load($id))) {
|
||||
|
@ -52,7 +52,7 @@ if (!$go or !data_submitted() or !confirm_sesskey()) { /// Print a form
|
||||
|
||||
|
||||
if (!$tables = $DB->get_tables() ) { // No tables yet at all.
|
||||
print_error('notables', 'debug');
|
||||
throw new \moodle_exception('notables', 'debug');
|
||||
}
|
||||
|
||||
echo $OUTPUT->box_start();
|
||||
|
@ -45,7 +45,7 @@ $mform = null;
|
||||
|
||||
$issuer = \core\oauth2\api::get_issuer($issuerid);
|
||||
if (!$issuer) {
|
||||
print_error('invaliddata');
|
||||
throw new \moodle_exception('invaliddata');
|
||||
}
|
||||
$PAGE->navbar->override_active_url(new moodle_url('/admin/tool/oauth2/issuers.php'), true);
|
||||
|
||||
|
@ -45,7 +45,7 @@ $mform = null;
|
||||
if ($issuerid) {
|
||||
$issuer = \core\oauth2\api::get_issuer($issuerid);
|
||||
if (!$issuer) {
|
||||
print_error('invaliddata');
|
||||
throw new \moodle_exception('invaliddata');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ $mform = null;
|
||||
|
||||
$issuer = \core\oauth2\api::get_issuer($issuerid);
|
||||
if (!$issuer) {
|
||||
print_error('invaliddata');
|
||||
throw new \moodle_exception('invaliddata');
|
||||
}
|
||||
$PAGE->navbar->override_active_url(new moodle_url('/admin/tool/oauth2/issuers.php'), true);
|
||||
|
||||
|
@ -32,7 +32,7 @@ $action = optional_param('action', null, PARAM_ALPHA);
|
||||
|
||||
require_login();
|
||||
if (isguestuser()) {
|
||||
print_error('noguest');
|
||||
throw new \moodle_exception('noguest');
|
||||
}
|
||||
$context = context_system::instance();
|
||||
|
||||
|
@ -31,7 +31,7 @@ $returnurl = optional_param('returnurl', null, PARAM_LOCALURL);
|
||||
require_login();
|
||||
$userid = $userid ?: $USER->id;
|
||||
if (isguestuser() || isguestuser($userid)) {
|
||||
print_error('noguest');
|
||||
throw new \moodle_exception('noguest');
|
||||
}
|
||||
$context = context_user::instance($userid);
|
||||
if ($userid != $USER->id) {
|
||||
|
@ -70,12 +70,12 @@ switch ($context->contextlevel) {
|
||||
break;
|
||||
|
||||
default:
|
||||
print_error('invalidcontext', 'tool_recyclebin');
|
||||
throw new \moodle_exception('invalidcontext', 'tool_recyclebin');
|
||||
break;
|
||||
}
|
||||
|
||||
if (!$recyclebin::is_enabled()) {
|
||||
print_error('notenabled', 'tool_recyclebin');
|
||||
throw new \moodle_exception('notenabled', 'tool_recyclebin');
|
||||
}
|
||||
|
||||
$PAGE->set_url('/admin/tool/recyclebin/index.php', array(
|
||||
@ -101,7 +101,7 @@ if (!empty($action)) {
|
||||
$recyclebin->restore_item($item);
|
||||
redirect($PAGE->url, get_string('alertrestored', 'tool_recyclebin', $item), 2);
|
||||
} else {
|
||||
print_error('nopermissions', 'error');
|
||||
throw new \moodle_exception('nopermissions', 'error');
|
||||
}
|
||||
break;
|
||||
|
||||
@ -111,7 +111,7 @@ if (!empty($action)) {
|
||||
$recyclebin->delete_item($item);
|
||||
redirect($PAGE->url, get_string('alertdeleted', 'tool_recyclebin', $item), 2);
|
||||
} else {
|
||||
print_error('nopermissions', 'error');
|
||||
throw new \moodle_exception('nopermissions', 'error');
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -36,7 +36,7 @@ $context = context_system::instance();
|
||||
$taskname = required_param('task', PARAM_RAW_TRIMMED);
|
||||
$task = \core\task\manager::get_scheduled_task($taskname);
|
||||
if (!$task) {
|
||||
print_error('cannotfindinfo', 'error', $taskname);
|
||||
throw new \moodle_exception('cannotfindinfo', 'error', $taskname);
|
||||
}
|
||||
|
||||
$returnurl = new moodle_url('/admin/tool/task/scheduledtasks.php',
|
||||
|
@ -38,7 +38,7 @@ $mform = null;
|
||||
if ($taskname) {
|
||||
$task = \core\task\manager::get_scheduled_task($taskname);
|
||||
if (!$task) {
|
||||
print_error('invaliddata');
|
||||
throw new \moodle_exception('invaliddata');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,9 +193,9 @@ $cir = new csv_import_reader($importid, 'uploadcourse');
|
||||
$readcount = $cir->load_csv_content($content, $options['encoding'], $options['delimiter']);
|
||||
unset($content);
|
||||
if ($readcount === false) {
|
||||
print_error('csvfileerror', 'tool_uploadcourse', '', $cir->get_error());
|
||||
throw new \moodle_exception('csvfileerror', 'tool_uploadcourse', '', $cir->get_error());
|
||||
} else if ($readcount == 0) {
|
||||
print_error('csvemptyfile', 'error', '', $cir->get_error());
|
||||
throw new \moodle_exception('csvemptyfile', 'error', '', $cir->get_error());
|
||||
}
|
||||
$processor = new tool_uploadcourse_processor($cir, $processoroptions, $defaults);
|
||||
$processor->execute(new tool_uploadcourse_tracker(tool_uploadcourse_tracker::OUTPUT_PLAIN));
|
||||
|
@ -42,9 +42,9 @@ if (empty($importid)) {
|
||||
$readcount = $cir->load_csv_content($content, $form1data->encoding, $form1data->delimiter_name);
|
||||
unset($content);
|
||||
if ($readcount === false) {
|
||||
print_error('csvfileerror', 'tool_uploadcourse', $returnurl, $cir->get_error());
|
||||
throw new \moodle_exception('csvfileerror', 'tool_uploadcourse', $returnurl, $cir->get_error());
|
||||
} else if ($readcount == 0) {
|
||||
print_error('csvemptyfile', 'error', $returnurl, $cir->get_error());
|
||||
throw new \moodle_exception('csvemptyfile', 'error', $returnurl, $cir->get_error());
|
||||
}
|
||||
} else {
|
||||
echo $OUTPUT->header();
|
||||
|
@ -54,7 +54,7 @@ if (empty($iid)) {
|
||||
unset($content);
|
||||
|
||||
if (!is_null($csvloaderror)) {
|
||||
print_error('csvloaderror', '', $returnurl, $csvloaderror);
|
||||
throw new \moodle_exception('csvloaderror', '', $returnurl, $csvloaderror);
|
||||
}
|
||||
// Continue to form2.
|
||||
|
||||
|
@ -192,12 +192,12 @@ function uu_validate_user_upload_columns(csv_import_reader $cir, $stdfields, $pr
|
||||
if (empty($columns)) {
|
||||
$cir->close();
|
||||
$cir->cleanup();
|
||||
print_error('cannotreadtmpfile', 'error', $returnurl);
|
||||
throw new \moodle_exception('cannotreadtmpfile', 'error', $returnurl);
|
||||
}
|
||||
if (count($columns) < 2) {
|
||||
$cir->close();
|
||||
$cir->cleanup();
|
||||
print_error('csvfewcolumns', 'error', $returnurl);
|
||||
throw new \moodle_exception('csvfewcolumns', 'error', $returnurl);
|
||||
}
|
||||
|
||||
// test columns
|
||||
@ -240,12 +240,12 @@ function uu_validate_user_upload_columns(csv_import_reader $cir, $stdfields, $pr
|
||||
} else {
|
||||
$cir->close();
|
||||
$cir->cleanup();
|
||||
print_error('invalidfieldname', 'error', $returnurl, $field);
|
||||
throw new \moodle_exception('invalidfieldname', 'error', $returnurl, $field);
|
||||
}
|
||||
if (in_array($newfield, $processed)) {
|
||||
$cir->close();
|
||||
$cir->cleanup();
|
||||
print_error('duplicatefieldname', 'error', $returnurl, $newfield);
|
||||
throw new \moodle_exception('duplicatefieldname', 'error', $returnurl, $newfield);
|
||||
}
|
||||
$processed[$key] = $newfield;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ require_capability('tool/uploaduser:uploaduserpictures', context_system::instanc
|
||||
$site = get_site();
|
||||
|
||||
if (!$adminuser = get_admin()) {
|
||||
print_error('noadmins', 'error');
|
||||
throw new \moodle_exception('noadmins', 'error');
|
||||
}
|
||||
|
||||
$strfile = get_string('file');
|
||||
|
@ -76,7 +76,7 @@ class edit_field_save extends XMLDBAction {
|
||||
// Do the job, setting result as needed
|
||||
|
||||
if (!data_submitted()) { // Basic prevention
|
||||
print_error('wrongcall', 'error');
|
||||
throw new \moodle_exception('wrongcall', 'error');
|
||||
}
|
||||
|
||||
// Get parameters
|
||||
|
@ -73,7 +73,7 @@ class edit_index_save extends XMLDBAction {
|
||||
// Do the job, setting result as needed
|
||||
|
||||
if (!data_submitted()) { // Basic prevention
|
||||
print_error('wrongcall', 'error');
|
||||
throw new \moodle_exception('wrongcall', 'error');
|
||||
}
|
||||
|
||||
// Get parameters
|
||||
|
@ -79,7 +79,7 @@ class edit_key_save extends XMLDBAction {
|
||||
// Do the job, setting result as needed
|
||||
|
||||
if (!data_submitted()) { // Basic prevention
|
||||
print_error('wrongcall', 'error');
|
||||
throw new \moodle_exception('wrongcall', 'error');
|
||||
}
|
||||
|
||||
// Get parameters
|
||||
|
@ -67,7 +67,7 @@ class edit_table_save extends XMLDBAction {
|
||||
// Do the job, setting result as needed
|
||||
|
||||
if (!data_submitted()) { // Basic prevention
|
||||
print_error('wrongcall', 'error');
|
||||
throw new \moodle_exception('wrongcall', 'error');
|
||||
}
|
||||
|
||||
// Get parameters
|
||||
|
@ -63,7 +63,7 @@ class edit_xml_file_save extends XMLDBAction {
|
||||
// Do the job, setting result as needed
|
||||
|
||||
if (!data_submitted()) { // Basic prevention
|
||||
print_error('wrongcall', 'error');
|
||||
throw new \moodle_exception('wrongcall', 'error');
|
||||
}
|
||||
|
||||
// Get parameters
|
||||
|
@ -104,16 +104,16 @@ if (file_exists($actionpath) && is_readable($actionpath)) {
|
||||
}
|
||||
} else {
|
||||
// TODO: need more detailed error info
|
||||
print_error('xmldberror');
|
||||
throw new \moodle_exception('xmldberror');
|
||||
}
|
||||
} else {
|
||||
$a = new stdClass();
|
||||
$a->action = $action;
|
||||
$a->actionclass = $actionclass;
|
||||
print_error('cannotinstantiateclass', 'tool_xmldb', '', $a);
|
||||
throw new \moodle_exception('cannotinstantiateclass', 'tool_xmldb', '', $a);
|
||||
}
|
||||
} else {
|
||||
print_error('invalidaction');
|
||||
throw new \moodle_exception('invalidaction');
|
||||
}
|
||||
|
||||
if ($xmldb_action->getDoesGenerate() != ACTION_GENERATE_XML) {
|
||||
|
@ -27,7 +27,7 @@
|
||||
$site = get_site();
|
||||
|
||||
if (!has_capability('moodle/user:update', $sitecontext) and !has_capability('moodle/user:delete', $sitecontext)) {
|
||||
print_error('nopermissions', 'error', '', 'edit/delete users');
|
||||
throw new \moodle_exception('nopermissions', 'error', '', 'edit/delete users');
|
||||
}
|
||||
|
||||
$stredit = get_string('edit');
|
||||
@ -50,7 +50,7 @@
|
||||
if ($confirmuser and confirm_sesskey()) {
|
||||
require_capability('moodle/user:update', $sitecontext);
|
||||
if (!$user = $DB->get_record('user', array('id'=>$confirmuser, 'mnethostid'=>$CFG->mnet_localhost_id))) {
|
||||
print_error('nousers');
|
||||
throw new \moodle_exception('nousers');
|
||||
}
|
||||
|
||||
$auth = get_auth_plugin($user->auth);
|
||||
@ -66,12 +66,12 @@
|
||||
|
||||
} else if ($resendemail && confirm_sesskey()) {
|
||||
if (!$user = $DB->get_record('user', ['id' => $resendemail, 'mnethostid' => $CFG->mnet_localhost_id, 'deleted' => 0])) {
|
||||
print_error('nousers');
|
||||
throw new \moodle_exception('nousers');
|
||||
}
|
||||
|
||||
// Prevent spamming users who are already confirmed.
|
||||
if ($user->confirmed) {
|
||||
print_error('alreadyconfirmed');
|
||||
throw new \moodle_exception('alreadyconfirmed', 'moodle');
|
||||
}
|
||||
|
||||
$returnmsg = get_string('emailconfirmsentsuccess');
|
||||
@ -88,10 +88,10 @@
|
||||
$user = $DB->get_record('user', array('id'=>$delete, 'mnethostid'=>$CFG->mnet_localhost_id), '*', MUST_EXIST);
|
||||
|
||||
if ($user->deleted) {
|
||||
print_error('usernotdeleteddeleted', 'error');
|
||||
throw new \moodle_exception('usernotdeleteddeleted', 'error');
|
||||
}
|
||||
if (is_siteadmin($user->id)) {
|
||||
print_error('useradminodelete', 'error');
|
||||
throw new \moodle_exception('useradminodelete', 'error');
|
||||
}
|
||||
|
||||
if ($confirm != md5($delete)) {
|
||||
@ -118,17 +118,17 @@
|
||||
}
|
||||
} else if ($acl and confirm_sesskey()) {
|
||||
if (!has_capability('moodle/user:update', $sitecontext)) {
|
||||
print_error('nopermissions', 'error', '', 'modify the NMET access control list');
|
||||
throw new \moodle_exception('nopermissions', 'error', '', 'modify the NMET access control list');
|
||||
}
|
||||
if (!$user = $DB->get_record('user', array('id'=>$acl))) {
|
||||
print_error('nousers', 'error');
|
||||
throw new \moodle_exception('nousers', 'error');
|
||||
}
|
||||
if (!is_mnet_remote_user($user)) {
|
||||
print_error('usermustbemnet', 'error');
|
||||
throw new \moodle_exception('usermustbemnet', 'error');
|
||||
}
|
||||
$accessctrl = strtolower(required_param('accessctrl', PARAM_ALPHA));
|
||||
if ($accessctrl != 'allow' and $accessctrl != 'deny') {
|
||||
print_error('invalidaccessparameter', 'error');
|
||||
throw new \moodle_exception('invalidaccessparameter', 'error');
|
||||
}
|
||||
$aclrecord = $DB->get_record('mnet_sso_access_control', array('username'=>$user->username, 'mnet_host_id'=>$user->mnethostid));
|
||||
if (empty($aclrecord)) {
|
||||
|
@ -17,7 +17,7 @@ if (empty($SESSION->bulk_users)) {
|
||||
}
|
||||
|
||||
if (empty($CFG->messaging)) {
|
||||
print_error('messagingdisable', 'error');
|
||||
throw new \moodle_exception('messagingdisable', 'error');
|
||||
}
|
||||
|
||||
$PAGE->set_primary_active_tab('siteadminnode');
|
||||
|
@ -80,7 +80,7 @@ class model_config {
|
||||
$exporttmpdir = make_request_directory();
|
||||
$jsonfilepath = $exporttmpdir . DIRECTORY_SEPARATOR . 'model-config.json';
|
||||
if (!file_put_contents($jsonfilepath, json_encode($modeldata))) {
|
||||
print_error('errornoexportconfig', 'analytics');
|
||||
throw new \moodle_exception('errornoexportconfig', 'analytics');
|
||||
}
|
||||
$zipfiles[self::CONFIG_FILE_NAME] = $jsonfilepath;
|
||||
|
||||
|
@ -502,7 +502,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
WHERE {$this->config->fielduser} = '".$this->ext_addslashes($extusername)."' ");
|
||||
|
||||
if (!$rs) {
|
||||
print_error('auth_dbcantconnect','auth_db');
|
||||
throw new \moodle_exception('auth_dbcantconnect', 'auth_db');
|
||||
} else if (!$rs->EOF) {
|
||||
// User exists externally.
|
||||
$result = true;
|
||||
@ -525,7 +525,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
FROM {$this->config->table} ");
|
||||
|
||||
if (!$rs) {
|
||||
print_error('auth_dbcantconnect','auth_db');
|
||||
throw new \moodle_exception('auth_dbcantconnect', 'auth_db');
|
||||
} else if (!$rs->EOF) {
|
||||
while ($rec = $rs->FetchRow()) {
|
||||
$rec = array_change_key_case((array)$rec, CASE_LOWER);
|
||||
@ -607,7 +607,7 @@ class auth_plugin_db extends auth_plugin_base {
|
||||
SET ".implode(',', $update)."
|
||||
WHERE {$this->config->fielduser} = ?";
|
||||
if (!$authdb->Execute($sql, array($this->ext_addslashes($extusername)))) {
|
||||
print_error('auth_dbupdateerror', 'auth_db');
|
||||
throw new \moodle_exception('auth_dbupdateerror', 'auth_db');
|
||||
}
|
||||
}
|
||||
$authdb->Close();
|
||||
|
@ -139,7 +139,7 @@ class auth_plugin_email extends auth_plugin_base {
|
||||
\core\event\user_created::create_from_userid($user->id)->trigger();
|
||||
|
||||
if (! send_confirmation_email($user, $confirmationurl)) {
|
||||
print_error('auth_emailnoemail', 'auth_email');
|
||||
throw new \moodle_exception('auth_emailnoemail', 'auth_email');
|
||||
}
|
||||
|
||||
if ($notify) {
|
||||
|
@ -148,7 +148,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
*/
|
||||
function user_login($username, $password) {
|
||||
if (! function_exists('ldap_bind')) {
|
||||
print_error('auth_ldapnotinstalled', 'auth_ldap');
|
||||
throw new \moodle_exception('auth_ldapnotinstalled', 'auth_ldap');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -450,12 +450,12 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
// strings (UCS-2 Little Endian format) and surrounded with
|
||||
// double quotes. See http://support.microsoft.com/?kbid=269190
|
||||
if (!function_exists('mb_convert_encoding')) {
|
||||
print_error('auth_ldap_no_mbstring', 'auth_ldap');
|
||||
throw new \moodle_exception('auth_ldap_no_mbstring', 'auth_ldap');
|
||||
}
|
||||
|
||||
// Check for invalid sAMAccountName characters.
|
||||
if (preg_match('#[/\\[\]:;|=,+*?<>@"]#', $extusername)) {
|
||||
print_error ('auth_ldap_ad_invalidchars', 'auth_ldap');
|
||||
throw new \moodle_exception ('auth_ldap_ad_invalidchars', 'auth_ldap');
|
||||
}
|
||||
|
||||
// First create the user account, and mark it as disabled.
|
||||
@ -465,7 +465,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
AUTH_AD_ACCOUNTDISABLE;
|
||||
$userdn = 'cn='.ldap_addslashes($extusername).','.$this->config->create_context;
|
||||
if (!ldap_add($ldapconnection, $userdn, $newuser)) {
|
||||
print_error('auth_ldap_ad_create_req', 'auth_ldap');
|
||||
throw new \moodle_exception('auth_ldap_ad_create_req', 'auth_ldap');
|
||||
}
|
||||
|
||||
// Now set the password
|
||||
@ -475,12 +475,12 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
if(!ldap_modify($ldapconnection, $userdn, $newuser)) {
|
||||
// Something went wrong: delete the user account and error out
|
||||
ldap_delete ($ldapconnection, $userdn);
|
||||
print_error('auth_ldap_ad_create_req', 'auth_ldap');
|
||||
throw new \moodle_exception('auth_ldap_ad_create_req', 'auth_ldap');
|
||||
}
|
||||
$uadd = true;
|
||||
break;
|
||||
default:
|
||||
print_error('auth_ldap_unsupportedusertype', 'auth_ldap', '', $this->config->user_type_name);
|
||||
throw new \moodle_exception('auth_ldap_unsupportedusertype', 'auth_ldap', '', $this->config->user_type_name);
|
||||
}
|
||||
$this->ldap_close();
|
||||
return $uadd;
|
||||
@ -528,14 +528,14 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
require_once($CFG->dirroot.'/user/lib.php');
|
||||
|
||||
if ($this->user_exists($user->username)) {
|
||||
print_error('auth_ldap_user_exists', 'auth_ldap');
|
||||
throw new \moodle_exception('auth_ldap_user_exists', 'auth_ldap');
|
||||
}
|
||||
|
||||
$plainslashedpassword = $user->password;
|
||||
unset($user->password);
|
||||
|
||||
if (! $this->user_create($user, $plainslashedpassword)) {
|
||||
print_error('auth_ldap_create_error', 'auth_ldap');
|
||||
throw new \moodle_exception('auth_ldap_create_error', 'auth_ldap');
|
||||
}
|
||||
|
||||
$user->id = user_create_user($user, false, false);
|
||||
@ -558,7 +558,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
\core\event\user_created::create_from_userid($user->id)->trigger();
|
||||
|
||||
if (! send_confirmation_email($user)) {
|
||||
print_error('noemail', 'auth_ldap');
|
||||
throw new \moodle_exception('noemail', 'auth_ldap');
|
||||
}
|
||||
|
||||
if ($notify) {
|
||||
@ -1018,7 +1018,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
& (~AUTH_AD_ACCOUNTDISABLE);
|
||||
break;
|
||||
default:
|
||||
print_error('user_activatenotsupportusertype', 'auth_ldap', '', $this->config->user_type_name);
|
||||
throw new \moodle_exception('user_activatenotsupportusertype', 'auth_ldap', '', $this->config->user_type_name);
|
||||
}
|
||||
$result = ldap_modify($ldapconnection, $userdn, $newinfo);
|
||||
$this->ldap_close();
|
||||
@ -1453,7 +1453,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
$result = $this->ldap_get_ad_pwdexpire($time, $ldapconnection, $user_dn);
|
||||
break;
|
||||
default:
|
||||
print_error('auth_ldap_usertypeundefined', 'auth_ldap');
|
||||
throw new \moodle_exception('auth_ldap_usertypeundefined', 'auth_ldap');
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@ -1474,7 +1474,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
$result = $time ; // Already in correct format
|
||||
break;
|
||||
default:
|
||||
print_error('auth_ldap_usertypeundefined2', 'auth_ldap');
|
||||
throw new \moodle_exception('auth_ldap_usertypeundefined2', 'auth_ldap');
|
||||
}
|
||||
return $result;
|
||||
|
||||
@ -1999,7 +1999,7 @@ class auth_plugin_ldap extends auth_plugin_base {
|
||||
return $ldapconnection;
|
||||
}
|
||||
|
||||
print_error('auth_ldap_noconnect_all', 'auth_ldap', '', $debuginfo);
|
||||
throw new \moodle_exception('auth_ldap_noconnect_all', 'auth_ldap', '', $debuginfo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,12 +10,12 @@ $site = get_site();
|
||||
|
||||
$authsequence = get_enabled_auth_plugins(); // Auths, in sequence.
|
||||
if (!in_array('ldap', $authsequence, true)) {
|
||||
print_error('ldap_isdisabled', 'auth');
|
||||
throw new \moodle_exception('ldap_isdisabled', 'auth');
|
||||
}
|
||||
|
||||
$authplugin = get_auth_plugin('ldap');
|
||||
if (empty($authplugin->config->ntlmsso_enabled)) {
|
||||
print_error('ntlmsso_isdisabled', 'auth_ldap');
|
||||
throw new \moodle_exception('ntlmsso_isdisabled', 'auth_ldap');
|
||||
}
|
||||
|
||||
$sesskey = sesskey();
|
||||
|
@ -10,12 +10,12 @@ $site = get_site();
|
||||
|
||||
$authsequence = get_enabled_auth_plugins(); // Auths, in sequence.
|
||||
if (!in_array('ldap', $authsequence, true)) {
|
||||
print_error('ldap_isdisabled', 'auth');
|
||||
throw new \moodle_exception('ldap_isdisabled', 'auth');
|
||||
}
|
||||
|
||||
$authplugin = get_auth_plugin('ldap');
|
||||
if (empty($authplugin->config->ntlmsso_enabled)) {
|
||||
print_error('ntlmsso_isdisabled', 'auth_ldap');
|
||||
throw new \moodle_exception('ntlmsso_isdisabled', 'auth_ldap');
|
||||
}
|
||||
|
||||
// If ntlmsso_finish() succeeds, then the code never returns,
|
||||
|
@ -12,12 +12,12 @@ $PAGE->set_context(context_system::instance());
|
||||
|
||||
$authsequence = get_enabled_auth_plugins(); // Auths, in sequence.
|
||||
if (!in_array('ldap', $authsequence, true)) {
|
||||
print_error('ldap_isdisabled', 'auth');
|
||||
throw new \moodle_exception('ldap_isdisabled', 'auth');
|
||||
}
|
||||
|
||||
$authplugin = get_auth_plugin('ldap');
|
||||
if (empty($authplugin->config->ntlmsso_enabled)) {
|
||||
print_error('ntlmsso_isdisabled', 'auth_ldap');
|
||||
throw new \moodle_exception('ntlmsso_isdisabled', 'auth_ldap');
|
||||
}
|
||||
|
||||
$sesskey = required_param('sesskey', PARAM_RAW);
|
||||
@ -41,7 +41,7 @@ if ($authplugin->ntlmsso_magic($sesskey) && file_exists($file)) {
|
||||
fclose($handle);
|
||||
exit;
|
||||
} else {
|
||||
print_error('ntlmsso_iwamagicnotenabled', 'auth_ldap');
|
||||
throw new \moodle_exception('ntlmsso_iwamagicnotenabled', 'auth_ldap');
|
||||
}
|
||||
|
||||
|
||||
|
@ -61,7 +61,7 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
* @return bool Authentication success or failure.
|
||||
*/
|
||||
function user_login($username, $password) {
|
||||
return false; // print_error("mnetlocal");
|
||||
return false; // Throw moodle_exception("mnetlocal").
|
||||
}
|
||||
|
||||
/**
|
||||
@ -152,7 +152,7 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
|
||||
|
||||
if (\core\session\manager::is_loggedinas()) {
|
||||
print_error('notpermittedtojumpas', 'mnet');
|
||||
throw new \moodle_exception('notpermittedtojumpas', 'mnet');
|
||||
}
|
||||
|
||||
// check remote login permissions
|
||||
@ -160,12 +160,12 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
or is_mnet_remote_user($USER)
|
||||
or isguestuser()
|
||||
or !isloggedin()) {
|
||||
print_error('notpermittedtojump', 'mnet');
|
||||
throw new \moodle_exception('notpermittedtojump', 'mnet');
|
||||
}
|
||||
|
||||
// check for SSO publish permission first
|
||||
if ($this->has_service($mnethostid, 'sso_sp') == false) {
|
||||
print_error('hostnotconfiguredforsso', 'mnet');
|
||||
throw new \moodle_exception('hostnotconfiguredforsso', 'mnet');
|
||||
}
|
||||
|
||||
// set RPC timeout to 30 seconds if not configured
|
||||
@ -230,7 +230,7 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
|
||||
// verify the remote host is configured locally before attempting RPC call
|
||||
if (! $remotehost = $DB->get_record('mnet_host', array('wwwroot' => $remotepeer->wwwroot, 'deleted' => 0))) {
|
||||
print_error('notpermittedtoland', 'mnet');
|
||||
throw new \moodle_exception('notpermittedtoland', 'mnet');
|
||||
}
|
||||
|
||||
// set up the RPC request
|
||||
@ -249,22 +249,23 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
list($code, $message) = array_map('trim',explode(':', $errormessage, 2));
|
||||
if($code == 702) {
|
||||
$site = get_site();
|
||||
print_error('mnet_session_prohibited', 'mnet', $remotepeer->wwwroot, format_string($site->fullname));
|
||||
throw new \moodle_exception('mnet_session_prohibited', 'mnet', $remotepeer->wwwroot,
|
||||
format_string($site->fullname));
|
||||
exit;
|
||||
}
|
||||
$message .= "ERROR $code:<br/>$errormessage<br/>";
|
||||
}
|
||||
print_error("rpcerror", '', '', $message);
|
||||
throw new \moodle_exception("rpcerror", '', '', $message);
|
||||
}
|
||||
unset($mnetrequest);
|
||||
|
||||
if (empty($remoteuser) or empty($remoteuser->username)) {
|
||||
print_error('unknownerror', 'mnet');
|
||||
throw new \moodle_exception('unknownerror', 'mnet');
|
||||
exit;
|
||||
}
|
||||
|
||||
if (user_not_fully_set_up($remoteuser, false)) {
|
||||
print_error('notenoughidpinfo', 'mnet');
|
||||
throw new \moodle_exception('notenoughidpinfo', 'mnet');
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -289,7 +290,7 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
if (empty($localuser) || ! $localuser->id) {
|
||||
/*
|
||||
if (empty($this->config->auto_add_remote_users)) {
|
||||
print_error('nolocaluser', 'mnet');
|
||||
throw new \moodle_exception('nolocaluser', 'mnet');
|
||||
} See MDL-21327 for why this is commented out
|
||||
*/
|
||||
$remoteuser->mnethostid = $remotehost->id;
|
||||
@ -303,7 +304,8 @@ class auth_plugin_mnet extends auth_plugin_base {
|
||||
|
||||
// check sso access control list for permission first
|
||||
if (!$this->can_login_remotely($localuser->username, $remotehost->id)) {
|
||||
print_error('sso_mnet_login_refused', 'mnet', '', array('user'=>$localuser->username, 'host'=>$remotehost->name));
|
||||
throw new \moodle_exception('sso_mnet_login_refused', 'mnet', '',
|
||||
array('user' => $localuser->username, 'host' => $remotehost->name));
|
||||
}
|
||||
|
||||
$fs = get_file_storage();
|
||||
|
@ -43,7 +43,7 @@ if (!isloggedin() or isguestuser()) {
|
||||
}
|
||||
|
||||
if (!is_enabled_auth('mnet')) {
|
||||
print_error('mnetdisable');
|
||||
throw new \moodle_exception('mnetdisable');
|
||||
}
|
||||
|
||||
// If hostid hasn't been specified, try getting it using wwwroot
|
||||
@ -63,7 +63,7 @@ $mnetauth = get_auth_plugin('mnet');
|
||||
$url = $mnetauth->start_jump_session($hostid, $wantsurl);
|
||||
|
||||
if (empty($url)) {
|
||||
print_error('DEBUG: Jump session was not started correctly or blank URL returned.'); // TODO: errors
|
||||
throw new \moodle_exception('DEBUG: Jump session was not started correctly or blank URL returned.'); // TODO: errors.
|
||||
}
|
||||
redirect($url);
|
||||
|
||||
|
@ -40,7 +40,7 @@ $PAGE->set_context(context_system::instance());
|
||||
$site = get_site();
|
||||
|
||||
if (!is_enabled_auth('mnet')) {
|
||||
print_error('mnetdisable');
|
||||
throw new \moodle_exception('mnetdisable');
|
||||
}
|
||||
|
||||
// confirm the MNET session
|
||||
|
@ -58,7 +58,7 @@ if ($confirmed == AUTH_CONFIRM_ALREADY) {
|
||||
// The user has confirmed successfully, let's log them in.
|
||||
|
||||
if (!$user = get_complete_user_data('username', $username)) {
|
||||
print_error('cannotfinduser', '', '', s($username));
|
||||
throw new \moodle_exception('cannotfinduser', '', '', s($username));
|
||||
}
|
||||
|
||||
if (!$user->suspended) {
|
||||
|
@ -45,7 +45,7 @@ if ($confirmed) {
|
||||
// The user has confirmed successfully, let's log them in.
|
||||
|
||||
if (!$user = get_complete_user_data('id', $userid)) {
|
||||
print_error('cannotfinduser', '', '', $userid);
|
||||
throw new \moodle_exception('cannotfinduser', '', '', $userid);
|
||||
}
|
||||
|
||||
if (!$user->suspended) {
|
||||
|
@ -105,7 +105,11 @@ class auth_plugin_shibboleth extends auth_plugin_base {
|
||||
|
||||
// Check whether we have got all the essential attributes
|
||||
if ( empty($_SERVER[$this->config->user_attribute]) ) {
|
||||
print_error( 'shib_not_all_attributes_error', 'auth_shibboleth' , '', "'".$this->config->user_attribute."' ('".$_SERVER[$this->config->user_attribute]."'), '".$this->config->field_map_firstname."' ('".$_SERVER[$this->config->field_map_firstname]."'), '".$this->config->field_map_lastname."' ('".$_SERVER[$this->config->field_map_lastname]."') and '".$this->config->field_map_email."' ('".$_SERVER[$this->config->field_map_email]."')");
|
||||
throw new \moodle_exception( 'shib_not_all_attributes_error', 'auth_shibboleth' , '',
|
||||
"'".$this->config->user_attribute."' ('".$_SERVER[$this->config->user_attribute]."'), '".
|
||||
$this->config->field_map_firstname."' ('".$_SERVER[$this->config->field_map_firstname]."'), '".
|
||||
$this->config->field_map_lastname."' ('".$_SERVER[$this->config->field_map_lastname]."') and '".
|
||||
$this->config->field_map_email."' ('".$_SERVER[$this->config->field_map_email]."')");
|
||||
}
|
||||
|
||||
$attrmap = $this->get_attributes();
|
||||
|
@ -34,7 +34,7 @@
|
||||
// Check whether Shibboleth is configured properly
|
||||
$readmeurl = (new moodle_url('/auth/shibboleth/README.txt'))->out();
|
||||
if (empty($pluginconfig->user_attribute)) {
|
||||
print_error('shib_not_set_up_error', 'auth_shibboleth', '', $readmeurl);
|
||||
throw new \moodle_exception('shib_not_set_up_error', 'auth_shibboleth', '', $readmeurl);
|
||||
}
|
||||
|
||||
/// If we can find the Shibboleth attribute, save it in session and return to main login page
|
||||
@ -88,14 +88,16 @@
|
||||
|
||||
else {
|
||||
// The Shibboleth user couldn't be mapped to a valid Moodle user
|
||||
print_error('shib_invalid_account_error', 'auth_shibboleth');
|
||||
throw new \moodle_exception('shib_invalid_account_error', 'auth_shibboleth');
|
||||
}
|
||||
}
|
||||
|
||||
// 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']) || !empty($_SERVER['Shib-Application-ID'])) {
|
||||
print_error('shib_no_attributes_error', 'auth_shibboleth' , '', '\''.$pluginconfig->user_attribute.'\', \''.$pluginconfig->field_map_firstname.'\', \''.$pluginconfig->field_map_lastname.'\' and \''.$pluginconfig->field_map_email.'\'');
|
||||
throw new \moodle_exception('shib_no_attributes_error', 'auth_shibboleth' , '',
|
||||
'\''.$pluginconfig->user_attribute.'\', \''.$pluginconfig->field_map_firstname.'\', \''.
|
||||
$pluginconfig->field_map_lastname.'\' and \''.$pluginconfig->field_map_email.'\'');
|
||||
} else {
|
||||
print_error('shib_not_set_up_error', 'auth_shibboleth', '', $readmeurl);
|
||||
throw new \moodle_exception('shib_not_set_up_error', 'auth_shibboleth', '', $readmeurl);
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ switch ($type) {
|
||||
$heading = get_string('backupactivity', 'backup', $cm->name);
|
||||
break;
|
||||
default :
|
||||
print_error('unknownbackuptype');
|
||||
throw new \moodle_exception('unknownbackuptype');
|
||||
}
|
||||
|
||||
$PAGE->set_title($heading);
|
||||
|
@ -147,7 +147,7 @@ if ($backup->get_stage() == backup_ui::STAGE_FINAL) {
|
||||
// backups don't store resulting files ever
|
||||
$tempdestination = make_backup_temp_directory($backupid, false);
|
||||
if (!file_exists($tempdestination) || !is_dir($tempdestination)) {
|
||||
print_error('unknownbackupexporterror'); // shouldn't happen ever
|
||||
throw new \moodle_exception('unknownbackupexporterror'); // Shouldn't happen ever.
|
||||
}
|
||||
|
||||
// Prepare the restore controller. We don't need a UI here as we will just use what
|
||||
|
@ -33,7 +33,7 @@ $lang = current_language();
|
||||
|
||||
require_login();
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
$badge = new badge($badgeid);
|
||||
$context = $badge->get_context();
|
||||
@ -42,7 +42,7 @@ require_capability('moodle/badges:configuredetails', $context);
|
||||
|
||||
if ($badge->type == BADGE_TYPE_COURSE) {
|
||||
if (empty($CFG->badges_allowcoursebadges)) {
|
||||
print_error('coursebadgesdisabled', 'badges');
|
||||
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
||||
}
|
||||
require_login($badge->courseid);
|
||||
$course = get_course($badge->courseid);
|
||||
|
@ -31,7 +31,7 @@ require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$hash = required_param('b', PARAM_ALPHANUM); // Issued badge unique hash for badge assertion.
|
||||
|
@ -36,7 +36,7 @@ $revoke = optional_param('revoke', false, PARAM_BOOL);
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$badge = new badge($badgeid);
|
||||
@ -47,7 +47,7 @@ $navurl = new moodle_url('/badges/index.php', array('type' => $badge->type));
|
||||
|
||||
if ($badge->type == BADGE_TYPE_COURSE) {
|
||||
if (empty($CFG->badges_allowcoursebadges)) {
|
||||
print_error('coursebadgesdisabled', 'badges');
|
||||
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
||||
}
|
||||
require_login($badge->courseid);
|
||||
$course = get_course($badge->courseid);
|
||||
|
@ -33,7 +33,7 @@ $update = optional_param('update', 0, PARAM_INT);
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$badge = new badge($badgeid);
|
||||
@ -44,7 +44,7 @@ require_capability('moodle/badges:configurecriteria', $context);
|
||||
|
||||
if ($badge->type == BADGE_TYPE_COURSE) {
|
||||
if (empty($CFG->badges_allowcoursebadges)) {
|
||||
print_error('coursebadgesdisabled', 'badges');
|
||||
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
||||
}
|
||||
require_login($badge->courseid);
|
||||
$course = get_course($badge->courseid);
|
||||
|
@ -158,7 +158,7 @@ abstract class award_criteria {
|
||||
$types = badges_list_criteria(false);
|
||||
|
||||
if (!isset($params['criteriatype']) || !isset($types[$params['criteriatype']])) {
|
||||
print_error('error:invalidcriteriatype', 'badges');
|
||||
throw new \moodle_exception('error:invalidcriteriatype', 'badges');
|
||||
}
|
||||
|
||||
$class = 'award_criteria_' . $types[$params['criteriatype']];
|
||||
|
@ -34,7 +34,7 @@ $action = optional_param('action', 'badge', PARAM_TEXT);
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$badge = new badge($badgeid);
|
||||
@ -49,7 +49,7 @@ if ($action == 'message') {
|
||||
|
||||
if ($badge->type == BADGE_TYPE_COURSE) {
|
||||
if (empty($CFG->badges_allowcoursebadges)) {
|
||||
print_error('coursebadgesdisabled', 'badges');
|
||||
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
||||
}
|
||||
require_login($badge->courseid);
|
||||
$course = get_course($badge->courseid);
|
||||
|
@ -31,7 +31,7 @@ $badgeid = required_param('id', PARAM_INT);
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$badge = new badge($badgeid);
|
||||
@ -41,7 +41,7 @@ require_capability('moodle/badges:configuredetails', $context);
|
||||
|
||||
if ($badge->type == BADGE_TYPE_COURSE) {
|
||||
if (empty($CFG->badges_allowcoursebadges)) {
|
||||
print_error('coursebadgesdisabled', 'badges');
|
||||
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
||||
}
|
||||
require_login($badge->courseid);
|
||||
$course = get_course($badge->courseid);
|
||||
|
@ -28,7 +28,7 @@ require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
global $DB;
|
||||
|
@ -55,7 +55,7 @@ $out = get_backpack_settings($userid);
|
||||
|
||||
// If we didn't find any badges then print an error.
|
||||
if (is_null($out)) {
|
||||
print_error('error:externalbadgedoesntexist', 'badges');
|
||||
throw new \moodle_exception('error:externalbadgedoesntexist', 'badges');
|
||||
}
|
||||
|
||||
$badges = $out->badges;
|
||||
@ -73,7 +73,7 @@ foreach ($badges as $b) {
|
||||
|
||||
// If we didn't find the badge a user might be trying to replace the userid parameter.
|
||||
if (empty($badge)) {
|
||||
print_error('error:externalbadgedoesntexist', 'badges');
|
||||
throw new \moodle_exception('error:externalbadgedoesntexist', 'badges');
|
||||
}
|
||||
|
||||
$output = $PAGE->get_renderer('core', 'badges');
|
||||
|
@ -29,7 +29,7 @@ require_once(__DIR__ . '/../config.php');
|
||||
require_once($CFG->libdir . '/badgeslib.php');
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Unique hash of badge assertion.
|
||||
|
@ -53,11 +53,11 @@ if ($page < 0) {
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
if (empty($CFG->badges_allowcoursebadges) && ($type == BADGE_TYPE_COURSE)) {
|
||||
print_error('coursebadgesdisabled', 'badges');
|
||||
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$err = '';
|
||||
|
@ -30,7 +30,7 @@ require_once($CFG->libdir . '/badgeslib.php');
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$context = context_user::instance($USER->id);
|
||||
@ -145,7 +145,7 @@ if ($backpack) {
|
||||
get_string('backpackemailverifypending', 'badges', $data->backpackemail),
|
||||
null, \core\output\notification::NOTIFY_INFO);
|
||||
} else {
|
||||
print_error ('backpackcannotsendverification', 'badges');
|
||||
throw new \moodle_exception('backpackcannotsendverification', 'badges');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ $show = optional_param('show', 0, PARAM_INT);
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$url = new moodle_url('/badges/mybadges.php');
|
||||
|
@ -33,11 +33,11 @@ $courseid = optional_param('id', 0, PARAM_INT);
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
if (empty($CFG->badges_allowcoursebadges) && ($type == BADGE_TYPE_COURSE)) {
|
||||
print_error('coursebadgesdisabled', 'badges');
|
||||
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$title = get_string('create', 'badges');
|
||||
|
@ -33,7 +33,7 @@ $awards = optional_param('awards', '', PARAM_ALPHANUM);
|
||||
require_login();
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$badge = new badge($badgeid);
|
||||
@ -42,7 +42,7 @@ $navurl = new moodle_url('/badges/index.php', array('type' => $badge->type));
|
||||
|
||||
if ($badge->type == BADGE_TYPE_COURSE) {
|
||||
if (empty($CFG->badges_allowcoursebadges)) {
|
||||
print_error('coursebadgesdisabled', 'badges');
|
||||
throw new \moodle_exception('coursebadgesdisabled', 'badges');
|
||||
}
|
||||
require_login($badge->courseid);
|
||||
$course = get_course($badge->courseid);
|
||||
|
@ -36,7 +36,7 @@ $PAGE->set_url($url);
|
||||
$PAGE->set_pagelayout('standard');
|
||||
|
||||
if (empty($CFG->enablebadges)) {
|
||||
print_error('badgesdisabled', 'badges');
|
||||
throw new \moodle_exception('badgesdisabled', 'badges');
|
||||
}
|
||||
|
||||
$mform = new badges_preferences_form();
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user