data = $data; } public function apply() { $resourceConfig = array(); if (isset($this->data['dbResourceConfig'])) { $dbConfig = $this->data['dbResourceConfig']; $resourceName = $dbConfig['name']; unset($dbConfig['name']); $resourceConfig[$resourceName] = $dbConfig; } if (isset($this->data['ldapResourceConfig'])) { $ldapConfig = $this->data['ldapResourceConfig']; $resourceName = $ldapConfig['name']; unset($ldapConfig['name']); $resourceConfig[$resourceName] = $ldapConfig; } try { Config::fromArray($resourceConfig) ->setConfigFile(Config::resolvePath('resources.ini')) ->saveIni(); } catch (Exception $e) { $this->error = $e; return false; } $this->error = false; return true; } public function getSummary() { if (isset($this->data['dbResourceConfig']) && isset($this->data['ldapResourceConfig'])) { $pageTitle = '
' . t('Resource Name') . ' | ' . '' . $this->data['dbResourceConfig']['name'] . ' | ' . '
' . t('Database Type') . ' | ' . '' . $this->data['dbResourceConfig']['db'] . ' | ' . '
' . t('Host') . ' | ' . '' . $this->data['dbResourceConfig']['host'] . ' | ' . '
' . t('Port') . ' | ' . '' . $this->data['dbResourceConfig']['port'] . ' | ' . '
' . t('Database Name') . ' | ' . '' . $this->data['dbResourceConfig']['dbname'] . ' | ' . '
' . t('Username') . ' | ' . '' . $this->data['dbResourceConfig']['username'] . ' | ' . '
' . t('Password') . ' | ' . '' . str_repeat('*', strlen($this->data['dbResourceConfig']['password'])) . ' | ' . '
' . t('Resource Name') . ' | ' . '' . $this->data['ldapResourceConfig']['name'] . ' | ' . '
' . t('Host') . ' | ' . '' . $this->data['ldapResourceConfig']['hostname'] . ' | ' . '
' . t('Port') . ' | ' . '' . $this->data['ldapResourceConfig']['port'] . ' | ' . '
' . t('Root DN') . ' | ' . '' . $this->data['ldapResourceConfig']['root_dn'] . ' | ' . '
' . t('Bind DN') . ' | ' . '' . $this->data['ldapResourceConfig']['bind_dn'] . ' | ' . '
' . t('Bind Password') . ' | ' . '' . str_repeat('*', strlen($this->data['ldapResourceConfig']['bind_pw'])) . ' | ' . '
' . sprintf($message, Config::resolvePath('resources.ini')) . '
'; } elseif ($this->error !== null) { $message = mt('setup', 'Resource configuration could not be written to: %s; An error occured:'); return '' . sprintf($message, Config::resolvePath('resources.ini')) . '
' . '' . $this->error->getMessage() . '
'; } } }