first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_enrol\form;
/**
* Form to customise the course role names.
*
* @package core_enrol
* @copyright 2023 Ferran Recio <ferran@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class renameroles extends \moodleform {
/**
* Form definition.
*/
public function definition() {
$mform = $this->_form;
$courseid = $this->_customdata['id'];
$roles = $this->_customdata['roles'] ?? [];
$formdata = new \stdClass();
$mform->addElement('hidden', 'id', $courseid);
$mform->setType('id', PARAM_INT);
foreach ($roles as $role) {
$settingname = 'role_' . $role->id;
$mform->addElement('text', $settingname, get_string('yourwordforx', '', $role->localname));
$mform->setType($settingname, PARAM_TEXT);
$formdata->{$settingname} = $role->coursealias;
}
$mform->addElement('submit', 'submit', get_string('save'));
$this->set_data($formdata);
}
}
@@ -0,0 +1,44 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_enrol\hook;
use stdClass;
/**
* Hook after enrolment status is changed.
*
* @package core_enrol
* @copyright 2024 Safat Shahin <safat.shahin@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[\core\attribute\label('Allows plugins or features to perform actions after the enrolment instance status is changed.')]
#[\core\attribute\tags('enrol')]
class after_enrol_instance_status_updated {
/**
* Constructor for the hook.
*
* @param stdClass $enrolinstance The enrol instance.
* @param int $newstatus The new status.
*/
public function __construct(
/** @var stdClass The enrol instance */
public readonly stdClass $enrolinstance,
/** @var int The new status */
public readonly int $newstatus,
) {
}
}
@@ -0,0 +1,62 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_enrol\hook;
use stdClass;
/**
* Hook after a user is enrolled in a course for an enrolment instance.
*
* @package core_enrol
* @copyright 2024 Safat Shahin <safat.shahin@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[\core\attribute\label('Allows plugins or features to perform actions after a user is enrolled in a course.')]
#[\core\attribute\tags('enrol', 'user')]
class after_user_enrolled {
/**
* Constructor for the hook.
*
* @param stdClass $enrolinstance The enrol instance.
* @param stdClass $userenrolmentinstance The user enrolment instance.
*/
public function __construct(
/** @var stdClass The enrol instance */
public readonly stdClass $enrolinstance,
/** @var stdClass The user enrolment instance */
public readonly stdClass $userenrolmentinstance,
) {
}
/**
* Get the user id.
*
* @return int
*/
public function get_userid(): int {
return $this->userenrolmentinstance->userid;
}
/**
* Get the enrol instance.
*
* @return stdClass The enrol instance.
*/
public function get_enrolinstance(): stdClass {
return $this->enrolinstance;
}
}
@@ -0,0 +1,46 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_enrol\hook;
use stdClass;
use Psr\EventDispatcher\StoppableEventInterface;
/**
* Hook before enrolment instance is deleted.
*
* @package core_enrol
* @copyright 20234 Safat Shahin <safat.shahin@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[\core\attribute\label('Allows plugins or features to perform actions before the enrolment instance is deleted.')]
#[\core\attribute\tags('enrol', 'user')]
class before_enrol_instance_deleted implements
StoppableEventInterface
{
use \core\hook\stoppable_trait;
/**
* Constructor for the hook.
*
* @param stdClass $enrolinstance The enrol instance.
*/
public function __construct(
/** @var stdClass The enrol instance */
public readonly stdClass $enrolinstance,
) {
}
}
@@ -0,0 +1,53 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_enrol\hook;
use stdClass;
/**
* Hook before a user is un-enrolled from a course for an enrolment instance.
*
* @package core_enrol
* @copyright 2024 Safat Shahin <safat.shahin@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[\core\attribute\label('Allows plugins or features to perform actions before a user enrolment is removed.')]
#[\core\attribute\tags('enrol', 'user')]
class before_user_enrolment_removed {
/**
* Constructor for the hook.
*
* @param stdClass $enrolinstance The enrol instance.
* @param stdClass $userenrolmentinstance The user enrolment instance.
*/
public function __construct(
/** @var stdClass The enrol instance */
public readonly stdClass $enrolinstance,
/** @var stdClass The user enrolment instance */
public readonly stdClass $userenrolmentinstance,
) {
}
/**
* Get the user id.
*
* @return int
*/
public function get_userid(): int {
return $this->userenrolmentinstance->userid;
}
}
@@ -0,0 +1,59 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_enrol\hook;
use stdClass;
/**
* Hook before a user enrolment is updated.
*
* @package core_enrol
* @copyright 2024 Safat Shahin <safat.shahin@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
#[\core\attribute\label('Allows plugins or features to perform actions before a user enrolment is updated.')]
#[\core\attribute\tags('enrol', 'user')]
class before_user_enrolment_updated {
/**
* Constructor for the hook.
*
* @param stdClass $enrolinstance The enrol instance.
* @param stdClass $userenrolmentinstance The user enrolment instance.
* @param bool $statusmodified Whether the status of the enrolment has been modified.
* @param bool $timeendmodified Whether the time end of the enrolment has been modified.
*/
public function __construct(
/** @var stdClass The enrol instance */
public readonly stdClass $enrolinstance,
/** @var stdClass The user enrolment instance */
public readonly stdClass $userenrolmentinstance,
/** @var bool Whether the status of the enrolment has been modified */
public readonly bool $statusmodified,
/** @var bool Whether the time end of the enrolment has been modified */
public readonly bool $timeendmodified,
) {
}
/**
* Get the user id.
*
* @return int
*/
public function get_userid(): int {
return $this->userenrolmentinstance->userid;
}
}
+295
View File
@@ -0,0 +1,295 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// 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 core_enrol.
*
* @package core_enrol
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_enrol\privacy;
defined('MOODLE_INTERNAL') || die();
use core_privacy\local\metadata\collection;
use core_privacy\local\request\approved_contextlist;
use core_privacy\local\request\context;
use core_privacy\local\request\contextlist;
use core_privacy\local\request\transform;
use core_privacy\local\request\writer;
use core_privacy\local\request\userlist;
use \core_privacy\local\request\approved_userlist;
/**
* Privacy Subsystem for core_enrol implementing metadata and plugin providers.
*
* @copyright 2018 Carlos Escobedo <carlos@moodle.com>
* @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,
\core_privacy\local\request\subsystem\provider {
/**
* Returns meta data about this system.
*
* @param collection $collection The initialised collection to add items to.
* @return collection A listing of user data stored through this system.
*/
public static function get_metadata(collection $collection): collection {
$collection->add_database_table(
'user_enrolments',
[
'status' => 'privacy:metadata:user_enrolments:status',
'enrolid' => 'privacy:metadata:user_enrolments:enrolid',
'userid' => 'privacy:metadata:user_enrolments:userid',
'timestart' => 'privacy:metadata:user_enrolments:timestart',
'timeend' => 'privacy:metadata:user_enrolments:timeend',
'modifierid' => 'privacy:metadata:user_enrolments:modifierid',
'timecreated' => 'privacy:metadata:user_enrolments:timecreated',
'timemodified' => 'privacy:metadata:user_enrolments:timemodified'
],
'privacy:metadata:user_enrolments:tableexplanation'
);
return $collection;
}
/**
* Get the list of contexts that contain user information for the specified user.
*
* @param int $userid The user to search.
* @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
*/
public static function get_contexts_for_userid(int $userid): contextlist {
$sql = "SELECT ctx.id
FROM {user_enrolments} ue
JOIN {enrol} e
ON e.id = ue.enrolid
AND ue.userid = :userid
JOIN {context} ctx
ON ctx.instanceid = e.courseid
AND ctx.contextlevel = :contextlevel";
$params = [
'contextlevel' => CONTEXT_COURSE,
'userid' => $userid
];
$contextlist = new contextlist();
$contextlist->add_from_sql($sql, $params);
return $contextlist;
}
/**
* Get the list of users within a specific context.
*
* @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination.
*/
public static function get_users_in_context(userlist $userlist) {
$context = $userlist->get_context();
if (!$context instanceof \context_course) {
return;
}
$sql = "SELECT ue.userid as userid
FROM {user_enrolments} ue
JOIN {enrol} e ON e.id = ue.enrolid
WHERE e.courseid = ?";
$params = [$context->instanceid];
$userlist->add_from_sql('userid', $sql, $params);
}
/**
* Export all user data for the specified user, in the specified contexts.
*
* @param approved_contextlist $contextlist The approved contexts to export information for.
*/
public static function export_user_data(approved_contextlist $contextlist) {
global $DB;
if (empty($contextlist->count())) {
return;
}
$userid = $contextlist->get_user()->id;
list($insql, $inparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
$params = [
'contextlevel' => CONTEXT_COURSE,
'userid' => $userid
];
$params += $inparams;
$sql = "SELECT ue.id,
ue.status,
ue.timestart,
ue.timeend,
ue.timecreated,
ue.timemodified,
e.enrol,
ctx.id as contextid
FROM {user_enrolments} ue
JOIN {enrol} e
ON e.id = ue.enrolid
AND ue.userid = :userid
JOIN {context} ctx
ON ctx.instanceid = e.courseid
AND ctx.contextlevel = :contextlevel
WHERE ctx.id $insql
ORDER BY ctx.id, e.enrol";
$data = [];
$lastcontextid = null;
$lastenrol = null;
$path = [get_string('privacy:metadata:user_enrolments', 'core_enrol')];
$flush = function($lastcontextid, $lastenrol, $data) use ($path) {
$context = \context::instance_by_id($lastcontextid);
writer::with_context($context)->export_related_data(
$path,
$lastenrol,
(object)$data
);
};
$userenrolments = $DB->get_recordset_sql($sql, $params);
foreach ($userenrolments as $userenrolment) {
if (($lastcontextid && $lastcontextid != $userenrolment->contextid) ||
($lastenrol && $lastenrol != $userenrolment->enrol)) {
$flush($lastcontextid, $lastenrol, $data);
$data = [];
}
$data[] = (object) [
'status' => $userenrolment->status,
'timecreated' => transform::datetime($userenrolment->timecreated),
'timemodified' => transform::datetime($userenrolment->timemodified),
'timestart' => transform::datetime($userenrolment->timestart),
'timeend' => transform::datetime($userenrolment->timeend)
];
$lastcontextid = $userenrolment->contextid;
$lastenrol = $userenrolment->enrol;
}
if (!empty($data)) {
$flush($lastcontextid, $lastenrol, $data);
}
$userenrolments->close();
}
/**
* Delete all data for all users in the specified context.
*
* @param \context $context The specific context to delete data for.
*/
public static function delete_data_for_all_users_in_context(\context $context) {
global $DB;
// Sanity check that context is at the User context level.
if ($context->contextlevel == CONTEXT_COURSE) {
$sql = "SELECT ue.id
FROM {user_enrolments} ue
JOIN {enrol} e ON e.id = ue.enrolid
WHERE e.courseid = :courseid";
$params = ['courseid' => $context->instanceid];
$enrolsids = $DB->get_fieldset_sql($sql, $params);
if (!empty($enrolsids)) {
list($insql, $inparams) = $DB->get_in_or_equal($enrolsids, SQL_PARAMS_NAMED);
static::delete_user_data($insql, $inparams);
}
}
}
/**
* Delete multiple users within a single context.
*
* @param approved_userlist $userlist The approved context and user information to delete information for.
*/
public static function delete_data_for_users(approved_userlist $userlist) {
global $DB;
$context = $userlist->get_context();
if ($context instanceof \context_course) {
list($usersql, $userparams) = $DB->get_in_or_equal($userlist->get_userids(), SQL_PARAMS_NAMED);
$sql = "SELECT ue.id
FROM {user_enrolments} ue
JOIN {enrol} e ON e.id = ue.enrolid
WHERE e.courseid = :courseid
AND ue.userid {$usersql}";
$params = ['courseid' => $context->instanceid] + $userparams;
$enrolsids = $DB->get_fieldset_sql($sql, $params);
if (!empty($enrolsids)) {
list($insql, $inparams) = $DB->get_in_or_equal($enrolsids, SQL_PARAMS_NAMED);
static::delete_user_data($insql, $inparams);
}
}
}
/**
* Delete all user data for the specified user, in the specified contexts.
*
* @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
*/
public static function delete_data_for_user(approved_contextlist $contextlist) {
global $DB;
if (empty($contextlist->count())) {
return;
}
$userid = $contextlist->get_user()->id;
list($insql, $inparams) = $DB->get_in_or_equal($contextlist->get_contextids(), SQL_PARAMS_NAMED);
$params = [
'contextlevel' => CONTEXT_COURSE,
'userid' => $userid
];
$params += $inparams;
$sql = "SELECT ue.id
FROM {user_enrolments} ue
JOIN {enrol} e
ON e.id = ue.enrolid
AND ue.userid = :userid
JOIN {context} ctx
ON ctx.instanceid = e.courseid
AND ctx.contextlevel = :contextlevel
WHERE ctx.id $insql";
$enrolsids = $DB->get_fieldset_sql($sql, $params);
if (!empty($enrolsids)) {
list($insql, $inparams) = $DB->get_in_or_equal($enrolsids, SQL_PARAMS_NAMED);
static::delete_user_data($insql, $inparams);
}
}
/**
* Delete data from $tablename with the IDs returned by $sql query.
*
* @param string $sql SQL query for getting the IDs of the uer enrolments entries to delete.
* @param array $params SQL params for the query.
*/
protected static function delete_user_data(string $sql, array $params) {
global $DB;
$DB->delete_records_select('user_enrolments', "id $sql", $params);
}
/**
* Get the subcontext for export.
*
* @param array $subcontext Any additional subcontext to use.
* @return array The array containing the full subcontext, i.e. [enrolments, subcontext]
*/
public static function get_subcontext(array $subcontext) {
return array_merge(
[get_string('privacy:metadata:user_enrolments', 'core_enrol')],
$subcontext
);
}
}
@@ -0,0 +1,260 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core_enrol\reportbuilder\local\entities;
use enrol_plugin;
use lang_string;
use stdClass;
use core_reportbuilder\local\entities\base;
use core_reportbuilder\local\filters\{boolean_select, date, duration, select, text};
use core_reportbuilder\local\helpers\format;
use core_reportbuilder\local\report\{column, filter};
/**
* Enrolment method entity
*
* @package core_enrol
* @copyright 2023 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class enrol extends base {
/**
* Database tables that this entity uses
*
* @return string[]
*/
protected function get_default_tables(): array {
return [
'enrol',
];
}
/**
* The default title for this entity
*
* @return lang_string
*/
protected function get_default_entity_title(): lang_string {
return new lang_string('enrolmentmethod', 'core_enrol');
}
/**
* Initialise the entity
*
* @return base
*/
public function initialise(): base {
$columns = $this->get_all_columns();
foreach ($columns as $column) {
$this->add_column($column);
}
// All the filters defined by the entity can also be used as conditions.
$filters = $this->get_all_filters();
foreach ($filters as $filter) {
$this
->add_filter($filter)
->add_condition($filter);
}
return $this;
}
/**
* Returns list of all available columns
*
* @return column[]
*/
protected function get_all_columns(): array {
global $DB;
$enrolalias = $this->get_table_alias('enrol');
// Plugin column.
$columns[] = (new column(
'plugin',
new lang_string('plugin'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TEXT)
->add_fields("{$enrolalias}.enrol")
->set_is_sortable(true)
->set_callback(static function(?string $enrol): string {
if ($enrol === null || !$plugin = enrol_get_plugin($enrol)) {
return '';
}
return $plugin->get_instance_name(null);
});
// Name column.
$columns[] = (new column(
'name',
new lang_string('name'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TEXT)
->add_fields("{$enrolalias}.enrol, {$enrolalias}.name, {$enrolalias}.courseid, " .
"{$enrolalias}.roleid, {$enrolalias}.customint1")
->set_is_sortable(true)
->set_callback(static function(?string $enrol, stdClass $instance): string {
if ($enrol === null || !$plugin = enrol_get_plugin($enrol)) {
return '';
}
return $plugin->get_instance_name($instance);
});
// Enabled column.
$columns[] = (new column(
'enabled',
new lang_string('enabled', 'core_admin'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_BOOLEAN)
// For accurate aggregation, we need to return boolean enabled = true by xor'ing the field value.
->add_field($DB->sql_bitxor("{$enrolalias}.status", 1), 'status')
->set_is_sortable(true)
->set_callback([format::class, 'boolean_as_text']);
// Period column.
$columns[] = (new column(
'period',
new lang_string('enrolperiod', 'core_enrol'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TIMESTAMP)
->add_fields("{$enrolalias}.enrolperiod")
->set_is_sortable(true)
->set_callback(static function(?int $enrolperiod): string {
if (!$enrolperiod) {
return '';
}
return format_time($enrolperiod);
});
// Start date column.
$columns[] = (new column(
'startdate',
new lang_string('enroltimestart', 'core_enrol'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TIMESTAMP)
->add_fields("{$enrolalias}.enrolstartdate")
->set_is_sortable(true)
->set_callback([format::class, 'userdate']);
// End date column.
$columns[] = (new column(
'enddate',
new lang_string('enroltimeend', 'core_enrol'),
$this->get_entity_name()
))
->add_joins($this->get_joins())
->set_type(column::TYPE_TIMESTAMP)
->add_fields("{$enrolalias}.enrolenddate")
->set_is_sortable(true)
->set_callback([format::class, 'userdate']);
return $columns;
}
/**
* Return list of all available filters
*
* @return filter[]
*/
protected function get_all_filters(): array {
global $DB;
$enrolalias = $this->get_table_alias('enrol');
// Plugin filter.
$filters[] = (new filter(
select::class,
'plugin',
new lang_string('plugin'),
$this->get_entity_name(),
"{$enrolalias}.enrol"
))
->add_joins($this->get_joins())
->set_options_callback(static function(): array {
return array_map(static function(enrol_plugin $plugin): string {
return $plugin->get_instance_name(null);
}, enrol_get_plugins(true));
});
// Custom name filter.
$filters[] = (new filter(
text::class,
'customname',
new lang_string('custominstancename', 'core_enrol'),
$this->get_entity_name(),
"{$enrolalias}.name"
))
->add_joins($this->get_joins());
// Enabled filter.
$filters[] = (new filter(
boolean_select::class,
'enabled',
new lang_string('enabled', 'core_admin'),
$this->get_entity_name(),
$DB->sql_bitxor("{$enrolalias}.status", 1)
))
->add_joins($this->get_joins());
// Period filter.
$filters[] = (new filter(
duration::class,
'period',
new lang_string('enrolperiod', 'core_enrol'),
$this->get_entity_name(),
"{$enrolalias}.enrolperiod"
))
->add_joins($this->get_joins());
// Start date filter.
$filters[] = (new filter(
date::class,
'startdate',
new lang_string('enroltimestart', 'core_enrol'),
$this->get_entity_name(),
"{$enrolalias}.enrolstartdate"
))
->add_joins($this->get_joins());
// End date filter.
$filters[] = (new filter(
date::class,
'enddate',
new lang_string('enroltimeend', 'core_enrol'),
$this->get_entity_name(),
"{$enrolalias}.enrolenddate"
))
->add_joins($this->get_joins());
return $filters;
}
}