function __construct($username, $password, $vars, $settings)
 {
     /** smart set of settings **/
     foreach ($settings as $setting => $setval) {
         if ($setval != '') {
             $this->settings[$setting] = $setval;
         }
     }
     // Authenticating
     if ($username != '') {
         $authenticate = wpl_users::authenticate($username, $password);
         if ($authenticate['status'] != 1) {
             $this->error = "ERROR: Authentication failed!";
             return false;
         }
         $this->uid = $authenticate['uid'];
     } else {
         $this->uid = 0;
     }
     if (!wpl_global::check_access($this->settings['access_view'], $this->uid)) {
         $this->error = "ERROR: No access to the command!";
         return false;
     }
     // Checking essential vars
     if (!isset($vars['pid']) or trim($vars['pid']) == '') {
         $this->error = "ERROR: No property id set!";
         return false;
     }
     $this->pid = $vars['pid'];
 }
 function build()
 {
     if (trim($this->error) == '' and !wpl_global::check_access($this->access, $this->uid)) {
         $this->error = "Access Error";
     }
     if (trim($this->access) == '') {
         $this->error = "Empty Access";
     }
     $this->status = trim($this->error) == '' ? 1 : 0;
     $this->message = trim($this->error) == '' ? 'Valid' : $this->error;
     $this->built = array('response' => array('status' => $this->status, 'message' => $this->message));
     return $this->built;
 }
 function __construct($username, $password, $vars, $settings)
 {
     /** smart set of settings **/
     foreach ($settings as $setting => $setval) {
         if ($setval != '') {
             $this->settings[$setting] = $setval;
         }
     }
     // Authenticating
     if ($username != '') {
         $authenticate = wpl_users::authenticate($username, $password);
         if ($authenticate['status'] != 1) {
             $this->error = "ERROR: Authentication failed!";
             return false;
         }
         $this->uid = $authenticate['uid'];
     } else {
         $this->uid = 0;
     }
     if (!wpl_global::check_access($this->settings['access_view'], $this->uid)) {
         $this->error = "ERROR: No access to the command!";
         return false;
     }
     // Include Thumbnails
     if (trim($vars['ithmb']) != '' and in_array($vars['ithmb'], array('0', '1'))) {
         $this->include_thumbnails = $vars['ithmb'];
     }
     // translate status
     if (trim($vars['dtranslated']) != '' and in_array($vars['dtranslated'], array('0', '1'))) {
         $this->dtranslated = $vars['dtranslated'];
     }
     // Checking essential vars
     if (!isset($vars['pid']) or trim($vars['pid']) == '') {
         $this->error = "ERROR: No property id set!";
         return false;
     }
     $this->pid = $vars['pid'];
     $this->image_sizes = trim($vars['image_sizes']) != '' ? explode('-', $vars['image_sizes']) : '';
 }
