/** * Return the new page to set as current page * * {@inheritdoc} Runs additional checks related to some registered pages. * * @param string $requestedPage The name of the requested page * @param Form $originPage The origin page * * @return Form The new page * * @throws InvalidArgumentException In case the requested page does not exist or is not permitted yet */ protected function getNewPage($requestedPage, Form $originPage) { $skip = false; $newPage = parent::getNewPage($requestedPage, $originPage); if ($newPage->getName() === 'setup_monitoring_ido') { $backendData = $this->getPageData('setup_monitoring_backend'); $skip = $backendData['type'] !== 'ido'; } elseif ($newPage->getName() === 'setup_monitoring_livestatus') { $backendData = $this->getPageData('setup_monitoring_backend'); $skip = $backendData['type'] !== 'livestatus'; } return $skip ? $this->skipPage($newPage) : $newPage; }
/** * Return the new page to set as current page * * Permission is checked by verifying that the requested page or its previous page has page data available. * The requested page is automatically permitted without any checks if the origin page is its previous * page or one that occurs later in order. * * @param string $requestedPage The name of the requested page * @param Form $originPage The origin page * * @return Form The new page * * @throws InvalidArgumentException In case the requested page does not exist or is not permitted yet */ protected function getNewPage($requestedPage, Form $originPage) { if ($this->parent) { return $this->parent->getNewPage($requestedPage, $originPage); } if (($page = $this->getPage($requestedPage)) !== null) { $permitted = true; $pages = $this->getPages(); if (!$this->hasPageData($requestedPage) && ($index = array_search($page, $pages, true)) > 0) { $previousPage = $pages[$index - 1]; if ($originPage === null || $previousPage->getName() !== $originPage->getName() && array_search($originPage, $pages, true) < $index) { $permitted = $this->hasPageData($previousPage->getName()); } } if ($permitted) { return $page; } } throw new InvalidArgumentException(sprintf('"%s" is either an unknown page or one you are not permitted to view', $requestedPage)); }
/** * Return the new page to set as current page * * {@inheritdoc} Runs additional checks related to some registered pages. * * @param string $requestedPage The name of the requested page * @param Form $originPage The origin page * * @return Form The new page * * @throws InvalidArgumentException In case the requested page does not exist or is not permitted yet */ protected function getNewPage($requestedPage, Form $originPage) { $skip = false; $newPage = parent::getNewPage($requestedPage, $originPage); if ($newPage->getName() === 'setup_auth_db_resource') { $authData = $this->getPageData('setup_authentication_type'); $skip = $authData['type'] !== 'db'; } elseif ($newPage->getname() === 'setup_ldap_discovery') { $authData = $this->getPageData('setup_authentication_type'); $skip = $authData['type'] !== 'ldap'; /*} elseif ($newPage->getName() === 'setup_ldap_discovery_confirm') { $skip = false === $this->hasPageData('setup_ldap_discovery');*/ } elseif ($newPage->getName() === 'setup_ldap_resource') { $authData = $this->getPageData('setup_authentication_type'); $skip = $authData['type'] !== 'ldap'; } elseif ($newPage->getName() === 'setup_config_db_resource') { $authData = $this->getPageData('setup_authentication_type'); $configData = $this->getPageData('setup_general_config'); $skip = $authData['type'] === 'db' || $configData['global_config_backend'] !== 'db'; } elseif (in_array($newPage->getName(), array('setup_auth_db_creation', 'setup_config_db_creation'))) { if (($newPage->getName() === 'setup_auth_db_creation' || $this->hasPageData('setup_config_db_resource')) && (($config = $this->getPageData('setup_auth_db_resource')) !== null || ($config = $this->getPageData('setup_config_db_resource')) !== null) && !$config['skip_validation']) { $db = new DbTool($config); try { $db->connectToDb(); // Are we able to login on the database? if (array_search(reset($this->databaseTables), $db->listTables()) === false) { // In case the database schema does not yet exist the // user needs the privileges to setup the database $skip = $db->checkPrivileges($this->databaseSetupPrivileges, $this->databaseTables); } else { // In case the database schema exists the user needs the required privileges // to operate the database, if those are missing we ask for another user $skip = $db->checkPrivileges($this->databaseUsagePrivileges, $this->databaseTables); } } catch (PDOException $_) { try { $db->connectToHost(); // Are we able to login on the server? // It is not possible to reliably determine whether a database exists or not if a user can't // log in to the database, so we just require the user to be able to create the database $skip = $db->checkPrivileges(array_unique(array_merge($this->databaseCreationPrivileges, $this->databaseSetupPrivileges)), $this->databaseTables); } catch (PDOException $_) { // We are NOT able to login on the server.. } } } else { $skip = true; } } return $skip ? $this->skipPage($newPage) : $newPage; }