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 2012-03-19 14:02:07 +04:00
parent 5a32653249
commit 546142be7c
14 changed files with 168 additions and 184 deletions

View file

@ -42,10 +42,12 @@ class ActionProfile extends Action {
$this->AddEvent('ajax-note-remove', 'EventAjaxNoteRemove');
$this->AddEventPreg('/^.+$/i','/^(whois)?$/i','EventWhois');
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^$/i','EventWall');
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^add$/i','EventWallAdd');
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^load$/i','EventWallLoad');
$this->AddEventPreg('/^.+$/i','/^wall$/i','/^load-reply$/i','EventWallLoadReply');
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^comments$/i','/^(page(\d+))?$/i','EventFavouriteComments');
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^(page(\d+))?$/i','EventFavourite');
$this->AddEventPreg('/^.+$/i','/^favourites$/i','/^topics/i','/^(page(\d+))?$/i','EventFavourite');
@ -54,6 +56,8 @@ class ActionProfile extends Action {
$this->AddEventPreg('/^.+$/i','/^created/i','/^(page(\d+))?$/i','EventCreatedTopics');
$this->AddEventPreg('/^.+$/i','/^created/i','/^topics/i','/^(page(\d+))?$/i','EventCreatedTopics');
$this->AddEventPreg('/^.+$/i','/^created/i','/^comments$/i','/^(page(\d+))?$/i','EventCreatedComments');
$this->AddEventPreg('/^.+$/i','/^friends/i','/^(page(\d+))?$/i','EventFriends');
}
/**********************************************************************************
@ -72,6 +76,37 @@ class ActionProfile extends Action {
}
return true;
}
/**
* Список друзей пользователей
*/
protected function EventFriends() {
if (!$this->CheckUserProfile()) {
return parent::EventNotFound();
}
/**
* Передан ли номер страницы
*/
$iPage=$this->GetParamEventMatch(1,2) ? $this->GetParamEventMatch(1,2) : 1;
/**
* Получаем список комментов
*/
$aResult=$this->User_GetUsersFriend($this->oUserProfile->getId(),$iPage,Config::Get('module.user.per_page'));
$aFriends=$aResult['collection'];
/**
* Формируем постраничность
*/
$aPaging=$this->Viewer_MakePaging($aResult['count'],$iPage,Config::Get('module.user.per_page'),4,$this->oUserProfile->getUserWebPath().'friends');
/**
* Загружаем переменные в шаблон
*/
$this->Viewer_Assign('aPaging',$aPaging);
$this->Viewer_Assign('aFriends',$aFriends);
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_friends').' '.$this->oUserProfile->getLogin());
$this->SetTemplateAction('friends');
}
/**
* Список топиков пользователя
*/
@ -222,7 +257,7 @@ class ActionProfile extends Action {
/**
* Получаем список друзей
*/
$aUsersFriend=$this->User_GetUsersFriend($this->oUserProfile->getId());
$aUsersFriend=$this->User_GetUsersFriend($this->oUserProfile->getId(),1,Config::Get('module.user.friend_on_profile'));
if (Config::Get('general.reg.invite')) {
/**
@ -261,7 +296,7 @@ class ActionProfile extends Action {
$this->Viewer_Assign('aBlogModerators',$aBlogModerators);
$this->Viewer_Assign('aBlogAdministrators',$aBlogAdministrators);
$this->Viewer_Assign('aBlogsOwner',$aBlogsOwner);
$this->Viewer_Assign('aUsersFriend',$aUsersFriend);
$this->Viewer_Assign('aUsersFriend',$aUsersFriend['collection']);
$this->Viewer_Assign('aUserFields',$aUserFields);
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile').' '.$this->oUserProfile->getLogin());
$this->Viewer_AddHtmlTitle($this->Lang_Get('user_menu_profile_whois'));
@ -1023,6 +1058,7 @@ class ActionProfile extends Action {
if ($this->oUserCurrent) {
$this->Viewer_Assign('oUserNote',$this->User_GetUserNote($this->oUserProfile->getId(),$this->oUserCurrent->getId()));
}
$this->Viewer_Assign('iCountFriendsUser',$this->User_GetCountUsersFriend($this->oUserProfile->getId()));
$this->Viewer_Assign('USER_FRIEND_NULL',ModuleUser::USER_FRIEND_NULL);
$this->Viewer_Assign('USER_FRIEND_OFFER',ModuleUser::USER_FRIEND_OFFER);

View file

@ -848,15 +848,33 @@ class ModuleUser extends Module {
/**
* Получает список друзей
*
* @param string $sUserId
* @param int $sUserId
* @param int $iPage
* @param int $iPerPage
* @return array
*/
public function GetUsersFriend($sUserId) {
if (false === ($data = $this->Cache_Get("user_friend_{$sUserId}"))) {
$data = $this->oMapper->GetUsersFriend($sUserId);
$this->Cache_Set($data, "user_friend_{$sUserId}", array("friend_change_user_{$sUserId}"), 60*60*24*2);
public function GetUsersFriend($sUserId,$iPage=1,$iPerPage=10) {
$sKey="user_friend_{$sUserId}_{$iPage}_{$iPerPage}";
if (false === ($data = $this->Cache_Get($sKey))) {
$data = array('collection'=>$this->oMapper->GetUsersFriend($sUserId,$iCount,$iPage,$iPerPage),'count'=>$iCount);
$this->Cache_Set($data, $sKey, array("friend_change_user_{$sUserId}"), 60*60*24*2);
}
$data['collection']=$this->GetUsersAdditionalData($data['collection']);
return $data;
}
/**
* Получает количество друзей
*
* @param int $sUserId
* @return array
*/
public function GetCountUsersFriend($sUserId) {
$sKey="count_user_friend_{$sUserId}";
if (false === ($data = $this->Cache_Get($sKey))) {
$data = $this->oMapper->GetCountUsersFriend($sUserId);
$this->Cache_Set($data, $sKey, array("friend_change_user_{$sUserId}"), 60*60*24*2);
}
$data=$this->GetUsersAdditionalData($data);
return $data;
}

View file

@ -471,7 +471,7 @@ class ModuleUser_MapperUser extends Mapper {
* @param int $iStatus
* @return array
*/
public function GetUsersFriend($sUserId) {
public function GetUsersFriend($sUserId,&$iCount,$iCurrPage,$iPerPage) {
$sql = "SELECT
uf.user_from,
uf.user_to
@ -486,15 +486,17 @@ class ModuleUser_MapperUser extends Mapper {
OR
(uf.status_from = ?d AND uf.status_to = ?d )
)
;";
LIMIT ?d, ?d ;";
$aUsers=array();
if ($aRows=$this->oDb->select(
if ($aRows=$this->oDb->selectPage(
$iCount,
$sql,
$sUserId,
$sUserId,
ModuleUser::USER_FRIEND_ACCEPT+ModuleUser::USER_FRIEND_OFFER,
ModuleUser::USER_FRIEND_ACCEPT,
ModuleUser::USER_FRIEND_ACCEPT
ModuleUser::USER_FRIEND_ACCEPT,
($iCurrPage-1)*$iPerPage, $iPerPage
)
) {
foreach ($aRows as $aUser) {
@ -506,6 +508,34 @@ class ModuleUser_MapperUser extends Mapper {
return array_unique($aUsers);
}
public function GetCountUsersFriend($sUserId) {
$sql = "SELECT
count(*) as c
FROM
".Config::Get('db.table.friend')." as uf
WHERE
( uf.user_from = ?d
OR
uf.user_to = ?d )
AND
( uf.status_from + uf.status_to = ?d
OR
(uf.status_from = ?d AND uf.status_to = ?d )
)";
if ($aRow=$this->oDb->selectRow(
$sql,
$sUserId,
$sUserId,
ModuleUser::USER_FRIEND_ACCEPT+ModuleUser::USER_FRIEND_OFFER,
ModuleUser::USER_FRIEND_ACCEPT,
ModuleUser::USER_FRIEND_ACCEPT
)
) {
return $aRow['c'];
}
return 0;
}
/**
* Получить список заявок на добавление в друзья от указанного пользователя
*

View file

@ -170,7 +170,8 @@ $config['module']['topic']['new_time'] = 60*60*24*1; // Время в сек
$config['module']['topic']['per_page'] = 10; // Число топиков на одну страницу
$config['module']['topic']['max_length'] = 15000; // Максимальное количество символов в одном топике
// Модуль User
$config['module']['user']['per_page'] = 15; // Число юзеров на страницу на странице статистики
$config['module']['user']['per_page'] = 15; // Число юзеров на страницу на странице статистики и в профиле пользователя
$config['module']['user']['friend_on_profile'] = 15; // Ограничение на вывод числа друзей пользователя на странице его профиля
$config['module']['user']['friend_notice']['delete'] = false; // Отправить talk-сообщение в случае удаления пользователя из друзей
$config['module']['user']['friend_notice']['accept'] = false; // Отправить talk-сообщение в случае одобрения заявки на добавление в друзья
$config['module']['user']['friend_notice']['reject'] = false; // Отправить talk-сообщение в случае отклонения заявки на добавление в друзья

View file

@ -1,41 +1,7 @@
{include file='header.tpl' menu='people'}
<h2 class="page-header">{$aLang.user_list}: {$oCity->getName()|escape:'html'}</h2>
{include file='user_list.tpl' aUsersList=$aUsersCity}
{if $aUsersCity}
<table class="table table-users">
<thead>
<tr>
<th>{$aLang.user}</th>
<th>{$aLang.user_date_last}</th>
<th>{$aLang.user_date_registration}</th>
<th>{$aLang.user_skill}</th>
<th>{$aLang.user_rating}</th>
</tr>
</thead>
<tbody>
{foreach from=$aUsersCity item=oUser}
{assign var="oSession" value=$oUser->getSession()}
<tr>
<td><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></td>
<td>{if $oSession}{date_format date=$oSession->getDateLast()}{/if}</td>
<td>{date_format date=$oUser->getDateRegister()}</td>
<td>{$oUser->getSkill()}</td>
<td>{$oUser->getRating()}</td>
</tr>
{/foreach}
</tbody>
</table>
{else}
{$aLang.user_empty}
{/if}
{include file='paging.tpl' aPaging="$aPaging"}
{include file='footer.tpl'}

View file

@ -1,40 +1,7 @@
{include file='header.tpl' menu='people'}
<h2 class="page-header">{$aLang.user_list}: <span>{$oCountry->getName()|escape:'html'}</span></h2>
{include file='user_list.tpl' aUsersList=$aUsersCountry}
{if $aUsersCountry}
<table class="table table-users">
<thead>
<tr>
<th class="table-users-cell-name">{$aLang.user}</th>
<th>{$aLang.user_date_last}</th>
<th>{$aLang.user_date_registration}</th>
<th class="table-users-cell-skill">{$aLang.user_skill}</th>
<th class="table-users-cell-rating">{$aLang.user_rating}</th>
</tr>
</thead>
<tbody>
{foreach from=$aUsersCountry item=oUser}
{assign var="oSession" value=$oUser->getSession()}
<tr>
<td class="table-users-cell-name"><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></td>
<td>{if $oSession}{date_format date=$oSession->getDateLast()}{/if}</td>
<td>{date_format date=$oUser->getDateRegister()}</td>
<td class="table-users-cell-skill">{$oUser->getSkill()}</td>
<td class="table-users-cell-rating"><strong>{$oUser->getRating()}</strong></td>
</tr>
{/foreach}
</tbody>
</table>
{else}
{$aLang.user_empty}
{/if}
{include file='paging.tpl' aPaging="$aPaging"}
{include file='footer.tpl'}

View file

@ -1,30 +1,5 @@
{include file='header.tpl' menu='people'}
{include file='user_list.tpl' aUsersList=$aUsersRating}
{if $aUsersRating}
<table class="table table-users">
<thead>
<tr>
<th class="table-users-cell-name">{$aLang.user}</th>
<th class="table-users-cell-skill">{$aLang.user_skill}</th>
<th class="table-users-cell-rating">{$aLang.user_rating}</th>
</tr>
</thead>
<tbody>
{foreach from=$aUsersRating item=oUser}
<tr>
<td class="table-users-cell-name"><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></td>
<td class="table-users-cell-skill">{$oUser->getSkill()}</td>
<td class="table-users-cell-rating">{$oUser->getRating()}</td>
</tr>
{/foreach}
</tbody>
</table>
{else}
{$aLang.user_empty}
{/if}
{include file='paging.tpl' aPaging="$aPaging"}
{include file='footer.tpl'}

View file

@ -1,34 +1,5 @@
{include file='header.tpl' menu='people'}
{include file='user_list.tpl' aUsersList=$aUsersRegister}
{if $aUsersRegister}
<table class="table table-users">
<thead>
<tr>
<th>{$aLang.user}</th>
<th>{$aLang.user_date_registration}</th>
<th>{$aLang.user_skill}</th>
<th>{$aLang.user_rating}</th>
</tr>
</thead>
<tbody>
{foreach from=$aUsersRegister item=oUser}
<tr>
<td><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></td>
<td>{date_format date=$oUser->getDateRegister()}</td>
<td>{$oUser->getSkill()}</td>
<td><strong>{$oUser->getRating()}</strong></td>
</tr>
{/foreach}
</tbody>
</table>
{else}
{$aLang.user_empty}
{/if}
{include file='paging.tpl' aPaging="$aPaging"}
{include file='footer.tpl'}

View file

@ -1,36 +1,5 @@
{include file='header.tpl' menu='people'}
{if $aUsersLast}
<table class="table table-users">
<thead>
<tr>
<th>{$aLang.user}</th>
<th>{$aLang.user_date_last}</th>
<th>{$aLang.user_skill}</th>
<th>{$aLang.user_rating}</th>
</tr>
</thead>
<tbody>
{foreach from=$aUsersLast item=oUser}
{assign var="oSession" value=$oUser->getSession()}
<tr>
<td><a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a></td>
<td>{date_format date=$oSession->getDateLast()}</td>
<td>{$oUser->getSkill()}</td>
<td>{$oUser->getRating()}</td>
</tr>
{/foreach}
</tbody>
</table>
{else}
{$aLang.user_empty}
{/if}
{include file='user_list.tpl' aUsersList=$aUsersLast}
{include file='paging.tpl' aPaging="$aPaging"}
{include file='footer.tpl'}

View file

@ -0,0 +1,12 @@
{assign var="sidebarPosition" value='left'}
{include file='header.tpl'}
{include file='actions/ActionProfile/profile_top.tpl'}
<h3 class="profile-page-header">{$aLang.user_menu_profile_friends}</h3>
{include file='user_list.tpl' aUsersList=$aFriends}
{include file='footer.tpl'}

View file

@ -51,6 +51,6 @@
<li {if $sAction=='profile' && $aParams[0]=='wall'}class="active"{/if}><a href="{$oUserProfile->getUserWebPath()}wall/">{$aLang.user_menu_profile_wall}{if ($iCountWallUser)>0} ({$iCountWallUser}){/if}</a></li>
<li {if $sAction=='profile' && $aParams[0]=='created'}class="active"{/if}><a href="{$oUserProfile->getUserWebPath()}created/topics/">{$aLang.user_menu_publication}{if ($iCountCreated)>0} ({$iCountCreated}){/if}</a></li>
<li {if $sAction=='profile' && $aParams[0]=='favourites'}class="active"{/if}><a href="{$oUserProfile->getUserWebPath()}favourites/topics/">{$aLang.user_menu_profile_favourites}{if ($iCountFavourite)>0} ({$iCountFavourite}){/if}</a></li>
<li {if $sAction=='profile' && $aParams[0]=='friends'}class="active"{/if}><a href="{$oUserProfile->getUserWebPath()}friends/">{$aLang.user_menu_profile_friends}</a></li>
<li {if $sAction=='profile' && $aParams[0]=='friends'}class="active"{/if}><a href="{$oUserProfile->getUserWebPath()}friends/">{$aLang.user_menu_profile_friends}{if ($iCountFriendsUser)>0} ({$iCountFriendsUser}){/if}</a></li>
</ul>
</section>

View file

@ -7,7 +7,7 @@
{include file='actions/ActionProfile/profile_top.tpl'}
<h3 class="profile-page-header">Стена</h3>
<h3 class="profile-page-header">{$aLang.user_menu_profile_wall}</h3>
<script>

View file

@ -125,18 +125,7 @@
<h2 class="header-table">{$aLang.profile_activity}</h2>
<table class="table table-profile-info">
{if $aUsersFriend}
<tr>
<td class="cell-label">{$aLang.profile_friends}:</td>
<td>
{foreach from=$aUsersFriend item=oUser}
<a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a>
{/foreach}
</td>
</tr>
{/if}
{if $oConfig->GetValue('general.reg.invite') and $oUserInviteFrom}
<tr>
<td class="cell-label">{$aLang.profile_invite_from}:</td>
@ -228,5 +217,19 @@
</table>
<h2 class="header-table"><a href="{$oUserProfile->getUserWebPath()}friends/">{$aLang.profile_friends}</a> {$iCountFriendsUser}</h2>
{if $aUsersFriend}
<table class="table table-profile-info">
<tr>
<td>
{foreach from=$aUsersFriend item=oUser}
<a href="{$oUser->getUserWebPath()}">{$oUser->getLogin()}</a>
{/foreach}
</td>
</tr>
</table>
{/if}
{include file='footer.tpl'}

View file

@ -0,0 +1,36 @@
{if $aUsersList}
<table class="table table-users">
<thead>
<tr>
<th class="table-users-cell-name">{$aLang.user}</th>
<th>{$aLang.user_date_last}</th>
<th>{$aLang.user_date_registration}</th>
<th class="table-users-cell-skill">{$aLang.user_skill}</th>
<th class="table-users-cell-rating">{$aLang.user_rating}</th>
</tr>
</thead>
<tbody>
{foreach from=$aUsersList item=oUserList}
{assign var="oSession" value=$oUserList->getSession()}
<tr>
<td class="table-users-cell-name"><a href="{$oUserList->getUserWebPath()}">{$oUserList->getLogin()}</a></td>
<td>{if $oSession}{date_format date=$oSession->getDateLast()}{/if}</td>
<td>{date_format date=$oUserList->getDateRegister()}</td>
<td class="table-users-cell-skill">{$oUserList->getSkill()}</td>
<td class="table-users-cell-rating"><strong>{$oUserList->getRating()}</strong></td>
</tr>
{/foreach}
</tbody>
</table>
{else}
{if $sUserListEmpty}
{$sUserListEmpty}
{else}
{$aLang.user_empty}
{/if}
{/if}
{include file='paging.tpl' aPaging="$aPaging"}