当前位置: 首页>>代码示例>>PHP>>正文


PHP User::getIdentity方法代码示例

本文整理汇总了PHP中Nette\Security\User::getIdentity方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getIdentity方法的具体用法?PHP User::getIdentity怎么用?PHP User::getIdentity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Nette\Security\User的用法示例。


在下文中一共展示了User::getIdentity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onSuccessCommentRemoval

 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());
 }
开发者ID:blitzik,项目名称:CMS,代码行数:7,代码来源:PageCommentSubscriber.php

示例2: _panelPrihlaseny

 /** 
  * 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;
 }
开发者ID:petak23,项目名称:echo-msz,代码行数:30,代码来源:UserLangMenu.php

示例3: processCreateInvitation

 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');
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:25,代码来源:InvitationGenerationControl.php

示例4: createComponentShipmentForm

 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;
 }
开发者ID:shophp,项目名称:shophp,代码行数:8,代码来源:ShipmentPresenter.php

示例5: getData

 /**
  * @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;
 }
开发者ID:kysela-petr,项目名称:generator-kysela,代码行数:11,代码来源:UserSectionView.php

示例6: getData

 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');
 }
开发者ID:kysela-petr,项目名称:generator-kysela,代码行数:8,代码来源:UserSectionProvider.php

示例7: getUserSection

 /**
  * @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;
 }
开发者ID:kysela-petr,项目名称:generator-kysela,代码行数:11,代码来源:UserSection.php

示例8: Submit

 /**
  * @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);
 }
开发者ID:vipercz,项目名称:sandbox,代码行数:60,代码来源:UserForm.php

示例9: loadFromSession

 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;
 }
开发者ID:jaromir92,项目名称:Sportwin,代码行数:10,代码来源:UserService.php

示例10: processForm

 /**
  * @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);
 }
开发者ID:Kotys,项目名称:eventor.io,代码行数:13,代码来源:SetEventForm.php

示例11: isGranted

 /**
  * {@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);
 }
开发者ID:zycon42,项目名称:security,代码行数:13,代码来源:SecurityContext.php

示例12: log

 /** 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);
     }
 }
开发者ID:vipercz,项目名称:sandbox,代码行数:14,代码来源:SQLLogger.php

示例13: formSucceeded

 /**
  * 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);
 }
开发者ID:martinmayer,项目名称:notejam,代码行数:17,代码来源:PadsControl.php

示例14: formSucceeded

 /**
  * 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');
     }
 }
开发者ID:martinmayer,项目名称:notejam,代码行数:18,代码来源:SettingsControl.php

示例15: consolidateCurrentCartWithCurrentUser

 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());
         }
     }
 }
开发者ID:shophp,项目名称:shophp,代码行数:13,代码来源:CurrentCartService.php


注:本文中的Nette\Security\User::getIdentity方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。