mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-45890 Blog: add additional events
This commit is contained in:
parent
26162efe4a
commit
02ce2e413c
12 changed files with 1115 additions and 328 deletions
|
@ -403,11 +403,29 @@ class blog_entry implements renderable {
|
|||
|
||||
/**
|
||||
* remove all associations for a blog entry
|
||||
* @return voic
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function remove_associations() {
|
||||
global $DB;
|
||||
$DB->delete_records('blog_association', array('blogid' => $this->id));
|
||||
|
||||
$associations = $DB->get_records('blog_association', array('blogid' => $this->id));
|
||||
foreach ($associations as $association) {
|
||||
|
||||
// Trigger an association deleted event.
|
||||
$context = context::instance_by_id($association->contextid);
|
||||
$eventparam = array(
|
||||
'objectid' => $this->id,
|
||||
'other' => array('subject' => $this->subject, 'blogid' => $this->id),
|
||||
'relateduserid' => $this->userid
|
||||
);
|
||||
$event = \core\event\blog_association_deleted::create($eventparam);
|
||||
$event->add_record_snapshot('blog_association', $association);
|
||||
$event->trigger();
|
||||
|
||||
// Now remove the association.
|
||||
$DB->delete_records('blog_association', array('id' => $association->id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue