decir/viewtopic.php
author Dan
Wed, 17 Oct 2007 23:44:22 -0400
changeset 4 c31210950118
parent 2 253118325c65
child 6 3f66ec435f08
permissions -rw-r--r--
Some access controls implemented... we'll see how well this works
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     1
<?php
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     2
/*
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     3
 * Decir
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     4
 * Version 0.1
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     5
 * Copyright (C) 2007 Dan Fuhry
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     6
 * viewtopic.php - Shows individual posts
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     7
 *
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     8
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
     9
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    10
 *
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    11
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    13
 */
1
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    14
 
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    15
require('common.php');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    16
require('bbcode.php');
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    17
require('functions_viewtopic.php');
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    18
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    19
global $whos_online;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    20
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    21
if ( strtolower($paths->getParam(0)) == 'post' || isset($_GET['pid']) )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    22
{
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    23
  $pid = ( $n = $paths->getParam(1) ) ? $n : ( ( isset($_GET['pid']) ) ? $_GET['pid'] : 0 );
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    24
  $pid = intval($pid);
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    25
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    26
  if(empty($pid))
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    27
  {
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    28
    $template->header();
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    29
    echo '<p>Invalid topic ID</p>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    30
    $template->footer();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    31
    return;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    32
  }
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    33
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    34
  $q = $db->sql_query('SELECT topic_id FROM '.table_prefix.'decir_posts WHERE post_id='.$pid.';');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    35
  if ( !$q )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    36
    $db->_die();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    37
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    38
  $row = $db->fetchrow();
1
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    39
  $tid = intval($row['topic_id']);
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    40
  $db->free_result();
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    41
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    42
else
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    43
{
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    44
  $tid = ( $n = $paths->getParam(1) ) ? $n : ( ( isset($_GET['tid']) ) ? $_GET['tid'] : 0 );
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    45
  $tid = intval($tid);
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    46
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    47
  if(empty($tid))
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    48
  {
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    49
    $template->header();
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    50
    echo '<p>Invalid topic ID</p>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    51
    $template->footer();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    52
    return;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    53
  }
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    54
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    55
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    56
$q = $db->sql_query('SELECT t.forum_id, t.topic_title, f.forum_name, f.forum_id, t.topic_id, t.topic_deleted, t.topic_deletor, t.topic_delete_reason, u.username AS deletor FROM '.table_prefix.'decir_topics AS t
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    57
                       LEFT JOIN '.table_prefix.'users AS u
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    58
                         ON ( u.user_id = t.topic_deletor OR t.topic_deletor IS NULL )
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    59
                       LEFT JOIN '.table_prefix.'decir_forums AS f
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    60
                         ON ( f.forum_id = t.forum_id )
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    61
                       WHERE t.topic_id='.$tid.';');
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    62
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    63
if ( !$q )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    64
  $db->_die();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    65
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    66
$topic_exists = true;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    67
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    68
if ( $db->numrows() > 0 )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    69
{
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    70
  $row = $db->fetchrow();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    71
  $forum_id = $row['forum_id'];
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    72
  $topic_id = $row['topic_id'];
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    73
  $topic_exists = true;
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    74
  // FIXME: This will be controlled by an ACL rule
4
c31210950118 Some access controls implemented... we'll see how well this works
Dan
parents: 2
diff changeset
    75
  if ( $row['topic_deleted'] == 1 && !$session->get_permissions('decir_see_deleted_topic_full') )
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    76
  {
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    77
    $topic_exists = false;
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    78
  }
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    79
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    80
else
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    81
{
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    82
  $topic_exists = false;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    83
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    84
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    85
// Set page title
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    86
$template->tpl_strings['PAGE_NAME'] = htmlspecialchars($row['topic_title']) . ' &laquo; ' . htmlspecialchars($row['forum_name']) . ' &laquo; Forums';
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    87
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    88
$template->header();
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    89
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    90
// build breadcrumbs
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    91
echo '<div class="breadcrumbs">';
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    92
echo '<a href="' . makeUrlNS('Special', 'Forum') . '">Forum index</a> &raquo; ';
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    93
echo '<a href="' . makeUrlNS('Special', 'Forum/ViewForum/' . $row['forum_id']) . '">' . htmlspecialchars($row['forum_name']) . '</a> &raquo; ';
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    94
echo htmlspecialchars($row['topic_title']);
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    95
echo '</div>';
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    96
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    97
if ( $row['topic_deleted'] == 1 )
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    98
{
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
    99
  // User will at this point have permission to read the deleted topic (and thus restore it)
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   100
  $restore_url = makeUrlNS('Special', 'Forum/RestoreTopic/' . $topic_id, false, true);
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   101
  echo '<div class="usermessage">This topic was deleted by ' . htmlspecialchars($row['deletor']) . '. You can <a href="' . $restore_url . '">restore this topic</a>.<br />
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   102
                                 <i>Reason for deletion: ' . htmlspecialchars($row['topic_delete_reason']) . '</i></div>';
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   103
}
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   104
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   105
if ( !$topic_exists )
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   106
{
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   107
  die_friendly('Error', '<p>The topic you requested does not exist.</p>');
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   108
}
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   109
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   110
$sql = 'SELECT COUNT(post_id) AS np FROM '.table_prefix."decir_posts WHERE topic_id=$tid;";
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   111
$q = $db->sql_query($sql);
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   112
if ( !$q )
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   113
  $db->_die();
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   114
list($num_posts) = $db->fetchrow_num();
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   115
$db->free_result();
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   116
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   117
$offset = 0;
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   118
if ( $p = $paths->getParam(2) )
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   119
{
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   120
  if ( preg_match('/^start=([0-9]+)$/', $p, $m) )
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   121
  {
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   122
    $offset = intval($m[1]);
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   123
  }
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   124
}
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   125
1
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   126
$sql = 'SELECT p.post_id,p.poster_name,p.poster_id,u.username,p.timestamp,p.edit_count,p.last_edited_by,p.post_deleted,u2.username AS editor,p.edit_reason,u.user_level,u.reg_time,t.post_text,t.bbcode_uid FROM '.table_prefix.'decir_posts AS p
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   127
          LEFT JOIN '.table_prefix.'users AS u
1
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   128
            ON u.user_id=p.poster_id
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   129
          LEFT JOIN '.table_prefix.'users AS u2
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   130
            ON (u2.user_id=p.last_edited_by OR p.last_edited_by IS NULL)
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   131
          LEFT JOIN '.table_prefix.'decir_posts_text AS t
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   132
            ON p.post_id=t.post_id
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   133
          WHERE p.topic_id='.$tid.'
1
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   134
          GROUP BY p.post_id
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   135
          ORDER BY p.timestamp ASC;';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   136
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   137
$q = $db->sql_unbuffered_query($sql);
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   138
if ( !$q )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   139
  $db->_die();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   140
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   141
$formatter = new DecirPostbit();
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   142
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   143
$html = paginate(
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   144
    $q, // MySQL result resource
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   145
    '{post_id}',
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   146
    $num_posts,
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   147
    makeUrlNS('Special', 'Forum/Topic/' . $tid . '/start=%s', false, true),
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   148
    $offset,
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   149
    15,
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   150
    array('post_id' => array($formatter, '_render'))
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   151
  );
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   152
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   153
if ( $html )
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   154
  echo $html;
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   155
else
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   156
  die_friendly('Error', '<p>The topic you requested does not exist.</p>');
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   157
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   158
$db->free_result();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   159
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   160
if ( $topic_exists )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   161
{
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   162
  $can_post_replies = false;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   163
  $can_post_topics  = false;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   164
  
1
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   165
  $forum_perms = $session->fetch_page_acl($forum_id, 'DecirForum');
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   166
  $topic_perms = $session->fetch_page_acl($topic_id, 'DecirTopic');
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   167
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   168
  if ( $forum_perms->get_permissions('decir_post') )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   169
    $can_post_topics = true;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   170
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   171
  if ( $topic_perms->get_permissions('decir_reply') )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   172
    $can_post_replies = true;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   173
  
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   174
  echo '<p>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   175
  if ( $can_post_topics )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   176
  {
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   177
    echo '<a href="' . makeUrlNS('Special', 'Forum/New/Topic/' . $forum_id) . '">Post new topic</a>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   178
  }
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   179
  if ( $can_post_topics && $can_post_replies )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   180
  {
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   181
    echo '&nbsp;&nbsp;|&nbsp;&nbsp;';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   182
  }
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   183
  if ( $can_post_replies )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   184
  {
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   185
    echo '<a href="' . makeUrlNS('Special', 'Forum/New/Reply/' . $topic_id) . '">Add reply</a>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   186
  }
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   187
  echo '</p>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   188
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   189
1
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   190
// log the hit
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   191
$time = time();
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   192
$q = $db->sql_query('INSERT INTO '.table_prefix."decir_hits(user_id, topic_id, timestamp) VALUES($session->user_id, $tid, $time);");
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   193
$q = $db->sql_query('UPDATE '.table_prefix."decir_topics SET num_views = num_views + 1 WHERE topic_id = $tid;");
1
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
   194
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   195
$template->footer();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
   196
2
253118325c65 Pagination on topics and a whole crapload of other stuff.
Dan
parents: 1
diff changeset
   197
?>