TinyPortal

Development => Support => Topic started by: Inny on April 29, 2009, 11:47:11 PM

Title: Article Category Permissions
Post by: Inny on April 29, 2009, 11:47:11 PM
Link to my site: http://www.epu-wow.com
SMF version: 1.1.8
TP version: 1.0.3 Beta 3
Theme name and version: Urban by Dzinerstudio
Mods installed:
1.     Pretty URLs Extras      0.9       [ Uninstall ]  [ List Files ]  [ Delete ]
2.    Move Old Topics    1.0    [ Uninstall ] [ List Files ] [ Delete ]
3.    Separate Sticky and Normal Topic    1.0    [ Uninstall ] [ List Files ] [ Delete ]
4.    Advanced Contact Form    1.1    [ Uninstall ] [ List Files ] [ Delete ]
5.    SMF Gallery Pro    1.4.5    [ Uninstall ] [ List Files ] [ Delete ]
6.    MCLegendII.2    3.0    [ Uninstall ] [ List Files ] [ Delete ]
7.    TinyPortal    1.075    [ Uninstall ] [ List Files ] [ Delete ]
8.    Regular smileys to dark background smiley set    1.0    [ Uninstall ] [ List Files ] [ Delete ]
9.    BBC Blizzard Quote Tag    1.0.3    [ Uninstall ] [ List Files ] [ Delete ]
10.    SMF 1.0.15 / 1.1.7 Update    1.0    [ List Files ] [ Delete ]
11.    SMF 1.0.14 / 1.1.6 Update    1.0    [ List Files ] [ Delete ]
12.    Aeva ~ Auto-Embed Video & Audio    5.2.56    [ List Files ] [ Delete ]
13.    Internal_Links_Use_Same_Window    1.2    [ Uninstall ] [ List Files ] [ Delete ]
14.    Googlebot & Spiders Mod    2.0.4    [ Uninstall ] [ List Files ] [ Delete ]
15.    [HTML] Permission Mod    1.01    [ Uninstall ] [ List Files ] [ Delete ]
16.    No Spam by Guests!    0.2    [ Uninstall ] [ List Files ] [ Delete ]
17.    Perfect Smiley Set    1.0    [ Uninstall ] [ List Files ] [ Delete ]
18.    TinyPortal    1.063    [ List Files ] [ Delete ]
19.    vBulletin Style Meta Tags    1.1    [ Uninstall ] [ List Files ] [ Delete ]
20.    Visual Verification Options    0.5.2    [ Uninstall ] [ List Files ] [ Delete ]
21.    RSS Feed Icon    1.1    [ Uninstall ] [ List Files ] [ Delete ]
22.    Aeva ~ Auto-Embed Video & Audio    6.2.75    [ Uninstall ] [ List Files ] [ Delete ]
23.    SMF 1.0.13 / 1.1.5 / 2.0 b3.1 Update    1.0    [ List Files ] [ Delete ]
24.    SMF 1.0.16 / 1.1.8 Update    1.0    [ Uninstall ] [ List Files ] [ Delete ]
25.    Regular smileys to dark background smiley set    1.0    [ Uninstall ] [ List Files ] [ Delete ]
26.    SMF Media Gallery    1.5.5    [ Uninstall ] [ List Files ] [ Delete ]
27.    User Control Panel By Alan S    2.0    [ Apply Mod ] [ List Files ] [ Delete ]
28.    Highslide Image Viewer    1.0    [ Uninstall ] [ List Files ] [ Delete ]
29.    Pretty URLs    0.9.1    [ Uninstall ] [ List Files ] [ Delete ]
30.    SMF Secure Login    1.0.4a    [ Uninstall ] [ List Files ] [ Delete ]
31.    Spoiler Tag    0.6    [ Uninstall ] [ List Files ] [ Delete ]
32.    reCAPTCHA for SMF    0.9.5.3    [ Uninstall ] [ List Files ] [ Delete ]
33.    AjaxChat Integration    3.0    [ Apply Mod ] [ List Files ] [ Delete ]
34.    Hide Info Center From Guests    1.0    [ Uninstall ] [ List Files ] [ Delete ]
Related Error messages: No error messages

