Esempio n. 1
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) . "\");"));
                 }
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * This method is the main method of each commands
  * @return mixed
  */
 public function build()
 {
     $settings = wpl_addon_mobile_application::get_settings();
     $properties_count = wpl_property::get_properties_count();
     print_r($this->get_listing_types());
     die;
     foreach ($settings as $key => $values) {
         $name = strtoupper($values['name']);
         $value = $values['value'];
         $this->built["settings"]["app_settings"][] = array('name' => $name, 'value' => $value);
         if ($name == 'SHOW_BUBBLE_LIMITATION') {
             if ($properties_count <= $value) {
                 $this->built["settings"]["app_settings"][] = array('name' => 'SHOW_BUBBLE', 'value' => 'true');
             } else {
                 $this->built["settings"]["app_settings"][] = array('name' => 'SHOW_BUBBLE', 'value' => 'false');
             }
         }
     }
     $this->built['filter_fragment'] = $this->create_filter_fragment();
     $this->built["settings"]['listing_types'] = $this->get_listing_types();
     $this->built["settings"]['update_status'] = $this->get_update_status();
 }
Esempio n. 3
0
 /**
  * This function is for importing/updating properties into the WPL. It uses WPL standard format for importing
  * This function must call in everywhere that we need to import properties like MLS and IMPORTER Addons.
  * @author Howard <*****@*****.**>
  * @static
  * @param array $properties_to_import
  * @param string $wpl_unique_field
  * @param int $user_id
  * @param string $source
  * @param boolean $finalize
  * @param array $log_params
  * @return array property IDs
  */
 public static function import($properties_to_import, $wpl_unique_field = 'mls_id', $user_id = '', $source = 'mls', $finalize = true, $log_params = array())
 {
     if (!$user_id) {
         $user_id = wpl_users::get_cur_user_id();
     }
     $pids = array();
     $added = array();
     // Used for logging results
     $updated = array();
     // Used for logging results
     /** model **/
     $model = new wpl_property();
     $possible_columns = wpl_db::columns('wpl_properties');
     foreach ($properties_to_import as $property_to_import) {
         $q = '';
         $unique_value = '';
         foreach ($property_to_import as $key => $row) {
             $wpl_field = $row['wpl_table_column'] ? $row['wpl_table_column'] : $key;
             $wpl_value = $row['wpl_value'] ? $row['wpl_value'] : '';
             /** validation table column **/
             if (!in_array($wpl_field, $possible_columns)) {
                 continue;
             }
             /** set unique value **/
             if ($wpl_field == $wpl_unique_field) {
                 $unique_value = $wpl_value;
             }
             /** set user id value **/
             if ($wpl_field == 'user_id') {
                 $user_id = $wpl_value;
             }
             $q .= "`{$wpl_field}`='" . wpl_db::escape($wpl_value) . "',";
         }
         $exists = $model->get_properties_count(" AND `{$wpl_unique_field}`='{$unique_value}'");
         if (!$exists) {
             $pid = $model->create_property_default($user_id);
         } else {
             $pid = $model->pid($unique_value, $wpl_unique_field);
         }
         /** add property id to return **/
         $pids[] = $pid;
         /** Add source and last sync date **/
         if (in_array('source', $possible_columns) and in_array('last_sync_date', $possible_columns)) {
             $q .= "`source`='{$source}',";
             $q .= "`last_sync_date`='" . date('Y-m-d H:i:s') . "',";
         }
         $q = trim($q, ', ');
         $query = "UPDATE `#__wpl_properties` SET " . $q . " WHERE `id`='" . $pid . "'";
         wpl_db::q($query);
         if ($finalize) {
             $mode = $exists ? 'edit' : 'add';
             $model->finalize($pid, $mode, $user_id);
         }
         if ($exists) {
             $added[] = $unique_value;
         } else {
             $updated[] = $unique_value;
         }
     }
     /** Creating Log **/
     if ($source == 'mls' and wpl_global::check_addon('mls')) {
         _wpl_import('libraries.addon_mls');
         if (method_exists('wpl_addon_mls', 'log')) {
             wpl_addon_mls::log($added, $updated, $log_params);
         }
     }
     return $pids;
 }