Get Photoshop help and share your work at PhotoshopForums.com

Bookmark and Share

Disable a phpBB Powered Page

Disable a phpBB Powered Page

Postby Thoul » November 27th 2004, 6:43 pm

Occasionally, you may want to disable a phpBB powered page on your site for some reason. Perhaps you're working on an upgrade or their is a problem with it. Whatever the reason, this guide shows a simple way of adding an option to disable a page in the Administration Control Panel.

You can use this guide to add as many disabling options as you wish. Just change every instance of "somepage" and "SOMEPAGE" in the code below to something unique for each page. Ideally, that should be based on the name of the page somehow.

First, you need to run this SQL query on your database. For more information on running SQL queries, see the Installing phpBB Hacks and Running SQL Queries with db_update.php tutorials.

Code: Select all
INSERT INTO phpbb_config (config_name, config_value) VALUES ('disable_somepage', 0);


Second, make the following file changes to add the option in the Administration Control Panel.
Code: Select all
##
##----------[ OPEN ]-------------------------------------
##

admin/admin_board.php

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

$disable_board_no = ( !$new['board_disable'] ) ? "checked=\"checked\"" : "";
##
##----------[ AFTER, ADD ]-------------------------------
##

//-------------------------------------------------------------------
//  Disable a phpBB Powered Page - Begin Code Addition
//

$disable_somepage_yes = ( $new['disable_somepage'] ) ? 'checked="checked"' : '';
$disable_somepage_no = ( !$new['disable_somepage'] ) ? 'checked="checked"' : '';

//
//  Disable a phpBB Powered Page - End Code Addition
//-------------------------------------------------------------------

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

	"L_DISABLE_BOARD_EXPLAIN" => $lang['Board_disable_explain'], 

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

//-------------------------------------------------------------------
//  Disable a phpBB Powered Page - Begin Code Addition
//

	'L_DISABLE_SOMEPAGE' => $lang['Disable_somepage'], 
	'L_DISABLE_SOMEPAGE_EXPLAIN' => $lang['Disable_somepage_explain'], 

//
//  Disable a phpBB Powered Page - End Code Addition
//-------------------------------------------------------------------

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

	"S_DISABLE_BOARD_NO" => $disable_board_no,
##
##----------[ AFTER, ADD ]-------------------------------
##

//-------------------------------------------------------------------
//  Disable a phpBB Powered Page - Begin Code Addition
//

	'S_DISABLE_SOMEPAGE_YES' => $disable_somepage_yes,
	'S_DISABLE_SOMEPAGE_NO' => $disable_somepage_no,

//
//  Disable a phpBB Powered Page - End Code Addition
//-------------------------------------------------------------------

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

templates/subSilver/admin/board_config_body.tpl

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

	<tr>
		<td class="row1">{L_DISABLE_BOARD}<br /><span class="gensmall">{L_DISABLE_BOARD_EXPLAIN}</span></td>
		<td class="row2"><input type="radio" name="board_disable" value="1" {S_DISABLE_BOARD_YES} /> {L_YES}&nbsp;&nbsp;<input type="radio" name="board_disable" value="0" {S_DISABLE_BOARD_NO} /> {L_NO}</td>
	</tr>
##
##----------[ AFTER, ADD ]-------------------------------
##

<!--  Disable a phpBB Powered Page - Begin Code Addition  -->
	<tr>
		<td class="row1">{L_DISABLE_SOMEPAGE}<br /><span class="gensmall">{L_DISABLE_SOMEPAGE_EXPLAIN}</span></td>
		<td class="row2"><input type="radio" name="disable_somepage" value="1" {S_DISABLE_SOMEPAGE_YES} /> {L_YES}&nbsp;&nbsp;<input type="radio" name="disable_somepage" value="0" {S_DISABLE_SOMEPAGE_NO} /> {L_NO}</td>
	</tr>
<!--  Disable a phpBB Powered Page - End Code Addition  -->

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

language/lang_english/lang_admin.php

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

//
// That's all Folks!
// -------------------------------------------------

##
##----------[ BEFORE, ADD ]------------------------------
##
//-------------------------------------------------------------------
//  Disable a phpBB Powered Page - Begin Code Addition
//

$lang['Disable_somepage'] = 'Disable somepage';
$lang['Disable_somepage_explain'] = 'This will make somepage unavailable to users. Administrators are able to access somepage while it is disabled.';

//
//  Disable a phpBB Powered Page - End Code Addition
//-------------------------------------------------------------------


Finally, make the following changes to add the disabling feature to the page itself. You, as an administrator, will be able to access the page even when it has been disabled.

Code: Select all
##
##----------[ OPEN ]-------------------------------------
##

somepage.php

##
##----------[ FIND ]-------------------------------------
##
## Note: This code may vary on some pages.

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_FAQ);
init_userprefs($userdata);
//
// End session management
//

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

//-------------------------------------------------------------------
//  Disable a phpBB Powered Page - Begin Code Addition
//

if ( $userdata['user_level'] != ADMIN && $board_config['disable_somepage']  )
{
	message_die(GENERAL_MESSAGE, 'Disabled_somepage', 'Information');
}

//
//  Disable a phpBB Powered Page - End Code Addition
//-------------------------------------------------------------------

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

language/lang_english/lang_main.php

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

//
// That's all, Folks!
// -------------------------------------------------


##
##----------[ BEFORE, ADD ]------------------------------
##


//-------------------------------------------------------------------
//  Disable a phpBB Powered Page - Begin Code Addition
//

$lang['Disabled_somepage'] = "Sorry, but somepage is currently unavailable at the administration's discretion. Please try again at another time.";

//
//  Disable a phpBB Powered Page - End Code Addition
//-------------------------------------------------------------------


That completes all the necessary changes. You will now be able to disable the chosen page at any time in the Admin Panel's General > Configuration page.
User avatar
Thoul
Admin/Webmaster
 
Posts: 18551
Joined: July 30th 2002, 11:30 am
Location: USA

Return to phpBB 2: Customizing Your phpBB

Who is online

Users browsing this forum: No registered users and 0 guests