1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 03:30:48 +03:00

Наброски поиска пользователей по стране/городу

This commit is contained in:
Mzhelskiy Maxim 2014-11-25 18:45:51 +07:00
parent 940b03af05
commit 99cfb8a811
6 changed files with 61 additions and 8 deletions

View file

@ -276,12 +276,17 @@ class ActionPeople extends Action
* Получаем алфавитный указатель на список пользователей
*/
$aPrefixUser = $this->User_GetGroupPrefixUser(1);
/**
* Список используемых стран
*/
$aCountriesUsed=$this->Geo_GetCountriesUsedByTargetType('user');
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aUsers', $aResult['collection']);
$this->Viewer_Assign('iSearchCount', $aResult['count']);
$this->Viewer_Assign('aPrefixUser', $aPrefixUser);
$this->Viewer_Assign('aCountriesUsed', $aCountriesUsed);
/**
* Устанавливаем шаблон вывода
*/

View file

@ -195,11 +195,11 @@ class ModuleGeo extends Module
* Проверяем есть ли уже связь с данным гео-объектом, если есть то возвращаем его
*/
$aTargetSelf = $this->GetTargets(array(
'target_type' => $sTargetType,
'target_id' => $iTargetId,
'geo_type' => $oGeoObject->getType(),
'geo_id' => $oGeoObject->getId()
), 1, 1);
'target_type' => $sTargetType,
'target_id' => $iTargetId,
'geo_type' => $oGeoObject->getType(),
'geo_id' => $oGeoObject->getId()
), 1, 1);
if (isset($aTargetSelf['collection'][0])) {
return $aTargetSelf['collection'][0];
}
@ -477,6 +477,17 @@ class ModuleGeo extends Module
return $this->oMapper->GetGroupCitiesByTargetType($sTargetType, $iLimit);
}
/**
* Возвращает список использованых стран для типа
*
* @param $sTargetType Тип владельца
* @return array
*/
public function GetCountriesUsedByTargetType($sTargetType)
{
return $this->oMapper->GetCountriesUsedByTargetType($sTargetType);
}
/**
* Проверка объекта с типом "user"
* Название метода формируется автоматически

View file

@ -389,4 +389,29 @@ class ModuleGeo_MapperGeo extends Mapper
}
return $aResult;
}
public function GetCountriesUsedByTargetType($sTargetType)
{
$sql = "
SELECT
c.*
FROM (
SELECT
DISTINCT country_id
FROM
" . Config::Get('db.table.geo_target') . "
WHERE target_type = ? and country_id IS NOT NULL
) as t
JOIN " . Config::Get('db.table.geo_country') . " as c on t.country_id=c.id
ORDER BY c.name_ru
";
$aResult = array();
if ($aRows = $this->oDb->select($sql, $sTargetType)) {
foreach ($aRows as $aRow) {
$aResult[] = Engine::GetEntity('ModuleGeo_EntityCountry', $aRow);
}
}
return $aResult;
}
}

View file

@ -251,7 +251,12 @@ jQuery(document).ready(function($){
type: 'sort',
name: 'sort_by',
selector: '.js-search-sort-menu li'
}
},
{
type: 'select',
name: 'country',
selector: '.js-search-ajax-user-country'
}
]
});

View file

@ -23,7 +23,7 @@
// Селекторы
selectors: {
more: '.js-more-search',
more: '.js-more-search'
},
// Фильтры

View file

@ -24,10 +24,17 @@
{* Пол *}
<p class="mb-10">Пол</p>
<div class="field-checkbox-group">
{include 'components/field/field.radio.tpl' inputClasses='js-search-ajax-user-sex' name='sex' value='' checked=true label='Любой'}
{include 'components/field/field.radio.tpl' inputClasses='js-search-ajax-user-sex' name='sex' value='man' label='Мужской'}
{include 'components/field/field.radio.tpl' inputClasses='js-search-ajax-user-sex' name='sex' value='woman' label='Женский'}
</div>
{* Страна/город *}
{include 'components/field/field.geo.tpl'
aGeoCountries = $aCountriesUsed
inputClasses = 'js-search-ajax-user-country'
name = 'geo'
inline = true
label = {lang name='user.settings.profile.fields.place.label'} }
{/block}