Commit aa139299 authored by Rajesh Taneja's avatar Rajesh Taneja
Browse files

MDL-42584 Events: modified get_description in events

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
parent 68291f2d
......@@ -265,8 +265,7 @@ class blog_entry implements renderable {
// 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();
......@@ -308,8 +307,7 @@ class blog_entry implements renderable {
$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();
......@@ -333,9 +331,8 @@ class blog_entry implements renderable {
$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();
......
......@@ -55,7 +55,7 @@ class blog_entry_created extends \core\event\base {
*
* @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;
}
......@@ -74,7 +74,7 @@ class blog_entry_created extends \core\event\base {
* @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;
}
/**
......
......@@ -63,7 +63,7 @@ class blog_entry_deleted extends \core\event\base {
*
* @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;
}
......@@ -73,7 +73,7 @@ class blog_entry_deleted extends \core\event\base {
* @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;
}
/**
......
......@@ -53,7 +53,7 @@ class blog_entry_updated extends base {
*
* @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;
}
......@@ -72,7 +72,7 @@ class blog_entry_updated extends base {
* @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;
}
/**
......@@ -108,7 +108,7 @@ class blog_entry_updated extends base {
*/
protected function get_legacy_logdata() {
return array(SITEID, 'blog', 'update', 'index.php?userid=' . $this->relateduserid . '&entryid=' . $this->objectid,
$this->other['subject']);
$this->customobject->subject);
}
}
......@@ -87,7 +87,7 @@ abstract class content_viewed extends base {
* @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';
}
/**
......
......@@ -60,8 +60,8 @@ class course_module_created extends base {
* @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;
}
/**
......
......@@ -60,8 +60,8 @@ class course_module_updated extends base {
* @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;
}
/**
......
......@@ -59,7 +59,7 @@ class user_deleted extends base {
*/
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;
}
/**
......
......@@ -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;
}
/**
......
......@@ -52,6 +52,15 @@ class course_module_viewed extends \core\event\content_viewed {
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
......
......@@ -49,7 +49,7 @@ class course_module_viewed extends \core\event\content_viewed {
* @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;
}
/**
......
......@@ -58,7 +58,7 @@ class course_module_viewed extends \core\event\content_viewed {
* @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;
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment