Example #1
0
 private function editorTypeHandle(WebProfile $e)
 {
     if ($e === null) {
         throw new Exceptions\NullPointerException("Argument Event cannot be null", 0);
     }
     try {
         $editor = null;
         $id = $this->getMixId($e->getEditor());
         if ($id !== null) {
             $editor = $this->userDao->find($id);
         }
         $e->setEditor($editor);
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
Example #2
0
 public function webProfileFormSuccess(WebProfileForm $form)
 {
     $values = $form->getValues();
     try {
         $dbUser = $this->userService->getUser($this->getEntity()->getId(), false);
         $wp = new WebProfile((array) $values);
         $wp->setUpdated(new \Nette\Utils\DateTime());
         $wp->setEditor($this->getUser()->getIdentity());
         if (!$values->picture->isOk()) {
             $wp->setPicture($dbUser->getWebProfile()->getPicture());
         } else {
             $wp->insertOldImgId($dbUser->getWebProfile()->getPicture());
         }
         $dbUser->setWebProfile($wp);
         $this->userService->changeWebProfile($dbUser);
     } catch (Exceptions\DataErrorException $e) {
         $this->logError($e);
         $m = $this->tt("usersModule.admin.messages.webProfileUpdateFailed", ["id" => $values["id"]]);
         $this->flashMessage($m, self::FM_ERROR);
     }
     $this->redirect("Admin:default");
 }
Example #3
0
 /**
  * Performs WebProfile data save from owning logged user
  * @param \App\UsersModule\Forms\PersonalWebProfileForm $form
  */
 public function webProfileFormSuccess(PersonalWebProfileForm $form)
 {
     $values = $form->getValues();
     $wp = new WebProfile((array) $values);
     $user = $this->getUser()->getIdentity();
     if (!$values->picture->isOk()) {
         $wp->setPicture($user->getWebProfile()->getPicture());
     } else {
         $wp->insertOldImgId($user->getWebProfile()->getPicture());
     }
     $wp->setStatus(WebProfileStatus::UPDATED);
     $wp->setUpdated(new \Nette\Utils\DateTime());
     $wp->setEditor($this->getUser()->getIdentity());
     $user->setWebProfile($wp);
     try {
         $this->userService->changeWebProfile($user);
     } catch (Exceptions\DataErrorException $e) {
         $this->handleDataSave($wp->getId(), "default", $e);
     }
     $this->redirect("this");
 }