/** * function undelete_post * This function reverts a post's status from 'deleted' to whatever * it previously was. **/ private function undelete_post($post_id) { $post = Post::get(array('id' => $post_id, 'status' => Post::status('any'))); if ($post->status == Post::status('deleted')) { $post->status = $post->info->prior_status ? $post->info->prior_status : Post::status('draft'); unset($post->info->prior_status); $post->update(); EventLog::log(sprintf(_t('Post %1$s (%2$s) restored.'), $post->id, $post->slug), 'info', 'content', 'habari'); //scheduled post if ($post->status == Post::status('scheduled')) { Posts::update_scheduled_posts_cronjob(); } return true; } else { return false; } }
/** * function delete * Deletes an existing post */ public function delete() { $allow = true; $allow = Plugins::filter( 'post_delete_allow', $allow, $this ); if ( ! $allow ) { return; } // invoke plugins Plugins::act( 'post_delete_before', $this ); // delete all the tags associated with this post Tags::save_associations( new Terms(), $this->id ); // Delete all comments associated with this post if ( $this->comments->count() > 0 ) { $this->comments->delete(); } // Delete all info records associated with this post $this->info->delete_all(); // Delete all post_tokens associated with this post $this->delete_tokens(); $result = parent::deleteRecord( DB::table( 'posts' ), array( 'slug'=>$this->slug ) ); EventLog::log( sprintf( _t( 'Post %1$s (%2$s) deleted.' ), $this->id, $this->slug ), 'info', 'content', 'habari' ); //scheduled post if ( $this->status == Post::status( 'scheduled' ) ) { Posts::update_scheduled_posts_cronjob(); } // invoke plugins on the after_post_delete action Plugins::act( 'post_delete_after', $this ); return $result; }