Beispiel #1
0
 /**
  * Save a contact against a given client object
  * 
  *
  * @param array|Contact $params 
  * @return Contact
  */
 public function saveContact($params)
 {
     $contact = null;
     try {
         $this->dbService->beginTransaction();
         // Get an existing one
         $contact = $this->dbService->saveObject($params, 'Contact');
         // check for a user object to also update
         if ($contact->id) {
             $user = $this->userService->getUserByField('contactid', $contact->id);
             if ($user) {
                 $params = array('firstname' => $contact->firstname, 'lastname' => $contact->lastname, 'email' => $contact->email);
                 $this->userService->updateUser($user, $params);
             }
         }
         $this->trackerService->track('update-contact', $contact->id, null, null, print_r($params, true));
         $this->dbService->commit();
     } catch (Exception $e) {
         $this->dbService->rollback();
         $this->log->err("Failed creating contact for params " . print_r($params, true) . ": " . $e->getMessage());
         $contact = null;
         throw $e;
     }
     return $contact;
 }
Beispiel #2
0
 /**
  * Process settings form.
  *
  * @return Illuminate\View\View A view.
  */
 public function processSettings()
 {
     try {
         $user = UserService::getUser(Auth::user()->id);
         $user->locale_id = Input::get('locale');
         unset($user->password);
         UserService::updateUser(Auth::user()->id, $user);
         $this->success(trans('messages.settingsSaved'));
         return Redirect::to('settings');
     } catch (Exception $e) {
         return $this->unexpected($e);
     }
 }
Beispiel #3
0
 public function saveAction()
 {
     $id = (int) $this->_getParam('id');
     $userToEdit = za()->getUser();
     // If an ID is passed, we need to be an admin to be
     // able to edit this user
     if ($id > 0) {
         $selectedUser = $this->userService->getUser($id);
         // now, if the selectedUser has a role less than mine, we can
         // edit them
         if ($selectedUser->getRoleValue() < za()->getUser()->getRoleValue() || za()->getUser()->isPower()) {
             $userToEdit = $selectedUser;
         }
     }
     // we're saving?
     // bind the user item
     if ($this->_getParam('password') != $this->_getParam('confirm')) {
         $this->view->addError('unmatched_password', 'Passwords do not match');
     } else {
         try {
             $params = $this->_getAllParams();
             // If no new pass was set, just clear it from the update
             if ($params['password'] == '') {
                 unset($params['password']);
             }
             $this->userService->updateUser($userToEdit, $params);
             $this->view->flash("Profile successfully updated");
         } catch (InvalidModelException $im) {
             $this->view->flash($im->getMessages());
             $this->redirect('user', 'edit', array('id' => $userToEdit->id));
             return;
         } catch (ExistingUserException $eu) {
             $this->view->flash("User already exists");
             $this->redirect('user', 'edit', array('id' => $userToEdit->id));
             return;
         }
     }
     $this->redirect('user', 'edit', array('id' => $userToEdit->id));
 }
        case 'pwd_change_get':
            require_once './user_view_pwd_change.php';
            break;
        case 'pwd_change_post':
            require_once 'class/user.class.php';
            require_once 'class/user_service.class.php';
            $username = trim($_POST['username']);
            $pwd = md5(trim($_POST['pwd']));
            $user = new User(null, null, null, null, $username, $pwd, null, null, null, null);
            $user_service = new UserService();
            $rs = $user_service->validateUser($user);
            if ($rs) {
                $user = $user_service->getUserByUsername($username);
                $user->pwd = md5($_POST["new_pwd"]);
                print_r($user);
                $user_service->updateUser($user);
                $_SESSION['operation'] = true;
                $_SESSION['operation_msg'] = "修改密码:" . $username . "成功";
                $log_service->addLog("update", "用户修改密码", $id);
                header("Location: ./index.php?mod=home");
            } else {
                $_SESSION['operation'] = false;
                $_SESSION['operation_msg'] = "密码错误,请重新输入";
                header("Location: index.php?mod=user&action=pwd_change_get");
            }
            break;
        default:
            break;
    }
} else {
    header("Location: ./index.php?mod=user&action=ls");
Beispiel #5
0
 /**
  * Process a form to edit an existing user.
  *
  * @param integer $id The id of the user to edit.
  *
  * @return mixed The response.
  */
 public function processEditUser($id)
 {
     try {
         // Get inputs.
         $user = new User();
         $user->username = Input::get('username');
         $user->password = Input::get('password');
         $user->password_confirmation = Input::get('password_confirmation');
         $user->first_name = Input::get('first_name');
         $user->last_name = Input::get('last_name');
         $user->email = Input::get('email');
         $user->status = Input::get('status');
         $user->role = Input::get('role');
         $user->locale_id = Input::get('locale_id');
         // Update user.
         UserService::updateUser($id, $user);
         $this->success(trans('messages.userUpdated'));
         return Redirect::route('users.list');
     } catch (ValidationException $e) {
         return Redirect::route('users.edit', array('id' => $id))->withInput(Input::all())->withErrors($e->getValidator());
     } catch (Exception $e) {
         return $this->unexpected($e);
     }
 }
 public function userUpdate(User $user)
 {
     $user = UserService::updateUser($user);
     return Redirect::route('user.app')->with('message', 'User was updated');
 }
Beispiel #7
0
         //add  json object { "a":"aa","b":"bb", user":{"userid":"aaaa"}}
         $sv = new UserService();
         $input = json_decode(file_get_contents("php://input"));
         // var_dump($input);
         $rs = $sv->createUser($input, getuserid($input));
         // var_dump($rs);
         return $rs;
         exit;
     }
 } else {
     if ($method == 'PUT' && $request[0] == 'test') {
         if (isset($request[1]) && is_numeric($request[1])) {
             $sv = new UserService();
             $input = json_decode(file_get_contents("php://input"));
             // var_dump($input);
             $rs = $sv->updateUser($input, getuserid($input));
             // var_dump($rs);
             return $rs;
             exit;
         }
     } else {
         if ($method == 'DELETE' && $request[0] == 'test') {
             if (isset($request[1]) && is_numeric($request[1])) {
                 $sv = new UserService();
                 $input = json_decode(file_get_contents("php://input"));
                 // var_dump($input);
                 $rs = $sv->deleteUser($request[1], getuserid($input));
                 // var_dump($rs);
                 return $rs;
                 exit;
             }