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
 * This file manages the forms to create and edit an instance of this module
19
 *
20
 * @package    mod_custommailing
21
 * @author     jeanfrancois@cblue.be
22
 * @copyright  2021 CBlue SPRL
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
require_once $CFG->dirroot . '/course/moodleform_mod.php';
29
 
30
/**
31
 * Moodleform class.
32
 *
33
 * @package    mod_custommailing
34
 * @author     jeanfrancois@cblue.be
35
 * @copyright  2021 CBlue SPRL
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 */
38
class mod_custommailing_mod_form extends moodleform_mod {
39
 
40
    /**
41
     * @throws coding_exception
42
     */
43
    public function definition() {
44
        $mform =& $this->_form;
45
 
46
        // Adding the "general" fieldset, where all the common settings are shown.
47
        $mform->addElement('header', 'general', get_string('general', 'form'));
48
 
49
        // Adding the standard "name" field.
50
        $mform->addElement('text', 'name', get_string('custommailingname', 'custommailing'), ['size' => '32']);
51
        $mform->setType('name', PARAM_TEXT);
52
        $mform->addRule('name', null, 'required', null, 'client');
53
        $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
54
 
55
        $config = get_config('custommailing');
56
        if (!empty($config->debugmode)) {
57
            $mform->addElement('html', html_writer::div(get_string('debugmode', 'mod_custommailing') . ' : ' . get_string('debugmode_help', 'mod_custommailing'), 'alert alert-danger'));
58
        }
59
 
60
        // Adding the standard "intro" fields.
61
        $this->standard_intro_elements();
62
 
63
        // Add standard elements, common to all modules.
64
        $this->standard_coursemodule_elements();
65
 
66
        // Add standard buttons, common to all modules.
67
        $this->add_action_buttons();
68
    }
69
 
70
    /**
71
     * @param array|stdClass $default_values
72
     */
73
    public function set_data($default_values) {
74
        $default_values->visible = false; // Force visible to false to hide the activity from students
75
        parent::set_data($default_values);
76
    }
77
}