1 |
efrain |
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 |
* This file contains the form add/update oauth2 user_field_mapping.
|
|
|
19 |
*
|
|
|
20 |
* @package tool_oauth2
|
|
|
21 |
* @copyright 2017 Damyon Wiese
|
|
|
22 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
namespace tool_oauth2\form;
|
|
|
26 |
defined('MOODLE_INTERNAL') || die();
|
|
|
27 |
|
|
|
28 |
use stdClass;
|
|
|
29 |
use core\form\persistent;
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Issuer form.
|
|
|
33 |
*
|
|
|
34 |
* @package tool_oauth2
|
|
|
35 |
* @copyright 2017 Damyon Wiese
|
|
|
36 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
37 |
*/
|
|
|
38 |
class user_field_mapping extends persistent {
|
|
|
39 |
|
|
|
40 |
/** @var string $persistentclass */
|
|
|
41 |
protected static $persistentclass = 'core\\oauth2\\user_field_mapping';
|
|
|
42 |
|
|
|
43 |
/** @var array $fieldstoremove */
|
|
|
44 |
protected static $fieldstoremove = array('submitbutton', 'action');
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Define the form - called by parent constructor
|
|
|
48 |
*/
|
|
|
49 |
public function definition() {
|
|
|
50 |
global $PAGE;
|
|
|
51 |
|
|
|
52 |
$mform = $this->_form;
|
|
|
53 |
$userfieldmapping = $this->get_persistent();
|
|
|
54 |
|
|
|
55 |
// External.
|
|
|
56 |
$mform->addElement('text', 'externalfield', get_string('userfieldexternalfield', 'tool_oauth2'));
|
|
|
57 |
$mform->addRule('externalfield', null, 'required', null, 'client');
|
|
|
58 |
$mform->addRule('externalfield', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
|
|
|
59 |
$mform->addHelpButton('externalfield', 'userfieldexternalfield', 'tool_oauth2');
|
|
|
60 |
|
|
|
61 |
// Internal.
|
|
|
62 |
$choices = $userfieldmapping->get_internalfield_list();
|
|
|
63 |
$mform->addElement('selectgroups', 'internalfield', get_string('userfieldinternalfield', 'tool_oauth2'), $choices);
|
|
|
64 |
$mform->addHelpButton('internalfield', 'userfieldinternalfield', 'tool_oauth2');
|
|
|
65 |
|
|
|
66 |
$mform->addElement('hidden', 'action', 'edit');
|
|
|
67 |
$mform->setType('action', PARAM_ALPHA);
|
|
|
68 |
|
|
|
69 |
$mform->addElement('hidden', 'issuerid', $userfieldmapping->get('issuerid'));
|
|
|
70 |
$mform->setConstant('issuerid', $this->_customdata['issuerid']);
|
|
|
71 |
$mform->setType('issuerid', PARAM_INT);
|
|
|
72 |
|
|
|
73 |
$mform->addElement('hidden', 'id', $userfieldmapping->get('id'));
|
|
|
74 |
$mform->setType('id', PARAM_INT);
|
|
|
75 |
|
|
|
76 |
$this->add_action_buttons(true, get_string('savechanges', 'tool_oauth2'));
|
|
|
77 |
}
|
|
|
78 |
|
|
|
79 |
}
|
|
|
80 |
|