TinyPortal

Development => Support => Topic started by: tribalost on May 08, 2007, 12:47:47 PM

Title: How To Restrict Guest From Viewing Articles
Post by: tribalost on May 08, 2007, 12:47:47 PM
can anyone please help me with this...
i know its a php code or something but i dunno how to start and i've just started learning php so im cluless...

tnx in advance...
Title: Re: How To Restrict Guest From Viewing Articles
Post by: G6Cad on May 08, 2007, 01:02:17 PM
You really dont have to change any code, just remodle the articles a bit.

Create a new category, pick out the membergroups you want to allow to see that category.
That way you reastrict what articles to show for guests if you leave the Guest checkbox empty when they are placed in that category.
Title: Re: How To Restrict Guest From Viewing Articles
Post by: tribalost on May 08, 2007, 01:06:50 PM
tnx 4 the quick reply g6 but im not sure where to manage the article category permissions :(
Title: Re: How To Restrict Guest From Viewing Articles
Post by: tribalost on May 08, 2007, 01:18:34 PM
nvm i just found out if ($context['user']['is_guest'])
{
   echo
   '<h5>Access Denied</h5>
   We are sorry. You must be registred on the site in order to view this Tool.';
} else  {
code
}


but tnx for the help anyways g6 :)
Title: Re: How To Restrict Guest From Viewing Articles
Post by: Xeriar on May 23, 2007, 10:06:10 AM
Quote from: G6â„¢ on May 08, 2007, 01:02:17 PM
Create a new category, pick out the membergroups you want to allow to see that category.
That way you reastrict what articles to show for guests if you leave the Guest checkbox empty when they are placed in that category.

Umm, sorry for the bump but, how do I do this?  I don't see any place where I can restrict articles or article categories by membergroup.
Title: Re: How To Restrict Guest From Viewing Articles
Post by: Zetan on May 23, 2007, 11:30:17 AM
You can't currenty "restrict" access to articles with an option.
But as mentioned above, you can grant member groups permissions to view articles.

I have an article category that only one member group knows about, that category has a seperate menu block that has links to those articles. Only the member group with permissions can see it. No other group knows it's there.

Title: Re: How To Restrict Guest From Viewing Articles
Post by: IchBin on May 24, 2007, 12:17:45 AM
if you want a work around you can use some php code to do it.

if (!$context['user']['is_guest']){
echo 'all your stuff here';
}


This will only display the article if the user is not a guest.
Title: Re: How To Restrict Guest From Viewing Articles
Post by: JOSHSKORN on May 24, 2007, 08:26:27 AM
Quote from: Zetan on May 23, 2007, 11:30:17 AM
You can't currenty "restrict" access to articles with an option.
But as mentioned above, you can grant member groups permissions to view articles.

That's what I found, it's either all or nothing.  You can either view all articles, or you can't.

Quote from: Zetan on May 23, 2007, 11:30:17 AM
I have an article category that only one member group knows about, that category has a seperate menu block that has links to those articles. Only the member group with permissions can see it. No other group knows it's there.
I was thinking about doing this, myself.  My concern is that, someone COULD potentially find the link to the article and have access to it.

Quote from: IchBinâ„¢ on May 24, 2007, 12:17:45 AM
if you want a work around you can use some php code to do it.

if (!$context['user']['is_guest']){
echo 'all your stuff here';
}

This code sounds intriguing.  Two questions of it though.  Lets say my site was www.mysite.com, and I didn't want non clan members to view Article #16 under any circumstances, not by right-clicking and being able to view the source or anything.  Secondly, instead of testing just forum guests, but for all member groups (allowing viewing privileges) beginning with the string "CM" to view the article?  Security of my articles is a big deal to me (see my second comment in response to Zetan's comments), and I want to pretty much know that there's no way possible that someone from the outside can view something.

Can you provide me with code, using the exact link of
http://www.mysite.com/smf/index.php?page=16 ?  I'm not a PHP programmer.
Title: Re: How To Restrict Guest From Viewing Articles
Post by: IchBin on May 25, 2007, 03:19:26 AM
You're questions seem a bit vague. But if you don't want to show an article to anyone unless they're a member of your clan group then you can change this code to do it.
Change the number 3 to the number the corresponds to your group number in your forum.

global $user_info;
if ($user_info['groups'] == 3){
echo 'your code goes here';
}

