Skip to content

Commit 3ee412c

Browse files
authored
Merge pull request #8 from ngandrass/feature/moodle51
Moodle 5.1 Support
2 parents 88450df + e00d0ef commit 3ee412c

18 files changed

+137
-104
lines changed

.github/workflows/moodle-plugin-ci.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212

1313
services:
1414
postgres:
15-
image: postgres:14
15+
image: postgres:15
1616
env:
1717
POSTGRES_USER: 'postgres'
1818
POSTGRES_HOST_AUTH_METHOD: 'trust'
@@ -72,6 +72,14 @@ jobs:
7272
- {moodle-branch: 'MOODLE_500_STABLE', php: '8.3', database: 'mariadb'}
7373
- {moodle-branch: 'MOODLE_500_STABLE', php: '8.4', database: 'pgsql'}
7474
- {moodle-branch: 'MOODLE_500_STABLE', php: '8.4', database: 'mariadb'}
75+
76+
# Moodle 5.1, PHP 8.2 to 8.4, PostgreSQL and MariaDB
77+
- {moodle-branch: 'MOODLE_501_STABLE', php: '8.2', database: 'pgsql'}
78+
- {moodle-branch: 'MOODLE_501_STABLE', php: '8.2', database: 'mariadb'}
79+
- {moodle-branch: 'MOODLE_501_STABLE', php: '8.3', database: 'pgsql'}
80+
- {moodle-branch: 'MOODLE_501_STABLE', php: '8.3', database: 'mariadb'}
81+
- {moodle-branch: 'MOODLE_501_STABLE', php: '8.4', database: 'pgsql'}
82+
- {moodle-branch: 'MOODLE_501_STABLE', php: '8.4', database: 'mariadb'}
7583
steps:
7684
- name: Check out repository code
7785
uses: actions/checkout@v4

.gitlab-ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ stages:
2323
stage: pluginci
2424
image: moodlehq/moodle-php-apache:${PHP_VERSION}
2525
services:
26-
- name: postgres:14
26+
- name: postgres:15
2727
alias: postgres
2828
variables:
2929
POSTGRES_USER: "postgres"
@@ -114,3 +114,10 @@ moodle-plugin-ci-M500:
114114
MOODLE_BRANCH: "MOODLE_500_STABLE"
115115
PHP_VERSION: "8.2"
116116
DB: "pgsql"
117+
118+
moodle-plugin-ci-M501:
119+
<<: *stage-pluginci-common
120+
variables:
121+
MOODLE_BRANCH: "MOODLE_500_STABLE"
122+
PHP_VERSION: "8.2"
123+
DB: "pgsql"

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## Version X.Y.Z (YYYYMMDDXX)
4+
5+
- Fix background color of Bootstrap badges on dry-run page with Moodle 5.1
6+
- Add Moodle 5.1 and all supported PHP versions to CI test matrix
7+
- Comply with Moodle coding style version 3.6
8+
9+
310
## Version 1.3.0 (2025100600)
411

