friends.php
ссылка friends.php?user=id узера
GET PRIVACY LEVEL у вас не будет работать - Это отдельная тема
Pager
PHP:
<?php
/* $Id: friends.php 42 2011-01-29 09:30:14Z Afsun $ */
$page = "friends";
include "header.php";
if(isset($_POST['p'])) { $p = $_POST['p']; } elseif(isset($_GET['p'])) { $p = $_GET['p']; } else { $p = 1; }
if(isset($_POST['s'])) { $s = $_POST['s']; } elseif(isset($_GET['s'])) { $s = $_GET['s']; } else { $s = "ld"; }
if(isset($_POST['search'])) { $search = $_POST['search']; } elseif(isset($_GET['search'])) { $search = $_GET['search']; } else { $search = ""; }
if(isset($_POST['task'])) { $task = $_POST['task']; } elseif(isset($_GET['task'])) { $task = $_GET['task']; } else { $task = ""; }
// ENSURE CONECTIONS ARE ALLOWED FOR THIS USER
if( !$setting['setting_connection_allow'] )
{
header("Location: user_home.php");
exit();
}
// SET FRIEND SORT-BY VARIABLES FOR HEADING LINKS
$u = "ud"; // LAST UPDATE DATE
$l = "ld"; // LAST LOGIN DATE
$t = "t"; // FRIEND TYPE
// SET SORT VARIABLE FOR DATABASE QUERY
switch($s)
{
case "ud": $sort = "se_users.user_dateupdated DESC"; $u = "ud"; break;
case "ld": $sort = "se_users.user_lastlogindate DESC"; $l = "ld"; break;
case "t": $sort = "se_friends.friend_type"; $t = "td"; break;
default: $sort = "se_users.user_dateupdated DESC"; $u = "ud";
}
// SET WHERE CLAUSE
$is_where = 0;
$where = "";
if($search != "")
{
$is_where = 1;
$where = "(se_users.user_username LIKE '%$search%' OR se_users.user_fname LIKE '%$search%' OR se_users.user_lname LIKE '%$search%' OR CONCAT(se_users.user_fname, ' ', se_users.user_lname) LIKE '%$search%' OR se_users.user_email LIKE '%$search%')";
}
// DECIDE WHETHER TO SHOW DETAILS
$connection_types = explode("<!>", trim($setting['setting_connection_types']));
$show_details = ( !empty($connection_types) || $setting['setting_connection_other'] || $setting['setting_connection_explain'] );
// GET TOTAL FRIENDS
$total_friends = $owner->user_friend_total(0, 1, $is_where, $where);
if($total_friends>0)
{
require_once ('Pager/Pager.php');
$params = array(
'mode' => 'Sliding', 'totalItems' => $total_friends, 'perPage' => $friends_per_page, 'delta' => 1, // for 'Jumping'-style a lower number is better
'append' => true, 'separator' => '', 'expanded' => false,
'spacesBeforeSeparator' => 0, 'spacesAfterSeparator'=>1,
'prevImg' =>'‹', 'nextImg'=>'›',
'clearIfVoid' => false, 'urlVar' => 'p',
//'linkClass' => 'pager_link',
'curPageLinkClassName' => 'current',
'firstPagePre' => '', 'firstPagePost' => '',
'lastPagePre' => '', 'lastPagePost' => '',
'useSessions' => false, 'closeSession' => false );
$pager = & Pager::factory($params);
$page_data = $pager->getPageData();
$links = $pager->getLinks();
$smarty->assign('gum_pagination',$links['all']);
}
// MAKE FRIEND PAGES
$friends_per_page = 10;
$page_vars = make_page($total_friends, $friends_per_page, $p);
// GET FRIEND ARRAY
$friends = $owner->user_friend_list($page_vars[0], $friends_per_page, 0, 1, $sort, $where, $show_details);
// GET PRIVACY LEVEL
$privacy_max = $owner->user_privacy_max($user);
$allowed_to_friend = ($privacy_max & $owner->user_info['user_privacy_friend_view']);
$is_friend_private = !$allowed_to_friend;
$smarty->assign('is_friend_private', $is_friend_private);
// ASSIGN VARIABLES AND INCLUDE FOOTER
$smarty->assign('s', $s);
$smarty->assign('u', $u);
$smarty->assign('l', $l);
$smarty->assign('t', $t);
$smarty->assign('search', $search);
$smarty->assign('friends', $friends);
$smarty->assign('total_friends', $total_friends);
$smarty->assign('maxpage', $page_vars[2]);
$smarty->assign('p', $page_vars[1]);
$smarty->assign('p_start', $page_vars[0]+1);
$smarty->assign('p_end', $page_vars[0]+count($friends));
$smarty->assign('show_details', $show_details);
$smarty->assign('online_friends', online_friends(owner) );
include "footer.php";
?>
.tpl Обязательно правим под себя...
$owner->get_declination_user - уже со склонятором.
PHP:
{include file='header.tpl'}
<div style='float: left; width: 80%; padding: 0px 10px 0px 2px;'>
<div class='portal_whatsnew' width='80%'>
{if $is_friend_private == 1}
<META http-equiv="refresh" content="0; url=/blank.php?code=37">
{else}
<div class='header_yellow'><a href='id{$owner->user_info.user_username}'><span class="etovi"><b>{lang_sprintf id=786 1=$owner->user_displayname}</b></span></a> » {lang_print id=894} {$owner->user_info.user_fname}</div>
<table class='tabs' cellpadding='0' cellspacing='0' width='100%'>
<tr>
<td class="tab0"> </td>
<td class="tab1" nowrap="nowrap"><a href="friends.php?user={$owner->user_info.user_id}">{lang_print id=894} ({$total_friends})</a></td>
<td class="tab"> </td>
<td class="tab2" nowrap="nowrap"><a href="friends_online.php?user={$owner->user_info.user_id}">{lang_print id=1100052} ({$online_friends[2]|@count})</a> </td>
{*<td class="tab"> </td>
<td class="tab2" nowrap="nowrap"><a href='user_friends_requests.php'>{lang_print id=895}</a></td>
<td class="tab"> </td>
<td class="tab2" nowrap="nowrap"><a href='user_friends_requests_outgoing.php'>{lang_print id=896}</a></td>
<td class="tab"> </td>
<td class="tab2" nowrap="nowrap"><a href='user_fof.php'>{lang_print id=17000500}</a></td>
<td class="tab"> </td>*}
<td class="tab3"> </td>
</tr>
</table>
{* DISPLAY MESSAGE IF NO FRIENDS *}
{if $total_friends == 0}
{* DISPLAY MESSAGE IF NO SEARCHED FRIENDS *}
{if $search != ""}
<br>
<table cellpadding='0' cellspacing='0' align='center'>
<tr><td class='result'>
<img src='./images/icons/bulb16.gif' border='0' class='icon'>{lang_print id=905}
</td></tr>
</table>
{* DISPLAY MESSAGE IF NO FRIENDS ON LIST *}
{else}
<div class="nomail">
{lang_print id=904}
</div>
{/if}
{* DISPLAY FRIENDS *}
{else}
{* JAVASCRIPT FOR CHANGING FRIEND MENU OPTION *}
{literal}
<script type="text/javascript">
<!--
function friend_update(status) {
{/literal}
window.location = 'user_friends.php?s={$s}&search={$search}&p={$p}';
{literal}
}
//-->
</script>
{/literal}
{* DISPLAY PAGINATION MENU IF APPLICABLE *}
{if $gum_pagination}
<div class="bar clearFix summaryBar">
<div class="gum_pagination" style="text-align: right; padding-bottom: 5px;margin-top:0px;">
{$gum_pagination}
</div></div>
{/if}
<div style='margin-left: auto; margin-right: auto; width: 850px;'>
{section name=friend_loop loop=$friends}
{* LOOP THROUGH FRIENDS *}
<div class='friends_result' style='width: 80%; height: auto; float: left; margin-left: 10px;'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td class='friends_result0' style='width: 90px; text-align: center;'><a href='{$url->url_create('profile',$friends[friend_loop]->user_info.user_username)}'><img src='{$friends[friend_loop]->user_photo('./images/nophoto.gif')}' class='photo' width='{$misc->photo_size($friends[friend_loop]->user_photo('./images/nophoto.gif'),'90','60','h')}' border='0' alt="{lang_sprintf id=509 1=$friends[friend_loop]->user_displayname_short}"></a></td>
<td class='friends_result1' width='100%' valign='top'>
<div class='friends_name'><a href='{$url->url_create('profile',$friends[friend_loop]->user_info.user_username)}'></a><a href='{$url->url_create('profile',$friends[friend_loop]->user_info.user_username)}'>{$friends[friend_loop]->user_displayname}</a></div>
<div class='friends_stats'>
{if $friends[friend_loop]->user_info.user_dateupdated != 0}<div>{lang_print id=849} {assign var='last_updated' value=$datetime->time_since($friends[friend_loop]->user_info.user_dateupdated)}{lang_sprintf id=$last_updated[0] 1=$last_updated[1]}</div>{/if}
{if $friends[friend_loop]->user_info.user_lastlogindate != 0}<div>{lang_print id=906} {assign var='last_login' value=$datetime->time_since($friends[friend_loop]->user_info.user_lastlogindate)}{lang_sprintf id=$last_login[0] 1=$last_login[1]}</div>{/if}
{if $show_details != 0}
{if $friends[friend_loop]->friend_type != ""}<div>{lang_print id=882} {$friends[friend_loop]->friend_type}</div>{/if}
{if $friends[friend_loop]->friend_explain != ""}<div>{lang_print id=907} {$friends[friend_loop]->friend_explain|truncate:30:"...":true}</div>{/if}
{/if}
</div>
</td>
<td class='friends_result2' valign='top' nowrap='nowrap'>
<div><a href="javascript:TB_show('{lang_print id=784}', 'user_messages_new.php?to_user={$friends[friend_loop]->user_displayname}&to_id={$friends[friend_loop]->user_info.user_username}&TB_iframe=true&height=350&width=450', '', './images/trans.gif');">{lang_print id=38} {$user->get_declination_user($friends[friend_loop]->user_displayname_short, 3)} {lang_print id=834}</a></div>
<div><a href = "mf_gifts_send.php?to={$friends[friend_loop]->user_info.user_username}">{lang_print id=38} {$user->get_declination_user($friends[friend_loop]->user_displayname_short, 3)} {lang_print id=80000026}</a></div>
<div id='addfriend_{$friends[friend_loop]->user_info.user_id}'><a href="javascript:TB_show('{lang_print id=876}', 'user_friends_manage.php?user={$friends[friend_loop]->user_info.user_username}&TB_iframe=true&height=300&width=450', '', './images/trans.gif');">{lang_print id=838}</a></div>
<div><a href='friends.php?user={$friends[friend_loop]->user_info.user_username}'>{lang_sprintf id=836 1=$owner->get_declination_user($friends[friend_loop]->user_displayname_short, 2)}</a></div>
</td>
</tr>
</table>
</div>
{cycle values=",<div style='clear: both;'></div>"}
{/section}
<div style='clear: both;'></div>
</div>
{* DISPLAY PAGINATION MENU IF APPLICABLE *}
{if $gum_pagination}
<div class="bar clearFix footerBar">
<div class="gum_pagination" style="text-align: right; padding-bottom: 3px;margin-top:3px;">
{$gum_pagination}
</div></div>
{/if}
{*
{if $maxpage > 1}
<div class='center' style='margin-top: 10px;'>
{if $p != 1}<a href='user_friends.php?s={$s}&search={$search}&p={math equation='p-1' p=$p}'>« {lang_print id=182}</a>{else}<font class='disabled'>« {lang_print id=182}</font>{/if}
{if $p_start == $p_end}
| {lang_sprintf id=184 1=$p_start 2=$total_friends} |
{else}
| {lang_sprintf id=185 1=$p_start 2=$p_end 3=$total_friends} |
{/if}
{if $p != $maxpage}<a href='user_friends.php?s={$s}&search={$search}&p={math equation='p+1' p=$p}'>{lang_print id=183} »</a>{else}<font class='disabled'>{lang_print id=183} »</font>{/if}
</div>
{/if}
*}
{/if}{/if}
</div></div>
{include file='footer.tpl'}