[Aphrodite] Simple Subforums MOD

Specific instructions on how to apply certain mods to certain styles.

Moderator: Moderators

Postby Paffendorf on Fri Jul 28, 2006 3:59 pm

The ONLY other mod I have installed is XS News Banner. But never the less, I solved it. Ill include the code change here so others may be able to use it. All I had to do was look carefully BETWEEN the lines and replace what was NEEDED. It works like a dream now....

Code: Select all

#-----[ OPEN ]------------------------------------------ 

templates/ca_aphrodite/index_body.tpl 


#-----[ FIND ]------------------------------------------ 

<!-- BEGIN forumrow --> 


#-----[ AFTER, ADD ]------------------------------------------ 

<!-- IF ! forumrow.PARENT --> 


#-----[ FIND ]------------------------------------------ 
#
 
<tr> 
   <td class="row3 row-center" width="30"><img src="{catrow.forumrow.FORUM_FOLDER_IMG}" width="25" height="25" alt="{catrow.forumrow.L_FORUM_FOLDER_ALT}" title="{catrow.forumrow.L_FORUM_FOLDER_ALT}" /></td> 
   <td class="row1h{catrow.forumrow.XS_NEW} row-forum" width="70%" onclick="window.location.href='{catrow.forumrow.U_VIEWFORUM}'"><a class="forumlink{catrow.forumrow.XS_NEW}" href="{catrow.forumrow.U_VIEWFORUM}">{catrow.forumrow.FORUM_NAME}</a><br /> 
     <span class="genmed">{catrow.forumrow.FORUM_DESC}<br /> 
     </span><span class="moderators">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}</span> 
     <!-- BEGIN switch_attached_forums --> 
     <!-- BEGIN br --> 
     <br /> 
     <!-- END br --> 
     <span class="moderators"><b>{catrow.forumrow.switch_attached_forums.L_ATTACHED_FORUMS}:</b> 
          <!-- BEGIN attached_forums --> 
           <a class="nav" href="{catrow.forumrow.switch_attached_forums.attached_forums.U_VIEWFORUM}"><img alt="{catrow.forumrow.switch_attached_forums.attached_forums.L_FORUM_IMAGE}" border="0" src="{catrow.forumrow.switch_attached_forums.attached_forums.FORUM_IMAGE}" title="{catrow.forumrow.switch_attached_forums.attached_forums.L_FORUM_IMAGE}" />{catrow.forumrow.switch_attached_forums.attached_forums.FORUM_NAME}</a> 
          <!-- END attached_forums --> 
     <span class="genmed"> 
     <!-- END switch_attached_forums --> 
   </td> 
   <td class="row2 row-center-small">{catrow.forumrow.TOPICS}</td> 
   <td class="row2 row-center-small">{catrow.forumrow.POSTS}</td> 
   <td class="row3 row-center-small" width="130">{catrow.forumrow.LAST_POST}</td> 
</tr> 


#-----[ REPLACE WITH ]------------------------------------------ 
#

<tr>
    <td class="row3 row-center" width="30"><img src="{catrow.forumrow.FORUM_FOLDER_IMG}" width="25" height="25" alt="{catrow.forumrow.L_FORUM_FOLDER_ALT}" title="{catrow.forumrow.L_FORUM_FOLDER_ALT}" /></td> 
    <td class="row1h{catrow.forumrow.XS_NEW} row-forum" width="70%" onclick="window.location.href='{catrow.forumrow.U_VIEWFORUM}'"><a class="forumlink{catrow.forumrow.XS_NEW}" href="{catrow.forumrow.U_VIEWFORUM}">{catrow.forumrow.FORUM_NAME}</a><br /> 
      <span class="genmed">{catrow.forumrow.FORUM_DESC}<br />
      <!-- BEGIN sub --><!-- DEFINE $HAS_SUB = 1 --><!-- IF catrow.forumrow.sub.NUM > 0 -->, <!-- ELSE --><span class="genmed">&nbsp;&nbsp;<font color="#cc0000">{L_SUBFORUMS}</font>: <!-- ENDIF -->{catrow.forumrow.sub.LAST_POST_SUB} <a href="{catrow.forumrow.sub.U_VIEWFORUM}" <!-- IF catrow.forumrow.sub.UNREAD -->class="topic-new"<!-- ENDIF --> title="{catrow.forumrow.sub.FORUM_DESC_HTML}">{catrow.forumrow.sub.FORUM_NAME}</a><!-- END sub --> 
      <!-- IF $HAS_SUB --></span><!-- UNDEFINE $HAS_SUB --><!-- ENDIF -->
        </span><span class="moderators"> <!-- IF catrow.forumrow.MODERATORS -->{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}<br /><!-- ENDIF --> </span></td>
     <!-- BEGIN switch_attached_forums -->
     <!-- BEGIN br -->
     <br />
     <!-- END br -->
     <span class="moderators"><b>{catrow.forumrow.switch_attached_forums.L_ATTACHED_FORUMS}:</b>
          <!-- BEGIN attached_forums -->
           <a class="nav" href="{catrow.forumrow.switch_attached_forums.attached_forums.U_VIEWFORUM}"><img alt="{catrow.forumrow.switch_attached_forums.attached_forums.L_FORUM_IMAGE}" border="0" src="{catrow.forumrow.switch_attached_forums.attached_forums.FORUM_IMAGE}" title="{catrow.forumrow.switch_attached_forums.attached_forums.L_FORUM_IMAGE}" />{catrow.forumrow.switch_attached_forums.attached_forums.FORUM_NAME}</a>
          <!-- END attached_forums -->
     <span class="genmed">
     <!-- END switch_attached_forums -->
   </td>
   <td class="row2 row-center-small">{catrow.forumrow.TOPICS}</td>
   <td class="row2 row-center-small">{catrow.forumrow.POSTS}</td>
   <td class="row3 row-center-small" width="130">{catrow.forumrow.LAST_POST}</td>
</tr>


Paffendorf
Paffendorf
Registered User
Registered User
 
Posts: 12
Joined: Thu Jul 27, 2006 1:50 pm

Postby UseLess on Fri Jul 28, 2006 4:11 pm

Greetings,

Well the template your using is not a standard Aphrodite due to the 'attach_forums' stuff which is not in the standard release of the style. Which is why I asked what mods you had installed.

Therefore the above will only apply to someone who also has the 'attach_forums' stuff in the template, probably added by some mod... ;)
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby estorado on Thu Aug 03, 2006 8:59 pm

hi,

nice mod and nice style, but i cant find

## Included Files: 2
## templates/ca_aphrodite/images/folders.gif
## templates/ca_aphrodite/images/folders_new.gif


i try to search, but i failed. need help.

greetings
User avatar
estorado
Registered User
Registered User
 
Posts: 10
Joined: Sat Jun 17, 2006 2:48 pm
Location: Regensburg, Germany

Postby DooBDee on Thu Aug 03, 2006 10:12 pm

Last time I checked, they were included with the APhrodite Style by default :)
DooBDee
Website Ninja
DooBDee.net
User avatar
DooBDee
Moderator
Moderator
 
Posts: 3530
Joined: Tue Mar 01, 2005 6:28 pm
Location: DooBDee.net

Postby UseLess on Thu Aug 03, 2006 10:25 pm

Greetings,

Get them here:

http://www.custombuiltsoftware.co.uk/do ... images.zip

there are 2 different types.
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby DooBDee on Thu Aug 03, 2006 10:29 pm

