/** * Step 2: Save the data */ public function saveAction() { $session = new Zend_Session_Namespace('setup'); $request = $this->getRequest(); $form = new Setup_Form_PreferencesForm(array('action' => '/setup/preferences/save', 'method' => 'post')); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('index', 'preferences', 'setup'); } try { if ($form->isValid($request->getPost())) { // Get the values posted $params = $form->getValues(); $session->preferences = $params; // Create the main xml config file if (Settings::saveConfig($session->db)) { // Start the creation of the database tables Settings::createDb(); // Get the default ISP company $isp_id = Isp::getActiveISPID(); // Save the company information Isp::saveAll($params, $isp_id); // TODO: Bind ISP to the current URL $IspUrls = new IspUrls(); $IspUrls->isp_id = $isp_id; $IspUrls->url = $_SERVER['HTTP_HOST']; $IspUrls->save(); // Adding the user as administrator AdminUser::addUser($params['firstname'], $params['lastname'], $params['email'], $params['password'], $isp_id); // Redirect the user to the homepage $this->_helper->redirector('index', 'summary', 'setup'); } // There was a problem the setup restarts $this->_helper->redirector('index', 'index', 'setup'); } } catch (Exception $e) { die($e->getMessage()); } $this->view->form = $form; return $this->_helper->viewRenderer('form'); }
/** * processAction * Update the record previously selected * @return unknown_type */ public function processAction() { $request = $this->getRequest(); // Create the buttons in the edit form $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/isp/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/isp/new/", "label" => $this->translator->translate('New'), "params" => array('css' => null))); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('index'); } // Get our form and validate it $form = $this->getForm('/admin/isp/process'); if (!$form->isValid($request->getPost())) { // Invalid entries $this->view->form = $form; $this->view->title = $this->translator->translate("ISP Account"); $this->view->description = $this->translator->translate("Some information must be checked again before saving them."); return $this->render('applicantform'); // re-render the login form } // Save the data Isp::saveAll($request->getPost(), $this->isp['isp_id']); return $this->_helper->redirector('account', 'isp', 'admin'); }