Example #1
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 #2
0
 /**
  * Finalize User Profile
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $user_id
  * @return boolean
  */
 public static function finalize($user_id)
 {
     /** create folder **/
     $folder_path = wpl_items::get_path($user_id, 2);
     if (!wpl_folder::exists($folder_path)) {
         wpl_folder::create($folder_path);
     }
     /** Multilingual **/
     if (wpl_global::check_multilingual_status()) {
         $languages = wpl_addon_pro::get_wpl_languages();
         $current_language = wpl_global::get_current_language();
         foreach ($languages as $language) {
             wpl_global::switch_language($language);
             /** Generate Rendered Data **/
             wpl_users::generate_rendered_data($user_id);
             wpl_users::update_text_search_field($user_id);
         }
         /** Switch to current language again **/
         wpl_global::switch_language($current_language);
     } else {
         /** Generate Rendered Data **/
         wpl_users::generate_rendered_data($user_id);
         wpl_users::update_text_search_field($user_id);
     }
     /** Generate Email Files **/
     wpl_users::generate_email_files($user_id);
     /** throwing event **/
     wpl_events::trigger('user_finalized', $user_id);
     return true;
 }
Example #3
0
 /**
  * Triggers an event
  * @author Howard <*****@*****.**>
  * @static
  * @param string $trigger
  * @param array $params
  */
 public static function event_handler($trigger, $params = array())
 {
     /** import library **/
     _wpl_import('libraries.events');
     /** trigger event **/
     wpl_events::trigger($trigger, $params);
 }
Example #4
0
 public function display($instance = array())
 {
     /** do cronjobs **/
     _wpl_import('libraries.events');
     wpl_events::do_cronjobs();
     /** check access **/
     if (!wpl_users::check_access('propertyshow')) {
         /** 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');
     /** property listing model **/
     $this->model = new wpl_property();
     $this->pid = wpl_request::getVar('pid', 0);
     $listing_id = wpl_request::getVar('mls_id', 0);
     if (trim($listing_id)) {
         $this->pid = wpl_property::pid($listing_id);
         wpl_request::setVar('pid', $this->pid);
     }
     $property = $this->model->get_property_raw_data($this->pid);
     /** no property found **/
     if (!$property or $property['finalized'] == 0 or $property['confirmed'] == 0 or $property['deleted'] == 1 or $property['expired'] >= 1) {
         /** import message tpl **/
         $this->message = __("No property found or it's not available now!", WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message', false, true);
     }
     $this->pshow_fields = $this->model->get_pshow_fields('', $property['kind']);
     $this->pshow_categories = wpl_flex::get_categories('', '', " AND `enabled`>='1' AND `kind`='" . $property['kind'] . "' AND `pshow`='1'");
     $wpl_properties = array();
     /** define current index **/
     $wpl_properties['current']['data'] = (array) $property;
     $wpl_properties['current']['raw'] = (array) $property;
     $find_files = array();
     $rendered_fields = $this->model->render_property($property, $this->pshow_fields, $find_files, true);
     $wpl_properties['current']['rendered_raw'] = $rendered_fields['ids'];
     $wpl_properties['current']['materials'] = $rendered_fields['columns'];
     foreach ($this->pshow_categories as $pshow_category) {
         $pshow_cat_fields = $this->model->get_pshow_fields($pshow_category->id, $property['kind']);
         $wpl_properties['current']['rendered'][$pshow_category->id]['self'] = (array) $pshow_category;
         $wpl_properties['current']['rendered'][$pshow_category->id]['data'] = $this->model->render_property($property, $pshow_cat_fields);
     }
     $wpl_properties['current']['items'] = wpl_items::get_items($this->pid, '', $property['kind'], '', 1);
     /** property location text **/
     $wpl_properties['current']['location_text'] = $this->model->generate_location_text((array) $property);
     /** property full link **/
     $wpl_properties['current']['property_link'] = $this->model->get_property_link((array) $property);
     /** property page title **/
     $wpl_properties['current']['property_page_title'] = $this->model->update_property_page_title($property);
     /** property title **/
     $wpl_properties['current']['property_title'] = $this->model->update_property_title($property);
     /** 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->wpl_properties = $wpl_properties;
     $this->kind = $property['kind'];
     $this->property = $wpl_properties['current'];
     /** updating the visited times and etc **/
     wpl_property::property_visited($this->pid);
     /** trigger event **/
     wpl_global::event_handler('property_show', array('id' => $this->pid));
     /** 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 #5
0
 /**
  * Unfinalize a property
  * @author Howard <*****@*****.**>
  * @static
  * @param int $property_id
  * @return boolean
  */
 public static function unfinalize($property_id)
 {
     $query = "UPDATE `#__wpl_properties` SET `finalized`='0' WHERE `id`='{$property_id}'";
     wpl_db::q($query, 'update');
     /** throwing events **/
     wpl_events::trigger('property_unfinalized', $property_id);
     return true;
 }
Example #6
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);
         }
     }
     /** WPL Import Event **/
     wpl_events::trigger('wpl_import', array('properties' => $properties_to_import, 'wpl_unique_field' => $wpl_unique_field, 'user_id' => $user_id, 'source' => $source, 'added' => $added, 'updated' => $updated, 'log_params' => $log_params, 'pids' => $pids));
     return $pids;
 }