public function onSuccessCommentRemoval(Comment $comment, $id) { /** @var \Users\User $user */ $user = $this->user->getIdentity(); $pageLink = $this->linkGenerator->link('Pages:Front:Page:show', ['internal_id' => $comment->getPageId()]); $this->appEventLogger->saveLog(sprintf('User [%s#%s] <b>has REMOVED</b> the Comment [%s#] of Author [%s] on the <a href="%s">Page [%s#%s]</a>', $user->getId(), $user->getUsername(), $id, $comment->getAuthor(), $pageLink, $comment->getPageId(), $comment->getPageTitle()), 'page_comment_release', $user->getId()); }
/** * Panel prihlaseneho uzivatela * @param string $baseUrl * @param string $log_out * @return \App\FrontModule\Components\User\MenuItem */ private function _panelPrihlaseny($baseUrl, $log_out) { $menu_user = []; $udata = $this->user->getIdentity(); if ($this->nastavenie['view_avatar']) { $obb = Html::el('img class="avatar"'); if ($udata->avatar_25 && is_file('www/' . $udata->avatar_25)) { $obb = $obb->src($baseUrl . '/www/' . $udata->avatar_25)->alt('avatar'); } else { $obb = $obb->src($baseUrl . '/www/ikonky/64/figurky_64.png')->alt('bez avatara'); } } else { $obb = ""; } $menu_user[] = new MenuItem(['odkaz' => 'UserLog:', 'nazov' => $obb . " " . $udata->meno . ' ' . $udata->priezvisko, 'title' => $udata->meno . ' ' . $udata->priezvisko]); if ($this->user->isAllowed('admin', 'enter')) { $menu_user[] = new MenuItem(['odkaz' => ':Admin:Homepage:', 'title' => 'Administrácia', 'ikonka' => $this->nastavenie['admin_link'] & 1 ? 'pencil' : '', 'nazov' => $this->nastavenie['admin_link'] & 2 ? $this->texty['base_AdminLink_name'] : '']); } if ($this->user->isInRole('admin')) { $hl_m_db_info = $this->lang->getDBInfo(); $menu_user[] = new MenuItem(['abs_link' => $baseUrl . "/www/adminer/?server=" . $hl_m_db_info['host'] . "&db=" . $hl_m_db_info['dbname'], 'title' => 'Adminer', 'target' => '_blank', 'nazov' => Html::el('img')->src($baseUrl . '/www/ikonky/16/graf_16.png')->alt('Adminer')]); } $menu_user[] = new MenuItem(['odkaz' => 'signOut!', 'ikonka' => "sign-out", 'nazov' => $log_out]); return $menu_user; }
public function processCreateInvitation(Form $form) { $value = $form->getValues(); $invitation = new Invitation($value['email'], $this->user->getIdentity()); try { /** @var EntityResultObject $resultObject */ $resultObject = $this->invitationsFacade->createInvitation($invitation); $this->flashMessage('Registrační pozvánka byla vytvořena.', 'success'); if (!$resultObject->hasNoErrors()) { $error = $resultObject->getFirstError(); $this->flashMessage($error['message'], $error['type']); } } catch (InvitationCreationAttemptException $ca) { $this->flashMessage('Pozvánku nebyla vytvořena. Zkuste akci opakovat později.', 'error'); } catch (UserAlreadyExistsException $uae) { $form->addError('Pozvánku nelze odeslat. Uživatel s E-Mailem ' . $value['email'] . ' je již zaregistrován.'); return; } catch (InvitationAlreadyExistsException $iae) { $form->addError('Někdo jiný již odeslal pozvánku uživateli s E-mailem ' . $value['email']); return; } catch (DBALException $e) { $this->flashMessage('Při vytváření pozvánky došlo k chybě. Zkuste akci opakovat později.', 'error'); } $this->redirect('this'); }
public function createComponentShipmentForm() { $form = $this->shipmentFormFactory->create($this->currentCartService->getCurrentCart()->getShipment(), $this->user->isLoggedIn() ? $this->user->getIdentity() : null); $form->onSuccess[] = function (ShipmentForm $form) { $this->updateShipment($form); }; return $form; }
/** * @return \Nette\Database\Table\Selection */ protected function getData() { $selection = $this->sectionFacade->all(); if (!$this->user->getIdentity()->super) { $this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections); } return $selection; }
public function getData() { $selection = $this->sectionFacade->all(); if (!$this->user->getIdentity()->super) { $this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections); } return $selection->fetchPairs('id', 'id'); }
protected $user; /** @var DbTable\Lang */ public $lang; /** @var array Hodnoty id=>nazov pre formulare z tabulky registracia */ protected $urovneReg; /** @var array Hodnoty id=>nazov pre formulare z tabulky hlavicka */ protected $hlavickaForm; /** @var array Hodnoty id=>nazov pre formulare z tabulky dlzka_novinky */ public $dlzkaNovinkyForm;
/** * @return \Nette\Database\Table\Selection */ public function getUserSection() { $selection = $this->sectionFacade->all(); if (!$this->user->getIdentity()->super) { $this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections); } return $selection; }
/** * @param Form $form */ public function Submit(Form $form) { $json = new \stdClass(); $json->result = "success"; $values = $form->getValues(); $result = false; if (!empty($values['userID'])) { $userEntity = $this->userRepository->get($values['userID']); if ($userEntity) { if ($this->user->isAllowed("user_management", "edit")) { $userEntity->setLogin($values['login']); if (!empty($values['password1'])) { $userEntity->setPassword($values['password1']); } if ($userEntity->getLogin() !== "root" && $userEntity->getUserID() !== $this->user->getId()) { $userEntity->setActive($values['active']); if ($userEntity->getRole()->getAclRoleID() != $this->user->getIdentity()->data['aclRoleID']) { $userEntity->setAclRoleID($values['role']); } } try { $result = $this->userRepository->save(); } catch (\PDOException $e) { $result = $e->getMessage(); } } else { $result = UserForm::PERMISSION; } } } else { if ($this->user->isAllowed("user_management", "add")) { $userEntity = new UserEntity(); $userEntity->setLogin($values['login'])->setPassword($values['password1'])->setActive($values['active'])->setAclRoleID($values['role']); try { $result = $this->userRepository->push($userEntity)->save(); } catch (\PDOException $e) { $result = $e->getMessage(); if (preg_match("/Duplicate entry/", $result)) { $result = "Nick <strong>" . $values['login'] . "</strong> již existuje. Zvolte prosím jiný login."; } } if ($result instanceof UserEntity || $result === TRUE) { $result = TRUE; } } else { $result = UserForm::PERMISSION; } } if ($result === TRUE) { $json->result = "success"; } else { $json->result = "error"; $json->message = $result; } $response = new JsonResponse($json); $this->getPresenter()->sendResponse($response); }
public static function loadFromSession(\Nette\Security\User $user) { $instance = new User(); $instance->setId($user->getIdentity()->id); $instance->setRole($user->getRoles()[0]); $instance->setEmail($user->getIdentity()->email); $instance->setFirstName($user->getIdentity()->firstName); $instance->setLastName($user->getIdentity()->lastName); return $instance; }
/** * @param \Nette\Application\UI\Form $form */ public function processForm(Form $form) { $values = $form->values; $event = $this->event ? $this->event : new Entity\Event($this->securityUser->getIdentity()); $event->name = $values->name; $event->date = DateTime::from($values->date); $event->place = $values->place; $event->note = $values->note; $this->eventFacade->save($event); }
/** * {@inheritdoc} */ public function isGranted($attributes, $object = null) { if (!is_array($attributes)) { $attributes = array($attributes); } if (!$this->user->isLoggedIn() || ($identity = $this->user->getIdentity()) === null) { $identity = new GuestIdentity(); } return $this->decisionManager->decide($identity, $attributes, $object); }
/** Funkce pro zápis zprávy * * @param string $message */ public function log($message) { if (is_string($message) && !empty($message)) { $record = array('timestamp' => new DateTime(), 'message' => $message, 'ip' => $_SERVER["REMOTE_ADDR"]); if ($this->user && $this->user->isLoggedIn()) { $record['userID'] = $this->user->getIdentity()->userID; } $this->database->table(SQLLogger::DB_TABLE)->insert($record); } }
/** * Callback method, that is called once form is successfully submitted, without validation errors. * * @param Form $form * @param Nette\Utils\ArrayHash $values */ public function formSucceeded(Form $form, $values) { if ($this->pad === NULL) { $this->em->persist($pad = new Pad($this->user->getIdentity())); } else { $pad = $this->pad; } $pad->setName($values->name); $this->em->flush($pad); $this->onSuccess($this, $pad); }
/** * Callback method, that is called once form is successfully submitted, without validation errors. * * @param Form $form * @param Nette\Utils\ArrayHash $values */ public function formSucceeded(Form $form, $values) { /** @var User $user */ $user = $this->user->getIdentity(); try { $user->changePassword($values->current, $values->password); $this->em->flush(); $this->onSuccess($this); } catch (InvalidPasswordException $e) { $form['current']->addError('Invalid current password'); } }
public function consolidateCurrentCartWithCurrentUser() { if ($this->user->isLoggedIn()) { /** @var User $identity */ $identity = $this->user->getIdentity(); if ($this->getCurrentCart()->hasItems()) { $this->getCurrentCart()->setUser($identity); $this->saveCurrentCart(); } elseif ($identity->hasAnyCart()) { $this->setCurrentCart($identity->getLastCart()); } } }
/** * Startup method * @return void */ public function startup() { parent::startup(); $this->lang = $this->translator->setLanguage($this->lang); $this->answers[0] = _("No"); $this->answers[1] = _("Yes"); // load user to presenter $this->user = $this->getUser(); // zkusi jestli je uzivatel prihlasen if (!$this->user->isLoggedIn()) { $this->redirect(":User:Authenticator:default", array('backlink' => $this->storeRequest())); } $this->lang = $this->user->getIdentity()->getData()["lang"]; $this->user->setAuthorizator(new \UserModule\Authorizator()); return; }
/** * main action * @return void */ public function actionDefault() { if ($this->user->isLoggedIn()) { $this->flashMessage(_("You are still logged in..."), "info"); $this->restoreRequest($this->backlink); $this->redirect(":Data:Browser:"); } // test of use valid SSL client certificate if ($this->ssl->verifyClient() == true) { $username = $this->ssl->getUsername(); $serial = $this->ssl->getSerial(); $this->user->setAuthenticator(new \UserModule\SSLAuthenticator($this->db)); try { // pokud to vyjde je vse OK $this->user->login($username, $serial); $this->user->getIdentity()->isSSLlogin = true; $this->flashMessage(_("You are logged in by SSL Certificate", "success")); $this->restoreRequest($this->backlink); $this->redirect(":Data:Browser:"); } catch (\Nette\Security\AuthenticationException $e) { // pokud to nevyjde dojdte k prihlaseni jmenem a heslem $this->flashMessage(_("You are not logged in by SSL Certificate because of: \n" . $e->getMessage(), "warning")); $this->redirect("login"); } } else { $this->flashMessage(_("You have not valid SSL certificate, please fill username and password"), "info"); $this->redirect("login"); } return; }
*/ class EditCategoriFormFactory { /** @var DbTable\User_categories */ private $user_categories; /** @var array */ private $urovneReg; /** @var int */
public function onLoggedOut(Security $security) { // BUG: Nette\Security\User 2.1 fires onLoggedOut before clearing storage if ($user = $this->repository->find($security->getIdentity()->getId())) { $security->getStorage()->setAuthenticated(FALSE); $this->user->signOut($user); } }
public function getIdentity() { $identity = parent::getIdentity(); if ($identity !== null) { $identity = $this->userService->getById((int) $identity->getId()); } return $identity; }
public function log($media, $event, $message, $who = null) { //Prepare identity $user_id = null; if ($this->user->isLoggedIn()) { $identity = $this->user->getIdentity(); if (!$who) { $who = $identity->username; } $user_id = $identity->getId(); } elseif (!$who) { $who = self::USR_ANONYMOUS; } //Prepare message $message = str_replace('%user%', $who, $message); //Add a record $this->storage->addRecord($media, $event, $message, $who, $user_id); }
/** * Make menu from config.neon * @return void */ public function addItems() { foreach ($this->data as $data) { if ($data["module"] . ":" . $data["presenter"] == $this->currentPresenter && $data["action"] == $this->currentAction) { $clickable = false; } else { $clickable = true; } $this->addItem($data["title"], $data["module"], $data["presenter"], $data["action"], $data["auth"], $clickable); } if ($this->user->isAllowed("user", "view")) { if (!isset($this->user->getIdentity()->isSSLlogin) or $this->user->getIdentity()->isSSLlogin == false) { $this->addItem(_("Logout"), "User", "Authenticator", "logout", "user", true); } else { $this->addItem(_("SSL Login"), "User", "Authenticator", "logout", "user", false); } } return; }
public function __construct(User $user) { $data = $user->getIdentity(); if (isset($data->data)) { foreach ($data->data as $name => $value) { if (property_exists($this, $name)) { $this->{$name} = $value; } } } }
/** * @param \Venne\Files\AjaxFileUploaderControl $control * @param string $fileName */ public function fileUpload(AjaxFileUploaderControl $control, $fileName) { try { $file = new File(); $file->setParent($this->dir); $file->setFile(new \SplFileInfo($control->getAjaxDir() . '/' . $fileName)); $file->setAuthor($this->userRepository->find($this->netteUser->getIdentity()->getId())); $this->entityManager->persist($file); $this->entityManager->flush(); } catch (\Exception $e) { Debugger::log($e); } }
public function sendNotifications(Form $form, $values) { $messages = []; foreach ($this->newListings as $listing) { $message = $this->sharedListingNotification->getNotificationMessage($listing, $this->user->getIdentity()->username, $this->users[$listing->getOwnerID()]); $messages[$listing->getOwnerID()] = $message; } try { $this->messagesFacade->sendMessages($messages); } catch (\DibiException $e) { $this->presenter->flashMessage('Nepodařilo se odeslat upozornění příjemcům.', 'warning'); $this->redirect('this'); } $this->redirect('this'); }
/** * Callback method, that is called once form is successfully submitted, without validation errors. * * @param Form $form * @param Nette\Utils\ArrayHash $values */ public function formSucceeded(Form $form, $values) { if ($this->note === NULL) { $note = new Note($this->user->getIdentity()); $this->em->persist($note); } else { $note = $this->note; } $note->setName($values->name); $note->setText($values->text); if ($values->pad === NULL) { $note->setPad(NULL); } else { $note->setPad($this->padRepository->find($values->pad)); } $this->em->flush(); $this->onSuccess($this); }
/** * @return array */ protected function getSections() { if (!$this->sections) { $selection = $this->filterSections($this->sectionFacade->all()); if (!$this->user->getIdentity()->super) { $this->sectionFilter->filterId($selection, $this->user->getIdentity()->sections); } $this->sectionOrderer->order($selection, 'section'); if ($this->moduleGroup) { $selection->select('section.id, module.name'); $selection->group('section.module'); } else { $selection->select('section.id,section.name'); } $this->sections = $selection->fetchPairs('id', 'name'); } return $this->sections; }
public function __construct(AppEventLogger $appEventLogger, User $user) { $this->appEventLogger = $appEventLogger; $this->user = $user->getIdentity(); }
public function onSuccessOptionsSaving() { /** @var \Users\User $user */ $user = $this->user->getIdentity(); $this->appEventLogger->saveLog(sprintf('User [%s#%s] <b>has EDITED</b> web options', $user->getId(), $user->getUsername()), 'options_editing', $user->getId()); }