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
 * Form for editing a multiblock subblock, specific to Totara.
19
 *
20
 * @package   block_multiblock
21
 * @copyright 2020 Peter Spicer <peter.spicer@catalyst-eu.net>
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace block_multiblock\form;
26
 
27
defined('MOODLE_INTERNAL') || die();
28
 
29
require_once($CFG->libdir . '/formslib.php');
30
 
31
/**
32
 * Form for editing a multiblock subblock, specific to Totara.
33
 *
34
 * The Moodle version keeps it tidy by just overriding the definition
35
 * method but this isn't possible in Totara.
36
 *
37
 * @package   block_multiblock
38
 * @copyright 2020 Peter Spicer <peter.spicer@catalyst-eu.net>
39
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
40
 */
41
class editblock_totara extends editblock_base {
42
 
43
    /**
44
     * Fix the form definition so we can actually have sub-block configuration.
45
     */
46
    public function definition_after_data() {
47
        $mform =& $this->_form;
48
 
49
        // Fix up the fields that need to be present but whose content should be hidden.
50
        $thingstohide = [
51
            'cs_enable_hiding',
52
            'cs_enable_docking',
53
            'cs_show_header',
54
            'cs_show_border',
55
            'bui_contexts',
56
            'bui_pagetypepattern',
57
            'bui_staticpagetypepattern',
58
            'bui_subpagepattern',
59
            'bui_defaultregion',
60
            'bui_defaultweight',
61
            'bui_visible',
62
            'bui_region',
63
            'bui_weight',
64
        ];
65
 
66
        foreach ($thingstohide as $element) {
67
            if (!empty($mform->_elementIndex[$element])) {
68
                $value = $mform->getElementValue($element);
69
                $mform->removeElement($element);
70
                $mform->addElement('hidden', $element, $value);
71
            }
72
        }
73
 
74
        // Just remove the things we don't care about.
75
        $thingstoremove = [
76
            'displayconfig',
77
            'bui_homecontext',
78
            'whereheader',
79
            'onthispage',
80
            'pagetypewarning',
81
            'restrictpagetypes',
82
            'submitbutton',
83
            'cancelbutton',
84
            'buttonar',
85
        ];
86
        foreach ($thingstoremove as $element) {
87
            if (!empty($mform->_elementIndex[$element])) {
88
                $mform->removeElement($element);
89
            }
90
        }
91
 
92
        $this->add_save_buttons();
93
    }
94
}