protected function evaluate() { $moduleName = $this->getCondition(); if (Platform::extensionLoaded($moduleName)) { $this->setStateText(sprintf(mt('setup', 'The PHP module %s is available.'), $this->getAlias() ?: $moduleName)); return true; } else { $this->setStateText(sprintf(mt('setup', 'The PHP module %s is missing.'), $this->getAlias() ?: $moduleName)); return false; } }
/** * Return an array containing the tab definitions for all supported types * * Using array_keys on this array or isset allows to check whether a * requested type is supported * * @return array */ public function getSupportedTypes() { $supportedTypes = array(); if (Platform::extensionLoaded('gd')) { $supportedTypes[self::TYPE_PDF] = array('name' => 'pdf', 'label' => 'PDF', 'icon' => 'file-pdf', 'urlParams' => array('format' => 'pdf')); } $supportedTypes[self::TYPE_CSV] = array('name' => 'csv', 'label' => 'CSV', 'icon' => 'file-excel', 'urlParams' => array('format' => 'csv')); if (Platform::extensionLoaded('json')) { $supportedTypes[self::TYPE_JSON] = array('name' => 'json', 'label' => 'JSON', 'icon' => 'img/icons/json.png', 'urlParams' => array('format' => 'json')); } return $supportedTypes; }
/** * @see Form::createElements() */ public function createElements(array $formData) { if (isset($formData['type']) && $formData['type'] === 'external' && !isset($_SERVER['REMOTE_USER'])) { $this->info($this->translate('You\'re currently not authenticated using any of the web server\'s authentication ' . 'mechanisms. Make sure you\'ll configure such, otherwise you\'ll not be able to ' . 'log into Icinga Web 2.'), false); } $backendTypes = array(); if (Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { $backendTypes['db'] = $this->translate('Database'); } if (Platform::extensionLoaded('ldap')) { $backendTypes['ldap'] = 'LDAP'; } $backendTypes['external'] = $this->translate('External'); $this->addElement('select', 'type', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('Authentication Type'), 'description' => $this->translate('The type of authentication to use when accessing Icinga Web 2'), 'multiOptions' => $backendTypes)); }
/** * @see Form::createElements() */ public function createElements(array $formData) { $backendTypes = array(); $backendType = isset($formData['type']) ? $formData['type'] : null; if (isset($this->resources['db'])) { $backendTypes['db'] = $this->translate('Database'); } if (isset($this->resources['ldap']) && ($backendType === 'ldap' || Platform::extensionLoaded('ldap'))) { $backendTypes['ldap'] = 'LDAP'; $backendTypes['msldap'] = 'ActiveDirectory'; } $externalBackends = array_filter($this->config->toArray(), function ($authBackendCfg) { return isset($authBackendCfg['backend']) && $authBackendCfg['backend'] === 'external'; }); if ($backendType === 'external' || empty($externalBackends)) { $backendTypes['external'] = $this->translate('External'); } if ($backendType === null) { $backendType = key($backendTypes); } $this->addElement('select', 'type', array('ignore' => true, 'required' => true, 'autosubmit' => true, 'label' => $this->translate('Backend Type'), 'description' => $this->translate('The type of the resource to use for this authenticaton provider'), 'multiOptions' => $backendTypes)); if (isset($formData['force_creation']) && $formData['force_creation']) { // In case another error occured and the checkbox was displayed before $this->addElement($this->getForceCreationCheckbox()); } $this->addElements($this->getBackendForm($backendType)->createElements($formData)->getElements()); }
/** * @see Form::createElemeents() */ public function createElements(array $formData) { $resourceType = isset($formData['type']) ? $formData['type'] : 'db'; $resourceTypes = array('file' => $this->translate('File'), 'livestatus' => 'Livestatus', 'ssh' => $this->translate('SSH Identity')); if ($resourceType === 'ldap' || Platform::extensionLoaded('ldap')) { $resourceTypes['ldap'] = 'LDAP'; } if ($resourceType === 'db' || Platform::hasMysqlSupport() || Platform::hasPostgresqlSupport()) { $resourceTypes['db'] = $this->translate('SQL Database'); } $this->addElement('select', 'type', array('required' => true, 'autosubmit' => true, 'label' => $this->translate('Resource Type'), 'description' => $this->translate('The type of resource'), 'multiOptions' => $resourceTypes, 'value' => $resourceType)); if (isset($formData['force_creation']) && $formData['force_creation']) { // In case another error occured and the checkbox was displayed before $this->addElement($this->getForceCreationCheckbox()); } $this->addElements($this->getResourceForm($resourceType)->createElements($formData)->getElements()); }