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


PHP User::isAllowed方法代码示例

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


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

示例1: addItem

 /**
  * Add menu item
  * @param string $title Text in anchor
  * @param string $module destination module
  * @param string $presenter destination presenter
  * @param string $action destination action
  * @param string $auth resource for authorizator
  * @param boolean $clickable is anchor clickable?
  * @return void
  */
 public function addItem($title, $module, $presenter, $action, $auth, $clickable = true)
 {
     if ($this->user->isAllowed($auth, "view")) {
         $this->items[] = array("title" => $title, "module" => $module, "presenter" => $presenter, "action" => $action, "clickable" => $clickable);
     }
     return;
 }
开发者ID:OCC2,项目名称:occ2pacs,代码行数:17,代码来源:LeftMenu.php

示例2: 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

示例3: addItem

 /**
  * Add menu item
  * @param string $title Text in anchor
  * @param string $module destination module
  * @param string $presenter destination presenter
  * @param string $action destination action
  * @param string $auth resource for authorizator
  * @param boolean $clickable is anchor clickable?
  * @return void
  */
 public function addItem($title, $module, $presenter, $action, $auth, $clickable = true, $params = null)
 {
     if ($this->user->isAllowed($auth, "view")) {
         if ($params != null) {
             $this->items[] = array("title" => _($title), "module" => $module, "presenter" => $presenter, "action" => $action, "clickable" => $clickable, "params" => $params);
         } else {
             $this->items[] = array("title" => _($title), "module" => $module, "presenter" => $presenter, "action" => $action, "clickable" => $clickable);
         }
     }
     return;
 }
开发者ID:OCC2,项目名称:occ2pacs,代码行数:21,代码来源:Tabs.php

