Example #1
0
 function deleteAction()
 {
     $this->view->title = "Delete user";
     $user = new Application_Model_User();
     if ($this->_request->isPost()) {
         Zend_Loader::loadClass('Zend_Filter_Alpha');
         $filter = new Zend_Filter_Alpha();
         $id = (int) $this->_request->getPost('id');
         $del = $filter->filter($this->_request->getPost('del'));
         if ($del == 'Yes' && $id > 0) {
             $where = 'id = ' . $id;
             $rows_affected = $user->delete($where);
         }
     } else {
         $id = (int) $this->_request->getParam('id');
         if ($id > 0) {
             // only render if we have an id and can find the vehicle.
             $this->view->user = $user->fetchRow('id=' . $id);
             if ($this->view->user->id > 0) {
                 // render template automatically
                 return;
             }
         }
     }
     // redirect back to the vehicle list unless we have rendered the view
     $this->_redirect('/users');
 }
Example #2
0
 /**
  * Método utilizado para excluir Users. Aguarda um parametro do tipo Int id.
  * @param int $id
  * @method deleteAction
  * @access public
  * @return void
  */
 public function deleteAction()
 {
     $user = new Application_Model_User();
     $id = $this->_getParam('id');
     $user->delete("id={$id}");
     $this->_redirect('/user/retrieve');
 }
 public function removeUserAction()
 {
     // action body
     $delId = $this->_getParam('id');
     $valid_actions = array("delete_cascade", "reassign_to");
     $files_action = $this->_getParam('deleted_files');
     # TODO : remove this. we only use default for now not to break the UI.
     if (!$files_action) {
         # set default action
         $files_action = "reassign_to";
         $new_owner = Application_Model_User::getFirstAdmin();
     }
     # only delete when valid action is selected for the owned files
     if (!in_array($files_action, $valid_actions)) {
         return;
     }
     $userInfo = Zend_Auth::getInstance()->getStorage()->read();
     $userId = $userInfo->id;
     # Don't let users delete themselves
     if ($delId == $userId) {
         return;
     }
     $user = new Application_Model_User($delId);
     # Take care of the user's files by either assigning them to somebody
     # or deleting them all
     if ($files_action == "delete_cascade") {
         $user->deleteAllFiles();
     } elseif ($files_action == "reassign_to") {
         // TODO : fix code to actually use the line below and pick a
         // real owner instead of defaulting to the first found admin
         //$new_owner_id = $this->_getParam("new_owner");
         //$new_owner    = new Application_Model_User($new_owner_id);
         $user->donateFilesTo($new_owner);
         Logging::info("Reassign to user {$new_owner->getDbId()}");
     }
     # Finally delete the user
     $this->view->entries = $user->delete();
 }