-
Notifications
You must be signed in to change notification settings - Fork 0
/
setting_form.php
80 lines (64 loc) · 2.71 KB
/
setting_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
<?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 block_cps
* @copyright 2014 Louisiana State University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once $CFG->libdir . '/formslib.php';
class setting_form extends moodleform {
function definition() {
$m =& $this->_form;
$user = $this->_customdata['user'];
$_s = ues::gen_str('block_cps');
$isadmin = is_siteadmin();
$isteacher = cps_setting::is_valid(ues_user::sections(true));
$altexists = strlen($user->alternatename) > 0;
$fieldtype = !$altexists || $isteacher ? 'text' : 'static';
$m->addElement($fieldtype, 'user_firstname', $_s('user_firstname'));
$m->setDefault('user_firstname', $user->firstname);
$m->setType('user_firstname', PARAM_TEXT);
if ($isteacher) {
$m->addElement('checkbox', 'user_grade_restore', $_s('grade_restore'));
$m->addHelpButton('user_grade_restore', 'grade_restore', 'block_cps');
}
$m->addElement('hidden', 'id', $user->id);
$m->setType('id', PARAM_INT);
$buttons = array(
$m->createElement('cancel')
);
// Only show the save button if the user has not already savfed a preferred name.
if(!$altexists || $isadmin || $isteacher){
array_unshift($buttons, $m->createElement('submit', 'save', get_string('savechanges')));
}
$m->addGroup($buttons, 'buttons', ' ', array(' '), false);
}
}
class setting_search_form extends moodleform {
function definition() {
$m =& $this->_form;
$m->addElement('text', 'username', get_string('username'));
$m->setType('username',PARAM_ALPHANUMEXT);
$m->addElement('text', 'idnumber', get_string('idnumber'));
$m->setType('idnumber',PARAM_ALPHANUM);
$buttons = array(
$m->createElement('submit', 'search', get_string('search')),
$m->createElement('cancel')
);
$m->addGroup($buttons, 'buttons', ' ', array(' '), false);
}
}