Exemple #1
0
 private function save_params()
 {
     $table = wpl_request::getVar('table');
     $id = wpl_request::getVar('id');
     $post = wpl_request::get('post');
     $keys = (isset($post['wpl_params']) and is_array($post['wpl_params']['keys'])) ? $post['wpl_params']['keys'] : array();
     $values = (isset($post['wpl_params']) and is_array($post['wpl_params']['values'])) ? $post['wpl_params']['values'] : array();
     $params = array();
     foreach ($keys as $key => $value) {
         if (trim($value) == '') {
             continue;
         }
         $params[$value] = $values[$key];
     }
     /** save params **/
     wpl_global::set_params($table, $id, $params);
     /** trigger event **/
     wpl_global::event_handler('params_saved', array('table' => $table, 'id' => $id, 'params' => $params));
     $res = 1;
     $message = $res ? __('Params Saved.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN);
     $data = NULL;
     $response = array('success' => $res, 'message' => $message, 'data' => $data);
     echo json_encode($response);
     exit;
 }
Exemple #2
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);
 }
Exemple #3
0
 /**
  * Service runner
  * @author Howard <*****@*****.**>
  * @return void
  */
 public function run()
 {
     /** recognizer **/
     $recognizer = wpl_request::getVar('get_realtyna_platform', 0);
     if ($recognizer == 1) {
         exit('WPL');
     }
     $format = wpl_request::getVar('wplformat', '');
     $view = wpl_request::getVar('wplview', '');
     /** if it's not IO request **/
     if ($format != 'io' or $view != 'io') {
         return;
     }
     $wpl_settings = wpl_global::get_settings();
     /** if IO is disabled **/
     if (!$wpl_settings['io_status']) {
         return;
     }
     $dapikey = wpl_request::getVar('dapikey', '');
     $dapisecret = wpl_request::getVar('dapisecret', '');
     /** if API key or API secret is invalid **/
     if ($dapikey != $wpl_settings['api_key'] or $dapisecret != $wpl_settings['api_secret']) {
         exit("ERROR: Signature is invalid.");
     }
     $cmd = wpl_request::getVar('cmd', '');
     $io_object = new wpl_io_global();
     $commands = $io_object->get_commands();
     if (!in_array($cmd, $commands)) {
         exit("ERROR: Command not found.");
     }
     $dformat = wpl_request::getVar('dformat', 'json');
     $dformats = $io_object->get_formats();
     if (!in_array($dformat, $dformats)) {
         exit("ERROR: Format not found.");
     }
     $username = wpl_request::getVar('user');
     $password = wpl_request::getVar('pass');
     $dlang = wpl_request::getVar('dlang');
     $gvars = wpl_request::get('GET');
     $pvars = wpl_request::get('POST');
     $vars = array_merge($pvars, $gvars);
     $response = $io_object->response($cmd, $username, $password, $vars, $dformat);
     /** Error **/
     /*	if(is_string($response))
     		{
     			echo $response;
     			exit;
     		}*/
     $rendered = $io_object->render_format($cmd, $vars, $response, $dformat);
     if (is_array($rendered)) {
         if ($rendered['header'] != '') {
             header($rendered['header']);
         }
         echo $rendered['output'];
     } else {
         echo $rendered;
     }
     exit;
 }
