From 49251f44fe39cc77d99f61e1c582307387882eb6 Mon Sep 17 00:00:00 2001
From: zarzuelo <noreply@pandorafms.org>
Date: Fri, 30 May 2014 09:27:20 +0000
Subject: [PATCH] 2014-05-30  Sergio Martin <sergio.martin@artica.es>

	* general/logon_ok.php
	godmode/setup/news.php
	include/functions.php
	pandoradb.sql
	pandoradb.postgreSQL.sql
	pandoradb.oracle.sql
	index.php
	extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql
	extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql
	extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql: Added modal window mode
	to the pandora news for ticket: #821



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@10044 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
---
 pandora_console/ChangeLog                     |  14 ++
 .../pandoradb_migrate_5.0.x_to_5.1.mysql.sql  |   9 +
 .../pandoradb_migrate_5.0.x_to_5.1.oracle.sql |   9 +
 ...doradb_migrate_5.0.x_to_5.1.postgreSQL.sql |   9 +
 pandora_console/general/logon_ok.php          |  21 +-
 pandora_console/godmode/setup/news.php        | 212 ++++++++++++++++--
 pandora_console/include/functions.php         |  66 ++++++
 pandora_console/index.php                     |   5 +-
 pandora_console/pandoradb.oracle.sql          |   6 +-
 pandora_console/pandoradb.postgreSQL.sql      |   6 +-
 pandora_console/pandoradb.sql                 |   4 +
 11 files changed, 320 insertions(+), 41 deletions(-)

diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog
index 0f960dd602..32c9630f79 100644
--- a/pandora_console/ChangeLog
+++ b/pandora_console/ChangeLog
@@ -1,3 +1,17 @@
+2014-05-30  Sergio Martin <sergio.martin@artica.es>
+
+	* general/logon_ok.php
+	godmode/setup/news.php
+	include/functions.php
+	pandoradb.sql
+	pandoradb.postgreSQL.sql
+	pandoradb.oracle.sql
+	index.php
+	extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql
+	extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql
+	extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql: Added modal window mode
+	to the pandora news for ticket: #821
+
 2014-05-29  Miguel de Dios <miguel.dedios@artica.es>
 	
 	* include/graphs/pandora.d3.js, include/graphs/functions_d3.php,
diff --git a/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql b/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql
index c5952a29bb..44e82412e4 100644
--- a/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql
+++ b/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.mysql.sql
@@ -209,3 +209,12 @@ ALTER TABLE `tnetwork_component` ADD COLUMN `min_ff_event_normal` int(4) unsigne
 ALTER TABLE `tnetwork_component` ADD COLUMN `min_ff_event_warning` int(4) unsigned default '0';
 ALTER TABLE `tnetwork_component` ADD COLUMN `min_ff_event_critical` int(4) unsigned default '0';
 ALTER TABLE `tnetwork_component` ADD COLUMN `each_ff` tinyint(1) unsigned default '0';
+
+/* 2014/05/30 */
+-- ---------------------------------------------------------------------
+-- Table `tnews`
+-- ---------------------------------------------------------------------
+ALTER TABLE `tnews` ADD COLUMN `id_group` int(10) NOT NULL default 0;
+ALTER TABLE `tnews` ADD COLUMN `modal` tinyint(1) DEFAULT 0;
+ALTER TABLE `tnews` ADD COLUMN `expire` tinyint(1) DEFAULT 0;
+ALTER TABLE `tnews` ADD COLUMN `expire_timestamp` DATETIME  NOT NULL DEFAULT 0;
diff --git a/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql b/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql
index 97e933a150..0bb7d97e6b 100644
--- a/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql
+++ b/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.oracle.sql
@@ -193,3 +193,12 @@ ALTER TABLE tnetwork_component ADD COLUMN min_ff_event_normal INTEGER default 0;
 ALTER TABLE tnetwork_component ADD COLUMN min_ff_event_warning INTEGER default 0;
 ALTER TABLE tnetwork_component ADD COLUMN min_ff_event_critical INTEGER default 0;
 ALTER TABLE tnetwork_component ADD COLUMN each_ff NUMBER(1, 0) default 0;
