Location: PHPKode > projects > QuickTicket > quickticket/qti_members.php
<?php

/**
* PHP versions 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    QuickTicket
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.5 build:20101222
*/

session_start();
require_once('bin/qti_init.php');
if ( !$oVIP->CanView('V4') ) HtmlPage(11);
include('bin/qti_fn_sql.php');

// INITIALISE

$strGroup = 'all';
$strOrder = 'name';
$strDirec = 'ASC';
$intLimit = 0;
$intPage = 1;

// security check 1
if ( isset($_GET['group']) ) $strGroup = strip_tags($_GET['group']);
if ( isset($_GET['order']) ) $strOrder = strip_tags($_GET['order']);
if ( isset($_GET['dir']) ) $strDirec = strip_tags($_GET['dir']);
if ( isset($_GET['page']) ) $intPage = intval(strip_tags($_GET['page']));
if ( isset($_GET['view']) ) $_SESSION[QT]['viewmode'] = strip_tags($_GET['view']);

// security check 2 (no long argument)
if ( strlen($strGroup)>4 ) die('Invalid argument #group');
if ( strlen($strOrder)>20 ) die('Invalid argument #order');
if ( strlen($strDirec)>4 ) die('Invalid argument #dir');

$intLimit = ($intPage-1)*$_SESSION[QT]['topics_per_page'];

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

// MAP MODULE

if ( UseModule('map') ) { $strCheck='U'; include('qtim_map_ini.php'); } else { $bMap=false; }

// COUNT

Switch ($strGroup)
{
Case 'all': $strWhere = ' WHERE id>0'; break;
Case '0': $strWhere = ' WHERE id>0 AND '.FirstCharCase('name','a-z'); Break;
Default: $strWhere = ' 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.$strWhere);
$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
// --------

include('qti_p_header.php');

// header

echo '<table class="hidden" cellspacing="0">',N;
echo '<tr class="hidden">',N;
echo '<td class="hidden"><h2>',$oVIP->selfname,'</h2><p>',( $strGroup=='all' ? $intTotal.' '.$L['Members'] : $intCount.' / '.$intTotal.' '.$L['Members'] );
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">',N;

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

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

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

// -- build pager --

$strPager = MakePager("qti_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['Members']).'</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" >',N,'<tr class="button">',N,$strGroups,'</tr>',N,'</table>',N,N;

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

// end if no result

if ( $intCount==0 ) { TableEmpty($L['None'].'...'); include('qti_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">',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['photo'] = new cFLD('photo',$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.$strWhere;
$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'; }
  if ( $bMap )
  {
    // map settings
    if ( !empty($row['x']) && !empty($row['y']) )
    {
      $str = $row['name'].'<br /><br /><a class="gmap" href="'.Href('qti_user.php').'?id='.$row['id'].'">Open profile &raquo;</a>';
      if ( !empty($row['photo']) ) 
      {
      $str = '<table class="gmap"><tr><td>'.AsImg(AsAvatarScr($row['photo']),'',$row['name'],'maptip').'</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']['U']['icon']) )        $oMapPoint->icon        = $_SESSION[QT]['m_map']['U']['icon'];
      if ( isset($_SESSION[QT]['m_map']['U']['shadow']) )      $oMapPoint->shadow      = $_SESSION[QT]['m_map']['U']['shadow'];
      if ( isset($_SESSION[QT]['m_map']['U']['printicon']) )   $oMapPoint->printicon   = $_SESSION[QT]['m_map']['U']['printicon'];
      if ( isset($_SESSION[QT]['m_map']['U']['printshadow']) ) $oMapPoint->printshadow = $_SESSION[QT]['m_map']['U']['printshadow'];
      $arrExtData[intval($row['id'])] = $oMapPoint;
    }
  }
  $intWhile++; 
  if ( $intWhile>=$_SESSION[QT]['topics_per_page'] ) break; //odbc 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="button" cellspacing="0"><tr class="button"><td class="hidden" id="pager_zb">&nbsp;',$strPager,'</td></tr></table>
';
}

// 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)) );

    if ( $bMapGoogle )
    {
      echo '<table class="hidden" style="margin-top:5px;">',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;
    }

    if ( $bMapSitework )
    {
      if ( !$_SESSION[QT]['m_map_hidelist'] ) include('qtim_sitework/mapapi.php');
    }

    // Show/Hide

    if ( $_SESSION[QT]['m_map_hidelist'] ) 
    {
    echo '<p style="margin:2px"><a href="',Href(),'?showmap">',$L['map']['Show_map'],'</a></p>',N;
    }
    else
    {
    echo '<p style="margin:2px"><a href="',Href(),'?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('qtim_map_load.php'); } else { echo '<script type="text/javascript">function GUnload() { return true; }</script>'; }
}

include('qti_p_footer.php');

?>
Return current item: QuickTicket