Example #1
0
 /**
  * Use this function for creating query
  * @author Howard <*****@*****.**>
  * @param array $vars
  * @param string $needle_str
  * @return string $query
  */
 public static function create_query($vars = '', $needle_str = 'sf_')
 {
     if (!$vars) {
         $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     }
     /** clean vars **/
     $vars = wpl_global::clean($vars);
     $query = '';
     /** this is to include any customized and special form fields conditions **/
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'create_query';
     $path_exists = wpl_folder::exists($path);
     $find_files = array();
     if ($path_exists) {
         $files = wpl_folder::files($path, '.php$');
     }
     foreach ($vars as $key => $value) {
         /** escape value **/
         $value = wpl_db::escape($value);
         if (strpos($key, $needle_str) === false) {
             continue;
         }
         $ex = explode('_', $key);
         $format = $ex[1];
         $table_column = str_replace($needle_str . $format . '_', '', $key);
         $done_this = false;
         /** using detected files **/
         if (isset($find_files[$format])) {
             include $path . DS . $find_files[$format];
             continue;
         }
         foreach ($files as $file) {
             include $path . DS . $file;
             if ($done_this) {
                 /** add to detected files **/
                 $find_files[$format] = $file;
                 break;
             }
         }
     }
     return $query = trim($query, ' ,');
 }
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
 /**
  * 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;
 }
?>
</span>
            <span class="wpl-requirement-current"><?php 
echo $wpl_writable ? __('Yes', WPL_TEXTDOMAIN) : __('No', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-status p-action-btn">
            	<i class="icon-<?php 
echo $wpl_writable ? 'confirm' : 'danger';
?>
"></i>
            </span>
		</li>
        <!-- WPL temporary directory permission -->
        <?php 
$wpl_tmp_writable = wpl_folder::exists(wpl_global::init_tmp_folder()) ? true : false;
?>
        <li>
        	<span class="wpl-requirement-name"><?php 
echo __('tmp directory', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-require"><?php 
echo __('Writable', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-current"><?php 
echo $wpl_tmp_writable ? __('Yes', WPL_TEXTDOMAIN) : __('No', WPL_TEXTDOMAIN);
?>
</span>
            <span class="wpl-requirement-status p-action-btn">
Example #5
0
 /**
  * Generate search fields based on DBST fields
  * @author Steve A. <*****@*****.**>
  * @param  array  $fields
  * @param  array  $finds
  * @return array
  */
 public function generate_search_fields($fields, $finds = array())
 {
     $fields = json_decode(json_encode($fields), true);
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'widget_search' . DS . 'frontend';
     $files = array();
     $widget_id = '';
     if (wpl_folder::exists($path)) {
         $files = wpl_folder::files($path, '.php$');
     }
     $rendered = array();
     foreach ($fields as $key => $field) {
         $type = $field['type'];
         $field_id = $field['id'];
         $field_data = $field;
         $options = json_decode($field['options'], true);
         $done_this = false;
         $html = '';
         if (isset($finds[$type])) {
             $html .= '<span class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '">';
             include $path . DS . $finds[$type];
             $html .= '</span> ';
             $rendered[$field_id]['id'] = $field_id;
             $rendered[$field_id]['field_options'] = json_decode($field['options'], true);
             $rendered[$field_id]['html'] = $html;
             $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL;
             continue;
         }
         $html .= '<span class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '">';
         foreach ($files as $file) {
             include $path . DS . $file;
             /** proceed to next field **/
             if ($done_this) {
                 $finds[$type] = $file;
                 break;
             }
         }
         $html .= '</span> ';
         $rendered[$field_id]['id'] = $field_id;
         $rendered[$field_id]['field_options'] = json_decode($field['options'], true);
         $rendered[$field_id]['html'] = $html;
         $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL;
     }
     return $rendered;
 }
