Esempio n. 1
0
    $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;
        // Student Features
Esempio n. 2
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;
 }
Esempio n. 3
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;
 }