Skip to content

Commit

Permalink
Upgrade: Adopt changes from MDL-81960 and MDL-82183 and use new classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
abias committed Jan 8, 2025
1 parent 888d449 commit f3c0d58
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 2024-11-23 - Upgrade: Adopt changes from MDL-81960 and MDL-82183 and use new classes.
* 2024-11-23 - Prepare compatibility for Moodle 4.5.

### v4.4-r2
Expand Down
8 changes: 4 additions & 4 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ function tool_directsso_get_usable_urls() {
}

// Compose the HTML code.
$html = html_writer::start_tag('ul');
$html = \core\output\html_writer::start_tag('ul');
foreach ($urls as $u) {
$url = new moodle_url('/admin/tool/directsso/login.php', $u);
$html .= html_writer::tag('li', html_writer::link($url, $url->out()));
$url = new \core\url('/admin/tool/directsso/login.php', $u);
$html .= \core\output\html_writer::tag('li', \core\output\html_writer::link($url, $url->out()));
}
$html .= html_writer::end_tag('ul');
$html .= \core\output\html_writer::end_tag('ul');

// Return.
return $html;
Expand Down
14 changes: 7 additions & 7 deletions login.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@

// Set up page.
$PAGE->set_context(context_system::instance());
$PAGE->set_url(new moodle_url('/admin/tool/directsso/login.php', ['auth' => $auth, 'wantspage' => $wantspage]));
$PAGE->set_url(new \core\url('/admin/tool/directsso/login.php', ['auth' => $auth, 'wantspage' => $wantspage]));

// Get plugin config.
$config = get_config('tool_directsso');

// Prepare login page URL as fallback.
$loginpageurl = new moodle_url('/login/index.php');
$loginpageurl = new \core\url('/login/index.php');

// Prepare wantsURL based on the submitted wantspage parameter.
$allowedwantspages = explode(',', $config->allowedwantspages);
Expand All @@ -53,7 +53,7 @@
// If the admin allowed this wantspage target.
if (in_array(TOOL_DIRECTSSO_WANTSPAGE_FRONTPAGE, $allowedwantspages)) {
// Remember wantsurl.
$wantsurl = new moodle_url('/?redirect=0');
$wantsurl = new \core\url('/?redirect=0');
break;

// Otherwise.
Expand All @@ -67,7 +67,7 @@
// If the admin allowed this wantspage target.
if (in_array(TOOL_DIRECTSSO_WANTSPAGE_DASHBOARD, $allowedwantspages)) {
// Remember wantsurl.
$wantsurl = new moodle_url('/my');
$wantsurl = new \core\url('/my');
break;

// Otherwise.
Expand All @@ -86,7 +86,7 @@
// If a valid course ID was given.
if (!empty($courseid) && $DB->record_exists('course', ['id' => $courseid])) {
// Remember wantsurl.
$wantsurl = new moodle_url('/course/view.php', ['id' => $courseid]);
$wantsurl = new \core\url('/course/view.php', ['id' => $courseid]);
break;

// Otherwise.
Expand Down Expand Up @@ -116,15 +116,15 @@
$issuerid = required_param('id', PARAM_INT);

// And the page has one more parameter.
$PAGE->set_url(new moodle_url('/admin/tool/directsso/login.php',
$PAGE->set_url(new \core\url('/admin/tool/directsso/login.php',
['auth' => $auth, 'id' => $issuerid, 'wantspage' => $wantspage]));

// If the admin allowed this auth method.
if (in_array('oauth2', $allowedauths)) {
// Compose the URl, add the sesskey (as OAuth2 expects it together with the wantsurl)
// and redirect to the OAuth login page.
$redirectparams = ['wantsurl' => $wantsurl, 'sesskey' => sesskey(), 'id' => $issuerid];
$redirecturl = new moodle_url('/auth/oauth2/login.php', $redirectparams);
$redirecturl = new \core\url('/auth/oauth2/login.php', $redirectparams);
redirect($redirecturl);

// Otherwise.
Expand Down

0 comments on commit f3c0d58

Please sign in to comment.