/** * Function to limit event query by location. * * @string $type {deprecated} * @string $ltype {location type} * @mixed (string/integer) $lvalue {location value} */ function mc_limit_string($type = '', $ltype = '', $lvalue = '') { global $user_ID; $limit_string = $location = $current_location = ""; if (isset($_GET['loc']) && isset($_GET['ltype']) || $ltype != '' && $lvalue != '') { if (!isset($_GET['loc']) && !isset($_GET['ltype'])) { if ($ltype != '' && $lvalue != '') { $location = $ltype; $current_location = $lvalue; } } else { $location = urldecode($_GET['ltype']); $current_location = urldecode($_GET['loc']); } switch ($location) { case "name": $location_type = "event_label"; break; case "city": $location_type = "event_city"; break; case "state": $location_type = "event_state"; break; case "zip": $location_type = "event_postcode"; break; case "country": $location_type = "event_country"; break; case "region": $location_type = "event_region"; break; default: $location_type = $location; } if (in_array($location_type, array('event_label', 'event_city', 'event_state', 'event_postcode', 'event_country', 'event_region', 'event_location', 'event_street', 'event_street2', 'event_url', 'event_longitude', 'event_latitude', 'event_zoom', 'event_phone', 'event_phone2'))) { if ($current_location != 'all' && $current_location != '') { if (is_numeric($current_location)) { $limit_string = "{$location_type} = " . (int) $current_location . " AND"; } else { $limit_string = "{$location_type} = '" . esc_sql($current_location) . "' AND"; } } } } if ($limit_string != '') { if (isset($_GET['loc2']) && isset($_GET['ltype2'])) { $limit_string .= mc_secondary_limit($_GET['ltype2'], $_GET['loc2']); } } if (isset($_GET['access'])) { $limit_string .= mc_access_limit($_GET['access']); } return $limit_string; }
function mc_limit_string($type = '', $ltype = '', $lvalue = '') { global $user_ID; $user_settings = get_option('mc_user_settings'); $limit_string = ""; if (get_option('mc_user_settings_enabled') == 'true' && isset($user_settings['my_calendar_location_default']['enabled']) && $user_settings['my_calendar_location_default']['enabled'] == 'on' || isset($_GET['loc']) && isset($_GET['ltype']) || $ltype != '' && $lvalue != '') { if (!isset($_GET['loc']) && !isset($_GET['ltype'])) { if ($ltype == '' && $lvalue == '') { if (is_user_logged_in()) { get_currentuserinfo(); $current_settings = get_user_meta($user_ID, 'my_calendar_user_settings'); $current_location = $current_settings['my_calendar_location_default']; $location = get_option('mc_location_type'); } } else { if ($ltype != '' && $lvalue != '') { $location = $ltype; $current_location = esc_sql($lvalue); } } } else { $current_location = urldecode($_GET['loc']); $location = urldecode($_GET['ltype']); } switch ($location) { case "name": $location_type = "event_label"; break; case "city": $location_type = "event_city"; break; case "state": $location_type = "event_state"; break; case "zip": $location_type = "event_postcode"; break; case "country": $location_type = "event_country"; break; case "region": $location_type = "event_region"; break; default: $location_type = $location; } if ($current_location != 'all' && $current_location != '') { $limit_string = "{$location_type}='{$current_location}' AND"; //$limit_string .= ($type=='all')?' AND':""; } } if ($limit_string != '') { if (isset($_GET['loc2']) && isset($_GET['ltype2'])) { $limit_string .= mc_secondary_limit($_GET['ltype2'], $_GET['loc2']); } } if (isset($_GET['access'])) { $limit_string .= mc_access_limit($_GET['access']); } return $limit_string; }