decir/forum_index.php
author Dan
Wed, 17 Oct 2007 20:23:51 -0400
changeset 1 6f8b7c6fac02
parent 0 0417a5a0c7be
child 5 6eea55374f5b
permissions -rw-r--r--
Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
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
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
    52
        if ( $row['post_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
    53
        {
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    54
          $last_post_data = '<small>
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    55
                   <a href="' . makeUrlNS('DecirTopic', $row['topic_id']) . '#post' . $row['post_id'] . '">' . $row['topic_title'] . '</a><br />
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    56
                   ' . date('d M Y h:i a', $row['timestamp']) . '<br />
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    57
                   by <b><a style="color: #' . $color . '" href="' . makeUrlNS('User', $row['username']) . '">' . $row['username'] . '</a></b>
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    58
                 </small>';
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    59
        }
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    60
        else
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    61
        {
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    62
          $last_post_data = 'No posts';
6f8b7c6fac02 Let's just say: major progress and still only 20% complete. So many changes I forgot to commit.
Dan
parents: 0
diff changeset
    63
        }
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    64
        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
    65
             . $row['forum_name'] . '</a></b><br />' . $row['forum_desc'].'</td>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    66
             <td class="row3" style="text-align: center;">' . $row['num_topics'] . '</td>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    67
             <td class="row3" style="text-align: center;">' . $row['num_posts'] . '</td>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    68
             <td class="row1" style="text-align: center;">
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
    69
               ' . $last_post_data . '
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    70
             </td>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    71
             </tr>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    72
        break;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    73
      case FORUM_CATEGORY:
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    74
        // Category
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    75
        if ( $cat_open )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    76
          echo '</tbody>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    77
        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
    78
              <tbody id="forum_cat_' . $row['forum_id'] . '">';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    79
        $cat_open = true;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    80
        break;
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    81
    }
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    82
  } while ( $row = $db->fetchrow($q) );
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    83
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    84
else
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    85
{
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
    86
  echo '<td class="row1" colspan="5">This board has no forums.</td>';
0
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    87
}
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    88
if ( $cat_open )
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    89
  echo '</tbody>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    90
echo '</table>
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    91
      </div>';
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    92
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    93
$template->footer();
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    94
0417a5a0c7be Initial repository population
dan@fuhry
parents:
diff changeset
    95
?>