checkACL($this->acl)) { $this->validAcl = true; } else { $this->validAcl = false; } } /** * Retrieve filters. * * @return void */ private function getFilters() { $system = System::getInstance(); $this->id = (int) $system->getRequest('id', 0); $this->width = (int) $system->getRequest('width', 0); $this->height = (int) $system->getRequest('height', 0); if ($this->width < $this->height) { $w = $this->width; $this->width = $this->height; $this->height = $w; $this->rotate = true; } } /** * Renders the view. * * @return void */ public function show() { $this->getFilters(); if (empty($this->width) === true && empty($this->height) === true ) { // Reload forcing user to send width and height. $ui = Ui::getInstance(); $ui->retrieveViewPort(); } $this->height -= 39; $this->visualmap = db_get_row( 'tlayout', 'id', $this->id ); if (empty($this->visualmap)) { $this->show_fail_acl(); } $this->checkVisualmapACL($this->visualmap['id_group']); if (!$this->validAcl) { $this->show_fail_acl(); } $this->show_visualmap(); } /** * Shows an error if ACL fails. * * @param string $msg Optional message. * * @return void */ private function show_fail_acl(string $msg='') { $error['type'] = 'onStart'; if (empty($msg) === false) { $error['title_text'] = __('Error'); $error['content_text'] = $msg; } else { $error['title_text'] = __('You don\'t have access to this page'); $error['content_text'] = System::getDefaultACLFailText(); } if (class_exists('HomeEnterprise') === true) { $home = new HomeEnterprise(); } else { $home = new Home(); } $home->show($error); } /** * Ajax call manager. * * @param string $parameter2 Not sure why is doing this stuff. * * @return void */ public function ajax(string $parameter2='') { $system = System::getInstance(); $this->checkVisualmapACL($this->visualmap['id_group']); if ((bool) $this->validAcl === false) { $this->show_fail_acl(); } else { switch ($parameter2) { case 'render_map': $map_id = $system->getRequest('map_id', '0'); $width = $system->getRequest('width', '400'); $height = $system->getRequest('height', '400'); visual_map_print_visual_map( $map_id, false, true, $width, $height ); exit; default: exit; } } } /** * Generates HTML code to view target Visual console. * * @return void */ private function show_visualmap() { $ui = Ui::getInstance(); $system = System::getInstance(); include_once $system->getConfig('homedir').'/vendor/autoload.php'; // Query parameters. $visualConsoleId = (int) $system->getRequest('id'); // Refresh interval in seconds. $refr = (int) get_parameter('refr', $system->getConfig('vc_refr')); // Check groups can access user. $aclUserGroups = []; if (!users_can_manage_group_all('AR')) { $aclUserGroups = array_keys(users_get_groups(false, 'AR')); } // Load Visual Console. $visualConsole = null; try { $visualConsole = VisualConsole::fromDB(['id' => $visualConsoleId]); } catch (Throwable $e) { $this->show_fail_acl($e->getMessage()); exit; } $ui->createPage(); $ui->createDefaultHeader( sprintf( '%s', $this->visualmap['name'] ), $ui->createHeaderButton( [ 'icon' => 'ui-icon-back', 'pos' => 'left', 'text' => __('Back'), 'href' => 'index.php?page=visualmaps', 'class' => 'header-button-left', ] ) ); $ui->require_css('visual_maps'); $ui->require_css('register'); $ui->require_css('dashboards'); $ui->require_javascript('pandora_visual_console'); $ui->require_javascript('pandora_dashboards'); $ui->require_javascript('jquery.cookie'); $ui->require_css('modal'); $ui->require_css('form'); $ui->showFooter(false); $ui->beginContent(); $ui->contentAddHtml( include_javascript_d3(true) ); $size = [ 'width' => $this->width, 'height' => $this->height, ]; $visualConsoleData = $visualConsole->toArray(); $ratio_visualconsole = ($visualConsoleData['height'] / $visualConsoleData['width']); $ratio_t = ($size['width'] / $visualConsoleData['width']); $radio_h = ($size['height'] / $visualConsoleData['height']); $visualConsoleData['width'] = $size['width']; $visualConsoleData['height'] = ($size['width'] * $ratio_visualconsole); if ($visualConsoleData['height'] > $size['height']) { $ratio_t = $radio_h; $visualConsoleData['height'] = $size['height']; $visualConsoleData['width'] = ($size['height'] / $ratio_visualconsole); } $uniq = uniqid(); $output = '