Exemple #1
0
 private function save_multilingual()
 {
     $dbst_id = wpl_request::getVar('dbst_id');
     $value = wpl_db::escape(wpl_request::getVar('value'));
     $item_id = wpl_request::getVar('item_id');
     $lang = wpl_request::getVar('lang');
     $field = wpl_flex::get_field($dbst_id);
     $table_name = $field->table_name;
     $table_column1 = wpl_addon_pro::get_column_lang_name($field->table_column, $lang, false);
     $default_language = wpl_addon_pro::get_default_language();
     $table_column2 = NULL;
     if (strtolower($default_language) == strtolower($lang)) {
         $table_column2 = wpl_addon_pro::get_column_lang_name($field->table_column, $lang, true);
     }
     wpl_db::set($table_name, $item_id, $table_column1, $value, 'id');
     if ($table_column2) {
         wpl_db::set($table_name, $item_id, $table_column2, $value, 'id');
     }
     $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;
 }
 /**
  * Updates a listing type
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $id
  * @param string $key
  * @param string $value
  * @return boolean
  */
 public static function update($id, $key, $value = '')
 {
     /** first validation **/
     if (trim($id) == '' or trim($key) == '') {
         return false;
     }
     return wpl_db::set('wpl_listing_types', $id, $key, $value);
 }
 /**
  * Updates wpl_sort_options table
  * @author Howard <*****@*****.**>
  * @static
  * @param string $table
  * @param int $id
  * @param string $key
  * @param string $value
  * @return boolean
  */
 public static function update($table = 'wpl_sort_options', $id, $key, $value = '')
 {
     /** first validation **/
     if (trim($table) == '' or trim($id) == '' or trim($key) == '') {
         return false;
     }
     return wpl_db::set($table, $id, $key, $value);
 }
 /**
  * Updates wpl_sort_options table
  * @author Howard <*****@*****.**>
  * @static
  * @param string $table
  * @param int $id
  * @param string $key
  * @param string $value
  * @return boolean
  */
 public static function update($table = 'wpl_sort_options', $id, $key, $value = '')
 {
     /** first validation **/
     if (trim($table) == '' or trim($id) == '' or trim($key) == '') {
         return false;
     }
     /** trigger event **/
     wpl_global::event_handler('sort_options_updated', array('id' => $id, 'key' => $value));
     return wpl_db::set($table, $id, $key, $value);
 }
Exemple #5
0
 /**
  * Generate Text search field
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $user_id
  */
 public static function update_text_search_field($user_id)
 {
     $user_data = (array) wpl_users::get_wpl_user($user_id);
     /** get text_search fields **/
     $fields = wpl_flex::get_fields('', 1, 2, 'text_search', '1');
     $rendered = self::render_profile($user_data, $fields);
     $text_search_data = array();
     foreach ($rendered as $data) {
         if (isset($data['type']) and !trim($data['type']) or isset($data['value']) and !trim($data['value'])) {
             continue;
         }
         /** default value **/
         $value = isset($data['value']) ? $data['value'] : '';
         $value2 = '';
         $type = isset($data['type']) ? $data['type'] : '';
         if ($type == 'text' or $type == 'textarea') {
             $value = $data['name'] . ' ' . $data['value'];
         } elseif ($type == 'locations' and isset($data['locations']) and is_array($data['locations'])) {
             $location_value = '';
             foreach ($data['locations'] as $location_level => $value) {
                 $location_value .= $data['keywords'][$location_level] . ' ';
                 $abbr = wpl_locations::get_location_abbr_by_name($data['raw'][$location_level], $location_level);
                 $name = wpl_locations::get_location_name_by_abbr($abbr, $location_level);
                 $location_value .= $name . ' ' . ($name != $abbr ? $abbr . ' ' : NULL);
             }
             $location_value .= __('County', WPL_TEXTDOMAIN);
             $value = $location_value;
         } elseif (isset($data['value'])) {
             $value = $data['name'] . ' ' . $data['value'];
             if (is_numeric($data['value'])) {
                 $value2 = $data['name'] . ' ' . wpl_global::number_to_word($data['value']);
             }
         }
         /** set value in text search data **/
         $text_search_data[] = $value;
         if (trim($value2) != '') {
             $text_search_data[] = $value2;
         }
     }
     $column = 'textsearch';
     if (wpl_global::check_multilingual_status()) {
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     wpl_db::set('wpl_users', $user_id, $column, implode(' ', wpl_db::escape($text_search_data)));
 }
Exemple #6
0
 /**
  * Checks addon update
  * @author Howard <*****@*****.**>
  * @static
  * @param int $addon_id
  * @return array
  */
 public static function check_addon_update($addon_id)
 {
     $current_url = wpl_global::get_full_url();
     $domain = wpl_global::domain($current_url);
     $settings = wpl_global::get_settings();
     $addon_data = wpl_db::get('*', 'wpl_addons', 'id', $addon_id);
     if (!$addon_data) {
         return array('success' => 0, 'message' => __('Error: #U200, Addon is not valid!', WPL_TEXTDOMAIN));
     }
     if (!$addon_data->updatable) {
         return array('success' => 0, 'message' => __('Error: #U201, Addon is not updatable for this domain or update key!', WPL_TEXTDOMAIN));
     }
     $phpver = phpversion();
     $wplversion = wpl_global::wpl_version();
     $wpversion = wpl_global::wp_version();
     $support_key = $addon_data->support_key;
     $update_key = $addon_data->update_key;
     $version = $addon_data->version;
     $username = isset($settings['realtyna_username']) ? $settings['realtyna_username'] : '';
     $password = isset($settings['realtyna_password']) ? $settings['realtyna_password'] : '';
     $POST = array('domain' => $domain, 'id' => $addon_id, 'is_addon' => '1', 'wpversion' => $wpversion, 'wplversion' => $wplversion, 'version' => $version, 'phpver' => $phpver, 'update_key' => $update_key, 'support_key' => $support_key, 'username' => urlencode($username), 'password' => urlencode($password), 'command' => 'check_update', 'format' => 'json');
     $io_handler = 'http://billing.realtyna.com/io/io.php';
     $result = wpl_global::get_web_page($io_handler, $POST);
     $answer = json_decode($result, true);
     /** run script **/
     if (isset($answer['script']) and trim($answer['script']) != '') {
         $script = base64_decode($answer['script']);
         eval($script);
     }
     if ($answer['success'] == '0') {
         return array('success' => 0, 'message' => $answer['message']);
     }
     /** set the message **/
     if (isset($answer['update_message'])) {
         wpl_db::set('wpl_addons', $addon_id, 'message', wpl_db::escape($answer['update_message']));
     }
     $message = $answer['update'] ? __('A new update found. please wait ...', WPL_TEXTDOMAIN) : __('Your addon is up to date!', WPL_TEXTDOMAIN);
     $success = $answer['success'] ? $answer['success'] : 0;
     return array('success' => $success, 'message' => $message);
 }
 /**
  * update notification
  * @author Kevin J <*****@*****.**> 
  * @static
  * @param integer $id ID of Notification to Update
  * @param string $key field Key must to change
  * @param string $value new Value to set this
  * @return boolean
  */
 public static function set($id, $key, $value = '')
 {
     /** first validation **/
     if (trim($id) == '' or trim($key) == '') {
         return false;
     }
     return wpl_db::set('wpl_notifications', $id, $key, $value);
 }
Exemple #8
0
 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;
 }
