Skip to content

Commit

Permalink
fix code checker errors using phpcbf
Browse files Browse the repository at this point in the history
  • Loading branch information
my-curiosity committed Dec 12, 2023
1 parent f5ed877 commit 94d899e
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 38 deletions.
34 changes: 21 additions & 13 deletions block_overviewmyrolesincourses.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ public function get_content() {
$data->roleshortname = $rolefixname->shortname;
$data->rolelocalname = $rolefixname->localname;
$data->foldonstart = $foldonstart;
$data->mylist = $this->get_courses_enroled_with_roleid($USER->id,
$enroledcourses, $rolefixname->id, $favouritecourseids);
$data->mylist = $this->get_courses_enroled_with_roleid(
$USER->id,
$enroledcourses,
$rolefixname->id,
$favouritecourseids
);
$data->counter = count($data->mylist);
// To get example-json for mustache uncomment following line of code.
// This can be uses to get a json-example $objectasjson = json_encode($data);
Expand All @@ -101,7 +105,7 @@ public function get_content() {
$text .= $this->create_agenda();
}

$this->content = new stdClass;
$this->content = new stdClass();
$this->content->text = $text;
$footer = '';
$this->content->footer = $footer;
Expand All @@ -120,10 +124,12 @@ public function get_content() {
* @throws dml_exception
* @throws moodle_exception
*/
public function get_courses_enroled_with_roleid(string $userid,
array $enroledcourses,
string $roleid,
array $favouritecourseids = []): array {
public function get_courses_enroled_with_roleid(
string $userid,
array $enroledcourses,
string $roleid,
array $favouritecourseids = []
): array {
$result = [];
foreach ($enroledcourses as $enroledcourse) {
$coursecontext = context_course::instance($enroledcourse->id);
Expand Down Expand Up @@ -220,7 +226,7 @@ public function has_config() {
private function create_duration(stdClass $course): stdClass {
global $DB;
$now = time();
$startdate = userdate($course->startdate, get_string('strftimedatefullshort', 'core_langconfig'));
$startdate = userdate($course->startdate, get_string('strftimedatefullshort', 'core_langconfig'));

// Code: course->enddate is empty if function enrol_get_my_courses() was used.
$courserecord = $DB->get_record('course', ['id' => $course->id]);
Expand Down Expand Up @@ -313,13 +319,13 @@ public function create_agenda(): string {
* @return boolean
*/
public function instance_create() {
$data = array(
$data = [
'showpast' => get_config('block_overviewmyrolesincourses', 'defaultshowpast'),
'showinprogress' => get_config('block_overviewmyrolesincourses', 'defaultshowinprogress'),
'showfuture' => get_config('block_overviewmyrolesincourses', 'defaultshowfuture'),
'onlyfavourite' => get_config('block_overviewmyrolesincourses', 'defaultonlyshowfavourite'),
'foldonstart' => get_config('block_overviewmyrolesincourses', 'defaultfoldonstart')
);
'foldonstart' => get_config('block_overviewmyrolesincourses', 'defaultfoldonstart'),
];
$this->instance_config_save($data);
return true;
}
Expand All @@ -337,9 +343,11 @@ public function get_favourite_course_ids($userid): array {
$favourites = $ufservice->find_favourites_by_type('core_course', 'courses');
if ($favourites) {
$favouritecourseids = array_map(
function($favourite) {
function ($favourite) {
return $favourite->itemid;
}, $favourites);
},
$favourites
);
}
return $favouritecourseids;
}
Expand Down
28 changes: 14 additions & 14 deletions db/access.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@

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

$capabilities = array(
'block/overviewmyrolesincourses:myaddinstance' => array(
$capabilities = [
'block/overviewmyrolesincourses:myaddinstance' => [
'captype' => 'write',
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => array(
'archetypes' => [
'user' => CAP_ALLOW,
),
),
],
],

'block/overviewmyrolesincourses:addinstance' => array(
'block/overviewmyrolesincourses:addinstance' => [
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'write',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'archetypes' => [
'user' => CAP_ALLOW,
),
),
],
],

'block/overviewmyrolesincourses:viewcontent' => array(
'block/overviewmyrolesincourses:viewcontent' => [
'riskbitmask' => RISK_SPAM | RISK_XSS,
'captype' => 'read',
'contextlevel' => CONTEXT_BLOCK,
'archetypes' => array(
'archetypes' => [
'user' => CAP_ALLOW,
),
)
);
],
],
];
10 changes: 5 additions & 5 deletions edit_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,23 @@ protected function specific_definition($mform) {
$mform->addElement('header', 'config_header', get_string('blocksettings', 'block'));

$name = get_string('showpast', 'block_overviewmyrolesincourses');
$mform->addElement('advcheckbox', 'config_showpast', $name, '', array('group' => 1), array(0, 1));
$mform->addElement('advcheckbox', 'config_showpast', $name, '', ['group' => 1], [0, 1]);
$mform->setDefault('config_showpast', 0);

$name = get_string('showinprogress', 'block_overviewmyrolesincourses');
$mform->addElement('advcheckbox', 'config_showinprogress', $name, '', array('group' => 2), array(0, 1));
$mform->addElement('advcheckbox', 'config_showinprogress', $name, '', ['group' => 2], [0, 1]);
$mform->setDefault('config_showinprogress', 0);

$name = get_string('showfuture', 'block_overviewmyrolesincourses');
$mform->addElement('advcheckbox', 'config_showfuture', $name, '', array('group' => 3), array(0, 1));
$mform->addElement('advcheckbox', 'config_showfuture', $name, '', ['group' => 3], [0, 1]);
$mform->setDefault('config_showfuture', 0);

$name = get_string('onlyfavourite', 'block_overviewmyrolesincourses');
$mform->addElement('advcheckbox', 'config_onlyfavourite', $name, '', array('group' => 4), array(0, 1));
$mform->addElement('advcheckbox', 'config_onlyfavourite', $name, '', ['group' => 4], [0, 1]);
$mform->setDefault('config_onlyfavourite', 0);

$name = get_string('foldonstart', 'block_overviewmyrolesincourses');
$mform->addElement('advcheckbox', 'config_foldonstart', $name, '', array('group' => 5), array(0, 1));
$mform->addElement('advcheckbox', 'config_foldonstart', $name, '', ['group' => 5], [0, 1]);
$mform->setDefault('config_foldonstart', 0);
}
}
3 changes: 1 addition & 2 deletions privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {

/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
10 changes: 6 additions & 4 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

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

$settings = new admin_settingpage( 'block_overviewmyrolesincourses', get_string('pluginname', 'block_overviewmyrolesincourses') );
$settings = new admin_settingpage('block_overviewmyrolesincourses', get_string('pluginname', 'block_overviewmyrolesincourses'));
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_configcheckbox(
'block_overviewmyrolesincourses/isactiv',
Expand All @@ -47,10 +47,13 @@
$rolename->localname;
}
}
$settings->add(new admin_setting_configmultiselect('block_overviewmyrolesincourses/supportedroles',
$settings->add(new admin_setting_configmultiselect(
'block_overviewmyrolesincourses/supportedroles',
get_string('supportedroles', 'block_overviewmyrolesincourses'),
get_string('supportedroles_desc', 'block_overviewmyrolesincourses'),
array_keys($options), $options));
array_keys($options),
$options
));

$settings->add(new admin_setting_configcheckbox(
'block_overviewmyrolesincourses/showdeleteicon',
Expand Down Expand Up @@ -89,5 +92,4 @@
get_string('defaultonlyshowfavourite_desc', 'block_overviewmyrolesincourses'),
0
));

}

0 comments on commit 94d899e

Please sign in to comment.