forked from jpahullo/moodle-tool_mergeusers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index_form.php
95 lines (81 loc) · 3.68 KB
/
index_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
<?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/>.
/**
* Version information
*
* @package tool
* @subpackage mergeusers
* @author Nicolas Dunand <[email protected]>
* @author Mike Holzer
* @author Forrest Gaston
* @author Juan Pablo Torres Herrera
* @author Jordi Pujol-Ahulló, SREd, Universitat Rovira i Virgili
* @author John Hoopes <[email protected]>, University of Wisconsin - Madison
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once($CFG->libdir.'/formslib.php'); /// forms library
/**
* Define form snippet for getting the userids of the two users to merge
*/
class mergeuserform extends moodleform {
/**
* Form definition
*
* @uses $CFG
*/
public function definition() {
$mform =& $this->_form;
$strrequired = get_string('required');
$idstype = array(
'username' => get_string('username'),
'idnumber' => get_string('idnumber'),
'id' => 'Id',
);
$searchfields = array(
'idnumber' => get_string('idnumber'),
'' => get_string('all'),
'id' => 'Id',
'username' => get_string('username'),
'firstname' => get_string('firstname'),
'lastname' => get_string('lastname'),
'email' => get_string('email'),
);
$mform->addElement('header', 'mergeusers', get_string('header', 'tool_mergeusers'));
// Add elements
$searchuser = array();
$searchuser[] = $mform->createElement('text', 'searcharg');
$searchuser[] = $mform->createElement('select', 'searchfield', '', $searchfields, '');
$mform->addGroup($searchuser, 'searchgroup', get_string('searchuser', 'tool_mergeusers'));
$mform->setType('searchgroup[searcharg]', PARAM_TEXT);
$mform->addHelpButton('searchgroup', 'searchuser', 'tool_mergeusers');
$mform->addElement('static', 'mergeusersadvanced', get_string('mergeusersadvanced', 'tool_mergeusers'));
$mform->addHelpButton('mergeusersadvanced', 'mergeusersadvanced', 'tool_mergeusers');
$mform->setAdvanced('mergeusersadvanced');
$olduser = array();
$olduser[] = $mform->createElement('text', 'olduserid', "", 'size="10"');
$olduser[] = $mform->createElement('select', 'olduseridtype', '', $idstype, '');
$mform->addGroup($olduser, 'oldusergroup', get_string('olduserid', 'tool_mergeusers'));
$mform->setType('oldusergroup[olduserid]', PARAM_RAW_TRIMMED);
$mform->setAdvanced('oldusergroup');
$newuser = array();
$newuser[] = $mform->createElement('text', 'newuserid', "", 'size="10"');
$newuser[] = $mform->createElement('select', 'newuseridtype', '', $idstype, '');
$mform->addGroup($newuser, 'newusergroup', get_string('newuserid', 'tool_mergeusers'));
$mform->setType('newusergroup[newuserid]', PARAM_RAW_TRIMMED);
$mform->setAdvanced('newusergroup');
$this->add_action_buttons(false, get_string('search'));
}
}