|
27 | 27 |
|
28 | 28 | require_once('../../config.php'); |
29 | 29 |
|
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'); |
32 | 32 |
|
33 | 33 | global $PAGE, $OUTPUT, $SESSION; |
34 | 34 |
|
|
43 | 43 |
|
44 | 44 | $PAGE->set_context($context); |
45 | 45 | $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')); |
47 | 47 | $PAGE->set_heading($course->fullname); |
48 | 48 |
|
49 | 49 | require_login($course); |
|
69 | 69 | $SESSION->local_bulkenrol = []; |
70 | 70 | } |
71 | 71 | // Save data in Session. |
72 | | - $localbulkenrolkey = $courseid.'_'.time(); |
| 72 | + $localbulkenrolkey = $courseid . '_' . time(); |
73 | 73 | $SESSION->local_bulkenrol[$localbulkenrolkey] = $checkedmails; |
74 | 74 |
|
75 | 75 | // Create local_bulkenrol_inputs array in session. |
76 | 76 | if (!isset($SESSION->local_bulkenrol_inputs)) { |
77 | 77 | $SESSION->local_bulkenrol_inputs = []; |
78 | 78 | } |
79 | | - $localbulkenroldata = $localbulkenrolkey.'_data'; |
| 79 | + $localbulkenroldata = $localbulkenrolkey . '_data'; |
80 | 80 | $SESSION->local_bulkenrol_inputs[$localbulkenroldata] = $emails; |
81 | 81 | } else if ($form->is_cancelled()) { |
82 | 82 | if (!empty($id)) { |
83 | | - redirect($CFG->wwwroot .'/course/view.php?id='.$id, '', 0); |
| 83 | + redirect($CFG->wwwroot . '/course/view.php?id=' . $id, '', 0); |
84 | 84 | } else { |
85 | 85 | redirect($CFG->wwwroot, '', 0); |
86 | 86 | } |
|
96 | 96 | $form2 = new confirm_form(null, ['local_bulkenrol_key' => $localbulkenrolkey, 'courseid' => $id]); |
97 | 97 |
|
98 | 98 | 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 | + ) { |
101 | 103 | set_time_limit(600); |
102 | 104 |
|
103 | 105 | $msg = local_bulkenrol_users($localbulkenrolkey); |
104 | 106 |
|
105 | 107 | 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 | + ); |
107 | 114 | } 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 | + ); |
109 | 121 | } |
110 | | - |
111 | 122 | } else { |
112 | | - redirect($CFG->wwwroot .'/local/bulkenrol/index.php?id='.$id, '', 0); |
| 123 | + redirect($CFG->wwwroot . '/local/bulkenrol/index.php?id=' . $id, '', 0); |
113 | 124 | } |
114 | 125 | } 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); |
116 | 127 | } else { |
117 | 128 | $PAGE->set_url('/local/bulkenrol/index.php', ['id' => $id]); |
118 | 129 |
|
119 | 130 | echo $OUTPUT->header(); |
120 | 131 | 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 | + ) { |
123 | 136 | $localbulkenroldata = $SESSION->local_bulkenrol[$localbulkenrolkey]; |
124 | 137 |
|
125 | 138 | if (!empty($localbulkenroldata)) { |
|
131 | 144 | } |
132 | 145 |
|
133 | 146 | // 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 | + ) { |
136 | 151 | $a = new stdClass(); |
137 | 152 | $url = new \core\url('/local/bulkenrol/index.php', ['id' => $id, 'editlist' => $localbulkenrolkey]); |
138 | 153 | $a->url = $url->out(); |
139 | 154 | $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 | + ); |
142 | 158 | $notification->set_show_closebutton(false); |
143 | 159 | echo $OUTPUT->render($notification); |
144 | 160 |
|
|
0 commit comments