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


PHP AllPermissionsOptimizationUtil::securableItemLostReadPermissionsForGroup方法代码示例

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


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

示例1: testRegularUserControllerActionsWithElevationToModels


//.........这里部分代码省略.........
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/edit');
     $this->setGetArray(array('id' => $meeting3->id));
     $this->resetPostArray();
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/delete');
     //give parentGroup access to READ
     Yii::app()->user->userModel = $super;
     $meeting3->addPermissions($parentGroup, Permission::READ);
     $this->assertTrue($meeting3->save());
     AllPermissionsOptimizationUtil::securableItemGivenReadPermissionsForGroup($meeting3, $parentGroup);
     //Test userInParentGroup, access to meetings details should not fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $meeting3->id));
     $this->runControllerWithNoExceptionsAndGetContent('meetings/default/details');
     //Test userInParentGroup, access to meetings edit and delete should fail.
     $this->setGetArray(array('id' => $meeting3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/edit');
     $this->setGetArray(array('id' => $meeting3->id));
     $this->resetPostArray();
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/delete');
     //Test userInChildGroup, access to meetings details should not fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $meeting3->id));
     $this->runControllerWithNoExceptionsAndGetContent('meetings/default/details');
     //Test userInChildGroup, access to meetings edit and delete should fail.
     $this->setGetArray(array('id' => $meeting3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/edit');
     $this->setGetArray(array('id' => $meeting3->id));
     $this->resetPostArray();
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/delete');
     //give parentGroup access to read and write
     Yii::app()->user->userModel = $super;
     $meeting3->addPermissions($parentGroup, Permission::READ_WRITE_CHANGE_PERMISSIONS);
     $this->assertTrue($meeting3->save());
     AllPermissionsOptimizationUtil::securableItemLostReadPermissionsForGroup($meeting3, $parentGroup);
     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($meeting3, $parentGroup);
     //Test userInParentGroup, access to edit meetings should not fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $meeting3->id));
     $this->runControllerWithNoExceptionsAndGetContent('meetings/default/edit');
     //Test userInParentGroup, access to meetings delete should fail.
     $this->setGetArray(array('id' => $meeting3->id));
     $this->resetPostArray();
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/delete');
     //Test userInChildGroup, access to edit meetings should not fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->logoutCurrentUserLoginNewUserAndGetByUsername($userInChildGroup->username);
     $this->setGetArray(array('id' => $meeting3->id));
     $this->runControllerWithNoExceptionsAndGetContent('meetings/default/edit');
     //Test userInChildGroup, access to meetings delete should fail.
     $this->setGetArray(array('id' => $meeting3->id));
     $this->resetPostArray();
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/delete');
     //revoke parentGroup access to meetings read and write
     Yii::app()->user->userModel = $super;
     $meeting3->removePermissions($parentGroup, Permission::READ_WRITE_CHANGE_PERMISSIONS);
     $this->assertTrue($meeting3->save());
     AllPermissionsOptimizationUtil::securableItemLostPermissionsForGroup($meeting3, $parentGroup);
     //Test userInChildGroup, access to meetings detail, edit and delete should fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $meeting3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/details');
     $this->setGetArray(array('id' => $meeting3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/edit');
     $this->setGetArray(array('id' => $meeting3->id));
     $this->resetPostArray();
     $this->runControllerShouldResultInAccessFailureAndGetContent('meetings/default/delete');
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:67,代码来源:MeetingsRegularUserWalkthroughTest.php

示例2: testRegularUserControllerActionsWithElevationToModels


//.........这里部分代码省略.........
     $childGroup = new Group();
     $childGroup->name = 'BBB';
     $this->assertTrue($childGroup->save());
     $userInChildGroup = User::getByUsername('confused');
     $userInParentGroup = User::getByUsername('nobody');
     $childGroup->users->add($userInChildGroup);
     $this->assertTrue($childGroup->save());
     $parentGroup->users->add($userInParentGroup);
     $parentGroup->groups->add($childGroup);
     $this->assertTrue($parentGroup->save());
     $parentGroup->forget();
     $childGroup->forget();
     $parentGroup = Group::getByName('AAA');
     $childGroup = Group::getByName('BBB');
     //Add access for the confused user to Products and creation of Products.
     $userInChildGroup->setRight('ProjectsModule', ProjectsModule::RIGHT_ACCESS_PROJECTS);
     $userInChildGroup->setRight('ProjectsModule', ProjectsModule::RIGHT_CREATE_PROJECTS);
     $this->assertTrue($userInChildGroup->save());
     //create project owned by super
     $project3 = ProjectTestHelper::createProjectByNameForOwner('testingParentGroupPermission', $super);
     //Test userInParentGroup, access to details and edit should fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('projects/default/details');
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('projects/default/edit');
     //Test userInChildGroup, access to details and edit should fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('projects/default/details');
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('projects/default/edit');
     //give parentGroup access to READ
     Yii::app()->user->userModel = $super;
     $project3->addPermissions($parentGroup, Permission::READ);
     $this->assertTrue($project3->save());
     AllPermissionsOptimizationUtil::securableItemGivenReadPermissionsForGroup($project3, $parentGroup);
     //Test userInParentGroup, access to details should not fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerWithNoExceptionsAndGetContent('projects/default/details');
     //Test userInChildGroup, access to details should not fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerWithNoExceptionsAndGetContent('projects/default/details');
     $projectId = $project3->id;
     $project3->forget();
     $project3 = Project::getById($projectId);
     //give parentGroup access to read and write
     Yii::app()->user->userModel = $super;
     $project3->addPermissions($parentGroup, Permission::READ_WRITE_CHANGE_PERMISSIONS);
     $this->assertTrue($project3->save());
     AllPermissionsOptimizationUtil::securableItemLostReadPermissionsForGroup($project3, $parentGroup);
     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($project3, $parentGroup);
     //Test userInParentGroup, access to edit should not fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerWithNoExceptionsAndGetContent('projects/default/edit');
     //Test userInChildGroup, access to edit should not fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->logoutCurrentUserLoginNewUserAndGetByUsername($userInChildGroup->username);
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerWithNoExceptionsAndGetContent('projects/default/edit');
     $projectId = $project3->id;
     $project3->forget();
     $project3 = Project::getById($projectId);
     //revoke parentGroup access to read and write
     Yii::app()->user->userModel = $super;
     $project3->addPermissions($parentGroup, Permission::READ_WRITE_CHANGE_PERMISSIONS, Permission::DENY);
     $this->assertTrue($project3->save());
     AllPermissionsOptimizationUtil::securableItemLostPermissionsForGroup($project3, $parentGroup);
     //Test userInChildGroup, access to detail should fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('projects/default/details');
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('projects/default/edit');
     //Test userInParentGroup, access to detail should fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('projects/default/details');
     $this->setGetArray(array('id' => $project3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('projects/default/edit');
     //clear up the role relationships between users so not to effect next assertions
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $userInParentGroup->forget();
     $userInChildGroup->forget();
     $childGroup->forget();
     $parentGroup->forget();
     $userInParentGroup = User::getByUsername('nobody');
     $userInChildGroup = User::getByUsername('confused');
     $childGroup = Group::getByName('BBB');
     $parentGroup = Group::getByName('AAA');
     //clear up the role relationships between users so not to effect next assertions
     $parentGroup->users->remove($userInParentGroup);
     $parentGroup->groups->remove($childGroup);
     $this->assertTrue($parentGroup->save());
     $childGroup->users->remove($userInChildGroup);
     $this->assertTrue($childGroup->save());
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:101,代码来源:ProjectsRegularUserWalkthroughTest.php

示例3: testRegularUserControllerActionsWithElevationToModels


//.........这里部分代码省略.........
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/delete');
     //Test userInChildGroup, access to details, edit and delete should fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/details');
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/edit');
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/delete');
     //give parentGroup access to READ
     Yii::app()->user->userModel = $super;
     $lead3->addPermissions($parentGroup, Permission::READ);
     $this->assertTrue($lead3->save());
     AllPermissionsOptimizationUtil::securableItemGivenReadPermissionsForGroup($lead3, $parentGroup);
     //Test userInParentGroup, access to details should not fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerWithNoExceptionsAndGetContent('leads/default/details');
     //Test userInParentGroup, access to delete should fail.
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/edit');
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/delete');
     //Test userInChildGroup, access to edit and details should not fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerWithNoExceptionsAndGetContent('leads/default/details');
     //Test userInChildGroup, access to edit and delete should fail.
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/edit');
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/delete');
     //give parentGroup access to read and write
     Yii::app()->user->userModel = $super;
     $lead3->addPermissions($parentGroup, Permission::READ_WRITE_CHANGE_PERMISSIONS);
     $this->assertTrue($lead3->save());
     AllPermissionsOptimizationUtil::securableItemLostReadPermissionsForGroup($lead3, $parentGroup);
     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($lead3, $parentGroup);
     //Test userInParentGroup, access to edit should not fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerWithNoExceptionsAndGetContent('leads/default/edit');
     //Test userInParentGroup, access to delete should fail.
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/delete');
     //Test userInChildGroup, access to edit should not fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->logoutCurrentUserLoginNewUserAndGetByUsername($userInChildGroup->username);
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerWithNoExceptionsAndGetContent('leads/default/edit');
     //Test userInChildGroup, access to delete should fail.
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/delete');
     //revoke parentGroup access to read and write
     Yii::app()->user->userModel = $super;
     $lead3->removePermissions($parentGroup, Permission::READ_WRITE_CHANGE_PERMISSIONS);
     $this->assertTrue($lead3->save());
     AllPermissionsOptimizationUtil::securableItemLostPermissionsForGroup($lead3, $parentGroup);
     //Test userInChildGroup, access to detail, edit and delete should fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/details');
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/edit');
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/delete');
     //Test userInParentGroup, access to detail, edit and delete should fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/details');
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/edit');
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('leads/default/delete');
     //give parentGroup access to read, write and delete
     Yii::app()->user->userModel = $super;
     $lead3->addPermissions($parentGroup, Permission::READ_WRITE_DELETE);
     $this->assertTrue($lead3->save());
     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($lead3, $parentGroup);
     //Test userInChildGroup, access to delete should not fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->logoutCurrentUserLoginNewUserAndGetByUsername($userInChildGroup->username);
     $this->setGetArray(array('id' => $lead3->id));
     $this->runControllerWithRedirectExceptionAndGetContent('leads/default/delete', Yii::app()->createUrl('leads/default/index'));
     //clear up the role relationships between users so not to effect next assertions
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $userInParentGroup->forget();
     $userInChildGroup->forget();
     $childGroup->forget();
     $parentGroup->forget();
     $userInParentGroup = User::getByUsername('nobody');
     $userInChildGroup = User::getByUsername('confused');
     $childGroup = Group::getByName('BBB');
     $parentGroup = Group::getByName('AAA');
     $parentGroup->users->remove($userInParentGroup);
     $parentGroup->groups->remove($childGroup);
     $this->assertTrue($parentGroup->save());
     $childGroup->users->remove($userInChildGroup);
     $this->assertTrue($childGroup->save());
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:101,代码来源:LeadsRegularUserWalkthroughTest.php

示例4: testRegularUserControllerActionsWithElevationToModels


//.........这里部分代码省略.........
     $childGroup = new Group();
     $childGroup->name = 'BBB';
     $this->assertTrue($childGroup->save());
     $userInChildGroup = User::getByUsername('confused');
     $userInParentGroup = User::getByUsername('nobody');
     $childGroup->users->add($userInChildGroup);
     $this->assertTrue($childGroup->save());
     $parentGroup->users->add($userInParentGroup);
     $parentGroup->groups->add($childGroup);
     $this->assertTrue($parentGroup->save());
     $parentGroup->forget();
     $childGroup->forget();
     $parentGroup = Group::getByName('AAA');
     $childGroup = Group::getByName('BBB');
     //Add access for the confused user to ContactWebForms and creation of ContactWebForms.
     $userInChildGroup->setRight('ContactWebFormsModule', ContactWebFormsModule::RIGHT_ACCESS_CONTACT_WEB_FORMS);
     $userInChildGroup->setRight('ContactWebFormsModule', ContactWebFormsModule::RIGHT_CREATE_CONTACT_WEB_FORMS);
     $this->assertTrue($userInChildGroup->save());
     //create web form owned by super
     $contactWebForm3 = ContactWebFormTestHelper::createContactWebFormByName('testingParentGroupPermission', $super);
     //Test userInParentGroup, access to details and edit should fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('contactWebForms/default/details');
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('contactWebForms/default/edit');
     //Test userInChildGroup, access to details and edit should fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('contactWebForms/default/details');
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('contactWebForms/default/edit');
     //give parentGroup access to READ
     Yii::app()->user->userModel = $super;
     $contactWebForm3->addPermissions($parentGroup, Permission::READ);
     $this->assertTrue($contactWebForm3->save());
     AllPermissionsOptimizationUtil::securableItemGivenReadPermissionsForGroup($contactWebForm3, $parentGroup);
     //Test userInParentGroup, access to details should not fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/details');
     //Test userInChildGroup, access to details should not fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/details');
     $contactWebFormId = $contactWebForm3->id;
     $contactWebForm3->forget();
     $contactWebForm3 = ContactWebForm::getById($contactWebFormId);
     //give parentGroup access to read and write
     Yii::app()->user->userModel = $super;
     $contactWebForm3->addPermissions($parentGroup, Permission::READ_WRITE_CHANGE_PERMISSIONS);
     $this->assertTrue($contactWebForm3->save());
     AllPermissionsOptimizationUtil::securableItemLostReadPermissionsForGroup($contactWebForm3, $parentGroup);
     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($contactWebForm3, $parentGroup);
     //Test userInParentGroup, access to edit should not fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/edit');
     //Test userInChildGroup, access to edit should not fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->logoutCurrentUserLoginNewUserAndGetByUsername($userInChildGroup->username);
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerWithNoExceptionsAndGetContent('contactWebForms/default/edit');
     $contactWebFormId = $contactWebForm3->id;
     $contactWebForm3->forget();
     $contactWebForm3 = ContactWebForm::getById($contactWebFormId);
     //revoke parentGroup access to read and write
     Yii::app()->user->userModel = $super;
     $contactWebForm3->removePermissions($parentGroup, Permission::READ_WRITE_CHANGE_PERMISSIONS);
     $this->assertTrue($contactWebForm3->save());
     AllPermissionsOptimizationUtil::securableItemLostPermissionsForGroup($contactWebForm3, $parentGroup);
     //Test userInChildGroup, access to detail should fail.
     Yii::app()->user->userModel = $userInChildGroup;
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('contactWebForms/default/details');
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('contactWebForms/default/edit');
     //Test userInParentGroup, access to detail should fail.
     Yii::app()->user->userModel = $userInParentGroup;
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('contactWebForms/default/details');
     $this->setGetArray(array('id' => $contactWebForm3->id));
     $this->runControllerShouldResultInAccessFailureAndGetContent('contactWebForms/default/edit');
     //clear up the role relationships between users so not to effect next assertions
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $userInParentGroup->forget();
     $userInChildGroup->forget();
     $childGroup->forget();
     $parentGroup->forget();
     $userInParentGroup = User::getByUsername('nobody');
     $userInChildGroup = User::getByUsername('confused');
     $childGroup = Group::getByName('BBB');
     $parentGroup = Group::getByName('AAA');
     //clear up the role relationships between users so not to effect next assertions
     $parentGroup->users->remove($userInParentGroup);
     $parentGroup->groups->remove($childGroup);
     $this->assertTrue($parentGroup->save());
     $childGroup->users->remove($userInChildGroup);
     $this->assertTrue($childGroup->save());
 }
开发者ID:maruthisivaprasad,项目名称:zurmo,代码行数:101,代码来源:ContactWebFormsRegularUserWalkthroughTest.php

示例5: 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
  * @param bool $validate
  * @return bool|void
  * @throws NotSupportedException
  */
 public static function resolveExplicitReadWriteModelPermissions(SecurableItem $securableItem, ExplicitReadWriteModelPermissions $explicitReadWriteModelPermissions, $validate = false)
 {
     assert('$securableItem->id > 0');
     $optimizeReadPermissions = $securableItem::hasReadPermissionsOptimization();
     $securableItem->setTreatCurrentUserAsOwnerForPermissions(true);
     $saveSecurableItem = false;
     if ($explicitReadWriteModelPermissions->getReadOnlyPermitablesCount() > 0) {
         $saveSecurableItem = true;
         foreach ($explicitReadWriteModelPermissions->getReadOnlyPermitables() as $permitable) {
             if ($securableItem->addPermissions($permitable, Permission::READ) && $optimizeReadPermissions) {
                 if ($permitable instanceof Group) {
                     AllPermissionsOptimizationUtil::securableItemGivenReadPermissionsForGroup($securableItem, $permitable);
                     ReadPermissionsSubscriptionUtil::securableItemGivenPermissionsForGroup($securableItem);
                 } elseif ($permitable instanceof User) {
                     AllPermissionsOptimizationUtil::securableItemGivenReadPermissionsForUser($securableItem, $permitable);
                     ReadPermissionsSubscriptionUtil::securableItemGivenPermissionsForUser($securableItem);
                 } else {
                     throw new NotSupportedException();
                 }
             }
         }
     }
     if ($explicitReadWriteModelPermissions->getReadWritePermitablesCount() > 0) {
         $saveSecurableItem = true;
         foreach ($explicitReadWriteModelPermissions->getReadWritePermitables() as $permitable) {
             if ($securableItem->addPermissions($permitable, Permission::READ_WRITE_CHANGE_PERMISSIONS_CHANGE_OWNER) && $optimizeReadPermissions) {
                 if ($permitable instanceof Group) {
                     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForGroup($securableItem, $permitable);
                     ReadPermissionsSubscriptionUtil::securableItemGivenPermissionsForGroup($securableItem);
                 } elseif ($permitable instanceof User) {
                     AllPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($securableItem, $permitable);
                     ReadPermissionsSubscriptionUtil::securableItemGivenPermissionsForUser($securableItem);
                 } else {
                     throw new NotSupportedException();
                 }
             }
         }
     }
     if ($explicitReadWriteModelPermissions->getReadOnlyPermitablesToRemoveCount() > 0) {
         $saveSecurableItem = true;
         foreach ($explicitReadWriteModelPermissions->getReadOnlyPermitablesToRemove() as $permitable) {
             $securableItem->removePermissions($permitable, Permission::READ, Permission::ALLOW);
             if ($optimizeReadPermissions) {
                 if ($permitable instanceof Group) {
                     AllPermissionsOptimizationUtil::securableItemLostReadPermissionsForGroup($securableItem, $permitable);
                     ReadPermissionsSubscriptionUtil::securableItemLostPermissionsForGroup($securableItem);
                 } elseif ($permitable instanceof User) {
                     AllPermissionsOptimizationUtil::securableItemLostReadPermissionsForUser($securableItem, $permitable);
                     ReadPermissionsSubscriptionUtil::securableItemLostPermissionsForUser($securableItem);
                 } 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 ($optimizeReadPermissions) {
                 if ($permitable instanceof Group) {
                     AllPermissionsOptimizationUtil::securableItemLostPermissionsForGroup($securableItem, $permitable);
                     ReadPermissionsSubscriptionUtil::securableItemLostPermissionsForGroup($securableItem);
                 } elseif ($permitable instanceof User) {
                     AllPermissionsOptimizationUtil::securableItemLostPermissionsForUser($securableItem, $permitable);
                     ReadPermissionsSubscriptionUtil::securableItemLostPermissionsForUser($securableItem);
                 } else {
                     throw new NotSupportedException();
                 }
             }
         }
     }
     if ($saveSecurableItem) {
         $setBackToProcess = false;
         if ($securableItem->shouldProcessWorkflowOnSave()) {
             $securableItem->setDoNotProcessWorkflowOnSave();
             $setBackToProcess = true;
         }
         $saved = $securableItem->save($validate);
         if ($setBackToProcess) {
             $securableItem->setProcessWorkflowOnSave();
         }
         $securableItem->setTreatCurrentUserAsOwnerForPermissions(false);
         return $saved;
     }
     $securableItem->setTreatCurrentUserAsOwnerForPermissions(false);
     return true;
 }
开发者ID:RamaKavanan,项目名称:InitialVersion,代码行数:99,代码来源:ExplicitReadWriteModelPermissionsUtil.php


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