Example #1
1
 /**
  * Returns User Profile Link
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $user_id
  * @param int $target_id
  * @return string
  */
 public static function get_profile_link($user_id = '', $target_id = 0)
 {
     /** fetch currenr user data if user id is empty **/
     if (trim($user_id) == '') {
         $user_id = self::get_cur_user_id();
     }
     $user_data = self::get_user($user_id);
     $home_type = wpl_global::get_wp_option('show_on_front', 'posts');
     $home_id = wpl_global::get_wp_option('page_on_front', 0);
     if (!$target_id) {
         $target_id = wpl_request::getVar('wpltarget', 0);
     }
     if ($target_id) {
         $url = wpl_global::add_qs_var('uid', $user_id, wpl_sef::get_page_link($target_id));
         if ($home_type == 'page' and $home_id == $target_id) {
             $url = wpl_global::add_qs_var('wplview', 'profile_show', $url);
         }
     } else {
         $url = wpl_sef::get_wpl_permalink(true);
         $nosef = wpl_sef::is_permalink_default();
         $wpl_main_page_id = wpl_sef::get_wpl_main_page_id();
         if ($nosef or $home_type == 'page' and $home_id == $wpl_main_page_id) {
             $url = wpl_global::add_qs_var('wplview', 'profile_show', $url);
             $url = wpl_global::add_qs_var('uid', $user_id, $url);
         } else {
             $url .= urlencode($user_data->data->user_login) . '/';
         }
     }
     return $url;
 }
Example #2
0
 public static function save_external_images()
 {
     $kind = wpl_request::getVar('kind', 0);
     $pid = wpl_request::getVar('pid');
     $links_str = wpl_request::getVar('links', '');
     $type = wpl_request::getVar('type', 'gallery');
     $category = wpl_request::getVar('category', 'external');
     $links_str = str_replace(";", '<-->', $links_str);
     $links_str = str_replace(",", '<-->', $links_str);
     $links_str = str_replace("\r\n", '<-->', $links_str);
     $links_str = str_replace("\n", '<-->', $links_str);
     $links = explode('<-->', $links_str);
     foreach ($links as $link) {
         $link = trim($link, ',; ');
         if (trim($link) == '') {
             continue;
         }
         // get item category with first index
         $index = floatval(wpl_items::get_maximum_index($pid, $type, $kind, $category)) + 1.0;
         $name = 'external_image' . $index;
         $item = array('parent_id' => $pid, 'parent_kind' => $kind, 'item_type' => $type, 'item_cat' => $category, 'item_name' => $name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => $index, 'item_extra3' => $link);
         $item_id = wpl_items::save($item);
     }
     exit;
 }
Example #3
0
 public function upload()
 {
     /** import upload library **/
     _wpl_import('assets.packages.ajax_uploader.UploadHandler');
     $kind = wpl_request::getVar('kind', 0);
     $params = array();
     $params['accept_ext'] = wpl_flex::get_field_options(301);
     $extentions = explode(',', $params['accept_ext']['ext_file']);
     $ext_str = '';
     foreach ($extentions as $extention) {
         $ext_str .= $extention . '|';
     }
     // remove last |
     $ext_str = substr($ext_str, 0, -1);
     $ext_str = rtrim($ext_str, ';');
     $custom_op = array('upload_dir' => wpl_global::get_upload_base_path(), 'upload_url' => wpl_global::get_upload_base_url(), 'accept_file_types' => '/\\.(' . $ext_str . ')$/i', 'max_file_size' => $params['accept_ext']['file_size'] * 1000, 'min_file_size' => 1, 'max_number_of_files' => null);
     $upload_handler = new UploadHandler($custom_op);
     $response = json_decode($upload_handler->json_response);
     if (isset($response->files[0]->error)) {
         return;
     }
     $attachment_categories = wpl_items::get_item_categories('attachment', $kind);
     // get item category with first index
     $item_cat = reset($attachment_categories)->category_name;
     $index = floatval(wpl_items::get_maximum_index(wpl_request::getVar('pid'), wpl_request::getVar('type'), $kind, $item_cat)) + 1.0;
     $item = array('parent_id' => wpl_request::getVar('pid'), 'parent_kind' => $kind, 'item_type' => wpl_request::getVar('type'), 'item_cat' => $item_cat, 'item_name' => $response->files[0]->name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => $index);
     wpl_items::save($item);
 }
