Exemplo n.º 1
0
 public static function getUserProfileFieldInfoBySID($user_profile_field_sid)
 {
     $field_info = parent::getObjectInfo("user_profile_fields", $user_profile_field_sid);
     if (in_array($field_info['type'], array('list', 'multilist'))) {
         if (!empty($field_info['parent_sid'])) {
             if ($field_info['id'] == 'Country') {
                 $displayAS = !empty($field_info['display_as']) ? $field_info['display_as'] : 'country_name';
                 $field_info['list_values'] = SJB_CountriesManager::getAllCountriesCodesAndNames(true, $displayAS);
             }
         } else {
             $field_info['list_values'] = SJB_UserProfileFieldDBManager::getListValuesBySID($user_profile_field_sid);
         }
     } elseif ($field_info['type'] == 'tree') {
         $field_info['tree_values'] = SJB_UserProfileFieldTreeManager::getTreeValuesBySID($user_profile_field_sid);
         $field_info['tree_depth'] = SJB_UserProfileFieldTreeManager::getTreeDepthBySID($user_profile_field_sid);
     } elseif ($field_info['type'] == 'monetary') {
         $field_info['currency_values'] = SJB_CurrencyManager::getActiveCurrencyList();
     } elseif ($field_info['type'] == 'location') {
         $field_info['fields'] = SJB_UserProfileFieldManager::getUserProfileFieldsInfoByParentSID($user_profile_field_sid);
     }
     return $field_info;
 }
Exemplo n.º 2
0
 public static function setComplexFields(&$listing_field_info)
 {
     switch ($listing_field_info['type']) {
         case 'list':
         case 'multilist':
             if (!empty($listing_field_info['parent_sid'])) {
                 if ($listing_field_info['id'] == 'Country') {
                     $displayAS = !empty($listing_field_info['display_as']) ? $listing_field_info['display_as'] : 'country_name';
                     $listing_field_info['list_values'] = SJB_CountriesManager::getAllCountriesCodesAndNames(true, $displayAS);
                 }
             } else {
                 $listing_field_info['list_values'] = SJB_ListingFieldDBManager::getListValuesBySID($listing_field_info['sid']);
             }
             break;
         case 'tree':
             $listing_field_info['tree_values'] = SJB_ListingFieldDBManager::getTreeValuesBySID($listing_field_info['sid']);
             $listing_field_info['tree_depth'] = SJB_ListingFieldDBManager::getTreeDepthBySID($listing_field_info['sid']);
             break;
         case 'monetary':
             $listing_field_info['currency_values'] = SJB_CurrencyManager::getActiveCurrencyList();
             break;
         case 'complex':
             $listing_field_info['fields'] = SJB_ListingFieldDBManager::getListingFieldsInfoByParentSID($listing_field_info['sid']);
             $listing_field_info['table_name'] = 'listings';
             break;
         case 'location':
             $listing_field_info['fields'] = SJB_ListingFieldManager::getListingFieldsInfoByParentSID($listing_field_info['sid']);
             break;
         case 'geo':
             if (isset($listing_field_info['parent_sid'])) {
                 $parentID = SJB_DB::queryValue("SELECT `id` FROM `listing_fields` WHERE `sid` = ?n", $listing_field_info['parent_sid']);
                 $listing_field_info['parentID'] = $parentID;
             }
             break;
     }
     $listing_field_info['is_classifieds'] = 1;
 }
Exemplo n.º 3
0
 function getSystemSQL($table = '')
 {
     if (!$this->isValid()) {
         return null;
     }
     $value = $this->value;
     $currency = $this->value['currency'];
     $id = SJB_DB::quote($this->property_name);
     $search = array('%', '_');
     $replace = array('\\%', '\\_');
     if ($currency) {
         $course = SJB_CurrencyManager::getCurrencyByCurrCode($currency);
     }
     $course = isset($course['course']) ? $course['course'] : 1;
     if (!empty($value['not_less']) && !is_numeric($value['not_less'])) {
         $value['not_less'] = SJB_DB::quote($value['not_less']);
         $value['not_less'] = str_replace($search, $replace, $value['not_less']);
         return "(`{$id}` LIKE '%{$value['not_less']}%')";
     }
     if (!empty($value['not_more']) && !is_numeric($value['not_more'])) {
         $value['not_more'] = SJB_DB::quote($value['not_more']);
         $value['not_more'] = str_replace($search, $replace, $value['not_more']);
         return "(`{$id}` LIKE '%{$value['not_more']}%')";
     }
     $notLess = intval($value['not_less'] / $course);
     $notMore = intval($value['not_more'] / $course);
     $allCurrency = SJB_CurrencyManager::getActiveCurrencyList();
     $where = '';
     if (count($allCurrency) > 0) {
         $where = '(';
         foreach ($allCurrency as $currency) {
             if ($this->value['currency']) {
                 $notLessVal = $notLess * $currency['course'];
                 $notMoreVal = $notMore * $currency['course'];
                 $addCurrency = "AND `{$id}_parameter`={$currency['sid']}";
             } else {
                 $notLessVal = $notLess;
                 $notMoreVal = $notMore;
                 $addCurrency = '';
             }
             if ($notLessVal > 0 && $notMoreVal > 0) {
                 $where .= "((`{$id}` BETWEEN {$notLessVal} AND {$notMoreVal}) {$addCurrency}) OR ";
             } elseif ($notLessVal > 0) {
                 $where .= "(`{$id}` >= {$notLessVal} {$addCurrency}) OR ";
             } elseif ($notMoreVal > 0) {
                 $where .= "(`{$id}` BETWEEN 1 AND {$notMoreVal} {$addCurrency}) OR ";
             } else {
                 $where .= "(`{$id}` >= '0') OR ";
             }
         }
         $where = substr($where, 0, -4);
         $where .= ')';
     }
     return "{$where}";
 }