From fe0f580fa8d09ab0a79dbc4750daa0c140057bed Mon Sep 17 00:00:00 2001 From: Aldrioth Date: Wed, 27 Jul 2011 09:43:11 +0000 Subject: [PATCH] 2011-07-27 Tomas Palacios * godmode/setup/news.php: fixed a bug regarding bad timestamps and unability to create site news. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4629 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/godmode/setup/news.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pandora_console/godmode/setup/news.php b/pandora_console/godmode/setup/news.php index 7645d8df02..d54deccceb 100644 --- a/pandora_console/godmode/setup/news.php +++ b/pandora_console/godmode/setup/news.php @@ -32,12 +32,13 @@ ui_print_page_header (__('Site news management'), "", false, "", true); if (isset ($_POST["create"])) { // If create $subject = get_parameter ("subject"); $text = get_parameter ("text"); + $timestamp = db_get_value ('NOW()', 'tconfig_os', 'id_os', 1); $values = array( 'subject' => $subject, 'text' => $text, 'author' => $config["id_user"], - 'timestamp' => NOW()); + 'timestamp' => $timestamp); $id_link = db_process_sql_insert('tnews', $values); ui_print_result_message ($id_link, @@ -49,8 +50,11 @@ if (isset ($_POST["update"])) { // if update $id_news = (int) get_parameter ("id_news", 0); $subject = get_parameter ("subject"); $text = get_parameter ("text"); + //NOW() column exists in any table and always displays the current date and time, so let's get the value from a row in a table which can't be deleted. + //This way we prevent getting no value for this variable + $timestamp = db_get_value ('NOW()', 'tconfig_os', 'id_os', 1); - $values = array('subject' => $subject, 'text' => $text, 'timestamp' => 'NOW()'); + $values = array('subject' => $subject, 'text' => $text, 'timestamp' => $timestamp); $result = db_process_sql_update('tnews', $values, array('id_news' => $id_news)); ui_print_result_message ($result,