512
- Allow to ignore users based on their authentication method (e.g., ignore all users authenticated via LDAP)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[![Latest Version](https://img.shields.io/github/v/release/ngandrass/moodle-tool_userautodelete)](https://github.com/ngandrass/moodle-tool_userautodelete/releases)
44
[![PHP Support](https://img.shields.io/badge/PHP-7.4%20--%208.4-blue)](https://github.com/ngandrass/moodle-tool_userautodelete)
5-
[![Moodle Support](https://img.shields.io/badge/Moodle-4.1%20--%205.0-orange)](https://github.com/ngandrass/moodle-tool_userautodelete)
5+
[![Moodle Support](https://img.shields.io/badge/Moodle-4.1%20--%205.1-orange)](https://github.com/ngandrass/moodle-tool_userautodelete)
66
[![GitHub Workflow Status: Moodle Plugin CI](https://img.shields.io/github/actions/workflow/status/ngandrass/moodle-tool_userautodelete/moodle-plugin-ci.yml?label=Moodle%20Plugin%20CI)](https://github.com/ngandrass/moodle-tool_userautodelete/actions/workflows/moodle-plugin-ci.yml)
77
[![Code Coverage](https://img.shields.io/coverallsCoverage/github/ngandrass/moodle-tool_userautodelete)](https://coveralls.io/github/ngandrass/moodle-tool_userautodelete)
88
[![GitHub Issues](https://img.shields.io/github/issues/ngandrass/moodle-tool_userautodelete)](https://github.com/ngandrass/moodle-tool_userautodelete/issues)

classes/local/admin/admin_setting_configcheckbox_alwaystrue.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3131
*/
3232
class admin_setting_configcheckbox_alwaystrue extends \admin_setting_configcheckbox {
33-
3433
/**
3534
* Retrieves the current setting using the objects name
3635
*
@@ -48,5 +47,4 @@ public function get_setting() {
4847
public function is_readonly(): bool {
4948
return true;
5049
}
51-
5250
}

classes/logger.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
* of the logging system.
3636
*/
3737
class logger {
38-
3938
/** @var bool If true, all logging operations are suppressed */
4039
protected static bool $suppresslogs = false;
4140

@@ -104,5 +103,4 @@ public static function error(string $message): void {
104103
mtrace("[ERROR] $message");
105104
}
106105
}
107-
108106
}

classes/manager.php

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* Manages the user notification and deletion workflow
3333
*/
3434
class manager {
35-
3635
/** @var \stdClass Moodle config object for this plugin */
3736
protected \stdClass $config;
3837

@@ -370,13 +369,15 @@ protected function warn_inactive_users(): int {
370369
// Notify users.
371370
$numwarnedusers = 0;
372371
foreach ($userstowarn as $user) {
373-
if (!email_to_user(
374-
$user,
375-
get_admin(),
376-
$this->config->warning_email_subject,
377-
html_to_text(nl2br($this->config->warning_email_body)),
378-
$this->config->warning_email_body
379-
)) {
372+
if (
373+
!email_to_user(
374+
$user,
375+
get_admin(),
376+
$this->config->warning_email_subject,
377+
html_to_text(nl2br($this->config->warning_email_body)),
378+
$this->config->warning_email_body
379+
)
380+
) {
380381
logger::error(get_string('error_sending_warning_mail_to_user', 'tool_userautodelete', $user->id));
381382
continue;
382383
}
@@ -416,13 +417,15 @@ protected function delete_inactive_users(): int {
416417
foreach ($userstodelete as $user) {
417418
// Send deletion mail if enabled.
418419
if ($this->config->delete_email_enable) {
419-
if (!email_to_user(
420-
$user,
421-
get_admin(),
422-
$this->config->delete_email_subject,
423-
html_to_text(nl2br($this->config->delete_email_body)),
424-
$this->config->delete_email_body
425-
)) {
420+
if (
421+
!email_to_user(
422+
$user,
423+
get_admin(),
424+
$this->config->delete_email_subject,
425+
html_to_text(nl2br($this->config->delete_email_body)),
426+
$this->config->delete_email_body
427+
)
428+
) {
426429
logger::error(get_string('error_sending_delete_mail_to_user', 'tool_userautodelete', $user->id));
427430
} else {
428431
logger::info(get_string('delete_email_sent_to_user', 'tool_userautodelete', $user->id));
@@ -458,32 +461,34 @@ protected function delete_inactive_users(): int {
458461
protected function anonymize_user_record(int $userid): void {
459462
global $DB;
460463

461-
if ($DB->update_record('user', [
462-
'id' => $userid,
463-
'username' => "DELETED-USER-{$userid}",
464-
'password' => '',
465-
'idnumber' => '',
466-
'firstname' => 'DELETED',
467-
'lastname' => 'DELETED',
468-
'email' => "DELETED-USER-{$userid}@localhost",
469-
'phone1' => '',
470-
'phone2' => '',
471-
'institution' => '',
472-
'department' => '',
473-
'address' => '',
474-
'city' => '',
475-
'country' => '',
476-
'lastip' => '',
477-
'secret' => '',
478-
'picture' => 0,
479-
'description' => '',
480-
'imagealt' => '',
481-
'lastnamephonetic' => '',
482-
'firstnamephonetic' => '',
483-
'middlename' => '',
484-
'alternatename' => '',
485-
'moodlenetprofile' => '',
486-
])) {
464+
if (
465+
$DB->update_record('user', [
466+
'id' => $userid,
467+
'username' => "DELETED-USER-{$userid}",
468+
'password' => '',
469+
'idnumber' => '',
470+
'firstname' => 'DELETED',
471+
'lastname' => 'DELETED',
472+
'email' => "DELETED-USER-{$userid}@localhost",
473+
'phone1' => '',
474+
'phone2' => '',
475+
'institution' => '',
476+
'department' => '',
477+
'address' => '',
478+
'city' => '',
479+
'country' => '',
480+
'lastip' => '',
481+
'secret' => '',
482+
'picture' => 0,
483+
'description' => '',
484+
'imagealt' => '',
485+
'lastnamephonetic' => '',
486+
'firstnamephonetic' => '',
487+
'middlename' => '',
488+
'alternatename' => '',
489+
'moodlenetprofile' => '',
490+
])
491+
) {
487492
logger::info(get_string('user_anonymized', 'tool_userautodelete', $userid));
488493
} else {
489494
logger::error(get_string('error_anonymizing_user', 'tool_userautodelete', $userid));
@@ -527,5 +532,4 @@ protected function cleanup(): int {
527532

528533
return $numrecoveredusers;
529534
}
530-
531535
}

classes/output/log_table.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,14 @@
3131

3232
// @codeCoverageIgnoreStart
3333
global $CFG;
34-
require_once($CFG->libdir.'/tablelib.php');
34+
require_once($CFG->libdir . '/tablelib.php');
3535
// @codeCoverageIgnoreEnd
3636

3737

3838
/**
3939
* Table renderer for the log table
4040
*/
4141
class log_table extends \table_sql {
42-
4342
/**
4443
* Constructor
4544
*
@@ -116,5 +115,4 @@ public function col_deleted($values) {
116115
$color = $values->deleted > 0 ? 'danger' : 'secondary';
117116
return html_writer::span($values->deleted, "badge badge-{$color} text-bg-{$color} p-2");
118117
}
119-
120118
}

classes/privacy/provider.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@
4040
*
4141
* @codeCoverageIgnore This is handled by Moodle core tests
4242
*/
43-
class provider implements
43+
class provider implements // phpcs:ignore
4444
\core_privacy\local\metadata\provider,
45-
\core_privacy\local\request\plugin\provider,
46-
\core_privacy\local\request\core_userlist_provider {
47-
45+
\core_privacy\local\request\core_userlist_provider,
46+
\core_privacy\local\request\plugin\provider {
4847
/**
4948
* Returns meta data about this plugin.
5049
*
@@ -99,7 +98,7 @@ public static function export_user_data(approved_contextlist $contextlist) {
9998
writer::with_context($context)->export_data(
10099
[
101100
get_string('pluginname', 'tool_userautodelete'),
102-
get_string('inactivity_warning', 'tool_userautodelete')." #{$row->id}",
101+
get_string('inactivity_warning', 'tool_userautodelete') . " #{$row->id}",
103102
],
104103
(object) [
105104
'userid' => $row->userid,
@@ -184,5 +183,4 @@ public static function delete_data_for_users(approved_userlist $userlist) {
184183
[$insql, $inparams] = $DB->get_in_or_equal($userlist->get_userids());
185184
$DB->delete_records_select('tool_userautodelete_mail', "userid {$insql}", $inparams);
186185
}
187-
188186
}

classes/task/check_and_delete_users.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
* and finally deletes eligible users
3535
*/
3636
class check_and_delete_users extends \core\task\scheduled_task {
37-
3837
/**
3938
* Get a descriptive name for the task (shown to admins)
4039
*
@@ -50,10 +49,10 @@ public function get_name() {
5049
* Throw exceptions on errors (the job will be retried).
5150
*
5251
* @throws \coding_exception
52+
* @throws \dml_exception
5353
*/
5454
public function execute() {
5555
$manager = new \tool_userautodelete\manager();
5656
$manager->execute();
5757
}
58-
5958
}

0 commit comments

Comments
 (0)