Exemple #4
0
 /**
  * Generates wizard form using dbst fields
  * @author Howard R <*****@*****.**>
  * @param objects $fields
  * @param array $values
  * @param int $item_id
  * @param array $finds
  * @return void
  */
 public function generate_wizard_form($fields, $values, $item_id = 0, &$finds = array())
 {
     /** first validation **/
     if (!$fields) {
         return;
     }
     /** get files **/
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'dbst_wizard';
     $files = array();
     if (wpl_folder::exists($path)) {
         $files = wpl_folder::files($path, '.php$', false, false);
     }
     $wpllangs = wpl_global::check_multilingual_status() ? wpl_addon_pro::get_wpl_languages() : array();
     $has_more_details = false;
     foreach ($fields as $key => $field) {
         if (!$field) {
             return;
         }
         $done_this = false;
         $type = $field->type;
         $label = $field->name;
         $mandatory = $field->mandatory;
         $options = json_decode($field->options, true);
         $value = isset($values[$field->table_column]) ? stripslashes($values[$field->table_column]) : NULL;
         $kind = isset($values['kind']) ? $values['kind'] : NULL;
         $display = '';
         /** Specific **/
         if (trim($field->listing_specific) != '') {
             $specified_listings = explode(',', trim($field->listing_specific, ', '));
             self::$category_listing_specific_array[$field->id] = $specified_listings;
             if (!in_array($values['listing'], $specified_listings)) {
                 $display = 'display: none;';
             }
         } elseif (trim($field->property_type_specific) != '') {
             $specified_property_types = explode(',', trim($field->property_type_specific, ', '));
             self::$category_property_type_specific_array[$field->id] = $specified_property_types;
             if (!in_array($values['property_type'], $specified_property_types)) {
                 $display = 'display: none;';
             }
         } elseif (trim($field->user_specific) != '') {
             $specified_user_types = explode(',', trim($field->user_specific, ', '));
             self::$category_user_specific_array[$field->id] = $specified_user_types;
             if (!in_array($values['membership_type'], $specified_user_types)) {
                 $display = 'display: none;';
             }
         } elseif (isset($options['access'])) {
             foreach ($options['access'] as $access) {
                 if (!wpl_global::check_access($access)) {
                     $display = 'display: none;';
                     break;
                 }
             }
         }
         /** More Details **/
         if ($type == 'more_details' and !$has_more_details) {
             echo '<div class="wpl_listing_field_container wpl-pwizard-prow-' . $type . '" id="wpl_listing_field_container' . $field->id . '">';
             echo '<label for="wpl_c_' . $field->id . '"><span>' . __($label, WPL_TEXTDOMAIN) . '</span></label>';
             echo '<div id="wpl_more_details' . $field->id . '" style="display: none;" class="wpl-fields-more-details-block">';
             $has_more_details = true;
         } elseif ($type == 'more_details' and $has_more_details) {
             /** Only one details field is acceptable in each category **/
             continue;
         }
         /** Accesses **/
         if (isset($field->accesses) and trim($field->accesses) != '' and wpl_global::check_addon('membership')) {
             $accesses = explode(',', trim($field->accesses, ', '));
             $cur_membership_id = wpl_users::get_user_membership();
             if (!in_array($cur_membership_id, $accesses) and trim($field->accesses_message) == '') {
                 continue;
             } elseif (!in_array($cur_membership_id, $accesses) and trim($field->accesses_message) != '') {
                 echo '<div class="prow wpl_listing_field_container prow-' . $type . '" id="wpl_listing_field_container' . $field->id . '" style="' . $display . '">';
                 echo '<label for="wpl_c_' . $field->id . '">' . __($label, WPL_TEXTDOMAIN) . '</label>';
                 echo '<span class="wpl-access-blocked-message">' . __($field->accesses_message, WPL_TEXTDOMAIN) . '</span>';
                 echo '</div>';
                 continue;
             }
         }
         /** js validation **/
         self::$wizard_js_validation[$field->id] = self::generate_js_validation($field);
         if (isset($finds[$type])) {
             echo '<div class="prow wpl_listing_field_container prow-' . $type . '" id="wpl_listing_field_container' . $field->id . '" style="' . $display . '">';
             include $path . DS . $finds[$type];
             echo '</div>';
             continue;
         }
         echo '<div class="prow wpl_listing_field_container prow-' . $type . '" id="wpl_listing_field_container' . $field->id . '" style="' . $display . '">';
         foreach ($files as $file) {
             include $path . DS . $file;
             if ($done_this) {
                 $finds[$type] = $file;
                 break;
             }
         }
         echo '</div>';
     }
     if ($has_more_details) {
         echo '</div></div>';
     }
 }