Example #4
0
 /**
  * Service runner
  * @author Howard <*****@*****.**>
  * @return void
  */
 public function run()
 {
     $wpl_format = wpl_request::getVar('wpl_format');
     if (trim($wpl_format) == '') {
         return;
     }
     /** add listing menu **/
     if ($wpl_format == 'b:listing:ajax') {
         $wpl_function = wpl_request::getVar('wpl_function');
         if ($wpl_function == 'save') {
             $table_name = wpl_request::getVar('table_name');
             $table_column = wpl_request::getVar('table_column');
             $value = wpl_request::getVar('value');
             /** for checking limitation on feature and hot tag **/
             if (($table_column == 'sp_featured' or $table_column == 'sp_hot') and $value == 1) {
                 _wpl_import('libraries.property');
                 $current_user_id = wpl_users::get_cur_user_id();
                 $user_data = wpl_users::get_wpl_user($current_user_id);
                 $user_limit = $table_column == 'sp_featured' ? $user_data->maccess_num_feat : $user_data->maccess_num_hot;
                 $model = new wpl_property();
                 $used = $model->get_properties_count(" AND `user_id`='{$current_user_id}' AND `{$table_column}`='1'");
                 if ($used >= $user_limit and $user_limit != '-1') {
                     self::response(array('success' => '0', 'message' => '', 'data' => '', 'js' => "wplj(form_element_id).prop('checked', false); wpl_alert(\"" . __('Your membership limit reached. contact to administrator if you want to upgrade!', WPL_TEXTDOMAIN) . "\");"));
                 }
             }
         }
     }
 }
Example #5
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 #6
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;
 }
Example #7
0
 private function save_activity()
 {
     $information = wpl_request::getVar('info');
     $options = wpl_request::getVar('option');
     $associations = wpl_request::getVar('associations', '') ? wpl_request::getVar('associations', '') : array();
     $associations_str = '';
     foreach ($associations as $page_id => $value) {
         if ($value) {
             $associations_str .= '[' . $page_id . ']';
         }
     }
     $information['associations'] = $associations_str;
     /** validation for association type **/
     if (!isset($information['association_type']) or isset($information['association_type']) and is_null($information['association_type'])) {
         $information['association_type'] = 1;
     }
     if (is_null($options)) {
         $information['params'] = '';
     } else {
         $information['params'] = json_encode($options);
     }
     if (trim($information['layout']) != '') {
         $information['activity'] = $information['activity'] . ':' . $information['layout'];
     }
     if (!isset($information['activity_id'])) {
         wpl_activity::add_activity($information);
     } else {
         wpl_activity::update_activity($information);
     }
     exit;
 }
Example #8
0
 public function display($instance = array())
 {
     $this->uid = wpl_request::getVar('uid', 0);
     if (!$this->uid) {
         $this->uid = wpl_request::getVar('sf_select_user_id', 0);
         wpl_request::setVar('uid', $this->uid);
     }
     /** check user id **/
     if (!$this->uid) {
         /** import message tpl **/
         $this->message = __("No profile found or it's not available now!", WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message', false, true);
     }
     /** set the user id to search credentials **/
     wpl_request::setVar('sf_select_user_id', $this->uid);
     /** set the kind **/
     $this->kind = wpl_request::getVar('kind', '0');
     wpl_request::setVar('kind', $this->kind);
     /** User Type **/
     $this->user_type = wpl_users::get_user_user_type($this->uid);
     /** trigger event **/
     wpl_global::event_handler('profile_show', array('id' => $this->uid, 'kind' => $this->kind));
     /** import tpl **/
     $this->tpl = wpl_users::get_user_type_tpl($this->tpl_path, $this->tpl, $this->user_type);
     /** import tpl **/
     return parent::render($this->tpl_path, $this->tpl, false, true);
 }
Example #9
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;
 }
 private function sort_options($sort_ids)
 {
     if (trim($sort_ids) == '') {
         $sort_ids = wpl_request::getVar('sort_ids');
     }
     wpl_sort_options::sort_options($sort_ids);
     exit;
 }
 private function sort_rooms($sort_ids)
 {
     if (trim($sort_ids) == '') {
         $sort_ids = wpl_request::getVar('sort_ids');
     }
     wpl_room_types::sort_room_types($sort_ids);
     exit;
 }
