Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #43: support for Moodle 4.5 #44

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on: [push, pull_request]

jobs:
test:
uses: catalyst/catalyst-moodle-workflows/.github/workflows/group-310-plus-ci.yml@main
uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main
secrets:
moodle_org_token: ${{ secrets.MOODLE_ORG_TOKEN }}
with:
disable_behat: true
20 changes: 0 additions & 20 deletions .github/workflows/moodle-release.yml

This file was deleted.

37 changes: 23 additions & 14 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;
}

/**
* @param $userpassword
* Check if provided password is master password.
*
* @param string $userpassword User password.
* @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 All @@ -226,7 +231,7 @@ private function get_random_user_by_roleid($roleid) {

/**
* Get a user who is enrolled in a course.
* @param $courseid
* @param int $courseid
* @return bool|mixed
* @throws dml_exception
*/
Expand All @@ -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 int $courseid
* @param int $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
1 change: 1 addition & 0 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@
$plugin->requires = 2020110910; // Requires 3.10 as minimum.
$plugin->component = 'auth_basic'; // Full name of the plugin (used for diagnostics).
$plugin->maturity = MATURITY_STABLE;
$plugin->supported = [310, 405]; // A range of branch numbers of supported moodle versions.
Loading