Esempio n. 1
0
 /**
  * processAction
  * Update the record previously selected
  * @return unknown_type
  */
 public function processAction()
 {
     $request = $this->getRequest();
     $user_id = $request->getParam('user_id');
     $adminbuttons = array();
     // Get our form and validate it
     $form = $this->getForm('/admin/profile/process');
     // Create the buttons in the edit form
     if (AdminRoles::isAdministrator($this->logged_user['user_id'])) {
         $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')), array("url" => "/admin/profile/list", "label" => $this->translator->translate('List'), "params" => array('css' => null, 'id' => 'submit')));
     } else {
         $this->view->buttons = array(array("url" => "#", "label" => $this->translator->translate('Save'), "params" => array('css' => null, 'id' => 'submit')));
     }
     // Check if the email already exists only when a new record is created
     if (empty($user_id)) {
         $form->getElement('email')->addValidator(new Shineisp_Validate_NoRecordExists('AdminUser', 'email'), true);
     }
     // Check if we have a POST request
     if (!$request->isPost()) {
         return $this->_helper->redirector('index');
     }
     if (!$form->isValid($request->getPost())) {
         // Invalid entries
         $this->view->form = $form;
         $this->view->title = $this->translator->translate("User 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
     AdminUser::saveAll($request->getPost(), $request->getParam('user_id'));
     // Redirection
     if (AdminRoles::isAdministrator($this->logged_user['user_id'])) {
         return $this->_helper->redirector('list', 'profile', 'admin');
     } else {
         return $this->_helper->redirector('account', 'profile', 'admin');
     }
 }