當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。