Your ultimate PunBB resource!
You are not logged in.
alth wrote:
I've basically tried everything.. Went through the whole install process again.. double checked etc etc but it still won't work. Ended up with just adding the URLs as links manually with html in the forum discriptions..
Did you read through the posts here?
Did you see and try this?...
http://www.punres.org/viewtopic.php?pid=9840#p9840
Offline
alth - it is very strange - can you send me all the changed files you did for Sub Forum and i will check them? others have had no problem with it.
twohawks solution will otherwise work but it is not as practical, especially if you have lots of sub forums as you will need to manually edit each ones description and change it as you move a sub forum elsewhere.
Offline
working for 1.2.14 thanx
Offline
Thanks naitkris. I had not yet upgraded to a newer version of the sub forum mod ;^)
Offline
I have a problem with this mod, and I haven't seen it pass out here, so I'll just throw it in..
When using the mod, when I try to edit a forum on admin mode (admin_forums.php), it says:
Info
Bad request. The link you followed is incorrect or outdated.
Go back
What can this be? Because when I remove the modded admin_forums.php file and replace it with the original, it lets me edit it perfectly (except for the sub-forum stuff I am aiming to get).
Can anyone help me out on this one?? That'd be GREAT.
As far as I know, there have been no mods that I have currently installed, that have adjusted my admin_forums.php file. ![]()
Last edited by randomphpnoob (2007-02-20 08:02:56)
Offline
My admin_forums.php file:
<?php
/***********************************************************************
Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org)
This file is part of PunBB.
PunBB 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.
PunBB is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
************************************************************************/
// Tell header.php to use the admin template
define('PUN_ADMIN_CONSOLE', 1);
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'include/common_admin.php';
if ($pun_user['g_id'] > PUN_ADMIN)
message($lang_common['No permission']);
// Add a "default" forum
if (isset($_POST['add_forum']))
{
confirm_referrer('admin_forums.php');
$add_to_cat = intval($_POST['add_to_cat']);
if ($add_to_cat < 1)
message($lang_common['Bad request']);
$db->query('INSERT INTO '.$db->prefix.'forums (cat_id) VALUES('.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $db->error());
// Regenerate the quickjump cache
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache();
redirect('admin_forums.php', 'Forum added. Redirecting …');
}
// Delete a forum
else if (isset($_GET['del_forum']))
{
confirm_referrer('admin_forums.php');
$forum_id = intval($_GET['del_forum']);
if ($forum_id < 1)
message($lang_common['Bad request']);
if (isset($_POST['del_forum_comply'])) // Delete a forum with all posts
{
@set_time_limit(0);
// Prune all posts and topics
prune($forum_id, 1, -1);
// Locate any "orphaned redirect topics" and delete them
$result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
$num_orphans = $db->num_rows($result);
if ($num_orphans)
{
for ($i = 0; $i < $num_orphans; ++$i)
$orphans[] = $db->result($result, $i);
$db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
}
// Delete the forum and any forum specific group permissions
$db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $db->error());
$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
// Regenerate the quickjump cache
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache();
redirect('admin_forums.php', 'Forum deleted. Redirecting …');
}
else // If the user hasn't confirmed the delete
{
$result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
$forum_name = pun_htmlspecialchars($db->result($result));
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
require PUN_ROOT.'header.php';
generate_admin_menu('forums');
?>
<div class="blockform">
<h2><span>Confirm delete forum</span></h2>
<div class="box">
<form method="post" action="admin_forums.php?del_forum=<?php echo $forum_id ?>">
<div class="inform">
<fieldset>
<legend>Important! Read before deleting</legend>
<div class="infldset">
<p>Are you sure that you want to delete the forum "<?php echo $forum_name ?>"?</p>
<p>WARNING! Deleting a forum will delete all posts (if any) in that forum!</p>
</div>
</fieldset>
</div>
<p><input type="submit" name="del_forum_comply" value="Delete" /><a href="javascript:history.go(-1)">Go back</a></p>
</form>
</div>
</div>
<div class="clearer"></div>
</div>
<?php
require PUN_ROOT.'footer.php';
}
}
// Update forum positions
else if (isset($_POST['update_positions']))
{
confirm_referrer('admin_forums.php');
while (list($forum_id, $disp_position) = @each($_POST['position']))
{
if (!preg_match('#^\d+$#', $disp_position))
message('Position must be a positive integer value.');
$db->query('UPDATE '.$db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
}
// Regenerate the quickjump cache
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache();
redirect('admin_forums.php', 'Forums updated. Redirecting …');
}
else if (isset($_GET['edit_forum']))
{
$forum_id = intval($_GET['edit_forum']);
if ($forum_id < 1)
message($lang_common['Bad request']);
// Update group permissions for $forum_id
if (isset($_POST['save']))
{
confirm_referrer('admin_forums.php');
// Start with the forum details
$forum_name = trim($_POST['forum_name']);
$forum_desc = pun_linebreaks(trim($_POST['forum_desc']));
$cat_id = intval($_POST['cat_id']);
$sort_by = intval($_POST['sort_by']);
$redirect_url = isset($_POST['redirect_url']) ? trim($_POST['redirect_url']) : null;
if ($forum_name == '')
message('You must enter a forum name.');
if ($cat_id < 1)
message($lang_common['Bad request']);
$forum_desc = ($forum_desc != '') ? '\''.$db->escape($forum_desc).'\'' : 'NULL';
$redirect_url = ($redirect_url != '') ? '\''.$db->escape($redirect_url).'\'' : 'NULL';
$db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
// Now let's deal with the permissions
if (isset($_POST['read_forum_old']))
{
$result = $db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
while ($cur_group = $db->fetch_assoc($result))
{
$read_forum_new = ($cur_group['g_read_board'] == '1') ? isset($_POST['read_forum_new'][$cur_group['g_id']]) ? '1' : '0' : intval($_POST['read_forum_old'][$cur_group['g_id']]);
$post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0';
$post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? '1' : '0';
// Check if the new settings differ from the old
if ($read_forum_new != $_POST['read_forum_old'][$cur_group['g_id']] || $post_replies_new != $_POST['post_replies_old'][$cur_group['g_id']] || $post_topics_new != $_POST['post_topics_old'][$cur_group['g_id']])
{
// If the new settings are identical to the default settings for this group, delete it's row in forum_perms
if ($read_forum_new == '1' && $post_replies_new == $cur_group['g_post_replies'] && $post_topics_new == $cur_group['g_post_topics'])
$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
else
{
// Run an UPDATE and see if it affected a row, if not, INSERT
$db->query('UPDATE '.$db->prefix.'forum_perms SET read_forum='.$read_forum_new.', post_replies='.$post_replies_new.', post_topics='.$post_topics_new.' WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
if (!$db->affected_rows())
$db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$cur_group['g_id'].', '.$forum_id.', '.$read_forum_new.', '.$post_replies_new.', '.$post_topics_new.')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
}
}
}
}
// Regenerate the quickjump cache
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache();
redirect('admin_forums.php', 'Forum updated. Redirecting …');
}
else if (isset($_POST['revert_perms']))
{
confirm_referrer('admin_forums.php');
$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
// Regenerate the quickjump cache
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache();
redirect('admin_forums.php?edit_forum='.$forum_id, 'Permissions reverted to defaults. Redirecting …');
}
// Fetch forum info
$result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
message($lang_common['Bad request']);
$cur_forum = $db->fetch_assoc($result);
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
require PUN_ROOT.'header.php';
generate_admin_menu('forums');
?>
<div class="blockform">
<h2><span>Edit forum</span></h2>
<div class="box">
<form id="edit_forum" method="post" action="admin_forums.php?edit_forum=<?php echo $forum_id ?>">
<p class="submittop"><input type="submit" name="save" value="Save changes" tabindex="6" /></p>
<div class="inform">
<fieldset>
<legend>Edit forum details</legend>
<div class="infldset">
<table class="aligntop" cellspacing="0">
<tr>
<th scope="row">Forum name</th>
<td><input type="text" name="forum_name" size="35" maxlength="80" value="<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?>" tabindex="1" /></td>
</tr>
<tr>
<th scope="row">Description (HTML)</th>
<td><textarea name="forum_desc" rows="3" cols="50" tabindex="2"><?php echo pun_htmlspecialchars($cur_forum['forum_desc']) ?></textarea></td>
</tr>
<tr>
<th scope="row">Category</th>
<td>
<select name="cat_id" tabindex="3">
<?php
$result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error());
while ($cur_cat = $db->fetch_assoc($result))
{
$selected = ($cur_cat['id'] == $cur_forum['cat_id']) ? ' selected="selected"' : '';
echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'"'.$selected.'>'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
}
?>
</select>
</td>
</tr>
<tr>
<th scope="row">Sort topics by</th>
<td>
<select name="sort_by" tabindex="4">
<option value="0"<?php if ($cur_forum['sort_by'] == '0') echo ' selected="selected"' ?>>Last post</option>
<option value="1"<?php if ($cur_forum['sort_by'] == '1') echo ' selected="selected"' ?>>Topic start</option>
</select>
</td>
</tr>
<tr>
<th scope="row">Redirect URL</th>
<td><?php echo ($cur_forum['num_topics']) ? 'Only available in empty forums' : '<input type="text" name="redirect_url" size="45" maxlength="100" value="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" tabindex="5" />'; ?></td>
</tr>
</table>
</div>
</fieldset>
</div>
<div class="inform">
<fieldset>
<legend>Edit group permissions for this forum</legend>
<div class="infldset">
<p>In this form, you can set the forum specific permissions for the different user groups. If you haven't made any changes to this forums group permissions, what you see below is the default based on settings in <a href="admin_groups.php">User groups</a>. Administrators always have full permissions and are thus excluded. Permission settings that differ from the default permissions for the user group are marked red. The "Read forum" permission checkbox will be disabled if the group in question lacks the "Read board" permission. For redirect forums, only the "Read forum" permission is editable.</p>
<table id="forumperms" cellspacing="0">
<thead>
<tr>
<th class="atcl"> </th>
<th>Read forum</th>
<th>Post replies</th>
<th>Post topics</th>
</tr>
</thead>
<tbody>
<?php
$result = $db->query('SELECT g.g_id, g.g_title, g.g_read_board, g.g_post_replies, g.g_post_topics, fp.read_forum, fp.post_replies, fp.post_topics FROM '.$db->prefix.'groups AS g LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (g.g_id=fp.group_id AND fp.forum_id='.$forum_id.') WHERE g.g_id!='.PUN_ADMIN.' ORDER BY g.g_id') or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error());
while ($cur_perm = $db->fetch_assoc($result))
{
$read_forum = ($cur_perm['read_forum'] != '0') ? true : false;
$post_replies = (($cur_perm['g_post_replies'] == '0' && $cur_perm['post_replies'] == '1') || ($cur_perm['g_post_replies'] == '1' && $cur_perm['post_replies'] != '0')) ? true : false;
$post_topics = (($cur_perm['g_post_topics'] == '0' && $cur_perm['post_topics'] == '1') || ($cur_perm['g_post_topics'] == '1' && $cur_perm['post_topics'] != '0')) ? true : false;
// Determine if the current sittings differ from the default or not
$read_forum_def = ($cur_perm['read_forum'] == '0') ? false : true;
$post_replies_def = (($post_replies && $cur_perm['g_post_replies'] == '0') || (!$post_replies && ($cur_perm['g_post_replies'] == '' || $cur_perm['g_post_replies'] == '1'))) ? false : true;
$post_topics_def = (($post_topics && $cur_perm['g_post_topics'] == '0') || (!$post_topics && ($cur_perm['g_post_topics'] == '' || $cur_perm['g_post_topics'] == '1'))) ? false : true;
?>
<tr>
<th class="atcl"><?php echo pun_htmlspecialchars($cur_perm['g_title']) ?></th>
<td<?php if (!$read_forum_def) echo ' class="nodefault"'; ?>>
<input type="hidden" name="read_forum_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($read_forum) ? '1' : '0'; ?>" />
<input type="checkbox" name="read_forum_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($read_forum) ? ' checked="checked"' : ''; ?><?php echo ($cur_perm['g_read_board'] == '0') ? ' disabled="disabled"' : ''; ?> />
</td>
<td<?php if (!$post_replies_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>>
<input type="hidden" name="post_replies_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_replies) ? '1' : '0'; ?>" />
<input type="checkbox" name="post_replies_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_replies) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> />
</td>
<td<?php if (!$post_topics_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>>
<input type="hidden" name="post_topics_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_topics) ? '1' : '0'; ?>" />
<input type="checkbox" name="post_topics_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_topics) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> />
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="fsetsubmit"><input type="submit" name="revert_perms" value="Revert to default" /></div>
</div>
</fieldset>
</div>
<p class="submitend"><input type="submit" name="save" value="Save changes" /></p>
</form>
</div>
</div>
<div class="clearer"></div>
</div>
<?php
require PUN_ROOT.'footer.php';
}
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
require PUN_ROOT.'header.php';
generate_admin_menu('forums');
?>
<div class="blockform">
<h2><span>Add forum</span></h2>
<div class="box">
<form method="post" action="admin_forums.php?action=adddel">
<div class="inform">
<fieldset>
<legend>Create a new forum</legend>
<div class="infldset">
<table class="aligntop" cellspacing="0">
<tr>
<th scope="row">Add forum to category<div><input type="submit" name="add_forum" value=" Add " tabindex="2" /></div></th>
<td>
<select name="add_to_cat" tabindex="1">
<?php
$result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error());
while ($cur_cat = $db->fetch_assoc($result))
echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
?>
</select>
<span>Select the category to which you wish to add a new forum.</span>
</td>
</tr>
</table>
</div>
</fieldset>
</div>
</form>
</div>
<h2 class="block2"><span>Edit forums</span></h2>
<div class="box">
<form id="edforum" method="post" action="admin_forums.php?action=edit">
<p class="submittop"><input type="submit" name="update_positions" value="Update positions" tabindex="3" /></p>
<?php
$tabindex_count = 4;
// Display all the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
$cur_category = 0;
while ($cur_forum = $db->fetch_assoc($result))
{
if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?
{
if ($cur_category != 0)
echo "\t\t\t\t\t\t\t".'</table>'."\n\t\t\t\t\t\t".'</div>'."\n\t\t\t\t\t".'</fieldset>'."\n\t\t\t\t".'</div>'."\n";
?>
<div class="inform">
<fieldset>
<legend>Category: <?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></legend>
<div class="infldset">
<table cellspacing="0">
<?php
$cur_category = $cur_forum['cid'];
}
?>
<tr>
<th><a href="admin_forums.php?edit_forum=<?php echo $cur_forum['fid'] ?>">Edit</a> - <a href="admin_forums.php?del_forum=<?php echo $cur_forum['fid'] ?>">Delete</a></th>
<td>Position <input type="text" name="position[<?php echo $cur_forum['fid'] ?>]" size="3" maxlength="3" value="<?php echo $cur_forum['disp_position'] ?>" tabindex="<?php echo $tabindex_count ?>" />
<strong><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></strong></td>
</tr>
<?php
$tabindex_count += 2;
}
?>
</table>
</div>
</fieldset>
</div>
<p class="submitend"><input type="submit" name="update_positions" value="Update positions" tabindex="<?php echo $tabindex_count ?>" /></p>
</form>
</div>
</div>
<div class="clearer"></div>
</div>
<?php
require PUN_ROOT.'footer.php';Offline
anyone? please?
I really need this mod, and it won't work
.
Offline
hi randomphpnoob,
you need to update admin_forums.php properly, checking the admin_forums.php you just posted against my admin_forums.php, it revealed 5 places that are missing changes for the Sub Forum mod, example of 2 places are below:
i'd send you my admins_forums.php except i have changed it in a few places for other things so it wouldn't be the best if you are only adding Sub Forums. best is to reinstall the mod using the steps provided.
Offline
Another small fix (cosmetic) to Sub Forum Mod - thanks to bingiman for spotting this.
Problem is:
bingiman wrote:
Something is not quite right with this mod. I created (2) sub-forums and made myself moderator of 1 but yet when I check it, I am listed as moderator of both. However, if I go my profile under "Administration" the box is not checked. Has anyone noticed this before or is there a way to resolve this issue?
Update: What I have noticed in my case is this: I have 2 sub-forums. If I check off #1 as moderator it then makes me moderator of #1 and #2. If I check off just sub-forum #2, then it does not check off sub-forum #1 so there definitely is a bug here. Hope I explained myself properly.
Fix is:
In viewforum.php
FIND:
<?php echo $forum_field."\n".$moderators ?>REPLACE WITH:
<?php echo $forum_field;
if ($cur_subforum['moderators'] != '') {
echo "\n".$moderators;
}
?>Last edited by naitkris (2007-02-22 17:14:19)
Offline
thanks so much. the weird thing is that I've done these changes two times, and didn't it would be anything that I copied/pasted anything wrong.
again; thanks!!
Offline
naitkris wrote:
hi randomphpnoob,
you need to update admin_forums.php properly, checking the admin_forums.php you just posted against my admin_forums.php, it revealed 5 places that are missing changes for the Sub Forum mod, example of 2 places are below:
http://student.cs.ucc.ie/~knmj1/admin_f … operly.png
i'd send you my admins_forums.php except i have changed it in a few places for other things so it wouldn't be the best if you are only adding Sub Forums. best is to reinstall the mod using the steps provided.
oh shite, I think I might have posted the original admin_forums.php file ![]()
Offline
randomphpnoob wrote:
I think I might have posted the original admin_forums.php file
no worries randomphpnoob. if you want to post it or email it again that is fine.
Last edited by naitkris (2007-02-24 07:03:53)
Offline
i just noticed this but some optimised code for index.php which was fixed by binjured but was not included in version 1.0.5 and so it was left out of 1.0.6 also. it dramatically reduces processing time as the number of queries needed is cut down, so implement this fix by binjured manually if you haven't already - it is included in 1.0.7. also the problem spotted by bingiman to do with moderators in the parent forum of multiple sub forums is now fixed as well.
Sub Forum Mod 1.0.7
Sub Forum Mod 1.0.7 w/ Index View
History:
Fixed by binjured:
in version 1.0.7
- Optimised code on index.php so query isn't run for every forum processed
Fixed by naitkris:
in version 1.0.7
- Fixed "Moderated by" when viewing parent forum of multiple sub-forums with/without moderators
in version 1.0.6
- Fixed items in the quickjump so sub forums are indented (like fix in 1.0.4 by NeoTall for search)
Fixed by Timpa:
in version 1.0.5
- Correctly sorting subforums
- Now showing last post as it should
Fixed by NeoTall (Rus):
in version 1.0.4
- Fixed items in combobox "Select where to search"
in version 1.0.3
- Fixed search in SubForum when using "Non-MultiByted" language
in version 1.0.2
- Correctly displaying Last Post, Last Poster and Last Posted Time
- Correctly displaying Total Topics and Total Posts
in version 1.0.1
- Correctly creating Last Post link
- Correctly displaying word "Topics" on SubForum header
You will need to re-generate your quickjump cache after applying this mod for the quickjump to indent. The Clear Cache administration plugin can do this for you easily and is available from the PunBB Downloads page.
All credit to nico_somb for the Index View version as it is just taken from his version and modified a tiny bit to work with this one.
Sub Forum Mod is copyright of pabb.
Last edited by naitkris (2007-02-24 07:04:14)
Offline
I have retried, and still it stinkin' stops on me.
Again; here's my file:
<?php
/***********************************************************************
Copyright (C) 2002-2005 Rickard Andersson (rickard@punbb.org)
This file is part of PunBB.
PunBB 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.
PunBB is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston,
MA 02111-1307 USA
************************************************************************/
// Tell header.php to use the admin template
define('PUN_ADMIN_CONSOLE', 1);
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'include/common_admin.php';
if ($pun_user['g_id'] > PUN_ADMIN)
message($lang_common['No permission']);
// Add a "default" forum
if (isset($_POST['add_forum']))
{
confirm_referrer('admin_forums.php');
$add_to_cat = intval($_POST['add_to_cat']);
if ($add_to_cat < 1)
message($lang_common['Bad request']);
$db->query('INSERT INTO '.$db->prefix.'forums (cat_id) VALUES('.$add_to_cat.')') or error('Unable to create forum', __FILE__, __LINE__, $db->error());
// Regenerate the quickjump cache
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache();
redirect('admin_forums.php', 'Forum added. Redirecting …');
}
// Delete a forum
else if (isset($_GET['del_forum']))
{
confirm_referrer('admin_forums.php');
$forum_id = intval($_GET['del_forum']);
if ($forum_id < 1)
message($lang_common['Bad request']);
if (isset($_POST['del_forum_comply'])) // Delete a forum with all posts
{
@set_time_limit(0);
// Prune all posts and topics
prune($forum_id, 1, -1);
// Locate any "orphaned redirect topics" and delete them
$result = $db->query('SELECT t1.id FROM '.$db->prefix.'topics AS t1 LEFT JOIN '.$db->prefix.'topics AS t2 ON t1.moved_to=t2.id WHERE t2.id IS NULL AND t1.moved_to IS NOT NULL') or error('Unable to fetch redirect topics', __FILE__, __LINE__, $db->error());
$num_orphans = $db->num_rows($result);
if ($num_orphans)
{
for ($i = 0; $i < $num_orphans; ++$i)
$orphans[] = $db->result($result, $i);
$db->query('DELETE FROM '.$db->prefix.'topics WHERE id IN('.implode(',', $orphans).')') or error('Unable to delete redirect topics', __FILE__, __LINE__, $db->error());
}
// Delete the forum and any forum specific group permissions
$db->query('DELETE FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to delete forum', __FILE__, __LINE__, $db->error());
$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
// Regenerate the quickjump cache
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache();
redirect('admin_forums.php', 'Forum deleted. Redirecting …');
}
else // If the user hasn't confirmed the delete
{
$result = $db->query('SELECT forum_name FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
$forum_name = pun_htmlspecialchars($db->result($result));
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
require PUN_ROOT.'header.php';
generate_admin_menu('forums');
?>
<div class="blockform">
<h2><span>Confirm delete forum</span></h2>
<div class="box">
<form method="post" action="admin_forums.php?del_forum=<?php echo $forum_id ?>">
<div class="inform">
<fieldset>
<legend>Important! Read before deleting</legend>
<div class="infldset">
<p>Are you sure that you want to delete the forum "<?php echo $forum_name ?>"?</p>
<p>WARNING! Deleting a forum will delete all posts (if any) in that forum!</p>
</div>
</fieldset>
</div>
<p><input type="submit" name="del_forum_comply" value="Delete" /><a href="javascript:history.go(-1)">Go back</a></p>
</form>
</div>
</div>
<div class="clearer"></div>
</div>
<?php
require PUN_ROOT.'footer.php';
}
}
// Update forum positions
else if (isset($_POST['update_positions']))
{
confirm_referrer('admin_forums.php');
while (list($forum_id, $disp_position) = @each($_POST['position']))
{
if (!preg_match('#^\d+$#', $disp_position))
message('Position must be a positive integer value.');
$db->query('UPDATE '.$db->prefix.'forums SET disp_position='.$disp_position.' WHERE id='.intval($forum_id)) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
}
// Regenerate the quickjump cache
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache();
redirect('admin_forums.php', 'Forums updated. Redirecting …');
}
else if (isset($_GET['edit_forum']))
{
$forum_id = intval($_GET['edit_forum']);
if ($forum_id < 1)
message($lang_common['Bad request']);
// Update group permissions for $forum_id
if (isset($_POST['save']))
{
confirm_referrer('admin_forums.php');
// Start with the forum details
$forum_name = trim($_POST['forum_name']);
$forum_desc = pun_linebreaks(trim($_POST['forum_desc']));
$cat_id = intval($_POST['cat_id']);
$sort_by = intval($_POST['sort_by']);
$redirect_url = isset($_POST['redirect_url']) ? trim($_POST['redirect_url']) : null;
$parent_forum_id = intval($_POST['parent_forum']);
if ($forum_name == '')
message('You must enter a forum name.');
if ($cat_id < 1)
message($lang_common['Bad request']);
$forum_desc = ($forum_desc != '') ? '\''.$db->escape($forum_desc).'\'' : 'NULL';
$redirect_url = ($redirect_url != '') ? '\''.$db->escape($redirect_url).'\'' : 'NULL'; $db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.', parent_forum_id='.$parent_forum_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
// Now let's deal with the permissions
if (isset($_POST['read_forum_old']))
{
$result = $db->query('SELECT g_id, g_read_board, g_post_replies, g_post_topics FROM '.$db->prefix.'groups WHERE g_id!='.PUN_ADMIN) or error('Unable to fetch user group list', __FILE__, __LINE__, $db->error());
while ($cur_group = $db->fetch_assoc($result))
{
$read_forum_new = ($cur_group['g_read_board'] == '1') ? isset($_POST['read_forum_new'][$cur_group['g_id']]) ? '1' : '0' : intval($_POST['read_forum_old'][$cur_group['g_id']]);
$post_replies_new = isset($_POST['post_replies_new'][$cur_group['g_id']]) ? '1' : '0';
$post_topics_new = isset($_POST['post_topics_new'][$cur_group['g_id']]) ? '1' : '0';
// Check if the new settings differ from the old
if ($read_forum_new != $_POST['read_forum_old'][$cur_group['g_id']] || $post_replies_new != $_POST['post_replies_old'][$cur_group['g_id']] || $post_topics_new != $_POST['post_topics_old'][$cur_group['g_id']])
{
// If the new settings are identical to the default settings for this group, delete it's row in forum_perms
if ($read_forum_new == '1' && $post_replies_new == $cur_group['g_post_replies'] && $post_topics_new == $cur_group['g_post_topics'])
$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
else
{
// Run an UPDATE and see if it affected a row, if not, INSERT
$db->query('UPDATE '.$db->prefix.'forum_perms SET read_forum='.$read_forum_new.', post_replies='.$post_replies_new.', post_topics='.$post_topics_new.' WHERE group_id='.$cur_group['g_id'].' AND forum_id='.$forum_id) or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
if (!$db->affected_rows())
$db->query('INSERT INTO '.$db->prefix.'forum_perms (group_id, forum_id, read_forum, post_replies, post_topics) VALUES('.$cur_group['g_id'].', '.$forum_id.', '.$read_forum_new.', '.$post_replies_new.', '.$post_topics_new.')') or error('Unable to insert group forum permissions', __FILE__, __LINE__, $db->error());
}
}
}
}
// Regenerate the quickjump cache
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache();
redirect('admin_forums.php', 'Forum updated. Redirecting …');
}
else if (isset($_POST['revert_perms']))
{
confirm_referrer('admin_forums.php');
$db->query('DELETE FROM '.$db->prefix.'forum_perms WHERE forum_id='.$forum_id) or error('Unable to delete group forum permissions', __FILE__, __LINE__, $db->error());
// Regenerate the quickjump cache
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache();
redirect('admin_forums.php?edit_forum='.$forum_id, 'Permissions reverted to defaults. Redirecting …');
}
// Fetch forum info $result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id, parent_forum_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
if (!$db->num_rows($result))
message($lang_common['Bad request']);
$cur_forum = $db->fetch_assoc($result);
$parent_forums = Array();
$result = $db->query('SELECT DISTINCT parent_forum_id FROM '.$db->prefix.'forums WHERE parent_forum_id != 0');
while($r = $db->fetch_row($result))
$parent_forums[] = $r[0];
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
require PUN_ROOT.'header.php';
generate_admin_menu('forums');
?>
<div class="blockform">
<h2><span>Edit forum</span></h2>
<div class="box">
<form id="edit_forum" method="post" action="admin_forums.php?edit_forum=<?php echo $forum_id ?>">
<p class="submittop"><input type="submit" name="save" value="Save changes" tabindex="6" /></p>
<div class="inform">
<fieldset>
<legend>Edit forum details</legend>
<div class="infldset">
<table class="aligntop" cellspacing="0">
<tr>
<th scope="row">Forum name</th>
<td><input type="text" name="forum_name" size="35" maxlength="80" value="<?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?>" tabindex="1" /></td>
</tr>
<tr>
<th scope="row">Description (HTML)</th>
<td><textarea name="forum_desc" rows="3" cols="50" tabindex="2"><?php echo pun_htmlspecialchars($cur_forum['forum_desc']) ?></textarea></td>
</tr>
<tr>
<th scope="row">Category</th>
<td>
<select name="cat_id" tabindex="3">
<?php
$result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error());
while ($cur_cat = $db->fetch_assoc($result))
{
$selected = ($cur_cat['id'] == $cur_forum['cat_id']) ? ' selected="selected"' : '';
echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'"'.$selected.'>'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
}
?>
</select>
</td>
</tr>
<tr>
<th scope="row">Sort topics by</th>
<td>
<select name="sort_by" tabindex="4">
<option value="0"<?php if ($cur_forum['sort_by'] == '0') echo ' selected="selected"' ?>>Last post</option>
<option value="1"<?php if ($cur_forum['sort_by'] == '1') echo ' selected="selected"' ?>>Topic start</option>
</select>
</td>
</tr>
<tr>
<th scope="row">Redirect URL</th>
<td><?php echo ($cur_forum['num_topics']) ? 'Only available in empty forums' : '<input type="text" name="redirect_url" size="45" maxlength="100" value="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" tabindex="5" />'; ?></td>
</tr>
<tr>
<th scope="row">Parent forum</th>
<td>
<select name="parent_forum">
<option value="0">No parent forum</option>
<?php
if(!in_array($cur_forum['id'],$parent_forums))
{
$result = $db->query('SELECT id, forum_name, parent_forum_id FROM '.$db->prefix.'forums ORDER BY disp_position') or error('Unable to fetch forum lise',__FILE__,__LINE__,$db->error());
while($forum_list = $db->fetch_assoc($result))
{
$selected = ($forum_list['id'] == $cur_forum['parent_forum_id']) ? ' selected="selected"' : '';
if(!$forum_list['parent_forum_id'] && $forum_list['id'] != $cur_forum['id'])
echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$forum_list['id'].'"'.$selected.'>'.pun_htmlspecialchars($forum_list['forum_name']).'</option>'."\n";
}
}
?>
</select>
</td>
</tr>
</table>
</div>
</fieldset>
</div>
<div class="inform">
<fieldset>
<legend>Edit group permissions for this forum</legend>
<div class="infldset">
<p>In this form, you can set the forum specific permissions for the different user groups. If you haven't made any changes to this forums group permissions, what you see below is the default based on settings in <a href="admin_groups.php">User groups</a>. Administrators always have full permissions and are thus excluded. Permission settings that differ from the default permissions for the user group are marked red. The "Read forum" permission checkbox will be disabled if the group in question lacks the "Read board" permission. For redirect forums, only the "Read forum" permission is editable.</p>
<table id="forumperms" cellspacing="0">
<thead>
<tr>
<th class="atcl"> </th>
<th>Read forum</th>
<th>Post replies</th>
<th>Post topics</th>
</tr>
</thead>
<tbody>
<?php
$result = $db->query('SELECT g.g_id, g.g_title, g.g_read_board, g.g_post_replies, g.g_post_topics, fp.read_forum, fp.post_replies, fp.post_topics FROM '.$db->prefix.'groups AS g LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (g.g_id=fp.group_id AND fp.forum_id='.$forum_id.') WHERE g.g_id!='.PUN_ADMIN.' ORDER BY g.g_id') or error('Unable to fetch group forum permission list', __FILE__, __LINE__, $db->error());
while ($cur_perm = $db->fetch_assoc($result))
{
$read_forum = ($cur_perm['read_forum'] != '0') ? true : false;
$post_replies = (($cur_perm['g_post_replies'] == '0' && $cur_perm['post_replies'] == '1') || ($cur_perm['g_post_replies'] == '1' && $cur_perm['post_replies'] != '0')) ? true : false;
$post_topics = (($cur_perm['g_post_topics'] == '0' && $cur_perm['post_topics'] == '1') || ($cur_perm['g_post_topics'] == '1' && $cur_perm['post_topics'] != '0')) ? true : false;
// Determine if the current sittings differ from the default or not
$read_forum_def = ($cur_perm['read_forum'] == '0') ? false : true;
$post_replies_def = (($post_replies && $cur_perm['g_post_replies'] == '0') || (!$post_replies && ($cur_perm['g_post_replies'] == '' || $cur_perm['g_post_replies'] == '1'))) ? false : true;
$post_topics_def = (($post_topics && $cur_perm['g_post_topics'] == '0') || (!$post_topics && ($cur_perm['g_post_topics'] == '' || $cur_perm['g_post_topics'] == '1'))) ? false : true;
?>
<tr>
<th class="atcl"><?php echo pun_htmlspecialchars($cur_perm['g_title']) ?></th>
<td<?php if (!$read_forum_def) echo ' class="nodefault"'; ?>>
<input type="hidden" name="read_forum_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($read_forum) ? '1' : '0'; ?>" />
<input type="checkbox" name="read_forum_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($read_forum) ? ' checked="checked"' : ''; ?><?php echo ($cur_perm['g_read_board'] == '0') ? ' disabled="disabled"' : ''; ?> />
</td>
<td<?php if (!$post_replies_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>>
<input type="hidden" name="post_replies_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_replies) ? '1' : '0'; ?>" />
<input type="checkbox" name="post_replies_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_replies) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> />
</td>
<td<?php if (!$post_topics_def && $cur_forum['redirect_url'] == '') echo ' class="nodefault"'; ?>>
<input type="hidden" name="post_topics_old[<?php echo $cur_perm['g_id'] ?>]" value="<?php echo ($post_topics) ? '1' : '0'; ?>" />
<input type="checkbox" name="post_topics_new[<?php echo $cur_perm['g_id'] ?>]" value="1"<?php echo ($post_topics) ? ' checked="checked"' : ''; ?><?php echo ($cur_forum['redirect_url'] != '') ? ' disabled="disabled"' : ''; ?> />
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<div class="fsetsubmit"><input type="submit" name="revert_perms" value="Revert to default" /></div>
</div>
</fieldset>
</div>
<p class="submitend"><input type="submit" name="save" value="Save changes" /></p>
</form>
</div>
</div>
<div class="clearer"></div>
</div>
<?php
require PUN_ROOT.'footer.php';
}
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Forums';
require PUN_ROOT.'header.php';
generate_admin_menu('forums');
?>
<div class="blockform">
<h2><span>Add forum</span></h2>
<div class="box">
<form method="post" action="admin_forums.php?action=adddel">
<div class="inform">
<fieldset>
<legend>Create a new forum</legend>
<div class="infldset">
<table class="aligntop" cellspacing="0">
<tr>
<th scope="row">Add forum to category<div><input type="submit" name="add_forum" value=" Add " tabindex="2" /></div></th>
<td>
<select name="add_to_cat" tabindex="1">
<?php
$result = $db->query('SELECT id, cat_name FROM '.$db->prefix.'categories ORDER BY disp_position') or error('Unable to fetch category list', __FILE__, __LINE__, $db->error());
while ($cur_cat = $db->fetch_assoc($result))
echo "\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_cat['id'].'">'.pun_htmlspecialchars($cur_cat['cat_name']).'</option>'."\n";
?>
</select>
<span>Select the category to which you wish to add a new forum.</span>
</td>
</tr>
</table>
</div>
</fieldset>
</div>
</form>
</div>
<h2 class="block2"><span>Edit forums</span></h2>
<div class="box">
<form id="edforum" method="post" action="admin_forums.php?action=edit">
<p class="submittop"><input type="submit" name="update_positions" value="Update positions" tabindex="3" /></p>
<?php
$tabindex_count = 4;
// Display all the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.disp_position FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id ORDER BY c.disp_position, c.id, f.disp_position') or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
$cur_category = 0;
while ($cur_forum = $db->fetch_assoc($result))
{
if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?
{
if ($cur_category != 0)
echo "\t\t\t\t\t\t\t".'</table>'."\n\t\t\t\t\t\t".'</div>'."\n\t\t\t\t\t".'</fieldset>'."\n\t\t\t\t".'</div>'."\n";
?>
<div class="inform">
<fieldset>
<legend>Category: <?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></legend>
<div class="infldset">
<table cellspacing="0">
<?php
$cur_category = $cur_forum['cid'];
}
?>
<tr>
<th><a href="admin_forums.php?edit_forum=<?php echo $cur_forum['fid'] ?>">Edit</a> - <a href="admin_forums.php?del_forum=<?php echo $cur_forum['fid'] ?>">Delete</a></th>
<td>Position <input type="text" name="position[<?php echo $cur_forum['fid'] ?>]" size="3" maxlength="3" value="<?php echo $cur_forum['disp_position'] ?>" tabindex="<?php echo $tabindex_count ?>" />
<strong><?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></strong></td>
</tr>
<?php
$tabindex_count += 2;
}
?>
</table>
</div>
</fieldset>
</div>
<p class="submitend"><input type="submit" name="update_positions" value="Update positions" tabindex="<?php echo $tabindex_count ?>" /></p>
</form>
</div>
</div>
<div class="clearer"></div>
</div>
<?php
require PUN_ROOT.'footer.php';Note. this is the MODDED file, from the ORIGINAL PUNBB 1.2.14 package. No other mods have been applied.
Last edited by randomphpnoob (2007-02-24 05:38:12)
Offline
You have made an error with the changes. Please always double, triple, quadruple check your changes!
FIND ON LINE 180:
$redirect_url = ($redirect_url != '') ? '\''.$db->escape($redirect_url).'\'' : 'NULL'; $db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.', parent_forum_id='.$parent_forum_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error());REPLACE WITH:
$redirect_url = ($redirect_url != '') ? '\''.$db->escape($redirect_url).'\'' : 'NULL';
$db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.', parent_forum_id='.$parent_forum_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error());FIND ON LINE 231:
// Fetch forum info $result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id, parent_forum_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());REPLACE WITH:
// Fetch forum info
$result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id, parent_forum_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());You just have to return that stuff to the next line - small mistake. It will work now. Again, always check your changes many times.
Last edited by naitkris (2007-02-24 06:32:56)
Offline
oh that is awesome!
I really don't know where it went wrong, because I've tried it 4 (!) times. ![]()
Offline
good to hear randomphpnoob.
if it is a bug with the mod install instructions post it here so i or someone else can fix it in the archive.
Offline
Hey naitkris, nice work... really apreciate it!
Got a couple things... (updating to, or just installing, 1.0.7)
First I want to point out that, after you corrected me (appropriately so) on a suggestion I made to someone, I thought I'd go ahead and upgrade to 1.0.7 for the sake of automatic sub-forum display feature (much needed), but I was chagrined to find that there were no sub-forum display's automagically apearing on the index page 8^o
I (now) realize the code is available (only) separately, but I really think this is an "option" that should be included by default in the readme ...stay with me here...
So here are my 'things'...
1) On index page, when applying nico's code, I was unable to get the subforums to display in order of 'disp_position' as set in admin cp. I discovered that it has to do with the array retrieval for the subforums list, so I edited/corrected nico's code to allow for this.
What I also did there is I re-wrote nico's code a little to include the option to display the sub-forum listing on the front page (which i thought 1.0.7 included, but it doesn't) either as an 'inline list' or as a 'delimited list', or to be able to switch it off entirely if one wishes (assuming one includes the code by default).
2) On the viewforums page there is an option in the code to either display or hide the sub-forum topics on the Parent Forum page view (not documented). This is not included in the readme. Its an option I find some of my admins want, so I think it is important enough to include.
3) I found I had to do a lot of file comparison to pull off the upgrade from 1.0.4 correctly (some minor code and line reference issues). I found it to be difficult and unnecessarily time consuming.
4) So I re-wrote my 1.0.7 readme to account for all my little niggling issues and I have posted my revised version below for your review and ask you to please consider updating the one you are issuing accordingly... I think it may make things much easier for anyone either updating to 1.0.7, or installing fresh. Please check me on this and let me know what you think.
Cheers,
HTH
This Readme gets me there without any trouble...
UPDATE: naitkris has approved this and will update the 1.0.7 mod accordingly (thanks n!).
Of course, you may copy it from here and paste it into your existing old one if you wish ;^)
##
##
## Mod title: Sub Forum Mod
##
## Mod version: 1.0.7
## Works on PunBB: 1.2.6, 1.2.7, 1.2.8, 1.2.9, 1.2.14
## Release date: 2005-10-24
## Author: pabb
##
## Description: This mod lets Administrators add subforums to forums.
##
## Affected files: index.php (upgrade 1.0.4-1.0.7)
## viewtopic.php
## viewforum.php (upgrade 1.0.4-1.0.7)
## admin_forums.php
## lang\[Lang]\common.php
## search.php
## include\cache.php (upgrade 1.0.4-1.0.7)
##
## Affects DB: Yes
##
## Notes: Um.. none.
##
## DISCLAIMER: Please note that "mods" are not officially supported by
## PunBB. Installation of this modification is done at your
## own risk. Backup your forum database and any and all
## applicable files before proceeding.
##
## KNOWN BUGS: When deleting topics, posts, it does not show the parent forum as it should.
## The image/icon that marks new posts in index.php do not "glow" on new posts in subforums,
## only in parent forums.
##
## PS. Fixed by naitkris:
## in version 1.0.7
## - Fixed "Moderated by" when viewing parent forum of multiple sub-forums with/without moderators
## in version 1.0.6
## - Fixed items in the quickjump so sub forums are indented (like fix in 1.0.4 by NeoTall for search)
## Fixed by Timpa:
## in version 1.0.5
## - Correctly sorting subforums
## - Now showing last post as it should
## Fixed by NeoTall (Rus):
## in version 1.0.4
## - Fixed items in combobox "Select where to search"
## in version 1.0.3
## - Fixed search in SubForum when using "Non-MultiByted" language
## in version 1.0.2
## - Correctly displaying Last Post, Last Poster and Last Posted Time
## - Correctly displaying Total Topics and Total Posts
## in version 1.0.1
## - Correctly creating Last Post link
## - Correctly displaying word "Topics" on SubForum header
##
#
#---------[ 1. UPLOAD ]-------------------------------------------------------
#
install_mod.php to /
#
#---------[ 2. RUN ]----------------------------------------------------------
#
install_mod.php
#
#---------[ 3. DELETE ]-------------------------------------------------------
#
install_mod.php
#
#---------[ 4. OPEN ]---------------------------------------------------------
#
index.php
#
#---------[ 5. FIND (line: 37) ]---------------------------------------------
#
$page_title = pun_htmlspecialchars($pun_config['o_board_title']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
#
#---------[ 6. AFTER, ADD ]---------------------------------------------
#
################################################################################
########################### Sub Forum MOD (start) ##############################
################################################################################
$sfdb = array($_parent_id_, $_topics_, $_posts_, $_last_post_id_, $_last_poster_, $_last_post_);
$subforum = $db->query('SELECT MAX(id) FROM '.$db->prefix.'forums') or error('Unable to fetch sub forum info',__FILE__,__LINE__,$db->error());
for ($i = 0; $i < $db->result($subforum)+1; $i++)
{
$forums_info = $db->query('SELECT num_topics, num_posts, parent_forum_id, last_post_id, last_poster, last_post, id, forum_name FROM '.$db->prefix.'forums WHERE id='.$i) or error('Unable to fetch sub forum info',__FILE__,__LINE__,$db->error());
$current = $db->fetch_assoc($forums_info);
if ($current['parent_forum_id'] != 0)
{
$sfdb[$i][0] = $current['parent_forum_id'];
$sfdb[$i][1] = $current['num_topics'];
$sfdb[$i][2] = $current['num_posts'];
$sfdb[$i][3] = $current['last_post_id'];
$sfdb[$i][4] = $current['last_poster'];
$sfdb[$i][5] = $current['last_post'];
$sfdb[$i][6] = $current['id'];
$sfdb[$i][7] = $current['forum_name'];
}
}
################################################################################
########################### Sub Forum MOD ( end ) ##############################
################################################################################
#
#---------[ 7. FIND (line: 66) ]---------------------------------------------
#
// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
#
#---------[ 8. REPLACE WITH ]-------------------------------------------------
#
// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.parent_forum_id FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND (f.parent_forum_id IS NULL OR f.parent_forum_id=0) ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
#
#---------[ 9. FIND (line: 134) ]---------------------------------------------
#
$num_topics = $cur_forum['num_topics'];
$num_posts = $cur_forum['num_posts'];
#
#---------[ 10. REPLACE WITH ]---------------------------------------------
#
################################################################################
########################### Sub Forum MOD (start) ##############################
################################################################################
$n_t = 0;
$n_p = 0;
$l_pid = $cur_forum['last_post_id'];
$l_pr = $cur_forum['last_poster'];
$l_post = $cur_forum['last_post'];
for ($i = 0; $i < $db->result($subforum)+1; $i++)
{
if ($sfdb[$i][0] == $cur_forum['fid'])
{
$n_t = $n_t + $sfdb[$i][1];
$n_p = $n_p + $sfdb[$i][2];
if ($l_pid < $sfdb[$i][3])
{
$l_pid = $sfdb[$i][3];
$l_pr = $sfdb[$i][4];
$l_post = $sfdb[$i][5];
}
}
}
$num_topics = $n_t + $cur_forum['num_topics'];
$num_posts = $n_p + $cur_forum['num_posts'];
################################################################################
########################### Sub Forum MOD ( end ) ##############################
################################################################################
#
#---------[ 11. FIND (line: 167) ]---------------------------------------------
#
// If there is a last_post/last_poster.
if ($cur_forum['last_post'] != '')
$last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';
#
#---------[ 12. REPLACE WITH ]---------------------------------------------
#
if ($l_post != '')
$last_post = '<a href="viewtopic.php?pid='.$l_pid.'#p'.$l_pid.'">'.format_time($l_post).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($l_pr).'</span>';
#
#---------[ 6. FIND (line: 185) ]---------------------------------------------
#
<tr<?php if ($item_status != '') echo ' class="'.$item_status.'"'; ?>>
<td class="tcl">
<div class="intd">
<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo $icon_text ?></div></div>
<div class="tclcon">
<?php echo $forum_field."\n".$moderators ?>
#
#---------[ 7. AFTER, ADD ]-------------------------------------------------
#
<?php
$sub_forums_list = array();
if(!empty($sfdb)) {
foreach ($sfdb as $sub_forums) {
if($cur_forum['fid'] == $sub_forums[0]) {
$sub_forums_list[] = '<a href="viewforum.php?id='.$sub_forums[6].'">'.pun_htmlspecialchars($sub_forums[7]).'</a>';
}
}
// EDIT THIS FOR THE DISPLAY STYLE OF THE SUBFORUMS ON MAIN PAGE
if(!empty($sub_forums_list)) {
// Leave one $sub_forums_list commented out to use the other (between the ###..)
################################
//THIS IS Single Line Wrap Style
// $sub_forums_list = "\t\t\t\t\t\t\t\t".'<em>Sub Forums:</em> '.implode(', ', array_reverse($sub_forums_list))."\n";
//THIS IS List Style
$sub_forums_list = "\n".'<b><em>Sub Forums:</em></b><br /> -- '.implode('<br /> -- ', array_reverse($sub_forums_list))."\n";
################################
if ($cur_forum['forum_desc'] != NULL) {
echo "<br />";
}
//TO TURN OFF DISPLAY OF SUBFORUMS ON INDEX PAGE, COMMENT OUT THE FOLLOWING LINE
echo "$sub_forums_list";
}
}
?>
#
#---------[ 13. OPEN ]---------------------------------------------------------
#
viewforum.php
#
#---------[ 14. FIND (line: 39) ]---------------------------------------------
#
require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
#
#---------[ 15. AFTER, ADD ]---------------------------------------------
#
require PUN_ROOT.'lang/'.$pun_user['language'].'/index.php';
#
#---------[ 16. FIND (line: 45) ]---------------------------------------------
#
$result = $db->query('SELECT f.forum_name, f.redirect_url, f.moderators, f.num_topics, f.sort_by, fp.post_topics FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
#
#---------[ 17. REPLACE WITH ]---------------------------------------------
#
$result = $db->query('SELECT f.forum_name, pf.forum_name AS parent_forum, f.redirect_url, f.moderators, f.num_topics, f.sort_by, f.parent_forum_id, fp.post_topics FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') LEFT JOIN '.$db->prefix.'forums AS pf ON f.parent_forum_id=pf.id WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.id='.$id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
#
#---------[ 18. FIND (line: 83) ]---------------------------------------------
#
require PUN_ROOT.'header.php';
#
#---------[ 19. AFTER, ADD ]---------------------------------------------
# Option Note: if you do not want the subforums displaying at the top
# when you go into the main forum topic
# then in the following $sub_forum_result query change
# - ORDER BY disp_position') - to
# - ORDER BY disp_position', true) - (without the dashes)
#
$subforum_result = $db->query('SELECT forum_desc, forum_name, id, last_post, last_post_id, last_poster, moderators, num_posts, num_topics, redirect_url FROM '.$db->prefix.'forums WHERE parent_forum_id='.$id.' ORDER BY disp_position') or error('Unable to fetch sub forum info',__FILE__,__LINE__,$db->error());
if($db->num_rows($subforum_result))
{
?>
<div class="linkst">
<div class="inbox">
<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a> </li><li>» <?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul>
<div class="clearer"></div>
</div>
</div>
<div id="vf" class="blocktable">
<h2><span>Sub forums</span></h2>
<div class="box">
<div class="inbox">
<table cellspacing="0">
<thead>
<tr>
<th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th>
<th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th>
<th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
</tr>
</thead>
<tbody>
<?php
while($cur_subforum = $db->fetch_assoc($subforum_result))
{
$item_status = '';
$icon_text = $lang_common['Normal icon'];
$icon_type = 'icon';
// Are there new posts?
if (!$pun_user['is_guest'] && $cur_subforum['last_post'] > $pun_user['last_visit'])
{
$item_status = 'inew';
$icon_text = $lang_common['New icon'];
$icon_type = 'icon inew';
}
// Is this a redirect forum?
if ($cur_forum['redirect_url'] != '')
{
$forum_field = '<h3><a href="'.pun_htmlspecialchars($cur_subforum['redirect_url']).'" title="'.$lang_index['Link to'].' '.pun_htmlspecialchars($cur_subforum['redirect_url']).'">'.pun_htmlspecialchars($cur_subforum['forum_name']).'</a></h3>';
$num_topics = $num_posts = ' ';
$item_status = 'iredirect';
$icon_text = $lang_common['Redirect icon'];
$icon_type = 'icon';
}
else
{
$forum_field = '<h3><a href="viewforum.php?id='.$cur_subforum['id'].'">'.pun_htmlspecialchars($cur_subforum['forum_name']).'</a></h3>';
$num_topics = $cur_subforum['num_topics'];
$num_posts = $cur_subforum['num_posts'];
}
if ($cur_subforum['forum_desc'] != '')
$forum_field .= "\n\t\t\t\t\t\t\t\t".$cur_subforum['forum_desc'];
// If there is a last_post/last_poster.
if ($cur_subforum['last_post'] != '')
$last_post = '<a href="viewtopic.php?pid='.$cur_subforum['last_post_id'].'#p'.$cur_subforum['last_post_id'].'">'.format_time($cur_subforum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_subforum['last_poster']).'</span>';
else
$last_post = ' ';
if ($cur_subforum['moderators'] != '')
{
$mods_array = unserialize($cur_subforum['moderators']);
$moderators = array();
while (list($mod_username, $mod_id) = @each($mods_array))
$moderators[] = '<a href="profile.php?id='.$mod_id.'">'.pun_htmlspecialchars($mod_username).'</a>';
$moderators = "\t\t\t\t\t\t\t\t".'<p><em>('.$lang_common['Moderated by'].'</em> '.implode(', ', $moderators).')</p>'."\n";
}
?>
<tr<?php if ($item_status != '') echo ' class="'.$item_status.'"'; ?>>
<td class="tcl">
<div class="intd">
<div class="<?php echo $icon_type ?>"><div class="nosize"><?php echo $icon_text ?></div></div>
<div class="tclcon">
<?php echo $forum_field;
if ($cur_subforum['moderators'] != '') {
echo "\n".$moderators;
}
?>
</div>
</div>
</td>
<td class="tc2"><?php echo $num_topics ?></td>
<td class="tc3"><?php echo $num_posts ?></td>
<td class="tcr"><?php echo $last_post ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
<?php
}
#
#---------[ 20. FIND (line: 194) ]---------------------------------------------
#
<?php echo $post_link ?>
<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a> </li><li>» <?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul>
#
#---------[ 21. REPLACE WITH ]---------------------------------------------
#
<?php
echo $post_link;
if($cur_forum['parent_forum'])
echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].'</a> </li><li>» <a href="viewforum.php?id='.$cur_forum['parent_forum_id'].'">'.pun_htmlspecialchars($cur_forum['parent_forum']).'</a> </li><li>» '.pun_htmlspecialchars($cur_forum['forum_name']).'</li></ul>';
else
echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].' </a> </li><li>» '.pun_htmlspecialchars($cur_forum['forum_name']).'</li></ul>';
?>
#
#---------[ 22. FIND (line: 360) ]---------------------------------------------
#
<?php echo $post_link ?>
<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a> </li><li>» <?php echo pun_htmlspecialchars($cur_forum['forum_name']) ?></li></ul>
#
#---------[ 23. REPLACE WITH ]---------------------------------------------
#
<?php
echo $post_link;
if($cur_forum['parent_forum'])
echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].'</a> </li><li>» <a href="viewforum.php?id='.$cur_forum['parent_forum_id'].'">'.pun_htmlspecialchars($cur_forum['parent_forum']).'</a> </li><li>» '.pun_htmlspecialchars($cur_forum['forum_name']).'</li></ul>';
else
echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].' </a> </li><li>» '.pun_htmlspecialchars($cur_forum['forum_name']).'</li></ul>';
?>
#
#---------[ 24. OPEN ]---------------------------------------------
#
viewtopic.php
#
#---------[ 25. FIND (line: 97) ]---------------------------------------------
#
if (!$pun_user['is_guest'])
$result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
else
$result = $db->query('SELECT t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
#
#---------[ 26. REPLACE WITH ]---------------------------------------------
#
if (!$pun_user['is_guest'])
$result = $db->query('SELECT pf.forum_name AS parent_forum, f.parent_forum_id, t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, s.user_id AS is_subscribed FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'subscriptions AS s ON (t.id=s.topic_id AND s.user_id='.$pun_user['id'].') LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') LEFT JOIN '.$db->prefix.'forums AS pf ON f.parent_forum_id=pf.id WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
else
$result = $db->query('SELECT pf.forum_name AS parent_forum, f.parent_forum_id, t.subject, t.closed, t.num_replies, t.sticky, f.id AS forum_id, f.forum_name, f.moderators, fp.post_replies, 0 FROM '.$db->prefix.'topics AS t INNER JOIN '.$db->prefix.'forums AS f ON f.id=t.forum_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') LEFT JOIN '.$db->prefix.'forums AS pf ON f.parent_forum_id=pf.id WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND t.id='.$id.' AND t.moved_to IS NULL') or error('Unable to fetch topic info', __FILE__, __LINE__, $db->error());
#
#---------[ 27. FIND (line: 72) ]---------------------------------------------
#
<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li> » <a href="viewforum.php?id=<?php echo $cur_topic['forum_id'] ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul>
#
#---------[ 28. REPLACE WITH ]---------------------------------------------
#
<?php
if($cur_topic['parent_forum'])
echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].'</a> </li><li>» <a href="viewforum.php?id='.$cur_topic['parent_forum_id'].'">'.pun_htmlspecialchars($cur_topic['parent_forum']).'</a> </li><li>» <a href="viewforum.php?id='.$cur_topic['forum_id'].'">'.pun_htmlspecialchars($cur_topic['forum_name']).'</a> </li><li>» '.pun_htmlspecialchars($cur_topic['subject']).'</li></ul>';
else
echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].'</a></li><li> » <a href="viewforum.php?id='.$cur_topic['forum_id'].'">'.pun_htmlspecialchars($cur_topic['forum_name']).'</a></li><li> » '.pun_htmlspecialchars($cur_topic['subject']).'</li></ul>';
?>
#
#---------[ 29. FIND (line: 356) ]---------------------------------------------
#
<ul><li><a href="index.php"><?php echo $lang_common['Index'] ?></a></li><li> » <a href="viewforum.php?id=<?php echo $cur_topic['forum_id'] ?>"><?php echo pun_htmlspecialchars($cur_topic['forum_name']) ?></a></li><li> » <?php echo pun_htmlspecialchars($cur_topic['subject']) ?></li></ul>
#
#---------[ 30. REPLACE WITH ]---------------------------------------------
#
<?php
if($cur_topic['parent_forum'])
echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].'</a> </li><li>» <a href="viewforum.php?id='.$cur_topic['parent_forum_id'].'">'.pun_htmlspecialchars($cur_topic['parent_forum']).'</a> </li><li>» <a href="viewforum.php?id='.$cur_topic['forum_id'].'">'.pun_htmlspecialchars($cur_topic['forum_name']).'</a> </li><li>» '.pun_htmlspecialchars($cur_topic['subject']).'</li></ul>';
else
echo "\t\t".'<ul><li><a href="index.php">'.$lang_common['Index'].'</a></li><li> » <a href="viewforum.php?id='.$cur_topic['forum_id'].'">'.pun_htmlspecialchars($cur_topic['forum_name']).'</a></li><li> » '.pun_htmlspecialchars($cur_topic['subject']).'</li></ul>';
?>
#
#---------[ 31. OPEN ]---------------------------------------------
#
admin_forums.php
#
#---------[ 32. FIND (line: 170) ]---------------------------------------------
#
$redirect_url = isset($_POST['redirect_url']) ? trim($_POST['redirect_url']) : null;
#
#---------[ 33. AFTER, ADD ]---------------------------------------------
#
$parent_forum_id = intval($_POST['parent_forum']);
#
#---------[ 34. FIND (line: 182) ]---------------------------------------------
#
$db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
#
#---------[ 35. REPLACE WITH ]---------------------------------------------
#
$db->query('UPDATE '.$db->prefix.'forums SET forum_name=\''.$db->escape($forum_name).'\', forum_desc='.$forum_desc.', redirect_url='.$redirect_url.', sort_by='.$sort_by.', cat_id='.$cat_id.', parent_forum_id='.$parent_forum_id.' WHERE id='.$forum_id) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
#
#---------[ 36. FIND (line: 232) ]---------------------------------------------
#
$result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
#
#---------[ 37. REPLACE WITH ]---------------------------------------------
#
$result = $db->query('SELECT id, forum_name, forum_desc, redirect_url, num_topics, sort_by, cat_id, parent_forum_id FROM '.$db->prefix.'forums WHERE id='.$forum_id) or error('Unable to fetch forum info', __FILE__, __LINE__, $db->error());
#
#---------[ 38. FIND (line: 236) ]---------------------------------------------
#
$cur_forum = $db->fetch_assoc($result);
#
#---------[ 39. AFTER ADD ]---------------------------------------------
#
$parent_forums = Array();
$result = $db->query('SELECT DISTINCT parent_forum_id FROM '.$db->prefix.'forums WHERE parent_forum_id != 0');
while($r = $db->fetch_row($result))
$parent_forums[] = $r[0];
#
#---------[ 40. FIND (line: 295) ]---------------------------------------------
#
<th scope="row">Redirect URL</th>
<td><?php echo ($cur_forum['num_topics']) ? 'Only available in empty forums' : '<input type="text" name="redirect_url" size="45" maxlength="100" value="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" tabindex="5" />'; ?></td>
</tr>
#
#---------[ 41. AFTER, ADD ]---------------------------------------------
#
<tr>
<th scope="row">Parent forum</th>
<td>
<select name="parent_forum">
<option value="0">No parent forum</option>
<?php
if(!in_array($cur_forum['id'],$parent_forums))
{
$result = $db->query('SELECT id, forum_name, parent_forum_id FROM '.$db->prefix.'forums ORDER BY disp_position') or error('Unable to fetch forum lise',__FILE__,__LINE__,$db->error());
while($forum_list = $db->fetch_assoc($result))
{
$selected = ($forum_list['id'] == $cur_forum['parent_forum_id']) ? ' selected="selected"' : '';
if(!$forum_list['parent_forum_id'] && $forum_list['id'] != $cur_forum['id'])
echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$forum_list['id'].'"'.$selected.'>'.pun_htmlspecialchars($forum_list['forum_name']).'</option>'."\n";
}
}
?>
</select>
</td>
</tr>
#
#---------[ 42. OPEN ]---------------------------------------------
#
lang\[Lang]\common.php
#
#---------[ 43. FIND (line: 33) ]---------------------------------------------
#
'lang_multibyte' => false,
#
#---------[ 44. REPLACE WITH ]---------------------------------------------
#
'lang_multibyte' => true,
#
#---------[ 45. OPEN ]---------------------------------------------
#
search.php
#
#---------[ 46. FIND (line: 735) ]---------------------------------------------
#
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
#
#---------[ 47. REPLACE WITH ]---------------------------------------------
#
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url, f.parent_forum_id FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.redirect_url IS NULL ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
#
#---------[ 48. FIND (line: 749) ]---------------------------------------------
#
echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n";
#
#---------[ 49. REPLACE WITH ]---------------------------------------------
#
if ($cur_forum['parent_forum_id'] == 0)
{
echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n";
}
else
{
echo "\t\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'"> '.pun_htmlspecialchars($cur_forum['forum_name']).'</option>'."\n";
}
#
#---------[ 50. OPEN ]---------------------------------------------
#
cache.php
#
#---------[ 51. FIND (line: 181) ]---------------------------------------------
#
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$group_id.') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
#
#---------[ 52. REPLACE WITH ]---------------------------------------------
#
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.redirect_url, f.parent_forum_id FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$group_id.') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
#
#---------[ 53. FIND (line: 196) ]---------------------------------------------
#
$output .= "\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'"<?php echo ($forum_id == '.$cur_forum['fid'].') ? \' selected="selected"\' : \'\' ?>>'.pun_htmlspecialchars($cur_forum['forum_name']).$redirect_tag.'</option>'."\n";
#
#---------[ 54. REPLACE WITH ]---------------------------------------------
#
if ($cur_forum['parent_forum_id'] == 0) {
$output .= "\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'"<?php echo ($forum_id == '.$cur_forum['fid'].') ? \' selected="selected"\' : \'\' ?>>'.pun_htmlspecialchars($cur_forum['forum_name']).$redirect_tag.'</option>'."\n";
}
else {
$output .= "\t\t\t\t\t\t\t".'<option value="'.$cur_forum['fid'].'"<?php echo ($forum_id == '.$cur_forum['fid'].') ? \' selected="selected"\' : \'\' ?>> '.pun_htmlspecialchars($cur_forum['forum_name']).$redirect_tag.'</option>'."\n";
}
#
#---------[ 55. ATTENTION ]---------------------------------------------
#
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!! YOU MUST SORT FORUMS POSITION IN "Administration -> Forums"... !!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!! YOU SHOULD ALSO RE-GENERATE YOUR QUICKJUMP CACHE !!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
#
#---------[ 56. SAVE/UPLOAD ]-------------------------------------------------
#Last edited by twohawks (2007-02-24 14:02:02)
Offline
thanks twohawks.
1) the text you added make sense, i will update the archive for 1.0.7 to include this so people know how to change it.
2) there are 2 different versions of Sub Forum - one with no index view (as before) and one with it (that i took from nico's code), you must have downloaded the other one and thought it had it included when it wasn't. nonetheless, your change explains how to turn it off etc and how to also make it to have sub forums each on a new line (which i didn't think was wanted, but ok) so having it in the 1 zip file makes a lot of sense. good stuff. i will update the archive later accordingly.
3) line references - is this from a new 1.2.14 that you compared it with?
Last edited by naitkris (2007-02-24 13:53:53)
Offline
Cool, naitkris, glad it helps.
Yes, I thought the other one was only if you wanted the 'list-styling' that way, not if you wanted a list 'at all', lol!
I just finished polishing my readme and posted it above...
The line references were done with 1.2.12. The difference is my own personal logic, i.e., I figure that after you implement a change, like adding code, all subsequent code is pushed forward, effectively changing the line numbering! I also figure, if someone is 'actively implementing' an installation while following the readme they should be able to find the 'next section' after the line numbers shift, otherwise it just gets confusing while you go looking for the next thing that's "not there anymore" (or even behind you now!) - and it can be frustrating and cost more time, imho.
I think its a personal preference, so keep it the way you think best. Personally I prefer to write a readme as I go along, just as I think the end user will experience it irl.
So that's just my "two-sense", being the double-headed hawkman that I am, lol!
I am glad to see this mod moving forward and getting cleaned up and easier to install.
Cheers,
Last edited by twohawks (2007-02-24 12:53:27)
Offline
EDIT:
twohawks wrote:
UPDATE: naitkris has approved this and will update the 1.0.7 mod accordingly (thanks n!).
lol, i have no authority to approve anything for this - i am not the author of Sub Forum Mod - that is pabb, but the mod is not being updated by him so i and others (such as yourself) just update it here. the updates aren't "official" updates to the mod as pabb has to approve them.
anyways, good work twohawks.
about line numbering, i think most people who will implement this will use 1.2.14 and when i implement a mod i always do a search of the file for the code i am replacing rather than just browsing it (i don't know if many others do it this way) - it is a lot easier - the line numbers only are a rough guide to me as to whereabout the code should be. nonetheless you are right, shifting the line numbers as you implement makes much more sense to users and so is easier to install.
btw, you forgot the optimised code for index.php which was fixed by binjured, i re-added this plus your changes to the line numbers. also, the step numbers in yours appear wrong as they were no longer in order which was strange, i corrected this again. i also added your change to the Index View code with the comments there also to help people - this is good to have the option on how to display it on Index - i prefer it on 1 line personally for sub forums as it takes less space then, but a little choice is good.
ok, it is updated to 1.0.8 now - many thanks go to twohawks! hopefully the changes made to the readme by twohawks will make it easier to install it. it is also back to 1 zip file to make things easier, if you don't want sub forums listed on the index you only need to comment out some code.
Sub Forum Mod 1.0.8
History:
Fixed by twohawks:
in version 1.0.8
- Sub forums now display in order of 'disp_position' on Index as set in Admin CP
- Option to set sub forums view for 'inline' or 'multi-line' listing on Index
- Option to hide the sub forums view on Index
Fixed by naitkris:
in version 1.0.8
- Added Index view from nico_somb's version and modified to work here (was seperate version before)
Fixed by binjured:
in version 1.0.7
- Optimised code on index.php so query isn't run for every forum processed
Fixed by naitkris:
in version 1.0.7
- Fixed "Moderated by" when viewing parent forum of multiple sub-forums with/without moderators
in version 1.0.6
- Fixed items in the quickjump so sub forums are indented (like fix in 1.0.4 by NeoTall for search)
Fixed by Timpa:
in version 1.0.5
- Correctly sorting subforums
- Now showing last post as it should
Fixed by NeoTall (Rus):
in version 1.0.4
- Fixed items in combobox "Select where to search"
in version 1.0.3
- Fixed search in SubForum when using "Non-MultiByted" language
in version 1.0.2
- Correctly displaying Last Post, Last Poster and Last Posted Time
- Correctly displaying Total Topics and Total Posts
in version 1.0.1
- Correctly creating Last Post link
- Correctly displaying word "Topics" on SubForum header
You will need to re-generate your quickjump cache after applying this mod for the quickjump to indent. The Clear Cache administration plugin can do this for you easily and is available from the PunBB Downloads page.
All credit to nico_somb for the Index View version as it is just taken from his version and modified a tiny bit to work with this one.
Sub Forum Mod is copyright of pabb.
Last edited by naitkris (2007-02-24 14:42:26)
Offline
naitkris wrote:
lol, i have no authority to approve anything for this - i am not the author of Sub Forum Mod - that is pabb, but the mod is not being updated by him so i and others (such as yourself) just update it here. the updates aren't "official" updates to the mod as pabb has to approve them.
anyways, good work twohawks.
lol... Thanks naitkris.. its no different than gizzmo's calendar mod we are all working on...
naitkris wrote:
btw, you forgot the optimised code for index.php which was fixed by binjured, i re-added this
You know, I pulled this out thinking that when you updated in 1.0.6+7 you had re-addressed this with using that -max id- code, and I didn't check it out further... that in fact that was what was fixed! LOL... thanks for mentioning that!
naitkris wrote:
also, the step numbers in yours appear wrong
lmao... I always tend to catch that days later ...HA!
Good work!
Cheers,
Last edited by twohawks (2007-02-24 14:53:36)
Offline
twohawks wrote:
naitkris wrote:
btw, you forgot the optimised code for index.php which was fixed by binjured, i re-added this
You know, I pulled this out thinking that when you updated in 1.0.6+7 you had re-addressed this with using that -max id- code, and I didn't check it out further... thanks for mentioning that!
yeah, you see i also presumed it was in 1.0.5 (as it was posted before 1.0.5 was made) so when i updated it to 1.0.6 i thought it was in there already (not checking). only after doing some debugging the other day did i notice the large number of queries being run and so went to investigate it.
Last edited by naitkris (2007-02-24 14:59:39)
Offline
Edit/Strike that... just finished double-checking, it all looks great to me.
I would vote 1.0.8 rockin and ready for prime time.
Good work, n.
;^)
Last edited by twohawks (2007-02-24 15:37:25)
Offline
twohawks wrote:
On index page, when applying nico's code, I was unable to get the subforums to display in order of 'disp_position' as set in admin cp. I discovered that it has to do with the array retrieval for the subforums list, so I edited/corrected nico's code to allow for this.
I just went away and tested the new version properly on my development server (has lots of sub forums) with regards the disp_position change you made for index and all the change that you did does for me is reverse the order of the subforums by their ID, not to do with disp_position - the code you added "array_reverse($sub_forums_list)" when displaying caused this ![]()
I changed the code and then just added "ORDER BY disp_position" in the sub forums specific query and it now sorts as per the Admin CP properly.
Sub Forum Mod 1.0.9
Thus, only change in this version:
- Sub forums now display in order of 'disp_position' on Index as set in Admin CP
Last edited by naitkris (2007-02-24 21:21:49)
Offline