/** * 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) . "\");")); } } } } }
/** * Generate location text of User * @author Howard R <*****@*****.**> * @static * @param array $user_data * @param int $user_id * @param string $glue * @return string */ public static function generate_location_text($user_data, $user_id = 0, $glue = ',') { /** fetch user data if user id is setted **/ if ($user_id) { $user_data = (array) wpl_users::get_wpl_user($user_id); } if (!$user_id) { $user_id = $user_data['id']; } $locations = array(); if (isset($user_data['location7_name']) and trim($user_data['location7_name']) != '') { $locations['location7_name'] = __($user_data['location7_name'], WPL_TEXTDOMAIN); } if (isset($user_data['location6_name']) and trim($user_data['location6_name']) != '') { $locations['location6_name'] = __($user_data['location6_name'], WPL_TEXTDOMAIN); } if (isset($user_data['location5_name']) and trim($user_data['location5_name']) != '') { $locations['location5_name'] = __($user_data['location5_name'], WPL_TEXTDOMAIN); } if (isset($user_data['location4_name']) and trim($user_data['location4_name']) != '') { $locations['location4_name'] = __($user_data['location4_name'], WPL_TEXTDOMAIN); } if (isset($user_data['location3_name']) and trim($user_data['location3_name']) != '') { $locations['location3_name'] = __($user_data['location3_name'], WPL_TEXTDOMAIN); } if (isset($user_data['location2_name']) and trim($user_data['location2_name']) != '') { $locations['location2_name'] = __($user_data['location2_name'], WPL_TEXTDOMAIN); } if (isset($user_data['zip_name']) and trim($user_data['zip_name']) != '') { $locations['zip_name'] = __($user_data['zip_name'], WPL_TEXTDOMAIN); } if (isset($user_data['location1_name']) and trim($user_data['location1_name']) != '') { $locations['location1_name'] = __($user_data['location1_name'], WPL_TEXTDOMAIN); } $location_pattern = wpl_global::get_setting('user_location_pattern'); if (trim($location_pattern) == '') { $location_pattern = '[location5_name][glue][location4_name][glue][location3_name][glue][location2_name][glue][location1_name] [zip_name]'; } $location_text = ''; $location_text = isset($locations['location7_name']) ? str_replace('[location7_name]', $locations['location7_name'], $location_pattern) : str_replace('[location7_name]', '', $location_pattern); $location_text = isset($locations['location6_name']) ? str_replace('[location6_name]', $locations['location6_name'], $location_pattern) : str_replace('[location6_name]', '', $location_pattern); $location_text = isset($locations['location5_name']) ? str_replace('[location5_name]', $locations['location5_name'], $location_pattern) : str_replace('[location5_name]', '', $location_pattern); $location_text = isset($locations['location4_name']) ? str_replace('[location4_name]', $locations['location4_name'], $location_text) : str_replace('[location4_name]', '', $location_text); $location_text = isset($locations['location3_name']) ? str_replace('[location3_name]', $locations['location3_name'], $location_text) : str_replace('[location3_name]', '', $location_text); $location_text = isset($locations['location2_name']) ? str_replace('[location2_name]', $locations['location2_name'], $location_text) : str_replace('[location2_name]', '', $location_text); $location_text = isset($locations['zip_name']) ? str_replace('[zip_name]', $locations['zip_name'], $location_text) : str_replace('[zip_name]', '', $location_text); $location_text = isset($locations['location1_name']) ? str_replace('[location1_name]', $locations['location1_name'], $location_text) : str_replace('[location1_name]', '', $location_text); $location_text = str_replace('[glue]', $glue, $location_text); /** apply filters **/ _wpl_import('libraries.filters'); @extract(wpl_filters::apply('generate_user_location_text', array('location_text' => $location_text, 'glue' => $glue, 'user_data' => $user_data))); $final = ''; $ex = explode($glue, $location_text); foreach ($ex as $value) { if (trim($value) == '') { continue; } $final .= trim($value) . $glue . ' '; } $location_text = trim($final, $glue . ' '); $column = 'location_text'; $field_id = wpl_flex::get_dbst_id($column, 2); $field = wpl_flex::get_field($field_id); if (isset($field->multilingual) and $field->multilingual and wpl_global::check_multilingual_status()) { $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false); } /** update **/ $query = "UPDATE `#__wpl_users` SET `{$column}`='" . $location_text . "' WHERE `id`='{$user_id}'"; wpl_db::q($query, 'update'); return $location_text; }
private function delete_file($field_id, $user_id, $output = true) { $field_data = (array) wpl_db::get('*', 'wpl_dbst', 'id', $field_id); $user_data = (array) wpl_users::get_wpl_user($user_id); $path = wpl_items::get_path($user_id, $field_data['kind']) . $user_data[$field_data['table_column']]; /** delete file and reset db **/ wpl_file::delete($path); wpl_db::set('wpl_users', $user_id, $field_data['table_column'], ''); /** delete thumbnails **/ wpl_users::remove_thumbnails($user_id); /** called from other functions (upload function) **/ if (!$output) { return; } $res = 1; $message = $res ? __('Saved.', WPL_TEXTDOMAIN) : __('Error Occured.', WPL_TEXTDOMAIN); $data = NULL; $response = array('success' => $res, 'message' => $message, 'data' => $data); echo json_encode($response); exit; }
/** * Sets profile single page parameters * @author Howard <*****@*****.**> * @param int $user_id */ public function set_profile_page_params($user_id) { $current_link_url = wpl_global::get_full_url(); $user_data = (array) wpl_users::get_wpl_user($user_id); $this->user_title = ''; $this->user_keywords = ''; $this->user_description = __('Listings of', WPL_TEXTDOMAIN); if (trim($user_data['first_name']) != '') { $this->user_title .= $user_data['first_name']; $this->user_keywords .= $user_data['first_name'] . ','; $this->user_description .= ' ' . $user_data['first_name']; } if (trim($user_data['last_name']) != '') { $this->user_title .= ' ' . $user_data['last_name']; $this->user_keywords .= $user_data['last_name'] . ','; $this->user_description .= ' ' . $user_data['last_name']; } if (trim($user_data['company_name']) != '') { $this->user_title .= ' - ' . $user_data['company_name']; $this->user_keywords .= $user_data['company_name'] . ','; $this->user_description .= ' - ' . $user_data['company_name']; } $this->user_title .= ' ' . __('Listings', WPL_TEXTDOMAIN); $this->user_keywords = trim($this->user_keywords, ', '); $this->user_description .= ' ' . __('which is located in', WPL_TEXTDOMAIN) . ' ' . $user_data['location_text']; $html = wpl_html::getInstance(); wpl_html::$canonical = str_replace('&', '&', $current_link_url); /** set title **/ $html->set_title($this->user_title); /** set meta keywords **/ $html->set_meta_keywords($this->user_keywords); /** set meta description **/ $html->set_meta_description($this->user_description); }
', '<?php echo $field->id; ?> ');" <?php echo (isset($options['readonly']) and $options['readonly'] == 1) ? 'disabled="disabled"' : ''; ?> /> <span id="wpl_listing_saved_span_<?php echo $field->id; ?> " class="wpl_listing_saved_span"></span> <?php $done_this = true; } elseif ($type == 'property_types' and !$done_this) { $property_types = wpl_global::get_property_types(); $current_user = wpl_users::get_wpl_user(); $ptrestrict = $current_user->maccess_ptrestrict; $rproperty_types = explode(',', $current_user->maccess_property_types); ?> <label for="wpl_c_<?php echo $field->id; ?> "><?php echo __($label, WPL_TEXTDOMAIN); if (in_array($mandatory, array(1, 2))) { ?> <span class="required-star">*</span><?php } ?> </label> <select class="wpl_c_<?php