Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
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
 * Age and location verification mform.
19
 *
20
 * @package     core_auth
21
 * @copyright   2018 Mihail Geshoski <mihail@moodle.com>
22
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace core_auth\form;
26
 
27
defined('MOODLE_INTERNAL') || die();
28
 
29
require_once($CFG->libdir.'/formslib.php');
30
 
31
use moodleform;
32
 
33
/**
34
 * Age and location verification mform class.
35
 *
36
 * @copyright 2018 Mihail Geshoski <mihail@moodle.com>
37
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 */
39
class verify_age_location_form extends moodleform {
40
    /**
41
     * Defines the form fields.
42
     */
43
    public function definition() {
44
        global $CFG;
45
 
46
        $mform = $this->_form;
47
 
48
        $mform->addElement('text', 'age', get_string('whatisyourage'), array('optional'  => false));
49
        $mform->setType('age', PARAM_RAW);
50
        $mform->addRule('age', null, 'required', null, 'client');
51
        $mform->addRule('age', null, 'numeric', null, 'client');
52
 
53
        $countries = get_string_manager()->get_list_of_countries();
54
        $defaultcountry[''] = get_string('selectacountry');
55
        $countries = array_merge($defaultcountry, $countries);
56
        $mform->addElement('select', 'country', get_string('wheredoyoulive'), $countries);
57
        $mform->addRule('country', null, 'required', null, 'client');
58
        $mform->setDefault('country', $CFG->country);
59
 
60
        $this->add_action_buttons(true, get_string('proceed'));
61
    }
62
}