Пример #1
0
 public function profileAction()
 {
     $profilMapper = new UserMapper();
     $profil = $profilMapper->getUserById($this->getUser()->getId());
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuPanel'), array('controller' => 'panel', 'action' => 'index'))->add($this->getTranslator()->trans('menuSettings'), array('controller' => 'panel', 'action' => 'settings'))->add($this->getTranslator()->trans('menuEditProfile'), array('controller' => 'panel', 'action' => 'profile'));
     $errors = array();
     if ($this->getRequest()->isPost()) {
         $email = trim($this->getRequest()->getPost('email'));
         $firstname = trim($this->getRequest()->getPost('first-name'));
         $lastname = trim($this->getRequest()->getPost('last-name'));
         $homepage = trim($this->getRequest()->getPost('homepage'));
         $city = trim($this->getRequest()->getPost('city'));
         $birthday = new \Ilch\Date(trim($this->getRequest()->getPost('birthday')));
         if (empty($email)) {
             $this->addMessage('emailEmpty');
             $this->redirect(array('action' => 'profile'));
         } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
             $this->addMessage('emailError');
             $this->redirect(array('action' => 'profile'));
         }
         if (empty($errors)) {
             $model = new \Modules\User\Models\User();
             $model->setId($this->getUser()->getId());
             $model->setEmail($email);
             $model->setFirstName($firstname);
             $model->setLastName($lastname);
             $model->setHomepage($homepage);
             $model->setCity($city);
             $model->setBirthday($birthday);
             $profilMapper->save($model);
             $this->redirect(array('action' => 'profile'));
         }
     }
     $this->getView()->set('profil', $profil);
 }