Oh! It appears its not anymore. I could have swarn they were in a style pack somewhere along the line... Ah well, guess thats what happens when you get stuck doing other things and forget what you were previously doing.. ;)
DooBDee
Website Ninja
DooBDee.net
User avatar
DooBDee
Moderator
Moderator
 
Posts: 3530
Joined: Tue Mar 01, 2005 6:28 pm
Location: DooBDee.net

Postby Darvil on Fri Aug 18, 2006 12:12 am

I got everything except the last file "templates/ca_aphrodite/viewtopic_body.tpl"

It can't get this one line (only this line). "<a href="{U_INDEX}" class="nav">{L_INDEX}</a> "

I checked the code of subSilver and I could find it there.

Now I'm running phpbb 2.0.21 and the Aphrodite version I got is 2.0.18

Since I saw this line in subSilver does that mean the Aphrodite version you guys are talking about modding is 2.0.21?

I could only find version 2.0.18 on this site.. is there a special place where I can get it?

Also I also notice that when I installed aprodite MC version, and go to the admin menu I get a black background
and can't seem to see anything. Does that mean that I won't be able to use any 2.0.20 versions? (aprondite MC is 2.0.20)

Is there some instruction on how to upgrade it to 2.0.21 or is it too complicated for a layman like me to do?

Thanks
Darvil
Registered User
Registered User
 
Posts: 4
Joined: Thu Aug 17, 2006 12:52 pm

Postby UseLess on Fri Aug 18, 2006 12:56 am

Greetings,

The line in Aphrodite is;
Code: Select all
<a href="{U_INDEX}">{L_INDEX}</a>


Tip: When adding mods it's a good idea, if you cannot find what your looking for, to look for either part of the line or if a template variable is present in the find then look for that. A template variable is anything wrapped in '{}', such as "{U_INDEX}" and as these are common to all styles finding it will get you in the general area you want to be in.
Movie Quote:
It's not the years honey, it's the mileage...

I do not provide any install services for phpBB, Mods or Styles.
Please do not pm me for support/scripting help - you won't get any reply. If you have a question then make a post in the appropriate forum.
User avatar
UseLess
Registered User
Registered User
 
Posts: 6220
Joined: Mon Sep 27, 2004 2:14 am
Location: North East, UK

Postby Darvil on Fri Aug 18, 2006 2:17 am

Thanks UseLess

I actually found the line but I wasn't sure if I should do that. Now that I did it, its working fine :)

Thanks alot.

Now if you don't mind could you answer my other questions? Would it be safe for me to use this on my phpbb 2.0.21 board? Would upgrades will be easy if the skin for 2.0.21 gets released.. in other word would I require alot of modifications? (because I'm going to be adding alot of mods onto these skins.

Do you also know whats the deal with some skins (lower version like 2.0.18) making the admin menu all back so I can't see anything? When I ran into this situation I am unable to do anything til it magically fixes itself later.


Thanks!

edit: I finally figured out the problem. Sorry for even asking it here lol. Basically I had global admin template on and that doesn't work well with some of the skins which obviously need their own admin folder. :)
Darvil
Registered User
Registered User
 
Posts: 4
Joined: Thu Aug 17, 2006 12:52 pm

Subforum appearing but also appears in the Main Forum

Postby mumbaihelp on Fri Aug 25, 2006 8:32 pm

Subforum appears correctly in a forum - though it does not show in the inside page when the main forum is clicked.

Another problem is that the subforum also shows as another (duplicate) forum in the Main Forum as well - I've pasted my index_body.tpl code here - is there anything else to change? I've also used the Forum Icon with ACP Control - you can check http://www.petesplace-online.co.uk/ as well for reference.

Thanks for any help received.


Code: Select all
<div class="forumline nav-div">
   <p class="nav-header">
      <a href="{U_INDEX}">{L_INDEX}</a>
   </p>
   <div class="nav-links">
      <div class="nav-links-left">
         <!-- BEGIN switch_user_logged_in -->
         <a href="{U_PRIVATEMSGS}">{PRIVATE_MESSAGE_INFO}</a><br />
         <!-- END switch_user_logged_in -->
         {CURRENT_TIME} | {S_TIMEZONE}
      </div>
      <!-- BEGIN switch_user_logged_in -->
      <a href="{U_MARK_READ}">{L_MARK_FORUMS_READ}</a> | <a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a><br />
      <a href="{U_SEARCH_SELF}">{L_SEARCH_SELF}</a> | <a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a>
      <!-- END switch_user_logged_in -->
      <!-- BEGIN switch_user_logged_out --> 
      <a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a>
      <!-- END switch_user_logged_out -->
   </div>
</div>

<!-- BEGIN switch_user_logged_out -->
<div align="right">
   <form method="post" action="{S_LOGIN_ACTION}"><input type="hidden" name="autologin" value="checked" />
   <span class="gensmall">{L_USERNAME}:
      <input class="post" type="text" name="username" size="10" />
      &nbsp;{L_PASSWORD}:
      <input class="post" type="password" name="password" size="10" maxlength="32" />
      &nbsp;
      <input type="submit" class="mainoption" name="login" value="{L_LOGIN}" />
      </span>
   </form>
</div>
<!-- END switch_user_logged_out -->

<!-- BEGIN catrow -->
<table width="100%" cellspacing="0" class="forumline">
<tr>
   <td colspan="6" class="row-header"><span>{catrow.CAT_DESC}</span></td>
</tr>
<tr>
   <th colspan="3">{L_FORUM}</th>
   <th>{L_TOPICS}</th>
   <th>{L_POSTS}</th>
   <th>{L_LASTPOST}</th>
</tr>
<!-- BEGIN forumrow -->
<tr> 
  <td <!-- IF catrow.forumrow.HAS_SUBFORUMS > 0 -->rowspan="2" <!-- ENDIF -->class="row3 row-center" width="30"><img src="{catrow.forumrow.FORUM_FOLDER_IMG}" width="25" height="25" alt="{catrow.forumrow.L_FORUM_FOLDER_ALT}" title="{catrow.forumrow.L_FORUM_FOLDER_ALT}" /></td> 
<td class="row1h">{catrow.forumrow.FORUM_ICON_IMG}</td>
  <td class="row1h{catrow.forumrow.XS_New} row-forum" width="70%" height="55" valign="middle" onclick="window.location.href='{catrow.forumrow.U_VIEWFORUM}'"><a class="forumlink{catrow.forumrow.XS_NEW}" href="{catrow.forumrow.U_VIEWFORUM}">{catrow.forumrow.FORUM_NAME}</a><br /> 
     <span class="genmed">{catrow.forumrow.FORUM_DESC}<br /></span> 
<!-- IF catrow.forumrow.MODERATORS --><span class="moderators">{catrow.forumrow.L_MODERATOR} {catrow.forumrow.MODERATORS}<br /></span><!-- ENDIF --> 
    </td> 
   <td <!-- IF catrow.forumrow.HAS_SUBFORUMS > 0 -->rowspan="2" <!-- ENDIF -->class="row2 row-center-small">{catrow.forumrow.TOTAL_TOPICS}</td> 
   <td <!-- IF catrow.forumrow.HAS_SUBFORUMS > 0 -->rowspan="2" <!-- ENDIF -->class="row2 row-center-small">{catrow.forumrow.TOTAL_POSTS}</td> 
    <td <!-- IF catrow.forumrow.HAS_SUBFORUMS > 0 -->rowspan="2" <!-- ENDIF -->class="row3 row-center-small" width="130">{catrow.forumrow.LAST_POST}</td> 