Example #12
0
 private function save_notification()
 {
     $info = wpl_request::getVar('info');
     wpl_notifications::save_notification($info);
     $message = __('Operation was successful.', WPL_TEXTDOMAIN);
     $response = array('success' => 1, 'message' => $message);
     echo json_encode($response);
     exit;
 }
Example #13
0
 public function home()
 {
     /** check permission **/
     wpl_global::min_access('administrator');
     $possible_orders = array('index', 'id', 'title');
     $this->orderby = in_array(wpl_request::getVar('orderby'), $possible_orders) ? wpl_request::getVar('orderby') : $possible_orders[0];
     $this->order = in_array(strtoupper(wpl_request::getVar('order')), array('ASC', 'DESC')) ? wpl_request::getVar('order') : 'ASC';
     /** import tpl **/
     parent::render($this->tpl_path, $this->tpl);
 }
Example #14
0
 public function home()
 {
     /** check permission **/
     wpl_global::min_access('administrator');
     $this->tpl = wpl_request::getVar('tpl', 'default');
     if ($this->tpl == 'modify') {
         $this->id = wpl_request::getVar('id', 0);
         $this->modify();
     } else {
         $this->notifications = wpl_notifications::get_notifications();
         parent::render($this->tpl_path, $this->tpl);
     }
 }
Example #15
0
 private function generate_modify_page($field_type, $field_id, $kind = 0)
 {
     if (trim($field_type) == '') {
         $field_type = wpl_request::getVar('field_type', 0);
     }
     if (trim($field_id) == '') {
         $field_id = wpl_request::getVar('field_id', 0);
     }
     $this->field_type = $field_type;
     $this->field_id = $field_id;
     $this->kind = $kind;
     parent::render($this->tpl_path, 'internal_modify');
     exit;
 }
Example #16
0
 public static function delete_room()
 {
     $item_id = wpl_request::getVar('item_id');
     /** deleting the room **/
     if ($item_id != -1) {
         $result = wpl_items::delete($item_id);
     }
     $res = (int) $result;
     $message = $res ? __('Deleted.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN);
     $data = $item_id;
     $response = array('success' => $res, 'message' => $message, 'data' => $data);
     echo json_encode($response);
     exit;
 }
Example #17
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 #18
0
 public function show_tips()
 {
     $page = wpl_request::getVar('page', '');
     /** First Validation **/
     if (!trim($page)) {
         return false;
     }
     $tips = array();
     $path = _wpl_import('assets.tips.' . $page, true, true);
     if (wpl_file::exists($path)) {
         $tips = (include_once $path);
     }
     /** Generate script **/
     $this->generate_scripts($tips);
 }
Example #19
0
 /**
  * author Howard
  * desctiption: change user of a property
  */
 private function change_user()
 {
     $pid = wpl_request::getVar('pid');
     $uid = wpl_request::getVar('uid');
     /** purge property **/
     if (wpl_users::check_access('change_user')) {
         $res = (int) wpl_property::change_user($pid, $uid);
         $message = __("User changed.", WPL_TEXTDOMAIN);
     } else {
         $res = 0;
         $message = __("You don't have access to this action.", WPL_TEXTDOMAIN);
     }
     /** echo response **/
     echo json_encode(array('success' => $res, 'message' => $message, 'data' => NULL));
     exit;
 }
Example #20
0
 public function home()
 {
     /** check permission **/
     wpl_global::min_access('administrator');
     $this->kind = trim(wpl_request::getVar('kind')) != '' ? wpl_request::getVar('kind') : 0;
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         $this->message = __('Invalid Kind!', WPL_TEXTDOMAIN);
         /** import tpl **/
         return parent::render($this->tpl_path, 'message');
     }
     $this->field_categories = wpl_flex::get_categories(0, $this->kind);
     $this->kind_label = wpl_flex::get_kind_label($this->kind);
     $this->dbst_types = wpl_flex::get_dbst_types(1, $this->kind);
     $this->new_dbst_id = wpl_flex::get_new_dbst_id();
     /** import tpl **/
     parent::render($this->tpl_path, $this->tpl);
 }