Doing this type of thing will not print any of your article to the page.
Title: Re: How To Restrict Guest From Viewing Articles
Post by: Xeriar on May 26, 2007, 01:29:30 AM
Speaking of...  is there -any- security at all for the 'add php' option?  Can we even restrict it if we don't want to let members with article access use it?
Title: Re: How To Restrict Guest From Viewing Articles
Post by: IchBin on May 26, 2007, 04:30:55 AM
No you can't. Which is why theirs an approval system though.
Title: Re: How To Restrict Guest From Viewing Articles
Post by: JOSHSKORN on May 26, 2007, 08:00:53 AM
Quote from: IchBinâ„¢ on May 25, 2007, 03:19:26 AM
You're questions seem a bit vague. But if you don't want to show an article to anyone unless they're a member of your clan group then you can change this code to do it.
Change the number 3 to the number the corresponds to your group number in your forum.

global $user_info;
if ($user_info['groups'] == 3){
echo 'your code goes here';
}

Doing this type of thing will not print any of your article to the page.

OK I hope I'm clear enough as to what I want with this request...

echo 'your code goes here';

This line of code means absolutely nothing to me. I'm not a PHP expert, therefore cannot interpret what you're saying, here.

In your IF block of your suggested code, how to I pull this page (http://www.mysite.com/smf/index.php?page=16) if my test is true (that is, if the member is allowed to view the article)?  The article is created with the regular editor, not PHP.  Do I need to create the actual article IN PHP instead, thus not having an article # to link to?  Do I need to create a regular article, click the source button, copy the code and paste it into my php article inside the if block?

Once again, my concerns:
Hope this is clear enough.
Title: Re: How To Restrict Guest From Viewing Articles
Post by: Zetan on May 26, 2007, 09:53:31 AM
Most .php cannot be viewed from the source as it's pulling information from the server.
Which means that anyone viewing the source will see the php code.. but not the information displayed that is being pulled from the server.

Not all articles need to be php.. you can use regular html too.

echo 'your code goes here';

The rest of you're article code, script is inserted between the '  ' that IchBin posted.

The IF user is... cannot be linked to and viewed.. If User is guest... they will see a warning message.
Title: Re: How To Restrict Guest From Viewing Articles
Post by: Xeriar on May 27, 2007, 07:47:06 AM
Quote from: IchBinâ„¢ on May 26, 2007, 04:30:55 AM
No you can't. Which is why theirs an approval system though.

Ugh.  Hmm.

Is it possible to have a setup where users could make and edit their own little blog-sections, but not those of others?
Title: Re: How To Restrict Guest From Viewing Articles
Post by: IchBin on May 27, 2007, 07:57:58 PM
There's no user specific permission built into TP yet for articles.
Title: Re: How To Restrict Guest From Viewing Articles
Post by: Polymath on November 12, 2007, 02:51:35 AM

if (!$context['user']['is_guest']){
echo '
<h5>Access Denied</h5>
  We are sorry. You must be registred with us in order to view giveaways.';
} else  {
echo '
<style type="text/css">
#ga_block { width: 250px; background-color: #F2F2F2; padding: 6px; border: 1px solid Blah blah blah balah blah blah blah blah

';
}


ok. this don't work. I want it so say " Access Denied
  We are sorry. You must be registred with us in order to view giveaways. " when not registered and logged in. But all it does is say that all the time evem to me(admin)

Have I missed some thing? Please.

This works:

if (!$context['user']['is_guest']){
echo 'all your stuff here';
}


But there is no message at all, not even an error. I would like it to encourage registration.

Thanks
Title: Re: How To Restrict Guest From Viewing Articles
Post by: IchBin on November 12, 2007, 02:47:47 PM
Using the ! at the beginning is like saying, if the user is "not" a guest. Take the ! out, and it will check to see if the user "is" a guest. :)
Title: Re: How To Restrict Guest From Viewing Articles
Post by: Polymath on November 13, 2007, 05:11:09 AM
Thank you very much. That sorts out viewing articles the quick way.
Title: Re: How To Restrict Guest From Viewing Articles
Post by: MPDesignZ on January 01, 2008, 05:23:42 AM
Quote from: IchBinâ,,¢ on May 24, 2007, 12:17:45 AM
if you want a work around you can use some php code to do it.

if (!$context['user']['is_guest']){
echo 'all your stuff here';
}


This will only display the article if the user is not a guest.

Awesome! Thanks this worked for me. :D