public function home() { /** check permission **/ wpl_global::min_access('administrator'); $this->level = trim(wpl_request::getVar('level')) != '' ? wpl_request::getVar('level') : 1; $this->parent = trim(wpl_request::getVar('sf_select_parent')) != '' ? wpl_request::getVar('sf_select_parent') : ""; $this->enabled = trim(wpl_request::getVar('sf_select_enabled')) != '' ? wpl_request::getVar('sf_select_enabled') : 1; $this->text_search = trim(wpl_request::getVar('sf_text_name')) != '' ? wpl_request::getVar('sf_text_name') : ''; $this->admin_url = wpl_global::get_wp_admin_url(); $this->load_zipcodes = trim(wpl_request::getVar('load_zipcodes')) != '' ? 1 : 0; /** set show all based on level **/ if ($this->level != 1) { $this->enabled = ''; } $possible_orders = array('id', 'name'); $orderby = in_array(wpl_request::getVar('orderby'), $possible_orders) ? wpl_request::getVar('orderby') : $possible_orders[0]; $order = in_array(strtoupper(wpl_request::getVar('order')), array('ASC', 'DESC')) ? wpl_request::getVar('order') : 'ASC'; $page_size = trim(wpl_request::getVar('page_size')) != '' ? wpl_request::getVar('page_size') : NULL; /** create where **/ $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET')); $vars = array_merge($vars, array('sf_select_parent' => $this->parent, 'sf_select_enabled' => $this->enabled)); $where_query = wpl_db::create_query($vars); $num_result = wpl_db::num("SELECT COUNT(id) FROM `#__wpl_location" . $this->level . "` WHERE 1 " . $where_query); $this->pagination = wpl_pagination::get_pagination($num_result, $page_size); $where_query .= " ORDER BY {$orderby} {$order} " . $this->pagination->limit_query; $this->wp_locations = wpl_locations::get_locations(!$this->load_zipcodes ? $this->level : 'zips', '', '', $where_query); $this->zipcode_parent_level = wpl_settings::get('zipcode_parent_level'); /** import tpl **/ parent::render($this->tpl_path, $this->tpl); }
public function user_manager() { /** check permission **/ wpl_global::min_access('administrator'); $possible_orders = array('u.id', 'u.user_registered'); $orderby = in_array(wpl_request::getVar('orderby'), $possible_orders) ? wpl_request::getVar('orderby') : $possible_orders[0]; $order = in_array(strtoupper(wpl_request::getVar('order')), array('ASC', 'DESC')) ? wpl_request::getVar('order') : 'ASC'; $page_size = trim(wpl_request::getVar('page_size')) != '' ? wpl_request::getVar('page_size') : NULL; $this->show_all = wpl_request::getVar('show_all', 0); $this->filter = wpl_request::getVar('filter', ''); $this->membership_id = wpl_request::getVar('membership_id', ''); $where_query = wpl_db::create_query(); if (trim($this->filter)) { $where_query = " AND (`user_login` LIKE '%" . $this->filter . "%' OR `user_email` LIKE '%" . $this->filter . "%' OR `first_name` LIKE '%" . $this->filter . "%' OR `last_name` LIKE '%" . $this->filter . "%')"; } if (trim($this->membership_id)) { $where_query = " AND `membership_id`='" . $this->membership_id . "'"; } $num_result = wpl_db::num("SELECT COUNT(u.ID) FROM `#__users` AS u " . ($this->show_all ? 'LEFT' : 'INNER') . " JOIN `#__wpl_users` AS wpl ON u.ID = wpl.id WHERE 1 {$where_query}"); $this->pagination = wpl_pagination::get_pagination($num_result, $page_size); $where_query .= " ORDER BY {$orderby} {$order} " . $this->pagination->limit_query; if ($this->show_all) { $this->wp_users = wpl_users::get_wp_users($where_query); } else { $this->wp_users = wpl_users::get_wpl_users($where_query); } $this->memberships = wpl_users::get_wpl_memberships(); /** import tpl **/ parent::render($this->tpl_path, $this->tpl); }
/** * Starts the search command * @author Howard R <*****@*****.**> * @param int $start * @param int $limit * @param string $orderby * @param string $order * @param array $where */ public function start($start, $limit, $orderby, $order, $where) { /** start time of model **/ $this->start_time = microtime(true); /** pagination and order options **/ $this->start = $start; $this->limit = $limit; $this->orderby = $orderby; $this->order = $order; /** main table **/ $this->main_table = "`#__wpl_users` AS p"; /** queries **/ $this->join_query = $this->create_join(); $this->groupby_query = $this->create_groupby(); /** generate where condition **/ $where = (array) $where; $this->where = wpl_db::create_query($where); /** generate select **/ $this->select = '*'; }
private function query($instance) { /** property listing model **/ $model = new wpl_property(); $data = $instance['data']; $this->start = 0; $this->limit = $data['limit']; $this->orderby = urldecode($data['orderby']); $this->order = $data['order']; /** detect kind **/ if (isset($data['kind']) and (trim($data['kind']) != '' or trim($data['kind']) != '-1')) { $kind = $data['kind']; } else { $kind = 0; } $where = array('sf_select_confirmed' => 1, 'sf_select_finalized' => 1, 'sf_select_deleted' => 0, 'sf_select_expired' => 0, 'sf_select_kind' => $kind); if (trim($data['listing']) and $data['listing'] != '-1') { $where['sf_select_listing'] = $data['listing']; } if (trim($data['property_type']) and $data['property_type'] != '-1') { $where['sf_select_property_type'] = $data['property_type']; } if (trim($data['property_ids'])) { $where['sf_multiple_id'] = trim($data['property_ids'], ', '); } if (trim($data['only_featured'])) { $where['sf_select_sp_featured'] = 1; } if (trim($data['only_hot'])) { $where['sf_select_sp_hot'] = 1; } if (trim($data['only_openhouse'])) { $where['sf_select_sp_openhouse'] = 1; } if (trim($data['only_forclosure'])) { $where['sf_select_sp_forclosure'] = 1; } /** Parent **/ if (isset($data['parent']) and trim($data['parent'])) { $where['sf_parent'] = $data['parent']; } if (isset($data['auto_parent']) and trim($data['auto_parent'])) { /** current proeprty id - This features works only in single property page **/ $property_data = NULL; $pid = wpl_request::getVar('pid', 0); if ($pid) { $property_data = $model->get_property_raw_data($pid); } if (isset($property_data['mls_id'])) { $where['sf_parent'] = $property_data['mls_id']; } } if (isset($data['random']) and trim($data['random']) and trim($data['property_ids']) == '') { $query_rand = "SELECT p.`id` FROM `#__wpl_properties` AS p WHERE 1 " . wpl_db::create_query($where) . " ORDER BY RAND() LIMIT " . $this->limit; $results = wpl_db::select($query_rand); $rand_ids = array(); foreach ($results as $result) { $rand_ids[] = $result->id; } $where['sf_multiple_id'] = implode(',', $rand_ids); } /** Similar properties **/ if (isset($data['sml_only_similars']) and $data['sml_only_similars']) { $sml_where = array('sf_select_confirmed' => 1, 'sf_select_finalized' => 1, 'sf_select_deleted' => 0, 'sf_select_expired' => 0); /** current proeprty id - This features works only in single property page **/ $pid = wpl_request::getVar('pid', 0); $property_data = wpl_property::get_property_raw_data($pid); if ($property_data) { $sml_where['sf_notselect_id'] = $pid; $sml_where['sf_select_kind'] = $property_data['kind']; if (isset($data['sml_inc_listing']) and $data['sml_inc_listing']) { $sml_where['sf_select_listing'] = $property_data['listing']; } if (isset($data['sml_inc_property_type']) and $data['sml_inc_property_type']) { $sml_where['sf_select_property_type'] = $property_data['property_type']; } if (isset($data['sml_inc_price']) and $data['sml_inc_price']) { $down_rate = $data['sml_price_down_rate'] ? $data['sml_price_down_rate'] : 0.8; $up_rate = $data['sml_price_up_rate'] ? $data['sml_price_up_rate'] : 1.2; $price_down_range = $property_data['price_si'] * $down_rate; $price_up_range = $property_data['price_si'] * $up_rate; $sml_where['sf_tmin_price_si'] = $price_down_range; $sml_where['sf_tmax_price_si'] = $price_up_range; } if (isset($data['sml_inc_radius']) and $data['sml_inc_radius']) { $latitude = $property_data['googlemap_lt']; $longitude = $property_data['googlemap_ln']; $radius = $data['sml_radius']; $unit_id = $data['sml_radius_unit']; if ($latitude and $longitude and $radius and $unit_id) { $sml_where['sf_radiussearchunit'] = $unit_id; $sml_where['sf_radiussearch_lat'] = $latitude; $sml_where['sf_radiussearch_lng'] = $longitude; $sml_where['sf_radiussearchradius'] = $radius; } } } /** overwrite $where if similar where is correct **/ if (count($sml_where) > 3) { $where = $sml_where; } } /** start search **/ $model->start($this->start, $this->limit, $this->orderby, $this->order, $where); /** run the search **/ return $model->query(); }
/** * Starts search command * @author Howard R <*****@*****.**> * @param int $start * @param int $limit * @param string $orderby * @param string $order * @param array $where * @param int $kind */ public function start($start, $limit, $orderby, $order, $where, $kind = 0) { /** start time of model **/ $this->start_time = microtime(true); if (in_array($orderby, array('p.mls_id+0', 'p.mls_id'))) { $orderby = 'cast(p.mls_id as unsigned)'; } /** pagination and order options **/ $this->start = $start; $this->limit = $limit; $this->orderby = $orderby; $this->order = $order; $this->kind = $kind; /** listing fields **/ $this->listing_fields = $this->get_plisting_fields('', $this->kind); /** main table **/ $this->main_table = "`#__wpl_properties` AS p"; /** queries **/ $this->join_query = $this->create_join(); $this->groupby_query = $this->create_groupby(); /** generate where condition **/ $where = (array) $where; $this->where = wpl_db::create_query($where); /** generate select **/ $this->select = $this->generate_select($this->listing_fields, 'p'); }
private function query($instance) { $model = new wpl_users(); $data = $instance['data']; $this->start = 0; $this->limit = $data['limit']; $this->orderby = $data['orderby']; $this->order = $data['order']; $where = array('sf_tmin_id' => 1, 'sf_select_access_public_profile' => 1, 'sf_select_expired' => 0); if (trim($data['user_type']) and $data['user_type'] != '-1') { $where['sf_select_membership_type'] = $data['user_type']; } if (trim($data['membership']) and $data['membership'] != '') { $where['sf_select_membership_id'] = $data['membership']; } if (trim($data['user_ids'])) { $where['sf_multiple_id'] = trim($data['user_ids'], ', '); } if (isset($data['random']) and trim($data['random']) and trim($data['user_ids']) == '') { $query_rand = "SELECT p.`id` FROM `#__wpl_users` AS p WHERE 1 " . wpl_db::create_query($where) . " ORDER BY RAND() LIMIT " . $this->limit; $results = wpl_db::select($query_rand); $rand_ids = array(); foreach ($results as $result) { $rand_ids[] = $result->id; } $where['sf_multiple_id'] = implode(',', $rand_ids); } $model->start($this->start, $this->limit, $this->orderby, $this->order, $where); return $model->query(); }