Only topic i could find related to this is Here (http://www.tinyportal.net/index.php/topic,26271.0.html), but theres no feedback.

Might be because im not using the correct words for searching bugtracker and forums.

In any case issue is that Access Permissions in my categories won't work. In our frontpage theres a block called Raid Reports, category is named like that and it shouldn't be viewable to quests.

Excuse my ignorance if theres somewhere a solution or its being fixed in a later version of TP but i couldn't find something related to enlighten me.

P.S.: Some mods are just uploaded and no installed.
Title: Re: Article Category Permissions
Post by: Renegd98 on April 30, 2009, 01:40:13 AM
Permissions for categories and articles is different than the permissions for the blocks. You set the permissions for each block within that blocks editing area. I bet if you go look at that block on your frontpage that the permissions are not set correctly. Or you may find some users are in a secondary member group.
Title: Re: Article Category Permissions
Post by: ZarPrime on April 30, 2009, 02:34:07 AM
Inny,

To add to what Renegd98 has said, you can choose what membergroups (including Guests) will have access to blocks or article categories, but not individual articles.

I can't tell from what you wrote whether the problem is that guests can see a particular block or if the problem is that guests can see the articles in a particular category.

Can you explain?

ZarPrime
Title: Re: Article Category Permissions
Post by: Inny on April 30, 2009, 07:11:00 AM
Sorry it wasn't clear.

Guests can see the articles in specific category when its set to not.

The block on my frontpage is set to show to everyone just to avoid confusion, was just an example to see that the articles are accessible by you even if the category that they are in shouldn't be accessible by guests.
Title: Re: Article Category Permissions
Post by: bloc on April 30, 2009, 08:49:34 AM
Seems like a bug there, it should not show an article inside a block if the category says its off limits to that member. I'll look into this possible bug.
Title: Re: Article Category Permissions
Post by: Inny on April 30, 2009, 12:26:22 PM
Are you able to re-produce this bug?

What worries me might be some leftovers from Previous TP installations. Forum is 2 years old now :(
Title: Re: Article Category Permissions
Post by: andre on June 14, 2009, 07:00:48 PM
I have the same problem. The articles category 'videos' is set to not show to guests, yet it does.
http://www.xtremelean.us
in one of the left blocks there are links to videos. The videos are embedded in articles. The articles should not be viewable by guests, yet they are.

help?

Thanks!  :)
Title: Re: Article Category Permissions
Post by: G6Cad on June 14, 2009, 07:06:50 PM
The help will arrive as soon as Bloc have found a fix for the bug, you just have to wait until he does and have posted it. if it's not a small bug and if the bug require a lot of changes, you have to wait for the next release of tp where the fix will be applied.
Title: Re: Article Category Permissions
Post by: Inny on June 19, 2009, 09:34:38 AM
I havent seen the specific bug in bugtracker or i missed it somehow and it still persists in Beta 4.

:coolsmiley:
Title: Re: Article Category Permissions
Post by: andre on June 20, 2009, 12:35:10 AM
Quote from: Inny on June 19, 2009, 09:34:38 AM
I havent seen the specific bug in bugtracker or i missed it somehow and it still persists in Beta 4.

:coolsmiley:

Yes, I am using beta 4 as well
Title: Re: Article Category Permissions
Post by: G6Cad on June 20, 2009, 09:34:27 AM
If Bloc say it might be a bug and it's not in the bugtracker nor fixed, please post a bug report in the bugtracker and add in all the info you can, and also link to this topic .
Bloc might need a reminder of this  :)
Title: Re: Article Category Permissions
Post by: andre on June 23, 2009, 02:53:03 AM
Quote from: G6 on June 20, 2009, 09:34:27 AM
If Bloc say it might be a bug and it's not in the bugtracker nor fixed, please post a bug report in the bugtracker and add in all the info you can, and also link to this topic .
Bloc might need a reminder of this  :)
http://www.tinyportal.net/index.php?action=bugtracker;sa=bug524
Title: Re: Article Category Permissions
Post by: maldave on June 24, 2009, 08:19:33 AM
Damn this is a nice thread. I have the same problem as Inny has, that is no matter what "access" I give in the article category, member from all groups can still read the artice that I have made.

