News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Adding and checking permissions

Started by Compuart, December 05, 2005, 11:33:58 AM

Previous topic - Next topic

Dannii

Use one permission: see_shouts.
If you want to test if someone can see the shouts use
if (allowedTo('see_shouts'))

if you want to test if they can't do it, use:
if (!allowedTo('see_shouts'))
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

hitsquaduk

wait it did work it was the ! i was missing...lol

Thank you very much this is really going to come in handy

i have some testing servers setup thats y i could not give you a url to go have a look once it works on the testing servers then i can do it on the main site...

once again thank you for your time on this im very very happy now :D..lol

befor i did

(!allowedTo('see_shouts'))

but im not useing see_shouts i dont think i set that up right anyway i have remove all the see_shouts permissions and im usering

if (!allowedTo('cantsee_shouts'))


Well i think it all works all do more testing but all looks ok from here]


once again thank you you guys are so very helpful

Dannii

The ! means not, or the opposite. If allowedTo() is true, then !allowedTo() will be false.

It's always best to use as few permissions as possible, and the way SMF is set up, permissions should be to allow something, not to deny something. If you want to deny something, you make a permission to allow it and then deny a group.

Anyways, glad it's working now.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

hitsquaduk

lol it looks all messed up i know so how would i make it to deny it then like your saying ??

i know you have spent anoth time on this already im sorry if you wantto get ion with other things you can..lol

but im all for learning new things:)


Jim R

Eldacar,

Here we are again.   :)

I have created my own Permissions:

View Post
and
View Topic

They work pretty well, but when a Guest tries to look where he is not allowed Guest sees language that says please login or register to see this area.  

When Subscribe (membergroup) tries to access similarly protect areas, it just says An Error Has Occurred.  Obviously I want Subscribe to get to the same area as Guest when reaching an area not permitted.

I'm currently using in display.php to determine which membergroups can see posts:

isAllowedTo('view_post');

And in MessageIndex.php I'm using to determine which membergroups can see topics:

isAllowedTo('view_topic');


I'm just trying to clean it up so all members in a group not allowed to see those levels are redirected or simply see a message telling them to login with a login boxes.

Help me!!!   :)

Dannii

"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Jim R

Quote from: eldacar on June 06, 2006, 11:49:07 PM
Please use the correct terminology! I still don't understand you.
http://docs.simplemachines.org/index.php?board=11.0

I am using the correct terminology.

The Forum has Boards.  Those Boards have Topics.  Those Topics have Posts. 

I have set up Permissions determining whether or not a User can:

View Posts
and
View Topics.


I just want to make sure when a User in a Membergroup isn't permitted to view a post or view a topic they get a prompt to Register and an opportunity to Login.


Dannii

But you can't view a topic without also viewing the posts, and vice versa.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Jim R

#28
Quote from: eldacar on June 07, 2006, 12:19:11 AM
But you can't view a topic without also viewing the posts, and vice versa.

Sure you can, afterall there is a different set of permissions for topics and posts.  Topics are what you see when you click on a Board.  Posts are what you see when you click on a Topic.

None of that is really the point.  Let's just deal with one of them for now to simplify things.  The point is I have set up a Permission, view_post. 

In display.php I have:

// The central part of the board - topic display.
function Display()
{
global $scripturl, $txt, $db_prefix, $modSettings, $context, $settings, $options, $sourcedir;
global $user_info, $ID_MEMBER, $board_info, $topic, $board, $attachments, $messages_request;

   

// Created my own Permission set to recognize View Post as a functional option in the Admin Permission panel.

isAllowedTo('view_post');


When my membergroup 'Subscribe' tries to access Posts in a Board where they are not permitted, they get An Error Has Occurred.  I would like for them to get to a Login page, which is what happens when my Guests have the same level of permissions.

That's all I need.

Dannii

You are viewing a topic when you open it and read the posts it contains. You are viewing a board when you open it up to see the list of topics, which is done by the MessageList template. You don't need the view_topic permission if it means viewing a board, because that is what the access control lists are for.

Well, if they're already logged in but can't do something, they get an error message, not a log in box.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Jim R

Quote from: eldacar on June 07, 2006, 01:38:02 AM
You are viewing a topic when you open it and read the posts it contains. You are viewing a board when you open it up to see the list of topics, which is done by the MessageList template. You don't need the view_topic permission if it means viewing a board, because that is what the access control lists are for.

Well, if they're already logged in but can't do something, they get an error message, not a log in box.

I don't want this at the Access Level because then those without that permission can't see the Board in list of Boards, and I don't put in code that I have to remember to change anytime I add a board.  I also want some boards hidden. 

With all due respect because I appreciate you're trying to help,you seem to getting bogged down in your terminology.  Let me start over.

There are Boards.
There are Topics.
There are Posts.

Access Level differentiates who can see a Board in the list of Boards.  (I'm not talking about that.)
There is nothing within the Permissions' section that differentiates who can view Topics within a Board.
There is nothing within the Permissions' section that differentiates who can view Posts within a Topic.

I have created these extra permissions.  They work.  They are restricting the access, for the most part, as I wish. 
I have the 'view_post' permission check in Display.php.
I have the 'view_topic' permission check in MessageIndex.php.


Can we please just focus on the 'view_post' part for the sake of simplicity?

I want a User when he gets to a place that Permission is restricting him from, viewing posts, to get a Login prompt.

Dannii

The code you posted before should do that, but obviously only guests will get a login prompt, because users are already logged in. They will instead get an error message.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Jim R

Quote from: eldacar on June 07, 2006, 08:19:28 AM
The code you posted before should do that, but obviously only guests will get a login prompt, because users are already logged in. They will instead get an error message.

I know that.  I'm trying to get around that.  When Users are logged in and try other things they aren't permitted to do they get a login prompt.

There has to be a way to prompt them to login.  Right?

I do appreciate your time.

Dannii

What will logging in accomplish? They are already logged in.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Jim R

Quote from: eldacar on June 07, 2006, 08:30:48 AM
What will logging in accomplish? They are already logged in.

A very good point.  Then I just need them to be pointed to a message saying they don't have permission to view this part of the forum, that they may need to 'subscribe' to see this part of the forum. 

Actually, I would tell them what subscription they would need to see that part of the forum.

I can't figure out how to change which message a User sees at that point.  I think I know where to add and/or change messages.

Dannii

so instead of isAllowedTo(), use an if statement.

if (!allowedTo(view_whatever))
{
     Display a message telling them to subscribe.
}
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Jim R

Quote from: eldacar on June 07, 2006, 08:40:11 AM
so instead of isAllowedTo(), use an if statement.

if (!allowedTo(view_whatever))
{
     Display a message telling them to subscribe.
}

Where?  Which file?

Thanks.

Dannii

well, wherever you use isAllowedTo, use that instead.
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Jim R

Here is what I have, but it didn't work.  I still just got the error note.


function Display()
{
global $scripturl, $txt, $db_prefix, $modSettings, $context, $settings, $options, $sourcedir;
global $user_info, $ID_MEMBER, $board_info, $topic, $board, $attachments, $messages_request;

   
if (!isAllowedTo('view_post'))
{
echo 'You do not have permission to read posts on this board.  You do not have the necessary subscription.'
;}



Dannii

"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Advertisement: