$subject,
'text' => $text,
'author' => $config["id_user"],
'timestamp' => NOW());
$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");
$values = array('subject' => $subject, 'text' => $text, 'timestamp' => 'NOW()');
$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 "';
}
else {
// Main list view for Links editor
echo "";
echo "".__('Subject')." | ";
echo "".__('Author')." | ";
echo "".__('Timestamp')." | ";
echo "".__('Delete')." | ";
$rows = db_get_all_rows_in_table("tnews", "timestamp");
if ($rows === false) {
$rows = array();
}
$color = 1;
foreach ($rows as $row) {
if ($color == 1) {
$tdcolor = "datos";
$color = 0;
}
else {
$tdcolor = "datos2";
$color = 1;
}
echo "".$row["subject"]." | ";
echo "".$row["author"]." | ";
echo "".$row["timestamp"]." | ";
echo '' . html_print_image("images/cross.png", true, array("border" => '0')) . ' |
';
}
echo "
";
echo "";
}
?>