For example this I have made this article within a article catergory called DKP;

http://www.skyline-mmo.eu/index.php?page=3

If you check the DKP category I have chosen that only moderators and LS member should be able to read the artice yet even someone who is not logged in "aka guest" can read it.

I was thinking maybe there is a way around this until a bugfix is out. For the website that I use I have put a button called "DKP" that is hidden and will only show for certain membergroup. The code to do this in the index.template.php of my current theme is;

if (in_array(7, $GLOBALS['user_info']['groups']))
echo '<li><a' , $current_action=='epguide' ? ' class="current"' : '' , ' href="', $scripturl, '?page=3"><span>DKP</span></a></li>';


What this code does is that only the membergroup 7 is allowed to view this button.

So I was wondering if its possible to have something similar in a php artice, that way you restrict who can see the artice.

My second problem would be what I want inside the artice and my problem here is that its html;

<iframe id="myframe" src="eqdkp" marginheight="0" vspace="0" hspace="0" scrolling="no" width="100%" frameborder="0" height="1200">none</iframe>

So my final question here would be how to make a php artice to work with those 2 codes ?

PS: I use SMF 1.1.9 and TinyPortal v1.0 beta 4

Title: Re: Article Category Permissions
Post by: Zetan on June 24, 2009, 08:33:56 AM
When I view the page you posted as a Guest, maldave, I have this returned:

Quote from: http://www.skyline-mmo.eu/index.php?page=3

No news entries found.


Until a bugfix is made, we used to use something like:

Code (PHP) Select


global $context;
if ($context['user']['is_guest'])
{
echo '

This page is available to Members Only. ';
}

else
{
echo '

Members content Here';
}

Title: Re: Article Category Permissions
Post by: maldave on June 24, 2009, 08:44:44 AM
Quote from: Zetan on June 24, 2009, 08:33:56 AM
When I view the page you posted as a Guest, maldave, I have this returned:

Quote from: http://www.skyline-mmo.eu/index.php?page=3

No news entries found.


Until a bugfix is made, we used to use something like:

Code (PHP) Select


global $context;
if ($context['user']['is_guest'])
{
echo '

This page is available to Members Only. ';
}

else
{
echo '

Members content Here';
}



The response that you got shouldnt be there so yes, it's a bug. Im going to post this on the Bug section as well so that Bloc can have a look at it ;D

EDIT: I saw someone else already post a bug report about this ^^
Title: Re: Article Category Permissions
Post by: maldave on June 24, 2009, 08:46:34 AM
But did you have an answer to my question if its possible to add html code to a php article ?
Title: Re: Article Category Permissions
Post by: Zetan on June 24, 2009, 09:38:55 AM
Did you try it?


Code (PHP) Select


{
echo '
<iframe id="myframe" src="eqdkp" marginheight="0" vspace="0" hspace="0" scrolling="no" width="100%" frameborder="0" height="1200">none</iframe>';
}

Title: Re: Article Category Permissions
Post by: maldave on June 24, 2009, 01:26:28 PM
Quote from: Zetan on June 24, 2009, 09:38:55 AM
Did you try it?


Code (PHP) Select


{
echo '
<iframe id="myframe" src="eqdkp" marginheight="0" vspace="0" hspace="0" scrolling="no" width="100%" frameborder="0" height="1200">none</iframe>';
}



Ok I tried and it it worked wonders ;D You are the king Zetan. Here is the php code with the iframe code;

{
global $context;
if ($context['user']['is_guest'])
echo '
This page is available to Members Only. ';
}
{
global $context;
if (in_array(7, $GLOBALS['user_info']['groups']))
echo '
<iframe id="myframe" src="eqdkp" marginheight="0" vspace="0" hspace="0" scrolling="no" width="100%" frameborder="0" height="1200">none</iframe>';
}


