Example #1
0
require_once RESACCMAN_BASE . "/classes/html/GroupPermissionsForm.php";
$title = Text::getText("GroupPermissions");
if (GroupPermissionsForm::isSubmitted($_REQUEST)) {
    $g = GroupPermissionsForm::handle($_REQUEST);
    $today = date("r");
    header("Location: groupPermissions.php?id=" . $g->getId() . "&saved=" . $today);
} else {
    if (sizeof($_REQUEST['id']) > 0) {
        $g = SecurityGroup::getById($id);
    }
}
if ($g == NULL) {
    $errMsg = Text::getText("GroupNotFound") . ": '" . $id . "'";
    die($errMsg);
}
$title .= ": " . $g->getName();
$form = new GroupPermissionsForm($g);
if (strlen($_REQUEST['saved']) > 0) {
    $form->setMessage(IsatisText::getText("Saved") . ": " . $_REQUEST['saved']);
}
include "header.php";
?>
<h2><?php 
echo $title;
?>
</h2><?
$form->printContent();
include("footer.php");

?>
Example #2
0
 /**
  * Allows the user to manage individual permissions for each
  * user group
  *
  * @access public
  * @return void
  */
 public function flippersAction()
 {
     $this->title = 'Manage permissions for this group.';
     $form = new GroupPermissionsForm();
     $fliperModel = new Flipper();
     $groupModel = new Group();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $fliperModel->savePermissions($form->getValues());
             $this->_helper->FlashMessenger(array('msg-success' => sprintf('Permissions for group %s were successfully updated.', $group['name'])));
             App_FlagFlippers_Manager::save();
             $this->_redirect('/groups/');
         }
     } else {
         $id = $this->_getParam('id');
         if (!is_numeric($id)) {
             $this->_helper->FlashMessenger(array('msg-success' => sprintf('We cannot find group with id %s', $id)));
             $this->_redirect('/groups/');
         }
         $group = $groupModel->findById($id);
         $flipper = $fliperModel->findByGroupId($id);
         if (empty($group)) {
             $this->_helper->FlashMessenger(array('msg-success' => sprintf('The permissions for the group %s were updated.', $form->getValue('name'))));
             $this->_redirect('/groups/');
         }
         $form->populate($flipper->toArray(), $id);
         $this->view->item = $group;
     }
     $this->view->form = $form;
 }