Location: PHPKode > projects > QuickTicket > quickticket/qti_topics_prt.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    QuickTicket
* @author     Philippe Vandenberghe <hide@address.com>
* @copyright  2008-2012 The PHP Group
* @version    2.3 build:20091102
*/

session_start();
require_once('bin/qti_init.php');
$oVIP->output='print';
if ( $_SESSION[QT]['visitor_right']<2 && $oVIP->role=='V' ) HtmlPage(11);
if ( !$oVIP->CanView('V2') ) HtmlPage(11);

$s = -1; QThttpvar('s','int'); if ( $s<0 ) die('Missing section id...');

// ---------
// INITIALISE
// ---------

include('bin/qti_fn_sql.php');

$oSEC = new cSection($s);

if ( $oSEC->type==1 && ($oVIP->role=='V' || $oVIP->role=='U') )
{
  // exit
  $oVIP->selfname = $L['Section'];
  $oVIP->exitname = ObjTrans('index','i',$_SESSION[QT]['index_name']);
  $oVIP->EndMessage(NULL,$L['R_staff'],$_SESSION[QT]['skin_dir'],0);
}
if ( $oSEC->type==2 && $oVIP->role=='V' )
{
  // exit
  $oVIP->selfname = $L['Section'];
  $oVIP->exitname = ObjTrans('index','i',$_SESSION[QT]['index_name']);
  $oVIP->EndMessage(NULL,$L['R_member'],$_SESSION[QT]['skin_dir'],0);
}

$oVIP->selfurl = 'qti_topics.php';
$oVIP->selfname = $L['Section'].': '.$oSEC->name;

$strCommand = '';
$numid = '';
$arrMe[] = array();

$strOrder = 'lastpostdate';
$strDirec = 'DESC';
$intPage = 1;
$intLimit = 0;
if ( isset($_GET['page']) ) { $intLimit = (intval($_GET['page'])-1)*$_SESSION[QT]['topics_per_page']; $intPage = intval($_GET['page']); }
if ( isset($_GET['order']) ) $strOrder = $_GET['order'];
if ( isset($_GET['dir']) ) $strDirec = $_GET['dir'];

// MAP MODULE

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

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

include('qti_p_header.php');

echo '
<h2>',$oSEC->name,'</h2>
';

// SECTION OPTIONS

$strWhere = '';
if ( $oSEC->type==2 && !$oVIP->IsStaff() ) $strWhere = ' AND t.firstpostuser='.$oVIP->id;
if ( $_SESSION[QT]['show_closed']=='0' ) $strWhere.=' AND t.status<>"Z"'; 

// BUTTON LINE AND PAGER

$oDB->Query('SELECT count(t.id) as countid FROM '.TABTOPIC.' t WHERE t.forum='.$oSEC->id.$strWhere);
$row = $oDB->Getrow();
$intCount = $row['countid'];
$strPager = MakePager("$oVIP->selfurl?s=$oSEC->id",$intCount,$_SESSION[QT]['topics_per_page'],$intPage);
if ($strPager!='') $strPager = $L['Page'].$strPager;

if ($_SESSION[QT]['section_desc']=='1')
{
  if (!empty($oSEC->descr)) echo '<!-- Section description -->',N,'<p id="sectiondesc">',$oSEC->descr,'</p>',N,'<!-- Section description -->',N,N;
}

echo '
<!-- Button and pager -->
<table class="button button_top" cellspacing="0">
<tr class="button">',S,'<td id="pager_zt">',$strPager,'</td>
</tr>
</table>
<!-- End button and pager -->
';

// DISPLAY

if ( $intCount==0 )
{
  echo '<br/>',$L['None'],'... ',$L['E_topic_private'],'<br/><br/>',N;
  include('qti_p_footer.php');
  exit;
}

// LIST TOPICS

// Last column: can be '0' (moderator requests no-field)
if ( !empty($_SESSION[QT]['lastcolumn']) ) $oSEC->d_last = $_SESSION[QT]['lastcolumn'];
switch($oSEC->d_last)
{
case 'replies': $str=$L['Replys']; break;
case 'views': $str=$L['Views']; break;
case 'status': $str=$L['Status']; break;
case 'wisheddate': $str=$L['Wisheddate']; break;
case 'id': $str='Id'; break;
case 'actorname': $str=$L['Userrole_MA']; break;
case 'notifiedname': $str=$L['Userrole_UN']; break;
case 'tags': $str=$L['Tags']; break;
case 'modifdate': $str=$L['Modified']; break;
case 'coord': $str=$L['Coord']; break;
default: $str=$oSEC->d_last;
}

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