As you can see this will only show for group 7, and if you are a guest that tries to look at the article you will only get "This page is available to Members Only".
My followup question here is if you want group 7 and group 9 to be able to access the artice. I did the following change to code and it worked, basically added another global $context;

{
global $context;
if ($context['user']['is_guest'])
echo '
This page is available to Members Only. ';
}
{
global $context;
if (in_array(7, $GLOBALS['user_info']['groups']))
echo '
<iframe id="myframe" src="eqdkp" marginheight="0" vspace="0" hspace="0" scrolling="no" width="100%" frameborder="0" height="1200">none</iframe>';
}
{
global $context;
if (in_array(9, $GLOBALS['user_info']['groups']))
echo '
<iframe id="myframe" src="eqdkp" marginheight="0" vspace="0" hspace="0" scrolling="no" width="100%" frameborder="0" height="1200">none</iframe>';
}


Even though this works I'm feeling the the code is to long and that you can somehow make it a lot shorter then I have done it. ^^
Title: Re: Article Category Permissions
Post by: Zetan on June 24, 2009, 02:04:57 PM
I've been called many things... &@Ã,£^ etc..


have you tried



if (in_array(7,9,10,11, $GLOBALS['user_info']['groups']))

Title: Re: Article Category Permissions
Post by: maldave on June 24, 2009, 02:18:03 PM
Quote from: Zetan on June 24, 2009, 02:04:57 PM
I've been called many things... &@Ã,£^ etc..


have you tried



if (in_array(7,9,10,11, $GLOBALS['user_info']['groups']))



Yes I tried that but then it wont show anything. If I have only 7 or only 9 then it works. If I try to input more then one group i.e. 7,9 then it wont show.
Title: Re: Article Category Permissions
Post by: Zetan on June 24, 2009, 02:31:38 PM
Ok, try


if (in_array('7,9,10', $GLOBALS['user_info']['groups']))
Title: Re: Article Category Permissions
Post by: maldave on June 24, 2009, 02:44:02 PM
Quote from: Zetan on June 24, 2009, 02:31:38 PM
Ok, try


if (in_array('7,9,10', $GLOBALS['user_info']['groups']))


I did and it didn't work either  :-\
Title: Re: Article Category Permissions
Post by: Zetan on June 24, 2009, 02:51:37 PM
Hmmm... I've probably got the placement wrong. It may need to "exclude" member groups.
I'm not the greatest code guru, I am one of the greatest Copy / Pasters, though. :P

Perhaps somebody else can help.
Title: Re: Article Category Permissions
Post by: IchBin on June 24, 2009, 04:02:00 PM
In your code you need to put the right variable in place. $GLOBALS is not a variable. It should look like this:

{
global $context;
if ($context['user']['is_guest'])
echo '
This page is available to Members Only. ';
}
{
global $context;
if (in_array(7, $context['user_info']['groups']))
echo '
<iframe id="myframe" src="eqdkp" marginheight="0" vspace="0" hspace="0" scrolling="no" width="100%" frameborder="0" height="1200">none</iframe>';
}
{
global $context;
if (in_array(9, $context['user_info']['groups']))
echo '
<iframe id="myframe" src="eqdkp" marginheight="0" vspace="0" hspace="0" scrolling="no" width="100%" frameborder="0" height="1200">none</iframe>';
}
Title: Re: Article Category Permissions
Post by: maldave on June 24, 2009, 04:18:52 PM
Quote from: IchBinâ„¢ on June 24, 2009, 04:02:00 PM
In your code you need to put the right variable in place. $GLOBALS is not a variable. It should look like this:

{
global $context;
if ($context['user']['is_guest'])
echo '
This page is available to Members Only. ';
}
{
global $context;
if (in_array(7, $context['user_info']['groups']))
echo '
<iframe id="myframe" src="eqdkp" marginheight="0" vspace="0" hspace="0" scrolling="no" width="100%" frameborder="0" height="1200">none</iframe>';
}
{
global $context;
if (in_array(9, $context['user_info']['groups']))
echo '
<iframe id="myframe" src="eqdkp" marginheight="0" vspace="0" hspace="0" scrolling="no" width="100%" frameborder="0" height="1200">none</iframe>';
}


