<?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 ( $_SESSION[QT]['visitor_right']<2 && $oVIP->role=='V' )
{
include('qti_p_header.php');
HtmlMsg(0);
echo $L['R_login_register'];
HtmlMsg(1);
include('qti_p_footer.php');
exit;
}
if ( !$oVIP->CanAccess('MUV',2,true) ) $oVIP->EndMessage('!',$L['R_member'],$_SESSION[QT]['skin_dir'],0);
$s = -1;
if ( isset($_GET['s']) ) $s = intval(strip_tags($_GET['s']));
if ( isset($_POST['s']) ) $s = intval(strip_tags($_POST['s']));
if ( $s<0 ) die('Missing section id...');
// ---------
// SUBMITTED
// ---------
if ( isset($_POST['Mok']) )
{
if ( $_POST['Maction']=='nt' )
{
if ( headers_sent() )
{
echo '<a href="qti_form_edit.php?s=',$s,'&a=nt">',$L['Post_new_topic'],'</a><meta http-equiv="REFRESH" content="0;url=qti_form_edit.php?s=',$s,'&a=nt">';
}
else
{
header('Location: qti_form_edit.php?s='.$s.'&a=nt');
}
exit;
}
if ( $_POST['Maction']=='show_Z' ) $_SESSION[QT]['show_closed']='1';
if ( $_POST['Maction']=='hide_Z' ) $_SESSION[QT]['show_closed']='0';
if ( $_POST['Maction']=='print' )
{
echo 'No yet developped';
exit;
}
if ( !empty($_POST['infofield']) )
{
$_SESSION[QT]['lastcolumn']=$_POST['infofield']; // can be N (none)
}
}
// ---------
// INITIALISE
// ---------
include('bin/qti_fn_limitsql.php');
$oSEC = new cSection($s);
if ( $oSEC->type==1 && ($oVIP->role=='V' || $oVIP->role=='U') )
{
// exit
$oVIP->selfname = $L['Section'];
$oVIP->exitname = ObjectName('index','i',$_SESSION[QT]['index_name']);
$oVIP->EndMessage(NULL,$L['R_moderator'],$_SESSION[QT]['skin_dir'],0);
}
if ( $oSEC->type==2 && $oVIP->role=='V' )
{
// exit
$oVIP->selfname = $L['Section'];
$oVIP->exitname = ObjectName('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 = '';
$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'];
if ($oVIP->numpost>0)
{
$oDB2 = new cDB($qti_dbsystem,$qti_host,$qti_database,$qti_user,$qti_pwd,$qti_port,$qti_dsn);
}
// MAP MODULE
$bMap = UseModule('map');
if ( $bMap ) { if ( empty($_SESSION[QT]['m_map_gkey']) ) $bMap=false; }
if ( $bMap ) { require_once('qtim_map_lib.php'); if ( !QTgcanmap($s) ) $bMap=false; }
if ( $bMap ) include(Translate('qtim_map.inc'));
// --------
// HTML START
// --------
if ( $bMap )
{
$arrMapPoints = array();
$strHeaderAddScript = QTgmapheader('http://gmaps-utility-library.googlecode.com/svn/trunk/markermanager/release/src/markermanager.js');
$strBodyAddOnunload='GUnload()';
}
$arrJava = array('com'=>false);
include('qti_p_header.php');
// FORUM OPTIONS
if ( $oSEC->status==1 )
{
$strCommand = '<td class="td_button" style="width:120px"><span class="a_button_off"> '.$L['E_section_closed'].' </span></td>';
}
else
{
$strCommand = '<td class="td_button" style="width:120px"> <a class="a_button" href="qti_form_edit.php?s='.$oSEC->id.'&a=nt">'.$L['Post_new_topic'].'</a> </td>';
if ( $oVIP->role=='V' && $_SESSION[QT]['visitor_right']<7 )
{
$strCommand = '<td class="td_button" style="width:120px"><span class="a_button_off"> '.$L['Post_new_topic'].' </span></td>';
}
}
$byuser = '';
if ( $oSEC->type==2 && $oVIP->role!='M' && $oVIP->role!='A' ) $byuser = ' AND t.firstpostuser='.$oVIP->id;
if ( !$_SESSION[QT]['show_closed'] ) $byuser .= ' AND t.status<>"Z"';
// BUTTON LINE AND PAGER
$oDB->Query('SELECT count(t.id) as countid FROM '.TABTOPIC.' t WHERE t.forum='.$oSEC->id.$byuser);
$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;
// BUTTONS
$strCommand = ( QTI_BACKBUTTON ? '<td class="td_button" style="width:20px"><a href="'.$oVIP->exiturl.'" class="a_button">'.QTI_BACKBUTTON.'</a></td>' : '').N.$strCommand.N.'<td></td>';
// Moderator Actions
if ( $oVIP->role=='M' || $oVIP->role=='A' )
{
echo '
<form method="post" action="qti_topics.php" id="modaction">
<div class="div_modboard">
<span class="span_modboard">',$L['Userrole'][$oVIP->role],' <input type="hidden" name="s" value="',$oSEC->id,'"/>
<select name="Maction" class="small" onchange="document.getElementById(\'action_ok\').click();">
<option value="">',S,'</option>
<option value="nt">',$L['Post_new_topic'],'...</option>
<option value="" disabled="disabled">---------------</option>
<option value="show_Z"',($_SESSION[QT]['show_closed'] ? ' class="bold"' : ''),'>',$L['Topic_closed_show'],'</option>
<option value="hide_Z"',(!$_SESSION[QT]['show_closed'] ? ' class="bold"' : ''),'>',$L['Topic_closed_hide'],'</option>
</select> ',$L['Last_column'],S;
echo '<select id="infofield" name="infofield" class="small" onchange="document.getElementById(\'action_ok\').click();">';
echo '<option value="">',S,'</option>';
echo QTastags($L['Last_column_label'],null,null,null,$oSEC->infofield,'bold');
echo '<option value="N" '.($oSEC->infofield=='N' ? ' class="bold"' : '').' class="small">('.$L['None'].')</option>
</select> <input type="submit" name="Mok" value="',$L['Ok'],'" class="small" id="action_ok"/>
<script type="text/javascript">
<!--
document.getElementById("action_ok").style.visibility="hidden";
document.getElementById("action_ok").value="";
-->
</script>
</span>
</div>
</form>',N;
}
// End Moderator actions
if ($_SESSION[QT]['section_desc']=='1')
{
if (!empty($oSEC->descr)) echo '<!-- Section description -->',N,'<p id="topic_sectiondescr">',$oSEC->descr,'</p>',N,'<!-- Section description -->',N,N;
}
echo '
<!-- Button and pager -->
<table class="ta_button ta_button_top" cellspacing="0">
<tr class="tr_button">',N,$strCommand,N,'<td id="zone_pager_top">',$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
$strExtra = $oSEC->infofield; // can be "N" (moderator requests no-field)
if ( !empty($_SESSION[QT]['lastcolumn']) ) $strExtra = $_SESSION[QT]['lastcolumn'];
echo '<table class="ta ta_t" cellspacing="0">',N;
echo '<tr class="tr_t tr_t0">',N;
/* ======== */
$arrFields = array(); // SORT LABEL CLASS STYLE
$arrFields['ico_status'] = array(TRUE, '-', 'th_t th_t_ico th_t_first', 'width:25px');
if ( $oSEC->numfield!='N' )
{
$arrFields['numid'] = array(TRUE, $L['Ref'], 'th_t th_t_ref', 'width:50px');
}
if ( !empty($oSEC->prefix) )
{
$arrFields['smile'] = array(FALSE,S, 'th_t th_t_smi', 'width:20px');
}
$arrFields['title'] = array(TRUE, $L['Topics'], 'th_t th_t_tit', '');
$arrFields['you'] = array(FALSE,S, 'th_t th_t_inf', 'width:10px');
$arrFields['firstpostname'] = array(TRUE, $L['Topic_starter'],'th_t th_t_inf', 'width:120px');
if ( $strExtra=='N' || $strExtra=='no' )
{
$arrFields['lastpostdate'] = array(TRUE, $L['Last_message'], 'th_t th_t_inf th_t_last', 'width:140px');
}
else
{
$arrFields['lastpostdate'] = array(TRUE, $L['Last_message'], 'th_t th_t_inf', 'width:150px');
$arrFields[$strExtra] = array(TRUE, $L['Last_column_label'][$strExtra], 'th_t th_t_inf th_t_last', 'width:75px;text-align:center');
}
/* ======== */
TableHeader($arrFields,$intCount,"$oVIP->selfurl?s=$oSEC->id&page=1",$strOrder,$strDirec);
/* ======== */
echo '</tr>',N;
/* ------ */
// check that the INNER JOIN WORKS without parentheses in all rdbms
$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.$byuser;
if ( $strOrder=='title' ) { $strOrder='p.title'; } else { $strOrder='t.'.$strOrder; }
if ( $_SESSION[QT]['news_on_top']==1 ) $strOrder = 't.type ASC, '.$strOrder;
$query = LimitSQL($strState,$strOrder.' '.$strDirec,$intLimit,$_SESSION[QT]['topics_per_page'],$intCount);
$oDB->Query($query);
/* ------ */
$bAddPrefix = !empty($oSEC->prefix);
$bAddSection = false;
if ( $oSEC->numfield=='N' ) { $bAddRef = false; } else { $bAddRef = true; }
include('qti_topics_inc.php');
/* ------ */
echo '<tr class="tr_t tr_t9">',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>
';
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 => $arrMapPoint )
{
$str .= '<option class="gmap" value="new GLatLng('.$arrMapPoint['y'].','.$arrMapPoint['x'].')">'.$arrMapPoint['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('Topic',count($arrMapPoints))),strtolower(LangS('Topic',$oSEC->topics)) ),'</p>
</td>
</tr>
</table>
';
}
}
// BUTTON LINE AND PAGER
if ( $intCount>2 )
{
echo '
<!-- Button and pager -->
<table class="ta_button ta_button_bot" cellspacing="0">
<tr class="tr_button">',N,$strCommand,N,'<td id="zone_pager_bot">',$strPager,'</td>
</tr>
</table>
<!-- End button and pager -->
';
}
// ---------
// 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');
?>