Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | 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
namespace core_customfield;
18
 
19
use core\persistent;
20
 
21
/**
1441 ariadna 22
 * Customfield field persistent class
1 efrain 23
 *
1441 ariadna 24
 * @package   core_customfield
1 efrain 25
 * @copyright 2018 Toni Barbera <toni@moodle.com>
26
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27
 */
28
class field extends persistent {
29
 
30
    /**
31
     * Database table.
32
     */
33
    const TABLE = 'customfield_field';
34
 
35
    /**
36
     * Return the definition of the properties of this model.
37
     *
38
     * @return array
39
     */
40
    protected static function define_properties(): array {
41
        return array(
42
                'name' => [
43
                        'type' => PARAM_TEXT,
44
                ],
45
                'shortname' => [
46
                        'type' => PARAM_TEXT,
47
                ],
48
                'type' => [
49
                        'type' => PARAM_PLUGIN,
50
                ],
51
                'description' => [
52
                        'type' => PARAM_RAW,
53
                        'optional' => true,
54
                        'default' => null,
55
                        'null' => NULL_ALLOWED
56
                ],
57
                'descriptionformat' => [
58
                        'type' => PARAM_INT,
59
                        'default' => FORMAT_MOODLE,
1441 ariadna 60
                        'optional' => true,
61
                        'null' => NULL_ALLOWED,
1 efrain 62
                ],
63
                'sortorder' => [
64
                        'type' => PARAM_INT,
65
                        'optional' => true,
66
                        'default' => -1,
1441 ariadna 67
                        'null' => NULL_ALLOWED,
1 efrain 68
                ],
69
                'categoryid' => [
70
                        'type' => PARAM_INT
71
                ],
72
                'configdata' => [
73
                        'type' => PARAM_RAW,
74
                        'optional' => true,
75
                        'default' => null,
76
                        'null' => NULL_ALLOWED
77
                ],
78
        );
79
    }
80
 
81
    /**
82
     * Get decoded configdata.
83
     *
84
     * @return array
85
     */
86
    protected function get_configdata(): array {
87
        return json_decode($this->raw_get('configdata') ?? '', true) ?? array();
88
    }
89
}