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


PHP RedBeanModel::getSubset方法代码示例

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


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

示例1: rebuildViaSlowWay

 protected static function rebuildViaSlowWay($modelClassName)
 {
     // The slow way will remain here as documentation
     // for what the optimized way is doing.
     $mungeTableName = self::getMungeTableName($modelClassName);
     self::recreateTable($mungeTableName);
     //Specifically call RedBeanModel to avoid the use of the security in OwnedSecurableItem since for
     //rebuild it needs to look at all models regardless of permissions of the current user.
     $modelCount = RedBeanModel::getCount(null, null, $modelClassName);
     $subset = intval($modelCount / 20);
     if ($subset < 100) {
         $subset = 100;
     } elseif ($subset > 1000) {
         $subset = 1000;
     }
     $users = User::getAll();
     $groups = Group::getAll();
     $roles = Role::getAll();
     for ($i = 0; $i < $modelCount; $i += $subset) {
         //Specifically call RedBeanModel to avoid the use of the security in OwnedSecurableItem since for
         //rebuild it needs to look at all models regardless of permissions of the current user.
         $models = RedBeanModel::getSubset(null, $i, $subset, null, null, $modelClassName);
         foreach ($models as $model) {
             assert('$model instanceof SecurableItem');
             $securableItemId = $model->getClassId('SecurableItem');
             foreach ($users as $user) {
                 list($allowPermissions, $denyPermissions) = $model->getExplicitActualPermissions($user);
                 $effectiveExplicitPermissions = $allowPermissions & ~$denyPermissions;
                 if (($effectiveExplicitPermissions & Permission::READ) == Permission::READ) {
                     self::incrementCount($mungeTableName, $securableItemId, $user);
                 }
             }
             foreach ($groups as $group) {
                 list($allowPermissions, $denyPermissions) = $model->getExplicitActualPermissions($group);
                 $effectiveExplicitPermissions = $allowPermissions & ~$denyPermissions;
                 if (($effectiveExplicitPermissions & Permission::READ) == Permission::READ) {
                     self::incrementCount($mungeTableName, $securableItemId, $group);
                     foreach ($group->users as $user) {
                         if ($user->role->id > 0) {
                             self::incrementParentRolesCounts($mungeTableName, $securableItemId, $user->role);
                         }
                     }
                     foreach ($group->groups as $subGroup) {
                         self::processNestedGroupWhereParentHasReadPermissionOnSecurableItem($mungeTableName, $securableItemId, $subGroup);
                     }
                 }
             }
             foreach ($roles as $role) {
                 $count = self::getRoleMungeCount($model, $role);
                 assert('$count >= 0');
                 if ($count > 0) {
                     self::setCount($mungeTableName, $securableItemId, $role, $count);
                 }
             }
         }
     }
 }
开发者ID:sandeep1027,项目名称:zurmo_,代码行数:57,代码来源:ReadPermissionsOptimizationUtil.php


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