</tr> 
<!-- BEGIN sub --><!-- DEFINE $HAS_SUB = 1 --><!-- IF catrow.forumrow.sub.NUM > 0 -->, <!-- ELSE --><tr><td class="subforums" colspan="2"><span class="genmed">{L_SUBFORUMS}: <!-- ENDIF -->{catrow.forumrow.sub.LAST_POST_SUB} <a href="{catrow.forumrow.sub.U_VIEWFORUM}" <!-- IF catrow.forumrow.sub.UNREAD -->class="topic-new"<!-- ENDIF --> title="{catrow.forumrow.sub.FORUM_DESC_HTML}">{catrow.forumrow.sub.FORUM_NAME}</a><!-- END sub --> 
<!-- IF $HAS_SUB --><br /></span></td></tr><!-- UNDEFINE $HAS_SUB --><!-- ENDIF --> 
   <!-- END forumrow -->
</table>
<!-- END catrow -->

<div class="forumline">
   <p class="row-header"><span><a href="{U_VIEWONLINE}">{L_WHO_IS_ONLINE}</a></span></p>
   <p class="row1 gensmall">{TOTAL_POSTS}<br />{TOTAL_USERS}<br />{NEWEST_USER}</p>
   <p class="row1 gensmall">{TOTAL_USERS_ONLINE} &nbsp; [ {L_WHOSONLINE_ADMIN} ] &nbsp; [ {L_WHOSONLINE_MOD} ]<br />{RECORD_USERS}<br />{LOGGED_IN_USER_LIST}<br />{L_ONLINE_EXPLAIN}</p>
</div>

<table cellspacing="3" align="center" cellpadding="0" class="forumline no-width">
<tr>
   <td class="row-center-small"><img src="templates/ca_aphrodite/images/folder_new.gif" alt="{L_NEW_POSTS}"/></td>
   <td class="row-center-small">{L_NEW_POSTS}</td>
   <td class="row-center-small">&nbsp;&nbsp;</td>
   <td class="row-center-small"><img src="templates/ca_aphrodite/images/folder.gif" alt="{L_NO_NEW_POSTS}" /></td>
   <td class="row-center-small">{L_NO_NEW_POSTS}</td>
   <td class="row-center-small">&nbsp;&nbsp;</td>
   <td class="row-center-small"><img src="templates/ca_aphrodite/images/folder_locked.gif" alt="{L_FORUM_LOCKED}" /></td>
   <td class="row-center-small">{L_FORUM_LOCKED}</td>
</tr>
</table>
mumbaihelp
Registered User
Registered User
 
Posts: 6
Joined: Fri Aug 25, 2006 1:08 pm

Postby mumbaihelp on Sun Sep 03, 2006 7:44 pm

Any help would be appreciated. Anyone?
mumbaihelp
Registered User
Registered User
 
Posts: 6
Joined: Fri Aug 25, 2006 1:08 pm

Postby mumbaihelp on Sun Sep 03, 2006 7:59 pm

UPDATE: It worked! I was missing this <!-- IF ! forumrow.PARENT --> and an <!-- ENDIF --> from the code which was displaying the sub-forums again.
mumbaihelp
Registered User
Registered User
 
Posts: 6
Joined: Fri Aug 25, 2006 1:08 pm

Postby Gral on Tue Sep 05, 2006 6:00 pm

Main Forum is Working however when i go to the ACP i get this error on Left hand Side where my options are supposed to be


Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /homepages/3/d159792154/htdocs/forum/admin/admin_forums.php on line 415


-----------------------------------------------------------------------------------------
Here is the Code for that
_________________________________________________________________

Code: Select all
<?php
/***************************************************************************
*                             admin_forums.php
*                            -------------------
*   begin                : Thursday, Jul 12, 2001
*   copyright            : (C) 2001 The phpBB Group
*   email                : support@phpbb.com
*
*   $Id: admin_forums.php,v 1.40.2.13 2006/03/09 21:55:09 grahamje Exp $
*
***************************************************************************/

/***************************************************************************
*
*   This program is free software; you can redistribute it and/or modify
*   it under the terms of the GNU General Public License as published by
*   the Free Software Foundation; either version 2 of the License, or
*   (at your option) any later version.
*
***************************************************************************/

define('IN_PHPBB', 1);

if( !empty($setmodules) )
{
   $file = basename(__FILE__);
   $module['Forums']['Manage'] = $file;
   return;
}

//
// Load default header
//
$phpbb_root_path = "./../";
require($phpbb_root_path . 'extension.inc');
require('./pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_admin.'.$phpEx);

$forum_auth_ary = array(
   "auth_view" => AUTH_ALL,
   "auth_read" => AUTH_ALL,
   "auth_post" => AUTH_REG,
   "auth_reply" => AUTH_REG,
   "auth_edit" => AUTH_REG,
   "auth_delete" => AUTH_REG,
   "auth_sticky" => AUTH_MOD,
   "auth_announce" => AUTH_MOD,
   "auth_vote" => AUTH_REG,
   "auth_pollcreate" => AUTH_REG
);

//
// Mode setting
//
if( isset($HTTP_POST_VARS['mode']) || isset($HTTP_GET_VARS['mode']) )
{
   $mode = ( isset($HTTP_POST_VARS['mode']) ) ? $HTTP_POST_VARS['mode'] : $HTTP_GET_VARS['mode'];
   $mode = htmlspecialchars($mode);
}
else
{
   $mode = "";
}

// ------------------
// Begin function block
//
function get_info($mode, $id)
{
   global $db;

   switch($mode)
   {
      case 'category':
         $table = CATEGORIES_TABLE;
         $idfield = 'cat_id';
         $namefield = 'cat_title';
         break;

      case 'forum':
         $table = FORUMS_TABLE;
         $idfield = 'forum_id';
         $namefield = 'forum_name';
         break;

      default:
         message_die(GENERAL_ERROR, "Wrong mode for generating select list", "", __LINE__, __FILE__);
         break;
   }
   $sql = "SELECT count(*) as total
      FROM $table";
   if( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, "Couldn't get Forum/Category information", "", __LINE__, __FILE__, $sql);
   }
   $count = $db->sql_fetchrow($result);
   $count = $count['total'];

   $sql = "SELECT *
      FROM $table
      WHERE $idfield = $id";

   if( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, "Couldn't get Forum/Category information", "", __LINE__, __FILE__, $sql);
   }

   if( $db->sql_numrows($result) != 1 )
   {
      message_die(GENERAL_ERROR, "Forum/Category doesn't exist or multiple forums/categories with ID $id", "", __LINE__, __FILE__);
   }

   $return = $db->sql_fetchrow($result);
   $return['number'] = $count;
   return $return;
}

function get_list($mode, $id, $select)
{
   global $db;

   switch($mode)
   {
      case 'category':
         $table = CATEGORIES_TABLE;
         $idfield = 'cat_id';
         $namefield = 'cat_title';
         break;

      case 'forum':
         $table = FORUMS_TABLE;
         $idfield = 'forum_id';
         $namefield = 'forum_name';
         break;

      default:
         message_die(GENERAL_ERROR, "Wrong mode for generating select list", "", __LINE__, __FILE__);
         break;
   }

   $sql = "SELECT *
      FROM $table";
   if( $select == 0 )
   {
      $sql .= " WHERE $idfield <> $id";
   }

   if( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, "Couldn't get list of Categories/Forums", "", __LINE__, __FILE__, $sql);
   }

   $cat_list = "";

   while( $row = $db->sql_fetchrow($result) )
   {
      $s = "";
      if ($row[$idfield] == $id)
      {
         $s = " selected=\"selected\"";
      }
      $catlist .= "<option value=\"$row[$idfield]\"$s>" . $row[$namefield] . "</option>\n";
   }

   return($catlist);
}

