first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,69 @@
<?php
// This file is part of moodle - http://moodle_org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Antivirus scan data error event
*
* @package core
* @author Kevin Pham <kevinpham@catalyst-au.net>
* @copyright Catalyst IT, 2021
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class antivirus_scan_data_error extends \core\event\base {
/**
* Event data
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Return event description
*
* @return string description
* @throws \coding_exception
*/
public function get_description() {
if (isset($this->other['incidentdetails'])) {
return format_text($this->other['incidentdetails'], FORMAT_MOODLE);
} else {
return get_string('dataerrordesc', 'antivirus');
}
}
/**
* Return event name
*
* @return string name
* @throws \coding_exception
*/
public static function get_name() {
return get_string('dataerrorname', 'antivirus');
}
/**
* Return event report link
* @return \moodle_url
* @throws \moodle_exception
*/
public function get_url() {
return new \moodle_url('/report/infectedfiles/index.php');
}
}
@@ -0,0 +1,70 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Antivirus scan file error event
*
* @package core
* @author Kevin Pham <kevinpham@catalyst-au.net>
* @copyright Catalyst IT, 2021
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class antivirus_scan_file_error extends \core\event\base {
/**
* Event data
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Return event description
*
* @return string description
* @throws \coding_exception
*/
public function get_description() {
if (isset($this->other['incidentdetails'])) {
return format_text($this->other['incidentdetails'], FORMAT_MOODLE);
} else {
return get_string('fileerrordesc', 'antivirus');
}
}
/**
* Return event name
*
* @return string name
* @throws \coding_exception
*/
public static function get_name() {
return get_string('fileerrorname', 'antivirus');
}
/**
* Return event report link
* @return \moodle_url
* @throws \moodle_exception
*/
public function get_url() {
return new \moodle_url('/report/infectedfiles/index.php');
}
}
@@ -0,0 +1,69 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Abstract assessable submitted event.
*
* @package core
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Abstract assessable submitted event class.
*
* This class has to be extended by any event which represent that some content,
* on which someone will be assessed, has been submitted and so made available
* for grading. See {@link \core\event\assessable_uploaded} for when the content
* has just been uploaded.
*
* Both events could be triggered in a row, first the uploaded, then the submitted.
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class assessable_submitted extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Custom validation.
*
* @throws \coding_exception on error.
* @return void
*/
protected function validate_data() {
parent::validate_data();
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context passed must be module context.');
}
}
}
+84
View File
@@ -0,0 +1,84 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Abstract assessable uploaded event.
*
* @package core
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Abstract assessable uploaded event class.
*
* This class has to be extended by any event which represent that some content,
* on which someone will be assessed, has been uploaded. This is different
* than other events such as assessable_submitted, which means that the content
* has been submitted and made available for grading.
*
* Both events could be triggered in a row, first the uploaded, then the submitted.
*
* @property-read array $other {
* Extra information about event.
*
* - array pathnamehashes: uploaded files path name hashes.
* - string content: the content.
* }
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class assessable_uploaded extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Validation that should be shared among child classes.
*
* @throws \coding_exception when validation fails.
* @return void
*/
protected function validate_data() {
parent::validate_data();
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
} else if (!isset($this->other['pathnamehashes']) || !is_array($this->other['pathnamehashes'])) {
throw new \coding_exception('The \'pathnamehashes\' value must be set in other and must be an array.');
} else if (!isset($this->other['content']) || !is_string($this->other['content'])) {
throw new \coding_exception('The \'content\' value must be set in other and must be a string.');
}
}
public static function get_other_mapping() {
// Nothing to map.
return false;
}
}
+98
View File
@@ -0,0 +1,98 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge archived event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a badge is archived.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_archived extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgearchived', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has archived the badge with id '$this->objectid'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/overview.php', array('id' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
}
/**
* Used for maping events on restore
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge', 'restore' => 'badge');
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge awarded event.
*
* @property-read array $other {
* Extra information about event.
*
* - int expiredate: Badge expire timestamp.
* - int badgeissuedid: Badge issued ID.
* }
*
* @package core
* @copyright 2015 James Ballard
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a badge is awarded to a user.
*
* @package core
* @since Moodle 2.9
* @copyright 2015 James Ballard
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_awarded extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgeawarded', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->relateduserid' has been awarded the badge with id '".$this->objectid."'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/overview.php', array('id' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'badge', 'restore' => 'badge');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['badgeissuedid'] = array('db' => 'badge_issued', 'restore' => base::NOT_MAPPED);
return $othermapped;
}
}
+96
View File
@@ -0,0 +1,96 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge created event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a badge is created.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_created extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgecreated', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has created the badge with id '$this->objectid'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/overview.php', array('id' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
}
/**
* Used for maping events on restore
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge', 'restore' => 'badge');
}
}
@@ -0,0 +1,116 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge criteria created event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after criteria is created for a badge.
*
* @property-read array $other {
* Extra information about the event.
*
* - int badgeid: The ID of the badge affected
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_criteria_created extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge_criteria';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgecriteriacreated', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has created criteria to the badge with id '".$this->other['badgeid']."'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/criteria.php', array('id' => $this->other['badgeid']));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
if (!isset($this->other['badgeid'])) {
throw new \coding_exception('The \'badgeid\' value must be set in other.');
}
}
/**
* Used for maping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge_criteria', 'restore' => 'badge_criteria');
}
/**
* Used for maping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['badgeid'] = array('db' => 'badge', 'restore' => 'badge');
return $othermapped;
}
}
@@ -0,0 +1,117 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge criteria deleted event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after criteria is deleted from a badge.
*
* @property-read array $other {
* Extra information about the event.
*
* - int badgeid: The ID of the badge affected
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_criteria_deleted extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge_criteria';
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgecriteriadeleted', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has deleted criteria from the badge with id '".$this->other['badgeid']."'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/criteria.php', array('id' => $this->other['badgeid']));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
if (!isset($this->other['badgeid'])) {
throw new \coding_exception('The \'badgeid\' value must be set in other.');
}
}
/**
* Used for maping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge_criteria', 'restore' => 'badge_criteria');
}
/**
* Used for maping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['badgeid'] = array('db' => 'badge', 'restore' => 'badge');
return $othermapped;
}
}
@@ -0,0 +1,115 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge criteria updated event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after criteria is updated to a badge.
*
*
* @property-read array $other {
* Extra information about the event.
*
* - int badgeid: The ID of the badge affected
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_criteria_updated extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge_criteria';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgecriteriaupdated', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has updated criteria to the badge with id '".$this->other['badgeid']."'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/criteria.php', array('id' => $this->other['badgeid']));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
if (!isset($this->other['badgeid'])) {
throw new \coding_exception('The \'badgeid\' value must be set in other.');
}
}
/**
* Used for maping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge_criteria', 'restore' => 'badge_criteria');
}
/**
* Used for maping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['badgeid'] = array('db' => 'badge', 'restore' => 'badge');
return $othermapped;
}
}
+119
View File
@@ -0,0 +1,119 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge deleted event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/badgeslib.php');
/**
* Event triggered after a badge is deleted.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_deleted extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge';
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgedeleted', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has deleted the badge with id '$this->objectid'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
if ($this->other['badgetype'] == BADGE_TYPE_COURSE) {
// Course badge.
$return = new \moodle_url('/badges/index.php',
array('type' => BADGE_TYPE_COURSE, 'id' => $this->other['courseid']));
} else {
// Site badge.
$return = new \moodle_url('/badges/index.php', array('type' => BADGE_TYPE_SITE));
}
return $return;
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
if (!isset($this->other['badgetype'])) {
throw new \coding_exception('The \'badgetype\' value must be set in other.');
} else {
if (($this->other['badgetype'] != BADGE_TYPE_COURSE) && ($this->other['badgetype'] != BADGE_TYPE_SITE)) {
throw new \coding_exception('Invalid \'badgetype\' value.');
}
}
if ($this->other['badgetype'] == BADGE_TYPE_COURSE) {
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' value must be set in other.');
}
}
}
/**
* Used for maping events on restore
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge', 'restore' => 'badge');
}
}
+97
View File
@@ -0,0 +1,97 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge disabled event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a badge is disabled.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_disabled extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgedisabled', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has disabled access to the badge with id '$this->objectid'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/overview.php', array('id' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
}
/**
* Used for maping events on restore
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge', 'restore' => 'badge');
}
}
+97
View File
@@ -0,0 +1,97 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge duplicated event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a badge is duplicated.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_duplicated extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgeduplicated', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has duplicated the badge with id '$this->objectid'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/overview.php', array('id' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
}
/**
* Used for maping events on restore
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge', 'restore' => 'badge');
}
}
+97
View File
@@ -0,0 +1,97 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge enabled event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a badge is enabled.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_enabled extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgeenabled', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has enabled access to the badge with id '$this->objectid'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/overview.php', array('id' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
}
/**
* Used for maping events on restore
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge', 'restore' => 'badge');
}
}
+119
View File
@@ -0,0 +1,119 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge listing viewed event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/badgeslib.php');
/**
* Event triggered after a badge is viewed.
*
* @property-read array $other {
* Extra information about the event.
*
* - int badgetype: the type of badge (BADGE_TYPE_SITE or BADGE_TYPE_COURSE).
* - int courseid: The ID of the course (Not required for BADGE_TYPE_SITE).
* }
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_listing_viewed extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgelistingviewed', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
if ($this->other['badgetype'] == BADGE_TYPE_SITE) {
$return = "The user with id '$this->userid' has viewed the list of available badges for this site.";
} else {
$return = "The user with id '$this->userid' has viewed the list of available badges".
" for the course with the id '".$this->other['courseid']."'.";
}
return $return;
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
if ($this->other['badgetype'] == BADGE_TYPE_SITE) {
$params = array('type' => $this->other['badgetype']);
} else {
$params = array('id' => $this->other['courseid'], 'type' => $this->other['badgetype']);
}
return new \moodle_url('/badges/view.php', $params );
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['badgetype'])) {
throw new \coding_exception('The \'badgetype\' must be set in other.');
}
if ($this->other['badgetype'] == BADGE_TYPE_COURSE) {
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' must be set in other.');
}
}
}
/**
* Used for maping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['courseid'] = array('db' => 'course', 'restore' => 'course');
return $othermapped;
}
}
+118
View File
@@ -0,0 +1,118 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge revoked event.
*
* @property-read array $other {
* Extra information about event.
*
* - int expiredate: Badge expire timestamp.
* - int badgeissuedid: Badge issued ID.
* }
*
* @package core
* @copyright 2016 Matt Davidson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a badge is revoked from a user.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Matt Davidson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_revoked extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgerevoked', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->relateduserid' has had the badge with id '$this->objectid' revoked.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/overview.php', array('id' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
}
/**
* Get_objectid_mapping method.
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge', 'restore' => 'badge');
}
/**
* Get_other_mapping method.
*
* @return array
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['badgeissuedid'] = array('db' => 'badge_issued', 'restore' => base::NOT_MAPPED);
return $othermapped;
}
}
+96
View File
@@ -0,0 +1,96 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge updated event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a badge is updated.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_updated extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'badge';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgeupdated', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has updated the badge with id '$this->objectid'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/badges/overview.php', array('id' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
}
/**
* Used for maping events on restore
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'badge', 'restore' => 'badge');
}
}
+107
View File
@@ -0,0 +1,107 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Badge viewed event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a badge is viewed.
*
* @property-read array $other {
* Extra information about the event.
*
* - int badgeid: the ID of the badge.
* - int badgehash: The UID of the awarded badge.
* }
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class badge_viewed extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventbadgeviewed', 'badges');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has viewed the badge with the id '".$this->other['badgeid']."'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
if (isset($this->other['badgehash'])) {
return new \moodle_url('/badges/badge.php', ['hash' => $this->other['badgehash']]);
}
return new \moodle_url('/badges/badgeclass.php', ['id' => $this->other['badgeid']]);
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['badgeid'])) {
throw new \coding_exception('The \'badgeid\' must be set in other.');
}
}
/**
* Used for maping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['badgeid'] = array('db' => 'badge', 'restore' => 'badge');
return $othermapped;
}
}
+964
View File
@@ -0,0 +1,964 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Base event class.
*
* @package core
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* All other event classes must extend this class.
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
* @property-read string $eventname Name of the event (=== class name with leading \)
* @property-read string $component Full frankenstyle component name
* @property-read string $action what happened
* @property-read string $target what/who was target of the action
* @property-read string $objecttable name of database table where is object record stored
* @property-read int $objectid optional id of the object
* @property-read string $crud letter indicating event type
* @property-read int $edulevel log level (one of the constants LEVEL_)
* @property-read int $contextid
* @property-read int $contextlevel
* @property-read int $contextinstanceid
* @property-read int $userid who did this?
* @property-read int $courseid the courseid of the event context, 0 for contexts above course
* @property-read int $relateduserid
* @property-read int $anonymous 1 means event should not be visible in reports, 0 means normal event,
* create() argument may be also true/false.
* @property-read mixed $other array or scalar, can not contain objects
* @property-read int $timecreated
*/
abstract class base implements \IteratorAggregate {
/**
* Other level.
*/
const LEVEL_OTHER = 0;
/**
* Teaching level.
*
* Any event that is performed by someone (typically a teacher) and has a teaching value,
* anything that is affecting the learning experience/environment of the students.
*/
const LEVEL_TEACHING = 1;
/**
* Participating level.
*
* Any event that is performed by a user, and is related (or could be related) to his learning experience.
*/
const LEVEL_PARTICIPATING = 2;
/**
* The value used when an id can not be mapped during a restore.
*/
const NOT_MAPPED = -31337;
/**
* The value used when an id can not be found during a restore.
*/
const NOT_FOUND = -31338;
/**
* User id to use when the user is not logged in.
*/
const USER_NOTLOGGEDIN = 0;
/**
* User id to use when actor is not an actual user but system, cli or cron.
*/
const USER_OTHER = -1;
/** @var array event data */
protected $data;
/** @var array the format is standardised by logging API */
protected $logextra;
/** @var \context of this event */
protected $context;
/**
* @var bool indicates if event was already triggered,
* this prevents second attempt to trigger event.
*/
private $triggered;
/**
* @var bool indicates if event was already dispatched,
* this prevents direct calling of manager::dispatch($event).
*/
private $dispatched;
/**
* @var bool indicates if event was restored from storage,
* this prevents triggering of restored events.
*/
private $restored;
/** @var array list of event properties */
private static $fields = array(
'eventname', 'component', 'action', 'target', 'objecttable', 'objectid', 'crud', 'edulevel', 'contextid',
'contextlevel', 'contextinstanceid', 'userid', 'courseid', 'relateduserid', 'anonymous', 'other',
'timecreated');
/** @var array simple record cache */
private $recordsnapshots = array();
/**
* Private constructor, use create() or restore() methods instead.
*/
final private function __construct() {
$this->data = array_fill_keys(self::$fields, null);
// Define some basic details.
$classname = get_called_class();
$parts = explode('\\', $classname);
if (count($parts) !== 3 or $parts[1] !== 'event') {
throw new \coding_exception("Invalid event class name '$classname', it must be defined in component\\event\\
namespace");
}
$this->data['eventname'] = '\\'.$classname;
$this->data['component'] = $parts[0];
$pos = strrpos($parts[2], '_');
if ($pos === false) {
throw new \coding_exception("Invalid event class name '$classname', there must be at least one underscore separating
object and action words");
}
$this->data['target'] = substr($parts[2], 0, $pos);
$this->data['action'] = substr($parts[2], $pos + 1);
}
/**
* Create new event.
*
* The optional data keys as:
* 1/ objectid - the id of the object specified in class name
* 2/ context - the context of this event
* 3/ other - the other data describing the event, can not contain objects
* 4/ relateduserid - the id of user which is somehow related to this event
*
* @param array $data
* @return \core\event\base returns instance of new event
*
* @throws \coding_exception
*/
final public static function create(array $data = null) {
global $USER, $CFG;
$data = (array)$data;
/** @var \core\event\base $event */
$event = new static();
$event->triggered = false;
$event->restored = false;
$event->dispatched = false;
// By default all events are visible in logs.
$event->data['anonymous'] = 0;
// Set static event data specific for child class.
$event->init();
if (isset($event->data['level'])) {
if (!isset($event->data['edulevel'])) {
debugging('level property is deprecated, use edulevel property instead', DEBUG_DEVELOPER);
$event->data['edulevel'] = $event->data['level'];
}
unset($event->data['level']);
}
// Set automatic data.
$event->data['timecreated'] = time();
// Set optional data or use defaults.
$event->data['objectid'] = isset($data['objectid']) ? $data['objectid'] : null;
$event->data['courseid'] = isset($data['courseid']) ? $data['courseid'] : null;
$event->data['userid'] = isset($data['userid']) ? $data['userid'] : $USER->id;
$event->data['other'] = isset($data['other']) ? $data['other'] : null;
$event->data['relateduserid'] = isset($data['relateduserid']) ? $data['relateduserid'] : null;
if (isset($data['anonymous'])) {
$event->data['anonymous'] = $data['anonymous'];
}
$event->data['anonymous'] = (int)(bool)$event->data['anonymous'];
if (isset($event->context)) {
if (isset($data['context'])) {
debugging('Context was already set in init() method, ignoring context parameter', DEBUG_DEVELOPER);
}
} else if (!empty($data['context'])) {
$event->context = $data['context'];
} else if (!empty($data['contextid'])) {
$event->context = \context::instance_by_id($data['contextid'], MUST_EXIST);
} else {
throw new \coding_exception('context (or contextid) is a required event property, system context may be hardcoded in init() method.');
}
$event->data['contextid'] = $event->context->id;
$event->data['contextlevel'] = $event->context->contextlevel;
$event->data['contextinstanceid'] = $event->context->instanceid;
if (!isset($event->data['courseid'])) {
if ($coursecontext = $event->context->get_course_context(false)) {
$event->data['courseid'] = $coursecontext->instanceid;
} else {
$event->data['courseid'] = 0;
}
}
if (!array_key_exists('relateduserid', $data) and $event->context->contextlevel == CONTEXT_USER) {
$event->data['relateduserid'] = $event->context->instanceid;
}
// Warn developers if they do something wrong.
if ($CFG->debugdeveloper) {
static $automatickeys = array('eventname', 'component', 'action', 'target', 'contextlevel', 'contextinstanceid', 'timecreated');
static $initkeys = array('crud', 'level', 'objecttable', 'edulevel');
foreach ($data as $key => $ignored) {
if ($key === 'context') {
continue;
} else if (in_array($key, $automatickeys)) {
debugging("Data key '$key' is not allowed in \\core\\event\\base::create() method, it is set automatically", DEBUG_DEVELOPER);
} else if (in_array($key, $initkeys)) {
debugging("Data key '$key' is not allowed in \\core\\event\\base::create() method, you need to set it in init() method", DEBUG_DEVELOPER);
} else if (!in_array($key, self::$fields)) {
debugging("Data key '$key' does not exist in \\core\\event\\base");
}
}
$expectedcourseid = 0;
if ($coursecontext = $event->context->get_course_context(false)) {
$expectedcourseid = $coursecontext->instanceid;
}
if ($expectedcourseid != $event->data['courseid']) {
debugging("Inconsistent courseid - context combination detected.", DEBUG_DEVELOPER);
}
if (method_exists($event, 'get_legacy_logdata') ||
method_exists($event, 'set_legacy_logdata') ||
method_exists($event, 'get_legacy_eventname') ||
method_exists($event, 'get_legacy_eventdata')
) {
debugging("Invalid event functions defined in " . $event->data['eventname'], DEBUG_DEVELOPER);
}
}
// Let developers validate their custom data (such as $this->data['other'], contextlevel, etc.).
$event->validate_data();
return $event;
}
/**
* Override in subclass.
*
* Set all required data properties:
* 1/ crud - letter [crud]
* 2/ edulevel - using a constant self::LEVEL_*.
* 3/ objecttable - name of database table if objectid specified
*
* Optionally it can set:
* a/ fixed system context
*
* @return void
*/
abstract protected function init();
/**
* Let developers validate their custom data (such as $this->data['other'], contextlevel, etc.).
*
* Throw \coding_exception or debugging() notice in case of any problems.
*/
protected function validate_data() {
// Override if you want to validate event properties when
// creating new events.
}
/**
* Returns localised general event name.
*
* Override in subclass, we can not make it static and abstract at the same time.
*
* @return string
*/
public static function get_name() {
// Override in subclass with real lang string.
$parts = explode('\\', get_called_class());
if (count($parts) !== 3) {
return get_string('unknownevent', 'error');
}
return $parts[0].': '.str_replace('_', ' ', $parts[2]);
}
/**
* Returns the event name complete with metadata information.
*
* This includes information about whether the event has been deprecated so should not be used in all situations -
* for example within reports themselves.
*
* If overriding this function, please ensure that you call the parent version too.
*
* @return string
*/
public static function get_name_with_info() {
$return = static::get_name();
if (static::is_deprecated()) {
$return = get_string('deprecatedeventname', 'core', $return);
}
return $return;
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return null;
}
/**
* This method was originally intended for granular
* access control on the event level, unfortunately
* the proper implementation would be too expensive
* in many cases.
*
* @deprecated since 2.7
*
* @param int|\stdClass $user_or_id ID of the user.
* @return bool True if the user can view the event, false otherwise.
*/
public function can_view($user_or_id = null) {
debugging('can_view() method is deprecated, use anonymous flag instead if necessary.', DEBUG_DEVELOPER);
return is_siteadmin($user_or_id);
}
/**
* Restore event from existing historic data.
*
* @param array $data
* @param array $logextra the format is standardised by logging API
* @return bool|\core\event\base
*/
final public static function restore(array $data, array $logextra) {
$classname = $data['eventname'];
$component = $data['component'];
$action = $data['action'];
$target = $data['target'];
// Security: make 100% sure this really is an event class.
if ($classname !== "\\{$component}\\event\\{$target}_{$action}") {
return false;
}
if (!class_exists($classname)) {
return self::restore_unknown($data, $logextra);
}
$event = new $classname();
if (!($event instanceof \core\event\base)) {
return false;
}
$event->init(); // Init method of events could be setting custom properties.
$event->restored = true;
$event->triggered = true;
$event->dispatched = true;
$event->logextra = $logextra;
foreach (self::$fields as $key) {
if (!array_key_exists($key, $data)) {
debugging("Event restore data must contain key $key");
$data[$key] = null;
}
}
if (count($data) != count(self::$fields)) {
foreach ($data as $key => $value) {
if (!in_array($key, self::$fields)) {
debugging("Event restore data cannot contain key $key");
unset($data[$key]);
}
}
}
$event->data = $data;
return $event;
}
/**
* Restore unknown event.
*
* @param array $data
* @param array $logextra
* @return unknown_logged
*/
final protected static function restore_unknown(array $data, array $logextra) {
$classname = '\core\event\unknown_logged';
/** @var unknown_logged $event */
$event = new $classname();
$event->restored = true;
$event->triggered = true;
$event->dispatched = true;
$event->data = $data;
$event->logextra = $logextra;
return $event;
}
/**
* Create fake event from legacy log data.
*
* @param \stdClass $legacy
* @return base
*/
final public static function restore_legacy($legacy) {
$classname = get_called_class();
/** @var base $event */
$event = new $classname();
$event->restored = true;
$event->triggered = true;
$event->dispatched = true;
$context = false;
$component = 'legacy';
if ($legacy->cmid) {
$context = \context_module::instance($legacy->cmid, IGNORE_MISSING);
$component = 'mod_'.$legacy->module;
} else if ($legacy->course) {
$context = \context_course::instance($legacy->course, IGNORE_MISSING);
}
if (!$context) {
$context = \context_system::instance();
}
$event->data = array();
$event->data['eventname'] = $legacy->module.'_'.$legacy->action;
$event->data['component'] = $component;
$event->data['action'] = $legacy->action;
$event->data['target'] = null;
$event->data['objecttable'] = null;
$event->data['objectid'] = null;
if (strpos($legacy->action, 'view') !== false) {
$event->data['crud'] = 'r';
} else if (strpos($legacy->action, 'print') !== false) {
$event->data['crud'] = 'r';
} else if (strpos($legacy->action, 'update') !== false) {
$event->data['crud'] = 'u';
} else if (strpos($legacy->action, 'hide') !== false) {
$event->data['crud'] = 'u';
} else if (strpos($legacy->action, 'move') !== false) {
$event->data['crud'] = 'u';
} else if (strpos($legacy->action, 'write') !== false) {
$event->data['crud'] = 'u';
} else if (strpos($legacy->action, 'tag') !== false) {
$event->data['crud'] = 'u';
} else if (strpos($legacy->action, 'remove') !== false) {
$event->data['crud'] = 'u';
} else if (strpos($legacy->action, 'delete') !== false) {
$event->data['crud'] = 'p';
} else if (strpos($legacy->action, 'create') !== false) {
$event->data['crud'] = 'c';
} else if (strpos($legacy->action, 'post') !== false) {
$event->data['crud'] = 'c';
} else if (strpos($legacy->action, 'add') !== false) {
$event->data['crud'] = 'c';
} else {
// End of guessing...
$event->data['crud'] = 'r';
}
$event->data['edulevel'] = $event::LEVEL_OTHER;
$event->data['contextid'] = $context->id;
$event->data['contextlevel'] = $context->contextlevel;
$event->data['contextinstanceid'] = $context->instanceid;
$event->data['userid'] = ($legacy->userid ? $legacy->userid : null);
$event->data['courseid'] = ($legacy->course ? $legacy->course : null);
$event->data['relateduserid'] = ($legacy->userid ? $legacy->userid : null);
$event->data['timecreated'] = $legacy->time;
$event->logextra = array();
if ($legacy->ip) {
$event->logextra['origin'] = 'web';
$event->logextra['ip'] = $legacy->ip;
} else {
$event->logextra['origin'] = 'cli';
$event->logextra['ip'] = null;
}
$event->logextra['realuserid'] = null;
$event->data['other'] = (array)$legacy;
return $event;
}
/**
* This is used when restoring course logs where it is required that we
* map the objectid to it's new value in the new course.
*
* Does nothing in the base class except display a debugging message warning
* the user that the event does not contain the required functionality to
* map this information. For events that do not store an objectid this won't
* be called, so no debugging message will be displayed.
*
* Example of usage:
*
* return array('db' => 'assign_submissions', 'restore' => 'submission');
*
* If the objectid can not be mapped during restore set the value to \core\event\base::NOT_MAPPED, example -
*
* return array('db' => 'some_table', 'restore' => \core\event\base::NOT_MAPPED);
*
* Note - it isn't necessary to specify the 'db' and 'restore' values in this case, so you can also use -
*
* return \core\event\base::NOT_MAPPED;
*
* The 'db' key refers to the database table and the 'restore' key refers to
* the name of the restore element the objectid is associated with. In many
* cases these will be the same.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
debugging('In order to restore course logs accurately the event "' . get_called_class() . '" must define the
function get_objectid_mapping().', DEBUG_DEVELOPER);
return false;
}
/**
* This is used when restoring course logs where it is required that we
* map the information in 'other' to it's new value in the new course.
*
* Does nothing in the base class except display a debugging message warning
* the user that the event does not contain the required functionality to
* map this information. For events that do not store any other information this
* won't be called, so no debugging message will be displayed.
*
* Example of usage:
*
* $othermapped = array();
* $othermapped['discussionid'] = array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
* $othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
* return $othermapped;
*
* If an id can not be mapped during restore we set it to \core\event\base::NOT_MAPPED, example -
*
* $othermapped = array();
* $othermapped['someid'] = array('db' => 'some_table', 'restore' => \core\event\base::NOT_MAPPED);
* return $othermapped;
*
* Note - it isn't necessary to specify the 'db' and 'restore' values in this case, so you can also use -
*
* $othermapped = array();
* $othermapped['someid'] = \core\event\base::NOT_MAPPED;
* return $othermapped;
*
* The 'db' key refers to the database table and the 'restore' key refers to
* the name of the restore element the other value is associated with. In many
* cases these will be the same.
*
* @return array an array of other values and their corresponding mapping
*/
public static function get_other_mapping() {
debugging('In order to restore course logs accurately the event "' . get_called_class() . '" must define the
function get_other_mapping().', DEBUG_DEVELOPER);
}
/**
* Get static information about an event.
* This is used in reports and is not for general use.
*
* @return array Static information about the event.
*/
final public static function get_static_info() {
/** Var \core\event\base $event. */
$event = new static();
// Set static event data specific for child class.
$event->init();
return array(
'eventname' => $event->data['eventname'],
'component' => $event->data['component'],
'target' => $event->data['target'],
'action' => $event->data['action'],
'crud' => $event->data['crud'],
'edulevel' => $event->data['edulevel'],
'objecttable' => $event->data['objecttable'],
);
}
/**
* Get an explanation of what the class does.
* By default returns the phpdocs from the child event class. Ideally this should
* be overridden to return a translatable get_string style markdown.
* e.g. return new lang_string('eventyourspecialevent', 'plugin_type');
*
* @return string An explanation of the event formatted in markdown style.
*/
public static function get_explanation() {
$ref = new \ReflectionClass(get_called_class());
$docblock = $ref->getDocComment();
// Check that there is something to work on.
if (empty($docblock)) {
return null;
}
$docblocklines = explode("\n", $docblock);
// Remove the bulk of the comment characters.
$pattern = "/(^\s*\/\*\*|^\s+\*\s|^\s+\*)/";
$cleanline = array();
foreach ($docblocklines as $line) {
$templine = preg_replace($pattern, '', $line);
// If there is nothing on the line then don't add it to the array.
if (!empty($templine)) {
$cleanline[] = rtrim($templine);
}
// If we get to a line starting with an @ symbol then we don't want the rest.
if (preg_match("/^@|\//", $templine)) {
// Get rid of the last entry (it contains an @ symbol).
array_pop($cleanline);
// Break out of this foreach loop.
break;
}
}
// Add a line break to the sanitised lines.
$explanation = implode("\n", $cleanline);
return $explanation;
}
/**
* Returns event context.
* @return \context
*/
public function get_context() {
if (isset($this->context)) {
return $this->context;
}
$this->context = \context::instance_by_id($this->data['contextid'], IGNORE_MISSING);
return $this->context;
}
/**
* Returns relevant URL, override in subclasses.
* @return \moodle_url
*/
public function get_url() {
return null;
}
/**
* Return standardised event data as array.
*
* @return array All elements are scalars except the 'other' field which is array.
*/
public function get_data() {
return $this->data;
}
/**
* Return auxiliary data that was stored in logs.
*
* List of standard properties:
* - origin: IP number, cli,cron
* - realuserid: id of the user when logged-in-as
*
* @return array the format is standardised by logging API
*/
public function get_logextra() {
return $this->logextra;
}
/**
* Validate all properties right before triggering the event.
*
* This throws coding exceptions for fatal problems and debugging for minor problems.
*
* @throws \coding_exception
*/
protected function validate_before_trigger() {
global $DB, $CFG;
if (empty($this->data['crud'])) {
throw new \coding_exception('crud must be specified in init() method of each method');
}
if (!isset($this->data['edulevel'])) {
throw new \coding_exception('edulevel must be specified in init() method of each method');
}
if (!empty($this->data['objectid']) and empty($this->data['objecttable'])) {
throw new \coding_exception('objecttable must be specified in init() method if objectid present');
}
if ($CFG->debugdeveloper) {
// Ideally these should be coding exceptions, but we need to skip these for performance reasons
// on production servers.
if (!in_array($this->data['crud'], array('c', 'r', 'u', 'd'), true)) {
debugging("Invalid event crud value specified.", DEBUG_DEVELOPER);
}
if (!in_array($this->data['edulevel'], array(self::LEVEL_OTHER, self::LEVEL_TEACHING, self::LEVEL_PARTICIPATING))) {
// Bitwise combination of levels is not allowed at this stage.
debugging('Event property edulevel must a constant value, see event_base::LEVEL_*', DEBUG_DEVELOPER);
}
if (self::$fields !== array_keys($this->data)) {
debugging('Number of event data fields must not be changed in event classes', DEBUG_DEVELOPER);
}
$encoded = json_encode($this->data['other']);
// The comparison here is not set to strict. We just need to check if the data is compatible with the JSON encoding
// or not and we don't need to worry about how the data is encoded. Because in some cases, the data can contain
// objects, and objects can be converted to a different format during encoding and decoding.
if ($encoded === false) {
debugging('other event data must be compatible with json encoding', DEBUG_DEVELOPER);
}
if ($this->data['userid'] and !is_number($this->data['userid'])) {
debugging('Event property userid must be a number', DEBUG_DEVELOPER);
}
if ($this->data['courseid'] and !is_number($this->data['courseid'])) {
debugging('Event property courseid must be a number', DEBUG_DEVELOPER);
}
if ($this->data['objectid'] and !is_number($this->data['objectid'])) {
debugging('Event property objectid must be a number', DEBUG_DEVELOPER);
}
if ($this->data['relateduserid'] and !is_number($this->data['relateduserid'])) {
debugging('Event property relateduserid must be a number', DEBUG_DEVELOPER);
}
if ($this->data['objecttable']) {
if (!$DB->get_manager()->table_exists($this->data['objecttable'])) {
debugging('Unknown table specified in objecttable field', DEBUG_DEVELOPER);
}
if (!isset($this->data['objectid'])) {
debugging('Event property objectid must be set when objecttable is defined', DEBUG_DEVELOPER);
}
}
}
}
/**
* Trigger event.
*/
final public function trigger() {
global $CFG;
if ($this->restored) {
throw new \coding_exception('Can not trigger restored event');
}
if ($this->triggered or $this->dispatched) {
throw new \coding_exception('Can not trigger event twice');
}
$this->validate_before_trigger();
$this->triggered = true;
if (PHPUNIT_TEST and \phpunit_util::is_redirecting_events()) {
$this->dispatched = true;
\phpunit_util::event_triggered($this);
return;
}
\core\event\manager::dispatch($this);
$this->dispatched = true;
}
/**
* Was this event already triggered?
*
* @return bool
*/
final public function is_triggered() {
return $this->triggered;
}
/**
* Used from event manager to prevent direct access.
*
* @return bool
*/
final public function is_dispatched() {
return $this->dispatched;
}
/**
* Was this event restored?
*
* @return bool
*/
final public function is_restored() {
return $this->restored;
}
/**
* Add cached data that will be most probably used in event observers.
*
* This is used to improve performance, but it is required for data
* that was just deleted.
*
* @param string $tablename
* @param \stdClass $record
*
* @throws \coding_exception if used after ::trigger()
*/
final public function add_record_snapshot($tablename, $record) {
global $DB, $CFG;
if ($this->triggered) {
throw new \coding_exception('It is not possible to add snapshots after triggering of events');
}
// Special case for course module, allow instance of cm_info to be passed instead of stdClass.
if ($tablename === 'course_modules' && $record instanceof \cm_info) {
$record = $record->get_course_module_record();
}
// NOTE: this might use some kind of MUC cache,
// hopefully we will not run out of memory here...
if ($CFG->debugdeveloper) {
if (!($record instanceof \stdClass)) {
debugging('Argument $record must be an instance of stdClass.', DEBUG_DEVELOPER);
}
if (!$DB->get_manager()->table_exists($tablename)) {
debugging("Invalid table name '$tablename' specified, database table does not exist.", DEBUG_DEVELOPER);
} else {
$columns = $DB->get_columns($tablename);
$missingfields = array_diff(array_keys($columns), array_keys((array)$record));
if (!empty($missingfields)) {
debugging("Fields list in snapshot record does not match fields list in '$tablename'. Record is missing fields: ".
join(', ', $missingfields), DEBUG_DEVELOPER);
}
}
}
$this->recordsnapshots[$tablename][$record->id] = $record;
}
/**
* Returns cached record or fetches data from database if not cached.
*
* @param string $tablename
* @param int $id
* @return \stdClass
*
* @throws \coding_exception if used after ::restore()
*/
final public function get_record_snapshot($tablename, $id) {
global $DB;
if ($this->restored) {
throw new \coding_exception('It is not possible to get snapshots from restored events');
}
if (isset($this->recordsnapshots[$tablename][$id])) {
return clone($this->recordsnapshots[$tablename][$id]);
}
$record = $DB->get_record($tablename, array('id'=>$id));
$this->recordsnapshots[$tablename][$id] = $record;
return $record;
}
/**
* Magic getter for read only access.
*
* @param string $name
* @return mixed
*/
public function __get($name) {
if ($name === 'level') {
debugging('level property is deprecated, use edulevel property instead', DEBUG_DEVELOPER);
return $this->data['edulevel'];
}
if (array_key_exists($name, $this->data)) {
return $this->data[$name];
}
debugging("Accessing non-existent event property '$name'");
}
/**
* Magic setter.
*
* Note: we must not allow modification of data from outside,
* after trigger() the data MUST NOT CHANGE!!!
*
* @param string $name
* @param mixed $value
*
* @throws \coding_exception
*/
public function __set($name, $value) {
throw new \coding_exception('Event properties must not be modified.');
}
/**
* Is data property set?
*
* @param string $name
* @return bool
*/
public function __isset($name) {
if ($name === 'level') {
debugging('level property is deprecated, use edulevel property instead', DEBUG_DEVELOPER);
return isset($this->data['edulevel']);
}
return isset($this->data[$name]);
}
/**
* Create an iterator because magic vars can't be seen by 'foreach'.
*
* @return \ArrayIterator
*/
public function getIterator(): \Traversable {
return new \ArrayIterator($this->data);
}
/**
* Whether this event has been marked as deprecated.
*
* Events cannot be deprecated in the normal fashion as they must remain to support historical data.
* Once they are deprecated, there is no way to trigger the event, so it does not make sense to list it in some
* parts of the UI (e.g. Event Monitor).
*
* @return boolean
*/
public static function is_deprecated() {
return false;
}
}
@@ -0,0 +1,127 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when a new blog entry is associated with a context.
*
* @package core
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Class for event to be triggered when a new blog entry is associated with a context.
*
* @property-read array $other {
* Extra information about event.
*
* - string associatetype: type of blog association, course/coursemodule.
* - int blogid: id of blog.
* - int associateid: id of associate.
* - string subject: blog subject.
* }
*
* @package core
* @since Moodle 2.7
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_association_created extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->context = \context_system::instance();
$this->data['objecttable'] = 'blog_association';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventblogassociationadded', 'core_blog');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' associated the context '{$this->other['associatetype']}' with id " .
"'{$this->other['associateid']}' to the blog entry with id '{$this->other['blogid']}'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/blog/index.php', array('entryid' => $this->other['blogid']));
}
/**
* Custom validations.
*
* @throws \coding_exception when validation fails.
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (empty($this->other['associatetype']) || ($this->other['associatetype'] !== 'course'
&& $this->other['associatetype'] !== 'coursemodule')) {
throw new \coding_exception('The \'associatetype\' value must be set in other and be a valid type.');
}
if (!isset($this->other['blogid'])) {
throw new \coding_exception('The \'blogid\' value must be set in other.');
}
if (!isset($this->other['associateid'])) {
throw new \coding_exception('The \'associateid\' value must be set in other.');
}
if (!isset($this->other['subject'])) {
throw new \coding_exception('The \'subject\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
// Blogs are not included in backups, so no mapping required for restore.
return array('db' => 'blog_association', 'restore' => base::NOT_MAPPED);
}
public static function get_other_mapping() {
// Blogs are not included in backups, so no mapping required for restore.
$othermapped = array();
$othermapped['blogid'] = array('db' => 'post', 'restore' => base::NOT_MAPPED);
// The associateid field is varying (context->instanceid) so cannot be mapped.
return $othermapped;
}
}
@@ -0,0 +1,120 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when a new blog entry is associated with a context.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Class for event to be triggered when a new blog entry is deleted with a context.
*
* @property-read array $other {
* Extra information about event.
*
* - int blogid: id of blog.
* }
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_association_deleted extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->context = \context_system::instance();
$this->data['objecttable'] = 'blog_association';
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventblogassociationdeleted', 'core_blog');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' removed the associations from the blog entry with id "
. "'{$this->other['blogid']}'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/blog/index.php', array('entryid' => $this->other['blogid']));
}
/**
* Custom validations.
*
* @throws \coding_exception when validation fails.
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['blogid'])) {
throw new \coding_exception('The \'blogid\' value must be set in other.');
}
}
/**
* Used for restore of objectid.
*
* @return array
*/
public static function get_objectid_mapping() {
// Blogs are not included in backups, so no mapping required for restore.
return array('db' => 'blog_association', 'restore' => base::NOT_MAPPED);
}
/**
* Used for mappings of "other" data on restore.
*
* @return array
*/
public static function get_other_mapping() {
// Blogs are not included in backups, so no mapping required for restore.
$othermapped = array();
$othermapped['blogid'] = array('db' => 'post', 'restore' => base::NOT_MAPPED);
return $othermapped;
}
}
@@ -0,0 +1,61 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The blog comment created event.
*
* @package core
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* The blog comment created event class.
*
* @package core
* @since Moodle 2.7
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_comment_created extends comment_created {
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/blog/index.php', array('entryid' => $this->other['itemid']));
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' added the comment to the blog with id '{$this->other['itemid']}'.";
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['itemid'] = array('db' => 'post', 'restore' => base::NOT_MAPPED);
return $othermapped;
}
}
@@ -0,0 +1,61 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* The blog comment deleted event.
*
* @package core
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* The blog comment deleted event class.
*
* @package core
* @since Moodle 2.7
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_comment_deleted extends comment_deleted {
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/blog/index.php', array('entryid' => $this->other['itemid']));
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the comment for the blog with id '{$this->other['itemid']}'.";
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['itemid'] = array('db' => 'post', 'restore' => base::NOT_MAPPED);
return $othermapped;
}
}
+105
View File
@@ -0,0 +1,105 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when blog entries are viewed.
*
* @package core
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Class for event to be triggered when blog entries are viewed.
*
* @property-read array $other {
* Extra information about event.
*
* - int entryid: (optional) id of the entry.
* - int tagid: (optional) id of the tag.
* - int userid: (optional) id of the user.
* - int modid: (optional) id of the mod.
* - int groupid: (optional) id of the group.
* - int courseid: (optional) id of associated course.
* - string search: (optional) the string used to search.
* - int fromstart: (optional) the time to search from.
* }
*
* @package core
* @since Moodle 2.7
* @copyright 2013 onwards Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_entries_viewed extends base {
/** @var array List of url params accepted*/
private $validparams = array('entryid', 'tagid', 'userid', 'modid', 'groupid', 'courseid', 'search', 'fromstart');
/**
* Set basic properties for the event.
*/
protected function init() {
$this->context = \context_system::instance();
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventblogentriesviewed', 'core_blog');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed blog entries.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
$params = array();
foreach ($this->validparams as $param) {
if (!empty($this->other[$param])) {
$params[$param] = $this->other[$param];
}
}
return new \moodle_url('/blog/index.php', $params);
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['entryid'] = array('db' => 'post', 'restore' => base::NOT_MAPPED);
$othermapped['tagid'] = array('db' => 'tag', 'restore' => base::NOT_MAPPED);
$othermapped['userid'] = array('db' => 'user', 'restore' => 'user');
$othermapped['modid'] = array('db' => 'course_modules', 'restore' => 'course_module');
$othermapped['groupid'] = array('db' => 'groups', 'restore' => 'group');
$othermapped['courseid'] = array('db' => 'course', 'restore' => 'course');
return $othermapped;
}
}
+120
View File
@@ -0,0 +1,120 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when a new blog entry is added..
*
* @package core
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Class blog_entry_created
*
* Class for event to be triggered when a blog entry is created.
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_entry_created extends base {
/** @var \blog_entry A reference to the active blog_entry object. */
protected $blogentry;
/**
* Set basic properties for the event.
*/
protected function init() {
$this->context = \context_system::instance();
$this->data['objecttable'] = 'post';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Set blog_entry object to be used by observers.
*
* @param \blog_entry $blogentry A reference to the active blog_entry object.
*/
public function set_blog_entry(\blog_entry $blogentry) {
$this->blogentry = $blogentry;
}
/**
* Returns created blog_entry object for event observers.
*
* @throws \coding_exception
* @return \blog_entry
*/
public function get_blog_entry() {
if ($this->is_restored()) {
throw new \coding_exception('Function get_blog_entry() can not be used on restored events.');
}
return $this->blogentry;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('evententryadded', 'core_blog');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the blog entry with id '$this->objectid'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/blog/index.php', array('entryid' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
public static function get_objectid_mapping() {
// Blogs are not backed up, so no mapping required for restore.
return array('db' => 'post', 'restore' => base::NOT_MAPPED);
}
}
+111
View File
@@ -0,0 +1,111 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when a new blog entry is deleted.
*
* @package core
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Class blog_entry_deleted
*
* Event for when a new blog entry is deleted.
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_entry_deleted extends base {
/** @var \blog_entry A reference to the active blog_entry object. */
protected $blogentry;
/**
* Set basic event properties.
*/
protected function init() {
$this->context = \context_system::instance();
$this->data['objecttable'] = 'post';
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string("evententrydeleted", "core_blog");
}
/**
* Sets blog_entry object to be used by observers.
*
* @param \blog_entry $blogentry A reference to the active blog_entry object.
*/
public function set_blog_entry(\blog_entry $blogentry) {
$this->blogentry = $blogentry;
}
/**
* Returns deleted blog entry for event observers.
*
* @throws \coding_exception
* @return \blog_entry
*/
public function get_blog_entry() {
if ($this->is_restored()) {
throw new \coding_exception('Function get_blog_entry() can not be used on restored events.');
}
return $this->blogentry;
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the blog entry with id '$this->objectid'.";
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
public static function get_objectid_mapping() {
// Blogs are not backed up, so no need for mapping for restore.
return array('db' => 'post', 'restore' => base::NOT_MAPPED);
}
}
+119
View File
@@ -0,0 +1,119 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event to be triggered when a blog entry is updated.
*
* @package core
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Class blog_entry_updated
*
* Event to be triggered when a blog entry is updated.
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_entry_updated extends base {
/** @var \blog_entry A reference to the active blog_entry object. */
protected $blogentry;
/**
* Set basic event properties.
*/
protected function init() {
$this->context = \context_system::instance();
$this->data['objecttable'] = 'post';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Sets blog_entry object to be used by observers.
*
* @param \blog_entry $blogentry A reference to the active blog_entry object.
*/
public function set_blog_entry(\blog_entry $blogentry) {
$this->blogentry = $blogentry;
}
/**
* Returns updated blog entry for event observers.
*
* @throws \coding_exception
* @return \blog_entry
*/
public function get_blog_entry() {
if ($this->is_restored()) {
throw new \coding_exception('Function get_blog_entry() can not be used on restored events.');
}
return $this->blogentry;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('evententryupdated', 'core_blog');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the blog entry with id '$this->objectid'.";
}
/**
* Returns relevant URL.
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/blog/index.php', array('entryid' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
public static function get_objectid_mapping() {
// Blogs are not backed up, so no need for mapping for restore.
return array('db' => 'post', 'restore' => NOT_MAPPED);
}
}
+104
View File
@@ -0,0 +1,104 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when a new blog entry is associated with a context.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Class for event to be triggered when an external blog is added to moodle.
*
* @property-read array $other {
* Extra information about event.
*
* - string url: web address of the external blog added.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_external_added extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'blog_external';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventblogexternaladded', 'core_blog');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' added the external blog with the id '{$this->objectid}'" .
" from the web address '{$this->other['url']}'.";
}
/**
* Custom validations.
*
* @throws \coding_exception when validation fails.
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['url'])) {
throw new \coding_exception('The \'url\' value must be set in other.');
}
}
/**
* Used for maping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
// No mapping required.
return false;
}
/**
* Used for restore of events.
*
* @return array
*/
public static function get_objectid_mapping() {
// Blogs are not backed up, so no mapping required for restore.
return array('db' => 'blog_external', 'restore' => base::NOT_MAPPED);
}
}
@@ -0,0 +1,73 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when a new blog entry is associated with a context.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Class for event to be triggered when an external blog is removed from moodle.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_external_removed extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'blog_external';
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventblogexternalremoved', 'core_blog');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' removed the external blog with the id '{$this->objectid}'";
}
/**
* Used for restore of events.
*
* @return array
*/
public static function get_objectid_mapping() {
// Blogs are not backed up, so no mapping required for restore.
return array('db' => 'blog_external', 'restore' => base::NOT_MAPPED);
}
}
+104
View File
@@ -0,0 +1,104 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when a new blog entry is associated with a context.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Class for event to be triggered when an external blog is updated in moodle.
*
* @property-read array $other {
* Extra information about event.
*
* - string url: web address of the external blog.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_external_updated extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['objecttable'] = 'blog_external';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventblogexternalupdated', 'core_blog');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' added the external blog with the id '{$this->objectid}'" .
" with the web address '{$this->other['url']}'.";
}
/**
* Custom validations.
*
* @throws \coding_exception when validation fails.
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['url'])) {
throw new \coding_exception('The \'url\' value must be set in other.');
}
}
/**
* Used for maping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
// No mapping required.
return false;
}
/**
* Used for restore of events.
*
* @return array
*/
public static function get_objectid_mapping() {
// Blogs are not backed up, so no mapping required for restore.
return array('db' => 'blog_external', 'restore' => base::NOT_MAPPED);
}
}
@@ -0,0 +1,76 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Event for when a new blog entry is associated with a context.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Class for event to be triggered when an external blog is viewed to moodle.
*
* @property-read array $other {
* Extra information about event.
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class blog_external_viewed extends base {
/**
* Set basic properties for the event.
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventexternalblogsviewed', 'core_blog');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed their registered external blogs";
}
/**
* Used for backup / restore of events.
* @return array
*/
public static function get_objectid_mapping() {
// Blogs are not backed up, so no mapping required for restore.
return array('db' => 'blog_external', 'restore' => base::NOT_MAPPED);
}
}
@@ -0,0 +1,116 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Calendar event created event.
*
* @package core
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Calendar event created event.
*
* @property-read array $other {
* Extra information about the event.
*
* - int repeatid: id of the parent event if present, else 0.
* - int timestart: timestamp for event time start.
* - string name: name of the event.
* }
*
* @package core
* @since Moodle 2.7
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class calendar_event_created extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'event';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcalendareventcreated', 'core_calendar');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
$eventname = s($this->other['name']);
return "The user with id '$this->userid' created the event '$eventname' with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/calendar/view.php', array('view' => 'day', 'time' => $this->other['timestart']),
'event_' . $this->objectid);
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['repeatid'])) {
throw new \coding_exception('The \'repeatid\' value must be set in other.');
}
if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.');
}
if (!isset($this->other['timestart'])) {
throw new \coding_exception('The \'timestart\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'event', 'restore' => 'event');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['repeatid'] = array('db' => 'event', 'restore' => 'event');
return $othermapped;
}
}
@@ -0,0 +1,106 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Calendar event deleted event.
*
* @package core
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Calendar event deleted event.
*
* @property-read array $other {
* Extra information about the event.
*
* - int repeatid: id of the parent event if present, else 0.
* - int timestart: timestamp for event time start.
* - string name: name of the event.
* }
*
* @package core
* @since Moodle 2.7
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class calendar_event_deleted extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'event';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcalendareventdeleted', 'core_calendar');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
$eventname = s($this->other['name']);
return "The user with id '$this->userid' deleted the event '$eventname' with id '$this->objectid'.";
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['repeatid'])) {
throw new \coding_exception('The \'repeatid\' value must be set in other.');
}
if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.');
}
if (!isset($this->other['timestart'])) {
throw new \coding_exception('The \'timestart\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'event', 'restore' => 'event');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['repeatid'] = array('db' => 'event', 'restore' => 'event');
return $othermapped;
}
}
@@ -0,0 +1,115 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Calendar event updated event.
*
* @package core
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Calendar event updated event.
*
* @property-read array $other {
* Extra information about the event.
*
* - int repeatid: id of the parent event if present, else 0.
* - int timestart: timestamp for event time start.
* - string name: name of the event.
* }
*
* @package core
* @since Moodle 2.7
* @copyright 2014 onwards Ankit Agarwal <ankit.agrr@gmail.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class calendar_event_updated extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'event';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcalendareventupdated', 'core_calendar');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
$eventname = s($this->other['name']);
return "The user with id '$this->userid' updated the event '$eventname' with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/calendar/event.php', array('action' => 'edit', 'id' => $this->objectid));
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['repeatid'])) {
throw new \coding_exception('The \'repeatid\' value must be set in other.');
}
if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.');
}
if (!isset($this->other['timestart'])) {
throw new \coding_exception('The \'timestart\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'event', 'restore' => 'event');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['repeatid'] = array('db' => 'event', 'restore' => 'event');
return $othermapped;
}
}
@@ -0,0 +1,133 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* calendar subscription added event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a calendar subscription is added.
*
* @property-read array $other {
* Extra information about the event.
*
* - string eventtype: the type of events (site, course, group, user).
* - int courseid: The ID of the course (SITEID, User(0) or actual course)
* }
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class calendar_subscription_created extends base
{
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'event_subscriptions';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubscriptioncreated', 'calendar');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "User {$this->userid} has added a calendar
subscription with id {$this->objectid} of event type {$this->other['eventtype']}.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
$params = [];
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
$params['course'] = $this->other['courseid'];
if ($this->other['eventtype'] == 'group' && isset($this->other['groupid'])) {
$params['group'] = $this->other['groupid'];
}
}
if ($this->other['eventtype'] == 'category' && isset($this->other['categoryid'])) {
$params['category'] = $this->other['categoryid'];
}
return new \moodle_url('/calendar/managesubscriptions.php', $params);
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->context)) {
throw new \coding_exception('The \'context\' must be set.');
}
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
if (!isset($this->other['eventtype'])) {
throw new \coding_exception('The \'eventtype\' value must be set in other.');
}
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' value must be set in other.');
}
if ($this->other['eventtype'] == 'group' && !isset($this->other['groupid'])) {
throw new \coding_exception('The \'groupid\' value must be set in other.');
}
}
if ($this->other['eventtype'] == 'category' && !isset($this->other['categoryid'])) {
throw new \coding_exception('The \'categoryid\' value must be set in other.');
}
}
/**
* Returns mappings for restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'event_subscriptions', 'restore' => 'event_subscriptions');
}
}
@@ -0,0 +1,141 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* calendar subscription deleted event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a calendar subscription is deleted.
*
* @property-read array $other {
* Extra information about the event.
*
* - int courseid: The ID of the course (SITEID, User(0) or actual course)
* }
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class calendar_subscription_deleted extends base
{
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'event_subscriptions';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubscriptiondeleted', 'calendar');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "User {$this->userid} has deleted a calendar
subscription with id {$this->objectid}.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
$params = [];
if (isset($this->other['eventtype'])) {
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
$params['course'] = $this->other['courseid'];
if ($this->other['eventtype'] == 'group' && isset($this->other['groupid'])) {
$params['group'] = $this->other['groupid'];
}
}
if ($this->other['eventtype'] == 'category' && isset($this->other['categoryid'])) {
$params['category'] = $this->other['categoryid'];
}
} else {
// This is a legacy event.
// Prior to specification of the eventtype there were only two params.
if (($this->other['courseid'] != SITEID) && ($this->other['courseid'] != 0)) {
$params['course'] = $this->other['courseid'];
}
}
return new \moodle_url('/calendar/managesubscriptions.php', $params);
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->context)) {
throw new \coding_exception('The \'context\' must be set.');
}
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
if (!isset($this->other['eventtype'])) {
throw new \coding_exception('The \'eventtype\' value must be set in other.');
}
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' value must be set in other.');
}
if ($this->other['eventtype'] == 'group' && !isset($this->other['groupid'])) {
throw new \coding_exception('The \'groupid\' value must be set in other.');
}
}
if ($this->other['eventtype'] == 'category' && !isset($this->other['categoryid'])) {
throw new \coding_exception('The \'categoryid\' value must be set in other.');
}
}
/**
* Returns mappings for restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'event_subscriptions', 'restore' => 'event_subscriptions');
}
}
@@ -0,0 +1,133 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* calendar subscription updated event.
*
* @package core
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a calendar subscription is updated.
*
* @property-read array $other {
* Extra information about the event.
*
* - string eventtype: the type of events (site, course, group, user).
* - int courseid: The ID of the course (SITEID, User(0) or actual course)
* }
*
* @package core
* @since Moodle 3.2
* @copyright 2016 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class calendar_subscription_updated extends base
{
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'event_subscriptions';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubscriptionupdated', 'calendar');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "User {$this->userid} has updated a calendar
subscription with id {$this->objectid} of event type {$this->other['eventtype']}.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
$params = [];
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
$params['course'] = $this->other['courseid'];
if ($this->other['eventtype'] == 'group' && isset($this->other['groupid'])) {
$params['group'] = $this->other['groupid'];
}
}
if ($this->other['eventtype'] == 'category' && isset($this->other['categoryid'])) {
$params['category'] = $this->other['categoryid'];
}
return new \moodle_url('/calendar/managesubscriptions.php', $params);
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->context)) {
throw new \coding_exception('The \'context\' must be set.');
}
if (!isset($this->objectid)) {
throw new \coding_exception('The \'objectid\' must be set.');
}
if (!isset($this->other['eventtype'])) {
throw new \coding_exception('The \'eventtype\' value must be set in other.');
}
if ($this->other['eventtype'] == 'course' || $this->other['eventtype'] == 'group') {
if (!isset($this->other['courseid'])) {
throw new \coding_exception('The \'courseid\' value must be set in other.');
}
if ($this->other['eventtype'] == 'group' && !isset($this->other['groupid'])) {
throw new \coding_exception('The \'groupid\' value must be set in other.');
}
}
if ($this->other['eventtype'] == 'category' && !isset($this->other['categoryid'])) {
throw new \coding_exception('The \'categoryid\' value must be set in other.');
}
}
/**
* Returns mappings for restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'event_subscriptions', 'restore' => 'event_subscriptions');
}
}
+99
View File
@@ -0,0 +1,99 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Capability assigned event.
*
* @package core
* @since Moodle 3.8
* @copyright 2019 Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Capability assigned event class.
*
* @package core
* @since Moodle 3.8
* @copyright 2019 Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class capability_assigned extends base {
/**
* Initialise event parameters.
*/
protected function init() {
$this->data['objecttable'] = 'role_capabilities';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Returns localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcapabilityassigned', 'role');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
$strpermissions = [
CAP_INHERIT => get_string('notset', 'role'),
CAP_ALLOW => get_string('allow', 'role'),
CAP_PREVENT => get_string('prevent', 'role'),
CAP_PROHIBIT => get_string('prohibit', 'role')
];
$capability = $this->other['capability'];
$oldpermission = $this->other['oldpermission'];
$permission = $this->other['permission'];
if ($oldpermission == CAP_INHERIT && $permission == CAP_ALLOW) {
$description = "The user id '$this->userid' assigned the '$capability' capability for " .
"role '$this->objectid' with '$strpermissions[$permission]' permission";
} else {
$description = "The user id '$this->userid' changed the '$capability' capability permission for " .
"role '$this->objectid' from '$strpermissions[$oldpermission]' to '$strpermissions[$permission]'";
}
return $description;
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
if ($this->contextlevel == CONTEXT_SYSTEM) {
return new \moodle_url('/admin/roles/define.php', ['action' => 'edit', 'roleid' => $this->objectid]);
} else {
return new \moodle_url('/admin/roles/override.php', ['contextid' => $this->contextid,
'roleid' => $this->objectid]);
}
}
}
@@ -0,0 +1,81 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Capability unassigned event.
*
* @package core
* @since Moodle 3.8
* @copyright 2019 Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Capability unassigned event class.
*
* @package core
* @since Moodle 3.8
* @copyright 2019 Simey Lameze <simey@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class capability_unassigned extends base {
/**
* Initialise event parameters.
*/
protected function init() {
$this->data['objecttable'] = 'role_capabilities';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Returns localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcapabilityunassigned', 'role');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
$capability = $this->other['capability'];
return "The user id id '$this->userid' has unassigned the '$capability' capability for role '$this->objectid'";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
if ($this->contextlevel == CONTEXT_SYSTEM) {
return new \moodle_url('/admin/roles/define.php', ['action' => 'view', 'roleid' => $this->objectid]);
} else {
return new \moodle_url('/admin/roles/override.php', ['contextid' => $this->contextid,
'roleid' => $this->objectid]);
}
}
}
+80
View File
@@ -0,0 +1,80 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Cohort updated event.
*
* @package core
* @copyright 2013 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Cohort created event class.
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cohort_created extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'cohort';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcohortcreated', 'core_cohort');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the cohort with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/cohort/index.php', array('contextid' => $this->contextid));
}
public static function get_objectid_mapping() {
// Cohorts are not included in backups, so no mapping is needed for restore.
return array('db' => 'cohort', 'restore' => base::NOT_MAPPED);
}
}
+80
View File
@@ -0,0 +1,80 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Cohort deleted event.
*
* @package core
* @copyright 2013 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Cohort deleted event class.
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cohort_deleted extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'cohort';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcohortdeleted', 'core_cohort');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the cohort with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/cohort/index.php', array('contextid' => $this->contextid));
}
public static function get_objectid_mapping() {
// Cohorts are not included in backups, so no mapping is needed for restore.
return array('db' => 'cohort', 'restore' => base::NOT_MAPPED);
}
}
+95
View File
@@ -0,0 +1,95 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User added to a cohort event.
*
* @package core
* @copyright 2013 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* User added to a cohort event class.
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cohort_member_added extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'cohort';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcohortmemberadded', 'core_cohort');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' added the user with id '$this->relateduserid' to the cohort with " .
"id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/cohort/assign.php', array('id' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
public static function get_objectid_mapping() {
// Cohorts are not included in backups, so no mapping is needed for restore.
return array('db' => 'cohort', 'restore' => base::NOT_MAPPED);
}
}
@@ -0,0 +1,96 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User removed from a cohort event.
*
* @package core
* @copyright 2013 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* User removed from a cohort event class.
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cohort_member_removed extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'cohort';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcohortmemberremoved', 'core_cohort');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' removed the user with id '$this->relateduserid' from the cohort with " .
"id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/cohort/assign.php', array('id' => $this->objectid));
}
/**
* Custom validations.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
}
public static function get_objectid_mapping() {
// Cohorts are not included in backups, so no mapping is needed for restore.
return array('db' => 'cohort', 'restore' => base::NOT_MAPPED);
}
}
+80
View File
@@ -0,0 +1,80 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Cohort updated event.
*
* @package core
* @copyright 2013 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Cohort updated event class.
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class cohort_updated extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'cohort';
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcohortupdated', 'core_cohort');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the cohort with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/cohort/edit.php', array('id' => $this->objectid));
}
public static function get_objectid_mapping() {
// Cohorts are not included in backups, so no mapping is needed for restore.
return array('db' => 'cohort', 'restore' => base::NOT_MAPPED);
}
}
+114
View File
@@ -0,0 +1,114 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Abstract comment created event.
*
* @package core
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Abstract comment created event class.
*
* This class has to be extended by any event which is triggred while creating new comment.
*
* @property-read array $other {
* Extra information about event.
*
* - int itemid: id of item for which comment is added.
* }
*
* @package core
* @since Moodle 2.7
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class comment_created extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'comments';
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcommentcreated', 'moodle');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' added the comment with id '$this->objectid' to the '$this->component' " .
"with course module id '$this->contextinstanceid'.";
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
$context = $this->get_context();
if ($context) {
return $context->get_url();
} else {
return null;
}
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['itemid'])) {
throw new \coding_exception('The \'itemid\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'comments', 'restore' => 'comment');
}
public static function get_other_mapping() {
// We cannot map fields that do not have a 1:1 mapping.
$othermapped = array();
$othermapped['itemid'] = base::NOT_MAPPED;
return $othermapped;
}
}
+114
View File
@@ -0,0 +1,114 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Abstract comment deleted event.
*
* @package core
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Abstract comment deleted event class.
*
* This class has to be extended by any event which is triggred while deleting comment.
*
* @property-read array $other {
* Extra information about event.
*
* - int itemid: id of item for which comment is deleted.
* }
*
* @package core
* @since Moodle 2.7
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class comment_deleted extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'comments';
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcommentdeleted', 'moodle');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the comment with id '$this->objectid' from the '$this->component' " .
"with course module id '$this->contextinstanceid'.";
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
$context = $this->get_context();
if ($context) {
return $context->get_url();
} else {
return null;
}
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['itemid'])) {
throw new \coding_exception('The \'itemid\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'comments', 'restore' => 'comment');
}
public static function get_other_mapping() {
// We cannot map fields that do not have a 1:1 mapping.
$othermapped = array();
$othermapped['itemid'] = base::NOT_MAPPED;
return $othermapped;
}
}
+82
View File
@@ -0,0 +1,82 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Abstract comments viewed event.
*
* @package core
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Abstract comments viewed event class.
*
* This class has to be extended by any event which is triggered while viewing comment.
*
* @package core
* @since Moodle 2.7
* @copyright 2013 Rajesh Taneja <rajesh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class comments_viewed extends base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcommentsviewed', 'moodle');
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the comments for '$this->component' with instance id '$this->objectid'.";
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
$context = $this->get_context();
if ($context) {
return $context->get_url();
} else {
return null;
}
}
}
@@ -0,0 +1,57 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Comment created event for core_competency areas.
*
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Comment created event class for core_competency areas.
*
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_comment_created extends \core\event\comment_created {
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' added the comment with id '$this->objectid' to the '$this->component'";
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return null;
}
}
@@ -0,0 +1,48 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Comment deleted event for core_competency areas.
*
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Comment deleted event class for core_competency areas.
*
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_comment_deleted extends \core\event\comment_deleted {
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the comment with id '$this->objectid' from '$this->component'";
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Competency created event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\competency;
defined('MOODLE_INTERNAL') || die();
/**
* Competency created event class.
*
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_created extends base {
/**
* Convenience method to instantiate the event.
*
* @param competency $competency The competency.
* @return self
*/
public static function create_from_competency(competency $competency) {
if (!$competency->get('id')) {
throw new \coding_exception('The competency ID must be set.');
}
$event = static::create(array(
'contextid' => $competency->get_context()->id,
'objectid' => $competency->get('id')
));
$event->add_record_snapshot(competency::TABLE, $competency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the competency with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcompetencycreated', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::competency($this->objectid, $this->contextid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
+116
View File
@@ -0,0 +1,116 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Competency deleted event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\competency;
defined('MOODLE_INTERNAL') || die();
/**
* Competency deleted event class.
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_deleted extends base {
/**
* Convenience method to instantiate the event.
*
* @param competency $competency The competency.
* @return self
*/
public static function create_from_competency(competency $competency) {
if (!$competency->get('id')) {
throw new \coding_exception('The competency ID must be set.');
}
$event = static::create(array(
'contextid' => $competency->get_context()->id,
'objectid' => $competency->get('id'),
));
$event->add_record_snapshot(competency::TABLE, $competency->to_record());
return $event;
}
/**
* Instantiate events from competency ids.
*
* @param array $competencyids Array of competency ids.
* @param int $contextid The context id.
* @return self[] Array of events.
*/
public static function create_multiple_from_competencyids($competencyids, $contextid) {
$events = array();
foreach ($competencyids as $id) {
$events[$id] = static::create(array(
'contextid' => $contextid,
'objectid' => $id
));
}
return $events;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the competency with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcompetencydeleted', 'core_competency');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,171 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Evidence created event.
*
* @package core_competency
* @copyright 2016 Jun Pataleta <jun@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\evidence;
use core_competency\user_competency;
defined('MOODLE_INTERNAL') || die();
/**
* Evidence created event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int usercompetencyid: The user_competency ID linked to the evidence.
* - int competencyid: The competency ID linked to the evidence from user_competency.
* - int action: The action constant.
* - bool recommend: The recommend flag.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Jun Pataleta <jun@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_evidence_created extends base {
/**
* Convenience method to instantiate the event.
*
* @param evidence $evidence The evidence.
* @param user_competency $usercompetency The user competency object linked to the evidence.
* @param bool $recommend The recommend flag.
* @return evidence_created
* @throws \coding_exception
*/
final public static function create_from_evidence(evidence $evidence, user_competency $usercompetency, $recommend) {
// Make sure we have a valid evidence.
if (!$evidence->get('id')) {
throw new \coding_exception('The evidence ID must be set.');
}
// Make sure we have a valid user competency.
if (!$usercompetency->get('id')) {
throw new \coding_exception('The user competency ID must be set.');
}
// Make sure that the a proper user competecy is linked to the evidence.
if ($evidence->get('usercompetencyid') != $usercompetency->get('id')) {
throw new \coding_exception('The user competency linked with this evidence is invalid.');
}
$event = static::create([
'contextid' => $evidence->get('contextid'),
'objectid' => $evidence->get('id'),
'userid' => $evidence->get('actionuserid'),
'relateduserid' => $usercompetency->get('userid'),
'other' => [
'usercompetencyid' => $usercompetency->get('id'),
'competencyid' => $usercompetency->get('competencyid'),
'action' => $evidence->get('action'),
'recommend' => $recommend
]
]);
// Add record snapshot for the evidence.
$event->add_record_snapshot(evidence::TABLE, $evidence->to_record());
// Add record snapshot for the user competency.
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventevidencecreated', 'core_competency');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created an evidence with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency($this->other['usercompetencyid']);
}
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = evidence::TABLE;
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Validate the data.
*
* @throws \coding_exception
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->relateduserid)) {
throw new \coding_exception('The \'relateduserid\' must be set.');
}
if (!isset($this->other['usercompetencyid'])) {
throw new \coding_exception('The \'usercompetencyid\' data in \'other\' must be set.');
}
if (!isset($this->other['competencyid'])) {
throw new \coding_exception('The \'competencyid\' data in \'other\' must be set.');
}
if (!isset($this->other['action'])) {
throw new \coding_exception('The \'action\' data in \'other\' must be set.');
}
if (!isset($this->other['recommend'])) {
throw new \coding_exception('The \'recommend\' data in \'other\' must be set.');
}
}
}
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Competency framework created event.
*
* @package core_competency
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\competency_framework;
defined('MOODLE_INTERNAL') || die();
/**
* Competency framework created event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_framework_created extends base {
/**
* Convenience method to instantiate the event.
*
* @param competency_framework $framework The framework.
* @return self
*/
final public static function create_from_framework(competency_framework $framework) {
if (!$framework->get('id')) {
throw new \coding_exception('The competency framework ID must be set.');
}
$event = static::create(array(
'contextid' => $framework->get('contextid'),
'objectid' => $framework->get('id')
));
$event->add_record_snapshot(competency_framework::TABLE, $framework->to_record());
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcompetencyframeworkcreated', 'core_competency');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the competency framework with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::framework($this->objectid, $this->contextid);
}
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = competency_framework::TABLE;
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,102 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Competency framework deleted event.
*
* @package core_competency
* @copyright 2016 Serge Gauthier
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\competency_framework;
defined('MOODLE_INTERNAL') || die();
/**
* Competency framework deleted event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_framework_deleted extends base {
/**
* Convenience method to instantiate the event.
*
* @param competency_framework $framework The framework.
* @return self
*/
final public static function create_from_framework(competency_framework $framework) {
if (!$framework->get('id')) {
throw new \coding_exception('The competency framework ID must be set.');
}
$event = static::create(array(
'contextid' => $framework->get('contextid'),
'objectid' => $framework->get('id')
));
$event->add_record_snapshot(competency_framework::TABLE, $framework->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the competency framework with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcompetencyframeworkdeleted', 'core_competency');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = competency_framework::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,111 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Competency framework updated event.
*
* @package core_competency
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\competency_framework;
defined('MOODLE_INTERNAL') || die();
/**
* Competency framework updated event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_framework_updated extends base {
/**
* Convenience method to instantiate the event.
*
* @param competency_framework $framework The framework.
* @return self
*/
final public static function create_from_framework(competency_framework $framework) {
if (!$framework->get('id')) {
throw new \coding_exception('The competency framework ID must be set.');
}
$event = static::create(array(
'contextid' => $framework->get('contextid'),
'objectid' => $framework->get('id')
));
$event->add_record_snapshot(competency_framework::TABLE, $framework->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the competency framework with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcompetencyframeworkupdated', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::framework($this->objectid, $this->contextid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = competency_framework::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,107 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Competency framework viewed event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\competency_framework;
defined('MOODLE_INTERNAL') || die();
/**
* Competency framework viewed event class.
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_framework_viewed extends base {
/**
* Convenience method to instantiate the event.
*
* @param competency_framework $framework The framework.
* @return self
*/
public static function create_from_framework(competency_framework $framework) {
if (!$framework->get('id')) {
throw new \coding_exception('The competency framework ID must be set.');
}
$event = static::create(array(
'contextid' => $framework->get('contextid'),
'objectid' => $framework->get('id')
));
$event->add_record_snapshot(competency_framework::TABLE, $framework->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the competency framework with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcompetencyframeworkviewed', 'core_competency');
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::framework($this->objectid, $this->contextid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = competency_framework::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan approved event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan approved event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_approved extends base {
/**
* Convenience method to instantiate the plan approved event.
*
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id'),
'relateduserid' => $plan->get('userid'),
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' approved the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplanapproved', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan completed event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan completed event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_completed extends base {
/**
* Convenience method to instantiate the plan completed event.
*
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id'),
'relateduserid' => $plan->get('userid'),
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' completed the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplancompleted', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan created event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan created event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_created extends base {
/**
* Convenience method to instantiate the event.
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id')
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplancreated', 'core_competency');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the learning plan with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = plan::TABLE;
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,102 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan deleted event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan deleted event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_deleted extends base {
/**
* Convenience method to instantiate the event.
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id')
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplandeleted', 'core_competency');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan reopened event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan reopened event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_reopened extends base {
/**
* Convenience method to instantiate the plan reopened event.
*
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id'),
'relateduserid' => $plan->get('userid'),
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' reopened the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplanreopened', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan review request cancelled event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan review request cancelled event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_review_request_cancelled extends base {
/**
* Convenience method to instantiate the plan review request cancelled event.
*
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id'),
'relateduserid' => $plan->get('userid'),
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' cancelled a review request for the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplanreviewrequestcancelled', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan review requested event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan review requested event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_review_requested extends base {
/**
* Convenience method to instantiate the plan review requested event.
*
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id'),
'relateduserid' => $plan->get('userid'),
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' sent a review request for the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplanreviewrequested', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan review started event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan review started event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_review_started extends base {
/**
* Convenience method to instantiate the plan review started event.
*
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id'),
'relateduserid' => $plan->get('userid'),
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' started a review for the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplanreviewstarted', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan review stopped event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan review stopped event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_review_stopped extends base {
/**
* Convenience method to instantiate the plan review stopped event.
*
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id'),
'relateduserid' => $plan->get('userid'),
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' stopped a review for the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplanreviewstopped', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan unapproved event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan unapproved event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_unapproved extends base {
/**
* Convenience method to instantiate the plan unapproved event.
*
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id'),
'relateduserid' => $plan->get('userid'),
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' unapproved the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplanunapproved', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,110 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan unlinked event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan unlinked event class.
*
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_unlinked extends base {
/**
* Convenience method to instantiate the plan unlinked event.
*
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id'),
'relateduserid' => $plan->get('userid'),
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' unlinked the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplanunlinked', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan updated event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan updated event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_updated extends base {
/**
* Convenience method to instantiate the event.
*
* Actions triggering this event will NOT trigger the underlying plan_updated for related plans.
*
* @param plan $plan The plan.
* @return self
*/
final public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id')
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the learning plan with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplanupdated', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Plan viewed event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\plan;
defined('MOODLE_INTERNAL') || die();
/**
* Plan viewed event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_plan_viewed extends base {
/**
* Convenience method to instantiate the event.
*
* @param plan $plan The plan.
* @return self
*/
public static function create_from_plan(plan $plan) {
if (!$plan->get('id')) {
throw new \coding_exception('The plan ID must be set.');
}
$event = static::create(array(
'contextid' => $plan->get_context()->id,
'objectid' => $plan->get('id')
));
$event->add_record_snapshot(plan::TABLE, $plan->to_record());
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventplanviewed', 'core_competency');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the learning plan with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::plan($this->objectid);
}
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = plan::TABLE;
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Template created event.
*
* @package core_competency
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\template;
defined('MOODLE_INTERNAL') || die();
/**
* Template created event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_template_created extends base {
/**
* Convenience method to instantiate the event.
*
* @param template $template The template.
* @return self
*/
final public static function create_from_template(template $template) {
if (!$template->get('id')) {
throw new \coding_exception('The template ID must be set.');
}
$event = static::create(array(
'contextid' => $template->get('contextid'),
'objectid' => $template->get('id')
));
$event->add_record_snapshot(template::TABLE, $template->to_record());
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventtemplatecreated', 'core_competency');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the template with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::template($this->objectid, $this->contextid);
}
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = template::TABLE;
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,102 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Template deleted event.
*
* @package core_competency
* @copyright 2016 Serge Gauthier
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\template;
defined('MOODLE_INTERNAL') || die();
/**
* Template deleted event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_template_deleted extends base {
/**
* Convenience method to instantiate the event.
*
* @param template $template The template.
* @return self
*/
final public static function create_from_template(template $template) {
if (!$template->get('id')) {
throw new \coding_exception('The template ID must be set.');
}
$event = static::create(array(
'contextid' => $template->get('contextid'),
'objectid' => $template->get('id')
));
$event->add_record_snapshot(template::TABLE, $template->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the template with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventtemplatedeleted', 'core_competency');
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = template::TABLE;;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,113 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Template updated event.
*
* @package core_competency
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\template;
defined('MOODLE_INTERNAL') || die();
/**
* Template updated event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_template_updated extends base {
/**
* Convenience method to instantiate the event.
*
* Actions triggering this event will NOT trigger the underlying plan_updated for related plans.
*
* @param template $template The template.
* @return self
*/
final public static function create_from_template(template $template) {
if (!$template->get('id')) {
throw new \coding_exception('The template ID must be set.');
}
$event = static::create(array(
'contextid' => $template->get('contextid'),
'objectid' => $template->get('id')
));
$event->add_record_snapshot(template::TABLE, $template->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the template with id '$this->objectid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventtemplateupdated', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::template($this->objectid, $this->contextid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = template::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Template viewed event.
*
* @package core_competency
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\template;
defined('MOODLE_INTERNAL') || die();
/**
* Template viewed event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_template_viewed extends base {
/**
* Convenience method to instantiate the event.
*
* @param template $template The template.
* @return self
*/
public static function create_from_template(template $template) {
if (!$template->get('id')) {
throw new \coding_exception('The template ID must be set.');
}
$event = static::create(array(
'contextid' => $template->get('contextid'),
'objectid' => $template->get('id')
));
$event->add_record_snapshot(template::TABLE, $template->to_record());
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventtemplateviewed', 'core_competency');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the template with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::template($this->objectid, $this->contextid);
}
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = template::TABLE;
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Competency updated event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\competency;
defined('MOODLE_INTERNAL') || die();
/**
* Competency updated event class.
*
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_updated extends base {
/**
* Convenience method to instantiate the event.
*
* @param competency $competency The competency.
* @return self
*/
public static function create_from_competency(competency $competency) {
if (!$competency->get('id')) {
throw new \coding_exception('The competency ID must be set.');
}
$event = static::create(array(
'contextid' => $competency->get_context()->id,
'objectid' => $competency->get('id')
));
$event->add_record_snapshot(competency::TABLE, $competency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the competency with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcompetencyupdated', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::competency($this->objectid, $this->contextid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,139 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency plan viewed event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency_plan;
defined('MOODLE_INTERNAL') || die();
/**
* User competency plan viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int planid: id of plan for which competency is associated.
* - int competencyid: id of the competency.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_plan_viewed extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_competency_plan $usercompetencyplan The user competency plan.
* @return self
*/
public static function create_from_user_competency_plan(user_competency_plan $usercompetencyplan) {
if (!$usercompetencyplan->get('id')) {
throw new \coding_exception('The user competency plan ID must be set.');
}
$event = static::create(array(
'contextid' => $usercompetencyplan->get_context()->id,
'objectid' => $usercompetencyplan->get('id'),
'relateduserid' => $usercompetencyplan->get('userid'),
'other' => array(
'planid' => $usercompetencyplan->get('planid'),
'competencyid' => $usercompetencyplan->get('competencyid')
)
));
$event->add_record_snapshot(user_competency_plan::TABLE, $usercompetencyplan->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the user competency plan with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyplanviewed', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency_in_plan($this->relateduserid, $this->other['competencyid'],
$this->other['planid']);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = user_competency_plan::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if ($this->other === null) {
throw new \coding_exception('The \'competencyid\' and \'planid\' values must be set.');
}
if (!isset($this->other['competencyid'])) {
throw new \coding_exception('The \'competencyid\' value must be set.');
}
if (!isset($this->other['planid'])) {
throw new \coding_exception('The \'planid\' value must be set.');
}
}
}
@@ -0,0 +1,135 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency grade rated event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency;
defined('MOODLE_INTERNAL') || die();
/**
* User competency grade rated event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int grade: grade name of the user competency
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_rated extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_competency $usercompetency The user competency.
* @return self
*/
public static function create_from_user_competency(user_competency $usercompetency) {
if (!$usercompetency->get('id')) {
throw new \coding_exception('The user competency ID must be set.');
}
$params = array(
'contextid' => $usercompetency->get_context()->id,
'objectid' => $usercompetency->get('id'),
'relateduserid' => $usercompetency->get('userid'),
'other' => array(
'grade' => $usercompetency->get('grade')
)
);
$event = static::create($params);
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' rated the user competency with id '$this->objectid' "
. "with '" . $this->other['grade'] . "' rating";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyrated', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = user_competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if (!$this->relateduserid) {
throw new \coding_exception('The \'relateduserid\' value must be set.');
}
if (!isset($this->other) || !isset($this->other['grade'])) {
throw new \coding_exception('The \'grade\' value must be set.');
}
}
}
@@ -0,0 +1,150 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency grade rated in course event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency_course;
use context_course;
defined('MOODLE_INTERNAL') || die();
/**
* User competency grade rated in course event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int competencyid: id of competency.
* - int grade: grade name of the user competency
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_rated_in_course extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_competency_course $usercompetencycourse The user competency course.
* @return self
*/
public static function create_from_user_competency_course(user_competency_course $usercompetencycourse) {
if (!$usercompetencycourse->get('id')) {
throw new \coding_exception('The user competency course ID must be set.');
}
$params = array(
'objectid' => $usercompetencycourse->get('id'),
'relateduserid' => $usercompetencycourse->get('userid'),
'other' => array(
'competencyid' => $usercompetencycourse->get('competencyid'),
'grade' => $usercompetencycourse->get('grade')
)
);
$coursecontext = context_course::instance($usercompetencycourse->get('courseid'));
$params['contextid'] = $coursecontext->id;
$params['courseid'] = $usercompetencycourse->get('courseid');
$event = static::create($params);
$event->add_record_snapshot(user_competency_course::TABLE, $usercompetencycourse->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' rated the user competency with id '$this->objectid' with "
. "'" . $this->other['grade'] . "' rating "
. "in course with id '$this->courseid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyratedincourse', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency_in_course($this->relateduserid, $this->other['competencyid'],
$this->courseid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = user_competency_course::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if (!isset($this->other) || !isset($this->other['competencyid'])) {
throw new \coding_exception('The \'competencyid\' value must be set.');
}
if (!$this->courseid) {
throw new \coding_exception('The \'courseid\' value must be set.');
}
if (!$this->relateduserid) {
throw new \coding_exception('The \'relateduserid\' value must be set.');
}
if (!isset($this->other['grade'])) {
throw new \coding_exception('The \'grade\' value must be set.');
}
}
}
@@ -0,0 +1,150 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency grade rated in course event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency;
defined('MOODLE_INTERNAL') || die();
/**
* User competency grade rated in plan event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int competencyid: id of competency.
* - int grade: grade name of the user competency
* - int planid: the plan id
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_rated_in_plan extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_competency $usercompetency The user competency.
* @param int $planid The plan ID
* @return self
*/
public static function create_from_user_competency(user_competency $usercompetency, $planid) {
if (!$usercompetency->get('id')) {
throw new \coding_exception('The user competency ID must be set.');
}
$params = array(
'contextid' => $usercompetency->get_context()->id,
'objectid' => $usercompetency->get('id'),
'relateduserid' => $usercompetency->get('userid'),
'other' => array(
'competencyid' => $usercompetency->get('competencyid'),
'grade' => $usercompetency->get('grade'),
'planid' => $planid
)
);
$event = static::create($params);
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' rated the user competency with id '$this->objectid' with "
. "'" . $this->other['grade'] . "' rating "
. "in plan with id '" . $this->other['grade'] . "'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyratedinplan', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency_in_plan($this->relateduserid, $this->other['competencyid'],
$this->other['planid']);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = user_competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if (!isset($this->other) || !isset($this->other['competencyid'])) {
throw new \coding_exception('The \'competencyid\' value must be set.');
}
if (!isset($this->other['planid'])) {
throw new \coding_exception('The \'planid\' value must be set.');
}
if (!$this->relateduserid) {
throw new \coding_exception('The \'relateduserid\' value must be set.');
}
if (!isset($this->other['grade'])) {
throw new \coding_exception('The \'grade\' value must be set.');
}
}
}
@@ -0,0 +1,121 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency review requested event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency;
defined('MOODLE_INTERNAL') || die();
/**
* User competency review requested event class.
*
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_review_request_cancelled extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_competency $usercompetency The user competency.
* @return self
*/
public static function create_from_user_competency(user_competency $usercompetency) {
if (!$usercompetency->get('id')) {
throw new \coding_exception('The user competency ID must be set.');
}
$params = array(
'contextid' => $usercompetency->get_context()->id,
'objectid' => $usercompetency->get('id'),
'relateduserid' => $usercompetency->get('userid')
);
$event = static::create($params);
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' cancelled a review request for the user competency with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyreviewrequestcancelled', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = user_competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if (!$this->relateduserid) {
throw new \coding_exception('The \'relateduserid\' value must be set.');
}
}
}
@@ -0,0 +1,121 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency review requested event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency;
defined('MOODLE_INTERNAL') || die();
/**
* User competency review requested event class.
*
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_review_requested extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_competency $usercompetency The user competency.
* @return self
*/
public static function create_from_user_competency(user_competency $usercompetency) {
if (!$usercompetency->get('id')) {
throw new \coding_exception('The user competency ID must be set.');
}
$params = array(
'contextid' => $usercompetency->get_context()->id,
'objectid' => $usercompetency->get('id'),
'relateduserid' => $usercompetency->get('userid')
);
$event = static::create($params);
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' sent a review request for the user competency with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyreviewrequested', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = user_competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if (!$this->relateduserid) {
throw new \coding_exception('The \'relateduserid\' value must be set.');
}
}
}
@@ -0,0 +1,121 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency review started event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency;
defined('MOODLE_INTERNAL') || die();
/**
* User competency review started event class.
*
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_review_started extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_competency $usercompetency The user competency.
* @return self
*/
public static function create_from_user_competency(user_competency $usercompetency) {
if (!$usercompetency->get('id')) {
throw new \coding_exception('The user competency ID must be set.');
}
$params = array(
'contextid' => $usercompetency->get_context()->id,
'objectid' => $usercompetency->get('id'),
'relateduserid' => $usercompetency->get('userid')
);
$event = static::create($params);
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' started a review for the user competency with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyreviewstarted', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = user_competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if (!$this->relateduserid) {
throw new \coding_exception('The \'relateduserid\' value must be set.');
}
}
}
@@ -0,0 +1,121 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency review stopped event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency;
defined('MOODLE_INTERNAL') || die();
/**
* User competency review stopped event class.
*
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_review_stopped extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_competency $usercompetency The user competency.
* @return self
*/
public static function create_from_user_competency(user_competency $usercompetency) {
if (!$usercompetency->get('id')) {
throw new \coding_exception('The user competency ID must be set.');
}
$params = array(
'contextid' => $usercompetency->get_context()->id,
'objectid' => $usercompetency->get('id'),
'relateduserid' => $usercompetency->get('userid')
);
$event = static::create($params);
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' stopped a review for the user competency with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyreviewstopped', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_TEACHING;
$this->data['objecttable'] = user_competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if (!$this->relateduserid) {
throw new \coding_exception('The \'relateduserid\' value must be set.');
}
}
}
@@ -0,0 +1,130 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency viewed event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency;
use context_course;
defined('MOODLE_INTERNAL') || die();
/**
* User competency viewed event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int competencyid: id of competency.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_viewed extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_competency $usercompetency The user competency.
* @return self
*/
public static function create_from_user_competency_viewed(user_competency $usercompetency) {
if (!$usercompetency->get('id')) {
throw new \coding_exception('The user competency ID must be set.');
}
$params = array(
'contextid' => $usercompetency->get_context()->id,
'objectid' => $usercompetency->get('id'),
'relateduserid' => $usercompetency->get('userid'),
'other' => array(
'competencyid' => $usercompetency->get('competencyid')
)
);
$event = static::create($params);
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the user competency with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyviewed', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency($this->objectid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = user_competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if (!isset($this->other) || !isset($this->other['competencyid'])) {
throw new \coding_exception('The \'competencyid\' value must be set.');
}
}
}
@@ -0,0 +1,138 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency viewed event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency_course;
use context_course;
defined('MOODLE_INTERNAL') || die();
/**
* User competency viewed in course event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int competencyid: id of competency.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_viewed_in_course extends base {
/**
* Convenience method to instantiate the event in course.
*
* @param user_competency_course $usercompetencycourse The user competency for the course.
* @return self
*/
public static function create_from_user_competency_viewed_in_course(user_competency_course $usercompetencycourse) {
if (!$usercompetencycourse->get('id')) {
throw new \coding_exception('The user competency course ID must be set.');
}
$params = array(
'objectid' => $usercompetencycourse->get('id'),
'relateduserid' => $usercompetencycourse->get('userid'),
'other' => array(
'competencyid' => $usercompetencycourse->get('competencyid')
)
);
$coursecontext = context_course::instance($usercompetencycourse->get('courseid'));
$params['contextid'] = $coursecontext->id;
$params['courseid'] = $usercompetencycourse->get('courseid');
$event = static::create($params);
$event->add_record_snapshot(user_competency_course::TABLE, $usercompetencycourse->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the user course competency with id '$this->objectid' "
. "in course with id '$this->courseid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyviewedincourse', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency_in_course($this->relateduserid, $this->other['competencyid'],
$this->courseid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = user_competency_course::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if (!$this->courseid) {
throw new \coding_exception('The \'courseid\' value must be set.');
}
if (!isset($this->other) || !isset($this->other['competencyid'])) {
throw new \coding_exception('The \'competencyid\' value must be set.');
}
}
}
@@ -0,0 +1,143 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* User competency viewed event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_competency;
use context_course;
defined('MOODLE_INTERNAL') || die();
/**
* User competency viewed in plan event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int planid: id of plan for which competency is associated.
* - int competencyid: id of competency.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_competency_viewed_in_plan extends base {
/**
* Convenience method to instantiate the event in plan.
*
* @param user_competency $usercompetency The user competency.
* @param int $planid The pland ID
* @return self
*/
public static function create_from_user_competency_viewed_in_plan(user_competency $usercompetency, $planid) {
if (!$usercompetency->get('id')) {
throw new \coding_exception('The user competency ID must be set.');
}
$params = array(
'contextid' => $usercompetency->get_context()->id,
'objectid' => $usercompetency->get('id'),
'relateduserid' => $usercompetency->get('userid'),
'other' => array(
'competencyid' => $usercompetency->get('competencyid'),
'planid' => $planid
)
);
$event = static::create($params);
$event->add_record_snapshot(user_competency::TABLE, $usercompetency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the user competency with id '$this->objectid' "
. "in plan with id '" . $this->other['planid'] . "'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventusercompetencyviewedinplan', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_competency_in_plan($this->relateduserid, $this->other['competencyid'],
$this->other['planid']);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = user_competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
/**
* Custom validation.
*
* Throw \coding_exception notice in case of any problems.
*/
protected function validate_data() {
if ($this->other === null) {
throw new \coding_exception('The \'competencyid\' and \'planid\' values must be set.');
}
if (!isset($this->other['competencyid'])) {
throw new \coding_exception('The \'competencyid\' value must be set.');
}
if (!isset($this->other['planid'])) {
throw new \coding_exception('The \'planid\' value must be set.');
}
}
}
@@ -0,0 +1,109 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Evidence of prior learning created event.
*
* @package core_competency
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_evidence;
defined('MOODLE_INTERNAL') || die();
/**
* Evidence of prior learning created event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_evidence_created extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_evidence $userevidence The evidence of prior learning.
* @return self
*/
final public static function create_from_user_evidence(user_evidence $userevidence) {
if (!$userevidence->get('id')) {
throw new \coding_exception('The evidence of prior learning ID must be set.');
}
$event = static::create(array(
'contextid' => $userevidence->get_context()->id,
'objectid' => $userevidence->get('id'),
'relateduserid' => $userevidence->get('userid')
));
$event->add_record_snapshot(user_evidence::TABLE, $userevidence->to_record());
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventuserevidencecreated', 'core_competency');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the evidence of prior learning with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_evidence($this->objectid);
}
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = user_evidence::TABLE;
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,100 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Evidence of prior learning deleted event.
*
* @package core_competency
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_evidence;
defined('MOODLE_INTERNAL') || die();
/**
* Evidence of prior learning deleted event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_evidence_deleted extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_evidence $userevidence The evidence of prior learning.
* @return self
*/
final public static function create_from_user_evidence(user_evidence $userevidence) {
if (!$userevidence->get('id')) {
throw new \coding_exception('The evidence of prior learning ID must be set.');
}
$event = static::create(array(
'contextid' => $userevidence->get_context()->id,
'objectid' => $userevidence->get('id'),
'relateduserid' => $userevidence->get('userid')
));
$event->add_record_snapshot(user_evidence::TABLE, $userevidence->to_record());
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventuserevidencedeleted', 'core_competency');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the evidence of prior learning with id '$this->objectid'.";
}
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = user_evidence::TABLE;
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,109 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Evidence of prior learning updated event.
*
* @package core_competency
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\user_evidence;
defined('MOODLE_INTERNAL') || die();
/**
* Evidence of prior learning updated event class.
*
* @property-read array $other {
* Extra information about event.
* }
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Serge Gauthier <serge.gauthier.2@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_user_evidence_updated extends base {
/**
* Convenience method to instantiate the event.
*
* @param user_evidence $userevidence The evidence of prior learning.
* @return self
*/
final public static function create_from_user_evidence(user_evidence $userevidence) {
if (!$userevidence->get('id')) {
throw new \coding_exception('The evidence of prior learning ID must be set.');
}
$event = static::create(array(
'contextid' => $userevidence->get_context()->id,
'objectid' => $userevidence->get('id'),
'relateduserid' => $userevidence->get('userid')
));
$event->add_record_snapshot(user_evidence::TABLE, $userevidence->to_record());
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventuserevidenceupdated', 'core_competency');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the evidence of prior learning with id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::user_evidence($this->objectid);
}
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = user_evidence::TABLE;
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
+108
View File
@@ -0,0 +1,108 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Competency viewed event.
*
* @package core_competency
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use core\event\base;
use core_competency\competency;
defined('MOODLE_INTERNAL') || die();
/**
* Competency viewed event class.
*
*
* @package core_competency
* @since Moodle 3.1
* @copyright 2016 Issam Taboubi <issam.taboubi@umontreal.ca>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class competency_viewed extends base {
/**
* Convenience method to instantiate the event.
*
* @param competency $competency The competency.
* @return self
*/
public static function create_from_competency(competency $competency) {
if (!$competency->get('id')) {
throw new \coding_exception('The competency ID must be set.');
}
$event = static::create(array(
'contextid' => $competency->get_context()->id,
'objectid' => $competency->get('id')
));
$event->add_record_snapshot(competency::TABLE, $competency->to_record());
return $event;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the competency with id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcompetencyviewed', 'core_competency');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return \core_competency\url::competency($this->objectid, $this->contextid);
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = competency::TABLE;
}
/**
* Get_objectid_mapping method.
*
* @return string the name of the restore mapping the objectid links to
*/
public static function get_objectid_mapping() {
return base::NOT_MAPPED;
}
}
@@ -0,0 +1,101 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Default completion for activity in a course updated event
*
* @package core
* @copyright 2017 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Default completion for activity in a course updated event
*
* @package core
* @since Moodle 3.3
* @copyright 2017 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class completion_defaults_updated extends base {
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = 'course_completion_defaults';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventdefaultcompletionupdated', 'completion');
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/course/defaultcompletion.php', array('id' => $this->courseid));
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the default completion for module " .
"'{$this->other['modulename']}' in course with id '$this->courseid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
*/
protected function validate_data() {
parent::validate_data();
if ($this->contextlevel != CONTEXT_COURSE) {
throw new \coding_exception('Context passed must be course context.');
}
if (!isset($this->other['modulename'])) {
throw new \coding_exception('The \'modulename\' value must be set in other.');
}
}
/**
* This is used when restoring course logs where it is required that we
* map the objectid to it's new value in the new course.
*
* @return array
*/
public static function get_objectid_mapping() {
parent::get_objectid_mapping();
return array('db' => 'course_completion_defaults', 'restore' => 'course_completion_defaults');
}
}
+120
View File
@@ -0,0 +1,120 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Config log created.
*
* @package core
* @copyright 2017 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
use moodle_url;
/**
* Event class for when an admin config log is created.
*
* @property-read array $other {
* Extra information about event.
*
* - string name: name of config setting
* - string plugin: name of plugin
* - string oldvalue: previous value
* - string value: new value
* }
*
* @package core
* @copyright 2017 Damyon Wiese
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class config_log_created extends base {
/**
* Initialise required event data properties.
*/
protected function init() {
$this->data['objecttable'] = 'config_log';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Returns localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventconfiglogcreated');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
$name = $this->other['name'];
$plugin = isset($this->other['plugin']) ? $this->other['plugin'] : 'core';
$value = isset($this->other['value']) ? $this->other['value'] : 'Not set';
$oldvalue = isset($this->other['oldvalue']) ? $this->other['oldvalue'] : 'Not set';
return "The user with id '$this->userid' changed the config setting '$name' for component '$plugin' " .
"from '$oldvalue' to '$value'.";
}
/**
* Returns relevant URL.
*
* @return moodle_url
*/
public function get_url() {
return new moodle_url('/report/configlog/index.php', [
'search' => $this->other['name'],
]);
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.');
}
if (!array_key_exists('plugin', $this->other)) {
throw new \coding_exception('The \'plugin\' value must be set in other.');
}
if (!array_key_exists('oldvalue', $this->other)) {
throw new \coding_exception('The \'oldvalue\' value must be set in other.');
}
if (!array_key_exists('value', $this->other)) {
throw new \coding_exception('The \'value\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
// Config log is not mappable.
return array('db' => 'config_log', 'restore' => base::NOT_MAPPED);
}
public static function get_other_mapping() {
return false;
}
}
+124
View File
@@ -0,0 +1,124 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Abstract event for content viewing.
*
* This class has been deprecated, please extend base event or other relevent abstract class.
*
* @package core
* @copyright 2013 Ankit Agarwal
* @deprecated since Moodle 2.7
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
debugging('core\event\content_viewed has been deprecated. Please extend base event or other relevant abstract class.',
DEBUG_DEVELOPER);
/**
* Class content_viewed.
*
* This class has been deprecated, please extend base event or other relevent abstract class.
*
* @property-read array $other {
* Extra information about the event.
*
* - string content: name of the content viewed.
* }
*
* @package core
* @since Moodle 2.6
* @copyright 2013 Ankit Agarwal
* @deprecated since Moodle 2.7
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class content_viewed extends base {
/** @var null|array $legacylogdata Legacy log data */
protected $legacylogdata = null;
/**
* Set basic properties of the event.
*/
protected function init() {
global $PAGE;
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->context = $PAGE->context;
}
/**
* Set basic page properties.
*/
public function set_page_detail() {
global $PAGE;
if (!isset($this->data['other'])) {
$this->data['other'] = array();
}
$this->data['other'] = array_merge(array('url' => $PAGE->url->out_as_local_url(false),
'heading' => $PAGE->heading,
'title' => $PAGE->title), $this->data['other']);
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcontentviewed', 'moodle');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed content.";
}
/**
* Custom validation.
*
* @throws \coding_exception when validation does not pass.
* @return void
*/
protected function validate_data() {
parent::validate_data();
// Make sure this class is never used without a content identifier.
if (empty($this->other['content'])) {
throw new \coding_exception('The \'content\' value must be set in other.');
}
}
public static function get_other_mapping() {
return false;
}
/**
* This event has been deprected.
*
* @return boolean
*/
public static function is_deprecated() {
return true;
}
}
@@ -0,0 +1,137 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contentbank content created event.
*
* @package core
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
/**
* Content bank content created class.
*
* @property-read array $other {
* Extra information about event.
* - string contenttype: the contenttype of the content.
* - string name: the name of the content.
* }
*
* @package core
* @since Moodle 3.9
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class contentbank_content_created extends base {
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = 'contentbank_content';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Creates an event from content bank content object
*
* @since Moodle 3.9
* @param \stdClass $record Data to create the event
* @return contentbank_content_created
*/
public static function create_from_record(\stdClass $record) {
$event = self::create([
'objectid' => $record->id,
'relateduserid' => $record->usercreated,
'context' => \context::instance_by_id($record->contextid),
'other' => [
'contenttype' => $record->contenttype,
'name' => $record->name
]
]);
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcontentcreated', 'core_contentbank');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created the content with id '$this->objectid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['contenttype'])) {
throw new \coding_exception('The \'contenttype\' value must be set in other.');
}
if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.');
}
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
$url = new \moodle_url('/contentbank/view.php');
$url->param('id', $this->objectid);
return $url;
}
/**
* Used for mapping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'contentbank_content', 'restore' => 'contentbank_content');
}
/**
* Used for mapping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
// No mapping required.
return false;
}
}
@@ -0,0 +1,126 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contentbank content deleted event.
*
* @package core
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
/**
* Content bank content deleted class.
*
* @property-read array $other {
* Extra information about event.
* - string contenttype: the contenttype of the content.
* - string name: the name of the content.
* }
*
* @package core
* @since Moodle 3.9
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class contentbank_content_deleted extends base {
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = 'contentbank_content';
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Creates an event from content bank content object
*
* @since Moodle 3.9
* @param \stdClass $record Data to create the event
* @return contentbank_content_deleted
*/
public static function create_from_record(\stdClass $record) {
$event = self::create([
'objectid' => $record->id,
'relateduserid' => $record->usercreated,
'context' => \context::instance_by_id($record->contextid),
'other' => [
'contenttype' => $record->contenttype,
'name' => $record->name
]
]);
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcontentdeleted', 'core_contentbank');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the content with id '$this->objectid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['contenttype'])) {
throw new \coding_exception('The \'contenttype\' value must be set in other.');
}
if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.');
}
}
/**
* Used for mapping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'contentbank_content', 'restore' => 'contentbank_content');
}
/**
* Used for mapping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
// No mapping required.
return false;
}
}
@@ -0,0 +1,137 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contentbank content uploaded event.
*
* @package core
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
/**
* Content bank content updated class.
*
* @property-read array $other {
* Extra information about event.
* - string contenttype: the contenttype of the content.
* - string name: the name of the content.
* }
*
* @package core
* @since Moodle 3.9
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class contentbank_content_updated extends base {
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = 'contentbank_content';
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Creates an event from content bank content object
*
* @since Moodle 3.9
* @param \stdClass $record Data to create the event
* @return contentbank_content_updated
*/
public static function create_from_record(\stdClass $record) {
$event = self::create([
'objectid' => $record->id,
'relateduserid' => $record->usercreated,
'context' => \context::instance_by_id($record->contextid),
'other' => [
'contenttype' => $record->contenttype,
'name' => $record->name
]
]);
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcontentupdated', 'core_contentbank');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' updated the content with id '$this->objectid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['contenttype'])) {
throw new \coding_exception('The \'contenttype\' value must be set in other.');
}
if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.');
}
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
$url = new \moodle_url('/contentbank/view.php');
$url->param('id', $this->objectid);
return $url;
}
/**
* Used for mapping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'contentbank_content', 'restore' => 'contentbank_content');
}
/**
* Used for mapping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
// No mapping required.
return false;
}
}
@@ -0,0 +1,137 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contentbank content uploaded event.
*
* @package core
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
/**
* Content bank content uploaded class.
*
* @property-read array $other {
* Extra information about event.
* - string contenttype: the contenttype of the content.
* - string name: the name of the content.
* }
*
* @package core
* @since Moodle 3.9
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class contentbank_content_uploaded extends base {
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = 'contentbank_content';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Creates an event from content bank content object
*
* @since Moodle 3.9
* @param \stdClass $record Data to create the event
* @return contentbank_content_uploaded
*/
public static function create_from_record(\stdClass $record) {
$event = self::create([
'objectid' => $record->id,
'relateduserid' => $record->usercreated,
'context' => \context::instance_by_id($record->contextid),
'other' => [
'contenttype' => $record->contenttype,
'name' => $record->name
]
]);
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcontentuploaded', 'core_contentbank');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' uploaded the content with id '$this->objectid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['contenttype'])) {
throw new \coding_exception('The \'contenttype\' value must be set in other.');
}
if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.');
}
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
$url = new \moodle_url('/contentbank/view.php');
$url->param('id', $this->objectid);
return $url;
}
/**
* Used for mapping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'contentbank_content', 'restore' => 'contentbank_content');
}
/**
* Used for mapping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
// No mapping required.
return false;
}
}
@@ -0,0 +1,137 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Contentbank content viewed event.
*
* @package core
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
/**
* Content bank content updated class.
*
* @property-read array $other {
* Extra information about event.
* - string contenttype: the contenttype of the content.
* - string name: the name of the content.
* }
*
* @package core
* @since Moodle 3.9
* @copyright 2020 Amaia Anabitarte <amaia@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class contentbank_content_viewed extends base {
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = 'contentbank_content';
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Creates an event from content bank content object
*
* @since Moodle 3.9
* @param \stdClass $record Data to create the event
* @return contentbank_content_viewed
*/
public static function create_from_record(\stdClass $record) {
$event = self::create([
'objectid' => $record->id,
'relateduserid' => $record->usercreated,
'context' => \context::instance_by_id($record->contextid),
'other' => [
'contenttype' => $record->contenttype,
'name' => $record->name
]
]);
return $event;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcontentviewed', 'core_contentbank');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' viewed the content with id '$this->objectid'.";
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['contenttype'])) {
throw new \coding_exception('The \'contenttype\' value must be set in other.');
}
if (!isset($this->other['name'])) {
throw new \coding_exception('The \'name\' value must be set in other.');
}
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
$url = new \moodle_url('/contentbank/view.php');
$url->param('id', $this->objectid);
return $url;
}
/**
* Used for mapping events on restore
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'contentbank_content', 'restore' => 'contentbank_content');
}
/**
* Used for mapping events on restore
*
* @return bool
*/
public static function get_other_mapping() {
// No mapping required.
return false;
}
}
+85
View File
@@ -0,0 +1,85 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Context locked event.
*
* @package core_access
* @copyright 2019 University of Nottingham
* @author Neill Magill <neill.magill@nottingham.ac.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a context has been frozen.
*
* @package core_access
* @since Moodle 3.8
* @copyright 2019 University of Nottingham
* @author Neill Magill <neill.magill@nottingham.ac.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class context_locked extends base {
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' locked the context with id '$this->objectid' ";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcontextlocked', 'access');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
// Try to get the url for the context.
try {
$context = \context::instance_by_id($this->objectid);
$url = $context->get_url();
} catch (\dml_missing_record_exception $e) {
// The context no longer exists, give them the system url instead.
$url = \context_system::instance()->get_url();
}
return $url;
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'context';
}
}
+85
View File
@@ -0,0 +1,85 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Context unlocked event.
*
* @package core_access
* @copyright 2019 University of Nottingham
* @author Neill Magill <neill.magill@nottingham.ac.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Event triggered after a context has been unfrozen.
*
* @package core_access
* @since Moodle 3.8
* @copyright 2019 University of Nottingham
* @author Neill Magill <neill.magill@nottingham.ac.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class context_unlocked extends base {
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' unlocked the context with id '$this->objectid' ";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcontextunlocked', 'access');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
// Try to get the url for the context.
try {
$context = \context::instance_by_id($this->objectid);
$url = $context->get_url();
} catch (\dml_missing_record_exception $e) {
// The context no longer exists, give them the system url instead.
$url = \context_system::instance()->get_url();
}
return $url;
}
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'context';
}
}
+118
View File
@@ -0,0 +1,118 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Course backup created event.
*
* @package core
* @copyright 2017 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\event;
defined('MOODLE_INTERNAL') || die();
/**
* Course backup created event class.
*
* @property-read array $other {
* Extra information about event.
*
* - string format: Format of backup (moodle, imscc)
* - int mode: execution mode.
* - boolean interactive: Interactive mode (yes/no)
* - string type: backup type
* }
*
* @package core
* @since Moodle 3.4
* @copyright 2017 Stephen Bourget
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_backup_created extends base {
/**
* Initialise the event data.
*/
protected function init() {
$this->data['objecttable'] = 'course';
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_TEACHING;
}
/**
* Returns localised general event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcoursebackupcreated');
}
/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' created a backup of the course with the id '$this->objectid'.";
}
/**
* Returns relevant URL.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/course/view.php', array('id' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['format'])) {
throw new \coding_exception('The \'format\' value must be set in other.');
}
if (!isset($this->other['mode'])) {
throw new \coding_exception('The \'mode\' value must be set in other.');
}
if (!isset($this->other['interactive'])) {
throw new \coding_exception('The \'interactive\' value must be set in other.');
}
if (!isset($this->other['type'])) {
throw new \coding_exception('The \'type\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'course', 'restore' => 'course');
}
public static function get_other_mapping() {
// No need to map anything.
return false;
}
}

Some files were not shown because too many files have changed in this diff Show More