예제 #1
0
 public function generate_addons()
 {
     $tpl = 'internal_addons';
     $this->addons = wpl_db::select("SELECT * FROM `#__wpl_addons` ORDER BY `id` ASC", 'loadAssocList');
     /** import tpl **/
     parent::render($this->tpl_path, $tpl);
 }
예제 #2
0
 /**
  * Sorts sort options
  * @author Howard <*****@*****.**>
  * @static
  * @param string $sort_ids
  */
 public static function sort_options($sort_ids)
 {
     $query = "SELECT `id`,`index` FROM `#__wpl_sort_options` WHERE `id` IN ({$sort_ids}) ORDER BY `index` ASC";
     $options = wpl_db::select($query, 'loadAssocList');
     $conter = 0;
     $ex_sort_ids = explode(',', $sort_ids);
     foreach ($ex_sort_ids as $ex_sort_id) {
         self::update('wpl_sort_options', $ex_sort_id, 'index', $options[$conter]["index"]);
         $conter++;
     }
 }
예제 #3
0
 private function locationtextsearch_autocomplete($term)
 {
     $limit = 10;
     $query = "SELECT `count`, `location_text` AS name FROM `#__wpl_locationtextsearch` WHERE `location_text` LIKE '" . $term . "%' ORDER BY `count` DESC LIMIT " . $limit;
     $results = wpl_db::select($query, 'loadAssocList');
     $output = array();
     foreach ($results as $result) {
         $output[] = array('label' => $result['name'], 'value' => $result['name']);
     }
     echo json_encode($output);
     exit;
 }
예제 #4
0
 /**
  * Returns notifications
  * @author Howard R <*****@*****.**>
  * @static
  * @param string $where
  * @param string $result
  * @return mixed
  */
 public static function get_notifications($where = '', $result = 'loadObjectList')
 {
     $query = "SELECT * FROM `#__wpl_notifications` WHERE 1 " . $where;
     return wpl_db::select($query, $result);
 }
예제 #5
0
 /**
  * Get a room type by name
  * @author Howard <*****@*****.**>
  * @static
  * @param string $name
  * @return array
  */
 public static function get_room_type($name)
 {
     $query = "SELECT * FROM `#__wpl_room_types` WHERE `name`='{$name}' LIMIT 1";
     return wpl_db::select($query, 'loadAssoc');
 }