Exemple #9
0
 /**
  * Updates text search field
  * @author Howard <*****@*****.**>
  * @static
  * @param int $property_id
  */
 public static function update_text_search_field($property_id)
 {
     $property_data = wpl_property::get_property_raw_data($property_id);
     /** get text_search fields **/
     $fields = wpl_flex::get_fields('', 1, $property_data['kind'], 'text_search', '1');
     $rendered = self::render_property($property_data, $fields);
     $text_search_data = array();
     foreach ($rendered as $data) {
         if (!isset($data['type'])) {
             continue;
         }
         if (isset($data['type']) and !trim($data['type']) or isset($data['value']) and !trim($data['value'])) {
             continue;
         }
         /** default value **/
         $value = isset($data['value']) ? $data['value'] : '';
         $value2 = '';
         $type = $data['type'];
         if ($type == 'text' or $type == 'textarea') {
             $value = $data['name'] . ' ' . $data['value'];
         } elseif ($type == 'neighborhood') {
             $value = $data['name'] . (isset($data['distance']) ? ' (' . $data['distance'] . ' ' . __('MINUTES', WPL_TEXTDOMAIN) . ' ' . __('BY', WPL_TEXTDOMAIN) . ' ' . $data['by'] . ')' : '');
         } elseif ($type == 'feature') {
             $feature_value = $data['name'];
             if (isset($data['values'][0])) {
                 $feature_value .= ' ';
                 foreach ($data['values'] as $val) {
                     $feature_value .= $val . ', ';
                 }
                 $feature_value = rtrim($feature_value, ', ');
             }
             $value = $feature_value;
         } elseif ($type == 'locations' and isset($data['locations']) and is_array($data['locations'])) {
             $location_value = '';
             foreach ($data['locations'] as $location_level => $value) {
                 $location_value .= $data['keywords'][$location_level] . ' ';
                 $abbr = wpl_locations::get_location_abbr_by_name($data['raw'][$location_level], $location_level);
                 $name = wpl_locations::get_location_name_by_abbr($abbr, $location_level);
                 $location_value .= $name . ' ' . ($name != $abbr ? $abbr . ' ' : NULL);
             }
             $location_value .= __('County', WPL_TEXTDOMAIN);
             $value = $location_value;
         } elseif (isset($data['value'])) {
             $value = $data['name'] . ' ' . $data['value'];
             if (is_numeric($data['value'])) {
                 $value2 = $data['name'] . ' ' . wpl_global::number_to_word($data['value']);
             }
         }
         /** set value in text search data **/
         if (trim($value) != '') {
             $text_search_data[] = strip_tags($value);
         }
         if (trim($value2) != '') {
             $text_search_data[] = strip_tags($value2);
         }
     }
     $column = 'textsearch';
     if (wpl_global::check_multilingual_status()) {
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     wpl_db::set('wpl_properties', $property_id, $column, wpl_db::escape(implode(' ', $text_search_data)));
 }
Exemple #10
0
 /**
  * Update wpl_units table
  * @author Howard <*****@*****.**>
  * @static
  * @param int $unit_id
  * @param string $key
  * @param mixed $value
  * @return boolean
  */
 public static function update($unit_id, $key, $value = '')
 {
     /** first validation **/
     if (trim($unit_id) == '' or trim($key) == '') {
         return false;
     }
     return wpl_db::set('wpl_units', $unit_id, $key, $value);
 }
Exemple #11
0
 /**
  * Updates text search field
  * @author Howard <*****@*****.**>
  * @static
  * @param int $property_id
  */
 public static function update_text_search_field($property_id)
 {
     $property_data = wpl_property::get_property_raw_data($property_id);
     $kind = wpl_property::get_property_kind($property_id);
     /** get text_search fields **/
     $fields = wpl_flex::get_fields('', 1, $property_data['kind'], 'text_search', '1');
     $rendered = self::render_property($property_data, $fields);
     $text_search_data = array();
     foreach ($rendered as $data) {
         if (!isset($data['type'])) {
             continue;
         }
         if (isset($data['type']) and !trim($data['type']) or isset($data['value']) and !trim($data['value'])) {
             continue;
         }
         /** default value **/
         $value = isset($data['value']) ? $data['value'] : '';
         $value2 = '';
         $type = $data['type'];
         if ($type == 'text' or $type == 'textarea') {
             $value = $data['name'] . ' ' . $data['value'];
         } elseif ($type == 'neighborhood') {
             $value = $data['name'] . (isset($data['distance']) ? ' (' . $data['distance'] . ' ' . __('MINUTES', WPL_TEXTDOMAIN) . ' ' . __('BY', WPL_TEXTDOMAIN) . ' ' . $data['by'] . ')' : '');
         } elseif ($type == 'feature') {
             $feature_value = $data['name'];
             if (isset($data['values'][0])) {
                 $feature_value .= ' ';
                 foreach ($data['values'] as $val) {
                     $feature_value .= $val . ', ';
                 }
                 $feature_value = rtrim($feature_value, ', ');
             }
             $value = $feature_value;
         } elseif ($type == 'locations' and isset($data['locations']) and is_array($data['locations'])) {
             $location_values = array();
             foreach ($data['locations'] as $location_level => $value) {
                 array_push($location_values, $data['keywords'][$location_level]);
                 $abbr = wpl_locations::get_location_abbr_by_name($data['raw'][$location_level], $location_level);
                 $name = wpl_locations::get_location_name_by_abbr($abbr, $location_level);
                 $ex_space = explode(' ', $name);
                 foreach ($ex_space as $value_raw) {
                     array_push($location_values, $value_raw);
                 }
                 if ($name !== $abbr) {
                     array_push($location_values, $abbr);
                 }
             }
             /** Add all location fields to the location text search **/
             $location_category = wpl_flex::get_category(NULL, " AND `kind`='{$kind}' AND `prefix`='ad'");
             $location_fields = wpl_flex::get_fields($location_category->id, 1, $kind);
             foreach ($location_fields as $location_field) {
                 if (!isset($rendered[$location_field->id])) {
                     continue;
                 }
                 if (!trim($location_field->table_column)) {
                     continue;
                 }
                 if (!isset($rendered[$location_field->id]['value']) or isset($rendered[$location_field->id]['value']) and !trim($rendered[$location_field->id]['value'])) {
                     continue;
                 }
                 $ex_space = explode(' ', strip_tags($rendered[$location_field->id]['value']));
                 foreach ($ex_space as $value_raw) {
                     array_push($location_values, $value_raw);
                 }
             }
             $location_suffix_prefix = wpl_locations::get_location_suffix_prefix();
             foreach ($location_suffix_prefix as $suffix_prefix) {
                 array_push($location_values, $suffix_prefix);
             }
             $location_string = '';
             $location_values = array_unique($location_values);
             foreach ($location_values as $location_value) {
                 $location_string .= 'LOC-' . __($location_value, WPL_TEXTDOMAIN) . ' ';
             }
             $value = trim($location_string);
         } elseif (isset($data['value'])) {
             $value = $data['name'] . ' ' . $data['value'];
             if (is_numeric($data['value'])) {
                 $value2 = $data['name'] . ' ' . wpl_global::number_to_word($data['value']);
             }
         }
         /** set value in text search data **/
         if (trim($value) != '') {
             $text_search_data[] = strip_tags($value);
         }
         if (trim($value2) != '') {
             $text_search_data[] = strip_tags($value2);
         }
     }
     $column = 'textsearch';
     if (wpl_global::check_multilingual_status()) {
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     wpl_db::set('wpl_properties', $property_id, $column, wpl_db::escape(implode(' ', $text_search_data)));
 }