Project

General

Profile

1 1457 Luisehahne
<?php
2
/**
3
 *
4
 * @category        modules
5
 * @package         news
6
 * @author          WebsiteBaker Project
7 1918 Luisehahne
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker.org/
9 1457 Luisehahne
 * @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$
13 1918 Luisehahne
 * @filesource      $HeadURL$
14 1457 Luisehahne
 * @lastmodified    $Date$
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 1918 Luisehahne
$post_id = 0;
29 1457 Luisehahne
30 1918 Luisehahne
try {
31 1457 Luisehahne
// Get default commenting
32 1918 Luisehahne
	$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 1457 Luisehahne
// Insert new row into database
38 1918 Luisehahne
	$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 1457 Luisehahne
}
54 1918 Luisehahne
$admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'&section_id='.$section_id.'&post_id='.$post_id );
55 1457 Luisehahne
$admin->print_footer();