예제 #6
0
 private function item_save()
 {
     $kind = wpl_request::getVar('kind', 0);
     $parent_id = wpl_request::getVar('item_id', 0);
     $item_type = wpl_request::getVar('item_type', '');
     $item_cat = wpl_request::getVar('item_cat', '');
     $item_name = wpl_request::getVar('value', '');
     $item_extra1 = wpl_request::getVar('item_extra1', '');
     $item_extra2 = wpl_request::getVar('item_extra2', '');
     $item_extra3 = wpl_request::getVar('item_extra3', '');
     $query = "SELECT `id` FROM `#__wpl_items` WHERE `parent_kind`='{$kind}' AND `parent_id`='{$parent_id}' AND `item_type`='{$item_type}' AND `item_cat`='{$item_cat}'";
     $item_id = wpl_db::select($query, 'loadResult');
     $item = array('parent_id' => $parent_id, 'parent_kind' => $kind, 'item_type' => $item_type, 'item_cat' => $item_cat, 'item_name' => $item_name, 'creation_date' => date("Y-m-d H:i:s"), 'index' => '1.00', 'item_extra1' => $item_extra1, 'item_extra2' => $item_extra2, 'item_extra3' => $item_extra3);
     wpl_items::save($item, $item_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;
 }
예제 #7
0
 /**
  * Returns abbreviation by location name
  * @author Howard <*****@*****.**>
  * @static
  * @param string $name
  * @param int $location_level
  * @return string
  */
 public static function get_location_abbr_by_name($name, $location_level = 1)
 {
     /** First Validation **/
     if (!$location_level) {
         $location_level = 1;
     }
     if ($location_level == 'zips') {
         return $name;
     }
     $abbr = wpl_db::select("SELECT `abbr` FROM `#__wpl_location" . $location_level . "` WHERE LOWER(`name`)='" . strtolower($name) . "'", 'loadResult');
     return trim($abbr) ? $abbr : $name;
 }
예제 #8
0
 /**
  * Returns Listing Types by parent id
  * @author Peter <*****@*****.**>
  * @static
  * @param int $parent 
  * @param int $enabled
  * @return mixed
  */
 public static function get_property_types_by_parent($parent, $enabled = 1)
 {
     $query = "SELECT * FROM `#__wpl_property_types` WHERE `parent` IN ({$parent}) `enabled`>='{$enabled}' AND `name`!='' ORDER BY `index` ASC";
     return wpl_db::select($query, 'loadAssocList');
 }
예제 #9
0
 /**
  * Checks if a property type has properties or not
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $property_type_id
  * @return int
  */
 public static function have_properties($property_type_id)
 {
     $query = "SELECT count(`id`) as 'id' FROM `#__wpl_properties` WHERE `property_type`='{$property_type_id}'";
     $res = wpl_db::select($query, 'loadAssoc');
     return $res['id'];
 }
예제 #10
0
        $property_types_str = '';
        if (count($property_types)) {
            foreach ($property_types as $property_type) {
                $property_types_str .= $property_type['id'] . ',';
            }
            $property_types_str = trim($property_types_str, ', ');
        }
        if (trim($property_types_str)) {
            $query .= " AND `property_type` IN ({$property_types_str})";
        }
    }
    $done_this = true;
} elseif ($format == 'ltcategory' and !$done_this) {
    if ($value != '-1' and trim($value) != '') {
        $category_id = wpl_db::select("SELECT `id` FROM `#__wpl_listing_types` WHERE LOWER(name)='" . strtolower($value) . "' AND `parent`='0'", 'loadResult');
        $listing_types = wpl_db::select("SELECT `id` FROM `#__wpl_listing_types` WHERE `parent`='{$category_id}'", 'loadAssocList');
        $listing_types_str = '';
        if (count($listing_types)) {
            foreach ($listing_types as $listing_type) {
                $listing_types_str .= $listing_type['id'] . ',';
            }
            $listing_types_str = trim($listing_types_str, ', ');
        }
        if (trim($listing_types_str)) {
            $query .= " AND `listing` IN ({$listing_types_str})";
        }
    }
    $done_this = true;
} elseif ($format == 'datemin' and !$done_this) {
    _wpl_import('libraries.render');
    $min = $value;
예제 #11
0
" id="wpl_st_<?php 
    echo $setting_record->id;
    ?>
">
    <h3 class="separator-name"><?php 
    echo $setting_title;
    ?>
</h3>
	<hr />
</div>
<?php 
    $done_this = true;
} elseif ($type == 'select' and !$done_this) {
    $show_empty = isset($options['show_empty']) ? $options['show_empty'] : NULL;
    $show_shortcode = isset($options['show_shortcode']) ? $options['show_shortcode'] : NULL;
    $values = isset($options['query']) ? wpl_db::select($options['query'], 'loadAssocList') : $options['values'];
    ?>
<div class="prow wpl_setting_form_container wpl_st_type<?php 
    echo $setting_record->type;
    ?>
 wpl_st_<?php 
    echo $setting_record->setting_name;
    ?>
" id="wpl_st_<?php 
    echo $setting_record->id;
    ?>
">
    <div class="select-wp">
        <label for="wpl_st_form_element<?php 
    echo $setting_record->id;
    ?>
예제 #12
0
 /**
  * Removes WPL cached data
  * @author Howard <*****@*****.**>
  * @static
  * @param type $cache_type
  * @return boolean
  */
 public static function clear_cache($cache_type = 'all')
 {
     /** first validation **/
     $cache_type = strtolower($cache_type);
     if (trim($cache_type) == '') {
         return false;
     }
     /** import libraries **/
     _wpl_import('libraries.property');
     _wpl_import('libraries.items');
     if ($cache_type == 'unfinalized_properties' or $cache_type == 'all') {
         $properties = wpl_db::select("SELECT `id` FROM `#__wpl_properties` WHERE `finalized`='0'", 'loadAssocList');
         foreach ($properties as $property) {
             wpl_property::purge($property['id']);
         }
     }
     if ($cache_type == 'properties_cached_data' or $cache_type == 'all') {
         $q = " `location_text`='', `rendered`='', `alias`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('alias', 'location_text', 'rendered'));
         }
         $query = "UPDATE `#__wpl_properties` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'location_texts' or $cache_type == 'all') {
         $q = " `location_text`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('location_text'));
         }
         $query = "UPDATE `#__wpl_properties` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'listings_thumbnails' or $cache_type == 'all') {
         $properties = wpl_db::select("SELECT `id`, `kind` FROM `#__wpl_properties` WHERE `id`>0", 'loadAssocList');
         $ext_array = array('jpg', 'jpeg', 'gif', 'png');
         foreach ($properties as $property) {
             $path = wpl_items::get_path($property['id'], $property['kind']);
             $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true);
             foreach ($thumbnails as $thumbnail) {
                 wpl_file::delete($thumbnail);
             }
         }
     }
     if ($cache_type == 'users_cached_data' or $cache_type == 'all') {
         $q = " `location_text`='', `rendered`=''";
         if (wpl_global::check_multilingual_status()) {
             $q = self::get_multilingual_query(array('location_text', 'rendered'), 'wpl_users');
         }
         $query = "UPDATE `#__wpl_users` SET " . $q;
         wpl_db::q($query);
     }
     if ($cache_type == 'users_thumbnails' or $cache_type == 'all') {
         $users = wpl_db::select("SELECT `id` FROM `#__wpl_users` WHERE `id`>0", 'loadAssocList');
         $ext_array = array('jpg', 'jpeg', 'gif', 'png');
         foreach ($users as $user) {
             $path = wpl_items::get_path($user['id'], 2);
             $thumbnails = wpl_folder::files($path, 'th.*\\.(' . implode('|', $ext_array) . ')$', 3, true);
             foreach ($thumbnails as $thumbnail) {
                 wpl_file::delete($thumbnail);
             }
         }
     }
     /** trigger event **/
     wpl_global::event_handler('cache_cleared', array('cache_type' => $cache_type));
     return true;
 }
