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


PHP ReadPermissionsOptimizationUtil::securableItemLostPermissionsForUser方法代码示例

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


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

示例1: resolveExplicitReadWriteModelPermissions

 /**
  * Given a SecurableItem, add and remove permissions
  * based on what the provided ExplicitReadWriteModelPermissions indicates should be done.
  * Sets @see SecurableItem->setTreatCurrentUserAsOwnerForPermissions as true in order to ensure the current user
  * can effectively add permissions even if the current user is no longer the owner.
  * @param SecurableItem $securableItem
  * @param ExplicitReadWriteModelPermissions $explicitReadWriteModelPermissions
  * @return boolean
  * @throws NotSupportedException()
  */
 public static function resolveExplicitReadWriteModelPermissions(SecurableItem $securableItem, ExplicitReadWriteModelPermissions $explicitReadWriteModelPermissions)
 {
     assert('$securableItem->id > 0');
     $securableItem->setTreatCurrentUserAsOwnerForPermissions(true);
     $saveSecurableItem = false;
     if ($explicitReadWriteModelPermissions->getReadOnlyPermitablesCount() > 0) {
         $saveSecurableItem = true;
         foreach ($explicitReadWriteModelPermissions->getReadOnlyPermitables() as $permitable) {
             $securableItem->addPermissions($permitable, Permission::READ);
             if ($permitable instanceof Group) {
                 ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($securableItem, $permitable);
             } elseif ($permitable instanceof User) {
                 ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($securableItem, $permitable);
             } else {
                 throw new NotSupportedException();
             }
         }
     }
     if ($explicitReadWriteModelPermissions->getReadWritePermitablesCount() > 0) {
         $saveSecurableItem = true;
         foreach ($explicitReadWriteModelPermissions->getReadWritePermitables() as $permitable) {
             $securableItem->addPermissions($permitable, Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER);
             if ($permitable instanceof Group) {
                 ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($securableItem, $permitable);
             } elseif ($permitable instanceof User) {
                 ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($securableItem, $permitable);
             } else {
                 throw new NotSupportedException();
             }
         }
     }
     if ($explicitReadWriteModelPermissions->getReadOnlyPermitablesToRemoveCount() > 0) {
         $saveSecurableItem = true;
         foreach ($explicitReadWriteModelPermissions->getReadOnlyPermitablesToRemove() as $permitable) {
             $securableItem->removePermissions($permitable, Permission::READ, Permission::ALLOW);
             if ($permitable instanceof Group) {
                 ReadPermissionsOptimizationUtil::securableItemLostPermissionsForGroup($securableItem, $permitable);
             } elseif ($permitable instanceof User) {
                 ReadPermissionsOptimizationUtil::securableItemLostPermissionsForUser($securableItem, $permitable);
             } else {
                 throw new NotSupportedException();
             }
         }
     }
     if ($explicitReadWriteModelPermissions->getReadWritePermitablesToRemoveCount() > 0) {
         $saveSecurableItem = true;
         foreach ($explicitReadWriteModelPermissions->getReadWritePermitablesToRemove() as $permitable) {
             $securableItem->removePermissions($permitable, Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER, Permission::ALLOW);
             if ($permitable instanceof Group) {
                 ReadPermissionsOptimizationUtil::securableItemLostPermissionsForGroup($securableItem, $permitable);
             } elseif ($permitable instanceof User) {
                 ReadPermissionsOptimizationUtil::securableItemLostPermissionsForUser($securableItem, $permitable);
             } else {
                 throw new NotSupportedException();
             }
         }
     }
     if ($saveSecurableItem) {
         $setBackToProcess = false;
         if ($securableItem->shouldProcessWorkflowOnSave()) {
             $securableItem->setDoNotProcessWorkflowOnSave();
             $setBackToProcess = true;
         }
         $saved = $securableItem->save();
         if ($setBackToProcess) {
             $securableItem->setProcessWorkflowOnSave();
         }
         $securableItem->setTreatCurrentUserAsOwnerForPermissions(false);
         return $saved;
     }
     $securableItem->setTreatCurrentUserAsOwnerForPermissions(false);
     return true;
 }
开发者ID:youprofit,项目名称:Zurmo,代码行数:83,代码来源:ExplicitReadWriteModelPermissionsUtil.php

示例2: securableItemLostReadPermissionsForUser

 /**
  * @param SecurableItem $securableItem
  * @param User $user
  */
 public static function securableItemLostReadPermissionsForUser(SecurableItem $securableItem, User $user)
 {
     ReadPermissionsOptimizationUtil::securableItemLostPermissionsForUser($securableItem, $user);
     AllPermissionsOptimizationCache::forgetSecurableItemForRead($securableItem);
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:9,代码来源:AllPermissionsOptimizationUtil.php

示例3: testUserLosesReadOnOwnedSecurableItem_Slide7

 /**
  * @depends testGroupGivenReadOnOwnedSecurableItem_Slide6
  */
 public function testUserLosesReadOnOwnedSecurableItem_Slide7()
 {
     $u1 = User::getByUsername('u1.');
     $u2 = User::getByUsername('u2.');
     $u3 = User::getByUsername('u3.');
     Yii::app()->user->userModel = $u1;
     $a1 = new Account();
     $a1->name = 'A1.';
     $a1->addPermissions($u2, Permission::READ);
     $a1->addPermissions($u3, Permission::READ);
     $this->assertTrue($a1->save());
     //Called in OwnedSecurableItem::afterSave();
     //ReadPermissionsOptimizationUtil::ownedSecurableItemCreated($a1);
     ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($a1, $u2);
     ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($a1, $u3);
     $this->assertEquals(array(array('R2', 1), array('R3', 1), array('R5', 2), array('R6', 2), array('U2', 1), array('U3', 1)), self::getAccountMungeRows($a1));
     $this->assertTrue(self::accountMungeDoesntChangeWhenRebuilt());
     $a1->removePermissions($u2, Permission::READ);
     $this->assertTrue($a1->save());
     ReadPermissionsOptimizationUtil::securableItemLostPermissionsForUser($a1, $u2);
     $this->assertEquals(array(array('R2', 1), array('R3', 1), array('R5', 1), array('R6', 1), array('U3', 1)), self::getAccountMungeRows($a1));
     $this->assertTrue(self::accountMungeDoesntChangeWhenRebuilt());
     $a1->removePermissions($u3, Permission::READ);
     $this->assertTrue($a1->save());
     ReadPermissionsOptimizationUtil::securableItemLostPermissionsForUser($a1, $u3);
     $this->assertEquals(array(array('R2', 1), array('R3', 1)), self::getAccountMungeRows($a1));
     $this->assertTrue(self::accountMungeDoesntChangeWhenRebuilt());
     $a1->delete();
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:32,代码来源:AccountReadPermissionsOptimizationScenariosTest.php


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