/**
  * 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
 /**
  * delete url rewriting 
  * @author EL GUENNUNI Sohaib s.elguennuni@gmail.com
  * @param 
  * @return 
  */
 public function deleteAction()
 {
     $this->title = 'Delete url';
     $form = new DeleteForm();
     $urlModel = new UrlAlias();
     if ($this->getRequest()->isPost()) {
         $urlModel->deleteById($this->_getParam('id'));
         $this->_helper->FlashMessenger(array('msg-success' => 'The url was successfully deleted.'));
         //Regenerate Flag and Flippers
         App_FlagFlippers_Manager::save();
         $this->_redirect('/url/');
     } else {
         $id = $this->_getParam('id');
         $row = $urlModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-warning' => sprintf('We cannot find url with id %s', $id)));
             $this->_redirect('/url/');
         }
         $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;
 }