// Begin Simple Subforums MOD
function get_list_cat($id, $parent, $forum_id)
{
   global $db;

   // Get categories
   $sql = 'SELECT * FROM ' . CATEGORIES_TABLE . ' ORDER BY cat_order ASC';
   
   if( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, "Couldn't get list of categories", '', __LINE__, __FILE__, $sql);
   }
   
   $cat_list = array();
   
   while( $row = $db->sql_fetchrow($result) )
   {
      $cat_list[] = $row;
   }

   $db->sql_freeresult($result);

   // Get all forums and check if forum has subforums
   $has_sub = false;
   $sql = 'SELECT forum_id, cat_id, forum_name, forum_parent FROM ' . FORUMS_TABLE . ' ORDER BY forum_order ASC';
   
   if( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, "Couldn't get list of forums", '', __LINE__, __FILE__, $sql);
   }
   
   $forums_list = array();
   
   while( $row = $db->sql_fetchrow($result) )
   {
      if( $row['forum_parent'] > 0 && $row['forum_parent'] == $forum_id )
      {
         $has_sub = true;
      }
      
      if( !$row['forum_parent'] )
      {
         $forums_list[] = $row;
      }
   }
   $db->sql_freeresult($result);

   // Generate select
   for( $i = 0; $i < count($cat_list); $i++ )
   {
      $cat_id = $cat_list[$i]['cat_id'];
      $selected = ( $id == $cat_id && $parent == 0 ) ? ' selected="selected"' : '';
      $str .= '<option value="' . $cat_id . '"' . $selected . '>' . $cat_list[$i]['cat_title'] . '</option>';
      
      if( !$has_sub )
      {
         for( $j = 0; $j < count($forums_list); $j++)
         {
            if( $forums_list[$j]['cat_id'] == $cat_id && $forums_list[$j]['forum_id'] != $forum_id )
            {
               $forum_id2 = $forums_list[$j]['forum_id'];
               $selected = ( $id == $cat_id && $parent == $forum_id2 ) ? ' selected="selected"' : '';
               $str .= '<option value="' . $cat_id . ',' . $forum_id2 . '"' . $selected . '>- ' . $forums_list[$j]['forum_name'] . '</option>';
            }
         }
      }
   }
   return $str;
}
// End Simple Subforums MOD

function renumber_order($mode, $cat = 0)
{
   global $db;

   switch($mode)
   {
      case 'category':
         $table = CATEGORIES_TABLE;
         $idfield = 'cat_id';
         $orderfield = 'cat_order';
         $cat = 0;
         break;

      case 'forum':
         $table = FORUMS_TABLE;
         $idfield = 'forum_id';
         $orderfield = 'forum_order';
         $catfield = 'cat_id';
         break;

      default:
         message_die(GENERAL_ERROR, "Wrong mode for generating select list", "", __LINE__, __FILE__);
         break;
   }

   $sql = "SELECT * FROM $table";
   if( $cat != 0)
   {
      $sql .= " WHERE $catfield = $cat";
   }
   $sql .= " ORDER BY $orderfield ASC";


   if( !$result = $db->sql_query($sql) )
   {
      message_die(GENERAL_ERROR, "Couldn't get list of Categories", "", __LINE__, __FILE__, $sql);
   }

   $i = 10;
   $inc = 10;

   while( $row = $db->sql_fetchrow($result) )
   {
      $sql = "UPDATE $table
         SET $orderfield = $i
         WHERE $idfield = " . $row[$idfield];
      if( !$db->sql_query($sql) )
      {
         message_die(GENERAL_ERROR, "Couldn't update order fields", "", __LINE__, __FILE__, $sql);
      }
      $i += 10;
   }

}
//
// End function block
// ------------------

//
// Begin program proper
//
if( isset($HTTP_POST_VARS['addforum']) || isset($HTTP_POST_VARS['addcategory']) )
{
   $mode = ( isset($HTTP_POST_VARS['addforum']) ) ? "addforum" : "addcat";

   if( $mode == "addforum" )
   {
      list($cat_id) = each($HTTP_POST_VARS['addforum']);
      $cat_id = intval($cat_id);
      //
      // stripslashes needs to be run on this because slashes are added when the forum name is posted
      //
      $forumname = stripslashes($HTTP_POST_VARS['forumname'][$cat_id]);
   }
}

if( !empty($mode) )
{
   switch($mode)
   {
      case 'addforum':
      case 'editforum':
         //
         // Show form to create/modify a forum
         //
         if ($mode == 'editforum')
         {
            // $newmode determines if we are going to INSERT or UPDATE after posting?

            $l_title = $lang['Edit_forum'];
            $newmode = 'modforum';
            $buttonvalue = $lang['Update'];

            $forum_id = intval($HTTP_GET_VARS[POST_FORUM_URL]);

            $row = get_info('forum', $forum_id);

            $cat_id = $row['cat_id'];

            // Begin Simple Subforums MOD
            $parent_id = $row['forum_parent'];
            // End Simple Subforums MOD
            $forumname = $row['forum_name'];
            $forumdesc = $row['forum_desc'];
            $forumstatus = $row['forum_status'];

            //
            // start forum prune stuff.
            //
            if( $row['prune_enable'] )
            {
               $prune_enabled = "checked=\"checked\"";
               $sql = "SELECT *
                        FROM " . PRUNE_TABLE . "
                        WHERE forum_id = $forum_id";
               if(!$pr_result = $db->sql_query($sql))
               {
                   message_die(GENERAL_ERROR, "Auto-Prune: Couldn't read auto_prune table.", __LINE__, __FILE__);
                 }

               $pr_row = $db->sql_fetchrow($pr_result);
            }
            else
            {
               $prune_enabled = '';
            }
         }
         else
         {
            $l_title = $lang['Create_forum'];
            $newmode = 'createforum';
            $buttonvalue = $lang['Create_forum'];

            $forumdesc = '';
            $forumstatus = FORUM_UNLOCKED;
            $forum_id = '';
            $prune_enabled = '';
// Begin Simple Subforums MOD
            $parent_id = 0;
            // End Simple Subforums MOD
         }

         // Begin Simple Subforums MOD
         $catlist = get_list_cat($cat_id, $parent_id, $forum_id);
         // End Simple Subforums MOD


         $forumstatus == ( FORUM_LOCKED ) ? $forumlocked = "selected=\"selected\"" : $forumunlocked = "selected=\"selected\"";
         
         // These two options ($lang['Status_unlocked'] and $lang['Status_locked']) seem to be missing from
         // the language files.
         $lang['Status_unlocked'] = isset($lang['Status_unlocked']) ? $lang['Status_unlocked'] : 'Unlocked';
         $lang['Status_locked'] = isset($lang['Status_locked']) ? $lang['Status_locked'] : 'Locked';
         
         $statuslist = "<option value=\"" . FORUM_UNLOCKED . "\" $forumunlocked>" . $lang['Status_unlocked'] . "</option>\n";
         $statuslist .= "<option value=\"" . FORUM_LOCKED . "\" $forumlocked>" . $lang['Status_locked'] . "</option>\n";

         $template->set_filenames(array(
            "body" => "admin/forum_edit_body.tpl")
         );

         $s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode .'" /><input type="hidden" name="' . POST_FORUM_URL . '" value="' . $forum_id . '" />';

         $template->assign_vars(array(
            'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"),
            'S_HIDDEN_FIELDS' => $s_hidden_fields,
            'S_SUBMIT_VALUE' => $buttonvalue,
            'S_CAT_LIST' => $catlist,
            'S_STATUS_LIST' => $statuslist,
            'S_PRUNE_ENABLED' => $prune_enabled,

            'L_FORUM_TITLE' => $l_title,
            'L_FORUM_EXPLAIN' => $lang['Forum_edit_delete_explain'],
            'L_FORUM_SETTINGS' => $lang['Forum_settings'],
            'L_FORUM_NAME' => $lang['Forum_name'],
            'L_CATEGORY' => $lang['Category']. ' / ' . $lang['Forum']
            'L_FORUM_DESCRIPTION' => $lang['Forum_desc'],
            'L_FORUM_STATUS' => $lang['Forum_status'],
            'L_AUTO_PRUNE' => $lang['Forum_pruning'],
            'L_ENABLED' => $lang['Enabled'],
            'L_PRUNE_DAYS' => $lang['prune_days'],
            'L_PRUNE_FREQ' => $lang['prune_freq'],
            'L_DAYS' => $lang['Days'],

            'PRUNE_DAYS' => ( isset($pr_row['prune_days']) ) ? $pr_row['prune_days'] : 7,
            'PRUNE_FREQ' => ( isset($pr_row['prune_freq']) ) ? $pr_row['prune_freq'] : 1,
            'FORUM_NAME' => $forumname,
            'DESCRIPTION' => $forumdesc)
         );
         $template->pparse("body");
         break;

      case 'createforum':
         //
         // Create a forum in the DB
         //
         if( trim($HTTP_POST_VARS['forumname']) == "" )
         {
            message_die(GENERAL_ERROR, "Can't create a forum without a name");
         }

         $sql = "SELECT MAX(forum_order) AS max_order
            FROM " . FORUMS_TABLE . "
            WHERE cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]);
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't get order number from forums table", "", __LINE__, __FILE__, $sql);
         }
         $row = $db->sql_fetchrow($result);

         $max_order = $row['max_order'];
         $next_order = $max_order + 10;
         
         $sql = "SELECT MAX(forum_id) AS max_id
            FROM " . FORUMS_TABLE;
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't get order number from forums table", "", __LINE__, __FILE__, $sql);
         }
         $row = $db->sql_fetchrow($result);

         $max_id = $row['max_id'];
         $next_id = $max_id + 1;

         //
         // Default permissions of public ::
         //
         $field_sql = "";
         $value_sql = "";
         while( list($field, $value) = each($forum_auth_ary) )
         {
            $field_sql .= ", $field";
            $value_sql .= ", $value";

         }

         // There is no problem having duplicate forum names so we won't check for it.
         
         // Begin Simple Subforums MOD
         $list = explode(',', $HTTP_POST_VARS[POST_CAT_URL]);
         $new_cat = ( count($list) ) ? intval($list[0]) : intval($HTTP_POST_VARS[POST_CAT_URL]);
         $new_parent = ( isset($list[1]) ) ? intval($list[1]) : 0;
         // End Simple Subforums MOD
