original_string: 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();
      }
code: 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();
      }
code_tokens: 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 ( ) ; }
docstring: Add a single association for a blog entry
  
  @param int $contextid - id of context to associate with the blog entry.
  @param string $unused This does nothing, do not use it.
docstring_tokens: Add a single association for a blog entry