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 » Fri May 31, 2013 2:51 pm

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 » Fri May 31, 2013 3:25 pm

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 » Sat Jun 01, 2013 12:43 am

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
VSE
Extension Customisations
Extension Customisations
Posts: 670
Joined: Mon Mar 08, 2010 9:18 am

Re: Split permission logic from translations

Post by VSE » Sat Jun 01, 2013 3:21 am

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 » Mon Jun 03, 2013 5:46 pm

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 » Mon Jun 03, 2013 7:01 pm

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 » Tue Jun 11, 2013 4:10 pm

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
keith10456
Registered User
Posts: 523
Joined: Sat Apr 22, 2006 10:29 pm
Contact:

Re: Split permission logic from translations

Post by keith10456 » Tue Jun 11, 2013 9:31 pm

Makes a lot of sense... +1

User avatar
VSE
Extension Customisations
Extension Customisations
Posts: 670
Joined: Mon Mar 08, 2010 9:18 am

Re: Split permission logic from translations

Post by VSE » Mon Jul 22, 2013 11:35 pm

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: Lanngöns/Hessen Germany
Contact:

Re: Split permission logic from translations

Post by wintstar » Tue Jul 23, 2013 6:34 am

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 :-)

Quote: "To achieve the possible, the impossible has to be tried again and again" (Hermann Hesse (1877-1962)).
A look into the future phpBB 3.1.0 - Board, current Builds
A look into the future phpBB 3.1.0 - Board-Plus, Extensions in the test

Post Reply