1
|
<?php
|
2
|
/**
|
3
|
*
|
4
|
* @category modules
|
5
|
* @package news
|
6
|
* @author WebsiteBaker Project
|
7
|
* @copyright 2009-2013, WebsiteBaker Org. e.V.
|
8
|
* @link http://www.websitebaker.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: add_post.php 1918 2013-06-07 04:18:18Z Luisehahne $
|
13
|
* @filesource $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/news/add_post.php $
|
14
|
* @lastmodified $Date: 2013-06-07 06:18:18 +0200 (Fri, 07 Jun 2013) $
|
15
|
*
|
16
|
*/
|
17
|
|
18
|
require('../../config.php');
|
19
|
|
20
|
// Include WB admin wrapper script
|
21
|
require(WB_PATH.'/modules/admin.php');
|
22
|
|
23
|
// Include the ordering class
|
24
|
require(WB_PATH.'/framework/class.order.php');
|
25
|
// Get new order
|
26
|
$order = new order(TABLE_PREFIX.'mod_news_posts', 'position', 'post_id', 'section_id');
|
27
|
$position = $order->get_new($section_id);
|
28
|
$post_id = 0;
|
29
|
|
30
|
try {
|
31
|
// Get default commenting
|
32
|
$sql = 'SELECT `commenting` FROM `'.TABLE_PREFIX.'mod_news_settings` '
|
33
|
. 'WHERE `section_id`='.(int)$section_id;
|
34
|
$query_settings = $database->query($sql);
|
35
|
$fetch_settings = $query_settings->fetchRow(MYSQL_ASSOC);
|
36
|
$commenting = $fetch_settings['commenting'];
|
37
|
// Insert new row into database
|
38
|
$sql = 'INSERT INTO `'.TABLE_PREFIX.'mod_news_posts` '
|
39
|
. 'SET `section_id`='.$section_id.', '
|
40
|
. '`page_id`='.$page_id.', '
|
41
|
. '`position`='.$position.', '
|
42
|
. '`commenting`=\''.$commenting.'\', '
|
43
|
. '`created_when`='.time().', '
|
44
|
. '`created_by`='.(int)$admin->get_user_id().', '
|
45
|
. '`posted_when`='.time().', '
|
46
|
. '`posted_by`='.(int)$admin->get_user_id().', '
|
47
|
. '`active`=1';
|
48
|
$database->query($sql);
|
49
|
$post_id = $admin->getIDKEY($database->LastInsertId);
|
50
|
} catch(WbDatabaseException $e) {
|
51
|
$sSectionIdPrefix = ( defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' ) ? SEC_ANCHOR : 'Sec' );
|
52
|
$admin->print_error($database->get_error(), WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'#'.$sSectionIdPrefix.$section_id );
|
53
|
}
|
54
|
$admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'§ion_id='.$section_id.'&post_id='.$post_id );
|
55
|
$admin->print_footer();
|