decir/forum_index.php
author dan@fuhry
Wed, 13 Jun 2007 22:33:54 -0400
changeset 0 0417a5a0c7be
child 1 6f8b7c6fac02
permissions -rw-r--r--
Initial repository population
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
 * install.php - Database installation wizard
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
 */
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    14
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    15
require('common.php');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    16
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    17
$template->header();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    18
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    19
// Not much left now but to just do it...
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    20
$q = $db->sql_query('SELECT f.forum_id,f.forum_type,f.forum_name,f.forum_desc,f.num_topics,f.num_posts,
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    21
       p.post_id,t.topic_id,t.topic_title,u.username,u.user_level,p.timestamp FROM '.table_prefix.'decir_forums AS f
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    22
  LEFT JOIN '.table_prefix.'decir_topics AS t
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    23
    ON (t.forum_id=f.forum_id)
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    24
  LEFT JOIN '.table_prefix.'decir_posts AS p
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    25
    ON (p.topic_id=t.topic_id)
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    26
  LEFT JOIN '.table_prefix.'users AS u
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    27
    ON (u.user_id=f.last_post_user OR f.last_post_user IS NULL)
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    28
  WHERE ( t.topic_id=f.last_post_topic AND p.post_id=f.last_post_id ) OR ( f.last_post_topic IS NULL AND f.last_post_id IS NULL )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    29
    GROUP BY f.parent,f.forum_id
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    30
    ORDER BY f.forum_order;');
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    31
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    32
if (!$q)
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    33
  $db->_die();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    34
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    35
echo '<div class="tblholder">
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    36
      <table border="0" cellspacing="1" cellpadding="4">
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    37
        <tr>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    38
          <th colspan="2">Forum</th>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    39
          <th style="max-width: 50px;">Topics</th>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    40
          <th style="max-width: 50px;">Posts</th>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    41
          <th>Last post</th>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    42
        </tr>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    43
$cat_open = false;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    44
if ( $row = $db->fetchrow($q) )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    45
{
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    46
  do {
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    47
    switch ( $row['forum_type'] )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    48
    {
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    49
      case FORUM_FORUM:
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    50
        $color = ( $row['user_level'] >= USER_LEVEL_ADMIN ) ? 'AA0000' : ( ( $row['user_level'] >= USER_LEVEL_MOD ) ? '00AA00' : '0000AA' );
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    51
        // Forum
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    52
        echo '<tr><td class="row3" style="text-align: center;">&lt;icon&gt;</td><td class="row2"><b><a href="' . makeUrlNS('DecirForum', $row['forum_id']) . '">'
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    53
             . $row['forum_name'] . '</a></b><br />' . $row['forum_desc'].'</td>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    54
             <td class="row3" style="text-align: center;">' . $row['num_topics'] . '</td>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    55
             <td class="row3" style="text-align: center;">' . $row['num_posts'] . '</td>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    56
             <td class="row1" style="text-align: center;">
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    57
               <small>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    58
                 <a href="' . makeUrlNS('DecirTopic', $row['topic_id']) . '#post' . $row['post_id'] . '">' . $row['topic_title'] . '</a><br />
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    59
                 ' . date('d M Y h:i a', $row['timestamp']) . '<br />
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    60
                 by <b><a style="color: #' . $color . '" href="' . makeUrlNS('User', $row['username']) . '">' . $row['username'] . '</a></b>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    61
               </small>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    62
             </td>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    63
             </tr>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    64
        break;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    65
      case FORUM_CATEGORY:
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    66
        // Category
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    67
        if ( $cat_open )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    68
          echo '</tbody>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    69
        echo '<tr><td class="row1" colspan="2"><h3 style="margin: 0; padding: 0;">' . $row['forum_name'] . '</h3></td><td class="row2" colspan="3"></td></tr>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    70
              <tbody id="forum_cat_' . $row['forum_id'] . '">';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    71
        $cat_open = true;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    72
        break;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    73
    }
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    74
  } while ( $row = $db->fetchrow($q) );
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    75
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    76
else
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    77
{
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    78
  echo '<td class="row1" colspan="4">This board has no forums.</td>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    79
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    80
if ( $cat_open )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    81
  echo '</tbody>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    82
echo '</table>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    83
      </div>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    84
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    85
$template->footer();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    86
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    87
?>