Exemple #4
0
 public function display()
 {
     $function = wpl_request::getVar('wpl_function');
     if ($function == 'add_user_to_wpl') {
         /** check permission **/
         wpl_global::min_access('administrator');
         $user_id = wpl_request::getVar('user_id');
         self::add_user_to_wpl($user_id);
     } elseif ($function == 'del_user_from_wpl') {
         /** check permission **/
         wpl_global::min_access('administrator');
         $user_id = wpl_request::getVar('user_id');
         $confirmed = wpl_request::getVar('wpl_confirmed', 0);
         self::del_user_from_wpl($user_id, $confirmed);
     } elseif ($function == 'generate_edit_page') {
         /** check permission **/
         wpl_global::min_access('administrator');
         $user_id = wpl_request::getVar('user_id');
         self::generate_edit_page($user_id);
     } elseif ($function == 'save_user') {
         /** check permission **/
         wpl_global::min_access('administrator');
         $inputs = wpl_request::get('POST');
         self::save_user($inputs);
     } elseif ($function == 'save') {
         $table_name = wpl_request::getVar('table_name', 'wpl_users');
         $table_column = wpl_request::getVar('table_column');
         $value = wpl_request::getVar('value');
         $item_id = wpl_request::getVar('item_id');
         self::save($table_name, $table_column, $value, $item_id);
     } elseif ($function == 'change_membership') {
         $user_id = wpl_request::getVar('id');
         $membership_id = wpl_request::getVar('membership_id');
         self::change_membership($user_id, $membership_id);
     } elseif ($function == 'location_save') {
         $table_name = wpl_request::getVar('table_name');
         $table_column = wpl_request::getVar('table_column');
         $value = wpl_request::getVar('value');
         $item_id = wpl_request::getVar('item_id');
         self::location_save($table_name, $table_column, $value, $item_id);
     } elseif ($function == 'finalize') {
         $item_id = wpl_request::getVar('item_id');
         self::finalize($item_id);
     } elseif ($function == 'upload_file') {
         $file_name = wpl_request::getVar('file_name');
         $user_id = wpl_request::getVar('item_id');
         self::upload_file($file_name, $user_id);
     } elseif ($function == 'delete_file') {
         $field_id = wpl_request::getVar('field_id');
         $user_id = wpl_request::getVar('item_id');
         self::delete_file($field_id, $user_id);
     } elseif ($function == 'save_multilingual') {
         self::save_multilingual();
     }
 }
Exemple #5
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;
 }
Exemple #6
0
 private function save_dbst()
 {
     $dbst_id = wpl_request::getVar('dbst_id', 0);
     $post = wpl_request::get('post');
     $mode = 'edit';
     /** insert new field **/
     if (!$dbst_id) {
         $mode = 'add';
         $dbst_id = wpl_flex::create_default_dbst();
     }
     $q = '';
     foreach ($post as $field => $value) {
         if (substr($field, 0, 4) != 'fld_') {
             continue;
         }
         $key = substr($field, 4);
         if (trim($key) == '') {
             continue;
         }
         $q .= "`{$key}`='{$value}', ";
     }
     /** add options to query **/
     $options = wpl_flex::get_encoded_options($post, 'opt_', wpl_flex::get_field_options($dbst_id));
     $q .= "`options`='" . wpl_db::escape($options) . "', ";
     $q = trim($q, ", ");
     $query = "UPDATE `#__wpl_dbst` SET " . $q . " WHERE `id`='{$dbst_id}'";
     wpl_db::q($query, 'update');
     $dbst_type = wpl_flex::get_dbst_key('type', $dbst_id);
     $dbst_kind = wpl_flex::get_dbst_key('kind', $dbst_id);
     /** run queries **/
     if ($mode == 'add') {
         wpl_flex::run_dbst_type_queries($dbst_id, $dbst_type, $dbst_kind, 'add');
     }
     /** Multilingual **/
     if (wpl_global::check_addon('pro')) {
         wpl_addon_pro::multilingual($dbst_id);
     }
     /** trigger event **/
     wpl_global::event_handler('dbst_modified', array('id' => $dbst_id, 'mode' => $mode, 'kind' => $dbst_kind, 'type' => $dbst_type));
     /** echo response **/
     echo json_encode(array('success' => 1, 'message' => __('Field saved.', WPL_TEXTDOMAIN), 'data' => NULL));
     exit;
 }
Exemple #7
0
 /**
  * Use this function for creating query
  * @author Howard <*****@*****.**>
  * @param array $vars
  * @param string $needle_str
  * @return string $query
  */
 public static function create_query($vars = '', $needle_str = 'sf_')
 {
     if (!$vars) {
         $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     }
     /** clean vars **/
     $vars = wpl_global::clean($vars);
     $query = '';
     /** this is to include any customized and special form fields conditions **/
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'create_query';
     $path_exists = wpl_folder::exists($path);
     $find_files = array();
     if ($path_exists) {
         $files = wpl_folder::files($path, '.php$');
     }
     foreach ($vars as $key => $value) {
         /** escape value **/
         $value = wpl_db::escape($value);
         if (strpos($key, $needle_str) === false) {
             continue;
         }
         $ex = explode('_', $key);
         $format = $ex[1];
         $table_column = str_replace($needle_str . $format . '_', '', $key);
         $done_this = false;
         /** using detected files **/
         if (isset($find_files[$format])) {
             include $path . DS . $find_files[$format];
             continue;
         }
         foreach ($files as $file) {
             include $path . DS . $file;
             if ($done_this) {
                 /** add to detected files **/
                 $find_files[$format] = $file;
                 break;
             }
         }
     }
     return $query = trim($query, ' ,');
 }
 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);
 }
