コード例 #1
0
 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 actionEditPolicies($id)
 {
     $group = Group::getById(intval($id));
     $title = Zurmo::t('ZurmoModule', 'Policies');
     $breadCrumbLinks = array(strval($group) => array('group/' . static::resolveBreadCrumbActionByGroup($group), 'id' => $id), $title);
     $data = PoliciesUtil::getAllModulePoliciesDataByPermitable($group);
     $policiesForm = PoliciesFormUtil::makeFormFromPoliciesData($data);
     $postVariableName = get_class($policiesForm);
     if (isset($_POST[$postVariableName])) {
         $castedPostData = PoliciesFormUtil::typeCastPostData($_POST[$postVariableName]);
         $policiesForm = PoliciesFormUtil::loadFormFromCastedPost($policiesForm, $castedPostData);
         if ($policiesForm->validate()) {
             if (PoliciesFormUtil::setPoliciesFromCastedPost($castedPostData, $group)) {
                 $this->clearCaches();
                 Yii::app()->user->setFlash('notification', Zurmo::t('ZurmoModule', 'Policies Saved Successfully.'));
                 $action = $this->resolveActionToGoToAfterSave($group);
                 $this->redirect(array($this->getId() . '/' . $action, 'id' => $group->id));
                 Yii::app()->end(0, false);
             }
         }
     }
     $metadata = PoliciesEditViewUtil::resolveMetadataFromData($policiesForm->data, PoliciesEditAndDetailsView::getMetadata());
     $titleBarAndEditView = new GroupActionBarAndSecurityEditView($this->getId(), $this->getModule()->getId(), $policiesForm, $group, $this->getModule()->getPluralCamelCasedName(), $metadata, 'PoliciesEditAndDetailsView', 'GroupPoliciesEditMenu');
     $view = new GroupsPageView(ZurmoDefaultAdminViewUtil::makeViewWithBreadcrumbsForCurrentUser($this, $titleBarAndEditView, $breadCrumbLinks, 'GroupBreadCrumbView'));
     echo $view->render();
 }