+
+/* 2014/05/30 */
+-- ---------------------------------------------------------------------
+-- Table `tnews`
+-- ---------------------------------------------------------------------
+ALTER TABLE tnews ADD COLUMN id_group NUMBER(10, 0) default 0 NOT NULL;
+ALTER TABLE tnews ADD COLUMN modal NUMBER(5, 0) default 0 NOT NULL;
+ALTER TABLE tnews ADD COLUMN expire NUMBER(5, 0) default 0 NOT NULL;
+ALTER TABLE tnews ADD COLUMN expire_timestamp TIMESTAMP default NULL;
diff --git a/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql b/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql
index 6e4f480411..fd04269970 100644
--- a/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql
+++ b/pandora_console/extras/pandoradb_migrate_5.0.x_to_5.1.postgreSQL.sql
@@ -167,3 +167,12 @@ ALTER TABLE "tnetwork_component" ADD COLUMN "min_ff_event_normal" INTEGER defaul
 ALTER TABLE "tnetwork_component" ADD COLUMN "min_ff_event_warning" INTEGER default 0;
 ALTER TABLE "tnetwork_component" ADD COLUMN "min_ff_event_critical" INTEGER default 0;
 ALTER TABLE "tnetwork_component" ADD COLUMN "each_ff" SMALLINT default 0;
+
+/* 2014/05/30 */
+-- ---------------------------------------------------------------------
+-- Table `tnews`
+-- ---------------------------------------------------------------------
+ALTER TABLE "tnews" ADD COLUMN "id_group" INTEGER NOT NULL default 0;
+ALTER TABLE "tnews" ADD COLUMN "modal" SMALLINT DEFAULT 0;
+ALTER TABLE "tnews" ADD COLUMN "expire" SMALLINT DEFAULT 0;
+ALTER TABLE "tnews" ADD COLUMN "expire_timestamp" TIMESTAMP without time zone default '1970-01-01 00:00:00';
diff --git a/pandora_console/general/logon_ok.php b/pandora_console/general/logon_ok.php
index ff3aae9112..a0cd0de147 100644
--- a/pandora_console/general/logon_ok.php
+++ b/pandora_console/general/logon_ok.php
@@ -41,23 +41,12 @@ echo '<div style="width:50%; float:left;" id="leftcolumn">';
 	//////////////////NEWS BOARD/////////////////////////////
 	echo '<div id="news_board">';
 	
-	switch ($config["dbtype"]) {
-		case "mysql":
-		case "postgresql":
-			$sql = "SELECT subject,timestamp,text,author
-				FROM tnews
-				ORDER BY timestamp DESC
-				LIMIT 3";
-			break;
-		case "oracle":
-			$sql = "SELECT subject,timestamp,text,author
-				FROM tnews
-				WHERE rownum <= 3
-				ORDER BY timestamp DESC";
-			break;
-	}
+	$options = array();
+	$options['id_user'] = $config['id_user'];
+	$options['modal'] = false;
+	$options['limit'] = 3;
+	$news = get_news($options);
 	
