2 little olympus code questions..

Discuss features as they are added to the new version. Give us your feedback. Don't post bug reports, feature requests, support questions or suggestions here.
Forum rules
Discuss features as they are added to the new version. Give us your feedback. Don't post bug reports, feature requests, support questions or suggestions here. Feature requests are closed.
Luciano
Registered User
Posts: 25
Joined: Wed Oct 17, 2001 6:33 am

2 little olympus code questions..

Post by Luciano »

I was just playing around.. and tried to figure out 2 little equivalents from the old phpbb..

one is $userdata['session_logged_in']

I found i could use $user->data['user_id'] != ANONYMOUS

but i find it not very elegant..
-------------------------

the other question was $userdata[user_level] == ADMIN

i found to ways to do it:
either:
check if user is in group id 7 (which seems to be admin)

or put this code at the top of the page:

Code: Select all

$is_the_admin = 0;
$is_the_admin = ($auth->acl_get('a_') && $user->data['user_id'] != ANONYMOUS) ? 1 &#58 0 ;
then checking admin just makes me check if $is_the_admin is 1 or 0...
_____________

I was asking if there were more elegant ways to do it?

Luciano
User avatar
{o}
Registered User
Posts: 90
Joined: Wed Mar 31, 2004 1:26 pm
Contact:

Re: 2 little olympus code questions..

Post by {o} »

What is inelegant in $user->data['user_id'] != ANONYMOUS :?:

About ADMIN. There is no "userlevel" in Olympus, because everything is permissions based. It means - you shouldn't check if someone is an admin but - if he is allowed to do certain thing.
Amorya
Registered User
Posts: 56
Joined: Mon May 26, 2003 3:15 pm

Re: 2 little olympus code questions..

Post by Amorya »

{o} wrote: What is inelegant in $user->data['user_id'] != ANONYMOUS :?:

About ADMIN. There is no "userlevel" in Olympus, because everything is permissions based. It means - you shouldn't check if someone is an admin but - if he is allowed to do certain thing.
Does that mean that you have to define all your things to support permissions? I.E. if I have "Add CMS article" as a thing someone can do, instead of checking for admin privs I would have to define Add CMS Article as a permission within PHPBB and set it in the admin panel?

If so, is that easy to do? (Don't tell me how - I'm not developing using 3.0 until beta. I just want to know if I'll have to rethink the strategy on this one.)

Amorya
Luciano
Registered User
Posts: 25
Joined: Wed Oct 17, 2001 6:33 am

Re: 2 little olympus code questions..

Post by Luciano »

same here..
for me its a photoalbum..
only the admin can switch it on or off...
and can set the moderators for the album..

the

Code: Select all

($auth->acl_get('a_') && $user->data['user_id'] != ANONYMOUS) 
gives the admin link at the bottom of a page..
so i'll stick that until someone comes out with something better..

as to the question:
What is inelegant in $user->data['user_id'] != ANONYMOUS ?

... well i used to go by the "safe" side..

example:

if($userdata['user_level] != anonymous && $userdata['session_logged_in'])


Luc
Roberdin
Registered User
Posts: 1546
Joined: Wed Apr 09, 2003 8:44 pm
Location: London, United Kingdom

Re: 2 little olympus code questions..

Post by Roberdin »

Which admin? What if I said to my friend, Bob, "Hey can you like after the forum for a few days? I'm going to allow you access to the ACP so that you can validate users for me but that's all."

Easily done, however, your MOD would then grant that guy full access to the gallery, despite the fact that he only has a couple of a_ permissions.


Now, you may rightly say that I should trust Bob with my photo albulm if I trust him with other areas of the ACP, but you are underminding the extensive permissions structure put in place. I would not the entire thing rendered essentially useless because you're using simplistic auth checks.
Rob
Luciano
Registered User
Posts: 25
Joined: Wed Oct 17, 2001 6:33 am

Re: 2 little olympus code questions..

Post by Luciano »

not quite...
there are moderators for the album..
but the admin.. in that case me.. the real admin, the site owner.. whatever you call him.. should have all permissions and override all others..
I saw an option i think it was: site-founder..
that guy should have all permissions in the album..

thats all.. (ok.. if you think its undermining)

Luc
Roberdin
Registered User
Posts: 1546
Joined: Wed Apr 09, 2003 8:44 pm
Location: London, United Kingdom

Re: 2 little olympus code questions..

Post by Roberdin »

Certainly, using the $user->is_founder check is preferable (that's the correct variable, right?), but it would be better if you added a few gallery options to the ACP, such as "Can delete photos" or whatever in the Users/Groups section, or even better, you could add 'Album' as a new type of Forum (like we have category, link, forum thus far) and then used a customised forum permissions screen. That would have the added advantage of allowing photo albulms (alba?) to be inside fora relating to them or whatever, but that's kind of wondering off the topic at hand...
Rob
Luciano
Registered User
Posts: 25
Joined: Wed Oct 17, 2001 6:33 am

Re: 2 little olympus code questions..

Post by Luciano »

we are getting off topic.. but i think it is still acceptable...

Well actually the permissions for the album are set in the control panel.. in an own album section that checks the groups..

As for the admin I still get an error when i set a user to founder.. (at least in the last snapshot i got) I am now using:

Code: Select all

$the_admin = 0;
$the_admin = ($auth->acl_get('a_') && $user->data['user_id'] != ANONYMOUS) ? 1 &#58 0 ;
and then i do:
$permissions = ($the_admin == 1) ? give permissions.... : do not give permissions ;

it is similar to the code that shows a user access to acp link...

I'm testing it right now at :
[Removed]
(feel free to test.. all functions are now active)

I know its not secure, as its not even a beta, but the worst that can happen is that 2 posts and 12 pics get deleted.. :mrgreen:

Luc
Last edited by Graham on Sat Feb 05, 2005 9:25 am, edited 1 time in total.
Reason: URI Removed
Graham
Registered User
Posts: 1304
Joined: Tue Mar 19, 2002 7:11 pm
Location: UK

Re: 2 little olympus code questions..

Post by Graham »

This really is getting a bit off topic here.

However, as the others have pointed out, there is no such thing as an "admin" in Olympus - since you can set permissions for each page of the ACP, so anyone who has access to a single page will have a_ set.

For what you want, you can either use the check of is the user the founder (if they are, they see all admin options whatever their permissions), or the preferable option would be to add new permissions settings to the system to use in your MOD. Examples of how to do this will be available at a later date.
"So Long, and Thanks for All the Fish"

Graham
Eeek, a blog!
Luciano
Registered User
Posts: 25
Joined: Wed Oct 17, 2001 6:33 am

Re: 2 little olympus code questions..

Post by Luciano »

i understand...
so I will go for founder.. to make it more compatible..
because i only want to be able to move, delete, and upload pics... without having to configure my name all the usergroups.. as I own the board. And I dont want all to know that I can delete, lock,.. move... pics.


thanx for the help!

Luc
Post Reply