Project

General

Profile

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 2003 2013-11-14 03:47:21Z Luisehahne $
13
 * @filesource      $HeadURL: svn://isteam.dynxs.de/wb-archiv/branches/2.8.x/wb/modules/news/add_post.php $
14
 * @lastmodified    $Date: 2013-11-14 04:47:21 +0100 (Thu, 14 Nov 2013) $
15
 *
16
 */
17

    
18
$config_file = realpath('../../config.php');
19
if(file_exists($config_file) && !defined('WB_URL'))
20
{
21
	require($config_file);
22
}
23

    
24
// show the info banner
25
$print_info_banner = true;
26
// Include WB admin wrapper script to fetch page_id and section_id for backlink
27
require(WB_PATH.'/modules/admin.php');
28

    
29
// Make news post access files dir
30
if(!function_exists('make_dir')) {require(WB_PATH.'/framework/functions.php');}
31

    
32
if(!make_dir(WB_PATH.PAGES_DIRECTORY.'/posts')) {
33
	$admin->print_error($MESSAGE['GENERIC_BAD_PERMISSIONS'], ADMIN_URL.'/pages/modify.php?page_id='.$page_id );
34
} else {
35
    // Include the ordering class
36
    require(WB_PATH.'/framework/class.order.php');
37
    // Get new order
38
    $order = new order(TABLE_PREFIX.'mod_news_posts', 'position', 'post_id', 'section_id');
39
    $position = $order->get_new($section_id);
40
    $post_id = 0;
41
    
42
    try {
43
    // Get default commenting
44
    	$sql = 'SELECT `commenting` FROM `'.TABLE_PREFIX.'mod_news_settings` '
45
    	     . 'WHERE `section_id`='.(int)$section_id;
46
    	$query_settings = $database->query($sql);
47
    	$fetch_settings = $query_settings->fetchRow(MYSQL_ASSOC);
48
    	$commenting = $fetch_settings['commenting'];
49
    // Insert new row into database
50
    	$sql = 'INSERT INTO `'.TABLE_PREFIX.'mod_news_posts` '
51
    	     . 'SET `section_id`='.$section_id.', '
52
    	     .     '`page_id`='.$page_id.', '
53
    	     .     '`position`='.$position.', '
54
    	     .     '`commenting`=\''.$commenting.'\', '
55
    	     .     '`created_when`='.time().', '
56
    	     .     '`created_by`='.(int)$admin->get_user_id().', '
57
    	     .     '`posted_when`='.time().', '
58
    	     .     '`posted_by`='.(int)$admin->get_user_id().', '
59
    	     .     '`active`=1';
60
    	$database->query($sql);
61
    	$post_id = $admin->getIDKEY($database->LastInsertId);
62
    } catch(WbDatabaseException $e) {
63
        $sSectionIdPrefix = ( defined( 'SEC_ANCHOR' ) && ( SEC_ANCHOR != '' )  ? SEC_ANCHOR : 'Sec' );
64
    	$admin->print_error($database->get_error(), WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'#'.$sSectionIdPrefix.$section_id );
65
    }
66
        $admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'&section_id='.$section_id.'&post_id='.$post_id );
67
    }
68
$admin->print_footer();
(5-5/34)