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
 * Mnet access control updated event.
19
 *
20
 * @package    core
21
 * @since      Moodle 2.7
22
 * @copyright  2013 Mark Nelson <markn@moodle.com>
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
namespace core\event;
27
 
28
defined('MOODLE_INTERNAL') || die();
29
 
30
/**
31
 * Mnet access control updated event class.
32
 *
33
 * @property-read array $other {
34
 *      Extra information about event.
35
 *
36
 *      - string username: the username of the user.
37
 *      - string hostname: the name of the host the user came from.
38
 *      - string accessctrl: the access control value.
39
 * }
40
 *
41
 * @package    core
42
 * @since      Moodle 2.7
43
 * @copyright  2013 Mark Nelson <markn@moodle.com>
44
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
45
 */
46
class mnet_access_control_updated extends base {
47
 
48
    /**
49
     * Init method.
50
     */
51
    protected function init() {
52
        $this->data['objecttable'] = 'mnet_sso_access_control';
53
        $this->data['crud'] = 'u';
54
        $this->data['edulevel'] = self::LEVEL_OTHER;
55
    }
56
 
57
    /**
58
     * Returns localised general event name.
59
     *
60
     * @return string
61
     */
62
    public static function get_name() {
63
        return get_string('eventaccesscontrolupdated', 'mnet');
64
    }
65
 
66
    /**
67
     * Returns relevant URL.
68
     *
69
     * @return \moodle_url
70
     */
71
    public function get_url() {
72
        return new \moodle_url('/admin/mnet/access_control.php');
73
    }
74
 
75
    /**
76
     * Returns description of what happened.
77
     *
78
     * @return string
79
     */
80
    public function get_description() {
81
        return "The user with id '$this->userid' updated access control for the user with username '{$this->other['username']}' " .
82
            "belonging to mnet host '{$this->other['hostname']}'.";
83
    }
84
 
85
    /**
86
     * Custom validation.
87
     *
88
     * @throws \coding_exception
89
     * @return void
90
     */
91
    protected function validate_data() {
92
        parent::validate_data();
93
 
94
        if (!isset($this->other['username'])) {
95
            throw new \coding_exception('The \'username\' value must be set in other.');
96
        }
97
 
98
        if (!isset($this->other['hostname'])) {
99
            throw new \coding_exception('The \'hostname\' value must be set in other.');
100
        }
101
 
102
        if (!isset($this->other['accessctrl'])) {
103
            throw new \coding_exception('The \'accessctrl\' value must be set in other.');
104
        }
105
    }
106
 
107
    public static function get_objectid_mapping() {
108
        // Mnet info is not backed up, so no need to map on restore.
109
        return array('db' => 'mnet_sso_access_control', 'restore' => base::NOT_MAPPED);
110
    }
111
 
112
    public static function get_other_mapping() {
113
        // Nothing to map.
114
        return false;
115
    }
116
 
117
    public static function is_deprecated() {
118
        return true;
119
    }
120
}