Skip to content

Commit

Permalink
issue #43: fix CI complains
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriim committed Nov 18, 2024
1 parent cb8dd98 commit 67b07b6
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 30 deletions.
33 changes: 21 additions & 12 deletions auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
*/
class auth_plugin_basic extends auth_plugin_base {

/**
* Defaults.
*
* @var int[]
*/
public $defaults = array(
'debug' => 0,
'send401' => 0,
Expand All @@ -49,9 +54,9 @@ public function __construct() {
/**
* A debug function, dumps to the php log as well as into the
* response headers for easy curl based debugging
*
* @param string $msg Message
*/
private function log($msg) {
private function log(string $msg) {
if ($this->config->debug) {
// @codingStandardsIgnoreStart
error_log('auth_basic: ' . $msg);
Expand Down Expand Up @@ -161,17 +166,16 @@ public function loginpage_hook() {
* @param string $username The username
* @param string $password The password
* @return bool Authentication success or failure.
*
* @SuppressWarnings("unused")
*/
public function user_login ($username, $password) {
return false;
}

/**
* Check if provided password is master password.
*
* @param $userpassword
* @return bool
* @throws dml_exception
*/
private function is_master_password($userpassword) {
global $CFG, $DB;
Expand Down Expand Up @@ -213,8 +217,9 @@ private function get_random_user() {

/**
* Get a user by site role.
*
* @param mixed $roleid Role ID
* @return bool|mixed
* @throws dml_exception
*/
private function get_random_user_by_roleid($roleid) {
$sql = "SELECT u.*
Expand Down Expand Up @@ -243,7 +248,10 @@ private function get_random_user_by_courseid($courseid) {
* Get a user who is enrolled in a course with a specified role.
* This will only get student with role at Course Level.
* It will ignore roles at other context level (module, category, block, site).
* @param $courseid
*
* @param mixed $courseid
* @param mixed $roleid Role ID
*
* @return bool|mixed
* @throws dml_exception
*/
Expand All @@ -260,9 +268,9 @@ private function get_random_user_by_courseid_with_roleid($courseid, $roleid) {

/**
* Get user based on template value.
* @param $template
*
* @param mixed $template
* @return bool|mixed
* @throws dml_exception
*/
private function get_user($template) {
$user = false;
Expand Down Expand Up @@ -300,12 +308,13 @@ private function get_user($template) {

/**
* Get random record.
* @param $sql
* @param null $params
*
* @param string $sql SQL
* @param null|array $params
* @return mixed
* @throws dml_exception
*/
private function random_record($sql, $params=null) {
private function random_record(string $sql, ?array $params = null) {
global $DB;
if ($DB->get_dbfamily() == 'mysql') {
$sql = $sql . " ORDER BY rand() LIMIT 1";
Expand Down
13 changes: 9 additions & 4 deletions classes/form/savepassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.


defined('MOODLE_INTERNAL') || die();
require_once("$CFG->libdir/formslib.php");

/**
* Master Password Form
*
* @package auth_basic
* @copyright 2018 Nathan Nguyen <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
require_once("$CFG->libdir/formslib.php");

class savepassword extends moodleform {

/**
* Form definition.
*
* @return void
*/
protected function definition() {
$mform = $this->_form;

Expand Down
14 changes: 7 additions & 7 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Privacy Subsystem implementation for auth_basic.
*
* @package auth_basic
* @copyright 2018 Olivier SECRET <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace auth_basic\privacy;

Expand All @@ -33,6 +26,13 @@
use core_privacy\local\request\userlist;
use core_privacy\local\request\writer;

/**
* Privacy Subsystem implementation for auth_basic.
*
* @package auth_basic
* @copyright 2018 Olivier SECRET <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements
\core_privacy\local\metadata\provider,
\core_privacy\local\request\core_userlist_provider,
Expand Down
5 changes: 5 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@

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

/**
* Upgrade hook.
*
* @param int $oldversion the version we are upgrading from
*/
function xmldb_auth_basic_upgrade($oldversion) {
global $DB;

Expand Down
14 changes: 7 additions & 7 deletions tests/auth_basic_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Base class for unit tests for auth_basic.
*
* @package auth_basic
* @category test
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

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

global $CFG;
require_once($CFG->dirroot.'/auth/basic/auth.php');

/**
* Base class for unit tests for auth_basic.
* @package auth_basic
* @category test
* @copyright Brendan Heywood <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class auth_basic_test extends advanced_testcase {
/** @var auth_plugin_basic Keeps the authentication plugin. */
protected $authplugin;
Expand Down

0 comments on commit 67b07b6

Please sign in to comment.