Skip to content

Commit 4ea79cc

Browse files
committed
Make codechecker happy again
1 parent b6b4476 commit 4ea79cc

File tree

7 files changed

+135
-86
lines changed

7 files changed

+135
-86
lines changed

classes/bulkenrol_form.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
global $CFG;
3232

33-
require_once($CFG->libdir.'/formslib.php');
33+
require_once($CFG->libdir . '/formslib.php');
3434

3535
/**
3636
* Class bulkenrol_form
@@ -39,33 +39,38 @@
3939
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4040
*/
4141
class bulkenrol_form extends moodleform {
42-
4342
/**
4443
* Form definition. Abstract method - always override!
4544
*/
4645
protected function definition() {
4746
global $CFG, $SESSION;
4847

49-
require_once($CFG->dirroot.'/local/bulkenrol/lib.php');
48+
require_once($CFG->dirroot . '/local/bulkenrol/lib.php');
5049

5150
$mform = $this->_form;
5251

5352
// Infotext.
5453
$msg = get_string('bulkenrol_form_intro', 'local_bulkenrol');
55-
$mform->addElement('html', '<div id="intro">'.$msg.'</div>');
54+
$mform->addElement('html', '<div id="intro">' . $msg . '</div>');
5655

5756
// Textarea for Emails.
58-
$mform->addElement('textarea', 'usermails',
59-
get_string('usermails', 'local_bulkenrol'), 'wrap="virtual" rows="10" cols="80"');
57+
$mform->addElement(
58+
'textarea',
59+
'usermails',
60+
get_string('usermails', 'local_bulkenrol'),
61+
'wrap="virtual" rows="10" cols="80"'
62+
);
6063
$mform->addRule('usermails', null, 'required');
6164
$mform->addHelpButton('usermails', 'usermails', 'local_bulkenrol');
6265

6366
// Add form content if the user came back to check his input.
6467
$localbulkenroleditlist = optional_param('editlist', 0, PARAM_ALPHANUMEXT);
6568
if (!empty($localbulkenroleditlist)) {
66-
$localbulkenroldata = $localbulkenroleditlist.'_data';
67-
if (!empty($localbulkenroldata) && !empty($SESSION->local_bulkenrol_inputs) &&
68-
array_key_exists($localbulkenroldata, $SESSION->local_bulkenrol_inputs)) {
69+
$localbulkenroldata = $localbulkenroleditlist . '_data';
70+
if (
71+
!empty($localbulkenroldata) && !empty($SESSION->local_bulkenrol_inputs) &&
72+
array_key_exists($localbulkenroldata, $SESSION->local_bulkenrol_inputs)
73+
) {
6974
$formdatatmp = $SESSION->local_bulkenrol_inputs[$localbulkenroldata];
7075
$mform->setDefault('usermails', $formdatatmp);
7176
}

classes/confirm_form.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
global $CFG;
3232

33-
require_once($CFG->libdir.'/formslib.php');
33+
require_once($CFG->libdir . '/formslib.php');
3434

3535
/**
3636
* Class confirm_form
@@ -39,7 +39,6 @@
3939
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
4040
*/
4141
class confirm_form extends moodleform {
42-
4342
/**
4443
* Form definition. Abstract method - always override!
4544
*/

classes/privacy/provider.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
3333
*/
3434
class provider implements \core_privacy\local\metadata\null_provider {
35-
3635
/**
3736
* Get the language string identifier with the component's language
3837
* file to explain why this plugin stores no data.

index.php

Lines changed: 35 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
require_once('../../config.php');
2929

30-
require_once($CFG->libdir.'/adminlib.php');
31-
require_once($CFG->dirroot.'/local/bulkenrol/locallib.php');
30+
require_once($CFG->libdir . '/adminlib.php');
31+
require_once($CFG->dirroot . '/local/bulkenrol/locallib.php');
3232

3333
global $PAGE, $OUTPUT, $SESSION;
3434

@@ -43,7 +43,7 @@
4343

4444
$PAGE->set_context($context);
4545
$PAGE->set_url('/local/bulkenrol/index.php', ['id' => $id]);
46-
$PAGE->set_title("$course->shortname: ".get_string('pluginname', 'local_bulkenrol'));
46+
$PAGE->set_title("$course->shortname: " . get_string('pluginname', 'local_bulkenrol'));
4747
$PAGE->set_heading($course->fullname);
4848

4949
require_login($course);
@@ -69,18 +69,18 @@
6969
$SESSION->local_bulkenrol = [];
7070
}
7171
// Save data in Session.
72-
$localbulkenrolkey = $courseid.'_'.time();
72+
$localbulkenrolkey = $courseid . '_' . time();
7373
$SESSION->local_bulkenrol[$localbulkenrolkey] = $checkedmails;
7474

7575
// Create local_bulkenrol_inputs array in session.
7676
if (!isset($SESSION->local_bulkenrol_inputs)) {
7777
$SESSION->local_bulkenrol_inputs = [];
7878
}
79-
$localbulkenroldata = $localbulkenrolkey.'_data';
79+
$localbulkenroldata = $localbulkenrolkey . '_data';
8080
$SESSION->local_bulkenrol_inputs[$localbulkenroldata] = $emails;
8181
} else if ($form->is_cancelled()) {
8282
if (!empty($id)) {
83-
redirect($CFG->wwwroot .'/course/view.php?id='.$id, '', 0);
83+
redirect($CFG->wwwroot . '/course/view.php?id=' . $id, '', 0);
8484
} else {
8585
redirect($CFG->wwwroot, '', 0);
8686
}
@@ -96,30 +96,43 @@
9696
$form2 = new confirm_form(null, ['local_bulkenrol_key' => $localbulkenrolkey, 'courseid' => $id]);
9797

9898
if ($formdata = $form2->get_data()) {
99-
if (!empty($localbulkenrolkey) && !empty($SESSION->local_bulkenrol) &&
100-
array_key_exists($localbulkenrolkey, $SESSION->local_bulkenrol)) {
99+
if (
100+
!empty($localbulkenrolkey) && !empty($SESSION->local_bulkenrol) &&
101+
array_key_exists($localbulkenrolkey, $SESSION->local_bulkenrol)
102+
) {
101103
set_time_limit(600);
102104

103105
$msg = local_bulkenrol_users($localbulkenrolkey);
104106

105107
if ($msg->status == 'error') {
106-
redirect($CFG->wwwroot .'/user/index.php?id='.$id, "$msg->text", null, \core\output\notification::NOTIFY_ERROR);
108+
redirect(
109+
$CFG->wwwroot . '/user/index.php?id=' . $id,
110+
"$msg->text",
111+
null,
112+
\core\output\notification::NOTIFY_ERROR
113+
);
107114
} else {
108-
redirect($CFG->wwwroot .'/user/index.php?id='.$id, "$msg->text", null, \core\output\notification::NOTIFY_SUCCESS);
115+
redirect(
116+
$CFG->wwwroot . '/user/index.php?id=' . $id,
117+
"$msg->text",
118+
null,
119+
\core\output\notification::NOTIFY_SUCCESS
120+
);
109121
}
110-
111122
} else {
112-
redirect($CFG->wwwroot .'/local/bulkenrol/index.php?id='.$id, '', 0);
123+
redirect($CFG->wwwroot . '/local/bulkenrol/index.php?id=' . $id, '', 0);
113124
}
114125
} else if ($form2->is_cancelled()) {
115-
redirect($CFG->wwwroot .'/local/bulkenrol/index.php?id='.$id, '', 0);
126+
redirect($CFG->wwwroot . '/local/bulkenrol/index.php?id=' . $id, '', 0);
116127
} else {
117128
$PAGE->set_url('/local/bulkenrol/index.php', ['id' => $id]);
118129

119130
echo $OUTPUT->header();
120131
echo $OUTPUT->heading(get_string('pluginname', 'local_bulkenrol'));
121-
if (!empty($localbulkenrolkey) && !empty($SESSION->local_bulkenrol) &&
122-
array_key_exists($localbulkenrolkey, $SESSION->local_bulkenrol)) {
132+
if (
133+
!empty($localbulkenrolkey) && !empty($SESSION->local_bulkenrol) &&
134+
array_key_exists($localbulkenrolkey, $SESSION->local_bulkenrol)
135+
) {
123136
$localbulkenroldata = $SESSION->local_bulkenrol[$localbulkenrolkey];
124137

125138
if (!empty($localbulkenroldata)) {
@@ -131,14 +144,17 @@
131144
}
132145

133146
// Show notification if there aren't any valid email addresses to enrol.
134-
if (!empty($localbulkenroldata) && isset($localbulkenroldata->validemailfound) &&
135-
empty($localbulkenroldata->validemailfound)) {
147+
if (
148+
!empty($localbulkenroldata) && isset($localbulkenroldata->validemailfound) &&
149+
empty($localbulkenroldata->validemailfound)
150+
) {
136151
$a = new stdClass();
137152
$url = new \core\url('/local/bulkenrol/index.php', ['id' => $id, 'editlist' => $localbulkenrolkey]);
138153
$a->url = $url->out();
139154
$notification = new \core\output\notification(
140-
get_string('error_no_valid_email_in_list', 'local_bulkenrol', $a),
141-
\core\output\notification::NOTIFY_WARNING);
155+
get_string('error_no_valid_email_in_list', 'local_bulkenrol', $a),
156+
\core\output\notification::NOTIFY_WARNING
157+
);
142158
$notification->set_show_closebutton(false);
143159
echo $OUTPUT->render($notification);
144160

lib.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ function local_bulkenrol_extend_navigation_course($navigation, $course, $context
3737
if (has_capability('local/bulkenrol:enrolusers', $context)) {
3838
// Create the navigation node.
3939
$url = new \core\url('/local/bulkenrol/index.php', ['id' => $course->id]);
40-
$bulkenrolnode = navigation_node::create(get_string('pluginname', 'local_bulkenrol'), $url,
41-
navigation_node::TYPE_SETTING, null, 'local_bulkenrol', new \core\output\pix_icon('i/users', ''));
40+
$bulkenrolnode = navigation_node::create(
41+
get_string('pluginname', 'local_bulkenrol'),
42+
$url,
43+
navigation_node::TYPE_SETTING,
44+
null,
45+
'local_bulkenrol',
46+
new \core\output\pix_icon('i/users', '')
47+
);
4248

4349
// Get the navigation node placement setting.
4450
$navigationplacement = get_config('local_bulkenrol', 'navigation');

0 commit comments

Comments
 (0)