Location: PHPKode > projects > QuickTicket > quickticket/quickticket/qti_member.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.
 *
 * @category   Troubleticket
 * @package    QuickTicket
 * @author     Philippe Vandenberghe <hide@address.com>
 * @copyright  2008-2012 The PHP Group
 * @license    http://www.php.net/license  PHP License 3.0
 * @version    1.9.0.3 build:20081001
 * @link       http://www.qt-cute.org/doc/package/qti
 * @since      File available since Release 1.0.0
 * @deprecated File deprecated in Release 2.0.0
 *
 */

session_start();
require_once('bin/qti_init.php');
if ( !$oVIP->CanAccess('MUV',4) ) $oVIP->EndMessage('!',$L['R_member'],$_SESSION[QT]['skin_dir'],0);

// INITIALISE

include('bin/qti_fn_limitsql.php');

$bMap = UseModule('map');
if ( $bMap ) { if ( empty($_SESSION[QT]['m_map_gkey']) ) $bMap=false; }
if ( $bMap ) { require_once('qtim_map_lib.php'); if ( !QTgcanmap('U') ) $bMap=false; }
if ( $bMap ) include(Translate('qtim_map.inc'));

$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)>12 ) die('Invalid argument #order');
if ( strlen($strDirec)>4 ) die('Invalid argument #dir');

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

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

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

if ( $bMap )
{
  $arrMapPoints = array();
  $strHeaderAddScript = QTgmapheader('http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/markermanager.js');
  $strBodyAddOnunload='GUnload()';
}

$arrCss = array('qti_legend.css');

include('qti_p_header.php');

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

// make groups line

$strGroups = '<td class="td_button_small" style="width:35px;">'.($strGroup=='all' ? '<b>'.$L['All'].'</b>' : '<a class="a_button" href="'.$oVIP->selfurl.'?group=all">'.$L['All'].'</a>' ).'</td>'.N;
for ($g='A';$g!='AA';$g++)
{
$strGroups .= '<td class="td_button_small" style="width:18px;">'.($strGroup==$g ? '<b>'.$g.'</b>' : '<a class="a_button" href="'.$oVIP->selfurl.'?group='.$g.'">'.$g.'</a>' ).'</td>'.N;
}
$strGroups .= '<td class="td_button_small" style="width:18px;">'.($strGroup=='0' ? '<b>#</b>' : '<a class="a_button" href="'.$oVIP->selfurl.'?group=0">#</a>' ).'</td>'.N;
$strGroups .= '<td class="td_hidden">&nbsp;</td>'.N;

  // refine query
  Switch ($strGroup)
  {
  Case 'all':   $where = ''; Break;
  Case '0':   $where = ' WHERE '.FirstCharCase('name','a-z'); Break;
  Default:   $where = ' WHERE '.FirstCharCase('name','u').'="'.$strGroup.'"'; Break;
  }

  // count query
  if ($strGroup=='all')
  {
  $intCount = $_SESSION[QT]['sys_members'];
  }
  else
  {
  $oDB->Query('SELECT count(id) as countid FROM '.TABUSER.$where);
  $row = $oDB->Getrow();
  $intCount = $row['countid'];
  }

// header

echo '<table class="ta_hidden" cellspacing="0">',N;
echo '<tr class="tr_hidden">',N;
echo '<td class="td_hidden"><h2>',$oVIP->selfname,'</h2><p>',($strGroup=='all' ? $_SESSION[QT]['sys_members'].' '.$L['Users'] : $intCount.' / '.$_SESSION[QT]['sys_members'].' '.$L['Users'] ),'</p></td>',N;
echo '<td class="td_hidden" style="width:170px;">',N;
echo '<div class="div_legendbox">',N;
echo '<p class="p_legendtitle">',$L['Top_participants'],'</p>',N;
echo '<table class="ta_hidden" cellspacing="0">',N;

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

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

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

// -- build pager --

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

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

if ($_SESSION[QT]['sys_members']>$_SESSION[QT]['topics_per_page']) echo '<table class="ta_button" cellspacing="0" >',N,'<tr class="tr_button">',N,$strGroups,'</tr>',N,'</table>',N,N;

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