Exemple #5
0
 function __construct($username, $password, $vars, $settings)
 {
     /** smart set of settings **/
     foreach ($settings as $setting => $setval) {
         if ($setval != '') {
             $this->settings[$setting] = $setval;
         }
     }
     // Authenticating
     if ($username != '') {
         $authenticate = wpl_users::authenticate($username, $password);
         if ($authenticate['status'] != 1) {
             $this->error = "ERROR: Authentication failed!";
             return false;
         }
         $this->uid = $authenticate['uid'];
     } else {
         $this->uid = 0;
     }
     if (!wpl_global::check_access($this->settings['access_view'], $this->uid)) {
         $this->error = "ERROR: No access to the command!";
         return false;
     }
     /** global settings **/
     $this->wpl_settings = wpl_settings::get_settings();
     $this->orderby = $this->wpl_settings['default_orderby'];
     $this->order = $this->wpl_settings['default_order'];
     // Include Thumbnails
     if (trim($vars['ithmb']) != '' and in_array($vars['ithmb'], array('0', '1'))) {
         $this->include_thumbnails = $vars['ithmb'];
     }
     // get special keys
     if (trim($vars['get_special_key']) != '' and in_array($vars['get_special_key'], array('0', '1'))) {
         $this->get_special_key = $vars['get_special_key'];
         $this->special_keys = explode('-', $vars['special_keys']);
     }
     // Set result type
     if (trim($vars['result_type']) != '' and in_array($vars['result_type'], array('1', '2', '3'))) {
         $this->result_type = $vars['result_type'];
     }
     // translate status
     if (trim($vars['dtranslated']) != '' and in_array($vars['dtranslated'], array('0', '1'))) {
         $this->dtranslated = $vars['dtranslated'];
     }
     // setting vars
     if (isset($vars['pictures'])) {
         $this->pictures = $vars['pictures'];
     }
     if (isset($vars['attachments'])) {
         $this->attachments = $vars['attachments'];
     }
     if (isset($vars['videos'])) {
         $this->attachments = $vars['videos'];
     }
     if (isset($vars['rooms'])) {
         $this->attachments = $vars['rooms'];
     }
     if (isset($vars['agentinfo'])) {
         $this->agentinfo = $vars['agentinfo'];
     }
     if (isset($vars['sort'])) {
         $this->orderby = $vars['sort'];
     }
     if (isset($vars['asc'])) {
         $this->order = $vars['asc'];
     }
     if (isset($vars['start'])) {
         $this->start = $vars['start'];
     }
     if (isset($vars['limit'])) {
         $this->limit = $vars['limit'];
     }
     if (isset($vars['type'])) {
         $this->type = $vars['type'];
     }
     if (isset($vars['kind'])) {
         $this->kind = $vars['kind'];
     }
     /** customized size of images **/
     $this->image_sizes = trim($vars['image_sizes']) != '' ? explode('-', $vars['image_sizes']) : '';
     // Checking essential vars
     foreach ($vars as $field => $value) {
         if (substr($field, 0, 3) != 'sf_') {
             continue;
         }
         if (strpos($field, 'sf_select_') === false) {
             $field = str_replace('sf_select', 'sf_select_', $field);
         }
         if (strpos($field, 'sf_unit_') === false) {
             $field = str_replace('sf_unit', 'sf_unit_', $field);
         }
         if (strpos($field, 'sf_min_') === false) {
             $field = str_replace('sf_min', 'sf_min_', $field);
         }
         if (strpos($field, 'sf_max_') === false) {
             $field = str_replace('sf_max', 'sf_max_', $field);
         }
         if (strpos($field, 'sf_tmin_') === false) {
             $field = str_replace('sf_tmin', 'sf_tmin_', $field);
         }
         if (strpos($field, 'sf_tmax_') === false) {
             $field = str_replace('sf_tmax', 'sf_tmax_', $field);
         }
         if (strpos($field, 'sf_multiple_') === false) {
             $field = str_replace('sf_multiple', 'sf_multiple_', $field);
         }
         if (strpos($field, 'sf_datemin_') === false) {
             $field = str_replace('sf_datemin', 'sf_datemin_', $field);
         }
         if (strpos($field, 'sf_datemax_') === false) {
             $field = str_replace('sf_datemax', 'sf_datemax_', $field);
         }
         if (strpos($field, 'sf_locationtextsearch_') === false) {
             $field = str_replace('sf_locationtextsearch', 'sf_locationtextsearch_', $field);
         }
         if (strpos($field, 'sf_notselect_') === false) {
             $field = str_replace('sf_notselect', 'sf_notselect_', $field);
         }
         if (strpos($field, 'sf_radiussearchunit_') === false) {
             $field = str_replace('sf_radiussearchunit', 'sf_radiussearchunit_', $field);
         }
         if (strpos($field, 'sf_text_') === false) {
             $field = str_replace('sf_text', 'sf_text_', $field);
         }
         if (strpos($field, 'sf_textsearch_') === false) {
             $field = str_replace('sf_textsearch', 'sf_textsearch_', $field);
         }
         $this->where[$field] = $value;
     }
 }
Exemple #6
0
 /**
  * Finalize a property and render needed data
  * @author Howard <*****@*****.**>
  * @static
  * @param int $property_id
  * @param string $mode
  * @param int $user_id
  * @return boolean
  */
 public static function finalize($property_id, $mode = 'edit', $user_id = '')
 {
     $property = self::get_property_raw_data($property_id);
     $update_query = self::generate_finalize_query($property, $property_id);
     $update_query .= "`finalized`='1',";
     if (wpl_global::check_access('confirm', $user_id)) {
         $update_query .= "`confirmed`='1',";
     }
     $update_query = trim($update_query, ', ');
     $query = "UPDATE `#__wpl_properties` SET " . $update_query . " WHERE `id`='{$property_id}'";
     wpl_db::q($query, 'update');
     /** Remove Property Cache **/
     wpl_property::clear_property_cache($property_id);
     /** 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);
             wpl_property::update_text_search_field($property_id);
             wpl_property::update_alias($property);
             wpl_property::update_property_page_title($property);
             wpl_property::update_property_title($property);
             /** generate rendered data **/
             wpl_property::generate_rendered_data($property_id);
         }
         /** Switch to current language again **/
         wpl_global::switch_language($current_language);
     } else {
         wpl_property::update_text_search_field($property_id);
         wpl_property::update_alias($property);
         wpl_property::update_property_page_title($property);
         wpl_property::update_property_title($property);
         /** generate rendered data **/
         wpl_property::generate_rendered_data($property_id);
     }
     /** Fixes **/
     wpl_property::fix_aliases($property, $property_id);
     wpl_property::update_numbs($property_id, $property);
     /** throwing events **/
     if ($mode == 'add') {
         wpl_events::trigger('add_property', $property_id);
     } elseif ($mode == 'edit') {
         wpl_events::trigger('edit_property', $property_id);
     }
     if (wpl_global::check_access('confirm', $user_id)) {
         wpl_events::trigger('property_confirm', $property_id);
     }
     return true;
 }