Exemplo n.º 1
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;
 }