HomeHelpTrac

source: tags/6.1/viewFriends.php @ 10263

Revision 10263, 4.3 KB checked in by Andrey Prikaznov, 3 years ago (diff)
Line 
1<?
2
3/***************************************************************************
4*                            Dolphin Smart Community Builder
5*                              -----------------
6*     begin                : Mon Mar 23 2006
7*     copyright            : (C) 2006 BoonEx Group
8*     website              : http://www.boonex.com/
9* This file is part of Dolphin - Smart Community Builder
10*
11* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12* http://creativecommons.org/licenses/by/3.0/
13*
14* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15* without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16* See the Creative Commons Attribution 3.0 License for more details.
17* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18* see license.txt file; if not, write to marketing@boonex.com
19***************************************************************************/
20
21
22require_once( 'inc/header.inc.php' );
23require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
24require_once( BX_DIRECTORY_PATH_INC . 'profiles.inc.php' );
25
26$_page['name_index'] = 82;
27$_page['css_name'] = 'browse.css';
28
29check_logged();
30
31if ( isset($_GET['iUser']) )
32{
33    $iID = (int)$_GET['iUser'];
34    $_page['header'] = getNickName( $iID)."'s "._t("_Friends");
35    $_page['header_text'] = getNickName( $iID)."'s "._t("_Friends");
36}
37
38$_ni = $_page['name_index'];
39$_page_cont[$_ni]['page_main_code'] = PageCompPageMainCode();
40
41PageCode();
42
43function PageCompPageMainCode()
44{
45    global $iID;
46   
47    $sFriendList = getFriendList( $iID );
48   
49    return $sFriendList;
50}
51
52function getFriendList( $id )
53{
54    global $site;
55    global $max_thumb_width;
56    global $max_thumb_height;
57
58    $iID = (int)$id;
59
60    ////////////////////////////
61    $iTotalNum = getFriendNumber($iID);
62    if( !$iTotalNum ) {
63        return MsgBox(_t( '_Sorry, nothing found' ));
64    }
65
66    $iPerPage = (int)$_GET['per_page'];
67    if( !$iPerPage )
68        $iPerPage = 28;
69
70    $iTotalPages = ceil( $iTotalNum / $iPerPage );
71
72    $iCurPage = (int)$_GET['page'];
73
74    if( $iCurPage > $iTotalPages )
75        $iCurPage = $iTotalPages;
76
77    if( $iCurPage < 1 )
78        $iCurPage = 1;
79
80    $sLimitFrom = ( $iCurPage - 1 ) * $iPerPage;
81    $sqlLimit = "LIMIT {$sLimitFrom}, {$iPerPage}";
82    ////////////////////////////
83
84    $friend_list_query = "
85        SELECT p.*
86        FROM `Profiles` AS p
87        LEFT JOIN `FriendList` AS f1 ON (f1.`ID` = p.`ID` AND f1.`Profile` ='{$iID}' AND `f1`.`Check` = 1)
88        LEFT JOIN `FriendList` AS f2 ON (f2.`Profile` = p.`ID` AND f2.`ID` ='{$iID}' AND `f2`.`Check` = 1)
89        WHERE 1
90        AND (f1.`ID` IS NOT NULL OR f2.`ID` IS NOT NULL)
91        ORDER BY p.`Picture` DESC
92        {$sqlLimit}
93    ";
94
95    $friend_list_res = db_res("$friend_list_query");
96   
97    $iCounter = 0;
98    while ( $friend_list_arr = mysql_fetch_assoc( $friend_list_res ) )
99    {
100        $iCounter ++;
101        $sKey = '1';
102        if( $iCounter == 3 )
103        {
104            $sKey = '1';
105        }
106
107        $ret .= '<div class="friends_thumb_'.$sKey.'">' . get_member_thumbnail($friend_list_arr['ID'], 'none', true) . '<div class="browse_nick"><a href="' . getProfileLink($friend_list_arr['ID']) . '">' . $friend_list_arr['NickName'] . '</a></div><div class="clear_both"></div></div>';
108       
109        if( $iCounter == 3)
110            $iCounter = 0;
111    }
112
113    if( $iTotalPages > 1)
114    {
115        $sRequest = $_SERVER['PHP_SELF'] . '?';
116        $aFields = array('iUser','action');
117       
118        foreach( $aFields as $field )
119            if( isset( $_GET[$field] ) )
120                $sRequest .= "&{$field}=" . htmlentities( process_pass_data( $_GET[$field] ) );
121       
122        $pagination = '<div style="text-align: center; position: relative;">'._t("_Results per page").':
123                <select name="per_page" onchange="window.location=\'' . $sRequest . '&per_page=\' + this.value;">
124                    <option value="10"' . ( $iPerPage == 10 ? ' selected="selected"' : '' ) . '>10</option>
125                    <option value="20"' . ( $iPerPage == 20 ? ' selected="selected"' : '' ) . '>20</option>
126                    <option value="50"' . ( $iPerPage == 50 ? ' selected="selected"' : '' ) . '>50</option>
127                    <option value="100"' . ( $iPerPage == 100 ? ' selected="selected"' : '' ) . '>100</option>
128                </select></div>' .
129            genPagination( $iTotalPages, $iCurPage, ( $sRequest . '&page={page}&per_page='.$iPerPage ) );
130    }
131    else
132        $pagination = '';
133
134    return $ret . $pagination;
135}
Note: See TracBrowser for help on using the repository browser.