diff --git a/auth/oidc/auth.php b/auth/oidc/auth.php index cd65c379a..a1c9281dc 100644 --- a/auth/oidc/auth.php +++ b/auth/oidc/auth.php @@ -192,13 +192,13 @@ public function handleredirect() { * @param bool $justremovetokens If true, just remove the stored OIDC tokens for the user, otherwise revert login methods. * @param bool $donotremovetokens If true, do not remove tokens when disconnecting. This migrates from a login account to a * "linked" account. - * @param moodle_url|null $redirect Where to redirect if successful. - * @param moodle_url|null $selfurl The page this is accessed from. Used for some redirects. + * @param \core\url|null $redirect Where to redirect if successful. + * @param \core\url|null $selfurl The page this is accessed from. Used for some redirects. * @param null $userid * @return mixed */ - public function disconnect($justremovetokens = false, $donotremovetokens = false, ?\moodle_url $redirect = null, - ?\moodle_url $selfurl = null, $userid = null) { + public function disconnect($justremovetokens = false, $donotremovetokens = false, ?\core\url $redirect = null, + ?\core\url $selfurl = null, $userid = null) { return $this->loginflow->disconnect($justremovetokens, $donotremovetokens, $redirect, $selfurl, $userid); } diff --git a/auth/oidc/binding_username_claim.php b/auth/oidc/binding_username_claim.php index dcb2a1da3..30ea8d468 100644 --- a/auth/oidc/binding_username_claim.php +++ b/auth/oidc/binding_username_claim.php @@ -31,7 +31,7 @@ require_login(); -$url = new moodle_url('/auth/oidc/binding_username_claim.php'); +$url = new \core\url('/auth/oidc/binding_username_claim.php'); $PAGE->set_url($url); $PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('admin'); @@ -97,7 +97,7 @@ echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('binding_username_claim_heading', 'auth_oidc')); -$bindingusernametoolurl = new moodle_url('/auth/oidc/change_binding_username_claim_tool.php'); +$bindingusernametoolurl = new \core\url('/auth/oidc/change_binding_username_claim_tool.php'); echo html_writer::tag('p', get_string('binding_username_claim_description', 'auth_oidc', $bindingusernametoolurl->out())); if ($existingclaims) { echo html_writer::tag('p', get_string('binding_username_claim_description_existing_claims', 'auth_oidc', diff --git a/auth/oidc/change_binding_username_claim_tool.php b/auth/oidc/change_binding_username_claim_tool.php index 491f75209..d33bac224 100644 --- a/auth/oidc/change_binding_username_claim_tool.php +++ b/auth/oidc/change_binding_username_claim_tool.php @@ -34,7 +34,7 @@ require_login(); -$url = new moodle_url('/auth/oidc/change_binding_username_claim_tool.php'); +$url = new \core\url('/auth/oidc/change_binding_username_claim_tool.php'); $PAGE->set_url($url); $PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('admin'); @@ -70,7 +70,7 @@ echo $OUTPUT->header(); echo $OUTPUT->heading(get_string('change_binding_username_claim_tool', 'auth_oidc')); - $bindingusernameclaimurl = new moodle_url('/auth/oidc/binding_username_claim.php'); + $bindingusernameclaimurl = new \core\url('/auth/oidc/binding_username_claim.php'); echo html_writer::tag('p', get_string('change_binding_username_claim_tool_description', 'auth_oidc', $bindingusernameclaimurl->out())); diff --git a/auth/oidc/classes/adminsetting/auth_oidc_admin_setting_iconselect.php b/auth/oidc/classes/adminsetting/auth_oidc_admin_setting_iconselect.php index 1fa8c8425..e8e882bd3 100644 --- a/auth/oidc/classes/adminsetting/auth_oidc_admin_setting_iconselect.php +++ b/auth/oidc/classes/adminsetting/auth_oidc_admin_setting_iconselect.php @@ -92,7 +92,7 @@ public function write_setting($data) { public function output_html($data, $query = '') { global $CFG, $OUTPUT; $attrs = ['type' => 'text/css', 'rel' => 'stylesheet', - 'href' => new \moodle_url('/auth/oidc/classes/adminsetting/iconselect.css')]; + 'href' => new \core\url('/auth/oidc/classes/adminsetting/iconselect.css')]; $html = \html_writer::empty_tag('link', $attrs); $html .= \html_writer::start_tag('div', ['style' => 'max-width: 390px']); $selected = (!empty($data)) ? $data : $this->defaultsetting; diff --git a/auth/oidc/classes/form/change_binding_username_claim_tool_form1.php b/auth/oidc/classes/form/change_binding_username_claim_tool_form1.php index 4e9172d80..b4e6cc7a7 100644 --- a/auth/oidc/classes/form/change_binding_username_claim_tool_form1.php +++ b/auth/oidc/classes/form/change_binding_username_claim_tool_form1.php @@ -28,7 +28,7 @@ use core_text; use csv_import_reader; use html_writer; -use moodle_url; +use core\url; use moodleform; /** @@ -43,7 +43,7 @@ class change_binding_username_claim_tool_form1 extends moodleform { protected function definition() { $mform =& $this->_form; - $url = new moodle_url('/auth/oidc/example.csv'); + $url = new \core\url('/auth/oidc/example.csv'); $link = html_writer::link($url, 'example.csv'); $mform->addElement('static', 'example.csv', get_string('examplecsv', 'auth_oidc'), $link); diff --git a/auth/oidc/classes/loginflow/authcode.php b/auth/oidc/classes/loginflow/authcode.php index a5455603b..28ef8a794 100644 --- a/auth/oidc/classes/loginflow/authcode.php +++ b/auth/oidc/classes/loginflow/authcode.php @@ -34,7 +34,7 @@ use core_text; use core_user; use moodle_exception; -use moodle_url; +use core\url; use pix_icon; use stdClass; @@ -74,7 +74,7 @@ public function loginpage_idp_list($wantsurl) { return [ [ - 'url' => new moodle_url('/auth/oidc/', ['source' => 'loginpage']), + 'url' => new \core\url('/auth/oidc/', ['source' => 'loginpage']), 'icon' => $icon, 'name' => strip_tags(format_text($this->config->opname)), ], @@ -116,14 +116,14 @@ public function handleredirect() { if ($silentloginmode) { if ($error == 'login_required') { // If silent login mode is enabled and the error is 'login_required', redirect to the login page. - $loginpageurl = new moodle_url('/login/index.php', ['noredirect' => 1]); + $loginpageurl = new \core\url('/login/index.php', ['noredirect' => 1]); redirect($loginpageurl); die(); } else if ($error == 'interaction_required') { if (strpos($errordescription, 'multiple user identities') !== false) { $selectaccount = true; } else { - $loginpageurl = new moodle_url('/login/index.php', ['noredirect' => 1]); + $loginpageurl = new \core\url('/login/index.php', ['noredirect' => 1]); redirect($loginpageurl); die(); } @@ -163,7 +163,7 @@ public function handleredirect() { $urltogo = $SESSION->wantsurl; unset($SESSION->wantsurl); } else { - $urltogo = new moodle_url('/'); + $urltogo = new \core\url('/'); } redirect($urltogo); die(); @@ -283,7 +283,7 @@ protected function handlecertadminconsentresponse(array $authparams) { $event->trigger(); $redirect = (!empty($additionaldata['redirect'])) ? $additionaldata['redirect'] : '/auth/oidc/ucp.php'; - redirect(new moodle_url($redirect)); + redirect(new \core\url($redirect)); } /** @@ -381,7 +381,7 @@ protected function handleauthresponse(array $authparams) { } else { throw new moodle_exception('errorinvalidredirect_message', 'auth_oidc'); } - redirect(new moodle_url($redirect)); + redirect(new \core\url($redirect)); } // If the user is already logged in we can treat this as a "migration" - a user switching to OIDC. @@ -391,7 +391,7 @@ protected function handleauthresponse(array $authparams) { } $this->handlemigration($oidcuniqid, $authparams, $tokenparams, $idtoken, $connectiononly); $redirect = (!empty($additionaldata['redirect'])) ? $additionaldata['redirect'] : '/auth/oidc/ucp.php'; - redirect(new moodle_url($redirect)); + redirect(new \core\url($redirect)); } else { // Otherwise it's a user logging in normally with OIDC. $this->handlelogin($oidcuniqid, $authparams, $tokenparams, $idtoken); diff --git a/auth/oidc/classes/loginflow/base.php b/auth/oidc/classes/loginflow/base.php index 219c6d437..95162a7c7 100644 --- a/auth/oidc/classes/loginflow/base.php +++ b/auth/oidc/classes/loginflow/base.php @@ -353,18 +353,18 @@ public function set_httpclient(\auth_oidc\httpclientinterface $httpclient) { * @param bool $justremovetokens If true, just remove the stored OIDC tokens for the user; otherwise, revert login methods. * @param bool $donotremovetokens If true, do not remove tokens when disconnecting. This migrates from a login account * to a "linked" account. - * @param \moodle_url|null $redirect URL to redirect to if successful. - * @param \moodle_url|null $selfurl The page this is accessed from, used for some redirects. + * @param \core\url|null $redirect URL to redirect to if successful. + * @param \core\url|null $selfurl The page this is accessed from, used for some redirects. * @param int|null $userid ID of the user to disconnect; uses the current user if not provided. */ - public function disconnect($justremovetokens = false, $donotremovetokens = false, ?\moodle_url $redirect = null, - ?\moodle_url $selfurl = null, $userid = null) { + public function disconnect($justremovetokens = false, $donotremovetokens = false, ?\core\url $redirect = null, + ?\core\url $selfurl = null, $userid = null) { global $USER, $DB, $CFG; if ($redirect === null) { - $redirect = new \moodle_url('/auth/oidc/ucp.php'); + $redirect = new \core\url('/auth/oidc/ucp.php'); } if ($selfurl === null) { - $selfurl = new \moodle_url('/auth/oidc/ucp.php', ['action' => 'disconnectlogin']); + $selfurl = new \core\url('/auth/oidc/ucp.php', ['action' => 'disconnectlogin']); } // Get the record of the user involved. Current user if no ID received. diff --git a/auth/oidc/classes/oidcclient.php b/auth/oidc/classes/oidcclient.php index 54a57f5f0..87b1d4aa6 100644 --- a/auth/oidc/classes/oidcclient.php +++ b/auth/oidc/classes/oidcclient.php @@ -26,7 +26,7 @@ namespace auth_oidc; use moodle_exception; -use moodle_url; +use core\url; defined('MOODLE_INTERNAL') || die(); @@ -276,7 +276,7 @@ public function authrequest($promptlogin = false, array $stateparams = [], array } $params = $this->getauthrequestparams($promptlogin, $stateparams, $extraparams, $selectaccount); - $redirecturl = new moodle_url($this->endpoints['auth'], $params); + $redirecturl = new \core\url($this->endpoints['auth'], $params); redirect($redirecturl); } @@ -290,7 +290,7 @@ public function authrequest($promptlogin = false, array $stateparams = [], array public function adminconsentrequest(array $stateparams = [], array $extraparams = []) { $adminconsentendpoint = 'https://login.microsoftonline.com/organizations/v2.0/adminconsent'; $params = $this->getadminconsentrequestparams($stateparams, $extraparams); - $redirecturl = new moodle_url($adminconsentendpoint, $params); + $redirecturl = new \core\url($adminconsentendpoint, $params); redirect($redirecturl); } diff --git a/auth/oidc/classes/utils.php b/auth/oidc/classes/utils.php index 93dfcfc58..6fd5fb99d 100644 --- a/auth/oidc/classes/utils.php +++ b/auth/oidc/classes/utils.php @@ -28,7 +28,7 @@ use Exception; use moodle_exception; use auth_oidc\event\action_failed; -use moodle_url; +use core\url; /** * General purpose utility class. @@ -60,7 +60,7 @@ public static function process_json_response($response, array $expectedstructure $result['error'] === 'invalid_grant' && isset($result['error_codes']) && count($result['error_codes']) == 1 && $result['error_codes'][0] == 53003) { - $localo365configurationpageurl = new moodle_url('/admin/settings.php', ['section' => 'local_o365']); + $localo365configurationpageurl = new \core\url('/admin/settings.php', ['section' => 'local_o365']); throw new moodle_exception('settings_adminconsent_error_53003', 'local_o365', $localo365configurationpageurl, '', $result['error_description']); } @@ -186,7 +186,7 @@ private static function make_json_safe($data) { * @return string The redirect URL. */ public static function get_redirecturl() { - $redirecturl = new moodle_url('/auth/oidc/'); + $redirecturl = new \core\url('/auth/oidc/'); return $redirecturl->out(false); } @@ -196,7 +196,7 @@ public static function get_redirecturl() { * @return string The redirect URL. */ public static function get_frontchannellogouturl() { - $logouturl = new moodle_url('/auth/oidc/logout.php'); + $logouturl = new \core\url('/auth/oidc/logout.php'); return $logouturl->out(false); } diff --git a/auth/oidc/cleanupoidctokens.php b/auth/oidc/cleanupoidctokens.php index 3d1a28453..f16b66ef3 100644 --- a/auth/oidc/cleanupoidctokens.php +++ b/auth/oidc/cleanupoidctokens.php @@ -30,7 +30,7 @@ require_login(); $context = context_system::instance(); -$pageurl = new moodle_url('/auth/oidc/cleanupoidctokens.php'); +$pageurl = new \core\url('/auth/oidc/cleanupoidctokens.php'); admin_externalpage_setup('auth_oidc_cleanup_oidc_tokens'); diff --git a/auth/oidc/lib.php b/auth/oidc/lib.php index 482060daa..e68eb316d 100644 --- a/auth/oidc/lib.php +++ b/auth/oidc/lib.php @@ -198,7 +198,7 @@ function auth_oidc_get_tokens_with_empty_ids() { $item->oidcuniqueid = $record->oidcuniqid; $item->matchingstatus = get_string('unmatched', 'auth_oidc'); $item->details = get_string('na', 'auth_oidc'); - $deletetokenurl = new moodle_url('/auth/oidc/cleanupoidctokens.php', ['id' => $record->id]); + $deletetokenurl = new \core\url('/auth/oidc/cleanupoidctokens.php', ['id' => $record->id]); $item->action = html_writer::link($deletetokenurl, get_string('delete_token', 'auth_oidc')); $emptyuseridtokens[$record->id] = $item; @@ -234,7 +234,7 @@ function auth_oidc_get_tokens_with_mismatched_usernames() { $item->matchingstatus = get_string('mismatched', 'auth_oidc'); $item->details = get_string('mismatched_details', 'auth_oidc', ['tokenusername' => $record->tokenusername, 'moodleusername' => $record->musername]); - $deletetokenurl = new moodle_url('/auth/oidc/cleanupoidctokens.php', ['id' => $record->id]); + $deletetokenurl = new \core\url('/auth/oidc/cleanupoidctokens.php', ['id' => $record->id]); $item->action = html_writer::link($deletetokenurl, get_string('delete_token_and_reference', 'auth_oidc')); $mismatchedtokens[$record->id] = $item; @@ -523,7 +523,7 @@ function auth_oidc_display_auth_lock_options($settings, $auth, $userfields, $hel // Generate the list of fields / mappings. if ($fieldnametoolong) { // Display a message that the field can not be mapped because it's too long. - $url = new moodle_url('/user/profile/index.php'); + $url = new \core\url('/user/profile/index.php'); $a = (object)['fieldname' => s($fieldname), 'shortname' => s($field), 'charlimit' => 67, 'link' => $url->out()]; $settings->add(new admin_setting_heading($auth.'/field_not_mapped_'.sha1($field), '', get_string('cannotmapfield', 'auth', $a))); diff --git a/auth/oidc/manageapplication.php b/auth/oidc/manageapplication.php index 401b88813..dd2e2864b 100644 --- a/auth/oidc/manageapplication.php +++ b/auth/oidc/manageapplication.php @@ -31,7 +31,7 @@ require_login(); -$url = new moodle_url('/auth/oidc/manageapplication.php'); +$url = new \core\url('/auth/oidc/manageapplication.php'); $PAGE->set_url($url); $PAGE->set_context(context_system::instance()); $PAGE->set_pagelayout('admin'); @@ -131,7 +131,7 @@ purge_all_caches(); // Then show the message to the user with instructions to update the application token. - $localo365configurl = new moodle_url('/admin/settings.php', ['section' => 'local_o365']); + $localo365configurl = new \core\url('/admin/settings.php', ['section' => 'local_o365']); redirect($localo365configurl, get_string('application_updated_microsoft', 'auth_oidc')); } else { redirect($url, get_string('application_updated', 'auth_oidc')); diff --git a/auth/oidc/settings.php b/auth/oidc/settings.php index 121db8346..70103b41f 100644 --- a/auth/oidc/settings.php +++ b/auth/oidc/settings.php @@ -40,7 +40,7 @@ // Application configuration page. $ADMIN->add('oidcfolder', new admin_externalpage('auth_oidc_application', get_string('settings_page_application', 'auth_oidc'), - new moodle_url('/auth/oidc/manageapplication.php'))); + new \core\url('/auth/oidc/manageapplication.php'))); $idptype = get_config('auth_oidc', 'idptype'); @@ -48,12 +48,12 @@ // Binding username claim page. $ADMIN->add('oidcfolder', new admin_externalpage('auth_oidc_binding_username_claim', get_string('settings_page_binding_username_claim', 'auth_oidc'), - new moodle_url('/auth/oidc/binding_username_claim.php'))); + new \core\url('/auth/oidc/binding_username_claim.php'))); // Change binding username claim tool page. $ADMIN->add('oidcfolder', new admin_externalpage('auth_oidc_change_binding_username_claim_tool', get_string('settings_page_change_binding_username_claim_tool', 'auth_oidc'), - new moodle_url('/auth/oidc/change_binding_username_claim_tool.php'))); + new \core\url('/auth/oidc/change_binding_username_claim_tool.php'))); } @@ -69,7 +69,7 @@ get_string('cfg_redirecturi_key', 'auth_oidc'), get_string('cfg_redirecturi_desc', 'auth_oidc'), utils::get_redirecturl())); // Link to authentication options. - $authenticationconfigurationurl = new moodle_url('/auth/oidc/manageapplication.php'); + $authenticationconfigurationurl = new \core\url('/auth/oidc/manageapplication.php'); $settings->add(new admin_setting_description('auth_oidc/authenticationlink', get_string('settings_page_application', 'auth_oidc'), get_string('cfg_authenticationlink_desc', 'auth_oidc', $authenticationconfigurationurl->out()))); @@ -83,7 +83,7 @@ get_string('cfg_forceredirect_key', 'auth_oidc'), get_string('cfg_forceredirect_desc', 'auth_oidc'), 0)); // Silent login mode. - $forceloginconfigurl = new moodle_url('/admin/settings.php', ['section' => 'sitepolicies']); + $forceloginconfigurl = new \core\url('/admin/settings.php', ['section' => 'sitepolicies']); $settings->add(new admin_setting_configcheckbox('auth_oidc/silentloginmode', get_string('cfg_silentloginmode_key', 'auth_oidc'), get_string('cfg_silentloginmode_desc', 'auth_oidc', $forceloginconfigurl->out(false)), 0)); @@ -243,7 +243,7 @@ // Cleanup OIDC tokens page. $ADMIN->add('oidcfolder', new admin_externalpage('auth_oidc_cleanup_oidc_tokens', - get_string('settings_page_cleanup_oidc_tokens', 'auth_oidc'), new moodle_url('/auth/oidc/cleanupoidctokens.php'))); + get_string('settings_page_cleanup_oidc_tokens', 'auth_oidc'), new \core\url('/auth/oidc/cleanupoidctokens.php'))); // Other settings page and its settings. $fieldmappingspage = new admin_settingpage('auth_oidc_field_mapping', get_string('settings_page_field_mapping', 'auth_oidc')); diff --git a/auth/oidc/ucp.php b/auth/oidc/ucp.php index 5d5d701e1..8d92af0a0 100644 --- a/auth/oidc/ucp.php +++ b/auth/oidc/ucp.php @@ -88,7 +88,7 @@ echo \html_writer::tag('h4', get_string('ucp_status_enabled', 'auth_oidc'), ['class' => 'notifysuccess']); if (is_enabled_auth('manual') === true) { if (auth_oidc_connectioncapability($USER->id, 'disconnect')) { - $connectlinkuri = new \moodle_url('/auth/oidc/ucp.php', ['action' => 'disconnectlogin']); + $connectlinkuri = new \core\url('/auth/oidc/ucp.php', ['action' => 'disconnectlogin']); $strdisconnect = get_string('ucp_login_stop', 'auth_oidc', $opname); $linkhtml = \html_writer::link($connectlinkuri, $strdisconnect); echo \html_writer::tag('h5', $linkhtml); @@ -98,7 +98,7 @@ } else { echo \html_writer::tag('h4', get_string('ucp_status_disabled', 'auth_oidc'), ['class' => 'notifyproblem']); if (auth_oidc_connectioncapability($USER->id, 'connect')) { - $connectlinkuri = new \moodle_url('/auth/oidc/ucp.php', ['action' => 'connectlogin']); + $connectlinkuri = new \core\url('/auth/oidc/ucp.php', ['action' => 'connectlogin']); $linkhtml = \html_writer::link($connectlinkuri, get_string('ucp_login_start', 'auth_oidc', $opname)); echo \html_writer::tag('h5', $linkhtml); echo \html_writer::span(get_string('ucp_login_start_desc', 'auth_oidc', $opname));