// ========
$arrFLD = array();
$oFLD = new cFLD('icon','&nbsp;'); $oFLD->uid='status';$oFLD->desc='class=th_t th_t_ico th_t_first'; $arrFLD['icon']=$oFLD;
$oFLD = new cFLD('numid',$L['Ref']);                   $oFLD->desc='class=th_t th_t_ref;style=background-color:%bg'; if ( $oSEC->numfield!='N' ) $arrFLD['numid']=$oFLD;
$oFLD = new cFLD('smile','&nbsp;');                    $oFLD->desc='class=th_t th_t_smi'; if ( !empty($oSEC->prefix) ) $arrFLD['smile']=$oFLD;
$oFLD = new cFLD('title',$L['Topics']);                $oFLD->desc='class=th_t th_t_tit'; $arrFLD['title']=$oFLD;
$oFLD = new cFLD('you','&nbsp;');                      $oFLD->desc='class=th_t th_t_inf;style=width:10px'; if ( QTI_LIST_ME ) $arrFLD['you']=$oFLD;
$oFLD = new cFLD('firstpostname',$L['Topic_starter']); $oFLD->desc='class=th_t th_t_inf'; $arrFLD['firstpostname']=$oFLD;
$oFLD = new cFLD('lastpostdate',$L['Last_message']);   $oFLD->desc='class=th_t th_t_inf'; $arrFLD['lastpostdate']=$oFLD;
if ( $oSEC->d_last=='none' || empty($oSEC->d_last) || $oSEC->d_last=='N' || $oSEC->d_last=='replies' )
{
$oFLD = new cFLD('replies',$L['Replys']); $oFLD->desc='class=th_t th_t_sta th_t_last'; $arrFLD['replies']=$oFLD;
}
else
{
$oFLD = new cFLD('replies',$L['Replys']); $oFLD->desc='class=th_t th_t_sta'; $arrFLD['replies']=$oFLD;
$oFLD = new cFLD($oSEC->d_last,$str);     $oFLD->desc='class=th_t th_t_sta th_t_last'.($oSEC->d_last=='status' ? ';style=background-color:%bg' : ';style=width:80x'); $arrFLD[$oSEC->d_last]=$oFLD;
}
// ========
TableHeader($arrFLD,$intCount,"$oVIP->selfurl?s=$oSEC->id&amp;page=1",$strOrder,$strDirec);
// ========

echo '</tr>',N;

foreach($arrFLD as $strKey=>$oFLD) if ( !empty($oFLD->desc) ) { $oFLD->desc = str_replace('th_','td_',$oFLD->desc); $arrFLD[$strKey]=$oFLD; }
// ========
if ( QTI_LIST_ME && $oVIP->numpost>0 ) {
if ( $oSEC->replies>0 ) {
  $oDB->Query('SELECT topic,issuedate FROM '.TABPOST.' WHERE forum='.$s.' AND type="R" AND userid='.$oVIP->id);
  while($row=$oDB->Getrow()) $arrMe[intval($row['topic'])] = $row['issuedate'];
}}
// ========
$strState  = 't.*, p.title, p.icon, p.textmsg FROM '.TABTOPIC.' t INNER JOIN '.TABPOST.' p ON t.firstpostid=p.id WHERE t.forum='.$oSEC->id.$strWhere;
if ( $strOrder=='title' ) { $strOrder='p.title'; } else { $strOrder='t.'.$strOrder; }
if ( $_SESSION[QT]['news_on_top']==1 ) $strOrder = 't.type ASC, '.$strOrder;
$oDB->Query( LimitSQL($strState,$strOrder.' '.$strDirec,$intLimit,$_SESSION[QT]['topics_per_page'],$intCount) );
// ========
$intWhile=0;
$strAlt='r1';
while($row=$oDB->Getrow())
{
  TableRow($arrFLD,$row,true,$oSEC,$strAlt,$bMap);
  if ( $strAlt=='r1' ) { $strAlt='r2'; } else { $strAlt='r1'; }
  $intWhile++; 
  //odbcbreak
  if ( $intWhile>=$_SESSION[QT]['topics_per_page'] ) break;  
}
// ========

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

echo '<p>',LangS('Topic',$intCount),'</p>',N;

// MAP MODULE

if ( $bMap )
{
if ( count($arrExtData)==0 )
{
echo '
<p class="gmap">',$L['map']['E_noposition'],'</p>
';
}
else
{
echo '
<div class="gmap" style="margin-top:5px;width:600px;">',QTgmapZoomControl($arrExtData),'
<div id="map_canvas" style="width:100%; height:',(count($arrExtData)>2 ? '410' : '360'),'px"></div>
<p class="gmap" style="margin:4px 0 0 0">',sprintf( $L['map']['items'],count($arrExtData),strtolower(LangS('Topic',$oSEC->topics)) ),'</p>
</div>
';
}
}

// BUTTON LINE AND PAGER

if ( $intCount>2 )
{
echo '
<!-- Button and pager -->
<table class="button button_bot" cellspacing="0">
<tr class="button">',S,'<td id="pager_zb">',$strPager,'</td>
</tr>
</table>
<!-- End button and pager -->
';
}

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