// end if no result
if ($intCount==0)
{
  echo '<p>'.$L['None'].'</p><br/>';
  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="ta ta_t" cellspacing="0">',N;
echo '<tr class="tr_t">',N;

  /* ======== */
  $arrFields = array(); // SORT LABEL CLASS STYLE
  if ( $bCompact )
  {
  $arrFields['name']     = array(TRUE, $L['Users'], 'th_t th_t_ref th_t_first', 'width:150px');
  }
  else
  {
  $arrFields['avatar']   = array(FALSE,$L['Avatar'], 'th_t th_t_sta th_t_first', 'width:130px');
  $arrFields['name']     = array(TRUE, $L['Users'], 'th_t th_t_ref', 'width:150px');
  }
  $arrFields['role']     = array(TRUE, $L['Role'], 'th_t th_t_sta', '');
  $arrFields['location'] = array(TRUE, $L['Location'], 'th_t th_t_sta', '');
  if ( $bCompact )
  {
  $arrFields['mail']     = array(FALSE,$L['Email'], 'th_t th_t_sta', 'width:25px');
  $arrFields['www']      = array(FALSE,'www', 'th_t th_t_sta', 'width:25px');
  }
  $arrFields['firstdate']= array(TRUE, $L['Joined'], 'th_t th_t_sta', '');
  $arrFields['numpost']  = array(TRUE, $L['Messages'], 'th_t th_t_sta th_t_last', '');
  /* ======== */
  TableHeader($arrFields,$intCount,"$oVIP->selfurl?group=$strGroup&amp;page=1",$strOrder,$strDirec);
  /* ======== */

echo '</tr>',N;

  /* ======== */
  $strState = 'id,name,role,location,mail,www,firstdate,numpost,privacy,avatar,x,y FROM '.TABUSER.$where;
  $strQ = LimitSQL($strState,$strOrder.' '.$strDirec,$intLimit,$_SESSION[QT]['topics_per_page'],$intCount);
  $oDB->Query($strQ);
  /* ======== */

  $strAlt='1';

  For ($i=0;$i<$_SESSION[QT]['topics_per_page'];$i++)
  {
    $row = $oDB->Getrow();
    if ( !$row ) break;

    $strMail = '<img class="ico ico_user" src="'.$_SESSION[QT]['skin_dir'].'/ico_user_e_0.gif" alt="mail" title="no e-mail"/>';
    if ( !empty($row['mail']) ) {
      if ( $row['privacy']=='2' ) $strMail = AsEmails($row['mail'],$row['id'],'0','img'.($_SESSION[QT]['javamail']=='1' ? 'java' : ''),false,$_SESSION[QT]['skin_dir'],'Java protected email','&nbsp;','; ');
      if ( $row['privacy']=='1' && $oVIP->role!='V' ) $strMail = AsEmails($row['mail'],$row['id'],'0','img'.($_SESSION[QT]['javamail']=='1' ? 'java' : ''),false,$_SESSION[QT]['skin_dir'],'Java protected email','&nbsp;','; ');
      if ( $oVIP->id==$row['id'] || $oVIP->role=='A' || $oVIP->role=='M' ) $strMail = AsEmails($row['mail'],$row['id'],'0','img'.($_SESSION[QT]['javamail']=='1' ? 'java' : ''),false,$_SESSION[QT]['skin_dir'],'Java protected email','&nbsp;','; ');
    }

    $strPhone = '';
    if ( !empty($row['phone']) )
    {
      if ( $row['privacy']=='2' ) $strPhone=$row['phone'];
      if ( $row['privacy']=='1' && $oVIP->role!='V' ) $strPhone=$row['phone'];
      if ( $oVIP->role=='A' || $oVIP->role=='M' ) $strPhone=$row['phone'];
    }

    if ($row['www']=='')
    {
    $www = '<img class="ico ico_user" src="'.$_SESSION[QT]['skin_dir'].'/ico_user_w_0.gif" alt="www" title="'.$L['No_Website'].'"/>';
    }
    else
    {
    $www = '<a href="'.$row['www'].'"><img class="ico ico_user" src="'.$_SESSION[QT]['skin_dir'].'/ico_user_w_1.gif" alt="www" title="'.$L['Website'].'"/></a>';
    }

    echo '<tr>'.N;
    if ( $bCompact )
    {
    echo '<td class="td_t td_t_ref',$strAlt,'"><a href="qti_usr.php?id=',$row['id'],'">',$row['name'],'</a></td>',N;
    echo '<td class="td_t td_t_sta',$strAlt,'"><span class="small">',$L['Userrole'][$row['role']],'</span></td>',N;
    echo '<td class="td_t td_t_sta',$strAlt,'">',(empty($row['location']) ? '' : '<span class="small">'.$row['location'].'<span><br/>'),(empty($strPhone) ? '' : '<span class="small">'.$strPhone.'</span>'),'</td>',N;
    echo '<td class="td_t td_t_sta',$strAlt,'">',$strMail,'</td>',N;
    echo '<td class="td_t td_t_sta',$strAlt,'">',$www,'</td>',N;
    }
    else
    {
    echo '<td class="td_t td_t_sta',$strAlt,'">',(empty($row['avatar']) ? S : AsImg('avatar/'.$row['id'].'.'.$row['avatar'],null,$row['name'],'imagelist',null,'qti_usr.php?id='.$row['id']) ),'</td>',N;
    echo '<td class="td_t td_t_ref',$strAlt,'"><a href="qti_usr.php?id=',$row['id'],'">',$row['name'],'</a></td>',N;
    echo '<td class="td_t td_t_sta',$strAlt,'"><span class="small">',$L['Userrole'][$row['role']],'</span></td>',N;
    echo '<td class="td_t td_t_sta',$strAlt,'">',(empty($row['location']) ? '' : '<span class="small">'.$row['location'].'</span><br/>'),(empty($strPhone) ? '' : '<span class="small">'.$strPhone.'</span><br/>'),$strMail,' ',$www,'</td>',N;
    }
    echo '<td class="td_t td_t_sta',$strAlt,'">',QTdate($row['firstdate'],$arrQTdate),'</td>',N;
    echo '<td class="td_t td_t_sta',$strAlt,'">',$row['numpost'],'</td>',N;
    echo '</tr>',N;

    if ( $strAlt=='1' ) { $strAlt='2'; } else { $strAlt='1'; }

    if ( $bMap && !empty($row['x']) && !empty($row['y']) )
    {
      $str = $row['name'].'<br/><br/><a class="a_gmap" href="qti_usr.php?id='.$row['id'].'">Open profile &raquo;</a>';
      if ( !empty($row['avatar']) )
      {
      $str = '<table class="ta_gmap"><tr><td>'.AsImg('avatar/'.$row['id'].'.'.$row['avatar'],null,$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']['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'];
      $arrMapPoints[intval($row['id'])] = $oMapPoint;
    }
  }

echo '<tr class="tr_t">',N;
echo '<td class="tf_t tf_t_first"></td>',N;
For ($i=0;$i<(count($arrFields)-2);$i++)
{
echo '<td class="tf_t"></td>',N;
}
echo '<td class="tf_t tf_t_last"></td>',N;
echo '</tr>
</table>
';

// -- Display pager --

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

// MAP MODULE

if ( $bMap )
{
  if ( count($arrMapPoints)==0 )
  {
  echo '<p class="p_gmap">'.$L['map']['E_noposition'].'</p>';
  }
  else
  {

     //select zoomto (maximum 15 items in the list)
     if ( count($arrMapPoints)>1 )
     {
       $str = '<p class="p_gmap" style="margin:0 0 4px 0"><a class="a_gmap" href="javascript:void(0)" onclick="zoomToFullExtend(); return false;">'.$L['map']['zoomtoall'].'</a> | '.$L['Goto'].' <select class="gmap" id="zoomto" name="zoomto" size="1" onchange="map.setCenter(eval(this.value));">';
       $str .= '<option class="gmap" value="new GLatLng('.QTgety($_SESSION[QT]['m_map_gcenter']).','.QTgetx($_SESSION[QT]['m_map_gcenter']).')"> </option>';
       $i=0;
       foreach ( $arrMapPoints as $intKey => $oMapPoint )
       {
       $str .= '<option class="gmap" value="new GLatLng('.$oMapPoint->y.','.$oMapPoint->x.')">'.$oMapPoint->title.'</option>';
       $i++; if ( $i>15 ) break;
       }
       $str .= '</select></p>';
     }

  echo '
  <table class="ta_hidden" style="margin-top:5px;">
  <tr class="tr_hidden">
  <td class="div_gmap">
  ',( count($arrMapPoints)>1 ? $str :'' ),'
  <div id="map_canvas" style="width:100%; height:350px;"></div>
  <p class="p_gmap" style="margin:4px 0 0 0">',sprintf($L['map']['items'],strtolower( LangS('User',count($arrMapPoints))),strtolower(LangS('User',$_SESSION[QT]['sys_members'])) ),'</p>
  </td>
  </tr>
  </table>
  ';
  }
}

// HTML END

if ( $bMap ) {
if ( count($arrMapPoints)>0 ) {

  $y = floatval(QTgety($_SESSION[QT]['m_map_gcenter']));
  $x = floatval(QTgetx($_SESSION[QT]['m_map_gcenter']));

  // center on the first ticket
  foreach ($arrMapPoints as $intKey => $oMapPoint)
  {
    if ( !empty($oMapPoint->y) && !empty($oMapPoint->x) )
    {
    $y = $oMapPoint->y;
    $x = $oMapPoint->x;
    break;
    }
  }

  $strFooterAddScript = QTgmappoints($L['map'],$y,$x,'click',$arrMapPoints).N.'mapload();';

}}

include('qti_p_footer.php');

?>
Return current item: QuickTicket