Beispiel #1
0
 /**
  * @module User
  * @action New
  * @return array
  */
 public function createAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         $isSamePassword = $params['password'] == $params['confirm'];
         if (!$isSamePassword) {
             $this->view->setTpl("New");
             if (!$isSamePassword) {
                 $this->view->error = $this->i18n->_("The passwords do not match");
             }
             return;
         }
         try {
             $this->getUserCatalog()->beginTransaction();
             $accessRole = $this->getRequest()->getParam('id_access_role');
             $username = $this->getRequest()->getParam('username');
             $pass = $this->getRequest()->getParam('password');
             $name = $this->getRequest()->getParam('name');
             $lastName = $this->getRequest()->getParam('last_name');
             $secondName = $this->getRequest()->getParam('second_name');
             $notifications = $this->getRequest()->getParam('notifications') == User::$ReceiveNotifications['Yes'] ? User::$ReceiveNotifications['Yes'] : User::$ReceiveNotifications['No'];
             $userParams = array('id_access_role' => $accessRole, 'username' => $username, 'password' => new Zend_Db_Expr("PASSWORD('{$pass}')"), 'name' => $name, 'last_name' => $lastName, 'second_name' => $secondName, 'status' => User::$Status['Active'], 'notifications' => $notifications);
             $user = UserFactory::createFromArray($userParams);
             $this->getUserCatalog()->create($user);
             $email = EmailFactory::createFromArray($params);
             $this->getEmailCatalog()->create($email);
             $this->newLogForCreate($user);
             $this->getUserCatalog()->linkToEmail($user->getIdPerson(), $email->getIdEmail());
             $this->getUserCatalog()->commit();
             $this->setFlash('ok', $this->i18n->_("The User was created correctly"));
         } catch (Exception $e) {
             $this->getUserCatalog()->rollBack();
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
     }
     $this->_redirect('user/list');
 }
Beispiel #2
0
 /**
  *
  * makeBean
  * @param array $resultset
  * @return \Application\Model\Bean\User
  */
 protected function makeBean($resultset)
 {
     return UserFactory::createFromArray($resultset);
 }