$sql = "INSERT INTO " . FORUMS_TABLE . " (forum_id, forum_name, cat_id,forum_parent, forum_desc, forum_order, forum_status, prune_enable" . $field_sql . ")
            VALUES ('" . $next_id . "', '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', " . $new_cat . ', ' . $new_parent . ", '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', $next_order, " . intval($HTTP_POST_VARS['forumstatus']) . ", " . intval($HTTP_POST_VARS['prune_enable']) . $value_sql . ")";
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't insert row in forums table", "", __LINE__, __FILE__, $sql);
         }

         if( $HTTP_POST_VARS['prune_enable'] )
         {

            if( $HTTP_POST_VARS['prune_days'] == "" || $HTTP_POST_VARS['prune_freq'] == "")
            {
               message_die(GENERAL_MESSAGE, $lang['Set_prune_data']);
            }

            $sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq)
               VALUES('" . $next_id . "', " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")";
            if( !$result = $db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, "Couldn't insert row in prune table", "", __LINE__, __FILE__, $sql);
            }
         }

         $message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

         message_die(GENERAL_MESSAGE, $message);

         break;

      case 'modforum':
// Begin Simple Subforums MOD
         $forum_id = intval($HTTP_POST_VARS[POST_FORUM_URL]);
         $row = get_info('forum', $forum_id);
         $list = explode(',', $HTTP_POST_VARS[POST_CAT_URL]);
         $new_cat = ( count($list) ) ? intval($list[0]) : intval($HTTP_POST_VARS[POST_CAT_URL]);
         $new_parent = ( isset($list[1]) ) ? intval($list[1]) : 0;
         
         if( !$row['forum_parent'] && $row['cat_id'] !== $new_cat )
         {
            // Move subforums to new category
            $sql = "UPDATE " . FORUMS_TABLE . " SET cat_id='$new_cat' WHERE forum_parent='$forum_id'";
            $db->sql_query($sql);
         }
         // End Simple Subforums MOD

         // Modify a forum in the DB
         if( isset($HTTP_POST_VARS['prune_enable']))
         {
            if( $HTTP_POST_VARS['prune_enable'] != 1 )
            {
               $HTTP_POST_VARS['prune_enable'] = 0;
            }
         }

         $sql = "UPDATE " . FORUMS_TABLE . "
            SET forum_name = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumname']) . "', cat_id = " $new_cat, forum_parent = $new_parent, forum_desc = '" . str_replace("\'", "''", $HTTP_POST_VARS['forumdesc']) . "', forum_status = " . intval($HTTP_POST_VARS['forumstatus']) . ", prune_enable = " . intval($HTTP_POST_VARS['prune_enable']) . "
            WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't update forum information", "", __LINE__, __FILE__, $sql);
         }

         if( $HTTP_POST_VARS['prune_enable'] == 1 )
         {
            if( $HTTP_POST_VARS['prune_days'] == "" || $HTTP_POST_VARS['prune_freq'] == "" )
            {
               message_die(GENERAL_MESSAGE, $lang['Set_prune_data']);
            }

            $sql = "SELECT *
               FROM " . PRUNE_TABLE . "
               WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
            if( !$result = $db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, "Couldn't get forum Prune Information","",__LINE__, __FILE__, $sql);
            }

            if( $db->sql_numrows($result) > 0 )
            {
               $sql = "UPDATE " . PRUNE_TABLE . "
                  SET   prune_days = " . intval($HTTP_POST_VARS['prune_days']) . ",   prune_freq = " . intval($HTTP_POST_VARS['prune_freq']) . "
                   WHERE forum_id = " . intval($HTTP_POST_VARS[POST_FORUM_URL]);
            }
            else
            {
               $sql = "INSERT INTO " . PRUNE_TABLE . " (forum_id, prune_days, prune_freq)
                  VALUES(" . intval($HTTP_POST_VARS[POST_FORUM_URL]) . ", " . intval($HTTP_POST_VARS['prune_days']) . ", " . intval($HTTP_POST_VARS['prune_freq']) . ")";
            }

            if( !$result = $db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, "Couldn't Update Forum Prune Information","",__LINE__, __FILE__, $sql);
            }
         }

         $message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

         message_die(GENERAL_MESSAGE, $message);

         break;
         
      case 'addcat':
         // Create a category in the DB
         if( trim($HTTP_POST_VARS['categoryname']) == '')
         {
            message_die(GENERAL_ERROR, "Can't create a category without a name");
         }

         $sql = "SELECT MAX(cat_order) AS max_order
            FROM " . CATEGORIES_TABLE;
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't get order number from categories table", "", __LINE__, __FILE__, $sql);
         }
         $row = $db->sql_fetchrow($result);

         $max_order = $row['max_order'];
         $next_order = $max_order + 10;

         //
         // There is no problem having duplicate forum names so we won't check for it.
         //
         $sql = "INSERT INTO " . CATEGORIES_TABLE . " (cat_title, cat_order)
            VALUES ('" . str_replace("\'", "''", $HTTP_POST_VARS['categoryname']) . "', $next_order)";
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't insert row in categories table", "", __LINE__, __FILE__, $sql);
         }

         $message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

         message_die(GENERAL_MESSAGE, $message);

         break;
         
      case 'editcat':
         //
         // Show form to edit a category
         //
         $newmode = 'modcat';
         $buttonvalue = $lang['Update'];

         $cat_id = intval($HTTP_GET_VARS[POST_CAT_URL]);

         $row = get_info('category', $cat_id);
         $cat_title = $row['cat_title'];

         $template->set_filenames(array(
            "body" => "admin/category_edit_body.tpl")
         );

         $s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" /><input type="hidden" name="' . POST_CAT_URL . '" value="' . $cat_id . '" />';

         $template->assign_vars(array(
            'CAT_TITLE' => $cat_title,

            'L_EDIT_CATEGORY' => $lang['Edit_Category'],
            'L_EDIT_CATEGORY_EXPLAIN' => $lang['Edit_Category_explain'],
            'L_CATEGORY' => $lang['Category'],

            'S_HIDDEN_FIELDS' => $s_hidden_fields,
            'S_SUBMIT_VALUE' => $buttonvalue,
            'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"))
         );

         $template->pparse("body");
         break;

      case 'modcat':
         // Modify a category in the DB
         $sql = "UPDATE " . CATEGORIES_TABLE . "
            SET cat_title = '" . str_replace("\'", "''", $HTTP_POST_VARS['cat_title']) . "'
            WHERE cat_id = " . intval($HTTP_POST_VARS[POST_CAT_URL]);
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't update forum information", "", __LINE__, __FILE__, $sql);
         }

         $message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

         message_die(GENERAL_MESSAGE, $message);

         break;
         
      case 'deleteforum':
         // Show form to delete a forum
         $forum_id = intval($HTTP_GET_VARS[POST_FORUM_URL]);

         $select_to = '<select name="to_id">';
         $select_to .= "<option value=\"-1\"$s>" . $lang['Delete_all_posts'] . "</option>\n";
         $select_to .= get_list('forum', $forum_id, 0);
         $select_to .= '</select>';

         $buttonvalue = $lang['Move_and_Delete'];

         $newmode = 'movedelforum';

         $foruminfo = get_info('forum', $forum_id);
         $name = $foruminfo['forum_name'];

         $template->set_filenames(array(
            "body" => "admin/forum_delete_body.tpl")
         );

         $s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" /><input type="hidden" name="from_id" value="' . $forum_id . '" />';

         $template->assign_vars(array(
            'NAME' => $name,

            'L_FORUM_DELETE' => $lang['Forum_delete'],
            'L_FORUM_DELETE_EXPLAIN' => $lang['Forum_delete_explain'],
            'L_MOVE_CONTENTS' => $lang['Move_contents'],
            'L_FORUM_NAME' => $lang['Forum_name'],

            "S_HIDDEN_FIELDS" => $s_hidden_fields,
            'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"),
            'S_SELECT_TO' => $select_to,
            'S_SUBMIT_VALUE' => $buttonvalue)
         );

         $template->pparse("body");
         break;

      case 'movedelforum':
         //
         // Move or delete a forum in the DB
         //
         $from_id = intval($HTTP_POST_VARS['from_id']);
         $to_id = intval($HTTP_POST_VARS['to_id']);
         $delete_old = intval($HTTP_POST_VARS['delete_old']);

         // Either delete or move all posts in a forum
         if($to_id == -1)
         {
            // Delete polls in this forum
            $sql = "SELECT v.vote_id
               FROM " . VOTE_DESC_TABLE . " v, " . TOPICS_TABLE . " t
               WHERE t.forum_id = $from_id
                  AND v.topic_id = t.topic_id";
            if (!($result = $db->sql_query($sql)))
            {
               message_die(GENERAL_ERROR, "Couldn't obtain list of vote ids", "", __LINE__, __FILE__, $sql);
            }

            if ($row = $db->sql_fetchrow($result))
            {
               $vote_ids = '';
               do
               {
                  $vote_ids = (($vote_ids != '') ? ', ' : '') . $row['vote_id'];
               }
               while ($row = $db->sql_fetchrow($result));

               $sql = "DELETE FROM " . VOTE_DESC_TABLE . "
                  WHERE vote_id IN ($vote_ids)";
               $db->sql_query($sql);

               $sql = "DELETE FROM " . VOTE_RESULTS_TABLE . "
                  WHERE vote_id IN ($vote_ids)";
               $db->sql_query($sql);

               $sql = "DELETE FROM " . VOTE_USERS_TABLE . "
                  WHERE vote_id IN ($vote_ids)";
               $db->sql_query($sql);
            }
            $db->sql_freeresult($result);
            
            include($phpbb_root_path . "includes/prune.$phpEx");
            prune($from_id, 0, true); // Delete everything from forum
         }
         else
         {
            $sql = "SELECT *
               FROM " . FORUMS_TABLE . "
               WHERE forum_id IN ($from_id, $to_id)";
            if( !$result = $db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, "Couldn't verify existence of forums", "", __LINE__, __FILE__, $sql);
            }

            if($db->sql_numrows($result) != 2)
            {
               message_die(GENERAL_ERROR, "Ambiguous forum ID's", "", __LINE__, __FILE__);
            }
            $sql = "UPDATE " . TOPICS_TABLE . "
               SET forum_id = $to_id
               WHERE forum_id = $from_id";
            if( !$result = $db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, "Couldn't move topics to other forum", "", __LINE__, __FILE__, $sql);
            }
            $sql = "UPDATE " . POSTS_TABLE . "
               SET   forum_id = $to_id
               WHERE forum_id = $from_id";
            if( !$result = $db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, "Couldn't move posts to other forum", "", __LINE__, __FILE__, $sql);
            }
            sync('forum', $to_id);
         }

         // Alter Mod level if appropriate - 2.0.4
         $sql = "SELECT ug.user_id
            FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug
            WHERE a.forum_id <> $from_id
               AND a.auth_mod = 1
               AND ug.group_id = a.group_id";
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't obtain moderator list", "", __LINE__, __FILE__, $sql);
         }

         if ($row = $db->sql_fetchrow($result))
         {
            $user_ids = '';
            do
            {
               $user_ids .= (($user_ids != '') ? ', ' : '' ) . $row['user_id'];
            }
            while ($row = $db->sql_fetchrow($result));

            $sql = "SELECT ug.user_id
               FROM " . AUTH_ACCESS_TABLE . " a, " . USER_GROUP_TABLE . " ug
               WHERE a.forum_id = $from_id
                  AND a.auth_mod = 1
                  AND ug.group_id = a.group_id
                  AND ug.user_id NOT IN ($user_ids)";
            if( !$result2 = $db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, "Couldn't obtain moderator list", "", __LINE__, __FILE__, $sql);
            }
               
            if ($row = $db->sql_fetchrow($result2))
            {
               $user_ids = '';
               do
               {
                  $user_ids .= (($user_ids != '') ? ', ' : '' ) . $row['user_id'];
               }
               while ($row = $db->sql_fetchrow($result2));

               $sql = "UPDATE " . USERS_TABLE . "
                  SET user_level = " . USER . "
                  WHERE user_id IN ($user_ids)
                     AND user_level <> " . ADMIN;
               $db->sql_query($sql);
            }
            $db->sql_freeresult($result);

         }
         $db->sql_freeresult($result2);

         $sql = "DELETE FROM " . FORUMS_TABLE . "
            WHERE forum_id = $from_id";
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't delete forum", "", __LINE__, __FILE__, $sql);
         }
         // Begin Simple Subforums MOD
         // Move subforums to category
         $sql = "UPDATE " . FORUMS_TABLE . " SET forum_parent = '0' WHERE forum_parent = '$from_id'";
         $db->sql_query($sql);
         // End Simple Subforums MOD

         $sql = "DELETE FROM " . AUTH_ACCESS_TABLE . "
            WHERE forum_id = $from_id";
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't delete forum", "", __LINE__, __FILE__, $sql);
         }
         
         $sql = "DELETE FROM " . PRUNE_TABLE . "
            WHERE forum_id = $from_id";
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't delete forum prune information!", "", __LINE__, __FILE__, $sql);
         }

         $message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

         message_die(GENERAL_MESSAGE, $message);

         break;
         
      case 'deletecat':
         //
         // Show form to delete a category
         //
         $cat_id = intval($HTTP_GET_VARS[POST_CAT_URL]);

         $buttonvalue = $lang['Move_and_Delete'];
         $newmode = 'movedelcat';
         $catinfo = get_info('category', $cat_id);
         $name = $catinfo['cat_title'];

         if ($catinfo['number'] == 1)
         {
            $sql = "SELECT count(*) as total
               FROM ". FORUMS_TABLE;
            if( !$result = $db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, "Couldn't get Forum count", "", __LINE__, __FILE__, $sql);
            }
            $count = $db->sql_fetchrow($result);
            $count = $count['total'];

            if ($count > 0)
            {
               message_die(GENERAL_ERROR, $lang['Must_delete_forums']);
            }
            else
            {
               $select_to = $lang['Nowhere_to_move'];
            }
         }
         else
         {
            $select_to = '<select name="to_id">';
            $select_to .= get_list('category', $cat_id, 0);
            $select_to .= '</select>';
         }

         $template->set_filenames(array(
            "body" => "admin/forum_delete_body.tpl")
         );

         $s_hidden_fields = '<input type="hidden" name="mode" value="' . $newmode . '" /><input type="hidden" name="from_id" value="' . $cat_id . '" />';

         $template->assign_vars(array(
            'NAME' => $name,

            'L_FORUM_DELETE' => $lang['Forum_delete'],
            'L_FORUM_DELETE_EXPLAIN' => $lang['Forum_delete_explain'],
            'L_MOVE_CONTENTS' => $lang['Move_contents'],
            'L_FORUM_NAME' => $lang['Forum_name'],
            
            'S_HIDDEN_FIELDS' => $s_hidden_fields,
            'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"),
            'S_SELECT_TO' => $select_to,
            'S_SUBMIT_VALUE' => $buttonvalue)
         );

         $template->pparse("body");
         break;

      case 'movedelcat':
         //
         // Move or delete a category in the DB
         //
         $from_id = intval($HTTP_POST_VARS['from_id']);
         $to_id = intval($HTTP_POST_VARS['to_id']);

         if (!empty($to_id))
         {
            $sql = "SELECT *
               FROM " . CATEGORIES_TABLE . "
               WHERE cat_id IN ($from_id, $to_id)";
            if( !$result = $db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, "Couldn't verify existence of categories", "", __LINE__, __FILE__, $sql);
            }
            if($db->sql_numrows($result) != 2)
            {
               message_die(GENERAL_ERROR, "Ambiguous category ID's", "", __LINE__, __FILE__);
            }

            $sql = "UPDATE " . FORUMS_TABLE . "
               SET cat_id = $to_id
               WHERE cat_id = $from_id";
            if( !$result = $db->sql_query($sql) )
            {
               message_die(GENERAL_ERROR, "Couldn't move forums to other category", "", __LINE__, __FILE__, $sql);
            }
         }

         $sql = "DELETE FROM " . CATEGORIES_TABLE ."
            WHERE cat_id = $from_id";
            
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't delete category", "", __LINE__, __FILE__, $sql);
         }

         $message = $lang['Forums_updated'] . "<br /><br />" . sprintf($lang['Click_return_forumadmin'], "<a href=\"" . append_sid("admin_forums.$phpEx") . "\">", "</a>") . "<br /><br />" . sprintf($lang['Click_return_admin_index'], "<a href=\"" . append_sid("index.$phpEx?pane=right") . "\">", "</a>");

         message_die(GENERAL_MESSAGE, $message);

         break;

      case 'forum_order':
         //
         // Change order of forums in the DB
         //
         $move = intval($HTTP_GET_VARS['move']);
         $forum_id = intval($HTTP_GET_VARS[POST_FORUM_URL]);

         $forum_info = get_info('forum', $forum_id);

         $cat_id = $forum_info['cat_id'];