예제 #13
0
 /**
  * It changes dummy fields to WPL fields
  * @author Howard R <*****@*****.**>
  * @static
  * @param array $parameters
  */
 public static function set_location_vars($parameters)
 {
     /** specific fields like country, state, city and ... **/
     $location_fields = array();
     $rendered_parameters = array();
     /** add location fields to specific fields **/
     $location_settings = wpl_global::get_settings('3');
     # location settings
     foreach ($location_settings as $location_key => $location_value) {
         if (!strpos($location_key, '_keyword') or trim($location_value) == '') {
             continue;
         }
         $location_id = str_replace('location', '', str_replace('_keyword', '', $location_key));
         if ($location_id != 'zips') {
             $location_fields['location' . $location_id . '_id'] = self::parse_field($location_value);
         } else {
             $location_fields['zip_id'] = self::parse_field($location_value);
         }
     }
     foreach ($parameters as $parameter) {
         $ex = explode(':', $parameter);
         if (count($ex) == 2) {
             $rendered_parameters[self::parse_field(urldecode($ex[0]))] = $ex[1];
         } elseif (count($ex) == 3) {
             $rendered_parameters[self::parse_field(urldecode($ex[1]))] = $ex[2];
         }
     }
     foreach ($location_fields as $column => $location_field) {
         if (!isset($rendered_parameters[$location_field])) {
             continue;
         }
         $location_id = str_replace('location', '', str_replace('_id', '', $column));
         if ($location_id == 'zip') {
             $location_id = 'zips';
         }
         $query = "SELECT `id` FROM `#__wpl_location" . $location_id . "` WHERE `name`='" . urldecode($rendered_parameters[$location_field]) . "' " . ($parent ? "AND `parent`='{$parent}'" : '');
         $parent = wpl_db::select($query, 'loadResult');
         wpl_request::setVar('sf_select_' . $column, $parent);
     }
 }
