Skip to content

Commit

Permalink
Fix Moodle plugin CI errors part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
patmr7 authored and weilai-irl committed Oct 25, 2024
1 parent 813d66c commit e3f778b
Show file tree
Hide file tree
Showing 79 changed files with 617 additions and 396 deletions.
6 changes: 3 additions & 3 deletions auth/oidc/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct($forceloginflow = null) {
*
* @return bool
*/
function can_be_manually_set() {
public function can_be_manually_set() {
return true;
}

Expand Down Expand Up @@ -197,8 +197,8 @@ public function handleredirect() {
* @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, ?\moodle_url $redirect = null,
?\moodle_url $selfurl = null, $userid = null) {
return $this->loginflow->disconnect($justremovetokens, $donotremovetokens, $redirect, $selfurl, $userid);
}

Expand Down
4 changes: 2 additions & 2 deletions auth/oidc/binding_username_claim.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@

$oidcconfig = get_config('auth_oidc');
if (!isset($oidcconfig->bindingusernameclaim)) {
// bindingusernameclaim is not set, set default value.
// Bindingusernameclaim is not set, set default value.
$formdata['bindingusernameclaim'] = 'auto';
$formdata['customclaimname'] = '';
set_config('bindingusernameclaim', 'auto', 'auth_oidc');
} else if(!$oidcconfig->bindingusernameclaim) {
} else if (!$oidcconfig->bindingusernameclaim) {
$formdata['bindingusernameclaim'] = 'auto';
$formdata['customclaimname'] = '';
} else if (in_array($oidcconfig->bindingusernameclaim, $predefinedbindingclaims)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\adminsetting;

defined('MOODLE_INTERNAL') || die();

/**
* Choose an icon for the identity provider entry on the login page.
*/
Expand Down Expand Up @@ -93,8 +91,8 @@ public function write_setting($data) {
*/
public function output_html($data, $query = '') {
global $CFG, $OUTPUT;
$attrs = array('type' => 'text/css', 'rel' => 'stylesheet',
'href' => new \moodle_url('/auth/oidc/classes/adminsetting/iconselect.css'));
$attrs = ['type' => 'text/css', 'rel' => 'stylesheet',
'href' => new \moodle_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;
Expand All @@ -114,7 +112,7 @@ public function output_html($data, $query = '') {
}
$html .= \html_writer::empty_tag('input', $inputattrs);
$labelattrs = [
'class' => 'iconselect'
'class' => 'iconselect',
];
$html .= \html_writer::label($iconhtml, $id, true, $labelattrs);
}
Expand Down
13 changes: 7 additions & 6 deletions auth/oidc/classes/adminsetting/auth_oidc_admin_setting_label.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,22 @@

use admin_setting;

defined('MOODLE_INTERNAL') || die();

/**
* Display a static text.
*/
class auth_oidc_admin_setting_label extends admin_setting {
/**
* @var string $label The label for display purposes.
*/
private $label;

/**
* Constructor.
*
* @param $name
* @param $label
* @param $visiblename
* @param $description
* @param string $name The setting name.
* @param string $label The label to display.
* @param string $visiblename The visible name for the setting.
* @param string $description A description of the setting.
*/
public function __construct($name, $label, $visiblename, $description) {
parent::__construct($name, $visiblename, $description, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\adminsetting;

defined('MOODLE_INTERNAL') || die();

/**
* Displays the redirect URI for easier config.
*/
Expand Down Expand Up @@ -79,7 +77,7 @@ public function output_html($data, $query = '') {
'type' => 'radio',
'name' => $inputname,
'id' => $flowtypeid,
'value' => $flowtype
'value' => $flowtype,
];
if ($data === $flowtype || (empty($data) && $flowtype === $this->get_defaultsetting())) {
$radioattrs['checked'] = 'checked';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,22 @@

use auth_oidc\utils;

defined('MOODLE_INTERNAL') || die();

/**
* Displays the redirect URI for easier config.
*/
class auth_oidc_admin_setting_redirecturi extends \admin_setting {
/**
* @var string $url The redirect URL for the configuration.
*/
private $url;

/**
* Constructor.
*
* @param $name
* @param $heading
* @param $description
* @param string $name The setting name.
* @param string $heading The setting heading.
* @param string $description The setting description.
* @param string $url The redirect URL.
*/
public function __construct($name, $heading, $description, $url) {
$this->nosave = true;
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/action_failed.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Event fired whenever we need to record a debug message.
*/
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/user_authed.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Event fired when a user authenticated with OIDC, but does not log in.
*/
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/user_connected.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Fired when a user connects to OpenID Connect.
*/
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/user_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Event fired when OIDC creates a new user.
*/
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/user_disconnected.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Fired when a user disconnects from OpenID Connect.
*/
Expand Down
2 changes: 0 additions & 2 deletions auth/oidc/classes/event/user_loggedin.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc\event;

defined('MOODLE_INTERNAL') || die();

/**
* Fired when a user uses OIDC to log in.
*/
Expand Down
4 changes: 1 addition & 3 deletions auth/oidc/classes/event/user_rename_attempt.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
use context_system;
use core\event\base;

defined('MOODLE_INTERNAL') || die();

/**
* Fired when a user attempts to change their username from the auth_oidc plugin.
*/
Expand Down Expand Up @@ -63,4 +61,4 @@ protected function init() {
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'user';
}
}
}
14 changes: 7 additions & 7 deletions auth/oidc/classes/form/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function definition() {
// Certificate source.
$mform->addElement('select', 'clientcertsource', auth_oidc_config_name_in_form('clientcertsource'), [
AUTH_OIDC_AUTH_CERT_SOURCE_TEXT => get_string('cert_source_text', 'auth_oidc'),
AUTH_OIDC_AUTH_CERT_SOURCE_FILE => get_string('cert_source_path', 'auth_oidc')
AUTH_OIDC_AUTH_CERT_SOURCE_FILE => get_string('cert_source_path', 'auth_oidc'),
]);
$mform->setDefault('clientcertsource', 0);
$mform->disabledIf('clientcertsource', 'clientauthmethod', 'neq', AUTH_OIDC_AUTH_METHOD_CERTIFICATE);
Expand Down Expand Up @@ -146,7 +146,7 @@ protected function definition() {
$mform->addElement('static', 'tokenendpoint_help', '', get_string('tokenendpoint_help', 'auth_oidc'));
$mform->addRule('tokenendpoint', null, 'required', null, 'client');

// "Other parameters" header.
// Other parameters header.
$mform->addElement('header', 'otherparams', get_string('settings_section_other_params', 'auth_oidc'));
$mform->setExpanded('otherparams');

Expand Down Expand Up @@ -184,11 +184,11 @@ protected function definition() {
/**
* Additional validate rules.
*
* @param $data
* @param $files
* @return array
* @param array $data Submitted data for validation.
* @param array $files Uploaded files for validation.
* @return array An array of validation errors, if any.
*/
function validation($data, $files) {
public function validation($data, $files) {
$errors = parent::validation($data, $files);

if (!isset($data['clientauthmethod'])) {
Expand Down Expand Up @@ -278,4 +278,4 @@ function validation($data, $files) {

return $errors;
}
}
}
18 changes: 17 additions & 1 deletion auth/oidc/classes/form/binding_username_claim.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,19 @@
* Class bindingusernameclaim represents the form on the binding username claim configuration page.
*/
class binding_username_claim extends moodleform {
/**
* Option for setting a non-Microsoft IdP.
*/
const OPTION_SET_NON_MS_IDP = 1;

/**
* Option for setting a Microsoft IdP without user sync.
*/
const OPTION_SET_MS_NO_USER_SYNC = 2;

/**
* Option for setting a Microsoft IdP with user sync enabled.
*/
const OPTION_SET_MS_WITH_USER_SYNC = 3;

/** @var int */
Expand Down Expand Up @@ -102,7 +113,12 @@ protected function definition() {
throw new moodle_exception('missing_idp_type', 'auth_oidc');
}

$mform->addElement('select', 'bindingusernameclaim', auth_oidc_config_name_in_form('binding_username_claim'), $bindingusernameoptions);
$mform->addElement(
'select',
'bindingusernameclaim',
auth_oidc_config_name_in_form('binding_username_claim'),
$bindingusernameoptions
);
$mform->setDefault('bindingusernameclaim', 'auto');
$mform->addElement('static', 'bindingusernameclaim_description', '', get_string($descriptionidentifier, 'auth_oidc'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
use moodle_url;
use moodleform;

defined('MOODLE_INTERNAL') || die();

/**
* Class change_binding_username_claim_tool_form1 represents the form on the change binding username claim tool page.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

use moodleform;

defined('MOODLE_INTERNAL') || die();

/**
* Class change_binding_username_claim_tool_form2 represents the form on the change binding username claim tool page.
*/
Expand All @@ -38,7 +36,7 @@ class change_binding_username_claim_tool_form2 extends moodleform {
*
* @return void
*/
function definition() {
public function definition() {
$mform =& $this->_form;
$data = $this->_customdata['data'];

Expand Down
4 changes: 2 additions & 2 deletions auth/oidc/classes/httpclient.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected function get_moodle_version() {
* @param array $options
* @return bool
*/
protected function request($url, $options = array()) {
protected function request($url, $options = []) {
$this->setHeader($this->get_clienttag_headers());
$result = parent::request($url, $options);
$this->resetHeader();
Expand All @@ -100,7 +100,7 @@ protected function request($url, $options = array()) {
* @param array $options
* @return bool
*/
public function post($url, $params = '', $options = array()) {
public function post($url, $params = '', $options = []) {
// Encode data to disable uploading files when values are prefixed @.
if (is_array($params)) {
$params = http_build_query($params, '', '&');
Expand Down
4 changes: 1 addition & 3 deletions auth/oidc/classes/httpclientinterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

namespace auth_oidc;

defined('MOODLE_INTERNAL') || die();

/**
* Interface defining an HTTP client.
*/
Expand All @@ -39,5 +37,5 @@ interface httpclientinterface {
* @param array $options
* @return bool
*/
public function post($url, $params = '', $options = array());
public function post($url, $params = '', $options = []);
}
2 changes: 0 additions & 2 deletions auth/oidc/classes/jwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

use moodle_exception;

defined('MOODLE_INTERNAL') || die();

/**
* Class for working with JWTs.
*/
Expand Down
Loading

0 comments on commit e3f778b

Please sign in to comment.