Location: PHPKode > projects > QuickTicket > quickticket/qti_topic_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);

// INITIALISE

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

include('bin/qti_fn_sql.php');

$oSEC = new cSection(intval($_GET['s']));
$oTopic = new cTopic(intval($_GET['t']),$oVIP->id);

  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' && $oTopic->type!='A' )
  {
  // 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);
  }

  if ( $oSEC->type==2 && $oVIP->role=='U' && $oTopic->type!='A' && $oTopic->firstpostuser!=$oVIP->id )
  {
  // exit
  $oVIP->selfname = $L['Section'];
  $oVIP->exitname = ObjTrans('index','i',$_SESSION[QT]['index_name']);
  $oVIP->EndMessage(NULL,$L['E_topic_private']."<br/>".$L['R_member'],$_SESSION[QT]['skin_dir'],0);
  }

$strCommand= '';
$intLimit = 0;
$PAGEcurr = 1;
if (isset($_GET['page'])) { $intLimit = ($_GET['page']-1)*$_SESSION[QT]['replies_per_page']; $PAGEcurr=$_GET['page']; }
if (isset($_GET['view'])) { $_SESSION[QT]['viewmode'] = $_GET['view']; }

$oVIP->selfurl = 'qti_topic.php';
$oVIP->exiturl = 'qti_topics.php?s='.$_GET['s'];
$oVIP->selfname = $L['Messages'];

// MAP MODULE

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

// MAP DATA

if ( $bMap ) {
if ( !empty($oTopic->y) && !empty($oTopic->x) ) {

  $y = floatval($oTopic->y);
  $x = floatval($oTopic->x);
  $strPname = ( $oSEC->numfield=='N' ? $oTopic->numid : sprintf($oSEC->numfield,$oTopic->numid) );
  $strPlink = '<a class="small" href="http://maps.google.com?q='.$y.','.$x.'+('.urlencode($strPname).')&z='.$_SESSION[QT]['m_map_gzoom'].'" title="'.$L['map']['In_google'].'" target="_blank">[G]</a>';
  if ( $_SESSION[QT]['viewmode']=='C' )
  {
  $strPinfo = '<span class="small bold">Lat: '.QTdd2dms($y).' <br/>Lon: '.QTdd2dms($x).'</span><br/><span class="small">DD: '.round($oTopic->y,8).', '.round($oTopic->x,8).'</span><br/>'.$strPlink;
  }
  else
  {
  $strPinfo = '<span class="bold">Lat: '.QTdd2dms($y).' <br/>Lon: '.QTdd2dms($x).'</span><br/><span class="small">DD: '.round($oTopic->y,8).', '.round($oTopic->x,8).'</span><br/><br/>'.$strPlink;
  }
  $oMapPoint = new cMapPoint($y,$x,$strPname,$strPinfo);
  if ( isset($_SESSION[QT]['m_map'][$s]['icon']) )        $oMapPoint->icon        = $_SESSION[QT]['m_map'][$s]['icon'];
  if ( isset($_SESSION[QT]['m_map'][$s]['shadow']) )      $oMapPoint->shadow      = $_SESSION[QT]['m_map'][$s]['shadow'];
  if ( isset($_SESSION[QT]['m_map'][$s]['printicon']) )   $oMapPoint->printicon   = $_SESSION[QT]['m_map'][$s]['printicon'];
  if ( isset($_SESSION[QT]['m_map'][$s]['printshadow']) ) $oMapPoint->printshadow = $_SESSION[QT]['m_map'][$s]['printshadow'];
  $arrExtData = array( $oMapPoint );

}}

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

include('qti_p_header.php');

echo '<p>',$oSEC->name,'</p>
<h2>',( $oSEC->numfield=='N' ? '' : sprintf($oSEC->numfield,$oTopic->numid).' &middot; ' ),$oVIP->statuses[$oTopic->status]['statusname'],'</h2>';

// map module
if ( $bMap )
{
  if ( !empty($oTopic->y) && !empty($oTopic->x) )
  {
  if ( $_SESSION[QT]['viewmode']=='C' )
  {
  echo '
  <div class="gmap" style="margin-bottom:5px;width:375px;">
  <div id="map_canvas" style="width:100%; height:200px;"></div>
  </div>
  ';
  }
  else
  {
  echo '
  <div class="gmap" style="margin-bottom:5px;width:500px;">
  <div id="map_canvas" style="width:100%; height:350px;"></div>
  </div>
  ';
  }
  echo '<p>',$L['Coord'],': ',QTdd2dms(floatval($oTopic->y)),', ',QTdd2dms(floatval($oTopic->x)),' ',$L['Coord_latlon'],' <span class="small disabled">DD ',round(floatval($oTopic->y),8),',',round(floatval($oTopic->y),8),'</span></p>';
  }
  else
  {
  echo '<p class="gmap">'.$L['map']['E_noposition'].'</p>';
  }
}

// COUNT RECORDS

$oDB->Query('SELECT count(*) as countid FROM '.TABPOST.' p WHERE p.forum='.$oSEC->id.' AND p.topic='.$oTopic->id);
$row = $oDB->Getrow();
$intPosts = $row['countid'];

// CONTENT

// -- stop if no post (or user not creator) --

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

// ======
$state = 'p.*, u.role, u.location, u.photo, u.signature FROM '.TABPOST.' p, '.TABUSER.' u WHERE p.userid = u.id AND p.topic='.$oTopic->id;
$oDB->Query( LimitSQL($state,'p.id ASC',$intLimit,$_SESSION[QT]['replies_per_page'],$intPosts) );
// ======
$iMsgNum = $intLimit;
$intWhile= 0;
$strAlt  = 'r1';
// ======
while ( $row=$oDB->Getrow() )
{
  $iMsgNum = $iMsgNum+1;
  $oPost = new cPost($row,$iMsgNum);
  if ( $_SESSION[QT]['viewmode']=='C' ) $oPost->text = QTcompact($oPost->text,0);
  $strButton = '';
  if ( !empty($oPost->modifuser) ) $strButton .= '<td class="td_line"><span class="small">&nbsp;'.$L['Modified_by'].' <a href="qti_usr.php?id='.$oPost->modifuser.'" class="small">'.$oPost->modifname.'</a> ('.QTdatestr($oPost->modifdate).')</span></td>'.N;
  if ( !empty($strButton) ) $strButton .= '<td class="hidden">&nbsp;</td>'.N;
  if ( !empty($strButton) ) $strButton = '<table class="hidden" cellspacing="0" style="margin:10px 0 1px 0;"><tr>'.$strButton.'</tr></table>'.N;

  // SHOW MESSAGE

  $oPost->Show($oSEC,$oTopic,true,$strButton,'',$_SESSION[QT]['skin_dir'],$strAlt);
  if ( $strAlt=='r1' ) { $strAlt='r2'; } else { $strAlt='r1'; }
  $intWhile++;

  // SHOW TAGS
  
  if ( $oPost->type=='P' && $_SESSION[QT]['tags']!='0' ) {
  if ( !empty($oTopic->tags) ) {
    $arrTags=explode(';',$oTopic->tags);
    echo '<div class="tags">',$L['Tags'],': ';
    foreach($arrTags as $strTag)
    {
    echo $strTag,'&nbsp; ';
    }  
    echo '</div>';
  }}
}
// ======

// --------
// HTML END
// --------

// MAP MODULE

if ( $bMap )
{
  if ( count($arrExtData)>0 ) { $bSmallMap=($_SESSION[QT]['viewmode']=='C'); 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