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


PHP Player::hasPermission方法代码示例

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


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

示例1: testRoleModification

 public function testRoleModification()
 {
     $role = new Role(Role::ADMINISTRATOR);
     $this->assertTrue($role->hasPerm(Permission::PUBLISH_NEWS));
     $this->assertFalse($this->player->hasPermission(Permission::PUBLISH_NEWS));
     $this->player->addRole($role);
     $this->assertTrue($this->player->hasPermission(Permission::PUBLISH_NEWS));
 }
开发者ID:kleitz,项目名称:bzion,代码行数:8,代码来源:PlayerTest.php

示例2: wipeAction

 public function wipeAction(Player $me)
 {
     $wipeable = array('Ban', 'Map', 'Match', 'News', 'NewsCategory', 'Page', 'Server', 'Team');
     $models = array();
     foreach ($wipeable as $type) {
         if (!$me->hasPermission($type::HARD_DELETE_PERMISSION)) {
             continue;
         }
         $models = array_merge($models, $type::getQueryBuilder()->where('status')->equals('deleted')->getModels());
     }
     return array('models' => $models);
 }
开发者ID:allejo,项目名称:bzion,代码行数:12,代码来源:AdminController.php

示例3: showAction

 public function showAction(Player $player, Player $me, Request $request)
 {
     if ($me->hasPermission(Permission::VIEW_VISITOR_LOG)) {
         $this->creator = new FormCreator($player);
         $form = $this->creator->create()->handleRequest($request);
         if ($form->isValid()) {
             $form = $this->handleAdminNotesForm($form, $player, $me);
         }
         $formView = $form->createView();
     } else {
         // Don't spend time rendering the form unless we need it
         $formView = null;
     }
     return array("player" => $player, "adminNotesForm" => $formView);
 }
开发者ID:bchhun,项目名称:bzion,代码行数:15,代码来源:PlayerController.php

示例4: playerByBzidAction

 public function playerByBzidAction(Player $me, Request $request, FlashBag $flashBag, $bzid = null)
 {
     if (!$me->hasPermission(Permission::VIEW_VISITOR_LOG)) {
         throw new ForbiddenException();
     }
     if ($bzid === null) {
         if (!$request->query->has('bzid')) {
             throw new BadRequestException("Please provide the BZID to search for");
         }
         $bzid = $request->query->get('bzid');
     }
     $player = Player::getFromBZID($bzid);
     if (!$player->isValid()) {
         $flashBag->add('error', "Player with BZID {$bzid} not found");
         return $this->goBack();
     }
     return new RedirectResponse($player->getURL());
 }
开发者ID:allejo,项目名称:bzion,代码行数:18,代码来源:SearchController.php

示例5: addPlayer

 public function addPlayer(Player $player)
 {
     if (count($this->players) >= $this->maxPlayers) {
         if ($player->hasPermission("sg.perks.join-full")) {
             // Players who have the correct permissions can join even when arenas are full.
             $m = count($this->players);
             $kick = array_keys($this->players)[rand(0, $m - 1)];
             $this->kickPlayer($this->players[$kick]["obj"], "Making space for " . $player->getName());
         } else {
             return false;
         }
     }
     $this->players[$player->getName()]["obj"] = $player;
     $this->players[$player->getName()]["pos"] = new Vector3($player->getX(), $player->getY(), $player->getZ());
     $this->players[$player->getName()]["level"] = $player->getLevel();
     $this->players[$player->getName()]["inventory"] = $player->getInventory();
     return true;
 }
开发者ID:100henrik100,项目名称:SurvivalGames,代码行数:18,代码来源:Arena.php

示例6: visibleTo

 /**
  * Make sure that Models invisible to a player are not returned
  *
  * Note that this method does not take PermissionModel::canBeSeenBy() into
  * consideration for performance purposes, so you will have to override this
  * in your query builder if necessary.
  *
  * @param  Player  $player      The player in question
  * @param  bool $showDeleted false to hide deleted models even from admins
  * @return self
  */
 public function visibleTo($player, $showDeleted = false)
 {
     $type = $this->type;
     if (is_subclass_of($type, "PermissionModel") && $player->hasPermission($type::EDIT_PERMISSION)) {
         // The player is an admin who can see hidden models
         if ($showDeleted) {
             return $this;
         } else {
             return $this->where('status')->notEquals('deleted');
         }
     } else {
         return $this->active();
     }
 }
开发者ID:blast007,项目名称:bzion,代码行数:25,代码来源:QueryBuilder.php

示例7: sendMessage

 /**
  * Sends a message to a group
  *
  * @throws HTTPException Thrown if the user doesn't have the
  *                              SEND_PRIVATE_MSG permission
  * @param  Player        $from   The sender
  * @param  Group         $to     The group that will receive the message
  * @param  Form          $form   The message's form
  * @param  Form          $form   The form before it handled the request
  * @param  Form          $cloned
  * @return void
  */
 private function sendMessage(Player $from, Group $to, &$form, $cloned)
 {
     if (!$from->hasPermission(Permission::SEND_PRIVATE_MSG)) {
         throw new ForbiddenException("You are not allowed to send messages");
     }
     $message = $form->get('message')->getData();
     $message = $to->sendMessage($from, $message);
     $this->getFlashBag()->add('success', "Your message was sent successfully");
     // Let javascript know the message's ID
     $this->attributes->set('id', $message->getId());
     // Reset the form
     $form = $cloned;
     // Notify everyone that we sent a new message
     $event = new NewMessageEvent($message, false);
     $this->dispatch(Events::MESSAGE_NEW, $event);
 }
开发者ID:kleitz,项目名称:bzion,代码行数:28,代码来源:MessageController.php

示例8: canBeHardDeletedBy

 /**
  * Find out whether a player can delete this model
  *
  * If possible, prefer to override PermissionModel::HARD_DELETE_PERMISSION
  *
  * @param  Player  $player
  * @return boolean
  */
 public function canBeHardDeletedBy($player)
 {
     return $player->hasPermission(static::HARD_DELETE_PERMISSION);
 }
开发者ID:kleitz,项目名称:bzion,代码行数:12,代码来源:PermissionModel.php

示例9: addNews

 /**
  * Add a new news article
  *
  * @param string $subject    The subject of the article
  * @param string $content    The content of the article
  * @param int    $authorID   The ID of the author
  * @param int    $categoryId The ID of the category this article will be published under
  * @param string $status     The status of the article: 'published', 'disabled', or 'deleted'
  *
  * @internal param int $categoryID The ID of the category
  * @return News|bool An object representing the article that was just created or false if the article was not created
  */
 public static function addNews($subject, $content, $authorID, $categoryId = 1, $status = 'published')
 {
     $author = new Player($authorID);
     // Only allow real players to post news articles and if the player posting has permissions to create new posts
     if ($author->isValid() && $author->hasPermission(Permission::PUBLISH_NEWS)) {
         return self::create(array('category' => $categoryId, 'subject' => $subject, 'content' => $content, 'author' => $authorID, 'editor' => $authorID, 'status' => $status), 'issiis', array('created', 'updated'));
     }
     return false;
 }
开发者ID:kleitz,项目名称:bzion,代码行数:21,代码来源:News.php


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