phpBB

Development Wiki

Difference between revisions of "Talk:Tutorial.Permissions"

From phpBB Development Wiki

m (Clear permissions using auth class method)
m (Adding new permission set)
 
(24 intermediate revisions by 7 users not shown)
Line 41: Line 41:
 
function build_auth_option_statement($key, $auth_options, &$sql_opts)</php>
 
function build_auth_option_statement($key, $auth_options, &$sql_opts)</php>
 
Perhaps this could make modding a bit easier...
 
Perhaps this could make modding a bit easier...
Well, I must back... doing some university stuff -- Greetings - [http://startrekguide.com/forum/memberlist.php?mode=viewprofile&u=2429 Emanuelle_1982]</blockquote>
+
Well, I must back... doing some university stuff -- Greetings - [[User:Emanuelle_1982|Emanuelle_1982]]</blockquote>
 +
 
 +
== some changes in CVS ==
 +
 
 +
well, in the permissions file there is a comment that the permissions lang file must in language/<lang>/acp folder, not into mods folder - it should be checked which method is correct
 +
 
 +
[EDIT:]both methods seems to be not working, even with clearing cache manually[/EDIT]
 +
 
 +
file: language/<lang>/acp/permissions_phpbb.php
 +
<php>/*
 +
* MODDERS PLEASE NOTE
 +
*
 +
* You are able to put your permission sets into a separate file too by
 +
* prefixing the new file with permissions_ and putting it into the acp
 +
* language folder.
 +
*
 +
* An example of how the file could look like:
 +
*
 +
* <code>
 +
*
 +
* if (empty($lang) || !is_array($lang))
 +
* {
 +
* $lang = array();
 +
* }
 +
*
 +
* // Adding new category
 +
* $lang['permission_cat']['bugs'] = 'Bugs';
 +
*
 +
* // Adding new permission set
 +
* $lang['permission_type']['bug_'] = 'Bug Permissions';
 +
*
 +
* // Adding the permissions
 +
* $lang = array_merge($lang, array(
 +
* 'acl_bug_view' => array('lang' => 'Can view bug reports', 'cat' => 'bugs'),
 +
* 'acl_bug_post' => array('lang' => 'Can post bugs', 'cat' => 'post'), // Using a phpBB category here
 +
* ));
 +
*
 +
* </code>
 +
*/</php>
 +
--[[User:Emanuelle 1982|Emanuelle 1982]] 11:45, 1 May 2007 (UTC)
 +
 
 +
:Both methods work for me, but unless you have the latest cvs version, the filename must not begin with "permissions_phpbb" - see [[bug:10301]].
 +
 
 +
::OK, that was the problem, now it works *gg*
 +
 
 +
==2nd way for negating a permission==
 +
 
 +
Well, there is a 2nd way to negate a permission request
 +
 
 +
1st and nearly always used: <code>!$auth->acl_get('u_foo')</code>
 +
 
 +
2nd (don't like it, not consistent) <code>$auth->acl_get('!u_foo')</code>, but is used too (in includes/mcp/mcp_topic.php)
 +
 
 +
Mention it or not?
 +
*Pro: it is a possibility, and is used
 +
*Contra: it reduces Code Readability
 +
--[[User:Emanuelle 1982|Emanuelle 1982]] 16:27, 9 May 2007 (UTC)
 +
:I think it is a bug, you should report it. [[User:Highway_of_Life|'''<span style="color:#0074ae;">Highway</span> <span style="color:green;">of</span> <span style="color:blue;">Life</span>''']] [[User talk:Highway_of_Life|<span style="color:red;">(talk)</span>]] 15:53, 10 May 2007 (UTC)
 +
 
 +
::was reported, with the said Information, DavidMJ thought that this will not be fixed [it works, there is a substring/strpos combo] [[bug:10695]]
 +
:::This has been implemented as it is a lot more efficient in some cases (not with simple acl_get) and also adds a feature to acl_getf, as you can't just use ! on an array to get forums where a user does not have a permission, this should be documented. --[[User:naderman|naderman]] 21:09, 10 May 2007
 +
 
 +
== Adding new permission set ==
 +
 
 +
This example found in <code>\root\language\en\acp\permissions_phpbb.php</code>
 +
<php>
 +
/**
 +
* MODDERS PLEASE NOTE
 +
*
 +
* You are able to put your permission sets into a separate file too by
 +
* prefixing the new file with permissions_ and putting it into the acp
 +
* language folder.
 +
*
 +
* An example of how the file could look like:
 +
*
 +
* <code>
 +
*
 +
* if (empty($lang) || !is_array($lang))
 +
* {
 +
* $lang = array();
 +
* }
 +
*
 +
* // Adding new category
 +
* $lang['permission_cat']['bugs'] = 'Bugs';
 +
*
 +
* // Adding new permission set
 +
* $lang['permission_type']['bug_'] = 'Bug Permissions';
 +
*
 +
* // Adding the permissions
 +
* $lang = array_merge($lang, array(
 +
* 'acl_bug_view' => array('lang' => 'Can view bug reports', 'cat' => 'bugs'),
 +
* 'acl_bug_post' => array('lang' => 'Can post bugs', 'cat' => 'post'), // Using a phpBB category here
 +
* ));
 +
*
 +
* </code>
 +
*/
 +
</php>
 +
<br />
 +
And everything works fine except this part
 +
<php>
 +
// Adding new permission set
 +
$lang['permission_type']['bug_'] = 'Bug Permissions';
 +
</php>
 +
<br />
 +
Thing is that modder can create new permission type, but can't manage it through ACP. Problem is in <code>\root\includes\acp\acp_permissions.php</code>
 +
<php>
 +
$this->permission_dropdown = array('u_', 'm_', 'a_');
 +
</php>
 +
As seen here, the ACP dropdown for managing permission sets are hardcoded only for User, Moderator and Admin. So if moder adds a new permission type he will not see it in a dropdown, (even if he has necessary permissions).
 +
 
 +
So to overcome this restriction i changed this line to:
 +
<php>
 +
$this->permission_dropdown = array_diff(array_keys($user->lang['permission_type']), array('f_', 'global'));
 +
</php>
 +
<br />
 +
<br />
 +
P.S. After that modder won't see new permission type regardless. Because there are no admin permissions for new permission type.
 +
This query (or analog via $auth_admin class) must be executed to change that
 +
<php>
 +
INSERT INTO phpbb_acl_options (auth_option, is_global, is_local, founder_only) VALUES
 +
('bug_', 1, 0, 0),
 +
('a_bugauth', 1, 0, 0);
 +
</php>
 +
<br />
 +
<br />
 +
Hope it helps someone.
 +
<br />
 +
[[User:Bulldozer am|Bulldozer am]] ([[User talk:Bulldozer am|talk]]) 16:19, 6 February 2014 (UTC)

Latest revision as of 10:27, 7 February 2014

Permissions talk page.

Please sign and date your entries by inserting ~~~~ at the end.

Start a new talk topic.


Just wanted to state that adding new permissions should *not* be done through an INSERT statement lonely but through the auth_admin::acl_add_option method.

This possibility should definately be explained as it's the prefered alternative naderman 11:17, 27 December 2006 (UTC)

Panels (in the ACP)

I've added this to the wiki:


To get the permission to show up under the right panel you need to use correct namning. a_view_foo : Administrator permissions panel m_view_foo : Moderator permissions panel u_view_foo : User permissions panel If you use the correct naming and giving it a category the permssion will show under the selected panel. Nothing more need todo.


But it needs to be reformated into a more userfriendly text.

Ztripez 20:04, 26 March 2007 (UTC)

Clear permissions using auth class method

Re-posting a message I received regarding this article... Highway of Life (talk) 17:05, 26 April 2007 (UTC)

I think there is a little improvement possible for an article in the Olympus Wiki ... suggestion:

clear permssions not by deleting cache folder, but using auth class, method

/**
* Clear one or all users cached permission settings
*/
function acl_clear_prefetch($user_id false)
and perhaps you also also must run
/**
* Fill auth_option statement for later querying based on the supplied options
*/
function build_auth_option_statement($key$auth_options, &$sql_opts)

Perhaps this could make modding a bit easier...

Well, I must back... doing some university stuff -- Greetings - Emanuelle_1982

some changes in CVS

well, in the permissions file there is a comment that the permissions lang file must in language/<lang>/acp folder, not into mods folder - it should be checked which method is correct

[EDIT:]both methods seems to be not working, even with clearing cache manually[/EDIT]

file: language/<lang>/acp/permissions_phpbb.php

/*
*    MODDERS PLEASE NOTE
*    
*    You are able to put your permission sets into a separate file too by
*    prefixing the new file with permissions_ and putting it into the acp 
*    language folder.
*
*    An example of how the file could look like:
*
*    <code>
*
*    if (empty($lang) || !is_array($lang))
*    {
*        $lang = array();
*    }
*
*    // Adding new category
*    $lang['permission_cat']['bugs'] = 'Bugs';
*
*    // Adding new permission set
*    $lang['permission_type']['bug_'] = 'Bug Permissions';
*
*    // Adding the permissions
*    $lang = array_merge($lang, array(
*        'acl_bug_view'        => array('lang' => 'Can view bug reports', 'cat' => 'bugs'),
*        'acl_bug_post'        => array('lang' => 'Can post bugs', 'cat' => 'post'), // Using a phpBB category here
*    ));
*
*    </code>
*/

--Emanuelle 1982 11:45, 1 May 2007 (UTC)

Both methods work for me, but unless you have the latest cvs version, the filename must not begin with "permissions_phpbb" - see bug:10301.
OK, that was the problem, now it works *gg*

2nd way for negating a permission

Well, there is a 2nd way to negate a permission request

1st and nearly always used: !$auth->acl_get('u_foo')

2nd (don't like it, not consistent) $auth->acl_get('!u_foo'), but is used too (in includes/mcp/mcp_topic.php)

Mention it or not?

  • Pro: it is a possibility, and is used
  • Contra: it reduces Code Readability

--Emanuelle 1982 16:27, 9 May 2007 (UTC)

I think it is a bug, you should report it. Highway of Life (talk) 15:53, 10 May 2007 (UTC)
was reported, with the said Information, DavidMJ thought that this will not be fixed [it works, there is a substring/strpos combo] bug:10695
This has been implemented as it is a lot more efficient in some cases (not with simple acl_get) and also adds a feature to acl_getf, as you can't just use ! on an array to get forums where a user does not have a permission, this should be documented. --naderman 21:09, 10 May 2007

Adding new permission set

This example found in \root\language\en\acp\permissions_phpbb.php

/**
*    MODDERS PLEASE NOTE
*
*    You are able to put your permission sets into a separate file too by
*    prefixing the new file with permissions_ and putting it into the acp
*    language folder.
*
*    An example of how the file could look like:
*
*    <code>
*
*    if (empty($lang) || !is_array($lang))
*    {
*        $lang = array();
*    }
*
*    // Adding new category
*    $lang['permission_cat']['bugs'] = 'Bugs';
*
*    // Adding new permission set
*    $lang['permission_type']['bug_'] = 'Bug Permissions';
*
*    // Adding the permissions
*    $lang = array_merge($lang, array(
*        'acl_bug_view'        => array('lang' => 'Can view bug reports', 'cat' => 'bugs'),
*        'acl_bug_post'        => array('lang' => 'Can post bugs', 'cat' => 'post'), // Using a phpBB category here
*    ));
*
*    </code>
*/


And everything works fine except this part

// Adding new permission set
    
$lang['permission_type']['bug_'] = 'Bug Permissions';


Thing is that modder can create new permission type, but can't manage it through ACP. Problem is in \root\includes\acp\acp_permissions.php

$this->permission_dropdown = array('u_''m_''a_');

As seen here, the ACP dropdown for managing permission sets are hardcoded only for User, Moderator and Admin. So if moder adds a new permission type he will not see it in a dropdown, (even if he has necessary permissions).

So to overcome this restriction i changed this line to:

$this->permission_dropdown array_diff(array_keys($user->lang['permission_type']), array('f_''global'));



P.S. After that modder won't see new permission type regardless. Because there are no admin permissions for new permission type. This query (or analog via $auth_admin class) must be executed to change that

INSERT INTO phpbb_acl_options (auth_optionis_globalis_localfounder_onlyVALUES 
('bug_'100),
(
'a_bugauth'100);



Hope it helps someone.
Bulldozer am (talk) 16:19, 6 February 2014 (UTC)