예제 #14
0
 /**
  * get Activities by given Array of ID
  * @author Kevin J <*****@*****.**>
  * @static
  * @param array $ex_sort_ids
  * @return array
  */
 private static function _get_data_for_sort($ex_sort_ids)
 {
     $id = array();
     $data = array();
     foreach ($ex_sort_ids as $ex_sort_id) {
         $id_section = explode(':', $ex_sort_id);
         $id[] = $id_section[0];
     }
     $query = "SELECT `id`, `index` FROM `#__wpl_activities` WHERE `id` IN (" . implode(",", $id) . ") ORDER BY `index` ASC, `id` DESC";
     $activities = wpl_db::select($query, 'loadAssocList');
     foreach ($activities as $activity) {
         $data[$activity['id']] = $activity['index'];
     }
     return $data;
 }
예제 #15
0
 private function query($instance)
 {
     $model = new wpl_users();
     $data = $instance['data'];
     $this->start = 0;
     $this->limit = $data['limit'];
     $this->orderby = $data['orderby'];
     $this->order = $data['order'];
     $where = array('sf_tmin_id' => 1, 'sf_select_access_public_profile' => 1, 'sf_select_expired' => 0);
     if (trim($data['user_type']) and $data['user_type'] != '-1') {
         $where['sf_select_membership_type'] = $data['user_type'];
     }
     if (trim($data['membership']) and $data['membership'] != '') {
         $where['sf_select_membership_id'] = $data['membership'];
     }
     if (trim($data['user_ids'])) {
         $where['sf_multiple_id'] = trim($data['user_ids'], ', ');
     }
     if (isset($data['random']) and trim($data['random']) and trim($data['user_ids']) == '') {
         $query_rand = "SELECT p.`id` FROM `#__wpl_users` AS p WHERE 1 " . wpl_db::create_query($where) . " ORDER BY RAND() LIMIT " . $this->limit;
         $results = wpl_db::select($query_rand);
         $rand_ids = array();
         foreach ($results as $result) {
             $rand_ids[] = $result->id;
         }
         $where['sf_multiple_id'] = implode(',', $rand_ids);
     }
     $model->start($this->start, $this->limit, $this->orderby, $this->order, $where);
     return $model->query();
 }
예제 #16
0
 /**
  * For inserting logs using WPL events API
  * @author Howard R <*****@*****.**>
  * @static
  * @param array $params
  * @return int
  */
 public static function autolog($params = array())
 {
     $dynamic_params = $params[0];
     $static_params = $params[1];
     $section = isset($static_params['section']) ? $static_params['section'] : 'no-section';
     $addon_id = isset($static_params['addon_id']) ? $static_params['addon_id'] : 0;
     $user_id = isset($static_params['user_id']) ? $static_params['user_id'] : NULL;
     $status = isset($static_params['status']) ? $static_params['status'] : 1;
     $priority = isset($static_params['priority']) ? $static_params['priority'] : 3;
     if ($static_params['type'] == 1) {
     } elseif ($static_params['type'] == 2) {
         $query = str_replace('[VALUE]', $dynamic_params, $static_params['pattern']);
         $contents = wpl_db::select($query, 'loadAssoc');
         $log_text = $static_params['message'];
         foreach ($contents as $key => $value) {
             $log_text = str_replace('[' . $key . ']', $value, $log_text);
         }
     }
     return self::add($log_text, $section, $status, $user_id, $addon_id, $priority);
 }
