phpBB

Development Wiki

Difference between revisions of "User:Highway of Life/Auth List"

From phpBB Development Wiki

(Created script for generating the auto roles for each permission level.)
 
m (fixed small bug, prints more well formed.)
Line 7: Line 7:
 
* @author Highway of Life http://startrekguide.com
 
* @author Highway of Life http://startrekguide.com
 
* @package Develop
 
* @package Develop
* @version $Id: auth_permissions_wiki.php 8 2007-04-13 22:53:02Z highwayoflife $
+
* @version $Id: auth_permissions_wiki.php 18 2007-04-18 00:40:27Z highwayoflife $
 
* @copyright (c) 2007 Star Trek Guide Group
 
* @copyright (c) 2007 Star Trek Guide Group
 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License  
 
* @license http://opensource.org/licenses/gpl-license.php GNU Public License  
Line 47: Line 47:
 
$type = '';
 
$type = '';
  
$action = sprintf('%sView Admin Permissions%s', '<a href="' . append_sid("mcp_permissions.$phpEx", 'acl=a') . '">', '<a/>') . '<br />';
+
$action = sprintf('%sView Admin Permissions%s', '<a href="' . append_sid("mcp_permissions.$phpEx", 'acl=a') . '">', '<a/>') . '<br />';
 
$action .= sprintf('%sView Moderator Permissions%s','<a href="' . append_sid("mcp_permissions.$phpEx", 'acl=m') . '">', '<a/>') . '<br />';
 
$action .= sprintf('%sView Moderator Permissions%s','<a href="' . append_sid("mcp_permissions.$phpEx", 'acl=m') . '">', '<a/>') . '<br />';
$action .= sprintf('%sView User Permissions%s', '<a href="' . append_sid("mcp_permissions.$phpEx", 'acl=u') . '">', '<a/>') . '<br />';
+
$action .= sprintf('%sView User Permissions%s', '<a href="' . append_sid("mcp_permissions.$phpEx", 'acl=u') . '">', '<a/>') . '<br />';
$action .= sprintf('%sView Forum Permissions%s', '<a href="' . append_sid("mcp_permissions.$phpEx", 'acl=f') . '">', '<a/>') . '<br />';
+
$action .= sprintf('%sView Forum Permissions%s', '<a href="' . append_sid("mcp_permissions.$phpEx", 'acl=f') . '">', '<a/>') . '<br />';
  
 
if (!empty($acl))
 
if (!empty($acl))
Line 84: Line 84:
 
if ($row['auth_option'] == ($type . '_'))
 
if ($row['auth_option'] == ($type . '_'))
 
{
 
{
print "|-\n| [[" . $row['auth_option'] . "]]\n| " . '<pre>$auth->acl_get(\'' . $row['auth_option'] . '\');</pre>' . "\n| " . $user->lang['permission_type'][$row['auth_option']] . "\n";
+
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
 
else
 
{
 
{
$permission = "acl_{$row['auth_option']}";
+
$permission = $row['auth_option'];
print "|-\n| [[" . $permission . "]]\n| " . '<pre>$auth->acl_get(\'' . $row['auth_option'] . '\');</pre>' . "\n| " . $user->lang[$permission]['lang'] . "\n";
+
print "|-\n";
 +
print "| [[$permission]]\n";
 +
print '| <php>$auth->acl_get(\'' . $row['auth_option'] . "');</php>\n";
 +
print '| ' . $user->lang['acl_' . $permission]['lang'] . "\n";
 
}
 
}
 
}
 
}

Revision as of 00:43, 18 April 2007

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("mcp_permissions.$phpEx"'acl=a') . '">''<a/>') . '<br />';
$action .= sprintf('%sView Moderator Permissions%s','<a href="' append_sid("mcp_permissions.$phpEx"'acl=m') . '">''<a/>') . '<br />';
$action .= sprintf('%sView User Permissions%s',        '<a href="' append_sid("mcp_permissions.$phpEx"'acl=u') . '">''<a/>') . '<br />';
$action .= sprintf('%sView Forum Permissions%s',    '<a href="' append_sid("mcp_permissions.$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'] . "');
\n";

print '| ' . $user->lang['permission_type'][$row['auth_option']] . "\n"; } else { $permission = $row['auth_option']; print "|-\n"; print "| $permission\n";

print '|
$auth->acl_get(\'' $row['auth_option'] . "');
\n";

print '| ' . $user->lang['acl_' . $permission]['lang'] . "\n"; } } $db->sql_freeresult($result); print '|}'; } else { trigger_error($action); } } else { trigger_error($action); } ?></php>