/** * Удаляет пост в блоге * @param int $post_id * @return bool */ public function deletePost($post_id) { cmsCore::callEvent('DELETE_POST', $post_id); $post = $this->getPost($post_id); if (!$post) { return false; } // пересчитываем рейтинг блога $this->inDB->query("UPDATE cms_blogs SET rating = rating - ({$post['rating']}) WHERE id = '{$post['blog_id']}'"); $this->inDB->delete('cms_blog_posts', "id = '{$post_id}'", 1); cmsCore::deleteRatings($this->getTarget('rating'), $post_id); cmsCore::deleteComments($this->getTarget('comments'), $post_id); cmsClearTags($this->getTarget('tags'), $post_id); cmsCore::deleteUploadImages($post_id, 'blog_post'); cmsActions::removeObjectLog($this->getTarget('actions_post'), $post_id); return true; }
/** * Удаляет фото * @param array $photo * @param obj $inUploadPhoto * @return bool */ public function deletePhoto($photo, $inUploadPhoto){ $photo = cmsCore::callEvent('DELETE_PHOTO', $photo); if(!$this->deletePhotoFile($photo['file'], $inUploadPhoto)){ return false; } cmsCore::deleteComments($this->getTarget('comments_photo'), $photo['id']); cmsCore::deleteRatings($this->getTarget('rating'), $photo['id']); cmsClearTags($this->getTarget('tags'), $photo['id']); cmsActions::removeObjectLog($this->getTarget('actions_photo'), $photo['id']); cmsCore::c('db')->query("DELETE FROM cms_photo_files WHERE id = '{$photo['id']}' LIMIT 1"); return true; }
/** * Удаляет статью * @return bool */ public function deleteArticle($id) { cmsCore::callEvent('DELETE_ARTICLE', $id); cmsCore::c('db')->delete('cms_content', "id='". $id ."'", 1); cmsCore::c('db')->delete('cms_tags', "target='content' AND item_id='". $id ."'"); cmsCore::clearAccess($id, 'material'); cmsActions::removeObjectLog('add_article', $id); @unlink(PATH .'/images/content/medium/'. ceil($id/100) .'/article'. $id .'.jpg'); @unlink(PATH .'/images/content/small/'. ceil($id/100) .'/article'. $id .'.jpg'); cmsCore::deleteUploadImages($id, '', 'content'); cmsCore::deleteRatings('content', $id); cmsCore::deleteComments('article', $id); return true; }
/** * Удаляет статью * @return bool */ public function deleteArticle($id) { cmsCore::callEvent('DELETE_ARTICLE', $id); $this->inDB->delete('cms_content', "id='{$id}'", 1); $this->inDB->delete('cms_tags', "target='content' AND item_id='{$id}'"); cmsCore::clearAccess($id, 'material'); cmsActions::removeObjectLog('add_article', $id); @unlink(PATH . '/images/photos/small/article' . $id . '.jpg'); @unlink(PATH . '/images/photos/medium/article' . $id . '.jpg'); cmsCore::deleteRatings('content', $id); cmsCore::deleteComments('article', $id); translations::deleteTargetTranslation('content_content', $id); return true; }
public function deleteComment($comment_id) { cmsCore::callEvent('DELETE_COMMENT', $comment_id); $this->childs = array(); $this->getCommentChilds($comment_id); $sql = "DELETE FROM cms_comments WHERE id = '{$comment_id}' LIMIT 1"; $this->inDB->query($sql); cmsCore::deleteRatings('comment', $comment_id); cmsActions::removeObjectLog('add_comment', $comment_id); cmsCore::deleteUploadImages($comment_id, 'comment'); if ($this->childs) { foreach ($this->childs as $child) { cmsCore::callEvent('DELETE_COMMENT', $child['id']); $sql = "DELETE FROM cms_comments WHERE id = '{$child['id']}' LIMIT 1"; $this->inDB->query($sql); cmsCore::deleteRatings('comment', $child['id']); cmsActions::removeObjectLog('add_comment', $child['id']); cmsCore::deleteUploadImages($child['id'], 'comment'); } } return true; }