phpbb site admin panel
- Bogey
- Bogey


- Joined: Jul 14, 2005
- Posts: 8211
- Loc: USA
- Status: Offline
I created a separate admin panel for my site which is integrated into phpbb 3. Works well on my local host but when I upload it on to my site, it tells me I don't have administrative privileges to get in. I doubt that it's the code since it works on my local server... I don't know what it is.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
August 12th, 2008, 11:44 am
- joebert
- Sledgehammer


- Joined: Feb 10, 2004
- Posts: 13455
- Loc: Florida
- Status: Offline
How did you integrate it, did you use a new ACP module ?
If you did, look in the file for it that's in the "info" folder of the ACP modules folder & find out which permission it's using, then you can guestimate which permission you need to check.
For instance, here's the info file for an ACP module I'm working on.
http://code.google.com/p/bb3-mods/sourc ... e_info.php
Note the 'auth' => 'acl_a_phpinfo',, that's what you're looking for. If it has an "*_a_*" it's an administrative permission, if it's a "*_m_*" it's a moderator permission, a "*_u_*" is a user permission.
In the case of my module there, I'm piggybacking the PHPINFO permission.
If you did, look in the file for it that's in the "info" folder of the ACP modules folder & find out which permission it's using, then you can guestimate which permission you need to check.
For instance, here's the info file for an ACP module I'm working on.
http://code.google.com/p/bb3-mods/sourc ... e_info.php
Note the 'auth' => 'acl_a_phpinfo',, that's what you're looking for. If it has an "*_a_*" it's an administrative permission, if it's a "*_m_*" it's a moderator permission, a "*_u_*" is a user permission.
In the case of my module there, I'm piggybacking the PHPINFO permission.
Strong with this one, the sudo is.
- Bogey
- Bogey


