public function indexAction() { $form = new Application_Form_Profile(); $form->setMethod('POST'); $form->setDefaultsFromEntity($this->user); $request = $this->getRequest(); if ($request->isPost() && $form->isValid($request->getPost())) { $values = $form->getValues(); try { if (!empty($values['image'])) { $imageInfo = array_pop($form->image->getFileInfo()); $values['image'] = $this->_helper->service('image')->save($imageInfo); } $this->service->save($values, $this->user); $this->_helper->redirector('index'); } catch (\InvalidArgumentException $e) { switch ($e->getMessage()) { case 'username_conflict': $form->username->addError($this->view->translate("User with given username exists.")); break; default: $form->image->addError($e->getMessage()); break; } } } $this->view->user_first_name = $this->user->getFirstName(); $this->view->user_last_name = $this->user->getLastName(); $this->view->user_email = $this->user->getEmail(); $this->view->form = $form; $this->view->user = new MetaUser($this->user); $this->view->first_time = $this->_getParam('first', false); }
public function profileAction() { $this->_helper->layout->setLayout('iframe'); $form = new Admin_Form_Profile(); $user = $this->getUser(); $formProfile = new Application_Form_Profile(); $formProfile->setDefaultsFromEntity($user); $form->addSubform($formProfile->getSubform('attributes'), 'attributes'); $request = $this->getRequest(); if ($request->isPost() && $form->isValid($request->getPost())) { $values = $form->getValues(); try { if (!empty($values['image'])) { $imageInfo = array_pop($form->image->getFileInfo()); $values['image'] = $this->_helper->service('image')->save($imageInfo); $this->view->image = $this->_helper->service('image')->getSrc($values['image'], $this->_getParam('width', 80), $this->_getParam('height', 80)); } else { unset($values['image']); } $this->_helper->service('user')->save($values, $user); $this->view->close = true; } catch (\InvalidArgumentException $e) { $form->image->addError($e->getMessage()); } } $this->view->form = $form; }