public function add_association($contextid, $unused = null) {
        global $DB;

        if ($unused !== null) {
            debugging('Illegal argument used in blog_entry->add_association()', DEBUG_DEVELOPER);
        }

        $assocobject = new StdClass;
        $assocobject->contextid = $contextid;
        $assocobject->blogid = $this->id;
        $id = $DB->insert_record('blog_association', $assocobject);

        // Trigger an association created event.
        $context = context::instance_by_id($contextid);
        $eventparam = array(
            'objectid' => $id,
            'other' => array('associateid' => $context->instanceid, 'subject' => $this->subject, 'blogid' => $this->id),
            'relateduserid' => $this->userid
        );
        if ($context->contextlevel == CONTEXT_COURSE) {
            $eventparam['other']['associatetype'] = 'course';

        } else if ($context->contextlevel == CONTEXT_MODULE) {
            $eventparam['other']['associatetype'] = 'coursemodule';
        }
        $event = \core\event\blog_association_created::create($eventparam);
        $event->trigger();
    }