public function testResolveMetadataFromPoliciesData()
 {
     $data = array('UsersModule' => array('POLICY_ENFORCE_STRONG_PASSWORDS' => array('displayName' => UsersModule::POLICY_ENFORCE_STRONG_PASSWORDS, 'explicit' => null, 'inherited' => Policy::YES), 'POLICY_MINIMUM_PASSWORD_LENGTH' => array('displayName' => UsersModule::POLICY_MINIMUM_PASSWORD_LENGTH, 'explicit' => 5, 'inherited' => null), 'POLICY_MINIMUM_USERNAME_LENGTH' => array('displayName' => UsersModule::POLICY_MINIMUM_USERNAME_LENGTH, 'explicit' => null, 'inherited' => null), 'POLICY_PASSWORD_EXPIRES' => array('displayName' => UsersModule::POLICY_PASSWORD_EXPIRES, 'explicit' => null, 'inherited' => Policy::YES), 'POLICY_PASSWORD_EXPIRY_DAYS' => array('displayName' => UsersModule::POLICY_PASSWORD_EXPIRY_DAYS, 'explicit' => 10, 'inherited' => 15)));
     $metadata = PoliciesEditViewUtil::resolveMetadataFromData($data, PoliciesEditAndDetailsView::getMetadata());
     $compareData = array('global' => array('toolbar' => array('elements' => array(array('type' => 'SaveButton', 'renderType' => 'Edit'), array('type' => 'CancelToListLink', 'renderType' => 'Edit'))), 'panels' => array(array('rows' => array(array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__POLICY_ENFORCE_STRONG_PASSWORDS', 'type' => 'PolicyInheritedYesNoText'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__POLICY_MINIMUM_PASSWORD_LENGTH', 'type' => 'PolicyIntegerAndStaticDropDown'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__POLICY_MINIMUM_USERNAME_LENGTH', 'type' => 'PolicyIntegerAndStaticDropDown'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'null', 'type' => 'PolicyPasswordExpiry'))))))))));
     $this->assertSame($compareData, $metadata);
     $metadata = PoliciesEffectiveDetailsViewUtil::resolveMetadataFromData($data, PoliciesEditAndDetailsView::getMetadata());
     $compareData = array('global' => array('toolbar' => array('elements' => array(array('type' => 'SaveButton', 'renderType' => 'Edit'), array('type' => 'CancelToListLink', 'renderType' => 'Edit'))), 'panels' => array(array('rows' => array(array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__POLICY_ENFORCE_STRONG_PASSWORDS__effective', 'type' => 'PolicyEffectiveYesNo'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__POLICY_MINIMUM_PASSWORD_LENGTH__effective', 'type' => 'PolicyEffectiveInteger'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'UsersModule__POLICY_MINIMUM_USERNAME_LENGTH__effective', 'type' => 'PolicyEffectiveInteger'))))), array('cells' => array(array('elements' => array(array('attributeName' => 'null', 'type' => 'PolicyEffectivePasswordExpiry'))))))))));
     $this->assertSame($compareData, $metadata);
 }
예제 #2
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();
 }