Skip to content

Commit

Permalink
MDL-67548 core_course: Reflect content move category in deleted event.
Browse files Browse the repository at this point in the history
  • Loading branch information
kabalin committed May 11, 2020
1 parent 39e777e commit 27b29b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion course/classes/category.php
Expand Up @@ -2169,7 +2169,7 @@ public function delete_move($newparentid, $showfeedback = false) {
$event = \core\event\course_category_deleted::create(array(
'objectid' => $this->id,
'context' => $context,
'other' => array('name' => $this->name)
'other' => array('name' => $this->name, 'contentmovedcategoryid' => $newparentid)
));
$event->set_coursecat($this);
$event->trigger();
Expand Down
7 changes: 6 additions & 1 deletion lib/classes/event/course_category_deleted.php
Expand Up @@ -33,6 +33,7 @@
* Extra information about event.
*
* - string name: category name.
* - string contentmovedcategoryid: (optional) category id where content was moved on deletion
* }
*
* @package core
Expand Down Expand Up @@ -71,7 +72,11 @@ public static function get_name() {
* @return string
*/
public function get_description() {
return "The user with id '$this->userid' deleted the course category with id '$this->objectid'.";
$descr = "The user with id '$this->userid' deleted the course category with id '$this->objectid'.";
if (!empty($this->other['contentmovedcategoryid'])) {
$descr .= " Its content has been moved to category with id '{$this->other['contentmovedcategoryid']}'.";
}
return $descr;
}

/**
Expand Down

0 comments on commit 27b29b2

Please sign in to comment.