Example #6
0
/** no direct access **/
defined('_WPLEXEC') or die('Restricted access');
if ($type == 'locations' and !$done_this) {
    /** import library **/
    _wpl_import('libraries.locations');
    $location_settings = wpl_global::get_settings('3');
    # location settings
    switch ($field['type']) {
        case 'simple':
            if ($location_settings['location_method'] == 2) {
                $show = 'simple_location_database';
            } else {
                $show = 'simple_location_text';
            }
            break;
        default:
            $show = $field['type'];
            break;
    }
    /** Place-holder **/
    $placeholder = (isset($field['extoption']) and trim($field['extoption'])) ? $field['extoption'] : $location_settings['locationzips_keyword'] . ', ' . $location_settings['location3_keyword'] . ', ' . $location_settings['location1_keyword'];
    $location_path = WPL_ABSPATH . DS . 'libraries' . DS . 'widget_search' . DS . 'frontend' . DS . 'location_items';
    $location_files = array();
    if (wpl_folder::exists($location_path)) {
        $location_files = wpl_folder::files($location_path, '.php$');
    }
    foreach ($location_files as $location_file) {
        include $location_path . DS . $location_file;
    }
}
Example #7
0
 /**
  * This functions will take care of multisite usage
  * @author Howard <*****@*****.**>
  * @param type $blog_id
  * @return string WPL base url for uploaded files
  */
 public static function get_upload_base_url($blog_id = NULL)
 {
     if (!$blog_id) {
         $blog_id = wpl_global::get_current_blog_id();
     }
     $ABSPATH = WPL_UP_ABSPATH;
     if (!$blog_id or $blog_id == 1) {
         return wpl_global::get_wp_site_url() . 'wp-content/uploads/WPL/';
     } else {
         $path = rtrim($ABSPATH, DS) . $blog_id . DS;
         if (!wpl_folder::exists($path)) {
             wpl_folder::create($path);
         }
         return wpl_global::get_wp_site_url() . 'wp-content/uploads/WPL' . $blog_id . '/';
     }
 }
Example #8
0
 public function render_search_fields($instance, $widget_id, $finds = array())
 {
     /** first validation **/
     if (!$instance) {
         return array();
     }
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'widget_search' . DS . 'frontend';
     $files = array();
     if (wpl_folder::exists($path)) {
         $files = wpl_folder::files($path, '.php$');
     }
     $fields = $instance['data'];
     uasort($fields, array('wpl_global', 'wpl_array_sort'));
     $rendered = array();
     foreach ($fields as $key => $field) {
         /** proceed to next field if field is not enabled **/
         if (!isset($field['enable']) or isset($field['enable']) and $field['enable'] != 'enable') {
             continue;
         }
         /** Fix empty id issue **/
         if ((!isset($field['id']) or isset($field['id']) and !$field['id']) and $key) {
             $field['id'] = $key;
         }
         $field_data = (array) wpl_flex::get_field($field['id']);
         if (!$field_data) {
             continue;
         }
         $field['name'] = $field_data['name'];
         $type = $field_data['type'];
         $field_id = $field['id'];
         $options = json_decode($field_data['options'], true);
         $display = '';
         $done_this = false;
         $html = '';
         /** listing and property type specific **/
         if (trim($field_data['listing_specific']) != '') {
             $specified_listings = explode(',', trim($field_data['listing_specific'], ', '));
             $this->listing_specific_array[$field_data['id']] = $specified_listings;
         } elseif (trim($field_data['property_type_specific']) != '') {
             $specified_property_types = explode(',', trim($field_data['property_type_specific'], ', '));
             $this->property_type_specific_array[$field_data['id']] = $specified_property_types;
         }
         /** Accesses **/
         if (trim($field_data['accesses']) != '') {
             $accesses = explode(',', trim($field_data['accesses'], ', '));
             $cur_membership_id = wpl_users::get_user_membership();
             if (!in_array($cur_membership_id, $accesses)) {
                 continue;
             }
         }
         if (isset($finds[$type])) {
             $html .= '<div class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '">';
             include $path . DS . $finds[$type];
             $html .= '</div>';
             $rendered[$field_id]['id'] = $field_id;
             $rendered[$field_id]['field_data'] = $field_data;
             $rendered[$field_id]['field_options'] = json_decode($field_data['options'], true);
             $rendered[$field_id]['search_options'] = isset($field['extoption']) ? $field['extoption'] : NULL;
             $rendered[$field_id]['html'] = $html;
             $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL;
             $rendered[$field_id]['display'] = $display;
             continue;
         }
         $html .= '<div class="wpl_search_field_container ' . (isset($field['type']) ? $field['type'] . '_type' : '') . ' ' . ((isset($field['type']) and $field['type'] == 'predefined') ? 'wpl_hidden' : '') . '" id="wpl' . $widget_id . '_search_field_container_' . $field['id'] . '" style="' . $display . '">';
         foreach ($files as $file) {
             include $path . DS . $file;
             /** proceed to next field **/
             if ($done_this) {
                 $finds[$type] = $file;
                 break;
             }
         }
         $html .= '</div>';
         $rendered[$field_id]['id'] = $field_id;
         $rendered[$field_id]['field_data'] = $field_data;
         $rendered[$field_id]['field_options'] = json_decode($field_data['options'], true);
         $rendered[$field_id]['search_options'] = isset($field['extoption']) ? $field['extoption'] : NULL;
         $rendered[$field_id]['html'] = $html;
         $rendered[$field_id]['current_value'] = isset($current_value) ? $current_value : NULL;
         $rendered[$field_id]['display'] = $display;
     }
     return $rendered;
 }
