phpBB

Development Wiki

User:Highway of life/Auth List

From phpBB Development Wiki

< User:Highway of life
Revision as of 18:59, 14 October 2008 by Highway of life (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Created this script to generate the permission roles for Admin permissions, Moderator permissions, User permissions, and Forum permissions tables.
Highway of Life (talk) 22:58, 13 April 2007 (UTC)

<?php
/** 
*
* @author Highway of Life http://startrekguide.com
* @package Develop
* @version $Id: auth_permissions_wiki.php 18 2007-04-18 00:40:27Z highwayoflife $
* @copyright (c) 2007 Star Trek Guide Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License 
*
*/

/**
* @ignore
*/
define('IN_PHPBB'true);
$phpbb_root_path './../';
$phpEx substr(strrchr(__FILE__'.'), 1);
include(
$phpbb_root_path 'common.' $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('common');

// is the user logged in?
if (!$user->data['is_registered'])
{
    if (
$user->data['is_bot'])
    {
        
// the user is a bot, send them back to home plate...
        
redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
    }
    
// the user is not logged in, give them a chance to login here...
    
login_box('''LOGIN');
}
else if (
$user->data['user_type'] != USER_FOUNDER)
{
    
trigger_error('NOT_AUTHORISED');
}
$user->add_lang('acp/permissions_phpbb');


$acl request_var('acl''');
$type '';

$action    sprintf('%sView Admin Permissions%s',        '<a href="' append_sid("auth_permissions_wiki.$phpEx"'acl=a') . '">''<a/>') . '<br />';
$action .= sprintf('%sView Moderator Permissions%s','<a href="' append_sid("auth_permissions_wiki.$phpEx"'acl=m') . '">''<a/>') . '<br />';
$action .= sprintf('%sView User Permissions%s',        '<a href="' append_sid("auth_permissions_wiki.$phpEx"'acl=u') . '">''<a/>') . '<br />';
$action .= sprintf('%sView Forum Permissions%s',    '<a href="' append_sid("auth_permissions_wiki.$phpEx"'acl=f') . '">''<a/>') . '<br />';

if (!empty(
$acl))
{
    switch (
$acl)
    {
        case 
'a':
            
$type 'a';
        break;
        case 
'm':
            
$type 'm';
        break;
        case 
'u':
            
$type 'u';
        break;
        case 
'f':
            
$type 'f';
        break;
    }
    
    if (
$type)
    {
        
header('Content-type:text/plain');
        print 
'{|border="1" cellspacing="0" cellpadding="3"
! Auth Option
! Auth Usage
! Auth Lang
'
;
        
$sql 'SELECT auth_option FROM ' ACL_OPTIONS_TABLE ' WHERE auth_option LIKE "' $type '_%"';
        
$result $db->sql_query($sql);
        while (
$row $db->sql_fetchrow($result))
        {
            if (
$row['auth_option'] == ($type '_'))
            {
                print 
"|-\n";
                print 
"| [[{$row['auth_option']}]]\n";
                print 
'| <php>$auth->acl_get(\'' $row['auth_option'] . "');< /php>\n";
                print 
'| ' $user->lang['permission_type'][$row['auth_option']] . "\n";
            }
            else
            {
                
$permission $row['auth_option'];
                print 
"|-\n";
                print 
"| [[$permission]]\n";
                print 
'| <php>$auth->acl_get(\'' $row['auth_option'] . "');< /php>\n";
                print 
'| ' $user->lang['acl_' $permission]['lang'] . "\n";
            }
        }
        
$db->sql_freeresult($result);
        print 
'|}';
    }
    else
    {
        
trigger_error($action);
    }
}
else
{
    
trigger_error($action);
}
?>