public function userInit() { $user = null; $email = $this->userValues["contact"]["email"]; try { $user = $this->userService->getUserEmail($email); } catch (Exceptions\NoResultException $ex) { $this->logger->addDebug($ex); } if ($user === null) { $this->logger->addInfo("Users module initializer - User - no user with email {$email} found. New one is gonna be created."); $addrValues = $this->userValues["contact"]["address"]; $address = new Address((array) $addrValues); $address->applyAccountNumber($this->userValues["contact"]["address"]["accountNumber"]); $address->applyIdentificationNumber($this->userValues["contact"]["address"]["identificationNumber"]); $address->applyTaxIdentificationNumber($this->userValues["contact"]["address"]["taxIdentificationNumber"]); $contValues = $this->userValues["contact"]; $contact = new Contact((array) $contValues); $contact->setAddress($address); $userValues = $this->userValues; unset($userValues["contact"]); $user = new User((array) $userValues); $user->setActive(true); $user->setContact($contact); $user->setBirthNumber("0000000000"); $this->userService->createUser($user); } }
public function createComponentDeletedGrid($name) { try { $users = $this->userService->getSelectUsers(); } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, "default", $ex); } $grid = new Grid($this, $name); $grid->setTranslator($this->getTranslator()); $grid->setModel($this->privateMessageService->getDeletedDatasource($this->getUser()->getIdentity())); $grid->addColumnText("starred", "communicationModule.pmForm.starred")->setSortable()->setCustomRender($this->starredRender); $headerStar = $grid->getColumn('starred')->headerPrototype; $headerStar->class[] = 'center'; $headerStar->style['width'] = '1%'; $grid->addColumnText("recipient", "communicationModule.pmForm.recipient")->setTruncate(17)->setCustomRender($this->recipientRender)->setSortable()->setFilterSelect([null => null] + $users); $headerSender = $grid->getColumn('recipient')->headerPrototype; $headerSender->class[] = 'center'; $headerSender->style['width'] = '15%'; $grid->addColumnText("subject", "communicationModule.pmForm.subject")->setCustomRender($this->subjectRender)->setSortable()->setFilterText(); $headerSbj = $grid->getColumn('subject')->headerPrototype; $headerSbj->class[] = 'center'; $headerSbj->style['width'] = '50%'; $grid->addColumnDate("sent", "communicationModule.pmForm.delivered")->setCustomRender($this->sentRender)->setSortable(); $headerSnt = $grid->getColumn('sent')->headerPrototype; $headerSnt->class[] = 'center'; $headerSnt->style['width'] = '15%'; $grid->setFilterRenderType($this->filterRenderType); $grid->addActionHref("delete", "", "purgeMessage!")->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("communicationModule.user.grid.purgeMessage")]))->setIcon('trash')->setConfirm(function ($u) { return "communicationModule.user.grid.message.reallyPurgeMessage"; }); $grid->setOperation(["delete" => $this->tt("communicationModule.grid.delete"), "starToggle" => $this->tt("communicationModule.grid.starToggle")], $this->gridOperationsHandler); return $grid; }
/** * 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; }
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; }
private function getSelectUsers() { try { $users = $this->userService->getSelectUsers(); return $users; } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, "default", $ex); } }
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); }
private function getSelectUsers() { try { if (!isset($this->selectUsers)) { $this->selectUsers = $this->userService->getSelectUsers(); } } catch (Exceptions\DataErrorException $ex) { $this->handleDataLoad(null, self::LAST_CHANCE_REDIRECT, $ex); } return $this->selectUsers; }
private function preparePositionForm($name) { $form = new PositionForm($this, $name, $this->getTranslator()); $roles = $this->roleService->getSelectRoles(); $users = $this->userService->getSelectUsers(); $groups = $this->sportGroupService->getSelectAllSportGroups(); $form->setSportGroups($groups); $form->setRoles($roles); $form->setUsers($users); return $form; }
/** * @param Credentials Prihlasovaci udaje. * @throws AuthenticationException Chyba v overeni udaju. * @return Identitu uzivatele. */ public function authenticate(array $credentials) { list($username, $password) = $credentials; try { $user = $this->usersService->getUserEmail($username); } catch (Exceptions\NoResultException $ex) { $this->getLogger()->addAlert("### ATTEMPT TO LOG IN WITH INVALID EMAIL ### - exception = " . $ex); throw new AuthenticationException("securityModule.loginControl.messages.invalidCredentials", self::IDENTITY_NOT_FOUND); } if (!Passwords::verify($password, $user->password)) { $this->getLogger()->addAlert("### ATTEMPT TO LOG IN WITH INVALID PASSWORD ### - tried password = "******"securityModule.loginControl.messages.invalidCredentials", self::INVALID_CREDENTIAL); } if (!$user->active) { $this->getLogger()->addAlert("### ATTEMPT TO LOG TO INACTIVE ACCOUNT ### - account id = " . $user->getId()); throw new AuthenticationException("securityModule.loginControl.messages.userUnactive"); } $this->usersService->updateLastLogin($user); $identity = $user; return $identity; }
public function createComponentUpdateParticipationForm($name) { $c = new EventParticipationForm($this, $name, $this->presenter->getTranslator()); $c->setMode(FormMode::UPDATE_MODE); try { $users = $this->userService->getSelectUsers($this->getPresenter()->getSelectUserIdOmit()); $c->setUsers($users); } catch (Exceptions\DataErrorException $ex) { $this->presenter->handleDataLoad(null, "default", $ex); } $c->initialize(); return $c; }
public function prepareEventForm($name) { $form = new EventForm($this, $name, $this->getTranslator()); try { $groups = $this->sportGroupsService->getSelectAllSportGroups(); $form->setSportGroups($groups); $users = $this->userService->getSelectUsers(); $form->setUsers($users); } catch (\Exception $ex) { $this->handleDataLoad(null, "default", $ex); } return $form; }
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 prepareStaticPageForm($name, $selfId = null) { $form = new StaticPageForm($this, $name, $this->getTranslator()); try { $sportGroups = $this->sportGroupService->getSelectAllSportGroups($selfId); $form->setSportGroups($sportGroups); $users = $this->userService->getSelectUsers(); $form->setUsers($users); $pages = $this->staticPageService->getSelectStaticPages($selfId); $form->setPages($pages); } catch (Exceptions\DataErrorException $ex) { $this->flashMessage($ex->getMessage(), self::FM_ERROR); } return $form; }
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; }
/** * Personal web profile form onSuccess event handler * @param PasswordChangeForm $form * @return void */ public function passWordChangeFormSuccess(PasswordChangeForm $form) { $values = $form->getValues(); $user = $this->getUser()->getIdentity(); if (!Passwords::verify($values->old, $user->getPassword())) { $form['old']->addError("usersModule.passwordChangeForm.oldPwDoesntMatch"); return; } try { $this->userService->changePassword($user->insertRawPassword($values->new1)); } catch (Exceptions\DataErrorException $ex) { $this->handleDataSave($user->getId(), "default", $ex); } $this->flashMessage($this->tt("usersModule.messages.passwordChanged"), self::FM_SUCCESS); //$this->notifService->notifyPasswordChange($user->insertRawPassword($values->new1)); $this->redirect("this"); }
private function doDenyProfile($id) { if (!is_numeric($id)) { $this->handleBadArgument($id, "Admin:default"); } try { $this->userService->denyWebProfile($id, $this->getUser()->getIdentity()); } catch (Exceptions\InvalidArgumentException $ex) { $this->logError($ex->getMessage()); $m = $this->tt("usersModule.admin.badArgumentFormat", ["id" => $id]); $this->flashMessage($m, self::FM_ERROR); } catch (Exceptions\DataErrorException $ex) { $this->logError($ex->getMessage()); $m = $this->tt("usersModule.admin.webProfileDenyFailed", ["id" => $id]); $this->flashMessage($m, self::FM_ERROR); } }
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; }
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()); } }
/** * Admin articles grid factory. * @param string $name * @return Grid */ public function createComponentArticlesGrid($name) { $articleStates = [null => null] + ArticleStatus::getOptions(); $commentModes = [null => null] + CommentMode::getOptions(); try { $users = [null => null] + $this->usersService->getSelectUsers(); } catch (Exceptions\DataErrorException $ex) { $this->handleException($ex); } $grid = new Grid($this, $name); $grid->setModel($this->articleService->getArticlesDataSource()); $grid->setTranslator($this->getTranslator()); $grid->setPrimaryKey("id"); $grid->addColumnNumber("id", "#")->cellPrototype->class[] = "center"; $headerId = $grid->getColumn("id")->headerPrototype; $headerId->class[] = "center"; $headerId->rowspan = "2"; $headerId->style["width"] = '0.1%'; $grid->addColumnText('title', $this->tt("articlesModule.admin.grid.title"))->setSortable()->setCustomRender($this->titleRender)->setFilterText(); $headerTitle = $grid->getColumn('title')->headerPrototype; $headerTitle->class[] = 'center'; $grid->addColumnText('status', $this->tt("articlesModule.admin.grid.state"))->setSortable()->setCustomRender($this->statusRender)->setFilterSelect($articleStates); $headerStatus = $grid->getColumn('status')->headerPrototype; $headerStatus->class[] = 'center'; $grid->addColumnText('commentMode', $this->tt("articlesModule.admin.grid.comments"))->setSortable()->setCustomRender($this->commentModeRender)->setFilterSelect($commentModes); $headerStatus = $grid->getColumn('commentMode')->headerPrototype; $headerStatus->class[] = 'center'; $grid->addColumnText('author', $this->tt("articlesModule.admin.grid.author"))->setSortable()->setFilterSelect($users); $headerAuthor = $grid->getColumn('author')->headerPrototype; $headerAuthor->class[] = 'center'; $grid->addColumnDate('updated', $this->tt("articlesModule.admin.grid.change"), self::DATETIME_FORMAT)->setSortable()->setFilterDateRange(); $headerAuthor = $grid->getColumn('updated')->headerPrototype; $headerAuthor->class[] = 'center'; $grid->addActionHref('delete', '', 'deleteArticle!')->setIcon('trash')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("articlesModule.admin.grid.delete")]))->setConfirm(function ($u) { return $this->tt("articlesModule.admin.grid.rlyDelArticle", null, ["id" => $u->getId()]); }); $grid->addActionHref('edit', '', 'updateArticle')->setIcon('pencil')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("articlesModule.admin.grid.update")])); $grid->addActionHref("goto", "", "goToArticle")->setIcon('eye-open')->setElementPrototype(\Nette\Utils\Html::el("a")->addAttributes(["title" => $this->tt("articlesModule.admin.grid.view")])); $grid->setOperation(["delete" => $this->tt("system.common.delete")], $this->articlesGridOperationHandler); $grid->setFilterRenderType($this->filterRenderType); $grid->setExport("admin-articles" . date("Y-m-d H:i:s", time())); return $grid; }