public function remove_associations() {
        global $DB;

        $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));
        }
    }