Example #9
0
 /**
  * Returns item directory path. If it's not exist it creates the directory 
  * @author Howard R <*****@*****.**>
  * @static
  * @param int $parent_id
  * @param int $kind
  * @return string
  */
 public static function get_path($parent_id, $kind = 0)
 {
     if ($kind == 2) {
         $path = wpl_global::get_upload_base_path() . 'users' . DS . $parent_id . DS;
     } else {
         $path = wpl_global::get_upload_base_path() . $parent_id . DS;
     }
     if (!wpl_folder::exists($path)) {
         wpl_folder::create($path);
     }
     return $path;
 }
Example #10
0
 /**
  * Generates select cluase of search query
  * @author Howard R <*****@*****.**>
  * @param array of objects $fields
  * @param string $table_name
  * @return string
  */
 public function generate_select($fields, $table_name = 'p')
 {
     /** first validation **/
     if (!$fields) {
         return;
     }
     /** get files **/
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'query_select';
     $files = array();
     $query = '';
     $defaults = array('id', 'kind', 'property_rank', 'pic_numb', 'att_numb', 'confirmed', 'finalized', 'deleted', 'user_id', 'add_date', 'visit_time', 'visit_date', 'sent_numb', 'contact_numb', 'zip_name', 'zip_id');
     foreach ($defaults as $default) {
         $query .= $table_name . ".`" . $default . "`, ";
     }
     if (wpl_folder::exists($path)) {
         $files = wpl_folder::files($path, '.php$');
     }
     foreach ($fields as $key => $field) {
         if (!$field) {
             continue;
         }
         if (trim($field->table_name) == '' or trim($field->table_column) == '') {
             continue;
         }
         $done_this = false;
         $type = $field->type;
         foreach ($files as $file) {
             include $path . DS . $file;
             /** break and go to next field **/
             if ($done_this) {
                 break;
             }
         }
         if (!$done_this) {
             $query .= $table_name . ".`{$field->table_column}`, ";
         }
     }
     return trim($query, ', ');
 }
Example #11
0
 /**
  * Generate setting field
  * @author Howard <*****@*****.**>
  * @static
  * @param array $setting_record
  * @return void
  */
 public static function generate_setting_form($setting_record)
 {
     /** first validation **/
     if (!$setting_record) {
         return;
     }
     $done_this = false;
     $type = $setting_record->type;
     $value = $setting_record->setting_value;
     $params = json_decode($setting_record->params, true);
     $options = json_decode($setting_record->options, true);
     $setting_title = trim($setting_record->title) != '' ? __($setting_record->title, WPL_TEXTDOMAIN) : __(str_replace('_', ' ', $setting_record->setting_name), WPL_TEXTDOMAIN);
     /** get files **/
     $path = WPL_ABSPATH . DS . 'libraries' . DS . 'settings_form';
     $files = array();
     if (wpl_folder::exists($path)) {
         $files = wpl_folder::files($path, '.php$');
         foreach ($files as $file) {
             include $path . DS . $file;
         }
     }
 }