Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1434 ariadna 1
<?php
2
// This file is part of Moodle - http://moodle.org/
3
//
4
// Moodle is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// Moodle is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
 
17
/**
18
 * local_moofactory_notification plugin
19
 *
20
 * @package     local_moofactory_notification
21
 * @copyright   2020 Patrick ROCHET <patrick.r@lmsfactory.com>
22
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
/*
26
 * This file generates the site admin settings page using Moodles
27
 * standard admin_settingpage class.
28
 */
29
 
30
defined('MOODLE_INTERNAL') || die;
31
 
32
$context = context_system::instance();
33
 
34
$settings = new admin_settingpage('local_moofactory_notification',  get_string('settings', 'local_moofactory_notification'));
35
 
36
// Settings
37
$name = 'local_moofactory_notification/enabled';
38
$title = get_string('enabled', 'local_moofactory_notification');
39
$description = get_string('enabled_desc', 'local_moofactory_notification');
40
$default = false;
41
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
42
$settings->add($setting);
43
 
44
$name = 'local_moofactory_notification/events';
45
$heading = get_string('eventstypes', 'local_moofactory_notification');
46
$information = '';
47
$setting = new admin_setting_heading($name, $heading, $information);
48
$settings->add($setting);
49
 
50
$name = 'local_moofactory_notification/siteevents';
51
$title = get_string('siteevents', 'local_moofactory_notification');
52
$description = get_string('siteevents_desc', 'local_moofactory_notification');
53
$default = false;
54
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
55
$settings->add($setting);
56
 
57
$name = 'local_moofactory_notification/daysbeforesiteevent';
58
$title = get_string('daysbeforesiteevent', 'local_moofactory_notification');
59
$description = get_string('daysbeforesiteevent_desc', 'local_moofactory_notification');
60
$default = 0;
61
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_INT, '3');
62
$settings->add($setting);
63
 
64
$name = 'local_moofactory_notification/hoursbeforesiteevent';
65
$title = get_string('hoursbeforesiteevent', 'local_moofactory_notification');
66
$description = get_string('hoursbeforesiteevent_desc', 'local_moofactory_notification');
67
$default = 0;
68
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_INT, '3');
69
$settings->add($setting);
70
 
71
$name = 'local_moofactory_notification/siteeventsnotification';
72
$title = get_string('usednotification', 'local_moofactory_notification');
73
$description = get_string('siteeventsnotification_desc', 'local_moofactory_notification');
74
$options = Array();
75
$records = $DB->get_records('local_mf_notification', array('type'=>'siteevent'), 'base DESC, name ASC');
76
foreach($records as $record) {
77
    $options[$record->id] = $record->name;
78
}
79
$setting = new admin_setting_configselect($name, $title, $description, '', $options);
80
$settings->add($setting);
81
 
82
$name = 'local_moofactory_notification/sep1';
83
$heading = ' ';
84
$information = '';
85
$setting = new admin_setting_heading($name, $heading, $information);
86
$settings->add($setting);
87
 
88
$name = 'local_moofactory_notification/coursesenrollments';
89
$title = get_string('coursesenrollments', 'local_moofactory_notification');
90
$description = get_string('coursesenrollments_desc', 'local_moofactory_notification');
91
$default = false;
92
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
93
$settings->add($setting);
94
 
95
$name = 'local_moofactory_notification/coursesenrollmentstime';
96
$title = get_string('coursesenrollmentstime', 'local_moofactory_notification');
97
$description = get_string('coursesenrollmentstime_desc', 'local_moofactory_notification');
98
$default = 0;
99
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_INT, '3');
100
$settings->add($setting);
101
 
102
$name = 'local_moofactory_notification/coursesenrollmentsnotification';
103
$title = get_string('usednotification', 'local_moofactory_notification');
104
$description = get_string('coursesenrollmentsnotification_desc', 'local_moofactory_notification');
105
$options = Array();
106
$records = $DB->get_records('local_mf_notification', array('type'=>'courseenroll'), 'base DESC, name ASC');
107
foreach($records as $record) {
108
    $options[$record->id] = $record->name;
109
}
110
$setting = new admin_setting_configselect($name, $title, $description, '', $options);
111
$settings->add($setting);
112
 
113
$name = 'local_moofactory_notification/sep2';
114
$heading = ' ';
115
$information = '';
116
$setting = new admin_setting_heading($name, $heading, $information);
117
$settings->add($setting);
118
 
119
$name = 'local_moofactory_notification/coursesaccess';
120
$title = get_string('coursesaccess', 'local_moofactory_notification');
121
$description = get_string('coursesaccess_desc', 'local_moofactory_notification');
122
$default = false;
123
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
124
$settings->add($setting);
125
 
