2013-07-03 10:50:50 +02: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.
2013-07-03 14:09:23 +02:00
ob_start ();
2013-07-03 10:50:50 +02:00
require_once ( '../include/functions_networkmap.php' );
2013-07-03 14:09:23 +02:00
ob_get_clean (); //Fixed unused javascript code.
2013-07-03 10:50:50 +02:00
class Networkmaps {
private $correct_acl = false ;
private $acl = " AR " ;
private $default = true ;
2013-07-08 12:15:49 +02:00
private $default_filters = array ();
2013-07-03 10:50:50 +02:00
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 ;
}
}
public function ajax ( $parameter2 = false ) {
$system = System :: getInstance ();
if ( ! $this -> correct_acl ) {
return ;
}
else {
switch ( $parameter2 ) {
case 'xxx' :
//$this->getFilters();
//$page = $system->getRequest('page', 0);
break ;
}
}
}
private function getFilters () {
$system = System :: getInstance ();
$user = User :: getInstance ();
2013-07-08 12:15:49 +02:00
$this -> default_filters [ 'group' ] = true ;
$this -> default_filters [ 'type' ] = true ;
2013-07-03 10:50:50 +02:00
$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 ;
2013-07-08 12:15:49 +02:00
$this -> default_filters [ 'group' ] = false ;
2013-07-03 10:50:50 +02:00
}
$this -> type = $system -> getRequest ( 'type' , __ ( " Type " ));
2013-07-08 12:15:49 +02:00
if (( $this -> type === __ ( " Type " )) || ( $this -> type === '0' )) {
$this -> type = '0' ;
2013-07-03 10:50:50 +02:00
}
else {
$this -> default = false ;
2013-07-08 12:15:49 +02:00
$this -> default_filters [ 'type' ] = false ;
2013-07-03 10:50:50 +02:00
}
}
public function show () {
if ( ! $this -> correct_acl ) {
$this -> show_fail_acl ();
}
else {
$this -> getFilters ();
$this -> show_networkmaps ();
}
}
private function show_fail_acl () {
$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' );
$home = new Home ();
$home -> show ( $error );
}
private function show_networkmaps () {
$ui = Ui :: getInstance ();
$ui -> createPage ();
2013-11-28 17:54:18 +01:00
$ui -> createDefaultHeader ( __ ( " Networkmaps " ),
2013-07-03 Miguel de Dios <miguel.dedios@artica.es>
* mobile/operation/events.php, mobile/operation/module_graph.php,
mobile/operation/modules.php, mobile/operation/networkmaps.php,
mobile/operation/groups.php, mobile/operation/agents.php,
mobile/operation/tactical.php, mobile/operation/networkmap.php,
mobile/operation/alerts.php, mobile/operation/agent.php,
mobile/include/ui.class.php: added the back button in the head and
impoved the source code style to make more easy the merges with
the last branch.
* include/functions_graph.php: fixed PHP notices.
git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8468 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
2013-07-03 15:59:38 +02:00
$ui -> createHeaderButton (
array ( 'icon' => 'back' ,
'pos' => 'left' ,
'text' => __ ( 'Back' ),
2013-11-28 17:54:18 +01:00
'href' => 'index.php?page=home' )));
2013-07-03 10:50:50 +02:00
$ui -> showFooter ( false );
$ui -> beginContent ();
$filter_title = sprintf ( __ ( 'Filter Networkmaps by %s' ),
$this -> filterNetworkmapsGetString ());
$ui -> contentBeginCollapsible ( $filter_title );
$ui -> beginForm ( " index.php?page=networkmaps " );
$system = System :: getInstance ();
$groups = users_get_groups_for_select (
$system -> getConfig ( 'id_user' ), " AR " , true , true , false , 'id_grupo' );
$options = array (
'name' => 'group' ,
'title' => __ ( 'Group' ),
'label' => __ ( 'Group' ),
'items' => $groups ,
'selected' => $this -> group
);
$ui -> formAddSelectBox ( $options );
$networkmap_types = networkmap_get_filter_types ();
$networkmap_types [ 0 ] = __ ( 'All' );
$options = array (
'name' => 'type' ,
'title' => __ ( 'Type' ),
'label' => __ ( 'Type' ),
'items' => $networkmap_types ,
'selected' => $this -> type
);
$ui -> formAddSelectBox ( $options );
$options = array (
'icon' => 'refresh' ,
'icon_pos' => 'right' ,
'text' => __ ( 'Apply Filter' )
);
$ui -> formAddSubmitButton ( $options );
$html = $ui -> getEndForm ();
$ui -> contentCollapsibleAddItem ( $html );
$ui -> contentEndCollapsible ();
$this -> listNetworkmapsHtml ();
$ui -> endContent ();
$ui -> showPage ();
}
private function listNetworkmapsHtml () {
$system = System :: getInstance ();
$ui = Ui :: getInstance ();
// Create filter
$where = array ();
// Order by type field
$where [ 'order' ] = 'type' ;
2014-02-07 11:07:54 +01:00
if ( $this -> group != '0' ) {
2013-07-03 10:50:50 +02:00
$where [ 'id_group' ] = $this -> group ;
2014-02-07 11:07:54 +01:00
}
else {
$where [ 'id_group' ] = array_keys ( users_get_groups ());
}
2013-07-03 10:50:50 +02:00
if ( $this -> type != '0' )
$where [ 'type' ] = $this -> type ;
$network_maps = db_get_all_rows_filter ( 'tnetwork_map' ,
$where );
if ( empty ( $network_maps )) {
$network_maps = array ();
}
$list = array ();
foreach ( $network_maps as $networkmap ) {
2014-02-07 11:07:54 +01:00
// If enterprise not loaded then skip this code
if ( $networkmap [ 'type' ] == 'policies' and ( ! defined ( 'PANDORA_ENTERPRISE' )))
continue ;
2013-07-03 10:50:50 +02:00
$row = array ();
$row [ __ ( 'Name' )] = '<a class="ui-link" data-ajax="false" href="index.php?page=networkmap&id=' . $networkmap [ 'id_networkmap' ] . '">' . io_safe_output ( $networkmap [ 'name' ]) . '</a>' ;
$row [ __ ( 'Type' )] = $networkmap [ 'type' ];
2013-12-05 15:56:57 +01:00
$row [ __ ( 'Group' )] = ui_print_group_icon ( $networkmap [ " id_group " ], true , " groups_small " , " " , false );
2013-07-03 10:50:50 +02:00
$list [] = $row ;
}
if ( count ( $network_maps ) == 0 ) {
$ui -> contentAddHtml ( '<p style="color: #ff0000;">' . __ ( 'No networkmaps' ) . '</p>' );
}
else {
$table = new Table ();
$table -> id = 'list_networkmaps' ;
$table -> importFromHash ( $list );
$ui -> contentAddHtml ( $table -> getHTML ());
}
2014-02-10 12:54:39 +01:00
$ui -> contentAddLinkListener ( 'list_networkmaps' );
2013-07-03 10:50:50 +02:00
}
private function filterNetworkmapsGetString () {
if ( $this -> default ) {
return __ ( " (Default) " );
}
else {
2013-07-08 12:15:49 +02:00
$filters_to_serialize = array ();
if ( ! $this -> default_filters [ 'group' ]) {
$filters_to_serialize [] = sprintf ( __ ( " Group: %s " ),
groups_get_name ( $this -> group , true ));
}
if ( ! $this -> default_filters [ 'type' ]) {
$networkmap_types = networkmap_get_filter_types ();
$networkmap_types [ 0 ] = __ ( 'All' );
$filters_to_serialize [] = sprintf ( __ ( " Type: %s " ),
$networkmap_types [ $this -> type ]);
}
$string = '(' . implode ( ' - ' , $filters_to_serialize ) . ')' ;
2013-07-03 10:50:50 +02:00
2013-07-08 12:15:49 +02:00
//~ $networkmap_types = networkmap_get_filter_types();
//~ $networkmap_types[0] = __('All');
//~ $type = $networkmap_types[$this->type];
//~ $group = groups_get_name($this->group, true);
//~
//~
//~ $string = sprintf(
//~ __("(Type: %s - Group: %s)"),
//~ $type, $group);
2013-07-03 10:50:50 +02:00
return $string ;
}
}
}
2013-11-28 17:54:18 +01:00
?>