Ejemplo n.º 1
0
 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();
 }
Ejemplo n.º 2
0
 /**
  * @depends testRightsFormUtilSetRightsFromPost
  */
 public function testGiveUserAccessToModule()
 {
     $user = User::getByUsername('billy');
     $this->assertFalse(RightsUtil::canUserAccessModule('AccountsModule', $user));
     $group = Group::getByName(Group::EVERYONE_GROUP_NAME);
     $fakePost = array('AccountsModule__RIGHT_ACCESS_ACCOUNTS' => strval(Right::ALLOW));
     $fakePost = RightsFormUtil::typeCastPostData($fakePost);
     $saved = RightsFormUtil::setRightsFromCastedPost($fakePost, $group);
     $this->assertTrue($saved);
     $this->assertTrue(RightsUtil::canUserAccessModule('AccountsModule', $user));
 }