application/controllers/Common.php
/* Function for shortlist the property and rate */
Function for shortlist the property and rate
Function for shortlist the property and rate
public function shortlist_property_post(){
    	$post_data = $this->post();
    	$userId = $post_data['userId'];
    	$loginUserId = $post_data['loginUserId'];
    	$searchId = $post_data['searchId'];
		$this->form_validation->set_data($post_data);
		$this->form_validation->set_error_delimiters('', '');
		$this->form_validation->set_rules('userId','User Id','required|numeric|callback_user_check');	
		if($userId != $loginUserId){
			$this->form_validation->set_rules('loginUserId','User Id','required|numeric|callback_user_in_tribe_check['.$post_data['searchId'].']');	
		}
		$this->form_validation->set_rules('searchId','Search criteria id','required|numeric|callback_search_criteria_check');	
		if ($this->form_validation->run() === false) {
    			$this->response(array('ResponseCode' => 0, 'ResponseMessage' => 'FAILURE', 'Comments' => validation_errors(),'Result'=>''), 400);    		
		}else{
			$shortlist_property = $this->Common_model->shortlist_property($post_data);
			if($shortlist_property){
				$shortlistedId = $shortlist_property['shortlistedId'];
				$shortlist_property['loginUserId'] = $loginUserId;				
				if ($shortlist_property) {
					ob_start();			
					$response = array('ResponseCode' => 1, 'ResponseMessage' => 'SUCCESS', 'Comments' => $_POST['message'],'Result'=>$shortlist_property,'Status' =>200);
			        echo json_encode($response); 
					$size = ob_get_length();
					header("Content-Encoding: none");
					header("Content-Length: {$size}");
					header("Connection: close");
					ob_end_flush();
					ob_flush();
					flush();
					if($_POST['message'] == 'Property rated successfully' || $_POST['message'] == 'Property rate updated successfully' || $_POST['message'] == 'Property shortlisted and rated successfully' || $_POST['message'] == 'Property shortlisted successfully')
					{
						$shortlistedId = $shortlistedId;
						$get_user_serach_property_info = $this->Common_model->get_user_serach_property_info($searchId,$shortlistedId);
						if($get_user_serach_property_info){
							$login_user_info = $this->Common_model->login_user_info($loginUserId);
							if($login_user_info){
								$user_name = $login_user_info[0]['firstName'];
							}else{
								$user_name = "";
							}
							$searchName = $get_user_serach_property_info[0]['searchName'];
							$propertyName = $get_user_serach_property_info[0]['propertyName'];
							$rate_tribe_users_device_tokens = $this->Common_model->rate_tribe_users_device_tokens($post_data);
							if(sizeof($rate_tribe_users_device_tokens)>0){
								$tribeDeviceToken = ARRAY();	
								foreach ($rate_tribe_users_device_tokens as $row) {
									if($row["deviceToken"]){
										$tribeDeviceToken[] = $row["deviceToken"];
									}							
								}
								if($_POST['message'] == 'Property rated successfully' || $_POST['message'] == 'Property rate updated successfully')
								{
									$message = $this->config->item('notification_for_rate_on_property');
									$category = "CATEGORY_RATE";
								}
								if($_POST['message'] == 'Property shortlisted and rated successfully' || $_POST['message'] == 'Property shortlisted successfully')
								{
									$message = $this->config->item('notification_for_shortlist_property');
									$category = "CATEGORY_SHORTLIST_PROPERTY";
								}
									$message_to_push = str_replace("name", $user_name, $message[0]);						
									$message_to_push_event = str_replace("propertyName", $propertyName, $message_to_push);
									$message_to_push_search = str_replace("searchName", $searchName, $message_to_push_event);
									$message_to_push_notification = $message_to_push_search;
									$payload = json_encode([
										'aps' => [
											'alert' => $message_to_push_notification,
											'sound' => 'cat.caf',
											'badge' => 1,
											'content-available' => 1,
											'category' => $category
										],
										"push_type"=> $message[1],
										"loginUserId"=> $loginUserId,
										"userId"=> $userId,
										"searchId"=> $searchId,
										"shortlistedId"=>$shortlistedId
									]);	
									$this->send_multiple_user_notification_ios($tribeDeviceToken, $payload);
							}
						}
					}
				}				
			}else{
				$this->response(array('ResponseCode' => 0, 'ResponseMessage' => 'FAILURE', 'Comments' => 'Fail to shortlist property','Result'=>false), 400);
			}
		}
    }
