List:Eventum Development« Previous MessageNext Message »
From:Bryan Alsdorf Date:September 24 2009 4:08pm
Subject:Re: Seems to be a bug in User::getRoleID()
View as plain text  
Hi,

In the future please only post to one of the lists.

User::getRoleID() uses the non-localized names because non-localized names are used 
throughout the code to check permissions. If getRoleID() worked off the localized name all

the references through all the code would have to be updated. Since these calls are just 
used for control structures and not displayed to anyone it is a waste to localize them.

So in your code:
if ($usr_role_id == User::getRoleID(ev_gettext('Reporter')))

Just remove the call to ev_gettext and the problem will be solved.

Best Regards,
/bryan

Srivathsan, M IN BLR SISL wrote:
> Hi all,
> 
> Just wanted to confirm whether my assessment is right or wrong
> 
> In the method User::getRoleID($role_title), the global variable $roles is used.  From
> the other portions of code in class.user.php, I understand that other role-related methods
> like User::getRole() and User::getRoles(), $GLOBALS['localized_roles'] is used.
> 
> I feel that User::getRoleID() should also use $GLOBALS['localized_roles'] instead of
> $roles that contains only untranslated role titles.  I wrote a code as part of my workflow
> engine wherein I am comparing the role id of user to that of a Reporter.  So I wrote 'if
> ($usr_role_id == User::getRoleID(ev_gettext('Reporter')))'.  In my implementation of
> eventum, 'Reporter' is translated as 'Employee'.  So, the method
> User::getRoleID(ev_gettext('Reporter'))) just returns a NULL as there is no role title
> 'Employee' in the $roles array but is there in $GLOBALS['localized_roles'].
> 
> Could anyone confirm / explain why User::getRoleID() method is not referring to
> $GLOBALS['localized_roles'] - any good reason?
> 
> Thanks and rgds,
> Watson
> 
> 


-- 
Bryan Alsdorf, Lead Web Developer
Monty Program, AB. http://askmonty.org
Thread