/** * Check if category is empty * * @param int $cat_id * @return bool */ public function isCatEmpty($h, $cat_id = 0) { //print "isCatEmpty <br/>****<br/>******"; //$posts = HotaruModels\Post::countByCategory($cat_id); $posts = \Hotaru\Models2\Post::countByCategory($h, $cat_id); // $sql = "SELECT count(post_id) FROM " . TABLE_POSTS . " WHERE post_category = %d "; // $posts = $h->db->get_var($h->db->prepare($sql, $cat_id)); if ($posts == 0) { return true; } else { return false; } }
/** * Physically delete all comments by a specified user (and responses) * * @param array $user_id * @return bool */ public function deleteComments($h, $user_id = 0) { if (!$user_id) { return false; } $sql = "SELECT comment_id FROM " . DB_PREFIX . "comments WHERE comment_user_id = %d"; $results = $h->db->get_results($h->db->prepare($sql, $user_id)); if ($results) { foreach ($results as $r) { $h->comment->id = $r->comment_id; // used by other plugins in "comment_delete_comment" function/hook $this->deleteComment($h, $h->comment->id); // delete parent comment $this->deleteCommentTree($h, $h->comment->id); // delete all children of that comment regardless of user } } //\HotaruModels\Post::updateCommentCount($this->postId); \Hotaru\Models2\Post::updateCommentCount($h, $this->postId); return true; }
public function updateCommentCountBulk() { \Hotaru\Models2\Post::updateCommentCountBulk($this); }
/** * Checks for existence of a post with given post_url * * @param str $post_url (slug) * @return int - id of post with matching url */ public function isPostUrl($h, $url = '') { //$post_id = \Hotaru\Models\Post::getFirstPostByPostUrl(urlencode($url)); $post_id = \Hotaru\Models2\Post::getFirstPostByPostUrl($h, urlencode($url)); if ($post_id) { return $post_id; } else { return false; } }