예제 #1
0
 /**
  * Step 2: Save the data
  */
 public function saveAction()
 {
     $session = new Zend_Session_Namespace('setup');
     $request = $this->getRequest();
     $form = new Setup_Form_DatabaseForm(array('action' => '/setup/database/save', 'method' => 'post'));
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('index', 'index', 'setup');
     }
     if ($form->isValid($request->getPost())) {
         // Get the values posted
         $params = $form->getValues();
         $conn = Shineisp_Commons_Utilities::chkdatabase($params['username'], $params['password'], $params['hostname'], $params['database']);
         if ($conn !== TRUE) {
             $this->_helper->redirector('index', 'database', 'setup', array('error' => $conn));
         } else {
             $session->db->hostname = $params['hostname'];
             $session->db->database = $params['database'];
             $session->db->username = $params['username'];
             $session->db->password = $params['password'];
             $this->_helper->redirector('index', 'preferences', 'setup');
         }
     }
     $this->view->form = $form;
     return $this->_helper->viewRenderer('form');
 }