Split permission logic from translations

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.1/Ascraeus branch. Everything listed in this forum will be available in phpBB 3.1.
User avatar
nickvergessen
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany
Contact:

Split permission logic from translations

Post by nickvergessen »

Currently we have a permission_phpbb.php file in the language dir with content as follows:

Code: Select all

	'acl_u_viewprofile'	=> array('lang' => 'Can view profiles, memberlist and online list', 'cat' => 'profile'),
	'acl_u_chgname'		=> array('lang' => 'Can change username', 'cat' => 'profile'),
I think we sould split that of into another file and only keep the translations in the language dir:
New file: includes/permissions/phpbb.php

Code: Select all

	'acl_u_viewprofile'	=> array('lang' => 'ACL_U_VIEWPROFILE', 'cat' => 'profile'),
	'acl_u_chgname'		=> array('lang' => 'ACL_U_CHANGENAME', 'cat' => 'profile'),
Translation file:

Code: Select all

	'ACL_U_VIEWPROFILE'	=> 'Can view profiles, memberlist and online list',
	'ACL_U_CHANGENAME'		=> 'Can change username',
Should be quite easy to achieve and would make translating quite a bit easier and it just makes no sense to have the logic within the translation files
Member of the Development-TeamNo Support via PM

User avatar
imkingdavid
Registered User
Posts: 1050
Joined: Thu Jul 30, 2009 12:06 pm

Re: Split permission logic from translations

Post by imkingdavid »

Sounds fine to me.
I do custom MODs. PM for a quote!
View My: MODs | Portfolio
Please do NOT contact for support via PM or email.
Remember, the enemy's gate is down.

User avatar
Pony99CA
Registered User
Posts: 986
Joined: Sun Feb 08, 2009 2:35 am
Location: Hollister, CA
Contact:

Re: Split permission logic from translations

Post by Pony99CA »

Wow, I had no idea that it wasn't done that way already.

Steve
Silicon Valley Pocket PC (http://www.svpocketpc.com)
Creator of manage_bots and spoof_user (ask me)
Need hosting for a small forum with full cPanel & MySQL access? Contact me or PM me.

User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

Re: Split permission logic from translations

Post by MattF »

Don't forget about extensions.

It'd also be necessary to implement this split-logic for extensions too... Would they need their own permissions directory for the logic files too?
Has an irascible disposition.

User avatar
nickvergessen
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany
Contact:

Re: Split permission logic from translations

Post by nickvergessen »

Yeah I will take care of that.
Member of the Development-TeamNo Support via PM

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: Split permission logic from translations

Post by EXreaction »

Preferably any changes would be backwards compatible (just translate the lang value if it exists, otherwise display the string).

User avatar
nickvergessen
Former Team Member
Posts: 733
Joined: Sun Oct 07, 2007 11:54 am
Location: Stuttgart, Germany
Contact:

Re: Split permission logic from translations

Post by nickvergessen »

Well that is what user->lang() does. It displayes the value if available or uses the key "as value" otherwise.
Member of the Development-TeamNo Support via PM


User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

Re: Split permission logic from translations

Post by MattF »

OK, so I'm trying out this (now that it has been merged) in an extension.

I got it working, but I want to make sure I'm doing it right.

It claims we use the core.permissions event for the logic.

Is this example the correctly intended way of doing the logic?

Code: Select all

static public function getSubscribedEvents()
{
    return array(
        'core.permissions'    => 'foo_bar_permissions',
    );
}

public function foo_bar_permissions($event)
{
    $event['permissions'] = array_merge($event['permissions'], array(
        'u_foobar'    => array(
            'lang' => 'ACL_U_FOOBAR',
            'cat' => 'misc',
        ),
    ));
}
 
And of course, I have a typical lang file named permissions_foobar.php with this:

Code: Select all

$lang = array_merge($lang, array(
    'ACL_U_FOOBAR'    => 'Can view foo bar topics',
));
 
Has an irascible disposition.

User avatar
wintstar
Registered User
Posts: 108
Joined: Sun Dec 02, 2012 1:38 pm
Location: Gießen /Hessen Germany
Contact:

Re: Split permission logic from translations

Post by wintstar »

Build 969. Why this forum permissions have been removed? Or be replaced by other? I can not find it in the new language file.

Code: Select all

	'acl_f_list'		=> array('lang' => 'Can see forum', 'cat' => 'post'),
	'acl_f_read'		=> array('lang' => 'Can read forum', 'cat' => 'post'),

EDIT

It is missing in the file

http://tracker.phpbb.com/browse/PHPBB3-11734
Greeting Stephan :-)

Post Reply