Project

General

Profile

« Previous | Next » 

Revision 1918

Added by Dietmar about 11 years ago

! /modules/news/ beginning beginning recoding
replacing absolute MediaUrl with place holder

View differences:

add_post.php
4 4
 * @category        modules
5 5
 * @package         news
6 6
 * @author          WebsiteBaker Project
7
 * @copyright       2009-2011, Website Baker Org. e.V.
8
 * @link			http://www.websitebaker2.org/
7
 * @copyright       2009-2013, WebsiteBaker Org. e.V.
8
 * @link            http://www.websitebaker.org/
9 9
 * @license         http://www.gnu.org/licenses/gpl.html
10 10
 * @platform        WebsiteBaker 2.8.x
11 11
 * @requirements    PHP 5.2.2 and higher
12 12
 * @version         $Id$
13
 * @filesource		$HeadURL$
13
 * @filesource      $HeadURL$
14 14
 * @lastmodified    $Date$
15 15
 *
16 16
 */
......
25 25
// Get new order
26 26
$order = new order(TABLE_PREFIX.'mod_news_posts', 'position', 'post_id', 'section_id');
27 27
$position = $order->get_new($section_id);
28
$post_id = 0;
28 29

  
30
try {
29 31
// Get default commenting
30
$query_settings = $database->query("SELECT commenting FROM ".TABLE_PREFIX."mod_news_settings WHERE section_id = '$section_id'");
31
$fetch_settings = $query_settings->fetchRow();
32
$commenting = $fetch_settings['commenting'];
33

  
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'];
34 37
// Insert new row into database
35
$database->query("INSERT INTO ".TABLE_PREFIX."mod_news_posts (section_id,page_id,position,commenting,active) VALUES ('$section_id','$page_id','$position','$commenting','1')");
36

  
37
// Get the id
38
$post_id = $admin->getIDKEY($database->get_one("SELECT LAST_INSERT_ID()"));
39

  
40
// Say that a new record has been added, then redirect to modify page
41
if($database->is_error()) {
42
	$admin->print_error($database->get_error(), WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'&section_id='.$section_id.'&post_id='.$post_id);
43
} else {
44
	$admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'&section_id='.$section_id.'&post_id='.$post_id);
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 );
45 53
}
46

  
47
// Print admin footer
54
$admin->print_success($TEXT['SUCCESS'], WB_URL.'/modules/news/modify_post.php?page_id='.$page_id.'&section_id='.$section_id.'&post_id='.$post_id );
48 55
$admin->print_footer();

Also available in: Unified diff