- Joined: Jul 14, 2005
- Posts: 8211
- Loc: USA
- Status: Offline
What I'm doing is... (Here is the whole page... a whole ne ACP page...).
Code: [ Select ]
<?php
/**
*
* @package site acp
* @version $Id: index.php 8591 2008-06-04 11:40:53Z Kellanved $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
define('IN_PHPBB', true);
define('ADMIN_START', true);
define('NEED_SID', true);
// Include files
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
// Default page (index)
$page = 'index';
// Get the required admin template page
if (isset($_GET['atp']))
{
//atp = admin template page
$page = $_GET['atp'];
}
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/acp/'. $page);
// End session management
// Have they authenticated (again) as an admin for this session?
if (!isset($user->data['session_admin']) || !$user->data['session_admin'])
{
login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false, './index.php');
}
// Is user any type of admin? No, then stop here, each script needs to
// check specific permissions but this is a catchall
if (!$auth->acl_get('a_'))
{
trigger_error('NO_ADMIN');
}
// We define the admin variables now, because the user is now able to use the admin related features...
define('IN_ADMIN', true);
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
// Set custom template for admin area
$template->set_custom_template($phpbb_admin_path . 'style', 'index');
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
// the acp template is never stored in the database
$user->theme['template_storedb'] = false;
// My Administrative Codes and options and whatever...
// Page title, this language variable should be defined in the language file you setup at the top of this page.
page_header($user->lang['PAGE_TITLE2']);
// Set the filename of the template you want to use for this file.
// This is the name of our template file located in /styles/<style>/templates/.
$template->set_filenames(array(
'body' => 'acp_' . $page . '.html',
));
// Completing the script and displaying the page.
page_footer();
?>
/**
*
* @package site acp
* @version $Id: index.php 8591 2008-06-04 11:40:53Z Kellanved $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
define('IN_PHPBB', true);
define('ADMIN_START', true);
define('NEED_SID', true);
// Include files
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../forum/';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
// Default page (index)
$page = 'index';
// Get the required admin template page
if (isset($_GET['atp']))
{
//atp = admin template page
$page = $_GET['atp'];
}
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/acp/'. $page);
// End session management
// Have they authenticated (again) as an admin for this session?
if (!isset($user->data['session_admin']) || !$user->data['session_admin'])
{
login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false, './index.php');
}
// Is user any type of admin? No, then stop here, each script needs to
// check specific permissions but this is a catchall
if (!$auth->acl_get('a_'))
{
trigger_error('NO_ADMIN');
}
// We define the admin variables now, because the user is now able to use the admin related features...
define('IN_ADMIN', true);
$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
// Set custom template for admin area
$template->set_custom_template($phpbb_admin_path . 'style', 'index');
$template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
// the acp template is never stored in the database
$user->theme['template_storedb'] = false;
// My Administrative Codes and options and whatever...
// Page title, this language variable should be defined in the language file you setup at the top of this page.
page_header($user->lang['PAGE_TITLE2']);
// Set the filename of the template you want to use for this file.
// This is the name of our template file located in /styles/<style>/templates/.
$template->set_filenames(array(
'body' => 'acp_' . $page . '.html',
));
// Completing the script and displaying the page.
page_footer();
?>
- <?php
- /**
- *
- * @package site acp
- * @version $Id: index.php 8591 2008-06-04 11:40:53Z Kellanved $
- * @copyright (c) 2005 phpBB Group
- * @license http://opensource.org/licenses/gpl-license.php GNU Public License
- *
- */
- /**
- */
- define('IN_PHPBB', true);
- define('ADMIN_START', true);
- define('NEED_SID', true);
- // Include files
- $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../forum/';
- $phpEx = substr(strrchr(__FILE__, '.'), 1);
- require($phpbb_root_path . 'common.' . $phpEx);
- require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
- require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
- // Default page (index)
- $page = 'index';
- // Get the required admin template page
- if (isset($_GET['atp']))
- {
- //atp = admin template page
- $page = $_GET['atp'];
- }
- // Start session management
- $user->session_begin();
- $auth->acl($user->data);
- $user->setup('mods/acp/'. $page);
- // End session management
- // Have they authenticated (again) as an admin for this session?
- if (!isset($user->data['session_admin']) || !$user->data['session_admin'])
- {
- login_box('', $user->lang['LOGIN_ADMIN_CONFIRM'], $user->lang['LOGIN_ADMIN_SUCCESS'], true, false, './index.php');
- }
- // Is user any type of admin? No, then stop here, each script needs to
- // check specific permissions but this is a catchall
- if (!$auth->acl_get('a_'))
- {
- trigger_error('NO_ADMIN');
- }
- // We define the admin variables now, because the user is now able to use the admin related features...
- define('IN_ADMIN', true);
- $phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
- // Set custom template for admin area
- $template->set_custom_template($phpbb_admin_path . 'style', 'index');
- $template->assign_var('T_TEMPLATE_PATH', $phpbb_admin_path . 'style');
- // the acp template is never stored in the database
- $user->theme['template_storedb'] = false;
- // My Administrative Codes and options and whatever...
- // Page title, this language variable should be defined in the language file you setup at the top of this page.
- page_header($user->lang['PAGE_TITLE2']);
- // Set the filename of the template you want to use for this file.
- // This is the name of our template file located in /styles/<style>/templates/.
- $template->set_filenames(array(
- 'body' => 'acp_' . $page . '.html',
- ));
- // Completing the script and displaying the page.
- page_footer();
- ?>
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
- joebert
- Sledgehammer


- Joined: Feb 10, 2004
- Posts: 13455
- Loc: Florida
- Status: Offline
- Bogey
- Bogey


