/**
  * Allows users to logically delete other users
  * (should be reserved for administrators)
  *
  * @access public
  * @return void
  */
 public function deleteAction()
 {
     $this->title = 'Delete this user';
     $form = new DeleteForm();
     $userModel = new BackofficeUser();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $userModel->deleteById($form->getValue('id'));
             $this->_helper->FlashMessenger(array('msg-success' => 'The item was successfully deleted.'));
             App_FlagFlippers_Manager::save();
             $this->_redirect('/users/');
         }
     } else {
         $id = $this->_getParam('id');
         if (!is_numeric($id)) {
             $this->_helper->FlashMessenger(array('msg-error' => 'The id you provided is invalid.'));
             $this->_redirect('/users/');
         }
         if ($id == 1) {
             $this->_helper->FlashMessenger(array('msg-error' => 'It is forbidden to mess with the admin account in this release.'));
             $this->_redirect('/users/');
         }
         $row = $userModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-error' => 'The requested item cannot be found.'));
             $this->_redirect('/users/');
         }
         $this->view->item = $row;
         $form->populate($row->toArray());
     }
     $this->view->form = $form;
 }
Example #2
0
 /**
  * Allows the user to delete an existing privilege. All the flippers related to
  * this privilege will be removed
  *
  * @access public
  * @return void
  */
 public function deleteAction()
 {
     $this->title = 'Delete privilege';
     $form = new DeleteForm();
     $privilegeModel = new Privilege();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $privilegeModel->deleteById($form->getValue('id'));
             $this->_helper->FlashMessenger(array('msg-success' => 'The privilege was successfully deleted.'));
             //Regenerate Flag and Flippers
             App_FlagFlippers_Manager::save();
             $this->_redirect('/privileges/');
         }
     } else {
         $id = $this->_getParam('id');
         $row = $privilegeModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-warning' => sprintf('We cannot find privilege with id %s', $id)));
             $this->_redirect('/privileges/');
         }
         $form->populate($row->toArray());
         $this->view->item = $row;
     }
     $this->view->form = $form;
 }
Example #3
0
 /**
  * Allows the user to delete an existing user group. All the users attached to
  * this group *WILL NOT* be deleted, they will just lose all 
  * privileges granted by this group
  *
  * @access public
  * @return void
  */
 public function deleteAction()
 {
     $this->title = 'Delete user group';
     $form = new DeleteForm();
     $groupModel = new Group();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $groupModel->deleteById($form->getValue('id'));
             $this->_helper->FlashMessenger(array('msg-success' => 'The group was successfully deleted.'));
             App_FlagFlippers_Manager::save();
             $this->_redirect('/groups/');
         }
     } else {
         $id = $this->_getParam('id');
         $row = $groupModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-success' => sprintf('We cannot find group with id %s', $id)));
             $this->_redirect('/groups/');
         }
         $form->populate($row->toArray());
         $this->view->item = $row;
     }
     $this->view->form = $form;
 }