// Begin Simple Subforums MOD
         if( !$forum_info['forum_parent'] )
         {
            // Find previous/next forum
            if( $move > 0 )
            {
               $sql = "SELECT forum_id, forum_order FROM " . FORUMS_TABLE . " WHERE cat_id = '$cat_id' AND forum_parent = '0' AND forum_order > '" . $forum_info['forum_order'] . "' ORDER BY forum_order ASC";
            }
            
            else
            {
               $sql = "SELECT forum_id, forum_order FROM " . FORUMS_TABLE . " WHERE cat_id = '$cat_id' AND forum_parent = '0' AND forum_order < '" . $forum_info['forum_order'] . "' ORDER BY forum_order DESC";
            }
            
            if( !($result = $db->sql_query($sql)) )
            {
               message_die(GENERAL_ERROR, "Couldn't change category order", '', __LINE__, __FILE__, $sql);
            }
            
            $row = $db->sql_fetchrow($result);
            $db->sql_freeresult($result);
            if($row !== false)
            {
               // Swap forum orders
               $sql = "UPDATE " . FORUMS_TABLE . " SET forum_order = '" . $row['forum_order'] . "' WHERE forum_id = '$forum_id'";
               $db->sql_query($sql);
               
               $sql = "UPDATE " . FORUMS_TABLE . " SET forum_order = '" . $forum_info['forum_order'] . "' WHERE forum_id = '" . $row['forum_id'];
               $db->sql_query($sql);
            }
         }
         
         else
         {
         // End Simple Subforums MOD

         $sql = "UPDATE " . FORUMS_TABLE . "
            SET forum_order = forum_order + $move
            WHERE forum_id = $forum_id";
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql);
         }

         renumber_order('forum', $forum_info['cat_id']);
