public function testResolveMetadataFromRightsData()
 {
     $rightsData = array('UsersModule' => array('RIGHT_CHANGE_USER_PASSWORDS' => array('displayName' => UsersModule::RIGHT_CHANGE_USER_PASSWORDS, 'explicit' => null, 'inherited' => Right::ALLOW), 'RIGHT_LOGIN_VIA_WEB' => array('displayName' => UsersModule::RIGHT_LOGIN_VIA_WEB, 'explicit' => null, 'inherited' => Right::DENY), 'RIGHT_LOGIN_VIA_MOBILE' => array('displayName' => UsersModule::RIGHT_LOGIN_VIA_MOBILE, 'explicit' => Right::ALLOW, 'inherited' => null), 'RIGHT_LOGIN_VIA_WEB_API' => array('displayName' => UsersModule::RIGHT_LOGIN_VIA_WEB_API, 'explicit' => null, 'inherited' => null)));
     $metadata = RightsEditViewUtil::resolveMetadataFromData($rightsData, RightsEditAndDetailsView::getMetadata());
     $compareData = array('global' => array('toolbar' => array('elements' => array(array('type' => 'SaveButton', 'renderType' => 'Edit'), array('type' => 'CancelLink', 'renderType' => 'Edit'))), 'panels' => array(array('rows' => array(array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__RIGHT_CHANGE_USER_PASSWORDS', 'type' => 'RightInheritedAllowStaticDropDown'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__RIGHT_LOGIN_VIA_WEB', 'type' => 'RightInheritedDenyText'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__RIGHT_LOGIN_VIA_MOBILE', 'type' => 'RightStaticDropDown'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__RIGHT_LOGIN_VIA_WEB_API', 'type' => 'RightStaticDropDown')))))), 'title' => 'Users'))));
     $this->assertSame($compareData, $metadata);
     $metadata = RightsEffectiveDetailsViewUtil::resolveMetadataFromData($rightsData, RightsEditAndDetailsView::getMetadata());
     $compareData = array('global' => array('toolbar' => array('elements' => array(array('type' => 'SaveButton', 'renderType' => 'Edit'), array('type' => 'CancelLink', 'renderType' => 'Edit'))), 'panels' => array(array('rows' => array(array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__RIGHT_CHANGE_USER_PASSWORDS__effective', 'type' => 'RightEffective'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__RIGHT_LOGIN_VIA_WEB__effective', 'type' => 'RightEffective'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__RIGHT_LOGIN_VIA_MOBILE__effective', 'type' => 'RightEffective'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__RIGHT_LOGIN_VIA_WEB_API__effective', 'type' => 'RightEffective')))))), 'title' => 'Users'))));
     $this->assertSame($compareData, $metadata);
 }
 public function actionEditRights($id)
 {
     $group = Group::getById(intval($id));
     $title = Zurmo::t('ZurmoModule', 'Rights');
     $breadCrumbLinks = array(strval($group) => array('group/' . static::resolveBreadCrumbActionByGroup($group), 'id' => $id), $title);
     $rightsData = RightsUtil::getAllModuleRightsDataByPermitable($group);
     $rightsForm = RightsFormUtil::makeFormFromRightsData($rightsData);
     $postVariableName = get_class($rightsForm);
     if (isset($_POST[$postVariableName])) {
         $castedPostData = RightsFormUtil::typeCastPostData($_POST[$postVariableName]);
         if (RightsFormUtil::setRightsFromCastedPost($castedPostData, $group)) {
             $this->clearCaches();
             $group->forget();
             $group = Group::getById(intval($id));
             Yii::app()->user->setFlash('notification', Zurmo::t('ZurmoModule', 'Rights Saved Successfully.'));
             $action = $this->resolveActionToGoToAfterSave($group);
             $this->redirect(array($this->getId() . '/' . $action, 'id' => $group->id));
             Yii::app()->end(0, false);
         }
     }
     $metadata = RightsEditViewUtil::resolveMetadataFromData($rightsForm->data, RightsEditAndDetailsView::getMetadata());
     $titleBarAndEditView = new GroupActionBarAndSecurityEditView($this->getId(), $this->getModule()->getId(), $rightsForm, $group, $this->getModule()->getPluralCamelCasedName(), $metadata, 'RightsEditAndDetailsView', 'GroupRightsEditMenu');
     $view = new GroupsPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $titleBarAndEditView, $breadCrumbLinks, 'GroupBreadCrumbView'));
     echo $view->render();
 }
 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();
 }