示例#1
0
 public function createComponentContactControl($name)
 {
     $c = new ContactControl($this, $name);
     $user = null;
     $id = null;
     try {
         $id = $this->getDefaultUserId();
         $user = $this->userService->getUser($id);
     } catch (Exceptions\DataErrorException $ex) {
         $this->handleDataLoad($id, "this", $ex);
     }
     if (!empty($user)) {
         $c->setUser($user);
     }
     return $c;
 }
示例#2
0
 /**
  * Action for displaying user's web profile detail
  * @param string $uid
  * @param string $gid
  */
 public function actionShowWebProfile($uid, $gid)
 {
     if (!is_numeric($uid)) {
         $this->redirect("default");
     }
     $user = null;
     $group = null;
     try {
         if (is_numeric($gid)) {
             $group = $this->sportGroupService->getSportGroup($gid);
         } else {
             $group = $this->sportGroupService->getSportGroupAbbr($gid);
         }
         $user = $this->userService->getUser($uid);
     } catch (Exceptions\DataErrorException $ex) {
         $this->handleDataLoad($uid, "default", $ex);
     }
     if ($group === null || $user === null) {
         $this->redirect("default");
     }
     $this->setEntity($user);
     $this->template->group = $group;
     $this->template->since = $user->getCreated();
     $this->template->name = $user->getName();
     $this->template->surname = $user->getSurname();
     $this->template->nick = $user->getNick();
     $profile = $user->getWebProfile();
     $this->template->publishable = $profile->getStatus() == WebProfileStatus::OK ? true : false;
     $this->template->profile = $profile;
 }
示例#3
0
 private function saveMailboxEntry(MailBoxEntry $mb)
 {
     $toObject = $this->userService->getUser($this->getMixId($mb->getRecipient()), false);
     $fromObject = $this->userService->getUser($this->getMixId($mb->getSender()), false);
     $mb->setOwner($toObject);
     $mb->setRecipient($toObject);
     $mb->setSender($fromObject);
     $this->mailboxDao->save($mb);
 }
示例#4
0
 private function referrerTypeHandle(BaseEntity $t)
 {
     try {
         $r = $this->getMixId($t->getReferrer());
         if ($r !== null) {
             $ref = $this->userService->getUser($r, false);
             $t->setReferrer($ref);
         }
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
     return $t;
 }
 private function entryEditorTypeHandle(MotivationEntry $t)
 {
     if ($t == null) {
         throw new Exceptions\NullPointerException("Argument MotivationTax cannot be null");
     }
     try {
         $u = $this->getMixId($t->getEditor());
         if ($u !== null) {
             $editor = $this->userService->getUser($u, false);
             $t->setEditor($editor);
         }
     } catch (\Exception $ex) {
         $this->logError($ex->getMessage());
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
     return $t;
 }
示例#6
0
 public function deleteEventParticipation($u, Event $e)
 {
     try {
         $eDb = $this->getEvent($e->getId());
         $uDb = $this->userService->getUser($this->getMixId($u));
         if ($eDb !== null && $eDb !== null) {
             $pDb = $this->participationDao->createQueryBuilder("p")->where("p.event = :event")->andWhere("p.owner = :owner")->setParameter("event", $eDb->getId())->setParameter("owner", $uDb->getId())->getQuery()->getSingleResult();
             if ($pDb !== null) {
                 $this->participationDao->delete($pDb);
                 $this->onDelete($pDb);
             }
         }
         $this->invalidateEntityCache($eDb);
     } catch (\Exception $ex) {
         $this->logError($ex);
         throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
     }
 }
示例#7
0
 private function posOwnerTypeHandle(Position $p)
 {
     if ($p === null) {
         throw new Exceptions\NullPointerException("Argument Position cannot be null");
     }
     try {
         $owner = null;
         $id = $this->getMixId($p->getOwner());
         if ($id !== null) {
             $owner = $this->userService->getUser($id, false);
         }
         $p->setOwner($owner);
     } catch (\Exception $e) {
         $this->logError($e);
         throw new Exceptions\DataErrorException($e->getMessage(), $e->getCode(), $e->getPrevious());
     }
     return $p;
 }
示例#8
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");
 }