1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category modules
|
5
|
* @package news
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2009-2011, Website Baker Org. e.V.
|
8
|
* @link http://www.websitebaker2.org/
|
9
|
* @license http://www.gnu.org/licenses/gpl.html
|
10
|
* @platform WebsiteBaker 2.8.x
|
11
|
* @requirements PHP 5.2.2 and higher
|
12
|
* @version $Id: delete_post.php 2088 2014-01-19 21:18:18Z darkviper $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/news/delete_post.php $
|
14
|
* @lastmodified $Date: 2014-01-19 22:18:18 +0100 (Sun, 19 Jan 2014) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
require('../../config.php');
|
19
|
|
20
|
$admin_header = false;
|
21
|
$update_when_modified = true; // Tells script to update when this page was last updated
|
22
|
$oReg = WbAdaptor::getInstance();
|
23
|
$oDb = WbDatabase::getInstance();
|
24
|
$oTrans = Translate::getInstance();
|
25
|
$oTrans->enableAddon('modules\news');
|
26
|
require($oReg->AppPath.'/modules/admin.php'); // Include WB admin wrapper script
|
27
|
$sErrMsg = '';
|
28
|
$sRedirectLink = $oReg->AcpUrl.'pages/modify.php?page_id='.$page_id;
|
29
|
if (($post_id = ($admin->checkIDKEY('post_id', false, 'GET')))) {
|
30
|
// Get post details
|
31
|
$sql = 'SELECT `link` FROM `'.$oDb->TablePrefix.'mod_news_posts` '
|
32
|
. 'WHERE `post_id`='.$post_id;
|
33
|
if (($sPostLink = $oDb->getOne($sql))) {
|
34
|
try {
|
35
|
$sAccesFilesRootDir = $oReg->AppPath.$oReg->PagesDir.'posts/';
|
36
|
$sAccesFileName = str_replace('posts/', '', trim($sPostLink, '/')).$oReg->PageExtension;
|
37
|
// Unlink post access file
|
38
|
$oAF = new AccessFile($sAccesFilesRootDir, $sAccesFileName);
|
39
|
$oAF->delete();
|
40
|
unset($oAF);
|
41
|
// first delete all depending records
|
42
|
$sql = 'DELETE FROM `'.$oDb->TablePrefix.'mod_news_comments` '
|
43
|
. 'WHERE `post_id`='.$post_id;
|
44
|
$oDb->doQuery($sql);
|
45
|
// now delete master record
|
46
|
$sql = 'DELETE FROM `'.$oDb->TablePrefix.'mod_news_posts` '
|
47
|
. 'WHERE `post_id`='.$post_id;
|
48
|
$oDb->doQuery($sql);
|
49
|
// reorder positions
|
50
|
$oOrder = new order($oDb->TablePrefix.'mod_news_posts', 'position', 'post_id', 'section_id');
|
51
|
$oOrder->clean($section_id);
|
52
|
} catch(AccessFileException $e) {
|
53
|
$sErrMsg = (string)$e;
|
54
|
} catch(WbDatabaseException $e) {
|
55
|
$sErrMsg = (string)$e;
|
56
|
$sRedirectLink = $oReg->AppUrl.'modules/news/modify_post.php?page_id='.$page_id.'&post_id='.$post_id;
|
57
|
}
|
58
|
} else {
|
59
|
$sErrMsg = $oTrans->TEXT_NOT_FOUND;
|
60
|
}
|
61
|
} else {
|
62
|
$sErrMsg = $oTrans->MESSAGE_GENERIC_SECURITY_ACCESS;
|
63
|
}
|
64
|
// print result
|
65
|
$admin->print_header();
|
66
|
if($sErrMsg) {
|
67
|
$admin->print_error($sErrMsg, $sRedirectLink);
|
68
|
} else {
|
69
|
$admin->print_success($oTrans->TEXT_SUCCESS, $sRedirectLink);
|
70
|
}
|
71
|
$oTrans->disableAddon();
|
72
|
$admin->print_footer();
|
73
|
|