// Begin Simple Subforums MOD
         }
         // End Simple Subforums MOD
         $show_index = TRUE;

         break;
         
      case 'cat_order':
         //
         // Change order of categories in the DB
         //
         $move = intval($HTTP_GET_VARS['move']);
         $cat_id = intval($HTTP_GET_VARS[POST_CAT_URL]);

         $sql = "UPDATE " . CATEGORIES_TABLE . "
            SET cat_order = cat_order + $move
            WHERE cat_id = $cat_id";
         if( !$result = $db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Couldn't change category order", "", __LINE__, __FILE__, $sql);
         }

         renumber_order('category');
         $show_index = TRUE;

         break;

      case 'forum_sync':
         sync('forum', intval($HTTP_GET_VARS[POST_FORUM_URL]));
         $show_index = TRUE;

         break;

      default:
         message_die(GENERAL_MESSAGE, $lang['No_mode']);
         break;
   }

   if ($show_index != TRUE)
   {
      include('./page_footer_admin.'.$phpEx);
      exit;
   }
}

//
// Start page proper
//
$template->set_filenames(array(
   "body" => "admin/forum_admin_body.tpl")
);

$template->assign_vars(array(
   'S_FORUM_ACTION' => append_sid("admin_forums.$phpEx"),
   'L_FORUM_TITLE' => $lang['Forum_admin'],
   'L_FORUM_EXPLAIN' => $lang['Forum_admin_explain'],
   'L_CREATE_FORUM' => $lang['Create_forum'],
   'L_CREATE_CATEGORY' => $lang['Create_category'],
   'L_EDIT' => $lang['Edit'],
   'L_DELETE' => $lang['Delete'],
   'L_MOVE_UP' => $lang['Move_up'],
   'L_MOVE_DOWN' => $lang['Move_down'],
   'L_RESYNC' => $lang['Resync'])
);