示例4: Submit

 /** Submit
  *
  * @param \Nette\Application\UI\Form $form
  */
 public function Submit(Form $form)
 {
     $json = new \stdClass();
     $json->result = "success";
     $values = $form->getValues();
     if (!empty($values['aclActionID'])) {
         if ($this->user->isAllowed("permission", "edit")) {
             $actionEntity = $this->actionRepository->get($values['aclActionID']);
             if ($actionEntity) {
                 $actionEntity->setName($values['name']);
                 $actionEntity->setHumanName($values['humanName']);
                 try {
                     $result = $this->actionRepository->save();
                 } catch (\PDOException $e) {
                     $result = $e->getMessage();
                 }
             } else {
                 $result = FALSE;
             }
         } else {
             $result = ActionForm::PERMISSION;
         }
     } else {
         if ($this->user->isAllowed("permission", "add")) {
             $actionEntity = new ActionEntity();
             $actionEntity->setName($values['name']);
             $actionEntity->setHumanName($values['humanName']);
             try {
                 $ent = $this->actionRepository->push($actionEntity)->save();
                 if ($ent instanceof ActionEntity || $ent === TRUE) {
                     $result = TRUE;
                 } else {
                     $result = FALSE;
                 }
             } catch (\PDOException $e) {
                 $result = $e->getMessage();
             }
         } else {
             $result = ActionForm::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,代码行数:54,代码来源:ActionForm.php

示例5: getArticles

 /**
  * @return Article[]
  */
 public function getArticles() : array
 {
     $articleFullPath = $this->getArticleFullPath();
     $result = Finder::findDirectories('*/*/*')->from($articleFullPath);
     $articles = [];
     foreach ($result as $articleDirectory) {
         /** @var SplFileInfo $articleDirectory */
         $relativePath = $this->parseRelativePath($articleDirectory);
         $article = $this->articleBuilder->getArticleFromMeta($articleDirectory, $relativePath);
         if ($this->userContext->isAllowed($article, Article::PERMISSION_VIEW)) {
             $articles[] = $article;
         }
     }
     return $articles;
 }
开发者ID:Achse,项目名称:petrhejna,代码行数:18,代码来源:ArticleReader.php

示例6: _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

示例7: Submit

 /** Submit
  * 
  * @param \Nette\Application\UI\Form $form
  */
 public function Submit(Form $form)
 {
     $json = new \stdClass();
     $json->result = "success";
     $values = $form->getValues();
     if (array_search(TRUE, (array) $values["actions"]) === FALSE) {
         $json->result = "error";
         $json->message = "Prosím vyberte alespoň jednu akci pro modul.";
     } else {
         if (!empty($values['aclResourceID'])) {
             if ($this->user->isAllowed("permission", "edit")) {
                 $result = $this->modelManager->update($values);
             } else {
                 $result = ResourceForm::PERMISSION;
             }
         } else {
             if ($this->user->isAllowed("permission", "add")) {
                 $result = $this->modelManager->insert($values);
             } else {
                 $result = ResourceForm::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,代码行数:36,代码来源:ResourceForm.php

示例8: checkMethod

 /**
  * @param \Nette\Reflection\Method $element
  */
 protected function checkMethod(Method $element)
 {
     $class = $element->class;
     $name = $element->name;
     $schema = $this->reader->getSchema($class);
     $exception = null;
     // users
     if (isset($schema[$name]['users']) && count($schema[$name]['users']) > 0) {
         $users = $schema[$name]['users'];
         if (!in_array($this->user->getId(), $users)) {
             $exception = sprintf('Access denied for your username: \'%s\'. Require: \'%s\'', $this->user->getId(), implode(', ', $users));
         } else {
             return;
         }
     } elseif (isset($schema[$name]['roles']) && count($schema[$name]['roles']) > 0) {
         $userRoles = $this->user->getRoles();
         $roles = $schema[$name]['roles'];
         if (count(array_intersect($userRoles, $roles)) == 0) {
             $exception = "Access denied for your roles: '" . implode(', ', $userRoles) . "'. Require one of: '" . implode(', ', $roles) . "'";
         } else {
             return;
         }
     } elseif (isset($schema[$name]['resource']) && $schema[$name]['resource']) {
         if (!$this->user->isAllowed($schema[$name]['resource'], $schema[$name]['privilege'])) {
             $exception = sprintf('Access denied for resource: \'%s\' and privilege: \'%s\'', $schema[$name]['resource'], $schema[$name]['privilege']);
         } else {
             return;
         }
     }
     if ($exception) {
         throw new ForbiddenRequestException($exception);
     }
 }
开发者ID:venne,项目名称:venne,代码行数:36,代码来源:ControlVerifier.php

示例9: Submit

 /** Submit
  * 
  * @param \Nette\Application\UI\Form $form
  */
 public function Submit(Form $form)
 {
     $json = new \stdClass();
     $json->result = "success";
     $values = $form->getValues();
     if (!empty($values['aclRoleID'])) {
         if ($this->user->isAllowed("permission", "edit")) {
             $result = $this->permissionManager->update($values);
         } else {
             $result = RoleForm::PERMISSION;
         }
     } else {
         if ($this->user->isAllowed("permission", "add")) {
             $result = $this->permissionManager->insert($values);
         } else {
             $result = RoleForm::PERMISSION;
         }
     }
     /*Debugger::dump($values);
     		exit();*/
     if ($result === TRUE) {
         $json->result = "success";
     } else {
         $json->result = "error";
         $json->message = $result;
     }
     $response = new JsonResponse($json);
     $this->getPresenter()->sendResponse($response);
 }
开发者ID:vipercz,项目名称:sandbox,代码行数:33,代码来源:RoleForm.php

示例10: checkResources

 protected function checkResources($element)
 {
     if ($element->hasAnnotation('resource')) {
         $resources = (array) $element->getAnnotation('resource');
         if (count($resources) != 1) {
             throw new InvalidStateException('Invalid annotation resource count!');
         }
         foreach ($resources as $resource) {
             if ($this->user->isAllowed($resource)) {
                 return true;
             }
         }
         return false;
     }
     return true;
 }
开发者ID:davefu,项目名称:PermissionChecker,代码行数:16,代码来源:AnnotationPermissionChecker.php

示例11: render

 public function render()
 {
     $this->template->setFile(__DIR__ . '/ServerList.latte');
     if ($this->user) {
         $this->template->servers = $this->serverRepo->findBy(array('user_id' => $this->user->id));
         $this->template->userId = $this->user;
         $this->template->allowedToStop = $this->user->isAllowed('commands', 'edit');
         $this->template->allowedToDelete = $this->user->isAllowed('delete', 'edit');
     } else {
         $this->template->servers = $this->serverRepo->findAll();
         $this->template->userId = FALSE;
         $this->template->allowedToStop = TRUE;
         $this->template->allowedToDelete = TRUE;
     }
     $this->template->servers->order('id');
     $this->template->registerHelper('getVersion', '\\gameUpdateModel::getVersionFromFileName');
     $this->template->render();
 }
开发者ID:VNovotna,项目名称:MP2014,代码行数:18,代码来源:ServerList.php

示例12: __construct

 public function __construct(array $config, Nette\Security\User $user)
 {
     parent::__construct($config);
     $this->processPattern(function ($value, $key) {
         return $value === NULL;
     }, function ($value, $key) use($user) {
         return $user->isAllowed('WebContent', 'Edit');
     });
 }
开发者ID:zaxxx,项目名称:zaxcms,代码行数:9,代码来源:ArticleConfig.php

示例13: addItems

 /**
  * 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;
 }
开发者ID:OCC2,项目名称:occ2pacs,代码行数:23,代码来源:TopMenu.php

示例14: create

 private function create()
 {
     $form = new Form();
     $form->addText('title', 'Titulek')->setRequired('Zadejte titulek')->setAttribute('placeholder', 'Zadejte titulek');
     if ($this->user->isAllowed(self::RES, 'moderate')) {
         $users = $this->userManager->getUserList();
         $form->addSelect('byUser', 'Za uživatele', ['0' => 'Neregistrovaný'] + $users['deleted'] + $users['allowed'])->setValue($this->user->id);
         $form->addText('byUnregUser', 'Za neregistrovaného uživatele');
     }
     $form->addTextArea('description', 'Popis')->setRequired('Zadejte popis');
     $form->addTextArea('text', 'Článek')->setRequired('Zadejte článek');
     $form->addText('keyWords', 'Klíčová slova');
     $form->addCheckbox('commentsAllow', 'Povolit komentáře');
     $form->addCheckbox('voteAllow', 'Povolit hlasování');
     $form->addUpload('photo', 'Náhledová fotka');
     if ($this->setSection) {
         $form->addSelect('underSection', 'Hlavní sekce', $this->articleManager->getMainSectionList())->setValue($this->setSection);
         if ($this->setSubsection) {
             $form->addSelect('underSubSection', 'Podsekce', $this->articleManager->getSubSectionList($this->setSection))->setValue($this->setSubsection);
             if ($this->setSerial) {
                 $form->addSelect('underSerial', 'Serial', $this->articleManager->getSerialList($this->setSubsection))->setValue($this->setSerial);
             } else {
                 $form->addSelect('underSerial', 'Serial', $this->articleManager->getSerialList($this->setSubsection))->setPrompt('Vyberte');
             }
         } else {
             $form->addSelect('underSubSection', 'Podsekce', $this->articleManager->getSubSectionList($this->setSection))->setPrompt('Vyberte podsekci');
             $form->addSelect('underSerial', 'Serial')->setPrompt('Vyberte podsekci');
         }
     } else {
         $form->addSelect('underSection', 'Hlavní sekce', $this->articleManager->getMainSectionList())->setPrompt('Vyberte hlavní sekci');
         $form->addSelect('underSubSection', 'Podsekce')->setPrompt('Vyberte hlavní sekci');
         $form->addSelect('underSerial', 'Serial')->setPrompt('Vyberte hlavní sekci');
     }
     if ($this->user->isAllowed('Section', 'moderate')) {
     }
     if ($this->user->isAllowed(self::RES, 'publish')) {
         $form->addCheckbox('published', 'Publikovaný ihned');
     }
     $form->addSubmit('submitArticle', 'Odeslat')->setValidationScope(false);
     return $form;
 }
开发者ID:kivi8,项目名称:ars-poetica,代码行数:41,代码来源:ArticleForm.php

示例15: isAllowed

 public function isAllowed($resource = IAuthorizator::ALL, $privilege = IAuthorizator::ALL)
 {
     $isAllowed = parent::isAllowed($resource, $privilege);
     if (is_array($resource)) {
         @(list($resource, $type) = $resource);
         // @ intentionally
     }
     if ($resource instanceof IUserAccessibleEntity && $isAllowed === FALSE) {
         return $resource->checkAccess($this->id, $privilege);
     }
     return $isAllowed;
 }
开发者ID:Myps,项目名称:security,代码行数:12,代码来源:User.php


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