Exemplo n.º 1
0
 /**
  * written by Francis
  * description: initialize pagination and properties for property manager page
  */
 private function init_page()
 {
     /** global settings **/
     $settings = wpl_settings::get_settings();
     /** listing settings **/
     $this->page_number = wpl_request::getVar('wplpage', 1);
     $limit = wpl_request::getVar('limit', $settings['default_page_size']);
     $start = wpl_request::getVar('start', ($this->page_number - 1) * $limit);
     $orderby = wpl_request::getVar('orderby', $settings['default_orderby']);
     $order = wpl_request::getVar('order', $settings['default_order']);
     $current_user_id = wpl_users::get_cur_user_id();
     $where = array();
     /** set page if start var passed **/
     $this->page_number = $start / $limit + 1;
     wpl_request::setVar('wplpage', $this->page_number);
     $this->model = new wpl_property();
     /** load user properties **/
     if (!wpl_users::is_administrator($current_user_id)) {
         $where['sf_select_user_id'] = $current_user_id;
     }
     /** detect kind **/
     $this->kind = wpl_request::getVar('kind', 0);
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         /** import message tpl **/
         $this->message = __('Invalid Request!', WPL_TEXTDOMAIN);
         parent::render($this->tpl_path, 'message');
         return false;
     }
     $this->kind_label = wpl_flex::get_kind_label($this->kind);
     $where['sf_select_kind'] = $this->kind;
     /** Add search conditions to the where **/
     $vars = array_merge(wpl_request::get('POST'), wpl_request::get('GET'));
     $where = array_merge($vars, $where);
     $this->model->start($start, $limit, $orderby, $order, $where, $this->kind);
     $query = $this->model->query();
     $properties = $this->model->search($query);
     $this->model->finish();
     /** get the number of all properties according to our query **/
     $properties_count = $this->model->get_properties_count();
     /** set pagination according to the number of items and limit **/
     $this->pagination = wpl_pagination::get_pagination($properties_count, $limit);
     $plisting_fields = $this->model->get_plisting_fields();
     $wpl_properties = array();
     foreach ($properties as $property) {
         $wpl_properties[$property->id] = $this->model->full_render($property->id, $plisting_fields, $property);
     }
     $this->wpl_properties = $wpl_properties;
     return true;
 }
Exemplo n.º 2
0
 public function home()
 {
     /** check permission **/
     wpl_global::min_access('administrator');
     $this->kind = trim(wpl_request::getVar('kind')) != '' ? wpl_request::getVar('kind') : 0;
     if (!in_array($this->kind, wpl_flex::get_valid_kinds())) {
         $this->message = __('Invalid Kind!', WPL_TEXTDOMAIN);
         /** import tpl **/
         return parent::render($this->tpl_path, 'message');
     }
     $this->field_categories = wpl_flex::get_categories(0, $this->kind);
     $this->kind_label = wpl_flex::get_kind_label($this->kind);
     $this->dbst_types = wpl_flex::get_dbst_types(1, $this->kind);
     $this->new_dbst_id = wpl_flex::get_new_dbst_id();
     /** import tpl **/
     parent::render($this->tpl_path, $this->tpl);
 }
