protected function add_instance($component, $itemtype, $itemid, context $context, $ordering, $tiuserid = 0) {
        global $DB;
        $this->ensure_fields_exist(array('name', 'rawname'), 'add_instance');

        $taginstance = new stdClass;
        $taginstance->tagid        = $this->id;
        $taginstance->component    = $component ? $component : '';
        $taginstance->itemid       = $itemid;
        $taginstance->itemtype     = $itemtype;
        $taginstance->contextid    = $context->id;
        $taginstance->ordering     = $ordering;
        $taginstance->timecreated  = time();
        $taginstance->timemodified = $taginstance->timecreated;
        $taginstance->tiuserid     = $tiuserid;

        $taginstance->id = $DB->insert_record('tag_instance', $taginstance);

        // Trigger tag added event.
        \core\event\tag_added::create_from_tag_instance($taginstance, $this->name, $this->rawname, true)->trigger();

        return $taginstance->id;
    }
protected function add_instance($component, $itemtype, $itemid, context $context, $ordering, $tiuserid = 0) {
        global $DB;
        $this->ensure_fields_exist(array('name', 'rawname'), 'add_instance');

        $taginstance = new stdClass;
        $taginstance->tagid        = $this->id;
        $taginstance->component    = $component ? $component : '';
        $taginstance->itemid       = $itemid;
        $taginstance->itemtype     = $itemtype;
        $taginstance->contextid    = $context->id;
        $taginstance->ordering     = $ordering;
        $taginstance->timecreated  = time();
        $taginstance->timemodified = $taginstance->timecreated;
        $taginstance->tiuserid     = $tiuserid;

        $taginstance->id = $DB->insert_record('tag_instance', $taginstance);

        // Trigger tag added event.
        \core\event\tag_added::create_from_tag_instance($taginstance, $this->name, $this->rawname, true)->trigger();

        return $taginstance->id;
    }
protected function add_instance ( $ component , $ itemtype , $ itemid , context $ context , $ ordering , $ tiuserid = 0 ) { global $ DB ; $ this -> ensure_fields_exist ( array ( 'name' , 'rawname' ) , 'add_instance' ) ; $ taginstance = new stdClass ; $ taginstance -> tagid = $ this -> id ; $ taginstance -> component = $ component ? $ component : '' ; $ taginstance -> itemid = $ itemid ; $ taginstance -> itemtype = $ itemtype ; $ taginstance -> contextid = $ context -> id ; $ taginstance -> ordering = $ ordering ; $ taginstance -> timecreated = time ( ) ; $ taginstance -> timemodified = $ taginstance -> timecreated ; $ taginstance -> tiuserid = $ tiuserid ; $ taginstance -> id = $ DB -> insert_record ( 'tag_instance' , $ taginstance ) ; // Trigger tag added event. \ core \ event \ tag_added :: create_from_tag_instance ( $ taginstance , $ this -> name , $ this -> rawname , true ) -> trigger ( ) ; return $ taginstance -> id ; }
Adds a tag instance

@param string $component
@param string $itemtype
@param string $itemid
@param context $context
@param int $ordering
@param int $tiuserid tag instance user id, only needed for tag areas with user tagging (such as core/course)
@return int id of tag_instance
Adds a tag instance