source: moodle/trunk/fuentes/lib/classes/event/mnet_access_control_updated.php @ 1331

Last change on this file since 1331 was 1331, checked in by jrpelegrina, 3 years ago

Updated to moodle 3.0.3

File size: 3.7 KB
Line 
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
26namespace core\event;
27
28defined('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 */
46class 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     * Return legacy data for add_to_log().
87     *
88     * @return array
89     */
90    protected function get_legacy_logdata() {
91        return array(SITEID, 'admin/mnet', 'update', 'admin/mnet/access_control.php', 'SSO ACL: ' . $this->other['accessctrl'] .
92            ' user \'' . $this->other['username'] . '\' from ' . $this->other['hostname']);
93    }
94
95    /**
96     * Custom validation.
97     *
98     * @throws \coding_exception
99     * @return void
100     */
101    protected function validate_data() {
102        parent::validate_data();
103
104        if (!isset($this->other['username'])) {
105            throw new \coding_exception('The \'username\' value must be set in other.');
106        }
107
108        if (!isset($this->other['hostname'])) {
109            throw new \coding_exception('The \'hostname\' value must be set in other.');
110        }
111
112        if (!isset($this->other['accessctrl'])) {
113            throw new \coding_exception('The \'accessctrl\' value must be set in other.');
114        }
115    }
116
117    public static function get_objectid_mapping() {
118        // Mnet info is not backed up, so no need to map on restore.
119        return array('db' => 'mnet_sso_access_control', 'restore' => base::NOT_MAPPED);
120    }
121
122    public static function get_other_mapping() {
123        // Nothing to map.
124        return false;
125    }
126}
Note: See TracBrowser for help on using the repository browser.