コード例 #1
0
ファイル: UserController.php プロジェクト: Eximagen/sochi
 /**
  * @module User
  * @action Update
  * @return array
  */
 public function updateAction()
 {
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         $idEmail = $params['id_email'];
         $id = $this->getRequest()->getParam('id_user');
         $user = UserQuery::create()->findByPKOrThrow($id, $this->i18n->_("It does not exist the User with id {$id}"));
         if (isset($idEmail)) {
             $emailQuery = EmailQuery::create()->findByPK($idEmail);
         }
         if (count($emailQuery) > 0) {
             $email = $emailQuery;
         } else {
             $email = EmailFactory::createFromArray($params);
             $this->getEmailCatalog()->create($email);
             $this->getUserCatalog()->linkToEmail($user->getIdPerson(), $email->getIdEmail());
         }
         $emailPerson = UserQuery::create()->innerJoinEmail()->whereAdd('Person.' . User::ID_PERSON, $user->getIdPerson())->whereAdd('Email.' . Email::ID_EMAIL, $email->getIdEmail(), UserQuery::NOT_EQUAL)->addColumn('Person2Email.id_email')->fetchCol();
         foreach ($emailPerson as $unlinkableMail) {
             $this->getUserCatalog()->unlinkFromEmail($user->getIdPerson(), $unlinkableMail);
         }
         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, 'name' => $name, 'last_name' => $lastName, 'second_name' => $secondName, 'notifications' => $notifications);
             if ($pass) {
                 $userParams['password'] = new Zend_Db_Expr("PASSWORD('{$pass}')");
             }
             UserFactory::populate($user, $userParams);
             $this->getUserCatalog()->update($user);
             EmailFactory::populate($email, $params);
             $this->getEmailCatalog()->update($email);
             $this->newLogForUpdate($user);
             $this->getUserCatalog()->commit();
             $this->setFlash('ok', $this->i18n->_("Se actualizo correctamente el User"));
         } catch (Exception $e) {
             $this->getUserCatalog()->rollBack();
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
     }
     $this->_redirect('user/list');
 }
コード例 #2
0
ファイル: EmailCatalog.php プロジェクト: Eximagen/sochi
 /**
  *
  * makeBean
  * @param array $resultset
  * @return \Application\Model\Bean\Email
  */
 protected function makeBean($resultset)
 {
     return EmailFactory::createFromArray($resultset);
 }