Exemple #9
0
 public function build()
 {
     /** property listing model **/
     $this->model = new wpl_property();
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         $this->error = "ERROR: Invalid property kind!";
         return false;
     }
     $default_where = array('sf_select_confirmed' => 1, 'sf_select_finalized' => 1, 'sf_select_deleted' => 0, 'sf_select_expired' => 0, 'sf_select_kind' => $this->kind);
     $this->where = array_merge($default_where, $this->where);
     /** Add search conditions to the where **/
     $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     $this->where = array_merge($vars, $this->where);
     /** start search **/
     $this->model->start($this->start, $this->limit, $this->orderby, $this->order, $this->where);
     $this->model->total = $this->model->get_properties_count();
     $this->built['listings']['total'] = $this->model->total;
     /** run the search **/
     $query = $this->model->query();
     $properties = $this->model->search();
     /** finish search **/
     $this->model->finish();
     $plisting_fields = $this->model->get_plisting_fields();
     foreach ($properties as $property) {
         $rendered = array();
         $rendered = $this->model->full_render($property->id, $plisting_fields, $property);
         $rendered['property_id'] = $property->id;
         $items = $rendered['items'];
         /** render gallery **/
         if ($this->pictures) {
             $rendered['images'] = wpl_items::render_gallery($items['gallery']);
         }
         /** render attachments **/
         if ($this->attachments) {
             $rendered['attachments'] = wpl_items::render_attachments($items['attachment']);
         }
         /** render videos **/
         if ($this->videos) {
             $rendered['videos'] = wpl_items::render_videos($items['video']);
         }
         /** render rooms **/
         if ($this->rooms) {
             $rendered['rooms'] = $items['rooms'];
         }
         /** render gallery custom sizes **/
         if (is_array($this->image_sizes)) {
             $rendered['custom_sizes'] = wpl_items::render_gallery_custom_sizes($property_id, $items['gallery'], $this->image_sizes);
         }
         /** render agent data **/
         if ($this->agentinfo) {
             $rendered['agent'] = wpl_users::full_render($property->user_id);
             unset($rendered['agent']['data']);
             unset($rendered['agent']['items']);
         }
         unset($rendered['items']);
         $this->built['listings'][$property->id] = $rendered;
     }
     return $this->built;
 }
Exemple #10
0
 /**
  * Generates request string from an array. Used in Property Listing and Profile Listing etc.
  * @author Howard R <*****@*****.**>
  * @param array $vars
  * @return string
  */
 public static function generate_request_str($vars = array())
 {
     /** First Validation **/
     if (!is_array($vars) or is_array($vars) and !count($vars)) {
         $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     }
     $request_str = '';
     foreach ($vars as $field => $value) {
         if (trim($value) == '') {
             continue;
         }
         $request_str .= $field . '=' . urlencode($value) . '&';
     }
     return trim($request_str, '& ');
 }
Exemple #11
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);
 }
Exemple #12
0
 /**
  * Returns current full URL
  * @author Howard <*****@*****.**>
  * @static
  * @return string
  */
 public static function get_full_url()
 {
     /** get $_SERVER **/
     $server = wpl_request::get('SERVER');
     $page_url = 'http';
     if (isset($server['HTTPS']) and $server['HTTPS'] == 'on') {
         $page_url .= 's';
     }
     $site_domain = (isset($server['HTTP_HOST']) and trim($server['HTTP_HOST']) != '') ? $server['HTTP_HOST'] : $server['SERVER_NAME'];
     $page_url .= '://';
     $page_url .= $site_domain . $server['REQUEST_URI'];
     return $page_url;
 }