Exemplo n.º 1
0
 /**
  * Inserts this entry in the database. Access control checks must be done by calling code.
  * TODO Set the publishstate correctly
  * @return void
  */
 public function add()
 {
     global $CFG, $USER, $DB;
     unset($this->id);
     $this->module = 'blog';
     $this->userid = empty($this->userid) ? $USER->id : $this->userid;
     $this->lastmodified = time();
     $this->created = time();
     // Insert the new blog entry.
     $this->id = $DB->insert_record('post', $this);
     if (!empty($CFG->useblogassociations)) {
         $this->add_associations();
     }
     core_tag_tag::set_item_tags('core', 'post', $this->id, context_user::instance($this->userid), $this->tags);
     // Trigger an event for the new entry.
     $event = \core\event\blog_entry_created::create(array('objectid' => $this->id, 'relateduserid' => $this->userid));
     $event->set_blog_entry($this);
     $event->trigger();
 }
Exemplo n.º 2
0
 /**
  * Inserts this entry in the database. Access control checks must be done by calling code.
  * TODO Set the publishstate correctly
  * @return void
  */
 public function add()
 {
     global $CFG, $USER, $DB;
     unset($this->id);
     $this->module = 'blog';
     $this->userid = empty($this->userid) ? $USER->id : $this->userid;
     $this->lastmodified = time();
     $this->created = time();
     // Insert the new blog entry.
     $this->id = $DB->insert_record('post', $this);
     // Update tags.
     $this->add_tags_info();
     if (!empty($CFG->useblogassociations)) {
         $this->add_associations();
     }
     tag_set('post', $this->id, $this->tags);
     // Trigger an event for the new entry.
     $event = \core\event\blog_entry_created::create(array('objectid' => $this->id, 'relateduserid' => $this->userid));
     $event->set_custom_data($this);
     $event->trigger();
 }