예제 #17
0
 /**
  * Returns maximum index for sorting a new item
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $parent_id
  * @param string $item_type
  * @param int $parent_kind
  * @param mixed $category
  * @param int $enabled
  * @param string $condition
  * @return int
  */
 public static function get_maximum_index($parent_id, $item_type = '', $parent_kind = 0, $category = '', $enabled = '', $condition = '')
 {
     /** first validation **/
     if (trim($parent_id) == '') {
         return NULL;
     }
     if (trim($condition) == '') {
         $condition = "";
         $condition .= " AND `parent_id`='{$parent_id}' AND `parent_kind`='{$parent_kind}'";
         if (trim($item_type) != '') {
             $condition .= " AND `item_type`='{$item_type}'";
         }
         if (trim($category) != '') {
             $condition .= " AND `item_cat`='{$category}'";
         }
         if (trim($enabled) != '') {
             $condition .= " AND `enabled`>='{$enabled}'";
         }
     }
     $query = "SELECT MAX(`index`) as max FROM `#__wpl_items` WHERE 1 " . $condition;
     $index = wpl_db::select($query, 'loadObject');
     return $index->max;
 }
예제 #18
0
 /**
  * Get property ids for a criteria
  * @author Howard R <*****@*****.**>
  * @static
  * @param string $column
  * @param mixed $value
  * @return type
  */
 public static function get_properties_list($column, $value)
 {
     $query = "SELECT `id` FROM `#__wpl_properties` WHERE `{$column}`='{$value}'";
     return wpl_db::select($query, 'loadAssocList');
 }
예제 #19
0
 /**
  * Gets filters by trigger and enabled status
  * @author Howard <*****@*****.**>
  * @param string $trigger
  * @param int $enabled
  * @return array
  */
 public static function get_filters($trigger, $enabled = 1)
 {
     $query = "SELECT * FROM `#__wpl_filters` WHERE `trigger`='{$trigger}' AND `enabled`>='{$enabled}'";
     return wpl_db::select($query);
 }
예제 #20
0
} else {
    echo __('No data!', WPL_TEXTDOMAIN);
}
?>
        </div>
    </div>
</div>
<div class="side-6 side-statistic2">
    <div class="panel-wp">
        <h3><?php 
echo __('Properties by property types', WPL_TEXTDOMAIN);
?>
</h3>
        <div class="panel-body">
        	<?php 
