Location: PHPKode > projects > QuickTalk Forum > quicktalk/qtf_members.php
<?php

/**
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license.  If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to hide@address.com so we can mail you a copy immediately.
*
* @package    QuickTalk
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.5 build:20100929
*/

session_start();
require_once('bin/qtf_init.php');
if ( !$oVIP->CanView('V5') ) HtmlPage(11);

// CHANGE USER INTERFACE

if (isset($_GET['view'])) $_SESSION[QT]['viewmode'] = substr($_GET['view'],0,1);

// INITIALISE

include('bin/qtf_fn_sql.php');

// Protection against injection: 'order','group','dir' are controlled
$strGroup = 'all';
$strOrder = 'name';
$strDirec = 'ASC';
$intLimit = 0;
$intPage  = 1;
if ( isset($_GET['group']) ) { $strGroup = substr($_GET['group'],0,3); } // protection against injection
if ( isset($_GET['page']) )  { $intLimit = (intval($_GET['page'])-1)*$_SESSION[QT]['topics_per_page']; $intPage = intval($_GET['page']); }
if ( isset($_GET['order']) ) { $strOrder = strip_tags(substr($_GET['order'],0,15)); } // protection against injection
if ( isset($_GET['dir']) )   { if ( $_GET['dir']=='DESC' ) $strDirec = 'DESC'; }      // protection against injection

$oVIP->selfurl = 'qtf_members.php';
$oVIP->selfname = $L['Memberlist'];

// MAP MODULE

if ( UseModule('map') ) { $bCheckList=true; include('qtfm_map_ini.php'); } else { $bMap=false; }

// COUNT

Switch ($strGroup)
{
Case 'all': $where = ' WHERE id>0'; Break;
Case '#':   $where = ' WHERE id>0 AND '.FirstCharCase('name','a-z'); Break;
Default:    $where = ' WHERE id>0 AND '.FirstCharCase('name','u').'="'.$strGroup.'"'; Break;
}

$intTotal = $oVIP->SysCount('members');
if ($strGroup=='all')
{
$intCount = $intTotal;
}
else
{
$oDB->Query('SELECT count(id) as countid FROM '.TABUSER.$where);
$row = $oDB->Getrow();
$intCount = $row['countid'];
}

// GROUP LINE

if ( $intCount>$_SESSION[QT]['topics_per_page'] || isset($_GET['group']) ) $strGroups = HtmlLettres($strGroup,$L['All']);

// --------
// HTML START
// --------

$bJava=true;
include('qtf_p_header.php');

// --------
// Title and top 5
// --------

// header

echo '<table class="hidden" cellspacing="0" summary="members header">',N;
echo '<tr class="hidden">',N;
echo '<td class="hidden"><h2>',$oVIP->selfname,'</h2><p>',( $strGroup=='all' ? $intTotal.' '.$L['Members'] : $intCount.' / '.$intTotal.' '.$L['Members'] );
if ( CanPerform("show_calendar",$oVIP->role) ) 
{
echo '&nbsp;&middot;&nbsp;<a href="',Href('qtf_calendar.php'),(empty($row['birthday']) ? '' : '?m='.substr($row['birthday'],4,2)),'">',$L['Birthdays_calendar'],'</a>';
}
echo '</p></td>',N;
echo '<td class="hidden" style="width:170px;">',N;
echo '<div class="legendbox">',N;
echo '<p class="legendtitle">',$L['Top_participants'],'</p>',N;
echo '<table class="hidden" cellspacing="0" summary="top participants">',N;

//-- LIMIT QUERY --
$strState = 'name, id, numpost FROM '.TABUSER.' WHERE id>0';
$oDB->Query( LimitSQL($strState,'numpost DESC',0,5) );
// --------

For ($i=0;$i<($_SESSION[QT]['viewmode']=='C' ? 2 : 5);$i++)
{
$row = $oDB->Getrow();
if (!$row) break;
echo '<tr><td style="text-align:left"><a href="qtf_user.php?id=',$row['id'],'">',$row['name'],'</a></td><td style="text-align:right">',$row['numpost'],'</td></tr>',N;
}
echo '</table>',N,'</div>',N;
echo '</td>',N;
echo '</tr>',N;
echo '</table>',N,N;

// --------
// Button line and pager
// --------

// -- build pager --

$strPager = MakePager("qtf_members.php?group=$strGroup&order=$strOrder&dir=$strDirec",$intCount,$_SESSION[QT]['topics_per_page'],$intPage);
if ( !empty($strPager) ) $strPager = $L['Page'].$strPager;
if ( $intCount<$intTotal ) $strPager = '<span class="small">'.$intCount.' '.$L['Selected_from'].' '.$intTotal.' '.strtolower($L['Users']).'</span>'.(empty($strPager) ? '' : ' | '.$strPager);

// -- Display button line (if more that tpp users) and pager --

if ($intTotal>$_SESSION[QT]['topics_per_page']) echo '<table class="button" cellspacing="0" summary="filter"><tr class="button">',$strGroups,'</tr></table>',N;

if ( !empty($strPager) )
{
echo '<table class="hidden" cellspacing="0"><tr class="hidden"><td class="hidden" id="pager_zt">',$strPager,'</td></tr></table>',N,N;
}

// end if no result
if ($intCount==0)
{
  echo '<p>',$L['None'],'</p><br/>';
  include('qtf_p_footer.php');
  exit;
}

// --------
// Memberlist
// --------

$bCompact = FALSE;
if ( $_SESSION[QT]['avatar']=='0' ) $bCompact = true;
if ( $_SESSION[QT]['viewmode']=='C' ) $bCompact = true;

