Example #1
0
 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);
 }
Example #2
0
 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);
 }
Example #3
0
 /**
  * written by Francis
  * description: initialize pagination and properties for property manager page
  */
 private function init_page()
 {
     /** global settings **/
     $settings = wpl_settings::get_settings();
     /** listing settings **/
     $this->page_number = wpl_request::getVar('wplpage', 1);
     $limit = wpl_request::getVar('limit', $settings['default_page_size']);
     $start = wpl_request::getVar('start', ($this->page_number - 1) * $limit);
     $orderby = wpl_request::getVar('orderby', $settings['default_orderby']);
     $order = wpl_request::getVar('order', $settings['default_order']);
     $current_user_id = wpl_users::get_cur_user_id();
     $where = array();
     /** set page if start var passed **/
     $this->page_number = $start / $limit + 1;
     wpl_request::setVar('wplpage', $this->page_number);
     $this->model = new wpl_property();
     /** load user properties **/
     if (!wpl_users::is_administrator($current_user_id)) {
         $where['sf_select_user_id'] = $current_user_id;
     }
     /** detect kind **/
     $this->kind = wpl_request::getVar('kind', 0);
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         /** import message tpl **/
         $this->message = __('Invalid Request!', WPL_TEXTDOMAIN);
         parent::render($this->tpl_path, 'message');
         return false;
     }
     $this->kind_label = wpl_flex::get_kind_label($this->kind);
     $where['sf_select_kind'] = $this->kind;
     /** Add search conditions to the where **/
     $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     $where = array_merge($vars, $where);
     $this->model->start($start, $limit, $orderby, $order, $where, $this->kind);
     $query = $this->model->query();
     $properties = $this->model->search($query);
     $this->model->finish();
     /** get the number of all properties according to our query **/
     $properties_count = $this->model->get_properties_count();
     /** set pagination according to the number of items and limit **/
     $this->pagination = wpl_pagination::get_pagination($properties_count, $limit);
     $plisting_fields = $this->model->get_plisting_fields();
     $wpl_properties = array();
     foreach ($properties as $property) {
         $wpl_properties[$property->id] = $this->model->full_render($property->id, $plisting_fields, $property);
     }
     $this->wpl_properties = $wpl_properties;
     return true;
 }