126
$name = 'local_moofactory_notification/coursesaccesstime';
127
$title = get_string('coursesaccesstime', 'local_moofactory_notification');
128
$description = get_string('coursesaccesstime_desc', 'local_moofactory_notification');
129
$default = 3;
130
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_INT, '3');
131
$settings->add($setting);
132
 
133
$name = 'local_moofactory_notification/coursesaccessnotification';
134
$title = get_string('usednotification', 'local_moofactory_notification');
135
$description = get_string('coursesaccessnotification_desc', 'local_moofactory_notification');
136
$options = Array();
137
$records = $DB->get_records('local_mf_notification', array('type'=>'courseaccess'), 'base DESC, name ASC');
138
foreach($records as $record) {
139
    $options[$record->id] = $record->name;
140
}
141
$setting = new admin_setting_configselect($name, $title, $description, '', $options);
142
$settings->add($setting);
143
 
144
$name = 'local_moofactory_notification/coursesaccessnotifnumber';
145
$title = get_string('coursesaccessnotifnumber', 'local_moofactory_notification');
146
$description = get_string('coursesaccessnotifnumber_desc', 'local_moofactory_notification');
147
$default = 3;
148
set_config('coursesaccessnotifdefaultnumber', $default, 'local_moofactory_notification');
149
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_INT, '3');
150
$settings->add($setting);
151
 
152
$name = 'local_moofactory_notification/sep3';
153
$heading = ' ';
154
$information = '';
155
$setting = new admin_setting_heading($name, $heading, $information);
156
$settings->add($setting);
157
 
158
$name = 'local_moofactory_notification/coursesevents';
159
$title = get_string('coursesevents', 'local_moofactory_notification');
160
$description = get_string('coursesevents_desc', 'local_moofactory_notification');
161
$default = false;
162
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
163
$settings->add($setting);
164
 
165
$name = 'local_moofactory_notification/courseseventsnotification';
166
$title = get_string('usednotification', 'local_moofactory_notification');
167
$description = get_string('courseseventsnotification_desc', 'local_moofactory_notification');
168
$options = Array();
169
$records = $DB->get_records('local_mf_notification', array('type'=>'courseevent'), 'base DESC, name ASC');
170
foreach($records as $record) {
171
    $options[$record->id] = $record->name;
172
}
173
$setting = new admin_setting_configselect($name, $title, $description, '', $options);
174
$settings->add($setting);
175
 
176
$name = 'local_moofactory_notification/sep4';
177
$heading = ' ';
178
$information = '';
179
$setting = new admin_setting_heading($name, $heading, $information);
180
$settings->add($setting);
181
 
182
$name = 'local_moofactory_notification/modulesaccess';
183
$title = get_string('moduleaccess', 'local_moofactory_notification');
184
$description = get_string('moduleaccess_desc', 'local_moofactory_notification');
185
$default = false;
186
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
187
$settings->add($setting);
188
 
189
$name = 'local_moofactory_notification/modulesleveetime';
190
$title = get_string('leveetime', 'local_moofactory_notification');
191
$description = get_string('leveetime_desc', 'local_moofactory_notification');
192
$default = 0;
193
$setting = new admin_setting_configtext($name, $title, $description, $default, PARAM_INT, '3');
194
$settings->add($setting);
195
 
196
$name = 'local_moofactory_notification/modulesaccessnotification';
197
$title = get_string('usednotification', 'local_moofactory_notification');
198
$description = get_string('moduleaccessnotification_desc', 'local_moofactory_notification');
199
$options = Array();
200
$records = $DB->get_records('local_mf_notification', array('type'=>'moduleaccess'), 'base DESC, name ASC');
201
foreach($records as $record) {
202
    $options[$record->id] = $record->name;
203
}
204
$setting = new admin_setting_configselect($name, $title, $description, '', $options);
205
$settings->add($setting);
206
 
207
/*
208
$name = 'local_moofactory_notification/sep4';
209
$heading = ' ';
210
$information = '';
211
$setting = new admin_setting_heading($name, $heading, $information);
212
$settings->add($setting);
213
 
214
$name = 'local_moofactory_notification/usersevents';
215
$title = get_string('usersevents', 'local_moofactory_notification');
216
$description = get_string('usersevents_desc', 'local_moofactory_notification');
217
$default = false;
218
$setting = new admin_setting_configcheckbox($name, $title, $description, $default, true, false);
219
$settings->add($setting);
220
*/
221
 
222
if (has_capability('local/moofactory_notification:managenotifications', $context)) {
223
    $ADMIN->add('localplugins', new admin_category('moofactory_notification', get_string('pluginname', 'local_moofactory_notification')));
224
    $ADMIN->add('moofactory_notification', $settings);
225
 
226
    $ADMIN->add('moofactory_notification', new admin_externalpage('local_moofactory_notification_managenotif',
227
    get_string('managenotif', 'local_moofactory_notification'),
228
    new moodle_url('/local/moofactory_notification/managenotif.php')));
229
}