Revision 2003
Added by Dietmar over 10 years ago
add_post.php | ||
---|---|---|
15 | 15 |
* |
16 | 16 |
*/ |
17 | 17 |
|
18 |
require('../../config.php'); |
|
18 |
$config_file = realpath('../../config.php'); |
|
19 |
if(file_exists($config_file) && !defined('WB_URL')) |
|
20 |
{ |
|
21 |
require($config_file); |
|
22 |
} |
|
19 | 23 |
|
20 |
// Include WB admin wrapper script |
|
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 |
|
21 | 27 |
require(WB_PATH.'/modules/admin.php'); |
22 | 28 |
|
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 |
// Make news post access files dir |
|
30 |
if(!function_exists('make_dir')) {require(WB_PATH.'/framework/functions.php');} |
|
29 | 31 |
|
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 ); |
|
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.'§ion_id='.$section_id.'&post_id='.$post_id ); |
|
67 |
} |
|
55 | 68 |
$admin->print_footer(); |
Also available in: Unified diff
! /modules/news/upgrade.php optimize add and modify field tables, rebuild message
! /modules/news/modify_post.php and modify_post.php check posts folder if not exists then create
! /upgrade-script.php add ModuleReorgAbstract calling the Reorg Accessfiles from modules