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


PHP Acl::setPermission方法代码示例

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


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

示例1: parseRule

 private function parseRule($line)
 {
     $arr = preg_split("/[=]+/", $line, 2);
     if (count($arr) != 2) {
         GitoliteException::throwInvalidRule($line);
     }
     $acl_split = preg_split("/[\\s\t]+/", trim($arr[0]), 2);
     $refexes = isset($acl_split[1]) ? $acl_split[1] : false;
     $acl = new Acl();
     $acl->setPermission($acl_split[0]);
     if ($refexes) {
         $acl->setRefexes($refexes);
     }
     $users = preg_split("/[\\s\t]+/", trim($arr[1]));
     foreach ($users as $user) {
         if (self::isTeam($user)) {
             if (!$this->getTeam($user)) {
                 GitoliteException::throwUndefinedTeam($user);
             }
             foreach ($this->getTeamAsUser($user)->items as $userModel) {
                 $acl->addUser($userModel);
                 $this->addUser($userModel);
             }
         } else {
             if (!($userModel = $this->getUser($user))) {
                 $userModel = new User();
                 $userModel->setName($user);
                 $this->addUser($userModel);
             }
             $acl->addUser($userModel);
         }
     }
     return $acl;
 }
开发者ID:carono,项目名称:gitolite-reader,代码行数:34,代码来源:Gitolite.php

示例2: import

 /**
  * Import gitolite.conf
  *
  */
 public function import()
 {
     $file = file($this->getGitLocalRepositoryPath() . DIRECTORY_SEPARATOR . self::GITOLITE_CONF_DIR . DIRECTORY_SEPARATOR . self::GITOLITE_CONF_FILE);
     foreach ($file as $line) {
         $line = trim($line);
         if ($line == '') {
             continue;
         }
         if (preg_match('/^[@]/', $line)) {
             $line_split = preg_split("/[=]+/", $line, 2);
             if (count($line_split) != 2) {
                 throw new \Exception('Invalid team def.');
             }
             $team_name = substr(trim($line_split[0]), 1);
             $team = new Team();
             $team->setName($team_name);
             $usr = preg_split("/[\\s\t]+/", trim($line_split[1]));
             foreach ($usr as $u) {
                 // is team
                 if (substr($u, 0, 1) == '@') {
                     $u = substr($u, 1);
                     if (!isset($this->teams[$u])) {
                         throw new \Exception('Undef team.');
                     }
                     $team->addTeam($this->teams[$u]);
                 } else {
                     if (isset($this->users[$u])) {
                         $team->addUser($this->users[$u]);
                     } else {
                         $user = new User();
                         $user->setUsername($u);
                         $key = $this->getGitLocalRepositoryPath() . DIRECTORY_SEPARATOR . self::GITOLITE_KEY_DIR . DIRECTORY_SEPARATOR . $user->renderKeyFileName();
                         if (file_exists($key)) {
                             $user->addKey(file_get_contents($key));
                         }
                         $this->users[$u] = $user;
                         $team->addUser($user);
                     }
                 }
             }
             $this->teams[$team_name] = $team;
         } elseif (preg_match('/^repo/', $line)) {
             $line_split = preg_split("/[\\s\t]+/", $line, 2);
             if (count($line_split) != 2) {
                 throw new \Exception('Invalid repository def.');
             }
             $repo = new Repo();
             $repo->setName(trim($line_split[1]));
         } elseif (preg_match('/^(R|RW|RW\\+|\\-|RWC|RW\\+C|RWD|RW\\+D|RWCD|RW\\+CD|RWDC|RW\\+DC)/', $line)) {
             $teams = array();
             $users = array();
             $line_split = preg_split("/[=]+/", $line, 2);
             if (count($line_split) != 2) {
                 throw new \FuelException('Invalid rule.');
             }
             $acl_split = preg_split("/[\\s\t]+/", trim($line_split[0]), 2);
             $refexes = isset($acl_split[1]) ? $acl_split[1] : false;
             $acl = new Acl();
             $acl->setPermission($acl_split[0]);
             if ($refexes) {
                 $acl->setRefexes($refexes);
             }
             $usr = preg_split("/[\\s\t]+/", trim($line_split[1]));
             foreach ($usr as $u) {
                 // is team
                 if (substr($u, 0, 1) == '@') {
                     $u = substr($u, 1);
                     if (!isset($this->teams[$u])) {
                         throw new \Exception('Undef. team');
                     }
                     $acl->addTeam($this->teams[$u]);
                 } else {
                     if (!isset($this->users[$u])) {
                         $this->users[$u] = new User();
                         $this->users[$u]->setUsername($u);
                         $key = $this->getGitLocalRepositoryPath() . DIRECTORY_SEPARATOR . self::GITOLITE_KEY_DIR . DIRECTORY_SEPARATOR . $this->users[$u]->renderKeyFileName();
                         if (file_exists($key)) {
                             $this->users[$u]->addKey(file_get_contents($key));
                         }
                     }
                     $acl->addUser($this->users[$u]);
                 }
             }
             $repo->addAcl($acl);
             $this->repos[$repo->getName()] = $repo;
         }
     }
 }
开发者ID:rafaelgou,项目名称:gitolite-php,代码行数:92,代码来源:Gitolite.php


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