$properties = wpl_db::select("SELECT COUNT(*) as count, `property_type` FROM `#__wpl_properties` WHERE `finalized`='1' AND `expired`='0' AND `confirmed`='1' AND `deleted`='0' AND `property_type`!='0' GROUP BY `property_type`", 'loadAssocList');
$data = array();
$total = 0;
foreach ($properties as $property) {
    $property_type = wpl_global::get_property_types($property['property_type']);
    if (is_object($property_type)) {
        $data[__($property_type->name, WPL_TEXTDOMAIN)] = $property['count'];
        $total += $property['count'];
    }
}
$params = array('chart_background' => '#fafafa', 'chart_width' => '100%', 'chart_height' => '250px', 'show_value' => 1, 'data' => $data);
if (count($data)) {
    echo '<div class="wpl-total-properties">' . sprintf(__('Total Properties: %s', WPL_TEXTDOMAIN), $total) . '</div>';
    wpl_global::import_activity('charts:bar', '', $params);
} else {
    echo __('No data!', WPL_TEXTDOMAIN);
예제 #21
0
 /**
  * Sorts flex fields
  * @author Howard R <*****@*****.**>
  * @static
  * @param string $sort_ids
  */
 public static function sort_flex($sort_ids)
 {
     $query = "SELECT DISTINCT `category`  FROM `#__wpl_dbst` WHERE `id` IN ({$sort_ids}) ORDER BY `index` ASC";
     $flex_category = wpl_db::select($query, 'loadAssoc');
     $conter = 0;
     $ex_sort_ids = explode(',', $sort_ids);
     foreach ($ex_sort_ids as $ex_sort_id) {
         if ($conter < 10) {
             $index = $flex_category["category"] . '.0' . $conter;
         } else {
             $index = $flex_category["category"] . '.' . $conter;
         }
         self::update('wpl_dbst', $ex_sort_id, 'index', $index);
         $conter++;
     }
 }
예제 #22
0
 /**
  * Gets cronjobs
  * @author Howard <*****@*****.**>
  * @param int $enabled
  * @return array
  */
 public static function get_cronjobs($enabled = 1)
 {
     $query = "SELECT * FROM `#__wpl_cronjobs` WHERE DATE_ADD(`latest_run`, INTERVAL `period` HOUR)<'" . date("Y-m-d H:i:s") . "' AND `enabled`>='{$enabled}'";
     return wpl_db::select($query);
 }
예제 #23
0
 /**
  * Uninstalling WPL
  * @author Howard <*****@*****.**>
  * @return boolean
  */
 public function uninstall_wpl()
 {
     $tables = wpl_db::select('SHOW TABLES');
     $database = wpl_db::get_DBO();
     foreach ($tables as $table_name => $table) {
         if (strpos($table_name, $database->prefix . 'wpl_') !== false) {
             /** drop table **/
             wpl_db::q("DROP TABLE `{$table_name}`");
         }
     }
     /** delete options **/
     wpl_db::q("DELETE FROM `#__options` WHERE `option_name` LIKE 'wpl_%' AND `option_name` NOT LIKE 'wpl_theme%'", 'delete');
     /** remove WPL upload directory **/
     if (function_exists('is_multisite') and is_multisite() and wpl_global::check_addon('multisite')) {
         $original_blog_id = wpl_global::get_current_blog_id();
         // Get all blogs
         $blogs = wpl_db::select("SELECT `blog_id` FROM `#__blogs`", 'loadColumn');
         foreach ($blogs as $blog) {
             if (!isset($blog->blog_id)) {
                 continue;
             }
             switch_to_blog($blog->blog_id);
             $upload_path = wpl_global::get_upload_base_path($blog->blog_id);
             if (wpl_folder::exists($upload_path)) {
                 wpl_folder::delete($upload_path);
             }
         }
         switch_to_blog($original_blog_id);
     } else {
         $upload_path = wpl_global::get_upload_base_path();
         if (wpl_file::exists($upload_path)) {
             wpl_file::delete($upload_path);
         }
     }
     return true;
 }
예제 #24
0
 private function query($instance)
 {
     /** property listing model **/
     $model = new wpl_property();
     $data = $instance['data'];
     $this->start = 0;
     $this->limit = $data['limit'];
     $this->orderby = urldecode($data['orderby']);
     $this->order = $data['order'];
     /** detect kind **/
     if (isset($data['kind']) and (trim($data['kind']) != '' or trim($data['kind']) != '-1')) {
         $kind = $data['kind'];
     } else {
         $kind = 0;
     }
     $where = array('sf_select_confirmed' => 1, 'sf_select_finalized' => 1, 'sf_select_deleted' => 0, 'sf_select_expired' => 0, 'sf_select_kind' => $kind);
     if (trim($data['listing']) and $data['listing'] != '-1') {
         $where['sf_select_listing'] = $data['listing'];
     }
     if (trim($data['property_type']) and $data['property_type'] != '-1') {
         $where['sf_select_property_type'] = $data['property_type'];
     }
     if (trim($data['property_ids'])) {
         $where['sf_multiple_id'] = trim($data['property_ids'], ', ');
     }
     if (trim($data['only_featured'])) {
         $where['sf_select_sp_featured'] = 1;
     }
     if (trim($data['only_hot'])) {
         $where['sf_select_sp_hot'] = 1;
     }
     if (trim($data['only_openhouse'])) {
         $where['sf_select_sp_openhouse'] = 1;
     }
     if (trim($data['only_forclosure'])) {
         $where['sf_select_sp_forclosure'] = 1;
     }
     /** Parent **/
     if (isset($data['parent']) and trim($data['parent'])) {
         $where['sf_parent'] = $data['parent'];
     }
     if (isset($data['auto_parent']) and trim($data['auto_parent'])) {
         /** current proeprty id - This features works only in single property page **/
         $property_data = NULL;
         $pid = wpl_request::getVar('pid', 0);
         if ($pid) {
             $property_data = $model->get_property_raw_data($pid);
         }
         if (isset($property_data['mls_id'])) {
             $where['sf_parent'] = $property_data['mls_id'];
         }
     }
     if (isset($data['random']) and trim($data['random']) and trim($data['property_ids']) == '') {
         $query_rand = "SELECT p.`id` FROM `#__wpl_properties` AS p WHERE 1 " . wpl_db::create_query($where) . " ORDER BY RAND() LIMIT " . $this->limit;
         $results = wpl_db::select($query_rand);
         $rand_ids = array();
         foreach ($results as $result) {
             $rand_ids[] = $result->id;
         }
         $where['sf_multiple_id'] = implode(',', $rand_ids);
     }
     /** Similar properties **/
     if (isset($data['sml_only_similars']) and $data['sml_only_similars']) {
         $sml_where = array('sf_select_confirmed' => 1, 'sf_select_finalized' => 1, 'sf_select_deleted' => 0, 'sf_select_expired' => 0);
         /** current proeprty id - This features works only in single property page **/
         $pid = wpl_request::getVar('pid', 0);
         $property_data = wpl_property::get_property_raw_data($pid);
         if ($property_data) {
             $sml_where['sf_notselect_id'] = $pid;
             $sml_where['sf_select_kind'] = $property_data['kind'];
             if (isset($data['sml_inc_listing']) and $data['sml_inc_listing']) {
                 $sml_where['sf_select_listing'] = $property_data['listing'];
             }
             if (isset($data['sml_inc_property_type']) and $data['sml_inc_property_type']) {
                 $sml_where['sf_select_property_type'] = $property_data['property_type'];
             }
             if (isset($data['sml_inc_price']) and $data['sml_inc_price']) {
                 $down_rate = $data['sml_price_down_rate'] ? $data['sml_price_down_rate'] : 0.8;
                 $up_rate = $data['sml_price_up_rate'] ? $data['sml_price_up_rate'] : 1.2;
                 $price_down_range = $property_data['price_si'] * $down_rate;
                 $price_up_range = $property_data['price_si'] * $up_rate;
                 $sml_where['sf_tmin_price_si'] = $price_down_range;
                 $sml_where['sf_tmax_price_si'] = $price_up_range;
             }
             if (isset($data['sml_inc_radius']) and $data['sml_inc_radius']) {
                 $latitude = $property_data['googlemap_lt'];
                 $longitude = $property_data['googlemap_ln'];
                 $radius = $data['sml_radius'];
                 $unit_id = $data['sml_radius_unit'];
                 if ($latitude and $longitude and $radius and $unit_id) {
                     $sml_where['sf_radiussearchunit'] = $unit_id;
                     $sml_where['sf_radiussearch_lat'] = $latitude;
                     $sml_where['sf_radiussearch_lng'] = $longitude;
                     $sml_where['sf_radiussearchradius'] = $radius;
                 }
             }
         }
         /** overwrite $where if similar where is correct **/
         if (count($sml_where) > 3) {
             $where = $sml_where;
         }
     }
     /** start search **/
     $model->start($this->start, $this->limit, $this->orderby, $this->order, $where);
     /** run the search **/
     return $model->query();
 }
예제 #25
0
 /**
  * Validate activation key
  * @author Howard <*****@*****.**>
  * @static
  * @param string $key
  * @return int User ID
  */
 public static function validate_activation_key($key)
 {
     /** first validation **/
     if (!trim($key)) {
         return 0;
     }
     $query = "SELECT `id` FROM `#__users` WHERE `user_activation_key`='{$key}'";
     $id = wpl_db::select($query, 'loadResult');
     if ($id) {
         return $id;
     }
     return 0;
 }
예제 #26
0
 /**
  * For inserting logs using WPL events API
  * @author Howard R <*****@*****.**>
  * @static
  * @param array $params
  * @return int
  */
 public static function autolog($params = array())
 {
     $log = wpl_global::get_setting('log', 1);
     if (!$log) {
         return false;
     }
     $dynamic_params = $params[0];
     $static_params = $params[1];
     $section = isset($static_params['section']) ? $static_params['section'] : 'no-section';
     $addon_id = isset($static_params['addon_id']) ? $static_params['addon_id'] : 0;
     $user_id = isset($static_params['user_id']) ? $static_params['user_id'] : NULL;
     $status = isset($static_params['status']) ? $static_params['status'] : 1;
     $priority = isset($static_params['priority']) ? $static_params['priority'] : 3;
     $patterns = array('[', ']');
     if ($static_params['type'] == 1) {
         preg_match_all('#\\[+[\\w|\\d]+\\]?#', $static_params['message'], $pattern_match);
         $message_pattern = $pattern_match[0];
         if (is_array($dynamic_params)) {
             if (count($dynamic_params) > 1) {
                 /* Modify params that took of preg_match */
                 $new_params = str_replace($patterns, '', $message_pattern);
                 $new_array_params = array();
                 foreach ($new_params as $value_array) {
                     $new_array_params[] = $dynamic_params[$value_array];
                 }
                 $log_text = str_replace($message_pattern, $new_array_params, $static_params['message']);
             } elseif (count($dynamic_params) == 1) {
                 $array_key = array_keys($dynamic_params);
                 $log_text = str_replace($message_pattern[0], $dynamic_params[$array_key[0]], $static_params['message']);
             }
         } else {
             $log_text = str_replace($message_pattern[0], $dynamic_params, $static_params['message']);
         }
     } elseif ($static_params['type'] == 2) {
         preg_match_all('#\\[+[\\w|\\d]+\\]?#', $static_params['pattern'], $pattern_match);
         $value_pattern = $pattern_match[0];
         if (is_array($dynamic_params)) {
             if (count($dynamic_params) > 1) {
                 /* Modify params that took of preg_match */
                 $new_params = str_replace($patterns, '', $value_pattern);
                 $new_array_params = array();
                 foreach ($new_params as $value_array) {
                     $new_array_params[] = $dynamic_params[$value_array];
                 }
                 $query = str_replace($value_pattern, $new_array_params, $static_params['pattern']);
             } elseif (count($dynamic_params) == 1) {
                 $array_values = array_values($dynamic_params);
                 $query = str_replace($value_pattern[0], $array_values[0], $static_params['pattern']);
             }
         } else {
             $query = str_replace($value_pattern[0], $dynamic_params, $static_params['pattern']);
         }
         $contents = wpl_db::select($query, 'loadAssoc');
         $log_text = $static_params['message'];
         if (!empty($contents)) {
             foreach ($contents as $key => $value) {
                 $log_text = str_replace('[' . $key . ']', $value, $log_text);
             }
         }
     }
     if ($log_text == '') {
         $log_text = __('Empty', WPL_TEXTDOMAIN);
     }
     return self::add($log_text, $section, $status, $user_id, $addon_id, $priority);
 }