/**
  * Delete a user (soft delete)
  *
  * @view /views/scripts/user/delete.phtml
  * @access public
  * @todo FIXME: The App_Form_Delete is missing somehow, this does not work
  * @todo DB Cols in the Controller, remove them through the DbRow_User class
  */
 public function deleteAction()
 {
     $userRow = new Admin_Model_DbRow_User($this->dbUser->find($this->checkUserIdParam()));
     $form = new App_Form_Delete($userRow);
     //FIXME: this file is missing
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getParams()) && $form->getElement('del_checkbox')->isChecked() === TRUE) {
             //FIXME: Here we have some DB Columns in the controller
             //       Find a solution with the DbRow_User Class
             $this->dbUser->update(array('uu_deleted' => date('Y-m-d H:i:s', time())), $this->dbUser->getAdapter()->quoteInto('uu_id = ?', $userRow->get('id'), Zend_Db::PARAM_INT));
             $this->_redirect('admin/user/index');
         } else {
             $form->setDescription('Failed to delete the user');
         }
     }
     $this->view->form = $form;
     $this->view->user = $userRow;
 }
 /**
  * Create the new user in the Database
  *
  * Method does some checks before inserting the user to be sure
  * having valid data
  *
  * @return array
  */
 public function saveNewUserAction()
 {
     // create the validator map
     $validatorMap = array('name' => array('validators' => array(), 'message' => 'Fullname cannot be emtpy'), 'username' => array('validators' => array(), 'message' => 'Username cannot be emtpy'), 'email' => array('validators' => array('EmailAddress'), 'message' => 'E-Mailaddress is empty or not valid'), 'groupid' => array('validators' => array(), 'message' => 'Please select a group'));
     $validate = new App_Validate_Ajax();
     $groupModel = new Admin_Model_DbTable_Groups();
     $userModel = new Admin_Model_DbTable_Users();
     $groupRowSet = $groupModel->find($this->request->getParam('groupid', 0));
     $userRow = $userModel->fetchRowByUserName($this->request->getParam('username', ''));
     if ($validate->isValid($this->request->getParams(), $validatorMap, TRUE) == FALSE || $groupRowSet->count() === 0 || $userRow) {
         $errors = $validate->getMessages();
         if ($groupRowSet->count() === 0) {
             $errors[] = 'No Group selected';
         }
         if ($userRow) {
             $errors[] = 'Username already exists';
         }
         return $this->responseFailure('Failed Saving informations', $errors);
     } else {
         $user = new Admin_Model_DbRow_User($this->request->getParams());
         $userModel->insert($user->toDbArray(array('groupid', 'username', 'password', 'name', 'email', 'enabled')));
         $user->fromArray($userModel->find($userModel->getAdapter()->lastInsertId()));
         return $this->responseSuccess(array());
     }
 }