-
Notifications
You must be signed in to change notification settings - Fork 38
/
renderer.php
211 lines (180 loc) · 9.22 KB
/
renderer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?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/>.
/**
*
* @package enrol_apply
* @copyright 2016 sudile GbR (http://www.sudile.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Johannes Burk <[email protected]>
*/
defined('MOODLE_INTERNAL') || die();
class enrol_apply_renderer extends plugin_renderer_base {
public function manage_page($table, $manageurl, $instance) {
echo $this->header();
echo $this->heading(get_string('confirmusers', 'enrol_apply'));
echo get_string('confirmusers_desc', 'enrol_apply');
$this->manage_form($table, $manageurl, $instance);
echo $this->footer();
}
public function edit_page($mform) {
echo $this->header();
echo $this->heading(get_string('pluginname', 'enrol_apply'));
$mform->display();
echo $this->footer();
}
public function manage_form($table, $manageurl, $instance) {
echo html_writer::start_tag('form', array(
'id' => 'enrol_apply_manage_form',
'method' => 'post',
'action' => $manageurl->out()));
$this->manage_table($table, $instance);
if ($table->totalrows > 0) {
echo html_writer::empty_tag('br');
echo html_writer::start_tag('div', array('class' => 'formaction'));
$formactions = array(
'confirm' => get_string('btnconfirm', 'enrol_apply'),
'wait' => get_string('btnwait', 'enrol_apply'),
'cancel' => get_string('btncancel', 'enrol_apply'));
echo html_writer::tag('label', get_string('withselectedusers'), array('for' => 'formaction'));
echo html_writer::select($formactions, 'formaction', '', array('' => 'choosedots'), array('id' => 'formaction'));
echo html_writer::tag('noscript',
html_writer::empty_tag('input', array('type' => 'submit', get_string('submit'))),
array('style' => 'display: inline;'));
echo html_writer::end_tag('div');
$this->page->requires->js_call_amd('enrol_apply/manage', 'init');
}
echo html_writer::end_tag('form');
}
public function info_page($table, $manageurl,$instance) {
echo $this->header();
echo $this->heading(get_string('submitted_info', 'enrol_apply'));
echo get_string('submitted_info', 'enrol_apply');
$this->info_form($table, $manageurl,$instance);
echo $this->footer();
}
public function manage_table($table, $instance) {
global $DB;
$extra = get_config('enrol_apply', 'profileoption');
if($extra) {
$field = $DB->get_record("user_info_field", array("id" => $extra));
$columns = array(
'checkboxcolumn',
'course',
'fullname', // Magic happens here: The column heading will automatically be set.
'email',
'applydate',
'field',
'applycomment');
$headers = array(
html_writer::checkbox('toggleall', 'toggleall', false, '', array('id' => 'toggleall')),
get_string('course'),
'fullname', // Magic happens here: The column heading will automatically be set due to column name 'fullname'.
get_string('email'),
get_string('applydate', 'enrol_apply'),
$field->name,
get_string('applycomment', 'enrol_apply'),
);
}
else{
$columns = array(
'checkboxcolumn',
'course',
'fullname', // Magic happens here: The column heading will automatically be set.
'email',
'applydate',
'applycomment');
$headers = array(
html_writer::checkbox('toggleall', 'toggleall', false, '', array('id' => 'toggleall')),
get_string('course'),
'fullname', // Magic happens here: The column heading will automatically be set due to column name 'fullname'.
get_string('email'),
get_string('applydate', 'enrol_apply'),
get_string('applycomment', 'enrol_apply'),
);
}
$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'id');
$table->out(50, true);
}
public function info_form($table, $manageurl,$instance) {
echo html_writer::start_tag('form', array(
'id' => 'enrol_apply_info_form',
'method' => 'post',
'action' => $manageurl->out()));
$this->info_table($table,$instance);
if ($table->totalrows > 0) {
echo html_writer::empty_tag('br');
echo html_writer::start_tag('div', array('class' => 'formaction'));
echo html_writer::end_tag('div');
$this->page->requires->js_call_amd('enrol_apply/info', 'init');
}
echo html_writer::end_tag('form');
}
public function info_table($table,$instance) {
$columns = array(
'fullname',
'applycomment');
$headers = array(
'User', // Magic happens here: The column heading will automatically be set due to column name 'fullname'.
$instance->customtext2);
$table->define_columns($columns);
$table->define_headers($headers);
$table->sortable(true, 'id');
$table->out(50, true);
}
public function application_notification_mail_body(
$course, $user, $manageurl, $applydescription, $standarduserfields = null, $extrauserfields = null) {
$body = '<p>'. get_string('coursename', 'enrol_apply') .': '.format_string($course->fullname).'</p>';
$body .= '<p>'. get_string('applyuser', 'enrol_apply') .': '.$user->firstname.' '.$user->lastname.'</p>';
$body .= '<p>'. get_string('comment', 'enrol_apply') .': '.$applydescription.'</p>';
if ($standarduserfields) {
$body .= '<p><strong>'. get_string('user_profile', 'enrol_apply').'</strong></p>';
$body .= '<p>'. get_string('firstname') .': '.$standarduserfields->firstname.'</p>';
$body .= '<p>'. get_string('lastname') .': '.$standarduserfields->lastname.'</p>';
$body .= '<p>'. get_string('email') .': '.$standarduserfields->email.'</p>';
$body .= '<p>'. get_string('city') .': '.$standarduserfields->city.'</p>';
$body .= '<p>'. get_string('country') .': '.$standarduserfields->country.'</p>';
if(isset($standarduserfields->lang)){
$body .= '<p>'. get_string('preferredlanguage') .': '.$standarduserfields->lang.'</p>';
}
$body .= '<p>'. get_string('description') .': '.$standarduserfields->description_editor['text'].'</p>';
$body .= '<p>'. get_string('firstnamephonetic') .': '.$standarduserfields->firstnamephonetic.'</p>';
$body .= '<p>'. get_string('lastnamephonetic') .': '.$standarduserfields->lastnamephonetic.'</p>';
$body .= '<p>'. get_string('middlename') .': '.$standarduserfields->middlename.'</p>';
$body .= '<p>'. get_string('alternatename') .': '.$standarduserfields->alternatename.'</p>';
$body .= '<p>'. get_string('url') .': '.$standarduserfields->url.'</p>';
$body .= '<p>'. get_string('icqnumber') .': '.$standarduserfields->icq.'</p>';
$body .= '<p>'. get_string('skypeid') .': '.$standarduserfields->skype.'</p>';
$body .= '<p>'. get_string('aimid') .': '.$standarduserfields->aim.'</p>';
$body .= '<p>'. get_string('yahooid') .': '.$standarduserfields->yahoo.'</p>';
$body .= '<p>'. get_string('msnid') .': '.$standarduserfields->msn.'</p>';
$body .= '<p>'. get_string('idnumber') .': '.$standarduserfields->idnumber.'</p>';
$body .= '<p>'. get_string('institution') .': '.$standarduserfields->institution.'</p>';
$body .= '<p>'. get_string('department') .': '.$standarduserfields->department.'</p>';
$body .= '<p>'. get_string('phone') .': '.$standarduserfields->phone1.'</p>';
$body .= '<p>'. get_string('phone2') .': '.$standarduserfields->phone2.'</p>';
$body .= '<p>'. get_string('address') .': '.$standarduserfields->address.'</p>';
}
if ($extrauserfields) {
foreach ($extrauserfields as $key => $value) {
$body .= '<p>'. $key .': '.$value.'</p>';
}
}
$body .= '<p>'. html_writer::link($manageurl, get_string('applymanage', 'enrol_apply')).'</p>';
return $body;
}
}