Skip to content

Commit

Permalink
MDL-42584 Events: modified get_description in events
Browse files Browse the repository at this point in the history
blog_entry_created - Removed summary field
blog_entry_deleted - Removed summary field and unwanted entry record
blog_entry_updated - Fixed single quotes and removed summary field
course_module_created - Removed subject
course_module_updated - Removed subject
user_deleted - Removed user firstname and last name
course_module_viewed - Fixed description
  • Loading branch information
Rajesh Taneja committed Oct 29, 2013
1 parent 68291f2 commit aa13929
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 23 deletions.
11 changes: 4 additions & 7 deletions blog/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,7 @@ public function add() {
// Trigger an event for the new entry.
$event = \core\event\blog_entry_created::create(array(
'objectid' => $this->id,
'relateduserid' => $this->userid,
'other' => array('subject' => $this->subject)
'relateduserid' => $this->userid
));
$event->set_custom_data($this);
$event->trigger();
Expand Down Expand Up @@ -308,8 +307,7 @@ public function edit($params=array(), $form=null, $summaryoptions=array(), $atta

$event = \core\event\blog_entry_updated::create(array(
'objectid' => $entry->id,
'relateduserid' => $entry->userid,
'other' => array('subject' => $entry->subject)
'relateduserid' => $entry->userid
));
$event->set_custom_data($entry);
$event->trigger();
Expand All @@ -333,9 +331,8 @@ public function delete() {

$event = \core\event\blog_entry_deleted::create(array(
'objectid' => $this->id,
'relateduserid' => $this->userid,
'other' => array('record' => (array) $record)
));
'relateduserid' => $this->userid
));
$event->add_record_snapshot("post", $record);
$event->set_custom_data($this);
$event->trigger();
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/event/blog_entry_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function init() {
*
* @param \blog_entry $data A reference to the active blog_entry object.
*/
public function set_custom_data($data) {
public function set_custom_data(\blog_entry $data) {
$this->customobject = $data;
}

Expand All @@ -74,7 +74,7 @@ public static function get_name() {
* @return string
*/
public function get_description() {
return 'Blog entry "'. $this->other['subject']. '" was created by user with id '. $this->userid;
return 'Blog entry id '. $this->objectid. ' was created by userid '. $this->userid;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/event/blog_entry_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static function get_name() {
*
* @param \blog_entry $data A reference to the active blog_entry object.
*/
public function set_custom_data($data) {
public function set_custom_data(\blog_entry $data) {
$this->customobject = $data;
}

Expand All @@ -73,7 +73,7 @@ public function set_custom_data($data) {
* @return string
*/
public function get_description() {
return "Blog entry ".$this->other['record']['subject']." was deleted by user with id ".$this->userid;
return 'Blog entry id '. $this->objectid. ' was deleted by userid '. $this->userid;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions lib/classes/event/blog_entry_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected function init() {
*
* @param \blog_entry $data A reference to the active blog_entry object.
*/
public function set_custom_data($data) {
public function set_custom_data(\blog_entry $data) {
$this->customobject = $data;
}

Expand All @@ -72,7 +72,7 @@ public static function get_name() {
* @return string
*/
public function get_description() {
return 'User with id {$this->userid} updated blog entry {$this->other["subject"]';
return 'Blog entry id '. $this->objectid. ' was updated by userid '. $this->userid;
}

/**
Expand Down Expand Up @@ -108,7 +108,7 @@ public static function get_legacy_eventname() {
*/
protected function get_legacy_logdata() {
return array(SITEID, 'blog', 'update', 'index.php?userid=' . $this->relateduserid . '&entryid=' . $this->objectid,
$this->other['subject']);
$this->customobject->subject);
}
}

2 changes: 1 addition & 1 deletion lib/classes/event/content_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static function get_name() {
* @return string
*/
public function get_description() {
return 'User with id ' . $this->userid . ' viewed content ' . $this->get_url();
return 'User with id ' . $this->userid . ' viewed content';
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/event/course_module_created.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public static function get_name() {
* @return string
*/
public function get_description() {
return 'The '. $this->other['modulename'] . ' module ' . $this->other['name']. ' was created by user with id '.
$this->userid;
return 'The '. $this->other['modulename'] . ' module with instance id ' . $this->other['instanceid'] .
' was created by user with id ' . $this->userid;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/event/course_module_updated.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public static function get_name() {
* @return string
*/
public function get_description() {
return 'The ' . $this->other['modulename'] . ' module ' . $this->other['name']. ' was updated by user with id '.
$this->userid;
return 'The ' . $this->other['modulename'] . ' module with instance id ' . $this->other['instanceid'] .
' was updated by user with id ' . $this->userid;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/event/user_deleted.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static function get_name() {
*/
public function get_description() {
$user = (object)$this->other['user'];
return 'User profile deleted for user '.$user->firstname.' '.$user->lastname.' id ('.$user->id.')';
return 'User profile deleted for userid ' . $user->id;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion mod/book/classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class course_module_viewed extends \core\event\content_viewed {
* @return string
*/
public function get_description() {
return "The user $this->userid has viewed the book $this->objectid.";
return 'User with id ' . $this->userid . ' viewed book activity with instance id ' . $this->objectid;
}

/**
Expand Down
9 changes: 9 additions & 0 deletions mod/choice/classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public static function get_name() {
return get_string('event_choice_viewed', 'choice');
}

/**
* Returns non-localised description of what happened.
*
* @return string
*/
public function get_description() {
return 'User with id ' . $this->userid . ' viewed choice activity with instance id ' . $this->objectid;
}

/**
* Returns relevant URL.
* @return \moodle_url
Expand Down
2 changes: 1 addition & 1 deletion mod/page/classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function init() {
* @return string
*/
public function get_description() {
return 'User with id ' . $this->userid . ' viewed page resource with instanceid ' . $this->objectid;
return 'User with id ' . $this->userid . ' viewed page resource with instance id ' . $this->objectid;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion mod/workshop/classes/event/course_module_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static function get_legacy_eventname() {
* @return string
*/
public function get_description() {
return 'User with id ' . $this->userid . ' viewed content ' . $this->get_url() . ' In phase ' . $this->other['content'];
return 'User with id ' . $this->userid . ' viewed workshop activity with instance id ' . $this->objectid;
}

/**
Expand Down

0 comments on commit aa13929

Please sign in to comment.