private static function get_property_suggestions_criteria() { if (!empty(self::$_model['property_suggestions']->search_criteria)) { parse_str(self::$_model['property_suggestions']->search_criteria, $criteria); if (!empty($criteria)) { $translated_criteria = array(); foreach ($criteria as $field => $value) { $translated_field = DispletRetsIdxResidentialsModel::get_translated_legacy_search_field($field); if (!empty($translated_field)) { $translated_criteria[] = $translated_field . '=' . $value; } } return $translated_criteria; } } }
public static function update_viewed_searches() { check_ajax_referer('displet_update_searches_nonce'); if (isset($_POST['action']) && $_POST['action'] == 'displet_update_searches' && !empty($_POST['last_hash'])) { $user_id = get_current_user_id(); if ($user_id != 0 && current_user_can('displet_save_searches') && !current_user_can(self::$_capabilities['view_leads'])) { $user_searches = get_user_meta($user_id, 'displet_user_hashes', true); $user_searches[] = $_POST['last_hash']; $user_searches_count = count($user_searches); update_user_meta($user_id, 'displet_user_hashes', $user_searches); update_user_meta($user_id, 'displet_user_hashes_count', $user_searches_count); $search_criteria = DispletRetsIdxResidentialsModel::get_search_criteria_from_hash($_POST['last_hash']); self::_send_saved_search_to_api($user_id, $search_criteria); do_action('displetretsidx_post_lead_viewed_search', $user_id, array('all_hashes' => $user_searches, 'hash_count' => $user_searches_count, 'last_hash' => $_POST['last_hash'])); } } die; }
public static function add_property_filter_to_saved_searches_per_user($user_id) { $api_user_id = get_user_meta($user_id, 'displet_api_user_id', true); $saved_searches = get_user_meta($user_id, 'displet_saved_searches', true); if (!empty($api_user_id) && !empty($saved_searches) && is_array($saved_searches)) { foreach ($saved_searches as $saved_search) { if (!empty($saved_search['api_id'])) { $criteria = DispletRetsIdxUtilities::get_search_criteria_array_from_hash($saved_search['hash']); $original_criteria = $criteria; $criteria['city'] = DispletRetsIdxResidentialsModel::get_filtered_city($criteria['city'], false); $criteria['max_list_price'] = DispletRetsIdxResidentialsModel::get_filtered_max_price($criteria['max_list_price']); $criteria['min_list_price'] = DispletRetsIdxResidentialsModel::get_filtered_min_price($criteria['min_list_price']); $criteria['property_type'] = DispletRetsIdxResidentialsModel::get_filtered_property_type($criteria['property_type'], false); $criteria['zip'] = DispletRetsIdxResidentialsModel::get_filtered_zip($criteria['zip'], false); $criteria = array_filter($criteria); if ($original_criteria !== $criteria) { DispletRetsIdxUsersApiController::update_saved_search($api_user_id, $saved_search['api_id'], $criteria); } } } } }
private static function _set_search_field_labels() { self::$_model['search_field_labels'] = DispletRetsIdxResidentialsModel::get_search_field_labels(); }
public static function send_users_saved_searches_to_api($user_id, $api_user_id) { if (!empty($user_id) && !empty($api_user_id)) { $saved_searches = get_user_meta($user_id, 'displet_saved_searches', true); if (!empty($saved_searches)) { $new_saved_searches = array(); foreach ($saved_searches as $saved_search) { if (is_array($saved_search)) { $hash = $saved_search['hash']; $name = $saved_search['name']; } else { $hash = $saved_search; $name = false; } if (empty($name)) { $name = wp_generate_password(12, false); } $criteria = DispletRetsIdxResidentialsModel::get_search_criteria_from_hash($hash); $saved_search_id = DispletRetsIdxUsersApiController::create_saved_search($api_user_id, $name, $criteria); $new_saved_searches[] = array('hash' => $hash, 'name' => $name, 'api_id' => $saved_search_id); } update_user_meta($user_id, 'displet_saved_searches', $new_saved_searches); } } }
/** * @param: $field: string ( area_mls_defined, city, property_type or school_district or status ) * @return: success: array * @return: failure: false */ function displetretsidx_get_filtered_field_options($field) { return DispletRetsIdxResidentialsModel::get_filtered_field_options($field); }
/** * @return: print: HTML markup */ function displetretsidx_the_save_search_registration_property_type_options() { echo DispletRetsIdxUtilities::get_select_options(DispletRetsIdxResidentialsModel::get_filtered_field_options('property_type'), 'Property Type'); }