-	$news = db_get_all_rows_sql ($sql);
 	if ($news !== false) {
 		echo '<table cellpadding="4" cellspacing="4" class="databox">';
 		echo '<tr><th><span>' . __('News board') . '</span></th></tr>';
diff --git a/pandora_console/godmode/setup/news.php b/pandora_console/godmode/setup/news.php
index 600fa973d7..51cbda63e8 100644
--- a/pandora_console/godmode/setup/news.php
+++ b/pandora_console/godmode/setup/news.php
@@ -33,12 +33,23 @@ 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' => $timestamp);
+	$id_group = get_parameter ("id_group");
+	$modal =  get_parameter ("modal");
+	$expire = get_parameter ("expire");
+	$expire_date = get_parameter ("expire_date");
+	$expire_date = date('Y-m-d', strtotime($expire_date));
+	$expire_time = get_parameter ("expire_time");
+	$expire_timestamp = "$expire_date $expire_time";
+		
+	$values = array('subject' => $subject, 
+					'text' => $text, 
+					'author' => $config["id_user"],
+					'timestamp' => $timestamp, 
+					'id_group' => $id_group, 
+					'modal' => $modal, 
+					'expire' => $expire, 
+					'expire_timestamp' => $expire_timestamp);
+					
 	$id_link = db_process_sql_insert('tnews', $values);
 	
 	ui_print_result_message ($id_link,
@@ -50,11 +61,26 @@ if (isset ($_POST["update"])) { // if update
 	$id_news = (int) get_parameter ("id_news", 0);
 	$subject = get_parameter ("subject");
 	$text = get_parameter ("text");
+	$id_group = get_parameter ("id_group");
+	$modal =  get_parameter ("modal");
+	$expire = get_parameter ("expire");
+	$expire_date = get_parameter ("expire_date");
+	$expire_date = date('Y-m-d', strtotime($expire_date));
+	$expire_time = get_parameter ("expire_time");
+	$expire_timestamp = "$expire_date $expire_time";
+	
 	//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);
+	$values = array('subject' => $subject, 
+					'text' => $text, 
+					'timestamp' => $timestamp, 
+					'id_group' => $id_group, 
+					'modal' => $modal, 
+					'expire' => $expire, 
+					'expire_timestamp' => $expire_timestamp);
+	
 	$result = db_process_sql_update('tnews', $values, array('id_news' => $id_news));
 	
 	ui_print_result_message ($result,
@@ -85,6 +111,20 @@ if ((isset ($_GET["form_add"])) || (isset ($_GET["form_edit"]))) {
 			$text = $result["text"];
 			$author = $result["author"];
 			$timestamp = $result["timestamp"];
+			$id_group = $result["id_group"];
+			$modal = $result["modal"];
+			$expire = $result["expire"];
+			
+			if ($expire) {
+				$expire_timestamp = $result["expire_timestamp"];
+				$expire_utimestamp = strtotime($expire_timestamp);
+			}
+			else {
+				$expire_utimestamp = time() + SECONDS_1WEEK;
+			}
+			
+			$expire_date = date('Y/m/d', $expire_utimestamp);
+			$expire_time = date('H:i:s', $expire_utimestamp);
 		}
 		else {
 			ui_print_error_message(__('Name error'));
@@ -95,11 +135,56 @@ if ((isset ($_GET["form_add"])) || (isset ($_GET["form_edit"]))) {
 		$text = "";
 		$subject = "";
 		$author = $config['id_user'];
+		$id_group = 0;
+		$modal = 0;
+		$expire = 0;
+		$expire_date = date('Y/m/d', time() + SECONDS_1WEEK);
+		$expire_time = date('H:i:s', time());
 	}
 	
 	// Create news
 	
-	echo '<table class="databox" cellpadding="4" cellspacing="4" width="98%">';
+	$table->width = '98%%';
+	$table->id = "news";
+	$table->cellpadding = 4;
+	$table->cellspacing = 4;
+	$table->class = "databox";
+	$table->head = array ();
+	$table->data = array ();
+	$table->style[0] = 'font-weight: bold;';
+	$table->style[1] = 'font-weight: bold;';
+	$table->style[2] = 'font-weight: bold;';
+	$table->style[3] = 'font-weight: bold;';
+	$table->style[4] = 'font-weight: bold;';
+	
+	$data = array();
+	$data[0] = __('Subject') . '<br>';
+	$data[0] .= '<input type="text" name="subject" size="35" value="'.$subject.'">';
+	
+	$data[1] = __('Group') . '<br>';
+	$data[1] .= html_print_select_groups($config["id_user"], "ER", users_can_manage_group_all(), 'id_group', $id_group, '', '', 0, true, false, false, '');
+	
+	$data[2] = __('Modal screen') . '<br>';
+	$data[2] .= html_print_checkbox_extended('modal', 1, $modal, false, '', 'style="margin-top: 5px;margin-bottom: 7px;"', true);
+	
+	$data[3] = __('Expire') . '<br>';
+	$data[3] .= html_print_checkbox_extended('expire', 1, $expire, false, '', 'style="margin-top: 5px;margin-bottom: 7px;"', true);
+
+	$data[4] = __('Expiration') . '<br>';
+	$data[4] .= html_print_input_text ('expire_date', $expire_date, '', 12, 10, true). ' ';
+	$data[4] .= html_print_input_text ('expire_time', $expire_time, '', 10, 7, true). ' ';
+	
+	$table->rowclass[] = '';
+	$table->data[] = $data;
+	
+	$data = array();
+	$data[0] = __('Text') . '<br>';
+	$data[0] .= html_print_textarea('text', 25, 15, $text, '', true);
+	$table->rowclass[] = '';
+	$table->colspan[1][0] = 5;
+
+	$table->data[] = $data;
+	
 	echo '<form name="ilink" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/news">';
 	if ($creation_mode == 1)
 		echo "<input type='hidden' name='create' value='1'>";
@@ -110,18 +195,10 @@ if ((isset ($_GET["form_add"])) || (isset ($_GET["form_edit"]))) {
 		echo $id_news;
 	} 
 	echo "'>";
-	echo '<tr>
-	<td class="datos">'.__('Subject').'</td>
-	<td class="datos"><input type="text" name="subject" size="35" value="'.$subject.'">';
-	echo '<tr>
-	<td class="datos2">'.__('Text').'</td>
-	<td class="datos2">
-	<textarea rows=4 cols=50 name="text" >';
-	echo $text;
-	echo '</textarea></td>';
-	echo '</tr>';
-	echo "</table>";
-	echo "<table width='98%'>";
+
+	html_print_table($table);
+	
+	echo "<table width='" . $table->width . "'>";
 	echo "<tr><td align='right'>";
 	if (isset($_GET["form_add"])) {
 		echo "<input name='crtbutton' type='submit' class='sub wand' value='".__('Create')."'>";
@@ -141,8 +218,10 @@ else {
 		// Main list view for Links editor
 		echo "<table cellpadding='4' cellspacing='4' class='databox' width=98%>";
 		echo "<th>".__('Subject')."</th>";
+		echo "<th>".__('Type')."</th>";
 		echo "<th>".__('Author')."</th>";
 		echo "<th>".__('Timestamp')."</th>";
+		echo "<th>".__('Expiration')."</th>";
 		echo "<th>".__('Delete')."</th>";
 		
 		
@@ -159,8 +238,31 @@ else {
 			}
 			echo "<tr><td class='$tdcolor'><b><a href='index.php?sec=gsetup&sec2=godmode/setup/news&form_edit=1&id_news=".$row["id_news"]."'>".$row["subject"]."</a></b></td>";
 
+			if ($row['modal']) {
+				echo "<td class='$tdcolor'>".__('Modal')."</b></td>";
+			}
+			else {
+				echo "<td class='$tdcolor'>".__('Board')."</b></td>";
+			}
+			
 			echo "<td class='$tdcolor'>".$row["author"]."</b></td>";
-			echo "<td class='$tdcolor'>".$row["timestamp"]."</b></td>";
+			$utimestamp = strtotime($row["timestamp"]);
+			echo "<td class='$tdcolor'>" . date($config['date_format'], strtotime($row["timestamp"])) . "</b></td>";
+			if ($row["expire"]) {
+				$expire_utimestamp = strtotime($row["expire_timestamp"]);
+				$expire_in_secs = $expire_utimestamp - $utimestamp;
+				
+				if( $expire_in_secs <= 0) {
+					echo "<td class='$tdcolor'>" . __('Expired') . "</b></td>";
+				}
+				else {
+					$expire_in = human_time_description_raw($expire_in_secs, false, 'large');
+					echo "<td class='$tdcolor'>" . $expire_in . "</b></td>";
+				}
+			}
+			else {
+				echo "<td class='$tdcolor'>".__('No')."</b></td>";
+			}
 			
 			echo '<td class="'.$tdcolor.'" align="center"><a href="index.php?sec=gsetup&sec2=godmode/setup/news&id_news='.$row["id_news"].'&borrar='.$row["id_news"].'" onClick="if (!confirm(\' '.__('Are you sure?').'\')) return false;">' . html_print_image("images/cross.png", true, array("border" => '0')) . '</a></td></tr>';
 		}
@@ -173,4 +275,72 @@ else {
 	echo "<input type='submit' class='sub next' name='form_add' value='".__('Add')."'>";
 	echo "</form></table>";
 }
+
+/*
+ * We must add javascript here. Otherwise, the date picker won't 
+ * work if the date is not correct because php is returning.
+ */
+
+ui_require_jquery_file ("ui-timepicker-addon");
+// This script is included manually to be included after jquery and avoid error
+echo '<script type="text/javascript" src="' . ui_get_full_url('include/javascript/i18n/jquery-ui-timepicker-' . get_user_language() . '.js', false, false, false) . '"></script>';
+ui_require_jquery_file("ui.datepicker-" . get_user_language(), "include/javascript/i18n/");
+
+// Include tiny for wysiwyg editor
+ui_require_javascript_file('tiny_mce', 'include/javascript/tiny_mce/');
+
 ?>
+<script language="javascript" type="text/javascript">
+
+	$(document).ready (function () {
+		$("#text-expire_time").timepicker({
+				showSecond: true,
+				timeFormat: '<?php echo TIME_FORMAT_JS; ?>',
+				timeOnlyTitle: '<?php echo __('Choose time');?>',
+				timeText: '<?php echo __('Time');?>',
+				hourText: '<?php echo __('Hour');?>',
+				minuteText: '<?php echo __('Minute');?>',
+				secondText: '<?php echo __('Second');?>',
+				currentText: '<?php echo __('Now');?>',
+				closeText: '<?php echo __('Close');?>'});
+		
+		$.datepicker.setDefaults($.datepicker.regional[ "<?php echo get_user_language(); ?>"]);
+		
+		$("#text-expire_date").datepicker({
+			dateFormat: "<?php echo DATE_FORMAT_JS; ?>",
+			changeMonth: true,
+			changeYear: true,
+			showAnim: "slideDown"});
+			
+			
+		tinyMCE.init({
+			mode : "exact",
+			elements: "textarea_text",
+			theme : "advanced",
+			theme_advanced_toolbar_location : "top",
+			theme_advanced_toolbar_align : "left",
+			theme_advanced_buttons1 : "bold,italic, |, image, link, |, cut, copy, paste, |, undo, redo, |, forecolor, |, fontsizeselect, |, justifyleft, justifycenter, justifyright",
+			theme_advanced_buttons2 : "",
+			theme_advanced_buttons3 : "",
+			convert_urls : false,
+			theme_advanced_statusbar_location : "none"
+		});
+		
+		$("#checkbox-expire").click(function() {
+			check_expire();
+		});
+		
+	});
+			
+	check_expire();
+
+	function check_expire() {
+		if ($("#checkbox-expire").is(":checked")) {
+			$('#news-0-4').css('visibility', '');
+		}
+		else {
+			$('#news-0-4').css('visibility', 'hidden');
+		}
+	}
+
+</script>
diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php
index 36d7e72375..2d77cafa8c 100644
--- a/pandora_console/include/functions.php
+++ b/pandora_console/include/functions.php
@@ -2029,4 +2029,70 @@ function translate_file_upload_status ($status_code) {
 	return $message;
 }
 
+/**
+ *  Get the arguments given in a function returning default value if not defined
+ *  @param string name of the argument
+ *  @param mixed array with arguments
+ *  @param string defualt value for this argument
+ * 
+ *  @return string value for the argument
+ */
+function get_argument ($argument, $arguments, $default) {
+	if (isset($arguments[$argument])) {
+		return $arguments[$argument];
+	}
+	else {
+		return $default;
+	}
+}
+
+/**
+ *  Get the arguments given in a function returning default value if not defined
+ *  @param mixed arguments
+ * 			- id_user: user who can see the news
+ *  		- modal: true if want to get modal news. false to return not modal news
+ * 			- limit: number of max news returned
+ *  @return mixed list of news
+ */
+function get_news($arguments) {
+	global $config;
+	
+	$id_user = get_argument ('id_user', $arguments, $config['id_user']);
+	$modal = get_argument ('modal', $arguments, false);
+	$limit = get_argument ('limit', $arguments, 99999999);
+	
+	$id_group = array_keys(users_get_groups($id_user, 'AR', true));
+	$id_group = implode(',',$id_group);
+	$current_datetime = date('Y-m-d H:i:s', time());
+	$modal = (int) $modal;
+	
+	switch ($config["dbtype"]) {
+		case "mysql":
+		case "postgresql":
+			$sql = sprintf("SELECT subject,timestamp,text,author
+				FROM tnews WHERE id_group IN (%s) AND 
+								modal = %s AND 
+								(expire = 0 OR (expire = 1 AND expire_timestamp > '%s'))
+				ORDER BY timestamp DESC
+				LIMIT %s", $id_group, $modal, $current_datetime, $limit);
+			break;
+		case "oracle":
+			$sql = sprintf("SELECT subject,timestamp,text,author
+				FROM tnews
+				WHERE rownum <= %limit AND id_group IN (%s) AND 
+								modal = %s AND 
+								(expire = 0 OR (expire = 1 AND expire_timestamp > '%s'))
+				ORDER BY timestamp DESC", $limit, $id_group, $modal, $current_datetime);
+			break;
+	}
+	
+	$news = db_get_all_rows_sql ($sql);
+	
+	if (empty($news)) {
+		$news = array();
+	}
+	
+	return $news;
+}
+
 ?>
diff --git a/pandora_console/index.php b/pandora_console/index.php
index 4deca0da52..a4dda309dd 100644
--- a/pandora_console/index.php
+++ b/pandora_console/index.php
@@ -404,15 +404,16 @@ if ($old_global_counter_chat != $now_global_counter_chat) {
 		$_SESSION['new_chat'] = true;
 }
 
-// Display login help info dialog
 if (get_parameter ('login', 0) !== 0) {
+	// Display news dialog
+	include_once("general/news_dialog.php");
 	
+	// Display login help info dialog
 	// If it's configured to not skip this
 	if (!isset($config['skip_login_help_dialog']) ||
 		$config['skip_login_help_dialog'] == 0) {
 		
 		include_once("general/login_help_dialog.php");
-		
 	}
 	
 }
diff --git a/pandora_console/pandoradb.oracle.sql b/pandora_console/pandoradb.oracle.sql
index 3c7e1f8888..112a7a2d0c 100644
--- a/pandora_console/pandoradb.oracle.sql
+++ b/pandora_console/pandoradb.oracle.sql
@@ -1053,7 +1053,11 @@ CREATE TABLE tnews (
 	author VARCHAR2(255) DEFAULT '',
 	subject VARCHAR2(255) DEFAULT '',
 	text CLOB NOT NULL,
-	timestamp TIMESTAMP default NULL
+	timestamp TIMESTAMP default NULL,
+	id_group NUMBER(10, 0) default 0 NOT NULL,
+	modal NUMBER(5, 0) default 0 NOT NULL,
+	expire NUMBER(5, 0) default 0 NOT NULL,
+	expire_timestamp TIMESTAMP default NULL
 );
 CREATE SEQUENCE tnews_s INCREMENT BY 1 START WITH 1;
 CREATE OR REPLACE TRIGGER tnews_inc BEFORE INSERT ON tnews REFERENCING NEW AS NEW FOR EACH ROW BEGIN SELECT tnews_s.nextval INTO :NEW.ID_NEWS FROM dual; END tnews_inc;;
diff --git a/pandora_console/pandoradb.postgreSQL.sql b/pandora_console/pandoradb.postgreSQL.sql
index 2109c199b3..ff696c7224 100644
--- a/pandora_console/pandoradb.postgreSQL.sql
+++ b/pandora_console/pandoradb.postgreSQL.sql
@@ -931,7 +931,11 @@ CREATE TABLE "tnews" (
 	"author" varchar(255)  NOT NULL DEFAULT '',
 	"subject" varchar(255)  NOT NULL DEFAULT '',
 	"text" TEXT NOT NULL,
-	"timestamp" TIMESTAMP without time zone default '1970-01-01 00:00:00'
+	"timestamp" TIMESTAMP without time zone default '1970-01-01 00:00:00',
+	"id_group" INTEGER NOT NULL default 0,
+	"modal" SMALLINT DEFAULT 0,
+	"expire" SMALLINT DEFAULT 0,
+	"expire_timestamp"  TIMESTAMP without time zone default '1970-01-01 00:00:00'
 );
 
 -- -----------------------------------------------------
diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql
index 7b658da7f0..e368855976 100644
--- a/pandora_console/pandoradb.sql
+++ b/pandora_console/pandoradb.sql
@@ -1006,6 +1006,10 @@ CREATE TABLE IF NOT EXISTS `tnews` (
 	`subject` varchar(255)  NOT NULL DEFAULT '',
 	`text` TEXT NOT NULL,
 	`timestamp` DATETIME  NOT NULL DEFAULT 0,
+	`id_group` int(10) NOT NULL default 0,
+	`modal` tinyint(1) DEFAULT 0,
+	`expire` tinyint(1) DEFAULT 0,
+	`expire_timestamp` DATETIME  NOT NULL DEFAULT 0,
 	PRIMARY KEY(`id_news`)
 ) ENGINE = InnoDB DEFAULT CHARSET=utf8;