- Joined: Jul 14, 2005
- Posts: 8211
- Loc: USA
- Status: Offline
I have but the fact that I don't know how to do that forced me to attempt at it this way. If you are so kind as to point me on how to do that, I would be more than glad to do it as a module 
And I don't get the following sentence in your post:
[EDIT:] I found this page on the phpbb site so I will be going through that... I still don't understand the above quote though
lol
[EDIT 2:] Oh... I think I get that quote lol. It lets me go to the forum acp correctly and doesn't give me that error thing.
And I don't get the following sentence in your post:
Joebert wrote:
The only thing that comes to mind is that you're not logged in as a phpBB3 administrator on the remote site, and that you are but don't realize it on the local site.
[EDIT:] I found this page on the phpbb site so I will be going through that... I still don't understand the above quote though
[EDIT 2:] Oh... I think I get that quote lol. It lets me go to the forum acp correctly and doesn't give me that error thing.
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
- joebert
- Sledgehammer


- Joined: Feb 10, 2004
- Posts: 13455
- Loc: Florida
- Status: Offline
I'm going to create a "Hello World" ACP module right here and now & write down everything I do as I do it. You should be able to finish integration of your other administrative functions beyond that. 
Oh and BTW, It's a good idea to do this as a full phpBB administrator.
---
Start my text editor.
Open "includes/acp/acp_php_info.php"
Save a new copy in the same folder as "acp_my_module.php"
Find and replace "php_info" with "my_module" throughout the file.
Replace the "main" function with the following
Save the file.
Open "includes/acp/info/acp_php_info.php"
Save a new copy in the same folder as "acp_my_module.php"
Find and replace "php_info" with "my_module" throughout the file.
Replace the "module" function with the following
Save the file.
Open "language/en/acp/common.php"
Merge the new language entry for the modules title at the end of the file like so
Save the file.
Login to my ACP, go to the "System" tab.
Click the "Administration Control Panel" option under "Module Management".
Click the ".MODS" row.
Enter "My Category" in the text box next to the "Create New Module" button.
Click "Create New Module".
Select "Yes" for "Module Enabled".
click "Submit".
Click "Back To Previous Page".
Click "My Category".
Select "My Modules Title" from the dropdown next to the "Add Module" button on the bottom-right of the page.
Click the "Add Module" button.
Click "Yes".
Click "Back to previous page".
Click "Enable" on the right side of the "My Modules Title" row.
Click "Admin Index" on the top-right of the page to refresh the ACP.
Click the ".MODS" tab.
I see the description for PHPINFO & the text "Hello World !" in the content area, and My Category & My Modules Title in the menu on the left.
At this point I'm using the php_info template file to quickly get something in working order, time to change that.
Open "adm/style/acp_php_info.html"
Save a copy in the same folder as "acp_my_module.html"
Replace the contents with the following
Save the file.
Go back into "includes/acp/acp_my_module.php"
Change the value for "$this->tpl_name" to "acp_my_module" so I have
Change the template variable key "PHPINFO" to "HELLO_WORLD" so I have
Save the file.
At this point I realize I'm using the permission setting for "PHPINFO" to control who can access this module & instead want it to require the same permission as altering board settings requires.
Open "includes/acp/info/acp_board.php"
Deterine which permissions that module uses by looking at the "auth" portion of the different modes.
In this case some use "acl_a_board" and some use "acl_a_server".
Go back to "includes/acp/info/acp_my_module.php"
I want my permissions to be a little less granulated than they are in acp_board, so I'm going to replace my modules "auth" which is "acl_a_phpinfo" to "acl_a_board && acl_a_server" which will require both of those permissions to access this module & give me the following
Save the file.
Click "My Modules Title" from the "My Category" menu on the left.
I don't see the PHPINFO stuff anymore, just "My Modules Title" in big letters, and "Hello World !" in smaller letters under it.
At this point I can make alterations to the following files to finish integrating something.
"includes/acp/acp_my_module.php"
"adm/style/acp_my_module.html"
Oh and BTW, It's a good idea to do this as a full phpBB administrator.
---
Start my text editor.
Open "includes/acp/acp_php_info.php"
Save a new copy in the same folder as "acp_my_module.php"
Find and replace "php_info" with "my_module" throughout the file.
Replace the "main" function with the following
Code: [ Select ]
function main($id, $mode)
{
global $db, $user, $auth, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
if ($mode != 'hello_world')
{
trigger_error('NO_MODE', E_USER_ERROR);
}
$this->tpl_name = 'acp_php_info';
$this->page_title = 'ACP_MY_MODULE';
$output = 'Hello World !';
$template->assign_var('PHPINFO', $output);
}
{
global $db, $user, $auth, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
if ($mode != 'hello_world')
{
trigger_error('NO_MODE', E_USER_ERROR);
}
$this->tpl_name = 'acp_php_info';
$this->page_title = 'ACP_MY_MODULE';
$output = 'Hello World !';
$template->assign_var('PHPINFO', $output);
}
- function main($id, $mode)
- {
- global $db, $user, $auth, $template;
- global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
- if ($mode != 'hello_world')
- {
- trigger_error('NO_MODE', E_USER_ERROR);
- }
- $this->tpl_name = 'acp_php_info';
- $this->page_title = 'ACP_MY_MODULE';
- $output = 'Hello World !';
- $template->assign_var('PHPINFO', $output);
- }
Save the file.
Open "includes/acp/info/acp_php_info.php"
Save a new copy in the same folder as "acp_my_module.php"
Find and replace "php_info" with "my_module" throughout the file.
Replace the "module" function with the following
Code: [ Select ]
function module()
{
return array(
'filename' => 'acp_my_module',
'title' => 'ACP_MY_MODULE',
'version' => '1.0.0',
'modes' => array(
'hello_world' => array('title' => 'ACP_MY_MODULE', 'auth' => 'acl_a_phpinfo', 'cat' => array('ACP_GENERAL_TASKS')),
),
);
}
{
return array(
'filename' => 'acp_my_module',
'title' => 'ACP_MY_MODULE',
'version' => '1.0.0',
'modes' => array(
'hello_world' => array('title' => 'ACP_MY_MODULE', 'auth' => 'acl_a_phpinfo', 'cat' => array('ACP_GENERAL_TASKS')),
),
);
}
- function module()
- {
- return array(
- 'filename' => 'acp_my_module',
- 'title' => 'ACP_MY_MODULE',
- 'version' => '1.0.0',
- 'modes' => array(
- 'hello_world' => array('title' => 'ACP_MY_MODULE', 'auth' => 'acl_a_phpinfo', 'cat' => array('ACP_GENERAL_TASKS')),
- ),
- );
- }
Save the file.
Open "language/en/acp/common.php"
Merge the new language entry for the modules title at the end of the file like so
Code: [ Select ]
// My Module
$lang = array_merge($lang, array(
'ACP_MY_MODULE' => 'My Modules Title'
));
$lang = array_merge($lang, array(
'ACP_MY_MODULE' => 'My Modules Title'
));
- // My Module
- $lang = array_merge($lang, array(
- 'ACP_MY_MODULE' => 'My Modules Title'
- ));
Save the file.
Login to my ACP, go to the "System" tab.
Click the "Administration Control Panel" option under "Module Management".
Click the ".MODS" row.
Enter "My Category" in the text box next to the "Create New Module" button.
Click "Create New Module".
Select "Yes" for "Module Enabled".
click "Submit".
Click "Back To Previous Page".
Click "My Category".
Select "My Modules Title" from the dropdown next to the "Add Module" button on the bottom-right of the page.
Click the "Add Module" button.
Click "Yes".
Click "Back to previous page".
Click "Enable" on the right side of the "My Modules Title" row.
Click "Admin Index" on the top-right of the page to refresh the ACP.
Click the ".MODS" tab.
I see the description for PHPINFO & the text "Hello World !" in the content area, and My Category & My Modules Title in the menu on the left.
At this point I'm using the php_info template file to quickly get something in working order, time to change that.
Open "adm/style/acp_php_info.html"
Save a copy in the same folder as "acp_my_module.html"
Replace the contents with the following
Code: [ Select ]
<!-- INCLUDE overall_header.html -->
<a name="maincontent"></a>
<h1>{L_ACP_MY_MODULE}</h1>
{HELLO_WORLD}
<!-- INCLUDE overall_footer.html -->
<a name="maincontent"></a>
<h1>{L_ACP_MY_MODULE}</h1>
{HELLO_WORLD}
<!-- INCLUDE overall_footer.html -->
- <!-- INCLUDE overall_header.html -->
- <a name="maincontent"></a>
- <h1>{L_ACP_MY_MODULE}</h1>
- {HELLO_WORLD}
- <!-- INCLUDE overall_footer.html -->
Save the file.
Go back into "includes/acp/acp_my_module.php"
Change the value for "$this->tpl_name" to "acp_my_module" so I have
Code: [ Select ]
$this->tpl_name = 'acp_my_module';
Change the template variable key "PHPINFO" to "HELLO_WORLD" so I have
Code: [ Select ]
$template->assign_var('HELLO_WORLD', $output);
Save the file.
At this point I realize I'm using the permission setting for "PHPINFO" to control who can access this module & instead want it to require the same permission as altering board settings requires.
Open "includes/acp/info/acp_board.php"
Deterine which permissions that module uses by looking at the "auth" portion of the different modes.
In this case some use "acl_a_board" and some use "acl_a_server".
Go back to "includes/acp/info/acp_my_module.php"
I want my permissions to be a little less granulated than they are in acp_board, so I'm going to replace my modules "auth" which is "acl_a_phpinfo" to "acl_a_board && acl_a_server" which will require both of those permissions to access this module & give me the following
Code: [ Select ]
'auth' => 'acl_a_board && acl_a_server',
Save the file.
Click "My Modules Title" from the "My Category" menu on the left.
I don't see the PHPINFO stuff anymore, just "My Modules Title" in big letters, and "Hello World !" in smaller letters under it.
At this point I can make alterations to the following files to finish integrating something.
"includes/acp/acp_my_module.php"
"adm/style/acp_my_module.html"
Strong with this one, the sudo is.
- Bogey
- Bogey


