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); } /** * 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(); } // Header. $this->height -= 40; $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='') { return; } /** * Generates HTML code to view target Visual console. * * @return void */ private function show_visualmap() { global $config; $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, ]; if ((bool) $config['mobile_view_orientation_vc'] === true) { $size = [ 'width' => $this->height, 'height' => $this->width, ]; } $ratio_t = $visualConsole->adjustToViewport($size, 'mobile'); $visualConsoleData = $visualConsole->toArray(); $uniq = uniqid(); $output = '