Exemple #1
0
 public static function getNextComingEvent()
 {
     $strCurrentEndDate = self::getCurrentEventEndDate()['end_date'];
     if (empty($strCurrentEndDate)) {
         $strCurrentDate = UtilityController::getDbTimeStamp(true);
         return self::where('start_date', '>=', $strCurrentDate)->orderBy('start_date', 'asc')->first();
     } else {
         return self::where('start_date', '>=', $strCurrentEndDate)->orderBy('start_date', 'asc')->first();
     }
 }
 /**
  * @param Request $request
  * @return Response to the Api call
  * Copied a set of PostEmail from ResetPassword TraitClass
  * Customized for the Api response handler diff from web
  */
 public function postEmailApi(Request $request)
 {
     // Get public access key and user access key from GET
     $arrRequest = array('email' => $request->query('email'));
     $public_access_key = $request->query('api_key');
     $status_code = HttpRequest::$REQUEST_SUCCESS_CODE;
     $status = true;
     $success = false;
     $errors = "";
     // Get android callback
     $android_callback = $request->query('caller');
     // If the Api Key is invalid
     if (UtilityController::validateApiKey($public_access_key)) {
         //Validate the email
         $validator = Validator::make($arrRequest, ['email' => 'required|email']);
         if ($validator->fails() && $status_code === HttpRequest::$REQUEST_SUCCESS_CODE) {
             $errors = "Email validation failed";
             $status_code = HttpRequest::$VALIDATION_FAILED_CODE;
             $status = false;
         }
         //Done validate for api key and email input
         if ($status) {
             // Sent Reset Link
             $response = $this->sendResetEmail($request);
             switch ($response) {
                 case Password::RESET_LINK_SENT:
                     $success = true;
                     break;
                 case Password::INVALID_USER:
                     $success = false;
                     $errors = "Email is not exist";
                     break;
             }
         }
     } else {
         $errors = "Access Denied";
         $status_code = HttpRequest::$ACCESS_DENIED_CODE;
         $status = false;
     }
     $arrResponse = array('api_ver' => self::$API_VERSION, 'caller' => $android_callback, 'error' => $errors, 'status_code' => $status_code, 'status' => $status, 'success' => $success);
     return $arrResponse;
 }
 public function getNextEvent(Request $request)
 {
     $errors = "";
     $status_code = 200;
     $status = true;
     $result = "";
     $public_access_key = $request->query('api_key');
     // Get android callback
     $android_callback = $request->query('caller');
     // If the Api Key is valid
     if (UtilityController::validateApiKey($public_access_key)) {
         $result = EventRead::getNextEvent();
     } else {
         // Access Denied detected
         $errors = "Access Denied";
         $status_code = HttpRequest::$ACCESS_DENIED_CODE;
         $status = false;
     }
     $arrResponse = array('api_ver' => self::$API_VERSION, 'caller' => $android_callback, 'error' => $errors, 'status_code' => $status_code, 'status' => $status, 'result' => $result);
     return $arrResponse;
 }
 /**
  * API for event participant
  */
 public function getEventParticipant(Request $request)
 {
     $errors = "";
     $status_code = 200;
     $status = "";
     $result = "";
     $user_id = $request->get('user_id');
     $event_id = $request->get('event_id');
     $public_access_key = $request->query('api_key');
     // Get android callback
     $android_callback = $request->query('caller');
     // If the Api Key is valid
     if (UtilityController::validateApiKey($public_access_key)) {
         /* Future enhance with the weighing measurement
          * Temporary assign all to default value
          */
         $request['weight'] = self::$weight;
         // Validate Event
         $intValidateStatus = EventParticipant::validateParticipantEvent($user_id, $event_id, $result, $error);
         // Done all Validation for user and event
         if ($intValidateStatus == 1) {
             $result = '{"event_id": ' . $event_id . ',"user_id": ' . $user_id . '}';
             // Input into Event Spool
             EventParticipantCreate::participateEvent($request);
             UserParticipantManage::logUserParticipant($user_id);
             $status = true;
         }
     } else {
         // Access Denied detected
         $errors = "Access Denied";
         $status_code = HttpRequest::$ACCESS_DENIED_CODE;
         $status = false;
     }
     $arrResponse = array('api_ver' => self::$API_VERSION, 'caller' => $android_callback, 'error' => $errors, 'status_code' => $status_code, 'status' => $status, 'result' => $result);
     return $arrResponse;
 }
 public static function getExpiredDate($duration)
 {
     return UtilityController::getAdvanceDayDate($duration, false);
 }