Exemplo n.º 3
0
 public function wizard($instance = array())
 {
     /** load assets **/
     $this->load_assets();
     /** check access **/
     if (!wpl_users::check_access('propertywizard')) {
         /** import message tpl **/
         $this->message = __("You don't have access to this part!", WPL_TEXTDOMAIN);
         return parent::render($this->tpl_path, 'message');
     }
     $this->kind = trim(wpl_request::getVar('kind')) != '' ? wpl_request::getVar('kind') : 0;
     $this->property_id = trim(wpl_request::getVar('pid')) != '' ? wpl_request::getVar('pid') : 0;
     $this->mode = $this->property_id ? 'edit' : 'add';
     if ($this->mode == 'add') {
         /** checking access **/
         if (!wpl_users::check_access($this->mode)) {
             $this->message = __("Limit reached. You can not add more property!", WPL_TEXTDOMAIN);
             return parent::render($this->tpl_path, 'message');
         }
         /** generate new property **/
         $this->property_id = wpl_property::create_property_default('', $this->kind);
     }
     $this->values = wpl_property::get_property_raw_data($this->property_id);
     $this->finalized = isset($this->values['finalized']) ? $this->values['finalized'] : 0;
     $this->kind = isset($this->values['kind']) ? $this->values['kind'] : 0;
     $this->field_categories = wpl_flex::get_categories(0, $this->kind);
     $this->kind_label = wpl_flex::get_kind_label($this->kind);
     if ($this->mode == 'edit') {
         if (!$this->values) {
             $this->message = __("Property does not exist!", WPL_TEXTDOMAIN);
             return parent::render($this->tpl_path, 'message');
         }
         /** checking access **/
         if (!wpl_users::check_access($this->mode, $this->values['user_id'])) {
             $this->message = __("You can not edit this property.", WPL_TEXTDOMAIN);
             return parent::render($this->tpl_path, 'message');
         }
     }
     /** import tpl **/
     $this->tpl = wpl_flex::get_kind_tpl($this->tpl_path, 'wizard', $this->kind);
     parent::render($this->tpl_path, $this->tpl);
 }
Exemplo n.º 4
0
 /**
  * Updates property title
  * @author Howard <*****@*****.**>
  * @static
  * @param array $property_data
  * @param int $property_id
  * @param boolean $force
  * @return string
  */
 public static function update_property_title($property_data, $property_id = 0, $force = false)
 {
     /** fetch property data if property id is setted **/
     if ($property_id) {
         $property_data = self::get_property_raw_data($property_id);
     }
     if (!$property_id) {
         $property_id = $property_data['id'];
     }
     $column = 'field_313';
     $field_id = wpl_flex::get_dbst_id($column, $property_data['kind']);
     $field = wpl_flex::get_field($field_id);
     $base_column = NULL;
     if (isset($field->multilingual) and $field->multilingual and wpl_global::check_multilingual_status()) {
         $base_column = wpl_global::get_current_language() == wpl_addon_pro::get_default_language() ? $column : NULL;
         $column = wpl_addon_pro::get_column_lang_name($column, wpl_global::get_current_language(), false);
     }
     /** return current title if exists **/
     if (isset($property_data[$column]) and trim($property_data[$column]) != '' and !$force) {
         return $property_data[$column];
     }
     /** first validation **/
     if (!$property_data) {
         return '';
     }
     $listing_data = wpl_global::get_listings($property_data['listing']);
     $listing = isset($listing_data->name) ? $listing_data->name : '';
     $property_type_data = wpl_global::get_property_types($property_data['property_type']);
     $property_type = isset($property_type_data->name) ? $property_type_data->name : '';
     $title = array();
     $title['property_type'] = __($property_type, WPL_TEXTDOMAIN);
     $title['listing'] = __($listing, WPL_TEXTDOMAIN);
     if ($property_data['kind']) {
         $kind_label = wpl_flex::get_kind_label($property_data['kind']);
         if (trim($kind_label)) {
             $title['kind'] = '(' . __($kind_label, WPL_TEXTDOMAIN) . ')';
         }
     }
     $title_str = implode(' ', $title);
     /** apply filters **/
     _wpl_import('libraries.filters');
     @extract(wpl_filters::apply('generate_property_title', array('title' => $title, 'title_str' => $title_str)));
     /** update **/
     if (wpl_db::columns('wpl_properties', $column)) {
         $query = "UPDATE `#__wpl_properties` SET `" . $column . "`='" . $title_str . "' WHERE `id`='" . $property_id . "'";
         wpl_db::q($query, 'update');
     }
     /** update **/
     if ($base_column and wpl_db::columns('wpl_properties', $base_column)) {
         $query = "UPDATE `#__wpl_properties` SET `" . $base_column . "`='" . $title_str . "' WHERE `id`='" . $property_id . "'";
         wpl_db::q($query, 'update');
     }
     return $title_str;
 }