public function testGetAdministrableModuleClassNames()
 {
     $names = GroupModulePermissionsDataToEditViewAdapater::getAdministrableModuleClassNames();
     $this->assertTrue(in_array('AccountsModule', $names));
     $this->assertTrue(in_array('ContactsModule', $names));
     $this->assertTrue(in_array('MeetingsModule', $names));
     $this->assertTrue(in_array('NotesModule', $names));
     $this->assertTrue(in_array('OpportunitiesModule', $names));
     $this->assertTrue(in_array('TasksModule', $names));
 }
 public static function resolveData($data)
 {
     assert('is_array($data)');
     $resolvedData = array();
     foreach ($data as $moduleClassName => $modulePermissions) {
         if (in_array($moduleClassName, GroupModulePermissionsDataToEditViewAdapater::getAdministrableModuleClassNames())) {
             $resolvedData[$moduleClassName] = $modulePermissions;
         }
     }
     return $resolvedData;
 }
 public function testResolveMetadataFromPermissionsData()
 {
     $data = array('AccountsModule' => array(Permission::CHANGE_OWNER => array('explicit' => null, 'inherited' => null), Permission::CHANGE_PERMISSIONS => array('explicit' => null, 'inherited' => null), Permission::DELETE => array('explicit' => null, 'inherited' => null), Permission::READ => array('explicit' => null, 'inherited' => Permission::ALLOW), Permission::WRITE => array('explicit' => null, 'inherited' => Permission::DENY)), 'ContactsModule' => array(Permission::CHANGE_OWNER => array('explicit' => null, 'inherited' => null), Permission::CHANGE_PERMISSIONS => array('explicit' => null, 'inherited' => null), Permission::DELETE => array('explicit' => null, 'inherited' => null), Permission::READ => array('explicit' => null, 'inherited' => Permission::ALLOW), Permission::WRITE => array('explicit' => null, 'inherited' => Permission::DENY)));
     $this->assertTrue(in_array('AccountsModule', GroupModulePermissionsDataToEditViewAdapater::getAdministrableModuleClassNames()));
     $newData = GroupModulePermissionsDataToEditViewAdapater::resolveData($data);
     $this->assertNotEmpty($newData);
     $this->assertEquals($data, $newData);
     $metadata = ModulePermissionsEditViewUtil::resolveMetadataFromData($newData, ModulePermissionsEditAndDetailsView::getMetadata());
     $compareData = array('global' => array('toolbar' => array('elements' => array(array('type' => 'CancelLink', 'renderType' => 'Edit'), array('type' => 'SaveButton', 'renderType' => 'Edit'))), 'panels' => array(array('rows' => array(array('title' => 'Accounts', 'cells' => array(array('elements' => array(array('attributeName' => 'AccountsModule__' . Permission::READ, 'type' => 'PermissionInheritedAllowStaticDropDown'))), array('elements' => array(array('attributeName' => 'AccountsModule__' . Permission::WRITE, 'type' => 'PermissionInheritedDenyText'))), array('elements' => array(array('attributeName' => 'AccountsModule__' . Permission::DELETE, 'type' => 'PermissionStaticDropDown'))))), array('title' => 'Contacts & Leads', 'cells' => array(array('elements' => array(array('attributeName' => 'ContactsModule__' . Permission::READ, 'type' => 'PermissionInheritedAllowStaticDropDown'))), array('elements' => array(array('attributeName' => 'ContactsModule__' . Permission::WRITE, 'type' => 'PermissionInheritedDenyText'))), array('elements' => array(array('attributeName' => 'ContactsModule__' . Permission::DELETE, 'type' => 'PermissionStaticDropDown'))))))))));
     $this->assertSame($compareData, $metadata);
     $metadata = ModulePermissionsActualDetailsViewUtil::resolveMetadataFromData($newData, ModulePermissionsEditAndDetailsView::getMetadata());
     $compareData = array('global' => array('toolbar' => array('elements' => array(array('type' => 'CancelLink', 'renderType' => 'Edit'), array('type' => 'SaveButton', 'renderType' => 'Edit'))), 'panels' => array(array('rows' => array(array('title' => 'Accounts', 'cells' => array(array('elements' => array(array('attributeName' => 'AccountsModule__' . Permission::READ . '__actual', 'type' => 'PermissionActual'))), array('elements' => array(array('attributeName' => 'AccountsModule__' . Permission::WRITE . '__actual', 'type' => 'PermissionActual'))), array('elements' => array(array('attributeName' => 'AccountsModule__' . Permission::DELETE . '__actual', 'type' => 'PermissionActual'))))), array('title' => 'Contacts & Leads', 'cells' => array(array('elements' => array(array('attributeName' => 'ContactsModule__' . Permission::READ . '__actual', 'type' => 'PermissionActual'))), array('elements' => array(array('attributeName' => 'ContactsModule__' . Permission::WRITE . '__actual', 'type' => 'PermissionActual'))), array('elements' => array(array('attributeName' => 'ContactsModule__' . Permission::DELETE . '__actual', 'type' => 'PermissionActual'))))))))));
     $this->assertSame($compareData, $metadata);
 }
