Ejemplo n.º 1
0
 public function updateUserStatus(User $user)
 {
     if (!($user->getStatus() == 'N' || $user->getStatus() == 'I')) {
         throw new SSSException(ErrorFactory::ERR_WRONG_USER_STATUS);
     }
     $userMod = new UserModel();
     try {
         $userFound = $userMod->updateStatus($user);
         if ($userFound === FALSE) {
             throw new SSSException(ErrorFactory::ERR_DB_INVALID_RESULT);
         }
         $ret['result'] = "success";
         return $ret;
     } catch (SSSException $e) {
         return $e->getError();
     }
 }
Ejemplo n.º 2
0
 public function checkWebAdminLogin(User $user)
 {
     if ($user->getType() != 'A') {
         return ErrorFactory::getError(ErrorFactory::LOGIN_FAIL_INVALID_USER);
     }
     //Check User Login
     $userMod = new UserModel();
     $userFound = $userMod->login($user);
     //Login Fail
     if (!$userFound) {
         return ErrorFactory::getError(ErrorFactory::LOGIN_FAIL_INVALID_USER);
     }
     $user->setId($userFound);
     $ret['result'] = "success";
     $ret['data']['user_id'] = $user->getId();
     session_start();
     $_SESSION['userId'] = $userFound;
     $_SESSION['userName'] = $user->getName();
     $_SESSION['loginDt'] = new \DateTime();
     return $ret;
 }
Ejemplo n.º 3
0
 /**
  * 
  * @param int $observeeId
  * @param string $date
  * @throws SSSException
  * @return Task[] | boolean
  */
 public function getAllTaskByObservee($observeeId)
 {
     $sp = "sp_task_getAllByObservee";
     $params = new SDMDBParameters();
     $params->add($observeeId);
     // 				var_dump($params);
     $result = $this->handler->execute_stored_procedure($sp, $params, 'array');
     // 								var_dump($result);
     $ret = false;
     if ($result && $result['response']['system']['errorNo'] == 0) {
         if (isset($result['response']['resultSet'])) {
             if (isset($result['response']['resultSet'][0])) {
                 $tasks = array();
                 $dataRows = $result['response']['resultSet'];
                 foreach ($dataRows as $data) {
                     $task = new Task();
                     $task->setId($data['id']);
                     $task->setLat($data['lat']);
                     $task->setLng($data['lng']);
                     $task->setAddress($data['address']);
                     $task->setMsg($data['msg']);
                     $task->setLastUpdate($data['lastUpdate']);
                     $task->setCreateDt($data['createDt']);
                     $taskType = new TaskType();
                     $taskType->setId($data['typeId']);
                     $taskType->setName($data['taskType']);
                     $task->setTaskType($taskType);
                     $taskStatus = new TaskStatus();
                     $taskStatus->setId($data['statusId']);
                     $taskStatus->setName($data['status']);
                     $task->setTaskStatus($taskStatus);
                     $reporter = new User();
                     $reporter->setId($data['reporterId']);
                     $reporter->setName($data['reporter']);
                     $task->setReport($reporter);
                     if (isset($data['handlerId'])) {
                         $handler = new User();
                         $handler->setId($data['handlerId']);
                         $handler->setName($data['handler']);
                         $task->setHandler($handler);
                     }
                     array_push($tasks, $task);
                 }
                 $ret = $tasks;
             } else {
                 throw new SSSException(ErrorFactory::ERR_DB_INVALID_RESULT);
             }
         } else {
             $ret = false;
         }
     } else {
         throw new SSSException(ErrorFactory::ERR_DB_EXECUTE);
     }
     return $ret;
 }
Ejemplo n.º 4
0
    require_once './testAPI.php';
    $params = json_decode($fakeParams, true);
    $action = $params['action'];
} else {
    if (isset($_POST['params'])) {
        $params = json_decode($_POST['params'], true);
        $action = $params['action'];
    }
}
// var_dump($params);
$result = ErrorFactory::getError(ErrorFactory::ERR_MISSING_PARAMETERS);
switch ($action) {
    case "login":
        if (validate_input_param($params, array('name', 'type', 'password', 'deviceID', 'wifiMac'))) {
            // 		if(validate_input_param($params,array('id', 'type', 'password', 'deviceID', 'wifiMac' ))){
            $user = new User();
            $user->setName($params['name']);
            // 			$user->setId($params['id']);
            $user->setPassword(md5($params['password']));
            $user->setType($params['type']);
            $device = new Device();
            $device->setId($params['deviceID']);
            $device->setWifiMacAddress($params['wifiMac']);
            $ctr = new LoginController();
            try {
                $result = $ctr->checkClientLogin($user, $device);
            } catch (SSSException $e) {
                $result = ErrorFactory::getError($e->getCode());
            }
        }
        break;
Ejemplo n.º 5
0
 public function addTask($observerId, $taskTypeId, $lat, $lng, $address, $msg)
 {
     try {
         // 			print 1;
         $type = new TaskType();
         $type->setId($taskTypeId);
         $reporter = new User();
         $reporter->setId($observerId);
         $task = new Task();
         $task->setTaskType($type);
         $task->setReport($reporter);
         $task->setLat($lat);
         $task->setLng($lng);
         $task->setAddress($address);
         $task->setMsg($msg);
         $taskMod = new TaskModel();
         $result = $taskMod->add($task);
         if ($result === FALSE) {
             $ret['result'] = 'fail';
         } else {
             // 				print 3;
             $ret['result'] = 'success';
         }
         return $ret;
     } catch (SSSException $e) {
         return $e->getError();
     }
 }
Ejemplo n.º 6
0
 // 		break;
 case "updateUserStatus":
     if (validate_input_param($params, array('userId', 'status'))) {
         $user = new User();
         $user->setId($params['userId']);
         $user->setStatus($params['status']);
         $ctr = new WebController();
         try {
             $result = $ctr->updateUserStatus($user);
         } catch (SSSException $e) {
             $result = ErrorFactory::getError($e->getCode());
         }
     }
     break;
     if (validate_input_param($params, array('type'))) {
         $user = new User();
         $user->setId($params['userId']);
         $user->setStatus($params['status']);
         $ctr = new WebController();
         try {
             $result = $ctr->updateUserStatus($user);
         } catch (SSSException $e) {
             $result = ErrorFactory::getError($e->getCode());
         }
     }
 case "getUsers":
     if (validate_input_param($params, array('type'))) {
         $ctr = new WebController();
         try {
             $result = $ctr->getUserByType($params['type']);
         } catch (SSSException $e) {
Ejemplo n.º 7
0
 public function getByType($type)
 {
     $sp = "sp_user_getByType";
     $params = new SDMDBParameters();
     $params->add($type);
     // 				var_dump($params);
     $result = $this->handler->execute_stored_procedure($sp, $params, 'array');
     // 				var_dump($result);
     $ret = false;
     if ($result && $result['response']['system']['errorNo'] == 0) {
         if (isset($result['response']['resultSet'])) {
             $items = $result['response']['resultSet'];
             $array = array();
             foreach ($items as $item) {
                 $user = new User();
                 $user->setName($item['login_name']);
                 $user->setId($item['user_id']);
                 $user->setType($item['user_type']);
                 $user->setStatus($item['status']);
                 $user->setLastUpdate($item['last_update']);
                 array_push($array, $user);
             }
             return $array;
         } else {
             $ret = false;
         }
     } else {
         throw new SSSException(ErrorFactory::ERR_DB_EXECUTE);
     }
     return $ret;
 }