- Joined: Jul 14, 2005
- Posts: 8211
- Loc: USA
- Status: Offline
- spork
- Brewmaster


- Joined: Sep 22, 2003
- Posts: 6128
- Loc: Seattle, WA
- Status: Offline
- Bogey
- Bogey


- Joined: Jul 14, 2005
- Posts: 8211
- Loc: USA
- Status: Offline
I know I haven't replied here in a long while, but I'm currently facing a problem... I can't get certain config variables to be submitted and saved...
Below is my includes/acp/acp_notifications.php
And my includes/acp/info/acp_notifications.php:
It shows everything correctly, but what it doesn't do is actually submit the values into the database. This is getting a bit frustrating... I don't know what to do... the following is my SQL for it...
Below is my includes/acp/acp_notifications.php
PHP Code: [ Select ]
<?php
/**
*
* @package acp
* @version $Id: acp_php_info.php 8479 2008-03-29 00:22:48Z naderman $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php<!-- m --> GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package acp
*/
class acp_notifications
{
var $u_action;
function main($id, $mode)
{
global $db, $user, $auth, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$action = request_var('action', '');
$submit = (isset($_POST['submit'])) ? true : false;
switch ($mode)
{
case 'Notifications':
$display_vars = array(
'title' => 'Notifications',
'vars' => array(
'legend1' => 'NOTIFICATION_NOTIFICATION',
'remove_notification_loggin' => array('lang' => 'NOTIFICATION_LOGGIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'remove_notification_posting' => array('lang' => 'NOTIFICATION_POSTING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
)
);
break;
default:
trigger_error('NO_MODE', E_USER_ERROR);
break;
}
$error = array();
// We validate the complete config if whished
validate_config_vars($display_vars['vars'], $cfg_array, $error);
// Do not write values if there is an error
if (sizeof($error) > 0)
{
$submit = false;
}
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
foreach ($display_vars['vars'] as $config_name => $null)
{
if ($submit && $config_name != 'legend1')
{
set_config($config_name, $config_value);
}
}
if ($submit)
{
add_log('admin', 'LOG_CONFIG_' . strtoupper($mode));
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
$this->tpl_name = 'acp_board';
$this->page_title = $display_vars['title'];
$template->assign_vars(array(
'L_TITLE' => $user->lang['ACP_NOTIFICATIONS_INFO'],
'L_TITLE_EXPLAIN' => $user->lang['ACP_NOTIFICATIONS_EXPLAIN'],
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => implode('<br />', $error),
'U_ACTION' => $this->u_action
));
// Output relevant page
foreach ($display_vars['vars'] as $config_key => $vars)
{
if (!is_array($vars) && strpos($config_key, 'legend') === false)
{
continue;
}
if (strpos($config_key, 'legend') !== false)
{
$template->assign_block_vars('options', array(
'S_LEGEND' => true,
'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars
));
continue;
}
$type = explode(':', $vars['type']);
$l_explain = '';
if ($vars['explain'] && isset($vars['lang_explain']))
{
$l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
}
else if ($vars['explain'])
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
$template->assign_block_vars('options', array(
'KEY' => $config_key,
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => $l_explain,
'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars),
));
unset($display_vars['vars'][$config_key]);
}
}
}
?>
/**
*
* @package acp
* @version $Id: acp_php_info.php 8479 2008-03-29 00:22:48Z naderman $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php<!-- m --> GNU Public License
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* @package acp
*/
class acp_notifications
{
var $u_action;
function main($id, $mode)
{
global $db, $user, $auth, $template;
global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
$action = request_var('action', '');
$submit = (isset($_POST['submit'])) ? true : false;
switch ($mode)
{
case 'Notifications':
$display_vars = array(
'title' => 'Notifications',
'vars' => array(
'legend1' => 'NOTIFICATION_NOTIFICATION',
'remove_notification_loggin' => array('lang' => 'NOTIFICATION_LOGGIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'remove_notification_posting' => array('lang' => 'NOTIFICATION_POSTING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
)
);
break;
default:
trigger_error('NO_MODE', E_USER_ERROR);
break;
}
$error = array();
// We validate the complete config if whished
validate_config_vars($display_vars['vars'], $cfg_array, $error);
// Do not write values if there is an error
if (sizeof($error) > 0)
{
$submit = false;
}
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
foreach ($display_vars['vars'] as $config_name => $null)
{
if ($submit && $config_name != 'legend1')
{
set_config($config_name, $config_value);
}
}
if ($submit)
{
add_log('admin', 'LOG_CONFIG_' . strtoupper($mode));
trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
}
$this->tpl_name = 'acp_board';
$this->page_title = $display_vars['title'];
$template->assign_vars(array(
'L_TITLE' => $user->lang['ACP_NOTIFICATIONS_INFO'],
'L_TITLE_EXPLAIN' => $user->lang['ACP_NOTIFICATIONS_EXPLAIN'],
'S_ERROR' => (sizeof($error)) ? true : false,
'ERROR_MSG' => implode('<br />', $error),
'U_ACTION' => $this->u_action
));
// Output relevant page
foreach ($display_vars['vars'] as $config_key => $vars)
{
if (!is_array($vars) && strpos($config_key, 'legend') === false)
{
continue;
}
if (strpos($config_key, 'legend') !== false)
{
$template->assign_block_vars('options', array(
'S_LEGEND' => true,
'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars
));
continue;
}
$type = explode(':', $vars['type']);
$l_explain = '';
if ($vars['explain'] && isset($vars['lang_explain']))
{
$l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
}
else if ($vars['explain'])
{
$l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
}
$template->assign_block_vars('options', array(
'KEY' => $config_key,
'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
'S_EXPLAIN' => $vars['explain'],
'TITLE_EXPLAIN' => $l_explain,
'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars),
));
unset($display_vars['vars'][$config_key]);
}
}
}
?>
- <?php
- /**
- *
- * @package acp
- * @version $Id: acp_php_info.php 8479 2008-03-29 00:22:48Z naderman $
- * @copyright (c) 2005 phpBB Group
- * @license http://opensource.org/licenses/gpl-license.php<!-- m --> GNU Public License
- *
- */
- /**
- * @ignore
- */
- if (!defined('IN_PHPBB'))
- {
- exit;
- }
- /**
- * @package acp
- */
- class acp_notifications
- {
- var $u_action;
- function main($id, $mode)
- {
- global $db, $user, $auth, $template;
- global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
- $action = request_var('action', '');
- $submit = (isset($_POST['submit'])) ? true : false;
- switch ($mode)
- {
- case 'Notifications':
- $display_vars = array(
- 'title' => 'Notifications',
- 'vars' => array(
- 'legend1' => 'NOTIFICATION_NOTIFICATION',
- 'remove_notification_loggin' => array('lang' => 'NOTIFICATION_LOGGIN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- 'remove_notification_posting' => array('lang' => 'NOTIFICATION_POSTING', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
- )
- );
- break;
- default:
- trigger_error('NO_MODE', E_USER_ERROR);
- break;
- }
- $error = array();
- // We validate the complete config if whished
- validate_config_vars($display_vars['vars'], $cfg_array, $error);
- // Do not write values if there is an error
- if (sizeof($error) > 0)
- {
- $submit = false;
- }
- // We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
- foreach ($display_vars['vars'] as $config_name => $null)
- {
- if ($submit && $config_name != 'legend1')
- {
- set_config($config_name, $config_value);
- }
- }
- if ($submit)
- {
- add_log('admin', 'LOG_CONFIG_' . strtoupper($mode));
- trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action));
- }
- $this->tpl_name = 'acp_board';
- $this->page_title = $display_vars['title'];
- $template->assign_vars(array(
- 'L_TITLE' => $user->lang['ACP_NOTIFICATIONS_INFO'],
- 'L_TITLE_EXPLAIN' => $user->lang['ACP_NOTIFICATIONS_EXPLAIN'],
- 'S_ERROR' => (sizeof($error)) ? true : false,
- 'ERROR_MSG' => implode('<br />', $error),
- 'U_ACTION' => $this->u_action
- ));
- // Output relevant page
- foreach ($display_vars['vars'] as $config_key => $vars)
- {
- if (!is_array($vars) && strpos($config_key, 'legend') === false)
- {
- continue;
- }
- if (strpos($config_key, 'legend') !== false)
- {
- $template->assign_block_vars('options', array(
- 'S_LEGEND' => true,
- 'LEGEND' => (isset($user->lang[$vars])) ? $user->lang[$vars] : $vars
- ));
- continue;
- }
- $type = explode(':', $vars['type']);
- $l_explain = '';
- if ($vars['explain'] && isset($vars['lang_explain']))
- {
- $l_explain = (isset($user->lang[$vars['lang_explain']])) ? $user->lang[$vars['lang_explain']] : $vars['lang_explain'];
- }
- else if ($vars['explain'])
- {
- $l_explain = (isset($user->lang[$vars['lang'] . '_EXPLAIN'])) ? $user->lang[$vars['lang'] . '_EXPLAIN'] : '';
- }
- $template->assign_block_vars('options', array(
- 'KEY' => $config_key,
- 'TITLE' => (isset($user->lang[$vars['lang']])) ? $user->lang[$vars['lang']] : $vars['lang'],
- 'S_EXPLAIN' => $vars['explain'],
- 'TITLE_EXPLAIN' => $l_explain,
- 'CONTENT' => build_cfg_template($type, $config_key, $this->new_config, $config_key, $vars),
- ));
- unset($display_vars['vars'][$config_key]);
- }
- }
- }
- ?>
And my includes/acp/info/acp_notifications.php:
PHP Code: [ Select ]
<?php
/**
*
* @package acp
* @version $Id: acp_php_info.php 8479 2008-03-29 00:22:48Z naderman $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php<!-- m --> GNU Public License
*
*/
/**
* @package module_install
*/
class acp_notifications_info
{
function module()
{
return array(
'filename' => 'notifications',
'title' => 'Notifications',
'version' => '1.0.0',
'modes' => array(
'Notifications' => array('title' => 'Notifications', 'auth' => 'acl_a_board', 'cat' => array('ACP_GENERAL_TASKS')),
),
);
}
function install()
{
}
function uninstall()
{
}
}
?>
/**
*
* @package acp
* @version $Id: acp_php_info.php 8479 2008-03-29 00:22:48Z naderman $
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php<!-- m --> GNU Public License
*
*/
/**
* @package module_install
*/
class acp_notifications_info
{
function module()
{
return array(
'filename' => 'notifications',
'title' => 'Notifications',
'version' => '1.0.0',
'modes' => array(
'Notifications' => array('title' => 'Notifications', 'auth' => 'acl_a_board', 'cat' => array('ACP_GENERAL_TASKS')),
),
);
}
function install()
{
}
function uninstall()
{
}
}
?>
- <?php
- /**
- *
- * @package acp
- * @version $Id: acp_php_info.php 8479 2008-03-29 00:22:48Z naderman $
- * @copyright (c) 2005 phpBB Group
- * @license http://opensource.org/licenses/gpl-license.php<!-- m --> GNU Public License
- *
- */
- /**
- * @package module_install
- */
- class acp_notifications_info
- {
- function module()
- {
- return array(
- 'filename' => 'notifications',
- 'title' => 'Notifications',
- 'version' => '1.0.0',
- 'modes' => array(
- 'Notifications' => array('title' => 'Notifications', 'auth' => 'acl_a_board', 'cat' => array('ACP_GENERAL_TASKS')),
- ),
- );
- }
- function install()
- {
- }
- function uninstall()
- {
- }
- }
- ?>
It shows everything correctly, but what it doesn't do is actually submit the values into the database. This is getting a bit frustrating... I don't know what to do... the following is my SQL for it...
Code: [ Select ]
"INSERT INTO `$dbname`.`{$table_pre}config` (`config_name` , `config_value` , `is_dynamic`) VALUES
('remove_notification_loggin', '1', '0'),
('remove_notification_posting', '1', '0');"
('remove_notification_loggin', '1', '0'),
('remove_notification_posting', '1', '0');"
- "INSERT INTO `$dbname`.`{$table_pre}config` (`config_name` , `config_value` , `is_dynamic`) VALUES
- ('remove_notification_loggin', '1', '0'),
- ('remove_notification_posting', '1', '0');"
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
- Bogey
- Bogey


- Joined: Jul 14, 2005
- Posts: 8211
- Loc: USA
- Status: Offline
- Bogey
- Bogey


- Joined: Jul 14, 2005
- Posts: 8211
- Loc: USA
- Status: Offline
I managed to solve the problem... What was wrong is that I didn't define $cfg_config... I had it defined before, but something else was causing the problem, and so I removed that.
Added that right after the switch and it all works fine
Hope that this helps somebody.
Code: [ Select ]
$this->new_config = $config;
$cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
$error = array();
$cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
$error = array();
- $this->new_config = $config;
- $cfg_array = (isset($_REQUEST['config'])) ? utf8_normalize_nfc(request_var('config', array('' => ''), true)) : $this->new_config;
- $error = array();
Added that right after the switch and it all works fine
"Bring forth therefore fruits meet for repentance:" Matthew 3:8
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 11 posts
- Users browsing this forum: Zealous and 137 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
