Пример #1
0
 /**
  *
  */
 public function actionTicket()
 {
     $params = ApiParams::getPostJsonParams();
     $model = Validation::checkUserAuthorization($params);
     if ($model->errors) {
         Utils::echoErrorResponse($model->getFirstErrors());
     } else {
     }
 }
Пример #2
0
 public function actionViewAlert()
 {
     $params = ApiParams::getPostJsonParams();
     $message = Validation::checkParamsAndGetMessage($params, ApiParams::$ACK_ALERT_PARAMS);
     if ($message->errors) {
         Utils::echoErrorResponse($message->getFirstErrors());
     } else {
         //TODO ......
     }
 }
 public function actionGetRecipientsList()
 {
     $params = ApiParams::getPostJsonParams();
     $model = Validation::checkUserAuthorization($params);
     if ($model->errors) {
         Utils::echoErrorResponse($model->getFirstErrors());
     } else {
         $recipiens = Recipients::find()->asArray()->all();
         $groups = Groups::find()->select('code')->asArray()->all();
         $groups_members = $this->getGroupsMembers($groups);
         Utils::echoSuccessResponse($groups_members);
     }
 }
Пример #4
0
 public static function getPostJsonParams()
 {
     $post = file_get_contents("php://input");
     //decode json post input as php array:
     try {
         $params = BaseJson::decode($post, $asArray = true);
         if (!$params) {
             $params = [];
         }
         return $params;
     } catch (InvalidParamException $e) {
         Utils::echoErrorResponse($e->getMessage());
         die;
     }
 }
Пример #5
0
 public static function setNewRecipientInfo($model, $info_type, $params)
 {
     try {
         $user_info = new RecipientMobileInfo();
         $user_info->recipient_mobile_index = $model->index;
         $user_info->info_type = $info_type;
         $user_info->occured_at = Utils::getCurrentTime();
         if (ApiParams::checkLocationParams($params)) {
             $user_info->pos_lat = $params[ApiParams::POS_LNG];
             $user_info->pos_lng = $params[ApiParams::POS_LAT];
         } elseif (ApiParams::checkIfThereAreNote($params)) {
             $user_info->note = $params[ApiParams::NOTE];
         }
         return $user_info->save();
     } catch (\Exception $e) {
         return $e;
     }
 }
 public function logOut($model)
 {
     $this->auth_key = $this->setNewAuthKey();
     $this->device_id = $model->device_id;
     $this->heartbeat_time = Utils::getCurrentTime();
     $this->recipient_mobile_index = $model->recipient_mobile_index;
     if (!$this->save()) {
         $this->addError(self::AUTH_KEY, $error = "c'not save new session");
     }
     return $this;
 }
Пример #7
0
 public function actionSaveUserPicture()
 {
     if (!isset($_FILES)) {
         Utils::echoErrorResponse(['file' => "not send any file"]);
     } else {
     }
 }