Example #4
0
 public function display($instance = array())
 {
     /** check access **/
     if (!wpl_users::check_access('propertylisting')) {
         /** import message tpl **/
         $this->message = __("You don't have access to this part!", WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message', false, true);
     }
     $this->tpl = wpl_request::getVar('tpl', 'default');
     $this->method = wpl_request::getVar('wplmethod', NULL);
     /** global settings **/
     $this->settings = wpl_settings::get_settings();
     /** listing settings **/
     $this->page_number = wpl_request::getVar('wplpage', 1, '', true);
     $this->limit = wpl_request::getVar('limit', $this->settings['default_page_size']);
     $this->start = wpl_request::getVar('start', ($this->page_number - 1) * $this->limit, '', true);
     $this->orderby = wpl_request::getVar('wplorderby', $this->settings['default_orderby'], '', true);
     $this->order = wpl_request::getVar('wplorder', $this->settings['default_order'], '', true);
     /** Set Property CSS class **/
     $this->property_css_class = !$this->wplraw ? wpl_request::getVar('wplpcc', NULL) : NULL;
     if (!$this->property_css_class) {
         $this->property_css_class = wpl_request::getVar('wplpcc', 'grid_box', 'COOKIE');
     }
     $this->property_css_class_switcher = wpl_request::getVar('wplpcc_switcher', '1');
     $this->property_listview = wpl_request::getVar('wplplv', '1');
     #Show listview or not
     /** RSS Feed Setting **/
     $this->listings_rss_enabled = isset($this->settings['listings_rss_enabled']) ? $this->settings['listings_rss_enabled'] : 0;
     /** detect kind **/
     $this->kind = wpl_request::getVar('kind', 0);
     if (!$this->kind) {
         $this->kind = wpl_request::getVar('sf_select_kind', 0);
     }
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         /** import message tpl **/
         $this->message = __('Invalid Request!', WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message', false, true);
     }
     /** pagination types **/
     $this->wplpagination = wpl_request::getVar('wplpagination', 'normal', '', true);
     wpl_request::setVar('wplpagination', $this->wplpagination);
     /** property listing model **/
     $this->model = new wpl_property();
     /** set page if start var passed **/
     $this->page_number = $this->start / $this->limit + 1;
     wpl_request::setVar('wplpage', $this->page_number);
     $where = array('sf_select_confirmed' => 1, 'sf_select_finalized' => 1, 'sf_select_deleted' => 0, 'sf_select_expired' => 0, 'sf_select_kind' => $this->kind);
     /** Add search conditions to the where **/
     $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     $where = array_merge($vars, $where);
     /** start search **/
     $this->model->start($this->start, $this->limit, $this->orderby, $this->order, $where, $this->kind);
     $this->model->total = $this->model->get_properties_count();
     /** validation for page_number **/
     $this->total_pages = ceil($this->model->total / $this->limit);
     if ($this->page_number <= 0 or $this->page_number > $this->total_pages) {
         $this->model->start = 0;
     }
     /** run the search **/
     $query = $this->model->query();
     $properties = $this->model->search();
     /** finish search **/
     $this->model->finish();
     $plisting_fields = $this->model->get_plisting_fields('', $this->kind);
     $wpl_properties = array();
     foreach ($properties as $property) {
         $wpl_properties[$property->id] = $this->model->full_render($property->id, $plisting_fields, $property);
     }
     /** define current index **/
     $wpl_properties['current'] = array();
     /** apply filters (This filter must place after all proccess) **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('property_listing_after_render', array('wpl_properties' => $wpl_properties)));
     $this->pagination = wpl_pagination::get_pagination($this->model->total, $this->limit, true, $this->wplraw);
     $this->wpl_properties = $wpl_properties;
     if ($this->wplraw and $this->method == 'get_markers') {
         $markers = array('markers' => $this->model->render_markers($wpl_properties), 'total' => $this->model->total);
         echo json_encode($markers);
         exit;
     } elseif ($this->wplraw and $this->method == 'get_listings') {
         if ($this->return_listings) {
             return $wpl_properties;
         } else {
             echo json_encode($wpl_properties);
             exit;
         }
     }
     /** import tpl **/
     $this->tpl = wpl_flex::get_kind_tpl($this->tpl_path, $this->tpl, $this->kind);
     return parent::render($this->tpl_path, $this->tpl, false, true);
 }
Example #5
0
 public function display($instance = array())
 {
     /** property listing model **/
     $this->model = new wpl_users();
     /** global settings **/
     $settings = wpl_settings::get_settings();
     /** listing settings **/
     $this->page_number = wpl_request::getVar('wplpage', 1, '', true);
     $this->limit = wpl_request::getVar('limit', $settings['default_profile_page_size'], '', true);
     $this->start = wpl_request::getVar('start', ($this->page_number - 1) * $this->limit, '', true);
     $this->orderby = wpl_request::getVar('wplorderby', $settings['default_profile_orderby'], '', true);
     $this->order = wpl_request::getVar('wplorder', $settings['default_profile_order'], '', true);
     /** Set Property CSS class **/
     $this->property_css_class = wpl_request::getVar('wplpcc', NULL);
     if (!$this->property_css_class) {
         $this->property_css_class = wpl_request::getVar('wplpcc', 'grid_box', 'COOKIE');
     }
     $this->property_css_class_switcher = wpl_request::getVar('wplpcc_switcher', '1');
     /** set page if start var passed **/
     $this->page_number = $this->start / $this->limit + 1;
     wpl_request::setVar('wplpage', $this->page_number);
     /** detect kind **/
     $this->kind = wpl_request::getVar('kind', 2);
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         /** import message tpl **/
         $this->message = __('Invalid Request!', WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message', false, true);
     }
     /** pagination types **/
     $this->wplpagination = wpl_request::getVar('wplpagination', 'normal', '', true);
     wpl_request::setVar('wplpagination', $this->wplpagination);
     $where = array('sf_tmin_id' => 1, 'sf_select_access_public_profile' => 1, 'sf_select_expired' => 0);
     /** Add search conditions to the where **/
     $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     $where = array_merge($vars, $where);
     /** start search **/
     $this->model->start($this->start, $this->limit, $this->orderby, $this->order, $where);
     $this->model->total = $this->model->get_users_count();
     /** validation for page_number **/
     $this->total_pages = ceil($this->model->total / $this->limit);
     if ($this->page_number <= 0 or $this->page_number > $this->total_pages) {
         $this->model->start = 0;
     }
     /** run the search **/
     $query = $this->model->query();
     $profiles = $this->model->search();
     /** finish search **/
     $this->model->finish();
     $plisting_fields = $this->model->get_plisting_fields();
     $wpl_profiles = array();
     foreach ($profiles as $profile) {
         $wpl_profiles[$profile->id] = $this->model->full_render($profile->id, $plisting_fields);
     }
     /** define current index **/
     $wpl_profiles['current'] = array();
     /** apply filters (This filter must place after all proccess) **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('profile_listing_after_render', array('wpl_profiles' => $wpl_profiles)));
     $this->pagination = wpl_pagination::get_pagination($this->model->total, $this->limit, true);
     $this->wpl_profiles = $wpl_profiles;
     /** import tpl **/
     return parent::render($this->tpl_path, $this->tpl, false, true);
 }
Example #6
0
 public static function get_pagination($num_result, $page_size = '', $show_options = false)
 {
     if (!$page_size) {
         $page_size = 20;
     }
     $p = new wpl_pagination();
     $p->items($num_result);
     $p->limit($page_size);
     // Limit entries per page
     $p->target(wpl_global::get_full_url());
     $p->currentPage(wpl_request::getVar('wplpage'));
     // Gets and validates the current page
     $p->calculate();
     // Calculates what to show
     $p->parameterName('wplpage');
     $p->adjacents(1);
     //No. of page away from the current page
     //making next and previous keyword to be translated
     $p->nextLabel(__("Next", WPL_TEXTDOMAIN));
     $p->prevLabel(__("Previous", WPL_TEXTDOMAIN));
     /** validation for page **/
     if (!wpl_request::getVar('wplpage')) {
         $p->page = 1;
     } else {
         $p->page = wpl_request::getVar('wplpage');
     }
     $p->max_page = ceil($num_result / $page_size);
     if ($p->page <= 0 or $p->page > $p->max_page) {
         $p->page = 1;
     }
     //Query for limit paging
     $p->limit_query = "LIMIT " . ($p->page - 1) * $p->limit . ", " . $p->limit;
     if ($show_options) {
         $p->show_total = true;
         $p->show_page_size = true;
     }
     return $p;
 }