public function publish()
{
if ($this->status == Post::status('published')) {
return true;
}
$allow = true;
$allow = Plugins::filter('post_publish_allow', $allow, $this);
if (!$allow) {
return false;
}
Plugins::act('post_publish_before', $this);
if ($this->status != Post::status('scheduled')) {
$this->pubdate = DateTime::create();
}
if ($this->status == Post::status('scheduled')) {
$msg = _t('Scheduled Post %1$s (%2$s) published at %3$s.', array($this->id, $this->slug, $this->pubdate->format()));
} else {
$msg = _t('Post %1$s (%2$s) published.', array($this->id, $this->slug));
}
$this->status = Post::status('published');
$result = $this->update(true);
EventLog::log($msg, 'info', 'content', 'habari');
// and call any final plugins
Plugins::act('post_publish_after', $this);
return $result;
}