echo '<table class="data_t" cellspacing="0" summary="members">',N;
echo '<tr class="data_t">',N;


// ========
$arrFLD = array();
if ( $bCompact )
{
$arrFLD['name'] = new cFLD('name',$L['Username'],'colhd colhdfirst','width:150px','colct colfirst','','ASC');
}
else
{
$arrFLD['picture'] = new cFLD('picture',$L['Avatar'],'colhd center colhdfirst','width:150px','colct center colfirst');
$arrFLD['name'] = new cFLD('name',$L['Username'],'colhd','','colct','','ASC');
}
$arrFLD['role'] = new cFLD('role',$L['Role'],'colhd','','colct','','ASC');
$arrFLD['contact'] = new cFLD('contact',$L['Contact'],'colhd','','colct'); 
$arrFLD['location'] = new cFLD('location',$L['Location'],'colhd','','colct','','ASC');
$arrFLD['numpost'] = new cFLD('numpost',$L['Messages'],'colhd center colhdlast','','colct center collast','','DESC');
// ========
TableHeader($arrFLD,$intCount,"$oVIP->selfurl?group=$strGroup&amp;page=1",$strOrder,$strDirec);
// ========

echo '</tr>',N;

// ========
$strState = '* FROM '.TABUSER.$where;
$oDB->Query( LimitSQL($strState,$strOrder.' '.$strDirec,$intLimit,$_SESSION[QT]['topics_per_page'],$intCount) );
// ========
$intWhile=0;
$strAlt='r1';
while($row=$oDB->Getrow())
{
  // privacy control for map and location field
  if ( $oVIP->IsPrivate($row['privacy'],$row['id']) ) { $row['y']=null; $row['x']=null; }

  TableRowShow($arrFLD,TableRowFormat($arrFLD,$row,null,null,$bMap),'data_t '.$strAlt);
  if ( $strAlt=='r1' ) { $strAlt='r2'; } else { $strAlt='r1'; }

  // map settings
  if ( $bMap ) {
  if ( !empty($row['x']) && !empty($row['y']) ) {
    $str = $row['name'].'<br/><br/><a class="gmap" href="qtf_user.php?id='.$row['id'].'">Open profile &raquo;</a>';
    if ( !empty($row['picture']) ) 
    {
    $str = '<table class="gmap" summary="google map"><tr><td>'.AsImg(QTF_DIR_PIC.$row['picture'],'',$row['name'],'imagelist').'</td><td>'.$str.'</td></tr></table>';
    }
    $oMapPoint = new cMapPoint( floatval($row['y']),floatval($row['x']),QTconv($row['name'],'-4'),$str );
    if ( isset($_SESSION[QT]['m_map_gsymbol']) )
    {
    $oMapPoint->icon = QTgetsymbol($row['role'],'icon');
    $oMapPoint->shadow = QTgetsymbol($row['role'],'shadow');
    $oMapPoint->printicon = QTgetsymbol($row['role'],'printicon');
    $oMapPoint->printshadow = QTgetsymbol($row['role'],'printshadow');
    }
    $arrExtData[intval($row['id'])] = $oMapPoint;
  }}
  $intWhile++; 
  //odbcbreak
  if ( $intWhile>=$_SESSION[QT]['topics_per_page'] ) break;  
}
// ========

echo '<tr class="data_t">',N;
echo '<td class="colft colftfirst"></td>',N;
for ($i=0;$i<(count($arrFLD)-2);$i++) echo '<td class="colft"></td>',N;
echo '<td class="colft colftlast"></td>
</tr>
</table>
';

// -- Display pager --

if ( !empty($strPager) )
{
echo '<table class="hidden" cellspacing="0" summary="pages"><tr class="hidden"><td class="hidden" id="pager_zb">',$strPager,'</td></tr></table>',N,N;
}

// MAP MODULE, Show map

if ( $bMap )
{
  echo '<!-- Map module -->',N;
  if ( count($arrExtData)>0 )
  {
    $strMapHelp = sprintf( $L['map']['items'],strtolower(LangS('Member',count($arrExtData))),strtolower(LangS('Member',$intTotal)) );

    echo '<table class="hidden" style="margin-top:5px;" summary="google map">',N;
    echo '<tr class="hidden">',N;
    echo '<td class="gmap">',N;
    if ( !$_SESSION[QT]['m_map_hidelist'] )
    {
    echo QTgmapZoomControl($arrExtData);
    echo '<div id="map_canvas" style="width:100%; height:',($_SESSION[QT]['viewmode']=='C' ? '350' : '400'),'px;"></div>',N;
    }
    if ( !empty($strMapHelp) ) echo '<p class="gmap" style="margin:4px 0 0 0">'.$strMapHelp.'</p>';
    echo '</td>',N;
    echo '</tr>',N;
    echo '</table>',N;

    // Show/Hide

    if ( $_SESSION[QT]['m_map_hidelist'] ) 
    {
    echo '<p style="margin:2px"><a href="',$oVIP->selfurl,'?showmap">',$L['map']['Show_map'],'</a></p>',N;
    }
    else
    {
    echo '<p style="margin:2px"><a href="',$oVIP->selfurl,'?hidemap">',$L['map']['Hide_map'],'</a></p>',N;
    }
  }
  else
  {
    echo '<p class="gmap">'.$L['map']['E_noposition'].'</p>',N;
  }
  echo '<!-- Map module end -->',N;
}

// --------
// HTML END
// --------

// MAP MODULE

if ( $bMap )
{
  if ( count($arrExtData)>0 ) { include('qtfm_map_load.php'); } else { echo '<script type="text/javascript">function GUnload() { return true; }</script>'; }
}

include('qtf_p_footer.php');

?>
Return current item: QuickTalk Forum