/** * SQL: Delete post by POSTed data * * @return MsgBox of result */ function ActionDeletePost($iPostID = 0) { if (!$this->bAdminMode) { $this->CheckLogged(); } if ($iPostID == 0) { $iPostID = (int) bx_get('DeletePostID'); } $iPostOwnerID = $this->_oDb->getPostOwnerByID($iPostID); if (!$this->isAllowedPostDelete($iPostOwnerID)) { return $this->_oTemplate->displayAccessDenied(); } if ($iPostID > 0) { $oCmts = new BxDolCmts($this->_oConfig->getCommentSystemName(), (int) $iPostID); $oCmts->onObjectDelete(); // delete votings bx_import('BxTemplVotingView'); $oVoting = new BxTemplVotingView($this->_oConfig->getRateSystemName(), $iPostID); $oVoting->deleteVotings($iPostID); $sFileName = $this->_oDb->getPostPhotoByID($iPostID); $sFilePathPost = 'big_' . $sFileName; if ($sFilePathPost != '' && file_exists(BX_BLOGS_IMAGES_PATH . $sFilePathPost) && is_file(BX_BLOGS_IMAGES_PATH . $sFilePathPost)) { @unlink(BX_BLOGS_IMAGES_PATH . $sFilePathPost); } $sFilePathPost = 'small_' . $sFileName; if ($sFilePathPost != '' && file_exists(BX_BLOGS_IMAGES_PATH . $sFilePathPost) && is_file(BX_BLOGS_IMAGES_PATH . $sFilePathPost)) { @unlink(BX_BLOGS_IMAGES_PATH . $sFilePathPost); } $sFilePathPost = 'orig_' . $sFileName; if ($sFilePathPost != '' && file_exists(BX_BLOGS_IMAGES_PATH . $sFilePathPost) && is_file(BX_BLOGS_IMAGES_PATH . $sFilePathPost)) { @unlink(BX_BLOGS_IMAGES_PATH . $sFilePathPost); } $vSqlRes = $this->_oDb->deletePost($iPostID); $sRet = db_affected_rows() > 0 ? _t('_post_successfully_deleted') : _t('_failed_to_delete_post'); $this->isAllowedPostDelete($iPostOwnerID, true); // perform action //reparse tags bx_import('BxDolTags'); $oTags = new BxDolTags(); $oTags->reparseObjTags('blog', $iPostID); //reparse categories $oCategories = new BxDolCategories(); $oCategories->reparseObjTags('bx_blogs', $iPostID); // delete views bx_import('BxDolViews'); $oViews = new BxDolViews($this->_oConfig->getViewSystemName(), $iPostID, false); $oViews->onObjectDelete(); //delete all subscriptions $oSubscription = BxDolSubscription::getInstance(); $oSubscription->unsubscribe(array('type' => 'object_id', 'unit' => 'bx_blogs', 'object_id' => $iPostID)); bx_import('BxDolAlerts'); $oZ = new BxDolAlerts('bx_blogs', 'delete_post', $iPostID, $iPostOwnerID); $oZ->alert(); return MsgBox($sRet); } else { return MsgBox(_t('_Error Occured')); } }