From f3d981897e25c27cd9d51f4030686206fd1da81f Mon Sep 17 00:00:00 2001 From: Mark Nelson Date: Thu, 17 Apr 2014 15:52:34 -0700 Subject: [PATCH] MDL-43557 events: renamed event class names 1) The core 'item_tagged' class was renamed to 'tag_added'. 2) The core 'item_untagged' class was renamed to 'tag_removed'. 3) The core 'message_read' class was renamed to 'message_viewed'. 4) The mod_forum 'userreport_viewed' class was renamed to 'user_report_viewed'. 5) The report_outline 'activity_viewed' was renamed to 'activity_report_viewed'. 6) The report_outline 'outline_viewed' was renamed to 'report_viewed'. --- lang/en/message.php | 2 +- lang/en/tag.php | 4 +- .../{message_read.php => message_viewed.php} | 6 +-- .../event/{item_tagged.php => tag_added.php} | 6 +-- .../{item_untagged.php => tag_removed.php} | 6 +-- message/lib.php | 2 +- message/tests/events_test.php | 6 +-- ...port_viewed.php => user_report_viewed.php} | 2 +- mod/forum/tests/events_test.php | 26 ++++++------- mod/forum/user.php | 2 +- ..._viewed.php => activity_report_viewed.php} | 2 +- .../{outline_viewed.php => report_viewed.php} | 2 +- report/outline/index.php | 4 +- report/outline/user.php | 2 +- tag/lib.php | 20 +++++----- tag/tests/events_test.php | 38 +++++++++---------- 16 files changed, 65 insertions(+), 65 deletions(-) rename lib/classes/event/{message_read.php => message_viewed.php} (94%) rename lib/classes/event/{item_tagged.php => tag_added.php} (96%) rename lib/classes/event/{item_untagged.php => tag_removed.php} (95%) rename mod/forum/classes/event/{userreport_viewed.php => user_report_viewed.php} (98%) rename report/outline/classes/event/{activity_viewed.php => activity_report_viewed.php} (97%) rename report/outline/classes/event/{outline_viewed.php => report_viewed.php} (98%) diff --git a/lang/en/message.php b/lang/en/message.php index 9ebe157085af1..ffe93e432bd4c 100644 --- a/lang/en/message.php +++ b/lang/en/message.php @@ -58,7 +58,7 @@ $string['eventmessagecontactblocked'] = 'Message contact blocked'; $string['eventmessagecontactremoved'] = 'Message contact removed'; $string['eventmessagecontactunblocked'] = 'Message contact unblocked'; -$string['eventmessageread'] = 'Message read'; +$string['eventmessageviewed'] = 'Message viewed'; $string['eventmessagesent'] = 'Message sent'; $string['forced'] = 'Forced'; $string['formorethan'] = 'For more than'; diff --git a/lang/en/tag.php b/lang/en/tag.php index 11c1651446e76..247b7ccb4fdc4 100644 --- a/lang/en/tag.php +++ b/lang/en/tag.php @@ -36,11 +36,11 @@ $string['entertags'] = 'Enter tags separated by commas'; $string['errortagfrontpage'] = 'Tagging the site main page is not allowed'; $string['errorupdatingrecord'] = 'Error updating tag record'; -$string['eventitemtagged'] = 'Item tagged'; -$string['eventitemuntagged'] = 'Item untagged'; +$string['eventtagadded'] = 'Tag added to an item'; $string['eventtagcreated'] = 'Tag created'; $string['eventtagdeleted'] = 'Tag deleted'; $string['eventtagflagged'] = 'Tag flagged'; +$string['eventtagremoved'] = 'Tag removed from an item'; $string['eventtagunflagged'] = 'Tag unflagged'; $string['eventtagupdated'] = 'Tag updated'; $string['flag'] = 'Flag'; diff --git a/lib/classes/event/message_read.php b/lib/classes/event/message_viewed.php similarity index 94% rename from lib/classes/event/message_read.php rename to lib/classes/event/message_viewed.php index 3ed0a5f9b5209..904b3940a6e1b 100644 --- a/lib/classes/event/message_read.php +++ b/lib/classes/event/message_viewed.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Message read event class. + * Message viewed event class. * * @property-read array $other { * Extra information about event. @@ -32,7 +32,7 @@ defined('MOODLE_INTERNAL') || die(); -class message_read extends base { +class message_viewed extends base { /** * Init method. @@ -49,7 +49,7 @@ protected function init() { * @return string */ public static function get_name() { - return get_string('eventmessageread', 'message'); + return get_string('eventmessageviewed', 'message'); } /** diff --git a/lib/classes/event/item_tagged.php b/lib/classes/event/tag_added.php similarity index 96% rename from lib/classes/event/item_tagged.php rename to lib/classes/event/tag_added.php index 1eb4996897c62..bad019bb85617 100644 --- a/lib/classes/event/item_tagged.php +++ b/lib/classes/event/tag_added.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Item tagged event. + * Event for when a tag has been added to an item. * * @property-read array $other { * Extra information about event. @@ -37,7 +37,7 @@ defined('MOODLE_INTERNAL') || die(); -class item_tagged extends base { +class tag_added extends base { /** * Initialise the event data. @@ -54,7 +54,7 @@ protected function init() { * @return string */ public static function get_name() { - return get_string('eventitemtagged', 'tag'); + return get_string('eventtagadded', 'tag'); } /** diff --git a/lib/classes/event/item_untagged.php b/lib/classes/event/tag_removed.php similarity index 95% rename from lib/classes/event/item_untagged.php rename to lib/classes/event/tag_removed.php index da60d869d1d2f..2ac45231ecacb 100644 --- a/lib/classes/event/item_untagged.php +++ b/lib/classes/event/tag_removed.php @@ -15,7 +15,7 @@ // along with Moodle. If not, see . /** - * Item untagged event. + * Event for when a tag has been removed from an item. * * @property-read array $other { * Extra information about event. @@ -37,7 +37,7 @@ defined('MOODLE_INTERNAL') || die(); -class item_untagged extends base { +class tag_removed extends base { /** * Initialise the event data. @@ -54,7 +54,7 @@ protected function init() { * @return string */ public static function get_name() { - return get_string('eventitemuntagged', 'tag'); + return get_string('eventtagremoved', 'tag'); } /** diff --git a/message/lib.php b/message/lib.php index 5efe92001dfb0..9d8b974a81302 100644 --- a/message/lib.php +++ b/message/lib.php @@ -2378,7 +2378,7 @@ function message_mark_message_read($message, $timeread, $messageworkingempty=fal $DB->delete_records('message', array('id' => $messageid)); // Trigger event for reading a message. - $event = \core\event\message_read::create(array( + $event = \core\event\message_viewed::create(array( 'objectid' => $messagereadid, 'userid' => $message->useridto, // Using the user who read the message as they are the ones performing the action. 'context' => context_user::instance($message->useridto), diff --git a/message/tests/events_test.php b/message/tests/events_test.php index e7f1a5e3885c2..2486b03b9ac7d 100644 --- a/message/tests/events_test.php +++ b/message/tests/events_test.php @@ -179,9 +179,9 @@ public function test_message_sent() { } /** - * Test the message read event. + * Test the message viewed event. */ - public function test_message_read() { + public function test_message_viewed() { global $DB; // Create a message to mark as read. @@ -199,7 +199,7 @@ public function test_message_read() { $event = reset($events); // Check that the event data is valid. - $this->assertInstanceOf('\core\event\message_read', $event); + $this->assertInstanceOf('\core\event\message_viewed', $event); $this->assertEquals(context_user::instance(2), $event->get_context()); $url = new moodle_url('/message/index.php', array('user1' => $event->userid, 'user2' => $event->relateduserid)); $this->assertEquals($url, $event->get_url()); diff --git a/mod/forum/classes/event/userreport_viewed.php b/mod/forum/classes/event/user_report_viewed.php similarity index 98% rename from mod/forum/classes/event/userreport_viewed.php rename to mod/forum/classes/event/user_report_viewed.php index a91f249a693c9..dc2d522dd6edf 100644 --- a/mod/forum/classes/event/userreport_viewed.php +++ b/mod/forum/classes/event/user_report_viewed.php @@ -37,7 +37,7 @@ * @copyright 2014 Dan Poltawski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class userreport_viewed extends \core\event\base { +class user_report_viewed extends \core\event\base { /** * Init method. diff --git a/mod/forum/tests/events_test.php b/mod/forum/tests/events_test.php index d11e800af6a7b..2570ced95f8f8 100644 --- a/mod/forum/tests/events_test.php +++ b/mod/forum/tests/events_test.php @@ -1083,9 +1083,9 @@ public function test_subscribers_viewed() { } /** - * Ensure userreport_viewed event validates that the reportmode is set. + * Ensure user_report_viewed event validates that the reportmode is set. */ - public function test_userreport_viewed_reportmode_validation() { + public function test_user_report_viewed_reportmode_validation() { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); @@ -1095,13 +1095,13 @@ public function test_userreport_viewed_reportmode_validation() { ); $this->setExpectedException('coding_exception', 'reportmode must be set in other.'); - \mod_forum\event\userreport_viewed::create($params); + \mod_forum\event\user_report_viewed::create($params); } /** - * Ensure userreport_viewed event validates that the contextlevel is correct. + * Ensure user_report_viewed event validates that the contextlevel is correct. */ - public function test_userreport_viewed_contextlevel_validation() { + public function test_user_report_viewed_contextlevel_validation() { $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); $forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id)); @@ -1113,13 +1113,13 @@ public function test_userreport_viewed_contextlevel_validation() { ); $this->setExpectedException('coding_exception', 'Context passed must be system or course.'); - \mod_forum\event\userreport_viewed::create($params); + \mod_forum\event\user_report_viewed::create($params); } /** - * Ensure userreport_viewed event validates that the relateduserid is set. + * Ensure user_report_viewed event validates that the relateduserid is set. */ - public function test_userreport_viewed_relateduserid_validation() { + public function test_user_report_viewed_relateduserid_validation() { $params = array( 'context' => context_system::instance(), @@ -1127,13 +1127,13 @@ public function test_userreport_viewed_relateduserid_validation() { ); $this->setExpectedException('coding_exception', 'relateduserid must be set.'); - \mod_forum\event\userreport_viewed::create($params); + \mod_forum\event\user_report_viewed::create($params); } /** - * Test the userreport_viewed event. + * Test the user_report_viewed event. */ - public function test_userreport_viewed() { + public function test_user_report_viewed() { // Setup test data. $user = $this->getDataGenerator()->create_user(); $course = $this->getDataGenerator()->create_course(); @@ -1145,7 +1145,7 @@ public function test_userreport_viewed() { 'other' => array('reportmode' => 'discussions'), ); - $event = \mod_forum\event\userreport_viewed::create($params); + $event = \mod_forum\event\user_report_viewed::create($params); // Trigger and capture the event. $sink = $this->redirectEvents(); @@ -1155,7 +1155,7 @@ public function test_userreport_viewed() { $event = reset($events); // Checking that the event contains the expected values. - $this->assertInstanceOf('\mod_forum\event\userreport_viewed', $event); + $this->assertInstanceOf('\mod_forum\event\user_report_viewed', $event); $this->assertEquals($context, $event->get_context()); $expected = array($course->id, 'forum', 'user report', "user.php?id={$user->id}&mode=discussions&course={$course->id}", $user->id); diff --git a/mod/forum/user.php b/mod/forum/user.php index b6ddb4e47c3ec..87aba79caaf66 100644 --- a/mod/forum/user.php +++ b/mod/forum/user.php @@ -121,7 +121,7 @@ 'relateduserid' => $user->id, 'other' => array('reportmode' => $mode), ); -$event = \mod_forum\event\userreport_viewed::create($params); +$event = \mod_forum\event\user_report_viewed::create($params); $event->trigger(); // Get the posts by the requested user that the current user can access. diff --git a/report/outline/classes/event/activity_viewed.php b/report/outline/classes/event/activity_report_viewed.php similarity index 97% rename from report/outline/classes/event/activity_viewed.php rename to report/outline/classes/event/activity_report_viewed.php index ef0458d178f1f..3b37a87dbb982 100644 --- a/report/outline/classes/event/activity_viewed.php +++ b/report/outline/classes/event/activity_report_viewed.php @@ -31,7 +31,7 @@ * @copyright 2014 Rajesh Taneja * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class activity_viewed extends \core\event\base { +class activity_report_viewed extends \core\event\base { /** * Init method. diff --git a/report/outline/classes/event/outline_viewed.php b/report/outline/classes/event/report_viewed.php similarity index 98% rename from report/outline/classes/event/outline_viewed.php rename to report/outline/classes/event/report_viewed.php index ff3525469ae71..4eb3a57baaf31 100644 --- a/report/outline/classes/event/outline_viewed.php +++ b/report/outline/classes/event/report_viewed.php @@ -34,7 +34,7 @@ * @copyright 2013 Ankit Agarwal * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class outline_viewed extends \core\event\base { +class report_viewed extends \core\event\base { /** * Init method. diff --git a/report/outline/index.php b/report/outline/index.php index f3733c784c141..dd5d0e0937333 100644 --- a/report/outline/index.php +++ b/report/outline/index.php @@ -37,8 +37,8 @@ $context = context_course::instance($course->id); require_capability('report/outline:view', $context); -// Trigger a content view event. -$event = \report_outline\event\activity_viewed::create(array('context' => $context)); +// Trigger an activity report viewed event. +$event = \report_outline\event\activity_report_viewed::create(array('context' => $context)); $event->trigger(); $showlastaccess = true; diff --git a/report/outline/user.php b/report/outline/user.php index 03dd659d613cf..ed4ac77a1f039 100644 --- a/report/outline/user.php +++ b/report/outline/user.php @@ -65,7 +65,7 @@ $PAGE->set_heading($course->fullname); // Trigger a report viewed event. -$event = \report_outline\event\outline_viewed::create(array('context' => context_course::instance($course->id), +$event = \report_outline\event\report_viewed::create(array('context' => context_course::instance($course->id), 'relateduserid' => $userid, 'other' => array('mode' => $mode))); $event->trigger(); diff --git a/tag/lib.php b/tag/lib.php index cd02df945201b..d8fd8c626f269 100644 --- a/tag/lib.php +++ b/tag/lib.php @@ -678,15 +678,15 @@ function tag_delete($tagids) { if ($taginstances) { // Save the system context in case the 'contextid' column in the 'tag_instance' table is null. $syscontextid = context_system::instance()->id; - // Loop through the tag instances and fire an 'item_untagged' event. + // Loop through the tag instances and fire a 'tag_removed'' event. foreach ($taginstances as $taginstance) { // We can not fire an event with 'null' as the contextid. if (is_null($taginstance->contextid)) { $taginstance->contextid = $syscontextid; } - // Trigger item untagged event. - $event = \core\event\item_untagged::create(array( + // Trigger tag removed event. + $event = \core\event\tag_removed::create(array( 'objectid' => $taginstance->id, 'contextid' => $taginstance->contextid, 'other' => array( @@ -757,15 +757,15 @@ function tag_delete_instances($component, $contextid = null) { $DB->delete_records('tag_instance',$params); // Save the system context in case the 'contextid' column in the 'tag_instance' table is null. $syscontextid = context_system::instance()->id; - // Loop through the tag instances and fire an 'item_untagged' event. + // Loop through the tag instances and fire an 'tag_removed' event. foreach ($taginstances as $taginstance) { // We can not fire an event with 'null' as the contextid. if (is_null($taginstance->contextid)) { $taginstance->contextid = $syscontextid; } - // Trigger item untagged event. - $event = \core\event\item_untagged::create(array( + // Trigger tag removed event. + $event = \core\event\tag_removed::create(array( 'objectid' => $taginstance->id, 'contextid' => $taginstance->contextid, 'other' => array( @@ -814,8 +814,8 @@ function tag_delete_instance($record_type, $record_id, $tagid, $userid = null) { $taginstance->contextid = context_system::instance()->id; } - // Trigger item untagged event. - $event = \core\event\item_untagged::create(array( + // Trigger tag removed event. + $event = \core\event\tag_removed::create(array( 'objectid' => $taginstance->id, 'contextid' => $taginstance->contextid, 'other' => array( @@ -1020,8 +1020,8 @@ function tag_assign($record_type, $record_id, $tagid, $ordering, $userid = 0, $c $contextid = context_system::instance()->id; } - // Trigger item tagged event. - $event = \core\event\item_tagged::create(array( + // Trigger tag added event. + $event = \core\event\tag_added::create(array( 'objectid' => $tag_instance_object->id, 'contextid' => $contextid, 'other' => array( diff --git a/tag/tests/events_test.php b/tag/tests/events_test.php index 1aa915bd14b41..2ecc0fca0d6cb 100644 --- a/tag/tests/events_test.php +++ b/tag/tests/events_test.php @@ -99,9 +99,9 @@ public function test_tag_updated() { } /** - * Test the item tagged event. + * Test the tag added event. */ - public function test_item_tagged() { + public function test_tag_added() { global $DB; // Create a course to tag. @@ -113,9 +113,9 @@ public function test_item_tagged() { $events = $sink->get_events(); $event = $events[1]; - // Check that the course was tagged and that the event data is valid. + // Check that the tag was added to the course and that the event data is valid. $this->assertEquals(1, $DB->count_records('tag_instance', array('component' => 'core'))); - $this->assertInstanceOf('\core\event\item_tagged', $event); + $this->assertInstanceOf('\core\event\tag_added', $event); $this->assertEquals(context_course::instance($course->id), $event->get_context()); $expected = array($course->id, 'coursetags', 'add', 'tag/search.php?query=A+tag', 'Course tagged'); $this->assertEventLegacyLogData($expected, $event); @@ -132,18 +132,18 @@ public function test_item_tagged() { $events = $sink->get_events(); $event = reset($events); - // Check that the question was tagged and the event data is valid. + // Check that the tag was added to the question and the event data is valid. $this->assertEquals(1, $DB->count_records('tag_instance', array('component' => 'core'))); - $this->assertInstanceOf('\core\event\item_tagged', $event); + $this->assertInstanceOf('\core\event\tag_added', $event); $this->assertEquals(context_system::instance(), $event->get_context()); $expected = null; $this->assertEventLegacyLogData($expected, $event); } /** - * Test the item untagged event. + * Test the tag removed event. */ - public function test_item_untagged() { + public function test_tag_removed() { global $DB; $this->setAdminUser(); @@ -169,9 +169,9 @@ public function test_item_untagged() { $events = $sink->get_events(); $event = reset($events); - // Check that the course was untagged and the event data is valid. + // Check that the tag was removed from the course and the event data is valid. $this->assertEquals(0, $DB->count_records('tag_instance')); - $this->assertInstanceOf('\core\event\item_untagged', $event); + $this->assertInstanceOf('\core\event\tag_removed', $event); $this->assertEquals(context_course::instance($course->id), $event->get_context()); // Create the tag. @@ -186,9 +186,9 @@ public function test_item_untagged() { $events = $sink->get_events(); $event = reset($events); - // Check that wiki page was untagged and the event data is valid. + // Check that tag was removed from the wiki page and the event data is valid. $this->assertEquals(0, $DB->count_records('tag_instance')); - $this->assertInstanceOf('\core\event\item_untagged', $event); + $this->assertInstanceOf('\core\event\tag_removed', $event); $this->assertEquals(context_module::instance($wiki->cmid), $event->get_context()); // Create a tag again - the other would have been deleted since there were no more instances associated with it. @@ -204,9 +204,9 @@ public function test_item_untagged() { $events = $sink->get_events(); $event = reset($events); - // Check that wiki page was untagged and the event data is valid. + // Check that tag was removed from the wiki page and the event data is valid. $this->assertEquals(0, $DB->count_records('tag_instance')); - $this->assertInstanceOf('\core\event\item_untagged', $event); + $this->assertInstanceOf('\core\event\tag_removed', $event); $this->assertEquals(context_module::instance($wiki->cmid), $event->get_context()); // Create a tag again - the other would have been deleted since there were no more instances associated with it. @@ -221,9 +221,9 @@ public function test_item_untagged() { $events = $sink->get_events(); $event = reset($events); - // Check that wiki page was untagged and the event data is valid. + // Check that tag was removed from the wiki page and the event data is valid. $this->assertEquals(0, $DB->count_records('tag_instance')); - $this->assertInstanceOf('\core\event\item_untagged', $event); + $this->assertInstanceOf('\core\event\tag_removed', $event); $this->assertEquals(context_module::instance($wiki->cmid), $event->get_context()); // Create another wiki. @@ -244,15 +244,15 @@ public function test_item_untagged() { $event1 = reset($events); $event2 = $events[1]; - // Check that wiki pages were untagged. + // Check that the tags were removed from the wiki pages. $this->assertEquals(0, $DB->count_records('tag_instance')); // Check the first event data is valid. - $this->assertInstanceOf('\core\event\item_untagged', $event1); + $this->assertInstanceOf('\core\event\tag_removed', $event1); $this->assertEquals(context_module::instance($wiki->cmid), $event1->get_context()); // Check that the second event data is valid. - $this->assertInstanceOf('\core\event\item_untagged', $event2); + $this->assertInstanceOf('\core\event\tag_removed', $event2); $this->assertEquals(context_module::instance($wiki2->cmid), $event2->get_context()); }