Firefox PHP

Hack to include forum in each folder

Posted by Oliver Riesen 
In my forum I use three folderlevels and I had the wish to display some forums from the top level also in the subfolders.

So I wrote a hack which allows to define that a forum is displayed:

- only in the selected folder (like now) or
- in each folder or
- starting from the actual folder also in the subfolders

You will find an example (in german) on
< [forum.langzeittest.de] >

The first forum on the top level ("Aktualisierungen...") is displayed also on the subfolders.

The following hack is tested with version 3.2.11. Feel free to adapt it to version 3.3.

Best regards.
Oliver Riesen
[www.langzeittest.de]

1. Add new column to table 'forums'

Add a new column in the table 'forums' (or the one you defined in common.php) with the following command:

ALTER TABLE forums ADD displayflag SMALLINT (6) DEFAULT '0' not null AFTER allow_uploads


2. Change /index.php

Search for the following line:

$sSQL="Select id, name, table_name, parent, folder, description from ".$pho_main." where active=1 and parent=$f";

and replace them with:

// get all parents
$all_parents=$f;
$act_id=$f;
while($act_id!=0){
$sSQL="Select parent from $pho_main where id=$act_id";
$q->query($DB, $sSQL);
$rec=$q->getrow();
$act_id=$rec["parent"];
$all_parents.=",".$act_id;
}
$sSQL="Select id, name, table_name, parent, folder, description from ".$pho_main." where active=1 and (parent=$f or displayflag=1 or (displayflag=2 and parent in (".$all_parents.")))";


3. Change /admin/pages/new.php

Search for the following two lines:

<tr>
<td valign="middle" bgcolor="#FFFFFF"><font face="Arial,Helvetica">Language:</font></td>

and insert just before:

<?PHP if(!$folder){ ?>
<tr>
<td valign="middle" bgcolor="#FFFFFF"><font face="Arial,Helvetica">Display option:</font></td>
<td valign="middle" bgcolor="#C0C0C0"><select name="check_disp" class=big>
<option value="0" <?PHP if($check_disp==0) echo "selected"; ?>>Show only in selected folder</option>
<option value="1" <?PHP if($check_disp==1) echo "selected"; ?>>Show in each folder</option>
<option value="2" <?PHP if($check_disp==2) echo "selected"; ?>>Show also in each subfolder</option>
</select></td>
</tr>
<?PHP } ?>


4. Change /admin/pages/props.php

Search for the following two lines:

<tr>
<td valign="middle" bgcolor="#FFFFFF"><font face="Arial,Helvetica">Language File:</font></td>

and insert just before:

<?PHP if(!$ForumFolder){ ?>
<tr>
<td valign="middle" bgcolor="#FFFFFF"><font face="Arial,Helvetica">Display option:</font></td>
<td valign="middle" bgcolor="#C0C0C0"><select name="check_disp" class=big>
<option value="0" <?PHP if($ForumCheckDisp==0) echo "selected"; ?>>Show only in selected folder</option>
<option value="1" <?PHP if($ForumCheckDisp==1) echo "selected"; ?>>Show in each folder</option>
<option value="2" <?PHP if($ForumCheckDisp==2) echo "selected"; ?>>Show also in each subfolder</option>
</select></td>
</tr>
<?PHP } ?>


5. Change /admin/index.php

Search for the following line:

$sSQL="Insert into ".$pho_main." (id, name, active, description, config_suffix, folder, parent, display, table_name, moderation, mod_email, mod_pass, email_list, email_return, email_tag, check_dup, multi_level, collapse, flat, staff_host, lang, html, table_width, table_header_color, table_header_font_color, table_body_color_1, table_body_color_2, table_body_font_color_1, table_body_font_color_2, nav_color, nav_font_color, allow_uploads) values ($id, '$name', 1, '$description', '$config_suffix', $folder, $parent, $display, '$table', '$moderation', '$mod_email', '$mod_pass', '$email_list', '$email_return', '$email_tag', $check_dup, $multi_level, $collapsed, $rflat, '$staff_host', '$lang', '$html', '$table_width', '$table_header_color', '$table_header_font_color', '$table_body_color_1', '$table_body_color_2', '$table_body_font_color_1', '$table_body_font_color_2', '$nav_color', '$nav_font_color','$allow_uploads')";

and replace them with:

$sSQL="Insert into ".$pho_main." (id, name, active, description, config_suffix, folder, parent, display, table_name, moderation, mod_email, mod_pass, email_list, email_return, email_tag, check_dup, multi_level, collapse, flat, staff_host, lang, html, table_width, table_header_color, table_header_font_color, table_body_color_1, table_body_color_2, table_body_font_color_1, table_body_font_color_2, nav_color, nav_font_color, allow_uploads, displayflag) values ($id, '$name', 1, '$description', '$config_suffix', $folder, $parent, $display, '$table', '$moderation', '$mod_email', '$mod_pass', '$email_list', '$email_return', '$email_tag', $check_dup, $multi_level, $collapsed, $rflat, '$staff_host', '$lang', '$html', '$table_width', '$table_header_color', '$table_header_font_color', '$table_body_color_1', '$table_body_color_2', '$table_body_font_color_1', '$table_body_font_color_2', '$nav_color', '$nav_font_color','$allow_uploads', $check_disp)";

After search for the following line:

$sSQL="Update ".$pho_main." set name='$name', description='$description', config_suffix='$config_suffix', parent=$parent, display=$display, moderation='$moderation', mod_email='$mod_email', mod_pass='$mod_pass', email_list='$email_list', email_return='$email_return', email_tag='$email_tag', check_dup=$check_dup, multi_level=$multi_level, collapse=$collapsed, flat=$rflat, staff_host='$staff_host', lang='$lang', html='$html', table_width='$table_width', table_header_color='$table_header_color', table_header_font_color='$table_header_font_color', table_body_color_1='$table_body_color_1', table_body_color_2='$table_body_color_2', table_body_font_color_1='$table_body_font_color_1', table_body_font_color_2='$table_body_font_color_2', nav_color='$nav_color', nav_font_color='$nav_font_color', allow_uploads='$allow_uploads' where id=$num";

and replace them with:

$sSQL="Update ".$pho_main." set name='$name', description='$description', config_suffix='$config_suffix', parent=$parent, display=$display, moderation='$moderation', mod_email='$mod_email', mod_pass='$mod_pass', email_list='$email_list', email_return='$email_return', email_tag='$email_tag', check_dup=$check_dup, multi_level=$multi_level, collapse=$collapsed, flat=$rflat, staff_host='$staff_host', lang='$lang', html='$html', table_width='$table_width', table_header_color='$table_header_color', table_header_font_color='$table_header_font_color', table_body_color_1='$table_body_color_1', table_body_color_2='$table_body_color_2', table_body_font_color_1='$table_body_font_color_1', table_body_font_color_2='$table_body_font_color_2', nav_color='$nav_color', nav_font_color='$nav_font_color', allow_uploads='$allow_uploads', displayflag=$check_disp where id=$num";

And last search for the following two lines:

$data.=" \$ForumAllowUploads='$rec->allow_uploads';\n";
$data.=" \$ForumTableBodyColor2='$rec->table_body_color_2';\n";

and replace them with:

$data.=" \$ForumAllowUploads='$rec->allow_uploads';\n";
$data.=" \$ForumCheckDisp='$rec->displayflag';\n";
$data.=" \$ForumTableBodyColor2='$rec->table_body_color_2';\n";
Sorry, you do not have permission to post/reply in this forum.