Example #21
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;
 }
Example #22
0
 public function wizard($instance = array())
 {
     /** load assets **/
     $this->load_assets();
     /** check access **/
     if (!wpl_users::check_access('propertywizard')) {
         /** import message tpl **/
         $this->message = __("You don't have access to this part!", WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message');
     }
     $this->kind = trim(wpl_request::getVar('kind')) != '' ? wpl_request::getVar('kind') : 0;
     $this->property_id = trim(wpl_request::getVar('pid')) != '' ? wpl_request::getVar('pid') : 0;
     $this->mode = $this->property_id ? 'edit' : 'add';
     if ($this->mode == 'add') {
         /** checking access **/
         if (!wpl_users::check_access($this->mode)) {
             $this->message = __("Limit reached. You can not add more property!", WPL_TEXTDOMAIN);
             return parent::render($this->tpl_path, 'message');
         }
         /** generate new property **/
         $this->property_id = wpl_property::create_property_default('', $this->kind);
     }
     $this->values = wpl_property::get_property_raw_data($this->property_id);
     $this->finalized = isset($this->values['finalized']) ? $this->values['finalized'] : 0;
     $this->kind = isset($this->values['kind']) ? $this->values['kind'] : 0;
     $this->field_categories = wpl_flex::get_categories(0, $this->kind);
     $this->kind_label = wpl_flex::get_kind_label($this->kind);
     if ($this->mode == 'edit') {
         if (!$this->values) {
             $this->message = __("Property does not exist!", WPL_TEXTDOMAIN);
             return parent::render($this->tpl_path, 'message');
         }
         /** checking access **/
         if (!wpl_users::check_access($this->mode, $this->values['user_id'])) {
             $this->message = __("You can not edit this property.", WPL_TEXTDOMAIN);
             return parent::render($this->tpl_path, 'message');
         }
     }
     /** import tpl **/
     $this->tpl = wpl_flex::get_kind_tpl($this->tpl_path, 'wizard', $this->kind);
     parent::render($this->tpl_path, $this->tpl);
 }
Example #23
0
 public function profile($instance = array())
 {
     /** check access **/
     if (!wpl_users::check_access('profilewizard')) {
         /** import message tpl **/
         $this->message = __("You don't have access to this part!", WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message');
     }
     _wpl_import('libraries.flex');
     $this->tpl = 'profile';
     $this->kind = wpl_flex::get_kind_id('user');
     $this->user_id = wpl_users::get_cur_user_id();
     if (wpl_users::is_administrator($this->user_id) and wpl_request::getVar('id', 0)) {
         $this->user_id = wpl_request::getVar('id');
     }
     $this->user_fields = wpl_flex::get_fields('', 1, $this->kind, 'pwizard', 1);
     $this->user_data = (array) wpl_users::get_wpl_data($this->user_id);
     /** import tpl **/
     parent::render($this->tpl_path, $this->tpl);
 }
Example #24
0
 private function contact_profile()
 {
     $fullname = wpl_request::getVar('fullname', '');
     $phone = wpl_request::getVar('phone', '');
     $email = wpl_request::getVar('email', '');
     $message = wpl_request::getVar('message', '');
     $user_id = wpl_request::getVar('user_id', '');
     $parameters = array('fullname' => $fullname, 'phone' => $phone, 'email' => $email, 'message' => $message, 'user_id' => $user_id);
     $returnData = array();
     if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
         $returnData['success'] = 0;
         $returnData['message'] = __('Your email is not a valid email!', WPL_TEXTDOMAIN);
     } else {
         wpl_events::trigger('contact_profile', $parameters);
         $returnData['success'] = 1;
         $returnData['message'] = __('Information sent to agent.', WPL_TEXTDOMAIN);
     }
     echo json_encode($returnData);
     exit;
 }
Example #25
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, ' ,');
 }
