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


PHP UserRole::getPermissionNames方法代码示例

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


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

示例1: getPermissionsFromDb

 /**
  * Init permission items map from DB for the given role
  * @param UserRole $dbRole
  */
 private static function getPermissionsFromDb($dbRole)
 {
     $map = self::initEmptyMap();
     // get all permission object names from role record
     if ($dbRole) {
         $tmpPermissionNames = $dbRole->getPermissionNames(true);
         $tmpPermissionNames = array_map('trim', explode(',', $tmpPermissionNames));
     } else {
         $tmpPermissionNames = array();
     }
     // add always allowed permissions
     if (self::$operatingPartner) {
         $alwaysAllowed = self::$operatingPartner->getAlwaysAllowedPermissionNames();
         $alwaysAllowed = array_map('trim', explode(',', $alwaysAllowed));
     } else {
         $alwaysAllowed = array(PermissionName::ALWAYS_ALLOWED_ACTIONS);
     }
     $tmpPermissionNames = array_merge($tmpPermissionNames, $alwaysAllowed);
     // if the request sent from the internal server set additional permission allowing access without KS
     // from internal servers
     if (kIpAddressUtils::isInternalIp()) {
         KalturaLog::debug('IP in range, adding ALWAYS_ALLOWED_FROM_INTERNAL_IP_ACTIONS permission');
         $alwaysAllowedInternal = array(PermissionName::ALWAYS_ALLOWED_FROM_INTERNAL_IP_ACTIONS);
         $tmpPermissionNames = array_merge($tmpPermissionNames, $alwaysAllowedInternal);
     }
     $permissionNames = array();
     foreach ($tmpPermissionNames as $name) {
         $permissionNames[$name] = $name;
     }
     $map[self::PERMISSION_NAMES_ARRAY] = $permissionNames;
     // get mapping of permissions to permission items
     $c = new Criteria();
     $c->addAnd(PermissionPeer::NAME, $permissionNames, Criteria::IN);
     $c->addAnd(PermissionPeer::PARTNER_ID, array(strval(PartnerPeer::GLOBAL_PARTNER), strval(self::$operatingPartnerId)), Criteria::IN);
     $c->addAnd(PermissionItemPeer::PARTNER_ID, array(strval(PartnerPeer::GLOBAL_PARTNER), strval(self::$operatingPartnerId)), Criteria::IN);
     $lookups = PermissionToPermissionItemPeer::doSelectJoinAll($c);
     foreach ($lookups as $lookup) {
         $item = $lookup->getPermissionItem();
         $permission = $lookup->getPermission();
         if (!$item) {
             KalturaLog::err('PermissionToPermissionItem id [' . $lookup->getId() . '] is defined with PermissionItem id [' . $lookup->getPermissionItemId() . '] which does not exists!');
             continue;
         }
         if (!$permission) {
             KalturaLog::err('PermissionToPermissionItem id [' . $lookup->getId() . '] is defined with Permission name [' . $lookup->getPermissionName() . '] which does not exists!');
             continue;
         }
         // organize permission items in local arrays
         $type = $item->getType();
         if ($type == PermissionItemType::API_ACTION_ITEM) {
             self::addApiAction($map, $item);
         } else {
             if ($type == PermissionItemType::API_PARAMETER_ITEM) {
                 self::addApiParameter($map, $item);
             }
         }
     }
     // set partner group permission
     $c = new Criteria();
     $c->addAnd(PermissionPeer::PARTNER_ID, self::$operatingPartnerId, Criteria::EQUAL);
     $c->addAnd(PermissionPeer::TYPE, PermissionType::PARTNER_GROUP, Criteria::EQUAL);
     $partnerGroupPermissions = PermissionPeer::doSelect($c);
     foreach ($partnerGroupPermissions as $pgPerm) {
         self::addPartnerGroupAction($map, $pgPerm);
     }
     return $map;
 }
开发者ID:kubrickfr,项目名称:server,代码行数:71,代码来源:kPermissionManager.php


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