/** * Executes index action * * @param sfRequest $request A request object */ public function executeInit(sfWebRequest $request) { //Check if kernel init went fine: $this->status = $this->getContext()->get('KernelStatus'); $this->getContext()->getUser()->setAttribute('relativeUrlRoot', $request->getRelativeUrlRoot()); //Add the log entry corresponding to the Kernel status: $log_ok = $this->getContext()->get('Kernel')->addLogIf(empty($this->status), array('info' => 'Application startup successful', 'error' => 'Application startup failed.')); //Check if error occured while logging: if (!$log_ok) { $this->status['log'] = 'Log files are unreachable, please check permissions on the log directory.'; } //Edit the databases.yml file: ParametersConfiguration::editYaml(); //Redirect to the localized homepage if everything went fine: $usersAuth = new usersAuth(); /*Depending on the user Type (disconnected, admin, viewer), a redirection is done*/ if ($usersAuth->isAdmin()) { $this->redirectIf(empty($this->status), '@localized_homepage'); } else { if ($usersAuth->isViewer()) { $this->redirectIf(empty($this->status), '@localized_homepage'); } else { $this->redirectIf(empty($this->status), '@authentification'); } } }
public function executeSystemParameters(sfWebRequest $request) { $error = 0; $this->forward404Unless($request->isMethod(sfRequest::POST)); //If the HTTP method is "post", get the values entered by the user: $this->values = array('ip_address' => $this->getRequestParameter('ip_address'), 'srv_port' => $this->getRequestParameter('srv_port'), 'dbms' => $this->getRequestParameter('dbms') + 1, 'db_name' => $this->getRequestParameter('db_name'), 'db_user_name' => $this->getRequestParameter('db_user_name'), 'db_password' => $this->getRequestParameter('db_password'), '_csrf_token' => $this->getRequestParameter('_csrf_token')); //Build the form with theses values: $form = new SystemParametersForm($this->values); //Execute the validators of this form: $form->bind($this->values); //If everything is fine: if ($form->isValid()) { //Insert the new values in the xml configuration file:*/ ParametersConfiguration::setBddParams($this->values); ParametersConfiguration::editYaml(); sfToolkit::clearGlob(sfConfig::get('sf_cache_dir') . '/install/*'); $this->redirect('firstBoot/stepTwo'); } else { $this->form = $form; $this->setTemplate("stepOne"); } }