public function insert()
{
$allow = true;
$allow = Plugins::filter('comment_insert_allow', $allow, $this);
if (!$allow) {
return false;
}
Plugins::act('comment_insert_before', $this);
// Invoke plugins for all fields, since they're all "changed" when inserted
foreach ($this->fields as $fieldname => $value) {
Plugins::act('comment_update_' . $fieldname, $this, $this->{$fieldname}, $value);
}
$result = parent::insertRecord(DB::table('comments'));
$this->newfields['id'] = DB::last_insert_id();
// Make sure the id is set in the comment object to match the row id
$this->fields = array_merge($this->fields, $this->newfields);
$this->newfields = array();
$this->info->commit($this->fields['id']);
Plugins::act('comment_insert_after', $this);
return $result;
}