forked from totara/facetoface-2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod_form.php
185 lines (143 loc) · 9.83 KB
/
mod_form.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
<?php
require_once "$CFG->dirroot/course/moodleform_mod.php";
class mod_facetoface_mod_form extends moodleform_mod {
function definition()
{
global $CFG;
$mform =& $this->_form;
// GENERAL
$mform->addElement('header', 'general', get_string('general', 'form'));
$mform->addElement('text', 'name', get_string('name'), array('size'=>'64'));
if (!empty($CFG->formatstringstriptags)) {
$mform->setType('name', PARAM_TEXT);
} else {
$mform->setType('name', PARAM_CLEAN);
}
$mform->addRule('name', null, 'required', null, 'client');
$this->add_intro_editor(true);
$mform->addElement('text', 'thirdparty', get_string('thirdpartyemailaddress', 'facetoface'), array('size'=>'64'));
$mform->setType('name', PARAM_NOTAGS);
$mform->addHelpButton('thirdparty', 'thirdpartyemailaddress', 'facetoface');
$mform->addElement('checkbox', 'thirdpartywaitlist', get_string('thirdpartywaitlist', 'facetoface'));
$mform->addHelpButton('thirdpartywaitlist', 'thirdpartywaitlist', 'facetoface');
$display = array();
for ($i=0; $i<=18; $i += 2) {
$display[] = $i;
}
$mform->addElement('select', 'display', get_string('sessionsoncoursepage', 'facetoface'), $display);
$mform->setDefault('display', 3); // 3th element is 6
$mform->addHelpButton('display', 'sessionsoncoursepage', 'facetoface');
$mform->addElement('checkbox', 'approvalreqd', get_string('approvalreqd', 'facetoface'));
$mform->addHelpButton('approvalreqd', 'approvalreqd', 'facetoface');
$mform->addElement('header', 'calendaroptions', get_string('calendaroptions', 'facetoface'));
$mform->addElement('checkbox', 'showoncalendar', get_string('showoncalendar', 'facetoface'));
$mform->setDefault('showoncalendar', true);
$mform->addHelpButton('showoncalendar', 'showoncalendar', 'facetoface');
$mform->addElement('text', 'shortname', get_string('shortname'), array('size' => 32, 'maxlength' => 32));
$mform->setType('shortname', PARAM_TEXT);
$mform->addHelpButton('shortname', 'shortname', 'facetoface');
$mform->disabledIf('shortname', 'showoncalendar');
$mform->addRule('shortname', null, 'maxlength', 32);
// REQUEST MESSAGE
$mform->addElement('header', 'request', get_string('requestmessage', 'facetoface'));
$mform->addHelpButton('request', 'requestmessage', 'facetoface');
$mform->addElement('text', 'requestsubject', get_string('email:subject', 'facetoface'), array('size'=>'55'));
$mform->setType('requestsubject', PARAM_TEXT);
$mform->setDefault('requestsubject', get_string('setting:defaultrequestsubjectdefault', 'facetoface'));
$mform->disabledIf('requestsubject', 'approvalreqd');
$mform->addElement('textarea', 'requestmessage', get_string('email:message', 'facetoface'), 'wrap="virtual" rows="15" cols="70"');
$mform->setDefault('requestmessage', get_string('setting:defaultrequestmessagedefault', 'facetoface'));
$mform->disabledIf('requestmessage', 'approvalreqd');
$mform->addElement('textarea', 'requestinstrmngr', get_string('email:instrmngr', 'facetoface'), 'wrap="virtual" rows="10" cols="70"');
$mform->setDefault('requestinstrmngr', get_string('setting:defaultrequestinstrmngrdefault', 'facetoface'));
$mform->disabledIf('requestinstrmngr', 'approvalreqd');
// CONFIRMATION MESSAGE
$mform->addElement('header', 'confirmation', get_string('confirmationmessage', 'facetoface'));
$mform->addHelpButton('confirmation', 'confirmationmessage', 'facetoface');
$mform->addElement('text', 'confirmationsubject', get_string('email:subject', 'facetoface'), array('size'=>'55'));
$mform->setType('confirmationsubject', PARAM_TEXT);
$mform->setDefault('confirmationsubject', get_string('setting:defaultconfirmationsubjectdefault', 'facetoface'));
$mform->addElement('textarea', 'confirmationmessage', get_string('email:message', 'facetoface'), 'wrap="virtual" rows="15" cols="70"');
$mform->setDefault('confirmationmessage', get_string('setting:defaultconfirmationmessagedefault', 'facetoface'));
$mform->addElement('checkbox', 'emailmanagerconfirmation', get_string('emailmanager', 'facetoface'));
$mform->addHelpButton('emailmanagerconfirmation', 'emailmanagerconfirmation', 'facetoface');
$mform->addElement('textarea', 'confirmationinstrmngr', get_string('email:instrmngr', 'facetoface'), 'wrap="virtual" rows="4" cols="70"');
$mform->addHelpButton('confirmationinstrmngr', 'confirmationinstrmngr', 'facetoface');
$mform->disabledIf('confirmationinstrmngr', 'emailmanagerconfirmation');
$mform->setDefault('confirmationinstrmngr', get_string('setting:defaultconfirmationinstrmngrdefault', 'facetoface'));
// REMINDER MESSAGE
$mform->addElement('header', 'reminder', get_string('remindermessage', 'facetoface'));
$mform->addHelpButton('reminder', 'remindermessage', 'facetoface');
$mform->addElement('text', 'remindersubject', get_string('email:subject', 'facetoface'), array('size'=>'55'));
$mform->setType('remindersubject', PARAM_TEXT);
$mform->setDefault('remindersubject', get_string('setting:defaultremindersubjectdefault', 'facetoface'));
$mform->addElement('textarea', 'remindermessage', get_string('email:message', 'facetoface'), 'wrap="virtual" rows="15" cols="70"');
$mform->setDefault('remindermessage', get_string('setting:defaultremindermessagedefault', 'facetoface'));
$mform->addElement('checkbox', 'emailmanagerreminder', get_string('emailmanager', 'facetoface'));
$mform->addHelpButton('emailmanagerreminder', 'emailmanagerreminder', 'facetoface');
$mform->addElement('textarea', 'reminderinstrmngr', get_string('email:instrmngr', 'facetoface'), 'wrap="virtual" rows="4" cols="70"');
$mform->addHelpButton('reminderinstrmngr', 'reminderinstrmngr', 'facetoface');
$mform->disabledIf('reminderinstrmngr', 'emailmanagerreminder');
$mform->setDefault('reminderinstrmngr', get_string('setting:defaultreminderinstrmngrdefault', 'facetoface'));
$reminderperiod = array();
for ($i=1; $i<=20; $i += 1) {
$reminderperiod[$i] = $i;
}
$mform->addElement('select', 'reminderperiod', get_string('reminderperiod', 'facetoface'), $reminderperiod);
$mform->setDefault('reminderperiod', 2);
$mform->addHelpButton('reminderperiod', 'reminderperiod', 'facetoface');
// WAITLISTED MESSAGE
$mform->addElement('header', 'waitlisted', get_string('waitlistedmessage', 'facetoface'));
$mform->addHelpButton('waitlisted', 'waitlistedmessage', 'facetoface');
$mform->addElement('text', 'waitlistedsubject', get_string('email:subject', 'facetoface'), array('size'=>'55'));
$mform->setType('waitlistedsubject', PARAM_TEXT);
$mform->setDefault('waitlistedsubject', get_string('setting:defaultwaitlistedsubjectdefault', 'facetoface'));
$mform->addElement('textarea', 'waitlistedmessage', get_string('email:message', 'facetoface'), 'wrap="virtual" rows="15" cols="70"');
$mform->setDefault('waitlistedmessage', get_string('setting:defaultwaitlistedmessagedefault', 'facetoface'));
// CANCELLATION MESSAGE
$mform->addElement('header', 'cancellation', get_string('cancellationmessage', 'facetoface'));
$mform->addHelpButton('cancellation', 'cancellationmessage', 'facetoface');
$mform->addElement('text', 'cancellationsubject', get_string('email:subject', 'facetoface'), array('size'=>'55'));
$mform->setType('cancellationsubject', PARAM_TEXT);
$mform->setDefault('cancellationsubject', get_string('setting:defaultcancellationsubjectdefault', 'facetoface'));
$mform->addElement('textarea', 'cancellationmessage', get_string('email:message', 'facetoface'), 'wrap="virtual" rows="15" cols="70"');
$mform->setDefault('cancellationmessage', get_string('setting:defaultcancellationmessagedefault', 'facetoface'));
$mform->addElement('checkbox', 'emailmanagercancellation', get_string('emailmanager', 'facetoface'));
$mform->addHelpButton('emailmanagercancellation', 'emailmanagercancellation', 'facetoface');
$mform->addElement('textarea', 'cancellationinstrmngr', get_string('email:instrmngr', 'facetoface'), 'wrap="virtual" rows="4" cols="70"');
$mform->addHelpButton('cancellationinstrmngr', 'cancellationinstrmngr', 'facetoface');
$mform->disabledIf('cancellationinstrmngr', 'emailmanagercancellation');
$mform->setDefault('cancellationinstrmngr', get_string('setting:defaultcancellationinstrmngrdefault', 'facetoface'));
$features = new stdClass;
$features->groups = false;
$features->groupings = false;
$features->groupmembersonly = false;
$features->outcomes = false;
$features->gradecat = false;
$features->idnumber = true;
$this->standard_coursemodule_elements($features);
$this->add_action_buttons();
}
function data_preprocessing(&$default_values)
{
// Fix manager emails
if (empty($default_values['confirmationinstrmngr'])) {
$default_values['confirmationinstrmngr'] = null;
}
else {
$default_values['emailmanagerconfirmation'] = 1;
}
if (empty($default_values['reminderinstrmngr'])) {
$default_values['reminderinstrmngr'] = null;
}
else {
$default_values['emailmanagerreminder'] = 1;
}
if (empty($default_values['cancellationinstrmngr'])) {
$default_values['cancellationinstrmngr'] = null;
}
else {
$default_values['emailmanagercancellation'] = 1;
}
}
}