Пример #4
0
 public function actionEditModulePermissions($id)
 {
     $group = Group::getById(intval($id));
     $title = Zurmo::t('ZurmoModule', 'Record Permissions');
     $breadCrumbLinks = array(strval($group) => array('group/' . static::resolveBreadCrumbActionByGroup($group), 'id' => $id), $title);
     $data = PermissionsUtil::getAllModulePermissionsDataByPermitable($group);
     $permissionsForm = ModulePermissionsFormUtil::makeFormFromPermissionsData($data);
     $postVariableName = get_class($permissionsForm);
     if (isset($_POST[$postVariableName])) {
         $this->clearCaches();
         $castedPostData = ModulePermissionsFormUtil::typeCastPostData($_POST[$postVariableName]);
         $readyToSetPostData = ModulePermissionsEditViewUtil::resolveWritePermissionsFromArray($castedPostData);
         if (ModulePermissionsFormUtil::setPermissionsFromCastedPost($readyToSetPostData, $group)) {
             Yii::app()->user->setFlash('notification', Zurmo::t('ZurmoModule', 'Record Permissions Saved Successfully.'));
             $action = $this->resolveActionToGoToAfterSave($group);
             $this->redirect(array($this->getId() . '/' . $action, 'id' => $group->id));
             Yii::app()->end(0, false);
         }
     }
     $permissionsData = GroupModulePermissionsDataToEditViewAdapater::resolveData($data);
     $metadata = ModulePermissionsEditViewUtil::resolveMetadataFromData($permissionsData, ModulePermissionsEditAndDetailsView::getMetadata());
     $titleBarAndEditView = new GroupActionBarAndSecurityEditView($this->getId(), $this->getModule()->getId(), $permissionsForm, $group, $this->getModule()->getPluralCamelCasedName(), $metadata, 'ModulePermissionsEditAndDetailsView', 'GroupModulePermissionsEditMenu');
     $view = new GroupsPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $titleBarAndEditView, $breadCrumbLinks, 'GroupBreadCrumbView'));
     echo $view->render();
 }
Пример #5
0
 public function actionSecurityDetails($id)
 {
     UserAccessUtil::resolveCanCurrentUserAccessAction(intval($id));
     $user = User::getById(intval($id));
     UserAccessUtil::resolveCanCurrentUserAccessRootUser($user);
     UserAccessUtil::resolveAccessingASystemUser($user);
     $title = Zurmo::t('UsersModule', 'Security Overview');
     $breadCrumbLinks = array(strval($user) => array('default/details', 'id' => $id), $title);
     $modulePermissionsData = PermissionsUtil::getAllModulePermissionsDataByPermitable($user);
     $modulePermissionsForm = ModulePermissionsFormUtil::makeFormFromPermissionsData($modulePermissionsData);
     $viewReadyModulePermissionsData = GroupModulePermissionsDataToEditViewAdapater::resolveData($modulePermissionsData);
     $modulePermissionsViewMetadata = ModulePermissionsActualDetailsViewUtil::resolveMetadataFromData($viewReadyModulePermissionsData, ModulePermissionsEditAndDetailsView::getMetadata());
     $rightsData = RightsUtil::getAllModuleRightsDataByPermitable($user);
     $rightsForm = RightsFormUtil::makeFormFromRightsData($rightsData);
     $rightsViewMetadata = RightsEffectiveDetailsViewUtil::resolveMetadataFromData($rightsData, RightsEditAndDetailsView::getMetadata());
     $policiesData = PoliciesUtil::getAllModulePoliciesDataByPermitable($user);
     $policiesForm = PoliciesFormUtil::makeFormFromPoliciesData($policiesData);
     $policiesViewMetadata = PoliciesEffectiveDetailsViewUtil::resolveMetadataFromData($policiesData, PoliciesEditAndDetailsView::getMetadata());
     $groupMembershipAdapter = new UserGroupMembershipToViewAdapter($user);
     $groupMembershipViewData = $groupMembershipAdapter->getViewData();
     $securityDetailsView = new UserActionBarAndSecurityDetailsView($this->getId(), $this->getModule()->getId(), $user, $modulePermissionsForm, $rightsForm, $policiesForm, $modulePermissionsViewMetadata, $rightsViewMetadata, $policiesViewMetadata, $groupMembershipViewData);
     $view = new UsersPageView($this->resolveZurmoDefaultOrAdminView($securityDetailsView, $breadCrumbLinks, 'UserBreadCrumbView'));
     echo $view->render();
 }