<?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('V2') ) HtmlPage(11);
include('bin/qti_fn_sql.php');
$s = -1; QThttpvar('s','int'); if ( $s<0 ) die('Missing section id...');
// ---------
// SUBMITTED
// ---------
if ( isset($_POST['Mok']) )
{
if ( $_POST['Maction']=='nt' ) $oHtml->Redirect('qti_form_edit.php?s='.$s.'&a=nt',$L['Post_new_topic']);
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 ( $_POST['d_last']==='-' || $_POST['d_last']==='' ) { unset($_SESSION[QT]['lastcolumn']); } else { $_SESSION[QT]['lastcolumn']=$_POST['d_last']; } // can be '0' (none)
}
// ---------
// INITIALISE
// ---------
$oSEC = new cSection($s);
if ( isset($_SESSION[QT]['lastcolumn']) ) $oSEC->d_last=$_SESSION[QT]['lastcolumn'];
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 = '';
$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'];
// Criteria sql: topics visible for current user ONLY
$strWhere = '';
if ( $oSEC->type==2 && !$oVIP->IsStaff() ) $strWhere .= ' AND (t.firstpostuser='.$oVIP->id.' OR t.type="A")';
if ( $_SESSION[QT]['show_closed']=='0' ) $strWhere.=' AND t.status<>"Z"';
$strOnTop = '';
if ( $_SESSION[QT]['news_on_top']==1 )
{
$strOnTop = 'CASE t.type WHEN "A" THEN "A" ELSE "Z" END as typea,';
if ( $oDB->type=='access' ) $strOnTop = 't.type as typea,';
}
// Count topics visible for current user ONLY
$oDB->Query( 'SELECT count(*) as countid FROM '.TABTOPIC.' t WHERE t.forum='.$oSEC->id.$strWhere );
$row = $oDB->Getrow();
$oSEC->items = intval($row['countid']);
// MAP MODULE
if ( UseModule('map') ) { $strCheck=$s; include('qtim_map_ini.php'); } else { $bMap=false; }
// --------
// HTML START
// --------
$strHeadScript = '
<script type="text/javascript" src="bin/qt_jquery.js"></script>
<script type="text/javascript">
<!--
$(document).ready(function() {
$(".tag").hover(function() {
var oTag = $(this);
$.post("qti_j_tag.php",{s:"'.$s.'",val:oTag.html(),lang:"'.GetIso().'",na:"..."}, function(data) { oTag.attr({title:data}); } );
});
});
-->
</script>
';
$oHtml->scripts = array();
include('qti_p_header.php');
// SECTION OPTIONS
if ( $oSEC->status==1 )
{
$strCommand = '<td class="button" style="width:120px"><span class="button_off"> '.$L['E_section_closed'].' </span></td>';
}
else
{
$strCommand = '<td class="button" style="width:120px"> <a class="button" href="'.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="button" style="width:120px"><span class="button_off"> '.$L['Post_new_topic'].' </span></td>';
}
}
$strCommand .= ( $oSEC->items<3 || $_SESSION[QT]['board_offline']=='1' || ($oVIP->role=='V' && $_SESSION[QT]['visitor_right']<5) ? '' : '<td class="button" style="width:30px"><span class="button"> '.AsImg($_SESSION[QT]['skin_dir'].'/ico_search.gif','Search',$L['Search'],'ico i_topic','','qti_search.php?s='.$s).' </span></td>' );
// BUTTON LINE AND PAGER
$strPager = MakePager("$oVIP->selfurl?s=$oSEC->id&order=$strOrder&dir=$strDirec",$oSEC->items,$_SESSION[QT]['topics_per_page'],$intPage);
if ($strPager!='') $strPager = $L['Page'].$strPager;
// BUTTONS
$strCommand = ( QTI_BACKBUTTON ? '<td class="button" style="width:20px"><a href="'.Href($oVIP->exiturl).'" class="button">'.QTI_BACKBUTTON.'</a></td>' : '').$strCommand;
// Moderator Actions
if ( $oVIP->IsStaff() )
{
$arr = array('views'=>$L['Views'],'status'=>$L['Status'],'actorname'=>$L['Userrole_MA']);
if ( $oSEC->wisheddate!=0 ) $arr['wisheddate']=$L['Wisheddate'];
if ( $oSEC->notifycc!=0 ) $arr['notifiedname']=$L['Userrole_UN'];
if ( !empty($_SESSION[QT]['tags']) ) $arr['tags']=$L['Tags'];
echo '
<form method="post" action="',Href(),'?s=',$s,'" id="modaction">
<div class="modboard">
<span class="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=""> </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="d_last" name="d_last" class="small" onchange="document.getElementById(\'action_ok\').click();">';
echo '<option value=""> </option>';
echo QTasTag($arr,'',array('current'=>$oSEC->d_last,'classC'=>'bold'));
echo '<option value="-" disabled="disabled">---------------</option>
<option value="none"'.($oSEC->d_last=='none' ? ' class="bold"' : '').' class="small">('.$L['None'].')</option>
<option value="-" disabled="disabled">---------------</option>
<option value="modifdate" class="small">',$L['Modified'],'</option>
<option value="id" class="small">Id</option>
';
if ( $bMap ) echo '<option value="coord" class="small">',$L['Coord'],'</option>
';
echo '
</select> <input type="submit" name="Mok" value="',$L['Ok'],'" class="small" id="action_ok" />
<script type="text/javascript">document.getElementById("action_ok").style.display="none";</script>
</span>
</div>
</form>
';
}
// End Moderator actions
if ($_SESSION[QT]['section_desc']=='1')
{
if (!empty($oSEC->descr)) echo '<p id="sectiondesc">',$oSEC->descr,'</p>',N;
}
echo '<table class="button button_top" cellspacing="0"><tr class="button">',$strCommand,'<td id="pager_zt"> ',$strPager,'</td></tr></table>
';
// End if no results
if ( $oSEC->items==0 ) { TableEmpty($L['E_no_topic'].'...'); include('qti_p_footer.php'); exit; }
// LIST TOPICS
// Last column: can be '0' (moderator requests no-field)
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">
<tr class="data_t">
';
// ========
$arrFLD = array();
$arrFLD = array();
$arrFLD['icon'] = new cFLD('icon','•','colhd colhdico colhdfirst','','colct colico colfirst','','ASC'); $arrFLD['icon']->uid='status';
if ( $oSEC->numfield!='N' )
$arrFLD['numid'] = new cFLD('numid',$L['Ref'],'colhd colhdref','','colct colref','','DESC');
if ( !empty($oSEC->prefix) )
$arrFLD['smile'] = new cFLD('smile',' ','colhd colhdsmi','','colct colsmi');
$arrFLD['title'] = new cFLD('title',$L['Topics'],'colhd','','colct','','DESC');
if ( QTI_LIST_ME )
$arrFLD['you'] = new cFLD('you',' ','colhd center','width:10px','colct center');
$arrFLD['firstpostname'] = new cFLD('firstpostname',$L['Author'],'colhd','width:140px','colct','','ASC');
$arrFLD['lastpostdate'] = new cFLD('lastpostdate',$L['Last_message'],'colhd','width:140px','colct','','ASC');
if ( $oSEC->d_last=='none' || empty($oSEC->d_last) || $oSEC->d_last=='N' || $oSEC->d_last=='replies' )
{
$arrFLD['replies'] = new cFLD('replies',$L['Replys'],'colhd center colhdlast','width:75px','colct center collast','','DESC');
}
else
{
$arrFLD['replies'] = new cFLD('replies',$L['Replys'],'colhd center','width:75px','colct center','','DESC');
$arrFLD[$oSEC->d_last] = new cFLD($oSEC->d_last,$str,'colhd center colhdlast','width:80px','colct center collast','',($oSEC->d_last=='tags' ? FALSE : 'ASC'));
}
if ( isset($arrFLD['numid']) || isset($arrFLD['status']) )
{
$arrStatusStyles=array();
foreach($oVIP->statuses as $id=>$arrStatus) if ( !empty($arrStatus['color']) ) $arrStatusStyles[$id]=$arrStatus['color'];
if ( isset($arrFLD['status']) ) $arrFLD['status']->style_dynamic=array('background-color:%s','status',$arrStatusStyles);
if ( isset($arrFLD['numid']) ) $arrFLD['numid']->style_dynamic=array('background-color:%s','status',$arrStatusStyles);
}
// ========
TableHeader($arrFLD,$oSEC->items,"$oVIP->selfurl?s=$oSEC->id&page=1",$strOrder,$strDirec);
// ========
echo '</tr>',N;
// ========
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 = $strOnTop.'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' ) { $strFullOrder='p.title'; } else { $strFullOrder='t.'.$strOrder; }
$oDB->Query( LimitSQL($strState,(empty($strOnTop) ? '' : 'typea DESC, ').$strFullOrder.' '.$strDirec,$intLimit,$_SESSION[QT]['topics_per_page'],$oSEC->items) );
// ========
$intWhile=0;
$strAlt='r1';
while($row=$oDB->Getrow())
{
TableRowShow($arrFLD,TableRowFormat($arrFLD,$row,true,$oSEC,$bMap),'data_t '.$strAlt,$row);
if ( $strAlt=='r1' ) { $strAlt='r2'; } else { $strAlt='r1'; }
$intWhile++;
//odbcbreak
if ( $intWhile>=$_SESSION[QT]['topics_per_page'] ) break;
}
// ========
echo '<tr class="colft">',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>',N;
echo '</tr>
</table>
';
// BUTTON LINE AND PAGER
$strCsv ='';
$strCalendar ='';
// calendar
if ( 1==1 )
{
$strCalendar = '<a class="tablecommand csv" href="'.Href('qti_calendar.php').'?s='.$s.'" title="Calendar view">Calendar view</a>';
}
// export define csv options according to $oSEC->items (max 10000)
if ( $oVIP->role!='V' )
{
if ( $oSEC->items<=$_SESSION[QT]['topics_per_page'] )
{
$strCsv = '<a class="tablecommand csv" href="'.Href('qti_topics_csv.php').'?s='.$s.'&size=all&n='.$oSEC->items.'" title="'.$L['H_Csv'].'">'.$L['Csv'].'</a>';
}
else
{
$strCsv = '<a class="tablecommand csv" href="'.Href('qti_topics_csv.php').'?s='.$s.'&size=p'.$intPage.'&n='.$oSEC->items.'&order='.$strOrder.'&dir='.$strDirec.'" title="'.$L['H_Csv'].'">'.$L['Csv'].' ('.strtolower($L['Page']).')</a>';
if ( $oSEC->items<=1000 ) $strCsv .= ' · <a class="tablecommand csv" href="'.Href('qti_topics_csv.php').'?s='.$s.'&size=all&n='.$oSEC->items.'&order='.$strOrder.'&dir='.$strDirec.'" title="'.$L['H_Csv'].'">'.$L['Csv'].' ('.strtolower($L['All']).')</a>';
if ( $oSEC->items>1000 && $oSEC->items<=2000 ) $strCsv .= ' · <a class="tablecommand csv" href="'.Href('qti_topics_csv.php').'?s='.$s.'&size=m1&n='.$oSEC->items.'&order='.$strOrder.'&dir='.$strDirec.'" title="'.$L['H_Csv'].'">'.$L['Csv'].' (1-1000)</a> · <a class="tablecommand csv" href="'.Href('qti_topics_csv.php').'?s='.$s.'&size=m2&n='.$oSEC->items.'" title="'.$L['H_Csv'].'">'.$L['Csv'].' (1000-'.$oSEC->items.')</a>';
if ( $oSEC->items>2000 && $oSEC->items<=5000 ) $strCsv .= ' · <a class="tablecommand csv" href="'.Href('qti_topics_csv.php').'?s='.$s.'&size=m5&n='.$oSEC->items.'&order='.$strOrder.'&dir='.$strDirec.'" title="'.$L['H_Csv'].'">'.$L['Csv'].' (1-5000)</a>';
if ( $oSEC->items>5000 ) $strCsv .= ' · <a class="tablecommand csv" href="'.Href('qti_topics_csv.php').'?s='.$s.'&m=5&n='.$oSEC->items.'&order='.$strOrder.'&dir='.$strDirec.'" title="'.$L['H_Csv'].'">'.$L['Csv'].' (1-5000)</a> · < class="tablecommand csv"a href="'.Href('qti_topics_csv.php').'?s='.$s.'&m=10&n='.$oSEC->items.'" title="'.$L['H_Csv'].'">'.$L['Csv'].' (5000-10000)</a>';
}
}
if ( !empty($strCsv) )
{
$strPager = $strCsv.' · '.$strPager;
}
if ( !empty($strCalendar) )
{
$strPager = $strCalendar.' · '.$strPager;
}
if ( substr($strPager,-10,10)==' · ' ) $strPager = substr($strPager,0,-10);
// display button, pager and csv
if ( $oSEC->items>2 )
{
echo '<table class="button button_bot" cellspacing="0"><tr class="button">',$strCommand,'<td id="pager_zb"> ',$strPager,'</td></tr></table>
';
}
else
{
echo '<p id="pager_zb" class="csv"> ',$strPager,'</p>';
}
// TAGS FILTRING
if ( QTI_LIST_TAG && !empty($_SESSION[QT]['tags']) )
{
require_once('bin/qti_fn_tags.php');
$arrTags = cSection::GetTagsUsed($s,50);
if ( count($arrTags)>0 )
{
if ( count($arrTags)>5 )
{
echo '<p class="tagbox">'.$L['Show_only_tag'],'</p><div class="tagbox">';
foreach($arrTags as $strTag)
{
echo '<a class="tag',(count($arrTags)>12 ? ' small' : ''),'" href="',Href('qti_find.php'),'?a=tst&s=',$s,'&y=',date('Y'),'&k1=-1&k2=-1&k3=',$strTag,'">',$strTag,'</a> ';
}
echo '</div>';
}
else
{
echo '<p class="tagline">'.$L['Show_only_tag'];
foreach($arrTags as $strTag)
{
echo ' <span class="tagline" title=""><a class="tag" href="',Href('qti_find.php'),'?a=tst&s=',$s,'&y=',date('Y'),'&k1=-1&k2=-1&k3=',$strTag,'">',$strTag,'</a></span>';
}
echo '</p>';
}
}
}
// MAP MODULE
if ( $bMap )
{
if ( count($arrExtData)==0 )
{
echo '<p class="gmap">'.$L['map']['E_noposition'].'</p>';
}
else
{
//select zoomto (maximum 15 items in the list)
if ( count($arrExtData)>1 )
{
$str = '<p class="gmap" style="margin:0 0 4px 0"><a class="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($arrExtData 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="hidden" style="margin-top:5px;">
<tr class="hidden">
<td class="gmap">
';
if ( count($arrExtData)>1 && !$_SESSION[QT]['m_map_hidelist'] ) echo $str;
if ( !$_SESSION[QT]['m_map_hidelist'] )
{
echo '<div id="map_canvas" style="width:100%; height:350px;"></div>';
}
echo '
<p class="gmap" style="margin:4px 0 0 0">',sprintf($L['map']['items'],strtolower( LangS('Topic',count($arrExtData))),strtolower(LangS('Topic',$oSEC->items)) ),'</p>
';
echo '</td>
</tr>
</table>
';
}
if ( count($arrExtData)!=0 )
{
if ( $_SESSION[QT]['m_map_hidelist'] )
{
echo '<p style="margin:2px"><a href="',Href(),'?s=',$s,'&showmap">',$L['map']['Show_map'],'</a></p>';
}
else
{
echo '<p style="margin:2px"><a href="',Href(),'?s=',$s,'&hidemap">',$L['map']['Hide_map'],'</a></p>';
}
}
}
// ---------
// 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');
?>