Example #26
0
 private function generate_modify_page($level = '1', $parent = '0', $location_id = '')
 {
     if (trim($level) == '') {
         $level = wpl_request::getVar('level');
     }
     if (trim($parent) == '') {
         $parent = wpl_request::getVar('parent');
     }
     if (trim($location_id) == '') {
         $location_id = wpl_request::getVar('location_id');
     }
     $this->location_data = '';
     $this->level = $level;
     $this->parent = $parent;
     $this->location_id = $location_id;
     /** get location data for edit **/
     if (trim($location_id) != '') {
         $this->location_data = wpl_locations::get_location($location_id, $level);
     }
     parent::render($this->tpl_path, 'edit');
     exit;
 }
Example #27
0
 private function report_abuse_submit()
 {
     $parameters = wpl_request::getVar('wplfdata', array());
     $property_id = isset($parameters['property_id']) ? $parameters['property_id'] : 0;
     $returnData = array();
     if (!$property_id) {
         $returnData['success'] = 0;
         $returnData['message'] = __('Invalid Property!', WPL_TEXTDOMAIN);
     } elseif (isset($parameters['email']) and !filter_var($parameters['email'], FILTER_VALIDATE_EMAIL)) {
         $returnData['success'] = 0;
         $returnData['message'] = __('Your email is not valid!', WPL_TEXTDOMAIN);
     } else {
         $PRO = new wpl_addon_pro();
         if ($PRO->report_abuse_send($parameters)) {
             $returnData['success'] = 1;
             $returnData['message'] = __('Abuse report sent successfully.', WPL_TEXTDOMAIN);
         } else {
             $returnData['success'] = 0;
             $returnData['message'] = __('Error sending!', WPL_TEXTDOMAIN);
         }
     }
     echo json_encode($returnData);
     exit;
 }
Example #28
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 #29
0
 private function set_parent()
 {
     $parent_id = wpl_request::getVar('parent_id', 0);
     $item_id = wpl_request::getVar('item_id', 0);
     $parent_data = wpl_property::get_property_raw_data($parent_id);
     $forbidden_fields = array('id', 'kind', 'deleted', 'mls_id', 'parent', 'pic_numb', 'att_numb', 'sent_numb', 'contact_numb', 'user_id', 'add_date', 'finalized', 'confirmed', 'visit_time', 'visit_date', 'last_modified_time_stamp', 'sp_featured', 'sp_hot', 'sp_openhouse', 'sp_forclosure', 'textsearch', 'property_title', 'location_text', 'vids_numb', 'rendered', 'alias');
     $q = '';
     foreach ($parent_data as $key => $value) {
         if (in_array($key, $forbidden_fields)) {
             continue;
         }
         $q .= "`{$key}`='{$value}', ";
     }
     $q .= trim($q, ', ');
     $query = "UPDATE `#__wpl_properties` SET `parent`='{$parent_id}', {$q} WHERE `id`='{$item_id}'";
     wpl_db::q($query);
     echo json_encode(array('success' => 1));
     exit;
 }
Example #30
0
 /**
  * for adding page number to listing pages
  * @author Howard <*****@*****.**>
  * @param string $title
  * @return string
  */
 public function wp_title($title)
 {
     $wplview = wpl_request::getVar('wplview');
     $wplpage = wpl_request::getVar('wplpage');
     if (in_array($wplview, array('property_listing', 'profile_listing')) and $wplpage >= 2) {
         /** has HTML tag **/
         if (strpos($title, '</') != false) {
             return $title;
         }
         return wpl_global::clean($title . ' -- ' . __('Page', WPL_TEXTDOMAIN) . ' ' . $wplpage);
     }
     return $title;
 }