Raised This Month: $ Target: $400
 0% 

access() or get_user_flags()?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jje
Junior Member
Join Date: Oct 2011
Old 09-08-2012 , 08:21   access() or get_user_flags()?
Reply With Quote #1

Hello. What is faster access(index, FLAG) or get_user_flags(index) & FLAG? Is there any difference?
Jje is offline
Send a message via ICQ to Jje Send a message via Skype™ to Jje
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-08-2012 , 08:29   Re: access() or get_user_flags()?
Reply With Quote #2

where are you using it that you need speed? maybe it would be better to cache the value to a boolean
jimaway is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-08-2012 , 08:31   Re: access() or get_user_flags()?
Reply With Quote #3

Use cmd_accessOr tell us in which context you want to use it.
In normal contexts, you shouldn't care about performances.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-08-2012 at 08:32.
ConnorMcLeod is offline
Jje
Junior Member
Join Date: Oct 2011
Old 09-08-2012 , 08:33   Re: access() or get_user_flags()?
Reply With Quote #4

Yes, but i interested for what access(...) need? Isn't this the same with (get_user_flags(index) & FLAG)?
Jje is offline
Send a message via ICQ to Jje Send a message via Skype™ to Jje
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-08-2012 , 08:35   Re: access() or get_user_flags()?
Reply With Quote #5

context plz
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Jje
Junior Member
Join Date: Oct 2011
Old 09-08-2012 , 08:37   Re: access() or get_user_flags()?
Reply With Quote #6

Code:
if(access(id, ADMIN_ADMIN));
and
Code:
if(get_user_flags(id) & ADMIN_ADMIN);
case the same? so for what access() was created?

Last edited by Jje; 09-08-2012 at 08:38.
Jje is offline
Send a message via ICQ to Jje Send a message via Skype™ to Jje
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-08-2012 , 08:44   Re: access() or get_user_flags()?
Reply With Quote #7

PHP Code:
stock access(id,level
{
    if (
level==ADMIN_ADMIN)
    {
        return 
is_user_admin(id);
    }
    else if (
level==ADMIN_ALL)
    {
        return 
1;
    }

    return (
get_user_flags(id) & level);

access prevents coder from making mistakes with flags, because not all coders know usages of ADMIN_ADMIN and ADMIN_ALL, and also it handles better situations where the admin level is hold by a variable.

So :
If you check admin access in a command, use cmd_access
Else use access.
You may also need has_flag or has_all_flags in some situations.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Jje
Junior Member
Join Date: Oct 2011
Old 09-08-2012 , 08:49   Re: access() or get_user_flags()?
Reply With Quote #8

Thanks a lot
Jje is offline
Send a message via ICQ to Jje Send a message via Skype™ to Jje
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:10.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode