private function set_property_info_list($ref_tag) { $ref_param = array("ref_tag" => $ref_tag); $val_return_json = GeneralFunc::CB_SendReceive_Service_Request("CB_Property:listing_detail", json_encode($ref_param)); $val_return = json_decode($val_return_json, TRUE); if ($val_return["status_information"] === sprintf("Info: Successfully retrieve data for %s", $ref_tag)) { $this->session->set_userdata('owner_email', $val_return["data"]["email"]); $this->session->set_userdata('ref_tag', $ref_tag); $this->property_info_list = $val_return["data"]; } else { $error = "Your selected property does not exist"; show_error($this->get_listing_not_found($error), 300, ""); } }
public function activate_listing($ref_tag, $user_id, $activate, &$val_return_array) { $activate_data = array(); $activate_data["ref_tag"] = $ref_tag; $activate_data["user_id"] = $user_id; $activate_data["activate"] = $activate; if ($activate === "true") { if (!$this->is_listing_available($user_id)) { return FALSE; } } $val_return = GeneralFunc::CB_SendReceive_Service_Request("CB_Property:change_listing_activate", json_encode($activate_data)); $val_return_array = json_decode($val_return, true); if ($val_return_array["status_information"] === "Info: Complete change activation status") { return TRUE; } return FALSE; }
public function get_user_number_of_available_listing() { $user_id = $this->session->userdata('user_id'); $filter_struct = array("filter" => array()); if ($user_id) { //setup the listing filter by user id $filter_struct["filter"]["user_id"] = $user_id; $filter_struct["filter"]["activate"] = '1'; //get the filtered listing details $user_listing_limit = GeneralFunc::CB_SendReceive_Service_Request("CB_Member:get_user_property_listing_limit", json_encode($user_id)); $listing_limit = json_decode($user_listing_limit, TRUE)["data"]["result"]; $user_existing_listing = GeneralFunc::CB_SendReceive_Service_Request("CB_Property:filter_listing", json_encode($filter_struct)); $number_of_listings = sizeof(json_decode($user_existing_listing, TRUE)["data"]["listing"]); $number_of_remaining_listings = $listing_limit - $number_of_listings; // Consolidate all data into a container $return_json = array("listing_limit" => (int) $listing_limit, "listing_avaliable" => $number_of_remaining_listings, "listing_used" => $number_of_listings); $this->_print(json_encode($return_json)); } else { $this->set_error("function:get_number_of_listings failed with invalid user id: (" . $user_id . ")"); } }
public function begin_reset_password() { $CI =& get_instance(); $CI->load->helper('url'); $CI->load->library('session'); $CI->load->library('extemplate'); $msg = ""; $success = TRUE; $data = NULL; $forgot_pass_obj = NULL; $pass = $this->_get_posted_value('password'); $confirmed_pass = $this->_get_posted_value('confirmed_password'); if (is_null($pass)) { $msg = "<span class='error'>Password cannot be empty</span>"; $success = FALSE; } elseif (is_null($confirmed_pass)) { $msg = "<span class='error'>Confirmed password cannot be empty</span>"; $success = FALSE; } elseif ($confirmed_pass !== $pass) { $msg = "<span class='error'>Password does not match with confirmed password</span>"; $success = FALSE; } if ($success) { $data["new_password"] = $pass; $forgot_pass_obj = $CI->session->userdata("forgotpassword"); if (!$forgot_pass_obj && (!isset($forgot_pass_obj["user_id"]) || !isset($forgot_pass_obj["new_pass_key"]))) { $msg = var_dump($forgot_pass_obj); //$data['new_pass_key']; $success = FALSE; } else { #$msg = var_dump($forgot_pass_obj); $data['user_id'] = $forgot_pass_obj["user_id"]; $data['new_pass_key'] = $forgot_pass_obj["new_pass_key"]; } } if ($success) { $val_return = GeneralFunc::CB_SendReceive_Service_Request("CB_Member:reset_password", json_encode($data)); $data = json_decode($val_return, TRUE); $data = $data["data"]["result"]; if (!is_null($data)) { $data['site_name'] = $CI->config->item('website_name'); if (isset($data["error"])) { $success = FALSE; $msg = $data["error"]; #$msg = "<span class='error'>" . var_dump($forgot_pass_obj) . "</span>"; } else { $success = TRUE; $msg = "Success"; } } else { $msg = "<span class='error'>Your password cannot been reset, please check with the admin.</span>"; $success = FALSE; } } $data["msg"] = $msg; $this->_print(json_encode($data)); }
public function get_converted_currency_value() { $currency_value = $this->_get_posted_value('currency_value'); $from_currency = $this->_get_posted_value('from_currency'); $to_currency = $this->_get_posted_value('to_currency'); $argument = json_encode(array("currency_value" => $currency_value, "from_currency" => $from_currency, "to_currency" => $to_currency)); $val_return_json = GeneralFunc::CB_SendReceive_Service_Request("CB_Currency:get_converted_currency_value", $argument); $val_return = json_decode($val_return_json, TRUE); $converted_currency_value = $val_return['data']['result']; $this->_print($converted_currency_value); }
protected function _check_recaptcha($website_name, $response_field, $challenge_field) { $captcha_code["remote_addr"] = $website_name; $captcha_code["challenge_field"] = $challenge_field; $captcha_code["response_field"] = $response_field; $val_return_json = GeneralFunc::CB_SendReceive_Service_Request("CB_Member:check_recaptcha", json_encode($captcha_code)); $val_return = json_decode($val_return_json, TRUE); return $val_return["data"]["result"]; }
function obtain_search_result() { // display per page $limit = 9; // $search_result["nav_total_page"] = 0; $search_result["total_result"] = 0; $search_result["search_result"] = array(); $ref_tag_list = array(); // Special handle for property_type_selection $property_category_selection = $this->_get_array_value($_GET, "property_category_selection"); if ($property_category_selection === "All Category") { $property_category_selection = NULL; } $property_type_selection = $this->_get_array_value($_GET, "property_type_selection"); if ($property_type_selection === "All Type") { $property_type_selection = NULL; } // Process page nav if no pass in $page_nav_num = $this->_get_array_value($_GET, "nav_page"); if ($page_nav_num == NULL || $page_nav_num <= 0) { $page_nav_num = 1; } $origin_max = $this->_get_array_value($_GET, "max_price"); $origin_min = $this->_get_array_value($_GET, "min_price"); $origin_currency = $this->_get_array_value($_GET, "currency"); $measurement_max = $this->_get_array_value($_GET, "max_sqft"); $measurement_min = $this->_get_array_value($_GET, "min_sqft"); $origin_measurement_type = $this->_get_array_value($_GET, "measurement_type"); //$supported_currency = $this->get_currency_list(); //$val_return = GeneralFunc::CB_SendReceive_Service_Request("CB_Currency:get_currency_list", NULL); $supported_currency = $this->get_currency_list(); //$supported_currency = json_decode($val_return, TRUE)['data']['result']; for ($i = 0; $i < count($supported_currency); $i++) { $currency_enum_to_string = $this->convert_currency_from_enum_to_string($i); for ($j = 0; $j < measurement_type::__len; $j++) { $price_range = $this->construct_currency_range($origin_max, $origin_min, $origin_currency, $i); $width_range = $this->construct_width_range($measurement_max, $measurement_min, $origin_measurement_type, MeasurementFactory::get_measurement_type_string($j)); $filter_array = array("limit" => $limit, "offset" => $limit * ($page_nav_num - 1), "filter" => array("activate" => 1, "service_type" => $this->session->userdata('action'), "state" => $this->_get_array_value($_GET, "selected_state"), "country" => $this->_get_array_value($_GET, "selected_country"), "property_category" => $property_category_selection, "property_type" => $property_type_selection, "unit_name" => $this->_get_array_value($_GET, "place_name"), "price <=" => $price_range[1] === "" || $price_range[1] === "0.00" ? NULL : $price_range[1], "price >=" => $price_range[0], "buildup <=" => $width_range[1] === "" || $width_range[1] === "0.00" ? NULL : $width_range[1], "buildup >=" => $width_range[0], "currency" => $currency_enum_to_string, "size_measurement_code" => MeasurementFactory::get_measurement_type_string($j))); // Invoke webservice to retrieve filter data $service = "CB_Property:filter_listing"; $val_return = GeneralFunc::CB_SendReceive_Service_Request($service, json_encode($filter_array)); if ($val_return === NULL) { continue; } $val_return_json_array = json_decode($val_return, true); // @todo - require better error handing $val_return_array = $val_return_json_array["data"]; // Align the data with output requirement foreach ($val_return_array["listing"] as $query_data) { if (in_array($query_data["ref_tag"], $ref_tag_list)) { $val_return_array["count"] = $val_return_array["count"] - 1; } else { $data = $this->convert_search_result_to_data($query_data); array_push($search_result["search_result"], $data); array_push($ref_tag_list, $data["ref_tag"]); } } $search_result["nav_total_page"] += ceil($val_return_array["count"] / $limit); $search_result["total_result"] += $val_return_array["count"]; } } echo json_encode($search_result); }
public function is_user_allowed_to_create_new_listing() { $user_id = $this->session->userdata('user_id'); $allowed = true; if ($user_id) { //setup the listing filter by user id $filter_struct["filter"]["user_id"] = $user_id; $filter_struct["filter"]["activate"] = 1; //get the filtered listing details $user_listing_limit = GeneralFunc::CB_SendReceive_Service_Request("CB_Member:get_user_property_listing_limit", json_encode($user_id)); $listing_limit = json_decode($user_listing_limit, TRUE)["data"]["result"]; $user_existing_listing = GeneralFunc::CB_SendReceive_Service_Request("CB_Property:filter_listing", json_encode($filter_struct)); $number_of_listings = sizeof(json_decode($user_existing_listing, TRUE)["data"]["listing"]); if ($number_of_listings < $listing_limit) { $allowed = true; } else { $allowed = false; } return $allowed; } else { $this->set_error("function:get_number_of_listings failed with invalid user id: (" . $user_id . ")"); } }
public function SendReceive_Service($service, $argument) { // Benchmark the function required time $this->benchmark->mark("ws_code_start"); $val_return = GeneralFunc::CB_SendReceive_Service_Request($service, $argument); $this->benchmark->mark("ws_code_end"); $data = "{$service} - " . $this->benchmark->elapsed_time('ws_code_start', 'ws_code_end'); $this->benchmark_dump_file($data); return $val_return; }