Skip to content

Commit

Permalink
MDL-43557 events: renamed event class names
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
mdjnelson committed Apr 30, 2014
1 parent e692f58 commit f3d9818
Show file tree
Hide file tree
Showing 16 changed files with 65 additions and 65 deletions.
2 changes: 1 addition & 1 deletion lang/en/message.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 2 additions & 2 deletions lang/en/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Message read event class.
* Message viewed event class.
*
* @property-read array $other {
* Extra information about event.
Expand All @@ -32,7 +32,7 @@

defined('MOODLE_INTERNAL') || die();

class message_read extends base {
class message_viewed extends base {

/**
* Init method.
Expand All @@ -49,7 +49,7 @@ protected function init() {
* @return string
*/
public static function get_name() {
return get_string('eventmessageread', 'message');
return get_string('eventmessageviewed', 'message');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Item tagged event.
* Event for when a tag has been added to an item.
*
* @property-read array $other {
* Extra information about event.
Expand All @@ -37,7 +37,7 @@

defined('MOODLE_INTERNAL') || die();

class item_tagged extends base {
class tag_added extends base {

/**
* Initialise the event data.
Expand All @@ -54,7 +54,7 @@ protected function init() {
* @return string
*/
public static function get_name() {
return get_string('eventitemtagged', 'tag');
return get_string('eventtagadded', 'tag');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Item untagged event.
* Event for when a tag has been removed from an item.
*
* @property-read array $other {
* Extra information about event.
Expand All @@ -37,7 +37,7 @@

defined('MOODLE_INTERNAL') || die();

class item_untagged extends base {
class tag_removed extends base {

/**
* Initialise the event data.
Expand All @@ -54,7 +54,7 @@ protected function init() {
* @return string
*/
public static function get_name() {
return get_string('eventitemuntagged', 'tag');
return get_string('eventtagremoved', 'tag');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion message/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
6 changes: 3 additions & 3 deletions message/tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @copyright 2014 Dan Poltawski <[email protected]>
* @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.
Expand Down
26 changes: 13 additions & 13 deletions mod/forum/tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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));
Expand All @@ -1113,27 +1113,27 @@ 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(),
'other' => array('reportmode' => 'posts'),
);

$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();
Expand All @@ -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();
Expand All @@ -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}&amp;mode=discussions&amp;course={$course->id}", $user->id);
Expand Down
2 changes: 1 addition & 1 deletion mod/forum/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @copyright 2014 Rajesh Taneja <[email protected]>
* @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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions report/outline/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion report/outline/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
20 changes: 10 additions & 10 deletions tag/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
Loading

0 comments on commit f3d9818

Please sign in to comment.