2014-02-06 18:39:39 +01:00
< ? php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// 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 for 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.
ob_start ();
require_once ( '../include/functions_visual_map.php' );
ob_get_clean (); //Fixed unused javascript code.
class Visualmaps {
private $correct_acl = false ;
2015-04-09 14:00:37 +02:00
private $acl = " VR " ;
2014-02-06 18:39:39 +01:00
private $default = true ;
private $default_filters = array ();
private $group = 0 ;
private $type = 0 ;
private $list_types = null ;
function __construct () {
$system = System :: getInstance ();
if ( $system -> checkACL ( $this -> acl )) {
$this -> correct_acl = true ;
}
else {
$this -> correct_acl = false ;
}
}
private function getFilters () {
$system = System :: getInstance ();
$user = User :: getInstance ();
$this -> default_filters [ 'group' ] = true ;
$this -> default_filters [ 'type' ] = true ;
$this -> group = ( int ) $system -> getRequest ( 'group' , __ ( " Group " ));
if ( ! $user -> isInGroup ( $this -> acl , $this -> group )) {
$this -> group = 0 ;
}
if (( $this -> group === __ ( " Group " )) || ( $this -> group == 0 )) {
$this -> group = 0 ;
}
else {
$this -> default = false ;
$this -> default_filters [ 'group' ] = false ;
}
$this -> type = $system -> getRequest ( 'type' , __ ( " Type " ));
if (( $this -> type === __ ( " Type " )) || ( $this -> type === '0' )) {
$this -> type = '0' ;
}
else {
$this -> default = false ;
$this -> default_filters [ 'type' ] = false ;
}
}
public function show () {
if ( ! $this -> correct_acl ) {
$this -> show_fail_acl ();
}
else {
$this -> getFilters ();
$this -> show_visualmaps ();
}
}
private function show_fail_acl () {
2014-10-15 18:12:51 +02:00
$error [ 'type' ] = 'onStart' ;
2014-02-06 18:39:39 +01:00
$error [ 'title_text' ] = __ ( 'You don\'t have access to this page' );
$error [ 'content_text' ] = __ ( 'Access to this page is restricted to authorized users only, please contact system administrator if you need assistance. <br><br>Please know that all attempts to access this page are recorded in security logs of Pandora System Database' );
2014-10-15 18:12:51 +02:00
if ( class_exists ( " HomeEnterprise " ))
$home = new HomeEnterprise ();
else
$home = new Home ();
2014-02-06 18:39:39 +01:00
$home -> show ( $error );
}
private function show_visualmaps () {
$ui = Ui :: getInstance ();
$ui -> createPage ();
$ui -> createDefaultHeader ( __ ( " Visual consoles " ),
$ui -> createHeaderButton (
array ( 'icon' => 'back' ,
'pos' => 'left' ,
'text' => __ ( 'Back' ),
'href' => 'index.php?page=home' )));
$ui -> showFooter ( false );
$ui -> beginContent ();
$this -> listVisualmapsHtml ();
$ui -> endContent ();
$ui -> showPage ();
}
private function listVisualmapsHtml () {
$system = System :: getInstance ();
$ui = Ui :: getInstance ();
// Create filter
$where = array ();
// Order by type field
$where [ 'order' ] = 'type' ;
if ( $this -> group != '0' )
$where [ 'id_group' ] = $this -> group ;
if ( $this -> type != '0' )
$where [ 'type' ] = $this -> type ;
// Only display maps of "All" group if user is administrator
// or has "RR" privileges, otherwise show only maps of user group
$id_user = $system -> getConfig ( 'id_user' );
$own_info = get_user_info ( $id_user );
if ( $own_info [ 'is_admin' ] || $system -> checkACL ( $this -> acl ))
2015-06-08 13:13:09 +02:00
$maps = visual_map_get_user_layouts ();
2014-02-06 18:39:39 +01:00
else
$maps = visual_map_get_user_layouts ( $id_user , false , false , false );
if ( empty ( $maps )) {
$maps = array ();
}
$list = array ();
foreach ( $maps as $map ) {
$row = array ();
$row [ __ ( 'Name' )] = '<a class="ui-link" data-ajax="false" href="index.php?page=visualmap&id=' . $map [ 'id' ] . '">' . io_safe_output ( $map [ 'name' ]) . '</a>' ;
//$row[__('Type')] = $map['type'];
$row [ __ ( 'Group' )] = ui_print_group_icon ( $map [ " id_group " ], true , " groups_small " , " " , false );
$list [] = $row ;
}
if ( count ( $maps ) == 0 ) {
$ui -> contentAddHtml ( '<p style="color: #ff0000;">' . __ ( 'No maps defined' ) . '</p>' );
}
else {
$table = new Table ();
$table -> id = 'list_visualmaps' ;
$table -> importFromHash ( $list );
$ui -> contentAddHtml ( $table -> getHTML ());
}
2014-02-10 12:54:39 +01:00
$ui -> contentAddLinkListener ( 'list_visualmaps' );
2014-02-06 18:39:39 +01:00
}
}
?>