public function shortlist_property_post ( ) { $ post_data = $ this -> post ( ) ; $ userId = $ post_data [ 'userId' ] ; $ loginUserId = $ post_data [ 'loginUserId' ] ; $ searchId = $ post_data [ 'searchId' ] ; $ this -> form_validation -> set_data ( $ post_data ) ; $ this -> form_validation -> set_error_delimiters ( '' , '' ) ; $ this -> form_validation -> set_rules ( 'userId' , 'User Id' , 'required|numeric|callback_user_check' ) ; if ( $ userId != $ loginUserId ) { $ this -> form_validation -> set_rules ( 'loginUserId' , 'User Id' , 'required|numeric|callback_user_in_tribe_check[' . $ post_data [ 'searchId' ] . ']' ) ; } $ this -> form_validation -> set_rules ( 'searchId' , 'Search criteria id' , 'required|numeric|callback_search_criteria_check' ) ; if ( $ this -> form_validation -> run ( ) === false ) { $ this -> response ( array ( 'ResponseCode' => 0 , 'ResponseMessage' => 'FAILURE' , 'Comments' => validation_errors ( ) , 'Result' => '' ) , 400 ) ; } else { $ shortlist_property = $ this -> Common_model -> shortlist_property ( $ post_data ) ; if ( $ shortlist_property ) { $ shortlistedId = $ shortlist_property [ 'shortlistedId' ] ; $ shortlist_property [ 'loginUserId' ] = $ loginUserId ; if ( $ shortlist_property ) { ob_start ( ) ; $ response = array ( 'ResponseCode' => 1 , 'ResponseMessage' => 'SUCCESS' , 'Comments' => $ _POST [ 'message' ] , 'Result' => $ shortlist_property , 'Status' => 200 ) ; echo json_encode ( $ response ) ; $ size = ob_get_length ( ) ; header ( " Content-Encoding: none " ) ; header ( " Content-Length:  { $ size } " ) ; header ( " Connection: close " ) ; ob_end_flush ( ) ; ob_flush ( ) ; flush ( ) ; if ( $ _POST [ 'message' ] == 'Property rated successfully' || $ _POST [ 'message' ] == 'Property rate updated successfully' || $ _POST [ 'message' ] == 'Property shortlisted and rated successfully' || $ _POST [ 'message' ] == 'Property shortlisted successfully' ) { $ shortlistedId = $ shortlistedId ; $ get_user_serach_property_info = $ this -> Common_model -> get_user_serach_property_info ( $ searchId , $ shortlistedId ) ; if ( $ get_user_serach_property_info ) { $ login_user_info = $ this -> Common_model -> login_user_info ( $ loginUserId ) ; if ( $ login_user_info ) { $ user_name = $ login_user_info [ 0 ] [ 'firstName' ] ; } else { $ user_name = " " ; } $ searchName = $ get_user_serach_property_info [ 0 ] [ 'searchName' ] ; $ propertyName = $ get_user_serach_property_info [ 0 ] [ 'propertyName' ] ; $ rate_tribe_users_device_tokens = $ this -> Common_model -> rate_tribe_users_device_tokens ( $ post_data ) ; if ( sizeof ( $ rate_tribe_users_device_tokens ) > 0 ) { $ tribeDeviceToken = ARRAY ( ) ; foreach ( $ rate_tribe_users_device_tokens as $ row ) { if ( $ row [ " deviceToken " ] ) { $ tribeDeviceToken [ ] = $ row [ " deviceToken " ] ; } } if ( $ _POST [ 'message' ] == 'Property rated successfully' || $ _POST [ 'message' ] == 'Property rate updated successfully' ) { $ message = $ this -> config -> item ( 'notification_for_rate_on_property' ) ; $ category = " CATEGORY_RATE " ; } if ( $ _POST [ 'message' ] == 'Property shortlisted and rated successfully' || $ _POST [ 'message' ] == 'Property shortlisted successfully' ) { $ message = $ this -> config -> item ( 'notification_for_shortlist_property' ) ; $ category = " CATEGORY_SHORTLIST_PROPERTY " ; } $ message_to_push = str_replace ( " name " , $ user_name , $ message [ 0 ] ) ; $ message_to_push_event = str_replace ( " propertyName " , $ propertyName , $ message_to_push ) ; $ message_to_push_search = str_replace ( " searchName " , $ searchName , $ message_to_push_event ) ; $ message_to_push_notification = $ message_to_push_search ; $ payload = json_encode ( [ 'aps' => [ 'alert' => $ message_to_push_notification , 'sound' => 'cat.caf' , 'badge' => 1 , 'content-available' => 1 , 'category' => $ category ] , " push_type " => $ message [ 1 ] , " loginUserId " => $ loginUserId , " userId " => $ userId , " searchId " => $ searchId , " shortlistedId " => $ shortlistedId ] ) ; $ this -> send_multiple_user_notification_ios ( $ tribeDeviceToken , $ payload ) ; } } } } } else { $ this -> response ( array ( 'ResponseCode' => 0 , 'ResponseMessage' => 'FAILURE' , 'Comments' => 'Fail to shortlist property' , 'Result' => false ) , 400 ) ; } } }
Function for shortlist the property and rate
Function for shortlist the property and rate
//$propertyUrl = $post_data['propertyUrl']; /*if(!empty($propertyUrl)){			
			$this->form_validation->set_rules('propertyUrl', 'Property image', 'required|callback_handle_property_image_upload');		
		}else{
			unset($post_data['propertyUrl']);
		}
		*/ //print_r($shortlist_property);exit(); // Get the size of the output. // Disable compression (in case content length is compressed). // Set the content length of the response. // Close the connection. // Flush all output. //send push to tribe members when rated //shortlisted property id //print_r($user_serach_info);exit(); //$device_token = $get_user_serach_property_info[0]['deviceToken']; /*Get the device tokens of tribe members for sending push */ //print_r($get_exists_users);exit(); //send notification //print_r($payload);exit(); //get_user_serach_property_info /*$this->response(array('ResponseCode' => 1, 'ResponseMessage' => 'SUCCESS', 'Comments' => $_POST['message'],'Result'=>true), 200);
				*/