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,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/>.
/**
* The mod_forum assessable uploaded event.
*
* @package mod_forum
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum assessable uploaded event class.
*
* @property-read array $other {
* Extra information about event.
*
* - int discussionid: id of discussion.
* - string triggeredfrom: name of the function from where event was triggered.
* }
*
* @package mod_forum
* @since Moodle 2.6
* @copyright 2013 Frédéric Massart
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class assessable_uploaded extends \core\event\assessable_uploaded {
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has posted content in the forum post with id '$this->objectid' " .
"in the discussion '{$this->other['discussionid']}' located in the forum with course module id " .
"'$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventassessableuploaded', 'mod_forum');
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/discuss.php', array('d' => $this->other['discussionid'], 'parent' => $this->objectid));
}
/**
* Init method.
*
* @return void
*/
protected function init() {
parent::init();
$this->data['objecttable'] = 'forum_posts';
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['discussionid'])) {
throw new \coding_exception('The \'discussionid\' value must be set in other.');
} else if (!isset($this->other['triggeredfrom'])) {
throw new \coding_exception('The \'triggeredfrom\' value must be set in other.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_posts', 'restore' => 'forum_post');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['discussionid'] = array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
return $othermapped;
}
}
@@ -0,0 +1,39 @@
<?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 mod_forum instance list viewed event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum instance list viewed event class.
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_instance_list_viewed extends \core\event\course_module_instance_list_viewed {
// No need for any code here as everything is handled by the parent class.
}
@@ -0,0 +1,63 @@
<?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 mod_forum course module viewed event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum course module viewed event class.
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_viewed extends \core\event\course_module_viewed {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'forum';
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/view.php', array('f' => $this->objectid));
}
public static function get_objectid_mapping() {
return array('db' => 'forum', 'restore' => 'forum');
}
}
+106
View File
@@ -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/>.
/**
* The mod_forum course searched event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum course searched event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - string searchterm: The searchterm used on forum search.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_searched extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
$searchterm = s($this->other['searchterm']);
return "The user with id '$this->userid' has searched the course with id '$this->courseid' for forum posts " .
"containing \"{$searchterm}\".";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventcoursesearched', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/search.php',
array('id' => $this->courseid, 'search' => $this->other['searchterm']));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['searchterm'])) {
throw new \coding_exception('The \'searchterm\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_COURSE) {
throw new \coding_exception('Context level must be CONTEXT_COURSE.');
}
}
public static function get_other_mapping() {
return false;
}
}
@@ -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/>.
/**
* The mod_forum discussion created event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum discussion created event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int forumid: The id of the forum the discussion is in.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class discussion_created extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'forum_discussions';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has created the discussion with id '$this->objectid' in the forum " .
"with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventdiscussioncreated', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/discuss.php', array('d' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
return $othermapped;
}
}
@@ -0,0 +1,112 @@
<?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 mod_forum discussion deleted event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum discussion deleted event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int forumid: The id of the forum the discussion is in.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class discussion_deleted extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'forum_discussions';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has deleted the discussion with id '$this->objectid' in the forum " .
"with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventdiscussiondeleted', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/view.php', array('id' => $this->contextinstanceid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
return $othermapped;
}
}
@@ -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/>.
namespace mod_forum\event;
use coding_exception;
use moodle_url;
/**
* The mod_forum discussion lock updated event.
*
* @package mod_forum
* @copyright 2022 Université Rennes 2 {@link https://www.univ-rennes2.fr}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class discussion_lock_updated extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init(): void {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'forum_discussions';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description(): string {
return "The user with id '$this->userid' {$this->other['status']} the discussion: $this->objectid".
" in the forum: {$this->other['forumid']}";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name(): string {
return get_string('eventdiscussionlockupdated', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return moodle_url
*/
public function get_url(): moodle_url {
return new moodle_url('/mod/forum/discuss.php', ['d' => $this->objectid]);
}
/**
* Custom validation.
*
* @throws coding_exception
* @return void
*/
protected function validate_data(): void {
parent::validate_data();
if (!isset($this->other['forumid'])) {
throw new coding_exception('forumid must be set in $other.');
}
if (!isset($this->other['status'])) {
throw new \coding_exception('The \'status\' value must be set in other.');
}
if (!in_array($this->other['status'], ['locked', 'unlocked'], true)) {
throw new \coding_exception('The \'status\' value must be \'locked\' or \'unlocked\'.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new coding_exception('Context passed must be module context.');
}
if (!isset($this->objectid)) {
throw new coding_exception('objectid must be set to the discussionid.');
}
}
/**
* Forum discussion object id mappings.
*
* @return array
*/
public static function get_objectid_mapping(): array {
return ['db' => 'forum_discussions', 'restore' => 'forum_discussion'];
}
/**
* Forum id mappings.
*
* @return array
*/
public static function get_other_mapping(): array {
return ['forumid' => ['db' => 'forum', 'restore' => 'forum']];
}
}
@@ -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/>.
/**
* The mod_forum discussion moved event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum discussion moved event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int fromforumid: The id of the forum the discussion is being moved from.
* - int toforumid: The id of the forum the discussion is being moved to.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class discussion_moved extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'forum_discussions';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has moved the discussion with id '$this->objectid' from the " .
"forum with id '{$this->other['fromforumid']}' to the forum with id '{$this->other['toforumid']}'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventdiscussionmoved', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/discuss.php', array('d' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['fromforumid'])) {
throw new \coding_exception('The \'fromforumid\' value must be set in other.');
}
if (!isset($this->other['toforumid'])) {
throw new \coding_exception('The \'toforumid\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['fromforumid'] = array('db' => 'forum', 'restore' => 'forum');
$othermapped['toforumid'] = array('db' => 'forum', 'restore' => 'forum');
return $othermapped;
}
}
@@ -0,0 +1,112 @@
<?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 mod_forum discussion pinned event.
*
* @package mod_forum
* @copyright 2014 Charles Fulton <fultonc@lafayette.edu>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum discussion pinned event.
*
* @package mod_forum
* @copyright 2014 Charles Fulton <fultonc@lafayette.edu>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class discussion_pinned extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'forum_discussions';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user {$this->userid} has pinned the discussion {$this->objectid} in the forum {$this->other['forumid']}";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventdiscussionpinned', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/discuss.php', array('d' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['forumid'])) {
throw new \coding_exception('forumid must be set in $other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context passed must be module context.');
}
if (!isset($this->objectid)) {
throw new \coding_exception('objectid must be set to the discussionid.');
}
}
/**
* Forum discussion object id mappings.
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
}
/**
* Forum id mappings.
*
* @return array
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
return $othermapped;
}
}
@@ -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/>.
/**
* The mod_forum discussion_subscription created event.
*
* @package mod_forum
* @copyright 2014 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum discussion_subscription created event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int forumid: The id of the forum which the discussion is in.
* - int discussion: The id of the discussion which has been subscribed to.
* }
*
* @package mod_forum
* @since Moodle 2.8
* @copyright 2014 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class discussion_subscription_created extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'forum_discussion_subs';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' subscribed the user with id '$this->relateduserid' to the discussion " .
" with id '{$this->other['discussion']}' in the forum with the course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventdiscussionsubscriptioncreated', 'mod_forum');
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/subscribe.php', array(
'id' => $this->other['forumid'],
'd' => $this->other['discussion'],
));
}
/**
* Custom validation.
*
* @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->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if (!isset($this->other['discussion'])) {
throw new \coding_exception('The \'discussion\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_discussion_subs', 'restore' => 'forum_discussion_sub');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
$othermapped['discussion'] = array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
return $othermapped;
}
}
@@ -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/>.
/**
* The mod_forum discussion_subscription deleted event.
*
* @package mod_forum
* @copyright 2014 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum discussion_subscription deleted event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int forumid: The id of the forum which the discussion is in.
* - int discussion: The id of the discussion which has been unsubscribed from.
* }
*
* @package mod_forum
* @since Moodle 2.8
* @copyright 2014 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class discussion_subscription_deleted extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'forum_discussion_subs';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' unsubscribed the user with id '$this->relateduserid' from the discussion " .
" with id '{$this->other['discussion']}' in the forum with the course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventdiscussionsubscriptiondeleted', 'mod_forum');
}
/**
* Get URL related to the action.
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/subscribe.php', array(
'id' => $this->other['forumid'],
'd' => $this->other['discussion'],
));
}
/**
* Custom validation.
*
* @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->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if (!isset($this->other['discussion'])) {
throw new \coding_exception('The \'discussion\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_discussion_subs', 'restore' => 'forum_discussion_sub');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
$othermapped['discussion'] = array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
return $othermapped;
}
}
@@ -0,0 +1,112 @@
<?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 mod_forum discussion unpinned event.
*
* @package mod_forum
* @copyright 2014 Charles Fulton <fultonc@lafayette.edu>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum discussion unpinned event.
*
* @package mod_forum
* @copyright 2014 Charles Fulton <fultonc@lafayette.edu>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class discussion_unpinned extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'forum_discussions';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user {$this->userid} has unpinned the discussion {$this->objectid} in the forum {$this->other['forumid']}";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventdiscussionunpinned', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/discuss.php', array('d' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['forumid'])) {
throw new \coding_exception('forumid must be set in $other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context passed must be module context.');
}
if (!isset($this->objectid)) {
throw new \coding_exception('objectid must be set to the discussionid.');
}
}
/**
* Forum discussion object id mappings.
*
* @return array
*/
public static function get_objectid_mapping() {
return array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
}
/**
* Forum id mappings.
*
* @return array
*/
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
return $othermapped;
}
}
@@ -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/>.
/**
* The mod_forum discussion updated event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum discussion updated event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int forumid: The id of the forum the discussion is in
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class discussion_updated extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'forum_discussions';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has updated the discussion with id '$this->objectid' in the forum " .
"with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventdiscussionupdated', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/discuss.php', array('d' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
return $othermapped;
}
}
@@ -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/>.
/**
* The mod_forum discussion viewed event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum discussion viewed event class.
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class discussion_viewed extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'forum_discussions';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has viewed the discussion with id '$this->objectid' in the forum " .
"with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventdiscussionviewed', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/discuss.php', array('d' => $this->objectid));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
}
}
+131
View File
@@ -0,0 +1,131 @@
<?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 mod_forum post created event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum post created event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int discussionid: The discussion id the post is part of.
* - int forumid: The forum id the post is part of.
* - string forumtype: The type of forum the post is part of.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class post_created extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'forum_posts';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has created the post with id '$this->objectid' in the discussion with " .
"id '{$this->other['discussionid']}' in the forum with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventpostcreated', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
if ($this->other['forumtype'] == 'single') {
// Single discussion forums are an exception. We show
// the forum itself since it only has one discussion
// thread.
$url = new \moodle_url('/mod/forum/view.php', array('f' => $this->other['forumid']));
} else {
$url = new \moodle_url('/mod/forum/discuss.php', array('d' => $this->other['discussionid']));
}
$url->set_anchor('p'.$this->objectid);
return $url;
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['discussionid'])) {
throw new \coding_exception('The \'discussionid\' value must be set in other.');
}
if (!isset($this->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if (!isset($this->other['forumtype'])) {
throw new \coding_exception('The \'forumtype\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_posts', 'restore' => 'forum_post');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
$othermapped['discussionid'] = array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
return $othermapped;
}
}
+130
View File
@@ -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/>.
/**
* The mod_forum post deleted event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum post deleted event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int discussionid: The discussion id the post is part of.
* - int forumid: The forum id the post is part of.
* - string forumtype: The type of forum the post is part of.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class post_deleted extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'forum_posts';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has deleted the post with id '$this->objectid' in the discussion with " .
"id '{$this->other['discussionid']}' in the forum with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventpostdeleted', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
if ($this->other['forumtype'] == 'single') {
// Single discussion forums are an exception. We show
// the forum itself since it only has one discussion
// thread.
$url = new \moodle_url('/mod/forum/view.php', array('f' => $this->other['forumid']));
} else {
$url = new \moodle_url('/mod/forum/discuss.php', array('d' => $this->other['discussionid']));
}
return $url;
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['discussionid'])) {
throw new \coding_exception('The \'discussionid\' value must be set in other.');
}
if (!isset($this->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if (!isset($this->other['forumtype'])) {
throw new \coding_exception('The \'forumtype\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_posts', 'restore' => 'forum_post');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
$othermapped['discussionid'] = array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
return $othermapped;
}
}
+131
View File
@@ -0,0 +1,131 @@
<?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 mod_forum post updated event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum post updated event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int discussionid: The discussion id the post is part of.
* - int forumid: The forum id the post is part of.
* - string forumtype: The type of forum the post is part of.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class post_updated extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'forum_posts';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has updated the post with id '$this->objectid' in the discussion with " .
"id '{$this->other['discussionid']}' in the forum with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventpostupdated', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
if ($this->other['forumtype'] == 'single') {
// Single discussion forums are an exception. We show
// the forum itself since it only has one discussion
// thread.
$url = new \moodle_url('/mod/forum/view.php', array('f' => $this->other['forumid']));
} else {
$url = new \moodle_url('/mod/forum/discuss.php', array('d' => $this->other['discussionid']));
}
$url->set_anchor('p'.$this->objectid);
return $url;
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['discussionid'])) {
throw new \coding_exception('The \'discussionid\' value must be set in other.');
}
if (!isset($this->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if (!isset($this->other['forumtype'])) {
throw new \coding_exception('The \'forumtype\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_posts', 'restore' => 'forum_post');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
$othermapped['discussionid'] = array('db' => 'forum_discussions', 'restore' => 'forum_discussion');
return $othermapped;
}
}
@@ -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/>.
/**
* The mod_forum subscription created event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum subscription created event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int forumid: The id of the forum which read tracking has been disabled on.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class readtracking_disabled extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has disabled read tracking for the user with id '$this->relateduserid' " .
"in the forum with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventreadtrackingdisabled', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/view.php', array('f' => $this->other['forumid']));
}
/**
* Custom validation.
*
* @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->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
return $othermapped;
}
}
@@ -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/>.
/**
* The mod_forum read tracking enabled event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum read tracking enabled event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int forumid: The id of the forum which readtracking has been enabled on.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class readtracking_enabled extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has enabled read tracking for the user with id '$this->relateduserid' " .
"in the forum with course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventreadtrackingenabled', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/view.php', array('f' => $this->other['forumid']));
}
/**
* Custom validation.
*
* @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->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
return $othermapped;
}
}
@@ -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/>.
/**
* The mod_forum subscribers list viewed event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum subscribers list viewed event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int forumid: The id of the forum which the subscriberslist has been viewed.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class subscribers_viewed extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has viewed the subscribers list for the forum with course " .
"module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubscribersviewed', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/subscribers.php', array('id' => $this->other['forumid']));
}
/**
* Custom validation.
*
* @throws \coding_exception
* @return void
*/
protected function validate_data() {
parent::validate_data();
if (!isset($this->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
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/>.
/**
* The mod_forum subscription created event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum subscription created event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int forumid: The id of the forum which has been subscribed to.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class subscription_created extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'forum_subscriptions';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' subscribed the user with id '$this->relateduserid' to the forum with " .
"course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubscriptioncreated', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/subscribers.php', array('id' => $this->other['forumid']));
}
/**
* Custom validation.
*
* @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->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_subscriptions', 'restore' => 'forum_subscription');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
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/>.
/**
* The mod_forum subscription deleted event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum subscription deleted event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - int forumid: The id of the forum which has been unsusbcribed from.
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class subscription_deleted extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'forum_subscriptions';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' unsubscribed the user with id '$this->relateduserid' to the forum with " .
"course module id '$this->contextinstanceid'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventsubscriptiondeleted', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
return new \moodle_url('/mod/forum/subscribers.php', array('id' => $this->other['forumid']));
}
/**
* Custom validation.
*
* @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->other['forumid'])) {
throw new \coding_exception('The \'forumid\' value must be set in other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new \coding_exception('Context level must be CONTEXT_MODULE.');
}
}
public static function get_objectid_mapping() {
return array('db' => 'forum_subscriptions', 'restore' => 'forum_subscription');
}
public static function get_other_mapping() {
$othermapped = array();
$othermapped['forumid'] = array('db' => 'forum', 'restore' => 'forum');
return $othermapped;
}
}
@@ -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/>.
namespace mod_forum\event;
use coding_exception;
use moodle_url;
/**
* The mod_forum subscription mode updated event.
*
* @package mod_forum
* @copyright 2022 Université Rennes 2 {@link https://www.univ-rennes2.fr}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class subscription_mode_updated extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init(): void {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
$this->data['objecttable'] = 'forum';
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description(): string {
return "The user with id '$this->userid' has updated the forum subscription
from mode '{$this->other['oldvalue']}' to mode '{$this->other['newvalue']}' in the forum id '$this->objectid'";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name(): string {
return get_string('eventforumsubscriptionupdated', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return moodle_url
*/
public function get_url(): moodle_url {
return new moodle_url('/mod/forum/subscribers.php', ['id' => $this->objectid]);
}
/**
* Custom validation.
*
* @throws coding_exception
* @return void
*/
protected function validate_data(): void {
parent::validate_data();
if (!isset($this->other['oldvalue'])) {
throw new coding_exception('oldvalue must be set in $other.');
}
if (!isset($this->other['newvalue'])) {
throw new coding_exception('newvalue must be set in $other.');
}
if ($this->contextlevel != CONTEXT_MODULE) {
throw new coding_exception('Context passed must be module context.');
}
if (!isset($this->objectid)) {
throw new coding_exception('objectid must be set to the forumid.');
}
}
/**
* Forum object id mappings.
*
* @return array
*/
public static function get_objectid_mapping(): array {
return ['db' => 'forum', 'restore' => 'forum'];
}
}
@@ -0,0 +1,123 @@
<?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 mod_forum user report viewed event.
*
* @package mod_forum
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_forum\event;
defined('MOODLE_INTERNAL') || die();
/**
* The mod_forum user report viewed event class.
*
* @property-read array $other {
* Extra information about the event.
*
* - string reportmode: The mode the report has been viewed in (posts or discussions).
* }
*
* @package mod_forum
* @since Moodle 2.7
* @copyright 2014 Dan Poltawski <dan@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class user_report_viewed extends \core\event\base {
/**
* Init method.
*
* @return void
*/
protected function init() {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
}
/**
* Returns description of what happened.
*
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' has viewed the user report for the user with id '$this->relateduserid' in " .
"the course with id '$this->courseid' with viewing mode '{$this->other['reportmode']}'.";
}
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventuserreportviewed', 'mod_forum');
}
/**
* Get URL related to the action
*
* @return \moodle_url
*/
public function get_url() {
$url = new \moodle_url('/mod/forum/user.php', array('id' => $this->relateduserid,
'mode' => $this->other['reportmode']));
if ($this->courseid != SITEID) {
$url->param('course', $this->courseid);
}
return $url;
}
/**
* Custom validation.
*
* @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->other['reportmode'])) {
throw new \coding_exception('The \'reportmode\' value must be set in other.');
}
switch ($this->contextlevel)
{
case CONTEXT_COURSE:
case CONTEXT_SYSTEM:
case CONTEXT_USER:
// OK, expected context level.
break;
default:
// Unexpected contextlevel.
throw new \coding_exception('Context level must be either CONTEXT_SYSTEM, CONTEXT_COURSE or CONTEXT_USER.');
}
}
public static function get_other_mapping() {
return false;
}
}