$sql = "SELECT cat_id, cat_title, cat_order
   FROM " . CATEGORIES_TABLE . "
   ORDER BY cat_order";
if( !$q_categories = $db->sql_query($sql) )
{
   message_die(GENERAL_ERROR, "Could not query categories list", "", __LINE__, __FILE__, $sql);
}

if( $total_categories = $db->sql_numrows($q_categories) )
{
   $category_rows = $db->sql_fetchrowset($q_categories);

   $sql = "SELECT *
      FROM " . FORUMS_TABLE . "
      ORDER BY cat_id, forum_order";
   if(!$q_forums = $db->sql_query($sql))
   {
      message_die(GENERAL_ERROR, "Could not query forums information", "", __LINE__, __FILE__, $sql);
   }

   if( $total_forums = $db->sql_numrows($q_forums) )
   {
      $forum_rows = $db->sql_fetchrowset($q_forums);
   }

   //
   // Okay, let's build the index
   //
   $gen_cat = array();

   for($i = 0; $i < $total_categories; $i++)
   {
      $cat_id = $category_rows[$i]['cat_id'];

      $template->assign_block_vars("catrow", array(
         'S_ADD_FORUM_SUBMIT' => "addforum[$cat_id]",
         'S_ADD_FORUM_NAME' => "forumname[$cat_id]",

         'CAT_ID' => $cat_id,
         'CAT_DESC' => $category_rows[$i]['cat_title'],

         'U_CAT_EDIT' => append_sid("admin_forums.$phpEx?mode=editcat&amp;" . POST_CAT_URL . "=$cat_id"),
         'U_CAT_DELETE' => append_sid("admin_forums.$phpEx?mode=deletecat&amp;" . POST_CAT_URL . "=$cat_id"),
         'U_CAT_MOVE_UP' => append_sid("admin_forums.$phpEx?mode=cat_order&amp;move=-15&amp;" . POST_CAT_URL . "=$cat_id"),
         'U_CAT_MOVE_DOWN' => append_sid("admin_forums.$phpEx?mode=cat_order&amp;move=15&amp;" . POST_CAT_URL . "=$cat_id"),
         'U_VIEWCAT' => append_sid($phpbb_root_path."index.$phpEx?" . POST_CAT_URL . "=$cat_id"))
      );

      for($j = 0; $j < $total_forums; $j++)
      {
         $forum_id = $forum_rows[$j]['forum_id'];
         
         if ($forum_rows[$j]['cat_id'] == $cat_id&& $forum_rows[$j]['forum_parent'] == 0)
         {

            $template->assign_block_vars("catrow.forumrow",   array(
               'FORUM_NAME' => $forum_rows[$j]['forum_name'],
               'FORUM_DESC' => $forum_rows[$j]['forum_desc'],
               'ROW_COLOR' => $row_color,
               'NUM_TOPICS' => $forum_rows[$j]['forum_topics'],
               'NUM_POSTS' => $forum_rows[$j]['forum_posts'],

               'U_VIEWFORUM' => append_sid($phpbb_root_path."viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id"),
               'U_FORUM_EDIT' => append_sid("admin_forums.$phpEx?mode=editforum&amp;" . POST_FORUM_URL . "=$forum_id"),
               'U_FORUM_DELETE' => append_sid("admin_forums.$phpEx?mode=deleteforum&amp;" . POST_FORUM_URL . "=$forum_id"),
               'U_FORUM_MOVE_UP' => append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=-15&amp;" . POST_FORUM_URL . "=$forum_id"),
               'U_FORUM_MOVE_DOWN' => append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=15&amp;" . POST_FORUM_URL . "=$forum_id"),
               'U_FORUM_RESYNC' => append_sid("admin_forums.$phpEx?mode=forum_sync&amp;" . POST_FORUM_URL . "=$forum_id"))
            );
// Begin Simple Subforums MOD
            for( $k = 0; $k < $total_forums; $k++ )
            {
               $forum_id2 = $forum_rows[$k]['forum_id'];
               if ( $forum_rows[$k]['forum_parent'] == $forum_id )
               {
                  $template->assign_block_vars("catrow.forumrow",   array(
                     'FORUM_NAME' => $forum_rows[$k]['forum_name'],
                     'FORUM_DESC' => $forum_rows[$k]['forum_desc'],
                     'ROW_COLOR' => $row_color,
                     'NUM_TOPICS' => $forum_rows[$k]['forum_topics'],
                     'NUM_POSTS' => $forum_rows[$k]['forum_posts'],
                     'STYLE' => ' style="padding-left: 20px;" ',
   
                     'U_VIEWFORUM' => append_sid($phpbb_root_path."viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id2"),
                     'U_FORUM_EDIT' => append_sid("admin_forums.$phpEx?mode=editforum&amp;" . POST_FORUM_URL . "=$forum_id2"),
                     'U_FORUM_DELETE' => append_sid("admin_forums.$phpEx?mode=deleteforum&amp;" . POST_FORUM_URL . "=$forum_id2"),
                     'U_FORUM_MOVE_UP' => append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=-15&amp;" . POST_FORUM_URL . "=$forum_id2"),
                     'U_FORUM_MOVE_DOWN' => append_sid("admin_forums.$phpEx?mode=forum_order&amp;move=15&amp;" . POST_FORUM_URL . "=$forum_id2"),
                     'U_FORUM_RESYNC' => append_sid("admin_forums.$phpEx?mode=forum_sync&amp;" . POST_FORUM_URL . "=$forum_id2"))
                  );

               }
               
            } // for ... forums
            // End Simple Subforums MOD
         }// if ... forumid == catid
         
      } // for ... forums

   } // for ... categories

}// if ... total_categories

$template->pparse("body");

include('./page_footer_admin.'.$phpEx);

?>
Forum Modding NooB, Admin of Many
Gral
Registered User
Registered User
 
Posts: 63
Joined: Fri Aug 25, 2006 2:48 pm

Postby Splinter on Tue Sep 05, 2006 8:35 pm

Useless will probably prove me wrong here :D

But I think the problem is with line 414 you need to put a , (comma) at the end of the line.
User avatar
Splinter
Coder
Coder
 
Posts: 483
Joined: Sun Feb 20, 2005 10:12 pm
Location: Nottingham, UK

Postby Gral on Tue Sep 05, 2006 8:37 pm

yep got it fixed mate,

However i have no idea how to use or set these up, i do not see any options in the ACP, im starting to feel like a 5 yr old on first day of school..... :shock:
Forum Modding NooB, Admin of Many
Gral
Registered User
Registered User
 
Posts: 63
Joined: Fri Aug 25, 2006 2:48 pm

PreviousNext

Return to How to mod some styles

Who is online

Users browsing this forum: No registered users and 1 guest