IchBin, the change that you purposed didn't work for me. This is the code that you suggested;


if (in_array(7, $context['user_info']['groups']))


When I try to use that I get a blank screen and the page that I want to show in the iframe doesn't show. Since this didn't work I had to use the old one that looks like this;

if (in_array(7, $GLOBALS['user_info']['groups']))
Title: Re: Article Category Permissions
Post by: Freddy on June 24, 2009, 04:53:34 PM
I don't think (not sure) but $context['user_info']['groups'] may not exist.

I think you need to use $user_info, where $user_info['groups'] contains all the groups the member is in.

Try this :

global $user_info;

// List all your allowed member groups in this array here...
$allowedMemberGroups = array(7,9,10,11);

$valid = false;

foreach ($allowedMemberGroups as $needle)
{
if (in_array($needle, $user_info['groups']))
$valid = true;
}

if ($valid == false)
{
echo '
This page is available to certain members only. ';
}
elseif ($valid == true)
{
echo '
Here is my iFrame or whatever...';
}


I've only tested it a little, seems to work okay here.

BTW; $user_info is a much much smaller array than $GLOBALS, so whatever you do I would suggest using that instead - it may just save a little on processing.

Also worth noting that a member can be in more than one group - eg an admin could be group 1 but maybe also a newbie in group 4 of the post count group.  Probably won't make much difference to this idea though...
Title: Re: Article Category Permissions
Post by: maldave on June 24, 2009, 05:18:36 PM
Quote from: freddy888 on June 24, 2009, 04:53:34 PM
I don't think (not sure) but $context['user_info']['groups'] may not exist.

I think you need to use $user_info, where $user_info['groups'] contains all the groups the member is in.

Try this :

global $user_info;

// List all your allowed boards in this array here...
$allowedBoards = array(7,9,10,11);

$valid = false;

foreach ($allowedBoards as $needle)
{
if (in_array($needle, $user_info['groups']))
$valid = true;
}

if ($valid == false)
{
echo '
This page is available to certain members only. ';
}
elseif ($valid == true)
{
echo '
Here is my iFrame or whatever...';
}


I've only tested it a little, seems to work okay here.

BTW; $user_info is a much much smaller array than $GLOBALS, so whatever you do I would suggest using that instead - it may just save a little on processing.

Also worth noting that a member can be in more than one group - eg an admin could be group 1 but maybe also a newbie in group 4 of the post count group.  Probably won't make much difference to this idea though...

This is perfect ;D It works just wondeful and you can exactly put in what groups that should access it ;D Thank you for sharing this code   ;D ;D
Title: Re: Article Category Permissions
Post by: Freddy on June 24, 2009, 06:07:20 PM
You are welcome, glad it works :)
Title: Re: Article Category Permissions
Post by: Freddy on June 24, 2009, 08:24:47 PM
Just had another look at my code...

I should have used something like $allowedMemberGroups rather than $allowedBoards - I was getting mixed up with another bit of code I did for board access.  So change it to something more appropriate if you want.

I've edited the code I posted above a little, but it's still basically the same thing.  All I did was make the variable name appropriate.
Title: Re: Article Category Permissions
Post by: maldave on June 24, 2009, 08:40:12 PM
Quote from: freddy888 on June 24, 2009, 08:24:47 PM
Just had another look at my code...

I should have used something like $allowedMemberGroups rather than $allowedBoards - I was getting mixed up with another bit of code I did for board access.  So change it to something more appropriate if you want.

I've edited the code I posted above a little, but it's still basically the same thing.  All I did was make the variable name appropriate.

Ok I updated it ^^
Title: Re: Article Category Permissions
Post by: IchBin on June 24, 2009, 10:41:16 PM
I think its $context['user']['groups'] or something like that. I can't remember of the top of my head. print_r($context) will tell you. :) $user_info holds the same values as you found out. :) Glad you got it all working.