diff --git a/pandora_agents/unix/DEBIAN/control b/pandora_agents/unix/DEBIAN/control index 530d72c92a..e3451f29f0 100644 --- a/pandora_agents/unix/DEBIAN/control +++ b/pandora_agents/unix/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-agent-unix -Version: 7.0NG.739-191008 +Version: 7.0NG.739-191017 Architecture: all Priority: optional Section: admin diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index 7a0b937277..f1dca77dff 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.739-191008" +pandora_version="7.0NG.739-191017" echo "Test if you has the tools for to make the packages." whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null diff --git a/pandora_agents/unix/pandora_agent b/pandora_agents/unix/pandora_agent index 3c1555127b..4628861d02 100755 --- a/pandora_agents/unix/pandora_agent +++ b/pandora_agents/unix/pandora_agent @@ -42,7 +42,7 @@ my $Sem = undef; my $ThreadSem = undef; use constant AGENT_VERSION => '7.0NG.739'; -use constant AGENT_BUILD => '191008'; +use constant AGENT_BUILD => '191017'; # Agent log default file size maximum and instances use constant DEFAULT_MAX_LOG_SIZE => 600000; diff --git a/pandora_agents/unix/pandora_agent.redhat.spec b/pandora_agents/unix/pandora_agent.redhat.spec index cfb80e4a20..5c3ff6fbab 100644 --- a/pandora_agents/unix/pandora_agent.redhat.spec +++ b/pandora_agents/unix/pandora_agent.redhat.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.739 -%define release 191008 +%define release 191017 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent.spec b/pandora_agents/unix/pandora_agent.spec index 75849e3332..25d7adc36a 100644 --- a/pandora_agents/unix/pandora_agent.spec +++ b/pandora_agents/unix/pandora_agent.spec @@ -3,7 +3,7 @@ # %define name pandorafms_agent_unix %define version 7.0NG.739 -%define release 191008 +%define release 191017 Summary: Pandora FMS Linux agent, PERL version Name: %{name} diff --git a/pandora_agents/unix/pandora_agent_installer b/pandora_agents/unix/pandora_agent_installer index c9c15b524d..e84b3e8ba4 100755 --- a/pandora_agents/unix/pandora_agent_installer +++ b/pandora_agents/unix/pandora_agent_installer @@ -10,7 +10,7 @@ # ********************************************************************** PI_VERSION="7.0NG.739" -PI_BUILD="191008" +PI_BUILD="191017" OS_NAME=`uname -s` FORCE=0 diff --git a/pandora_agents/win32/installer/pandora.mpi b/pandora_agents/win32/installer/pandora.mpi index c4cb54ef67..13dc69e5ee 100644 --- a/pandora_agents/win32/installer/pandora.mpi +++ b/pandora_agents/win32/installer/pandora.mpi @@ -186,7 +186,7 @@ UpgradeApplicationID {} Version -{191008} +{191017} ViewReadme {Yes} diff --git a/pandora_agents/win32/pandora.cc b/pandora_agents/win32/pandora.cc index 4c2e13743e..73132d3124 100644 --- a/pandora_agents/win32/pandora.cc +++ b/pandora_agents/win32/pandora.cc @@ -30,7 +30,7 @@ using namespace Pandora; using namespace Pandora_Strutils; #define PATH_SIZE _MAX_PATH+1 -#define PANDORA_VERSION ("7.0NG.739(Build 191008)") +#define PANDORA_VERSION ("7.0NG.739(Build 191017)") string pandora_path; string pandora_dir; diff --git a/pandora_agents/win32/versioninfo.rc b/pandora_agents/win32/versioninfo.rc index 421dfa8cb0..0592f5a8e2 100644 --- a/pandora_agents/win32/versioninfo.rc +++ b/pandora_agents/win32/versioninfo.rc @@ -11,7 +11,7 @@ BEGIN VALUE "LegalCopyright", "Artica ST" VALUE "OriginalFilename", "PandoraAgent.exe" VALUE "ProductName", "Pandora FMS Windows Agent" - VALUE "ProductVersion", "(7.0NG.739(Build 191008))" + VALUE "ProductVersion", "(7.0NG.739(Build 191017))" VALUE "FileVersion", "1.0.0.0" END END diff --git a/pandora_console/DEBIAN/control b/pandora_console/DEBIAN/control index dbc8eb0477..dbd51ba15b 100644 --- a/pandora_console/DEBIAN/control +++ b/pandora_console/DEBIAN/control @@ -1,5 +1,5 @@ package: pandorafms-console -Version: 7.0NG.739-191008 +Version: 7.0NG.739-191017 Architecture: all Priority: optional Section: admin diff --git a/pandora_console/DEBIAN/make_deb_package.sh b/pandora_console/DEBIAN/make_deb_package.sh index 6b176913da..c88aec37cb 100644 --- a/pandora_console/DEBIAN/make_deb_package.sh +++ b/pandora_console/DEBIAN/make_deb_package.sh @@ -14,7 +14,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -pandora_version="7.0NG.739-191008" +pandora_version="7.0NG.739-191017" package_pear=0 package_pandora=1 diff --git a/pandora_console/godmode/agentes/agent_manager.php b/pandora_console/godmode/agentes/agent_manager.php index 6ee2343fc0..d6b9448576 100644 --- a/pandora_console/godmode/agentes/agent_manager.php +++ b/pandora_console/godmode/agentes/agent_manager.php @@ -765,7 +765,7 @@ $table_adv_agent_icon .= html_print_select( ).''; if ($config['activate_gis']) { - $table_adv_gis = '
'.__('Ignore new GIS data:').'
'; + $table_adv_gis = ''.__('Update new GIS data:').'
'; if ($new_agent) { $update_gis_data = true; } diff --git a/pandora_console/godmode/agentes/configurar_agente.php b/pandora_console/godmode/agentes/configurar_agente.php index e97fa7cf39..55116f940a 100644 --- a/pandora_console/godmode/agentes/configurar_agente.php +++ b/pandora_console/godmode/agentes/configurar_agente.php @@ -1382,8 +1382,8 @@ if ($update_module || $create_module) { $ff_event_normal = (int) get_parameter('ff_event_normal'); $ff_event_warning = (int) get_parameter('ff_event_warning'); $ff_event_critical = (int) get_parameter('ff_event_critical'); - $ff_type = (int) get_parameter('ff_type'); - $each_ff = (int) get_parameter('each_ff'); + $ff_type = (int) get_parameter('ff_type', $module['ff_type']); + $each_ff = (int) get_parameter('each_ff', $module['each_ff']); $ff_timeout = (int) get_parameter('ff_timeout'); $unit = (string) get_parameter('unit'); $id_tag = (array) get_parameter('id_tag_selected'); diff --git a/pandora_console/godmode/massive/massive_edit_agents.php b/pandora_console/godmode/massive/massive_edit_agents.php index 9a43c661ce..83001be810 100755 --- a/pandora_console/godmode/massive/massive_edit_agents.php +++ b/pandora_console/godmode/massive/massive_edit_agents.php @@ -59,8 +59,10 @@ if ($update_agents) { $values['id_grupo'] = get_parameter('group'); } - if (get_parameter('interval', 0) != 0) { - $values['intervalo'] = get_parameter('interval'); + if (!(get_parameter('interval_select') == -1 && empty(get_parameter('interval_text')))) { + if (get_parameter('interval', 0) != 0) { + $values['intervalo'] = get_parameter('interval'); + } } if (get_parameter('id_os', '') != -1) { @@ -199,7 +201,7 @@ if ($update_agents) { } // Update the configuration files. - if ($result && ($old_interval_value != $values['intervalo'])) { + if ($result && ($old_interval_value != $values['intervalo']) && !empty($values['intervalo'])) { enterprise_hook( 'config_agents_update_config_token', [ @@ -523,7 +525,7 @@ $table->data[1][1] = html_print_select_groups(false, 'AR', false, 'group', $grou $table->data[2][0] = __('Interval'); -$table->data[2][1] = html_print_extended_select_for_time('interval', 0, '', __('No change'), '0', 10, true, 'width: 150px'); +$table->data[2][1] = html_print_extended_select_for_time('interval', 0, '', __('No change'), '0', 10, true, 'width: 150px', false); $table->data[3][0] = __('OS'); $table->data[3][1] = html_print_select_from_sql( diff --git a/pandora_console/godmode/menu.php b/pandora_console/godmode/menu.php index e57ee47409..7175081912 100644 --- a/pandora_console/godmode/menu.php +++ b/pandora_console/godmode/menu.php @@ -21,27 +21,42 @@ require_once 'include/functions_menu.php'; $menu_godmode = []; $menu_godmode['class'] = 'godmode'; - -if (check_acl($config['id_user'], 0, 'PM')) { +if (check_acl($config['id_user'], 0, 'AR') + || check_acl($config['id_user'], 0, 'AW') + || check_acl($config['id_user'], 0, 'RR') + || check_acl($config['id_user'], 0, 'RW') + || check_acl($config['id_user'], 0, 'PM') +) { $sub = []; $sub['godmode/servers/discovery&wiz=main']['text'] = __('Main'); $sub['godmode/servers/discovery&wiz=main']['id'] = 'Discovery'; - $sub['godmode/servers/discovery&wiz=tasklist']['text'] = __('Task list'); $sub['godmode/servers/discovery&wiz=tasklist']['id'] = 'tasklist'; - $sub2 = []; - $sub2['godmode/servers/discovery&wiz=hd&mode=netscan']['text'] = __('Network scan'); - enterprise_hook('hostdevices_submenu'); - $sub2['godmode/servers/discovery&wiz=hd&mode=customnetscan']['text'] = __('Custom network scan'); - $sub2['godmode/servers/discovery&wiz=hd&mode=managenetscanscripts']['text'] = __('Manage scan scripts'); - $sub['godmode/servers/discovery&wiz=hd']['text'] = __('Host & devices'); - $sub['godmode/servers/discovery&wiz=hd']['id'] = 'hd'; - $sub['godmode/servers/discovery&wiz=hd']['sub2'] = $sub2; + if (check_acl($config['id_user'], 0, 'AW') + || check_acl($config['id_user'], 0, 'PM') + ) { + if (check_acl($config['id_user'], 0, 'AW')) { + $sub2 = []; + $sub2['godmode/servers/discovery&wiz=hd&mode=netscan']['text'] = __('Network scan'); + enterprise_hook('hostdevices_submenu'); + $sub2['godmode/servers/discovery&wiz=hd&mode=customnetscan']['text'] = __('Custom network scan'); + } - enterprise_hook('applications_menu'); - enterprise_hook('cloud_menu'); - enterprise_hook('console_task_menu'); + if (check_acl($config['id_user'], 0, 'PM')) { + $sub2['godmode/servers/discovery&wiz=hd&mode=managenetscanscripts']['text'] = __('Manage scan scripts'); + } + + $sub['godmode/servers/discovery&wiz=hd']['text'] = __('Host & devices'); + $sub['godmode/servers/discovery&wiz=hd']['id'] = 'hd'; + $sub['godmode/servers/discovery&wiz=hd']['sub2'] = $sub2; + } + + if (check_acl($config['id_user'], 0, 'AW')) { + enterprise_hook('applications_menu'); + enterprise_hook('cloud_menu'); + enterprise_hook('console_task_menu'); + } // Add to menu. $menu_godmode['discovery']['text'] = __('Discovery'); @@ -92,7 +107,7 @@ if (!empty($sub)) { } $sub = []; -if (check_acl($config['id_user'], 0, 'AW')) { +if (check_acl($config['id_user'], 0, 'PM')) { $sub['godmode/groups/group_list']['text'] = __('Manage agents groups'); $sub['godmode/groups/group_list']['id'] = 'Manage agents groups'; } @@ -384,9 +399,6 @@ if (is_array($config['extensions'])) { if (strlen($extmenu['fatherId']) > 0) { if (array_key_exists('subfatherId', $extmenu)) { if (strlen($extmenu['subfatherId']) > 0) { - if ($extmenu['name'] = 'DB schema check') { - } - $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['text'] = __($extmenu['name']); $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['id'] = $extmenu['name']; $menu_godmode[$extmenu['fatherId']]['sub'][$extmenu['subfatherId']]['sub2'][$extmenu['sec2']]['refr'] = 0; diff --git a/pandora_console/godmode/servers/discovery.php b/pandora_console/godmode/servers/discovery.php index 3f2166bb39..2d0fcec8a1 100755 --- a/pandora_console/godmode/servers/discovery.php +++ b/pandora_console/godmode/servers/discovery.php @@ -4,7 +4,14 @@ global $config; check_login(); -if (! check_acl($config['id_user'], 0, 'AW')) { +if (! check_acl($config['id_user'], 0, 'AR') + && ! check_acl($config['id_user'], 0, 'AW') + && ! check_acl($config['id_user'], 0, 'AM') + && ! check_acl($config['id_user'], 0, 'RR') + && ! check_acl($config['id_user'], 0, 'RW') + && ! check_acl($config['id_user'], 0, 'RM') + && ! check_acl($config['id_user'], 0, 'PM') +) { db_pandora_audit( 'ACL Violation', 'Trying to access Server Management' @@ -134,11 +141,18 @@ if ($classname_selected === null) { $classname = basename($classpath, '.class.php'); $obj = new $classname(); + $button = $obj->load(); + + if ($button === false) { + // No acess, skip. + continue; + } + // DiscoveryTaskList must be first button. if ($classname == 'DiscoveryTaskList') { - array_unshift($wiz_data, $obj->load()); + array_unshift($wiz_data, $button); } else { - $wiz_data[] = $obj->load(); + $wiz_data[] = $button; } } diff --git a/pandora_console/godmode/servers/plugin.php b/pandora_console/godmode/servers/plugin.php index 3eb385332c..79fcfc61a2 100644 --- a/pandora_console/godmode/servers/plugin.php +++ b/pandora_console/godmode/servers/plugin.php @@ -928,10 +928,10 @@ if (($create != '') || ($view != '')) { $other['plugin_type'] = $plugin_meta['plugin_type']; $other['macros'] = urlencode($plugin_meta['macros']); $other['parameters'] = urlencode($plugin_meta['parameters']); - $other = implode('%7C', $other); + $other = implode('%7E', $other); $auth_token = json_decode($value['auth_token']); - $url = $value['server_url'].'include/api.php?op=set&op2=push_plugin'.'&id='.$pluginid.'&other_mode=url_encode_separator_%7C&other='.$other."&apipass=$auth_token->api_password"."&user=$auth_token->console_user&pass=$auth_token->console_password"; + $url = $value['server_url'].'include/api.php?op=set&op2=push_plugin'.'&id='.$pluginid.'&other_mode=url_encode_separator_%7E&other='.$other."&apipass=$auth_token->api_password"."&user=$auth_token->console_user&pass=$auth_token->console_password"; $file_path = realpath($plugin_meta['execute']); $post = ''; if (file_exists($file_path)) { diff --git a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php index ed7e1f3b10..ed523d0b82 100644 --- a/pandora_console/godmode/wizards/DiscoveryTaskList.class.php +++ b/pandora_console/godmode/wizards/DiscoveryTaskList.class.php @@ -200,7 +200,7 @@ class DiscoveryTaskList extends Wizard { global $config; - if (! check_acl($config['id_user'], 0, 'PM')) { + if (! check_acl($config['id_user'], 0, 'AW')) { db_pandora_audit( 'ACL Violation', 'Trying to access recon task viewer' @@ -241,7 +241,7 @@ class DiscoveryTaskList extends Wizard { global $config; - if (! check_acl($config['id_user'], 0, 'PM')) { + if (!$this->aclMulticheck('RR|RW|RM|PM')) { db_pandora_audit( 'ACL Violation', 'Trying to access recon task viewer' @@ -270,7 +270,7 @@ class DiscoveryTaskList extends Wizard { global $config; - if (! check_acl($config['id_user'], 0, 'PM')) { + if (! check_acl($config['id_user'], 0, 'RM')) { db_pandora_audit( 'ACL Violation', 'Trying to access recon task viewer' @@ -313,13 +313,9 @@ class DiscoveryTaskList extends Wizard check_login(); - if (! check_acl($config['id_user'], 0, 'PM')) { - db_pandora_audit( - 'ACL Violation', - 'Trying to access recon task viewer' - ); - include 'general/noaccess.php'; - return false; + if (!$this->aclMulticheck('AR|AW|AM')) { + // Tasklist are allowed only of agent managers. + return ''; } // Get all discovery servers. @@ -341,7 +337,7 @@ class DiscoveryTaskList extends Wizard // -------------------------------- // FORCE A RECON TASK // -------------------------------- - if (check_acl($config['id_user'], 0, 'PM')) { + if (check_acl($config['id_user'], 0, 'AW')) { if (isset($_GET['force'])) { $id = (int) get_parameter_get('force', 0); servers_force_recon_task($id); @@ -387,8 +383,10 @@ class DiscoveryTaskList extends Wizard // Operations. $table->headstyle[9] .= 'min-width: 150px; width: 150px;'; - $table->head[0] = __('Force'); - $table->align[0] = 'left'; + if (check_acl($config['id_user'], 0, 'AW')) { + $table->head[0] = __('Force'); + $table->align[0] = 'left'; + } $table->head[1] = __('Task name'); $table->align[1] = 'left'; @@ -455,11 +453,13 @@ class DiscoveryTaskList extends Wizard } if ($task['disabled'] == 0 && $server_name !== '') { - $data[0] = ''; - $data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]); - $data[0] .= ''; + if (check_acl($config['id_user'], 0, 'AW')) { + $data[0] = ''; + $data[0] .= html_print_image('images/target.png', true, ['title' => __('Force')]); + $data[0] .= ''; + } } else if ($task['disabled'] == 2) { $data[0] = ui_print_help_tip( __('This task has not been completely defined, please edit it'), @@ -622,18 +622,20 @@ class DiscoveryTaskList extends Wizard && $task['type'] != DISCOVERY_APP_ORACLE && $task['type'] != DISCOVERY_CLOUD_AWS_RDS ) { - $data[9] .= ''; - $data[9] .= html_print_image( - 'images/dynamic_network_icon.png', - true - ); - $data[9] .= ''; + if (check_acl($config['id_user'], 0, 'MR')) { + $data[9] .= ''; + $data[9] .= html_print_image( + 'images/dynamic_network_icon.png', + true + ); + $data[9] .= ''; + } } if (check_acl( $config['id_user'], $task['id_group'], - 'PM' + 'AW' ) ) { if ($ipam === true) { @@ -733,6 +735,16 @@ class DiscoveryTaskList extends Wizard { if ($script !== false) { switch ($script['type']) { + case DISCOVERY_SCRIPT_APP_VMWARE: + return 'wiz=app&mode=vmware&page=0'; + + case DISCOVERY_SCRIPT_IPAM_RECON: + return ''; + + case DISCOVERY_SCRIPT_IPMI_RECON: + default: + return 'wiz=hd&mode=customnetscan'; + case DISCOVERY_SCRIPT_CLOUD_AWS: switch ($task['type']) { case DISCOVERY_CLOUD_AWS_EC2: @@ -744,16 +756,6 @@ class DiscoveryTaskList extends Wizard default: return 'wiz=cloud'; } - - case DISCOVERY_SCRIPT_APP_VMWARE: - return 'wiz=app&mode=vmware&page=0'; - - case DISCOVERY_SCRIPT_IPAM_RECON: - return ''; - - case DISCOVERY_SCRIPT_IPMI_RECON: - default: - return 'wiz=hd&mode=customnetscan'; } } diff --git a/pandora_console/godmode/wizards/HostDevices.class.php b/pandora_console/godmode/wizards/HostDevices.class.php index fb9fba2cdd..fd7811f2e9 100755 --- a/pandora_console/godmode/wizards/HostDevices.class.php +++ b/pandora_console/godmode/wizards/HostDevices.class.php @@ -87,6 +87,7 @@ class HostDevices extends Wizard ) { $this->setBreadcrum([]); + $this->access = 'AW'; $this->task = []; $this->msg = $msg; $this->icon = $icon; @@ -100,6 +101,32 @@ class HostDevices extends Wizard } + /** + * Checks if environment is ready, + * returns array + * icon: icon to be displayed + * label: label to be displayed + * + * @return array With data. + **/ + public function load() + { + global $config; + // Check access. + check_login(); + + if (! $this->aclMulticheck('AW|PM')) { + return false; + } + + return [ + 'icon' => $this->icon, + 'label' => $this->label, + 'url' => $this->url, + ]; + } + + /** * Run wizard manager. * @@ -116,37 +143,42 @@ class HostDevices extends Wizard if ($mode === null) { $buttons = []; - $buttons[] = [ - 'url' => $this->url.'&mode=netscan', - 'icon' => 'images/wizard/netscan.png', - 'label' => __('Net Scan'), - ]; - if (enterprise_installed()) { + if (check_acl($config['id_user'], 0, $this->access)) { $buttons[] = [ - 'url' => $this->url.'&mode=importcsv', - 'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png', - 'label' => __('Import CSV'), + 'url' => $this->url.'&mode=netscan', + 'icon' => 'images/wizard/netscan.png', + 'label' => __('Net Scan'), ]; + if (enterprise_installed()) { + $buttons[] = [ + 'url' => $this->url.'&mode=importcsv', + 'icon' => ENTERPRISE_DIR.'/images/wizard/csv.png', + 'label' => __('Import CSV'), + ]; + + $buttons[] = [ + 'url' => $this->url.'&mode=deploy', + 'icon' => ENTERPRISE_DIR.'/images/wizard/deployment.png', + 'label' => __('Agent deployment'), + ]; + } + $buttons[] = [ - 'url' => $this->url.'&mode=deploy', - 'icon' => ENTERPRISE_DIR.'/images/wizard/deployment.png', - 'label' => __('Agent deployment'), + 'url' => $this->url.'&mode=customnetscan', + 'icon' => '/images/wizard/customnetscan.png', + 'label' => __('Custom NetScan'), ]; } - $buttons[] = [ - 'url' => $this->url.'&mode=customnetscan', - 'icon' => '/images/wizard/customnetscan.png', - 'label' => __('Custom NetScan'), - ]; - - $buttons[] = [ - 'url' => $this->url.'&mode=managenetscanscripts', - 'icon' => '/images/wizard/managenetscanscripts.png', - 'label' => __('Manage NetScan scripts'), - ]; + if (check_acl($config['id_user'], 0, 'PM')) { + $buttons[] = [ + 'url' => $this->url.'&mode=managenetscanscripts', + 'icon' => '/images/wizard/managenetscanscripts.png', + 'label' => __('Manage NetScan scripts'), + ]; + } $this->prepareBreadcrum( [ @@ -311,11 +343,11 @@ class HostDevices extends Wizard ) { // Default values, no data received. // User is accesing directly to this page. - if (users_is_admin() !== true && check_acl( + if (check_acl( $config['id_usuario'], $this->task['id_group'], - 'PM' - ) !== true + $this->access + ) != true ) { $this->msg = __('You have no access to edit this task.'); return false; @@ -487,7 +519,7 @@ class HostDevices extends Wizard check_login(); - if (! check_acl($config['id_user'], 0, 'PM')) { + if (! check_acl($config['id_user'], 0, $this->access)) { db_pandora_audit( 'ACL Violation', 'Trying to access Agent Management' @@ -529,11 +561,11 @@ class HostDevices extends Wizard // Check ACL. If user is not able to manage target task, // redirect him to main page. - if (users_is_admin() !== true && check_acl( + if (check_acl( $config['id_usuario'], $this->task['id_group'], - 'PM' - ) !== true + $this->access + ) != true ) { $form['form']['action'] = $this->url.'&mode=netscan&page='.($this->page - 1); } @@ -750,7 +782,7 @@ class HostDevices extends Wizard [ 'name' => 'id_group', 'returnAllGroup' => false, - 'privilege' => 'PM', + 'privilege' => $this->access, 'type' => 'select_groups', 'selected' => $this->task['id_group'], 'return' => true, diff --git a/pandora_console/godmode/wizards/Wizard.main.php b/pandora_console/godmode/wizards/Wizard.main.php index 3a65560285..cb29d78c06 100644 --- a/pandora_console/godmode/wizards/Wizard.main.php +++ b/pandora_console/godmode/wizards/Wizard.main.php @@ -87,6 +87,13 @@ class Wizard */ public $msg; + /** + * Defines access level to use this util. + * + * @var string + */ + public $access = 'AR'; + /** * Setter for breadcrum @@ -234,6 +241,42 @@ class Wizard public function run() { ui_require_css_file('wizard'); + // Check access. + check_login(); + + if (! $this->aclMulticheck()) { + return; + } + } + + + /** + * Check multiple acl perms. + * + * @param string $access Access in PM|AR|RR format. Optional. + * + * @return boolean Alowed or not. + */ + public function aclMulticheck($access=null) + { + global $config; + + if (isset($access)) { + $perms = explode('|', $access); + } else { + $perms = explode('|', $this->access); + } + + $allowed = false; + foreach ($perms as $perm) { + $allowed = $allowed || (bool) check_acl( + $config['id_user'], + 0, + $perm + ); + } + + return $allowed; } @@ -247,6 +290,14 @@ class Wizard **/ public function load() { + global $config; + // Check access. + check_login(); + + if (! $this->aclMulticheck()) { + return false; + } + return [ 'icon' => $this->icon, 'label' => $this->label, diff --git a/pandora_console/include/class/CustomNetScan.class.php b/pandora_console/include/class/CustomNetScan.class.php index dff9d227e1..77cf514158 100644 --- a/pandora_console/include/class/CustomNetScan.class.php +++ b/pandora_console/include/class/CustomNetScan.class.php @@ -65,6 +65,8 @@ class CustomNetScan extends Wizard $this->url = ui_get_full_url( 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd' ); + + $this->access = 'AW'; $this->page = $page; $this->breadcrum = $breadcrum; } @@ -77,6 +79,8 @@ class CustomNetScan extends Wizard */ public function parseNetScan() { + global $config; + if (isset($this->page) === true && $this->page === 0) { // Check if we're updating a task. $task_id = get_parameter('task', null); @@ -145,11 +149,11 @@ class CustomNetScan extends Wizard ) { // Default values, no data received. // User is accesing directly to this page. - if (users_is_admin() !== true && check_acl( - $config['id_usuario'], + if (check_acl( + $config['id_user'], $this->task['id_group'], - 'PM' - ) !== true + $this->access + ) != true ) { $this->msg = __('You have no access to edit this task.'); return false; @@ -275,7 +279,7 @@ class CustomNetScan extends Wizard { global $config; - if (!check_acl($config['id_user'], 0, 'PM')) { + if (!check_acl($config['id_user'], 0, $this->access)) { db_pandora_audit( 'ACL Violation', 'Trying to access Custom Net Scan.' @@ -317,11 +321,11 @@ class CustomNetScan extends Wizard // Check ACL. If user is not able to manage target task, // redirect him to main page. - if (users_is_admin() !== true && check_acl( - $config['id_usuario'], + if (check_acl( + $config['id_user'], $this->task['id_group'], - 'PM' - ) !== true + $this->access + ) != true ) { $form['form']['action'] = $this->url.'&mode=customnetscan&page='.($this->page - 1); } @@ -496,7 +500,7 @@ class CustomNetScan extends Wizard 'arguments' => [ 'name' => 'id_group', 'returnAllGroup' => false, - 'privilege' => 'PM', + 'privilege' => $this->access, 'type' => 'select_groups', 'selected' => $this->task['id_group'], 'return' => true, diff --git a/pandora_console/include/class/ManageNetScanScripts.class.php b/pandora_console/include/class/ManageNetScanScripts.class.php index efc94cc8b6..c4a61bae37 100644 --- a/pandora_console/include/class/ManageNetScanScripts.class.php +++ b/pandora_console/include/class/ManageNetScanScripts.class.php @@ -65,6 +65,8 @@ class ManageNetScanScripts extends Wizard $this->url = ui_get_full_url( 'index.php?sec=gservers&sec2=godmode/servers/discovery&wiz=hd' ); + + $this->access = 'PM'; $this->page = $page; $this->breadcrum = $breadcrum; } @@ -81,7 +83,7 @@ class ManageNetScanScripts extends Wizard { global $config; - if (check_acl($config['id_user'], 0, 'AW') === 0) { + if (check_acl($config['id_user'], 0, $this->access) === 0) { db_pandora_audit( 'ACL Violation', 'Trying to access Net Scan Script.' diff --git a/pandora_console/include/config_process.php b/pandora_console/include/config_process.php index 4f3ff4ba1b..8331ff97e6 100644 --- a/pandora_console/include/config_process.php +++ b/pandora_console/include/config_process.php @@ -20,7 +20,7 @@ /** * Pandora build version and version */ -$build_version = 'PC191008'; +$build_version = 'PC191017'; $pandora_version = 'v7.0NG.739'; // Do not overwrite default timezone set if defined. diff --git a/pandora_console/include/functions_api.php b/pandora_console/include/functions_api.php index 899add9ec0..7aa5278a7e 100644 --- a/pandora_console/include/functions_api.php +++ b/pandora_console/include/functions_api.php @@ -1492,7 +1492,7 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) global $config; if (!check_acl($config['id_user'], 0, 'AW')) { - returnError('forbidden', 'string'); + returnError('forbidden', 'you havent got permissions to do this'); return; } @@ -1500,127 +1500,101 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) return; } - $alias = $other['data'][0]; - $ip = $other['data'][1]; - $idParent = $other['data'][2]; - $idGroup = $other['data'][3]; - $cascadeProtection = $other['data'][4]; - $cascadeProtectionModule = $other['data'][5]; - $intervalSeconds = $other['data'][6]; - $idOS = $other['data'][7]; - // $idServer = $other['data'][7]; - $nameServer = $other['data'][8]; - $customId = $other['data'][9]; - $learningMode = $other['data'][10]; - $disabled = $other['data'][11]; - $description = $other['data'][12]; - $alias_as_name = $other['data'][13]; + $alias = io_safe_input(trim(preg_replace('/[\/\\\|%#&$]/', '', $other['data'][0]))); + $direccion_agente = io_safe_input($other['data'][1]); + $nombre_agente = hash('sha256', $direccion_agente.'|'.$direccion_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000))); + $id_parent = (int) $other['data'][2]; + $grupo = (int) $other['data'][3]; + $cascade_protection = (int) $other['data'][4]; + $cascade_protection_module = (int) $other['data'][5]; + $intervalo = (string) $other['data'][6]; + $id_os = (int) $other['data'][7]; + $server_name = (string) $other['data'][8]; + $custom_id = (string) $other['data'][9]; + $modo = (int) $other['data'][10]; + $disabled = (int) $other['data'][11]; + $comentarios = (string) $other['data'][12]; + $alias_as_name = (int) $other['data'][13]; + $update_module_count = (int) $config['metaconsole_agent_cache'] == 1; - if ($alias_as_name && !empty($alias)) { - $name = $alias; - } else { - $name = hash('sha256', $alias.'|'.$direccion_agente.'|'.time().'|'.sprintf('%04d', rand(0, 10000))); - if (empty($alias)) { - $alias = $name; - } - } - - if ($cascadeProtection == 1) { - if (($idParent != 0) && (db_get_value_sql( + if ($cascade_protection == 1) { + if (($id_parent != 0) && (db_get_value_sql( 'SELECT id_agente_modulo - FROM tagente_modulo - WHERE id_agente = '.$idParent.' AND id_agente_modulo = '.$cascadeProtectionModule + FROM tagente_modulo + WHERE id_agente = '.$id_parent.' AND id_agente_modulo = '.$cascade_protection_module ) === false) ) { returnError('parent_agent_not_exist', 'Is not a parent module to do cascade protection.'); + return; } } else { $cascadeProtectionModule = 0; } - switch ($config['dbtype']) { - case 'mysql': - $sql1 = 'SELECT name - FROM tserver WHERE BINARY name LIKE "'.$nameServer.'"'; - break; + $server_name = db_get_value_sql('SELECT name FROM tserver WHERE BINARY name LIKE "'.$server_name.'"'); - case 'postgresql': - case 'oracle': - $sql1 = 'SELECT name - FROM tserver WHERE name LIKE \''.$nameServer.'\''; - break; - } - - $nameServer = db_get_value_sql($sql1); - - // Check ACL group - if (!check_acl($config['id_user'], $idGroup, 'AW')) { - returnError('forbidden', 'string'); - return; - } - - // Check selected parent - if ($idParent != 0) { - $parentCheck = agents_check_access_agent($idParent); - if ($parentCheck === null) { - returnError('parent_agent_not_exist', __('The agent parent don`t exist.')); - return; - } - - if ($parentCheck === false) { - returnError('parent_agent_forbidden', __('The user cannot access to parent agent.')); - return; - } - } - - if (agents_get_agent_id($name)) { + // Check if agent exists (BUG WC-50518-2). + if ($alias == '' && $alias_as_name === 0) { + returnError('alias_not_specified', 'No agent alias specified'); + } else if (agents_get_agent_id($name)) { returnError('agent_name_exist', 'The name of agent yet exist in DB.'); - } else if (db_get_value_sql( - 'SELECT id_grupo - FROM tgrupo - WHERE id_grupo = '.$idGroup - ) === false - ) { + } else if (db_get_value_sql('SELECT id_grupo FROM tgrupo WHERE id_grupo = '.$grupo) === false) { returnError('id_grupo_not_exist', 'The group don`t exist.'); - } else if (db_get_value_sql( - 'SELECT id_os - FROM tconfig_os - WHERE id_os = '.$idOS - ) === false - ) { + } else if (db_get_value_sql('SELECT id_os FROM tconfig_os WHERE id_os = '.$id_os) === false) { returnError('id_os_not_exist', 'The OS don`t exist.'); - } else if (db_get_value_sql($sql1) === false) { + } else if ($server_name === false) { returnError('server_not_exist', 'The '.get_product_name().' Server don`t exist.'); } else { - $idAgente = db_process_sql_insert( - 'tagente', - [ - 'nombre' => $name, - 'alias' => $alias, - 'direccion' => $ip, - 'id_grupo' => $idGroup, - 'intervalo' => $intervalSeconds, - 'comentarios' => $description, - 'modo' => $learningMode, - 'id_os' => $idOS, - 'disabled' => $disabled, - 'cascade_protection' => $cascadeProtection, - 'cascade_protection_module' => $cascadeProtectionModule, - 'server_name' => $nameServer, - 'id_parent' => $idParent, - 'custom_id' => $customId, - ] - ); - - if (!empty($idAgente) && !empty($ip)) { - // register ip for this agent in 'taddress' - agents_add_address($idAgente, $ip); + if ($alias_as_name === 1) { + $exists_alias = db_get_row_sql('SELECT nombre FROM tagente WHERE nombre = "'.$alias.'"'); + $nombre_agente = $alias; } - if ($idGroup && !empty($idAgente)) { + if ($direccion_agente != '') { + $exists_ip = db_get_row_sql('SELECT direccion FROM tagente WHERE direccion = "'.$direccion_agente.'"'); + } + + if (!$exists_alias && !$exists_ip) { + $id_agente = db_process_sql_insert( + 'tagente', + [ + 'nombre' => $nombre_agente, + 'alias' => $alias, + 'alias_as_name' => $alias_as_name, + 'direccion' => $direccion_agente, + 'id_grupo' => $grupo, + 'intervalo' => $intervalo, + 'comentarios' => $comentarios, + 'modo' => $modo, + 'id_os' => $id_os, + 'disabled' => $disabled, + 'cascade_protection' => $cascade_protection, + 'cascade_protection_module' => $cascade_protection_module, + 'server_name' => $server_name, + 'id_parent' => $id_parent, + 'custom_id' => $custom_id, + 'os_version' => '', + 'agent_version' => '', + 'timezone_offset' => 0, + 'icon_path' => '', + 'url_address' => '', + 'update_module_count' => $update_module_count, + ] + ); + enterprise_hook('update_agent', [$id_agente]); + } else { + $id_agente = false; + } + + if ($id_agente !== false) { + // Create address for this agent in taddress. + if ($direccion_agente != '') { + agents_add_address($id_agente, $direccion_agente); + } + $tpolicy_group_old = db_get_all_rows_sql( 'SELECT id_policy FROM tpolicy_groups - WHERE id_group = '.$idGroup + WHERE id_group = '.$grupo ); if ($tpolicy_group_old) { @@ -1629,18 +1603,54 @@ function api_set_new_agent($thrash1, $thrash2, $other, $thrash3) 'tpolicy_agents', [ 'id_policy' => $old_group['id_policy'], - 'id_agent' => $idAgente, + 'id_agent' => $id_agente, ] ); } } + + $info = '{"Name":"'.$nombre_agente.'", + "IP":"'.$direccion_agente.'", + "Group":"'.$grupo.'", + "Interval":"'.$intervalo.'", + "Comments":"'.$comentarios.'", + "Mode":"'.$modo.'", + "ID_parent:":"'.$id_parent.'", + "Server":"'.$server_name.'", + "ID os":"'.$id_os.'", + "Disabled":"'.$disabled.'", + "Custom ID":"'.$custom_id.'", + "Cascade protection":"'.$cascade_protection.'", + "Cascade protection module":"'.$cascade_protection_module.'"}'; + + $unsafe_alias = io_safe_output($alias); + db_pandora_audit( + 'Agent management', + 'Created agent '.$unsafe_alias, + false, + true, + $info + ); + } else { + $id_agente = 0; + + if ($exists_alias) { + $agent_creation_error = __('Could not be created, because name already exists'); + } else if ($exists_ip) { + $agent_creation_error = __('Could not be created, because IP already exists'); + } else { + $agent_creation_error = __('Could not be created for unknown reason'); + } + + returnError('generic error', $agent_creation_error); + return; } returnData( 'string', [ 'type' => 'string', - 'data' => $idAgente, + 'data' => $id_agente, ] ); } diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index ccbe7f6dd2..9563732c68 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -4615,7 +4615,7 @@ function events_page_comments($event, $ajax=false) foreach ($comm as $c) { $data[0] = ''.$c['action'].' by '.$c['id_user'].''; $data[0] .= ''.$c['comment'].'
'; $table_comments->data[] = $data; } } diff --git a/pandora_console/include/functions_networkmap.php b/pandora_console/include/functions_networkmap.php index e4fb19e814..dda25538ee 100644 --- a/pandora_console/include/functions_networkmap.php +++ b/pandora_console/include/functions_networkmap.php @@ -2327,7 +2327,13 @@ function migrate_older_open_maps($id) $new_map_filter = []; $new_map_filter['dont_show_subgroups'] = $old_networkmap['dont_show_subgroups']; $new_map_filter['node_radius'] = 40; - $new_map_filter['id_migrate_map'] = $id; + $new_map_filter['x_offs'] = 0; + $new_map_filter['y_offs'] = 0; + $new_map_filter['z_dash'] = '0.5'; + $new_map_filter['node_sep'] = '0.1'; + $new_map_filter['rank_sep'] = 1; + $new_map_filter['mindist'] = 1; + $new_map_filter['kval'] = '0.1'; $map_values['filter'] = json_encode($new_map_filter); $map_values['description'] = 'Mapa open migrado'; @@ -2340,11 +2346,7 @@ function migrate_older_open_maps($id) $map_values['source_period'] = 60; $map_values['source'] = 0; $map_values['source_data'] = $old_networkmap['id_group']; - if ($old_networkmap['type'] == 'radial_dinamic') { - $map_values['generation_method'] = 6; - } else { - $map_values['generation_method'] = 4; - } + $map_values['generation_method'] = 3; $map_values['generated'] = 0; diff --git a/pandora_console/include/functions_planned_downtimes.php b/pandora_console/include/functions_planned_downtimes.php index 7f1a587b65..a9b701241b 100644 --- a/pandora_console/include/functions_planned_downtimes.php +++ b/pandora_console/include/functions_planned_downtimes.php @@ -748,7 +748,9 @@ function planned_downtimes_created($values) 'return' => false, 'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the current time'), ]; - } else if ($values['type_execution'] == 'once' && $values['date_from'] >= $values['date_to']) { + } else if ($values['type_execution'] == 'once' && ($values['date_from'] > $values['date_to']) + || (($values['date_from'] == $values['date_to']) && ($values['periodically_time_from'] >= $values['periodically_time_to'])) + ) { return [ 'return' => false, 'message' => __('Not created. Error inserting data').'. '.__('The end date must be higher than the start date'), @@ -794,6 +796,11 @@ function planned_downtimes_created($values) 'return' => false, 'message' => __('Not created. Error inserting data').'. '.__('There is no group with such id'), ]; + } else if (!$values['date_from'] || !$values['date_to']) { + return [ + 'return' => false, + 'message' => __('Not created. Error inserting data').'. '.__('Date is wrong formatted'), + ]; } else { if (trim(io_safe_output($values['name'])) != '') { if (!$check) { diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 0cf447eede..a54bce17de 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -4193,6 +4193,7 @@ function reporting_sql_graph( switch ($type) { case 'dinamic': case 'static': + case 'data': $return['chart'] = graph_custom_sql_graph( $content['id_rc'], $width, @@ -4204,9 +4205,6 @@ function reporting_sql_graph( $content['top_n_value'] ); break; - - case 'data': - break; } return reporting_check_structure_content($return); @@ -4406,6 +4404,7 @@ function reporting_netflow( switch ($type) { case 'dinamic': case 'static': + case 'data': $return['chart'] = netflow_draw_item( ($report['datetime'] - $content['period']), $report['datetime'], @@ -4879,22 +4878,23 @@ function reporting_value($report, $content, $type, $pdf=false) if ($content['visual_format'] != 2) { $time_begin = db_get_row_sql('select utimestamp from tagente_datos where id_agente_modulo ='.$content['id_agent_module'], true); - for ($i = $report['datetime']; $i > ($report['datetime'] - $content['period']); $i -= $content['lapse']) { + + for ($i = ($report['datetime'] - $content['period']); $i < $report['datetime']; $i += $content['lapse']) { $row = []; - $row[__('Lapse')] = date('Y-m-d H:i:s', ($i - $content['lapse'] + 1)).' to '.date('Y-m-d H:i:s', $i); + $row[__('Lapse')] = date('Y-m-d H:i:s', ($i + 1)).' to '.date('Y-m-d H:i:s', (($i + $content['lapse']) )); if ($i > $time_begin['utimestamp']) { switch ($type) { case 'max': - $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit; + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_max($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision']).' '.$unit; break; case 'min': - $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit; + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_min($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision']).' '.$unit; break; case 'avg': - $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], $i), $config['graph_precision']).' '.$unit; + $row[__('Maximun')] = format_for_graph(reporting_get_agentmodule_data_average($content['id_agent_module'], $content['lapse'], ($i + $content['lapse'])), $config['graph_precision']).' '.$unit; break; } } else { @@ -7560,8 +7560,26 @@ function reporting_custom_graph( $content['name'] = __('Simple graph'); } + $id_agent = agents_get_module_id( + $content['id_agent_module'] + ); + $id_agent_module = $content['id_agent_module']; + $agent_description = agents_get_description($id_agent); + $agent_group = agents_get_agent_group($id_agent); + $agent_address = agents_get_address($id_agent); + $agent_alias = agents_get_alias($id_agent); + $module_name = modules_get_agentmodule_name( + $id_agent_module + ); + + $module_description = modules_get_agentmodule_descripcion( + $id_agent_module + ); + $return['title'] = $content['name']; $return['subtitle'] = io_safe_output($graph['name']); + $return['agent_name'] = $agent_alias; + $return['module_name'] = $module_name; $return['description'] = $content['description']; $return['date'] = reporting_get_date_text( $report, @@ -7575,6 +7593,7 @@ function reporting_custom_graph( switch ($type) { case 'dinamic': case 'static': + case 'data': $params = [ 'period' => $content['period'], 'width' => $width, diff --git a/pandora_console/include/functions_reports.php b/pandora_console/include/functions_reports.php index de52d3322b..e63348850b 100755 --- a/pandora_console/include/functions_reports.php +++ b/pandora_console/include/functions_reports.php @@ -778,13 +778,15 @@ function reports_get_report_types($template=false, $not_editor=false) 'name' => __('Exception'), ]; if ($config['metaconsole'] != 1) { - $types['agent_module'] = [ - 'optgroup' => __('Grouped'), - 'name' => __('Agents/Modules'), - ]; + if (!$template) { + $types['agent_module'] = [ + 'optgroup' => __('Grouped'), + 'name' => __('Agents/Modules'), + ]; + } } - // Only pandora managers have access to the whole database + // Only pandora managers have access to the whole database. if (check_acl($config['id_user'], 0, 'PM')) { $types['sql'] = [ 'optgroup' => __('Grouped'), diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index 6c0db1db8f..6da735618b 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -39,7 +39,7 @@ if (isset($config['homedir'])) { /** - * Transform bbcode to HTML. + * Transform bbcode to HTML and truncate log. * * @param string $text Text. * @param array $allowed_tags Allowed_tags. @@ -48,16 +48,22 @@ if (isset($config['homedir'])) { */ function ui_bbcode_to_html($text, $allowed_tags=['[url]']) { - if (array_search('[url]', $allowed_tags) !== false) { - // If link hasn't http, add it. - if (preg_match('/https?:\/\//', $text)) { - $html_bbcode = '$2'; - } else { - $html_bbcode = '$2'; - } - + if (array_search('[url]', $allowed_tags) !== false || a) { // Replace bbcode format [url=www.example.org] String [/url] with or without http and slashes - $return = preg_replace('/\[url(?|](((?:https?:\/\/)?[^[]+))|(?:=[\'"]?((?:https?:\/\/)?[^]]+?)[\'"]?)](.+?))\[\/url]/', $html_bbcode, $text); + preg_match('/\[url(?|](((?:https?:\/\/)?[^[]+))|(?:=[\'"]?((?:https?:\/\/)?[^]]+?)[\'"]?)](.+?))\[\/url]/', $text, $matches); + if ($matches) { + $url = $matches[1]; + // Truncate text + $t_text = ui_print_truncate_text($matches[2]); + // If link hasn't http, add it. + if (preg_match('/https?:\/\//', $text)) { + $return = ''.$t_text.''; + } else { + $return = ''.$t_text.''; + } + } else { + $return = ui_print_truncate_text($text); + } } return $return; @@ -3191,14 +3197,18 @@ function ui_print_datatable(array $parameters) $.fn.dataTable.ext.errMode = "none"; $.fn.dataTable.ext.classes.sPageButton = "'.$pagination_class.'"; dt_'.$table_id.' = $("#'.$table_id.'").DataTable({ - '; + drawCallback: function(settings) {'; if (isset($parameters['drawCallback'])) { - $js .= 'drawCallback: function(settings) { - '.$parameters['drawCallback'].' - },'; + $js .= $parameters['drawCallback']; } $js .= ' + if (dt_'.$table_id.'.page.info().pages > 1) { + $("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").show() + } else { + $("#'.$table_id.'_wrapper > .dataTables_paginate.paging_simple_numbers").hide() + } + }, processing: true, serverSide: true, paging: true, @@ -3303,6 +3313,7 @@ function ui_print_datatable(array $parameters) dt_'.$table_id.'.draw().page(0) }); }); + '; // Order. @@ -5650,3 +5661,63 @@ function ui_print_breadcrums($tab_name) return $section; } + + +/** + * Show last comment + * + * @param array $comments array with comments + * + * @return string HTML string with the last comment of the events. + */ +function ui_print_comments($comments) +{ + global $config; + + $comments = explode('