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); }
/** * Updates locationtextsearch data. It runes by WPL cronjob! * @author Howard <*****@*****.**> * @static */ public static function update_locationtextsearch_data() { /** detele wpl_locationtextsearch completely **/ wpl_db::q("DELETE FROM `#__wpl_locationtextsearch`"); /** Don't run in case of many listings **/ if (wpl_db::num('', 'wpl_properties') > 2500) { wpl_db::q("UPDATE `#__wpl_cronjobs` SET `enabled`='0' WHERE `id`='1'"); return false; } _wpl_import('libraries.property'); $properties = wpl_property::select_active_properties('', '`id`,`location1_name`,`location2_name`,`location3_name`,`location4_name`,`location5_name`,`location6_name`,`location7_name`,`zip_name`'); $locations = array(); foreach ($properties as $property) { $pid = $property['id']; $locations[$pid] = array(); $locations[$pid]['full_location'] = ''; $locations[$pid]['zip'] = ''; for ($j = 1; $j <= 7; $j++) { $locations[$pid][$j] = ''; } for ($i = 7; $i >= 1; $i--) { $locations[$pid]['full_location'] .= ', ' . $property['location' . $i . '_name']; if ($i <= 7 and trim($property['location7_name'])) { $locations[$pid]['7'] .= ', ' . $property['location' . $i . '_name']; } if ($i <= 6 and trim($property['location6_name'])) { $locations[$pid]['6'] .= ', ' . $property['location' . $i . '_name']; } if ($i <= 5 and trim($property['location5_name'])) { $locations[$pid]['5'] .= ', ' . $property['location' . $i . '_name']; } if ($i <= 4 and trim($property['location4_name'])) { $locations[$pid]['4'] .= ', ' . $property['location' . $i . '_name']; } if ($i <= 3 and trim($property['location3_name'])) { $locations[$pid]['3'] .= ', ' . $property['location' . $i . '_name']; } if ($i <= 2 and trim($property['location2_name'])) { $locations[$pid]['2'] .= ', ' . $property['location' . $i . '_name']; } if ($i <= 1 and trim($property['location1_name'])) { $locations[$pid]['1'] .= ', ' . $property['location' . $i . '_name']; } } /** remove extra , and spaces if any **/ foreach ($locations[$pid] as $key => $location) { $locations[$pid][$key] = trim($location, ', '); } /** add zip code **/ $locations[$pid]['zip'] = $property['zip_name'] . ', ' . $locations[$pid]['full_location']; } /** make a new location array **/ $unique_locations = array(); foreach ($locations as $pid => $location) { foreach ($location as $location_level => $location_string) { $unique_locations[] = $location_string; } } $unique_locations = array_unique($unique_locations); foreach ($unique_locations as $location_text) { $query = "SELECT `kind`, COUNT(id) AS count FROM `#__wpl_properties` WHERE `deleted`='0' AND `finalized`='1' AND `confirmed`='1' AND `expired`='0' AND `location_text` LIKE '%" . wpl_db::escape($location_text) . "%' GROUP BY `kind`"; $counts = wpl_db::select($query, 'loadAssocList'); $total_count = 0; foreach ($counts as $count) { $total_count += $count['count']; } /** add to wpl_locationtextsearch **/ $query = "INSERT INTO `#__wpl_locationtextsearch` (`location_text`,`count`,`counts`) VALUES ('" . wpl_db::escape($location_text) . "','{$total_count}','" . json_encode($counts) . "')"; wpl_db::q($query); } }
public function validate_token($token, $delete = false) { $query = "SELECT COUNT(*) FROM `#__wpl_items` WHERE `item_name`='{$token}' AND `parent_kind`='-1'"; $num = wpl_db::num($query); if ($num and $delete) { $query = "DELETE FROM `#__wpl_items` WHERE `parent_kind`='-1' AND `item_name`='{$token}'"; wpl_db::q($query, 'DELETE'); } return $num ? true : false; }
/** * Check if setting exists or not * @author Howard <*****@*****.**> * @static * @param string $name * @param string $category * @return boolean */ public static function is_setting_exists($name, $category = '') { $condition = ''; if (trim($category) != '') { if (!is_numeric($category)) { $category = wpl_settings::get_category_id($category); } $condition .= "AND `category`='{$category}'"; } $query = "SELECT COUNT(`id`) FROM `#__wpl_settings` WHERE `setting_name`='{$name}' " . $condition; $num = wpl_db::num($query); return $num ? true : false; }