$subject, 'text' => $text, 'author' => $config["id_user"], 'timestamp' => $timestamp); $id_link = db_process_sql_insert('tnews', $values); ui_print_result_message ($id_link, __('Successfully created'), __('Could not be created')); } 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' => $timestamp); $result = db_process_sql_update('tnews', $values, array('id_news' => $id_news)); ui_print_result_message ($result, __('Successfully updated'), __('Not updated. Error updating data')); } if (isset ($_GET["borrar"])) { // if delete $id_news = (int) get_parameter ("borrar", 0); $result = db_process_sql_delete ('tnews', array ('id_news' => $id_news)); ui_print_result_message ($result, __('Successfully deleted'), __('Could not be deleted')); } // Main form view for Links edit if ((isset ($_GET["form_add"])) || (isset ($_GET["form_edit"]))) { if (isset($_GET["form_edit"])) { $creation_mode = 0; $id_news = (int) get_parameter ("id_news", 0); $result = db_get_row ("tnews", "id_news", $id_news); if ($result !== false) { $subject = $result["subject"]; $text = $result["text"]; $author = $result["author"]; $timestamp = $result["timestamp"]; } else { echo "

".__('Name error')."

"; } } else { // form_add $creation_mode = 1; $text = ""; $subject = ""; $author = $config['id_user']; } // Create news echo ''; echo ''; if ($creation_mode == 1) echo ""; else echo ""; echo ""; echo ''; echo ''; echo "
'.__('Subject').' '; echo '
'.__('Text').'
"; echo ""; echo "
"; if (isset($_GET["form_add"])) { echo ""; } else { echo ""; } echo '
'; } else { $rows = db_get_all_rows_in_table("tnews", "timestamp"); if ($rows === false) { $rows = array(); echo "
".__('There are no defined news')."
"; } else { // Main list view for Links editor echo ""; echo ""; echo ""; echo ""; echo ""; $color = 1; foreach ($rows as $row) { if ($color == 1) { $tdcolor = "datos"; $color = 0; } else { $tdcolor = "datos2"; $color = 1; } echo ""; echo ""; echo ""; echo ''; } echo "
".__('Subject')."".__('Author')."".__('Timestamp')."".__('Delete')."
".$row["subject"]."".$row["author"]."".$row["timestamp"]."' . html_print_image("images/cross.png", true, array("border" => '0')) . '
"; } echo ""; echo "
"; echo "
"; echo ""; echo "
"; } ?>