2014-05-30 12:34:21 +02:00
< ? php
2021-11-04 16:28:15 +01:00
// Pandora FMS - http://pandorafms.com
2014-05-30 12:34:21 +02:00
// ==================================================
2020-11-27 13:52:35 +01:00
// Copyright (c) 2005-2021 Artica Soluciones Tecnologicas
2014-05-30 12:34:21 +02:00
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/**
* @ package General
*/
global $config ;
2015-06-08 13:13:09 +02:00
2019-01-30 16:18:44 +01:00
$options = [];
2014-05-30 12:34:21 +02:00
$options [ 'id_user' ] = $config [ 'id_user' ];
$options [ 'modal' ] = true ;
$news = get_news ( $options );
// Clean subject entities
2019-01-30 16:18:44 +01:00
foreach ( $news as $k => $v ) {
$news [ $k ][ 'text' ] = io_safe_output ( $v [ 'text' ]);
$news [ $k ][ 'subject' ] = io_safe_output ( $v [ 'subject' ]);
2014-05-30 12:34:21 +02:00
}
if ( ! empty ( $news )) {
2019-01-30 16:18:44 +01:00
$options = [];
$options [ 'id' ] = 'news_json' ;
$options [ 'hidden' ] = 1 ;
$options [ 'content' ] = base64_encode ( json_encode ( $news ));
html_print_div ( $options );
2014-05-30 12:34:21 +02:00
}
// Prints news dialog template
2021-03-11 15:40:23 +01:00
echo '<div id="news_dialog" class="invisible">' ;
2019-01-30 16:18:44 +01:00
2021-03-11 15:40:23 +01:00
echo '<div class="parent_new_dialog_tmplt">' ;
echo '<span id="new_text"></span>' ;
echo '<span id="new_author"></span>' ;
echo '<span id="new_timestamp"></span>' ;
2019-01-30 16:18:44 +01:00
echo '</div>' ;
2021-03-11 15:40:23 +01:00
echo '<div id="div_btn_new_dialog">' ;
echo '<div class="float-right w20p">' ;
html_print_submit_button ( 'Ok' , 'hide-news-help' , false , 'class="ui-button-dialog ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok w100px";"' );
2019-01-30 16:18:44 +01:00
echo '</div>' ;
echo '</div>' ;
2014-05-30 12:34:21 +02:00
echo '</div>' ;
2019-01-30 16:18:44 +01:00
ui_require_javascript_file ( 'encode_decode_base64' );
2014-05-30 12:34:21 +02:00
?>
< script type = " text/javascript " language = " javascript " >
/* <![CDATA[ */
$ ( document ) . ready ( function () {
2019-01-30 16:18:44 +01:00
if ( typeof ( $ ( '#news_json' ) . html ()) != " undefined " ) {
var news_raw = Base64 . decode ( $ ( '#news_json' ) . html ());
var news = JSON . parse ( news_raw );
var inew = 0 ;
function show_new () {
if ( news [ inew ] != undefined ) {
$ ( '#new_text' ) . html ( news [ inew ] . text );
$ ( '#new_timestamp' ) . html ( news [ inew ] . timestamp );
$ ( '#new_author' ) . html ( news [ inew ] . author );
$ ( " #news_dialog " ) . dialog ({
resizable : true ,
draggable : true ,
modal : true ,
closeOnEscape : false ,
height : 450 ,
width : 630 ,
title : news [ inew ] . subject ,
overlay : {
opacity : 0.5 ,
background : " black "
}
});
$ ( '.ui-dialog-titlebar-close' ) . hide ();
}
}
$ ( " #submit-hide-news-help " ) . click ( function () {
$ ( " #news_dialog " ) . dialog ( 'close' );
inew ++ ;
show_new ();
});
show_new ();
}
2014-05-30 12:34:21 +02:00
});
/* ]]> */
</ script >