News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Hide links based on membergroups

Started by ~DS~, March 23, 2010, 08:38:53 PM

Previous topic - Next topic

~DS~

Quote from: Arantor on March 24, 2010, 12:10:41 PM
Can you use raw PHP?

If you're limited to basic HTML, there is NO way of doing it within the block itself.
Damn it, I knew it. I am using SP blocks for that. Otherwise I can do without block but it will look ugly even without the permission system.
Wait...there's custom php block. Will that work?
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Arantor

Yeah you can do it with a custom block.

So, again, what are the rules - what links must be shown to which groups? You've told me there are three links, some of which should be shown to some members. Tell me the rules of what links to show to what group(s), I'll write you the custom PHP for it.

~DS~

I am creating a "Resources" block simliar to the one used here.
http://thetwoworldsforum.com/index.php/board,76.0.html  (membergroup id 17)

http://thetwoworldsforum.com/index.php/board,75.0.html (membergroup id 16)

http://thetwoworldsforum.com/index.php/board,69.0.html (membergroup id 15)

Only membergroup of that id can see the link.
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Arantor

So board 76 can only be seen by admins and group 17 and so on? No doubling up of groups (e.g. board 75 and 69 by the same groups other than admin?)

~DS~

Quote from: Arantor on March 24, 2010, 01:00:20 PM
So board 76 can only be seen by admins and group 17 and so on? No doubling up of groups (e.g. board 75 and 69 by the same groups other than admin?)
Right, it can only be seen by admins and membergroups unless there is in need of a permission system to allow Global Moderator or other membergroups to view as well if that what you meant?
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Arantor

Well, without getting into the complexities, I need to know the ids of all the groups that you want to be able to see that link.

Reason being is the code then looks something like this:
global $user_info;
if (array_intersect($user_info['groups'], array(1, 17)))
  echo '<a href="http://thetwoworldsforum.com/index.php/board,76.0.html">Charter Board</a><br />';


That says that only groups 1 and 17 can see that link. (You don't need the global line for every link, just for the first one, then it's the same two lines repeated then edited.

~DS~

Quote from: Arantor on March 24, 2010, 01:14:20 PM
Well, without getting into the complexities, I need to know the ids of all the groups that you want to be able to see that link.

Reason being is the code then looks something like this:
global $user_info;
if (array_intersect($user_info['groups'], array(1, 17)))
  echo '<a href="http://thetwoworldsforum.com/index.php/board,76.0.html">Charter Board</a><br />';


That says that only groups 1 and 17 can see that link. (You don't need the global line for every link, just for the first one, then it's the same two lines repeated then edited.
Ok, id 24 and 25 can see the link as well considering they are Co-admin and Global Moderator.
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Arantor

global $user_info;
if (array_intersect($user_info['groups'], array(1, 17, 24, 25)))
  echo '<a href="http://thetwoworldsforum.com/index.php/board,76.0.html">Charter Board</a><br />';

~DS~

Quote from: Arantor on March 24, 2010, 01:21:55 PM
global $user_info;
if (array_intersect($user_info['groups'], array(1, 17, 24, 25)))
  echo '<a href="http://thetwoworldsforum.com/index.php/board,76.0.html">Charter Board</a><br />';

Yep, that worked.
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

~DS~

Quote from: Dismal Shadow on March 24, 2010, 01:35:09 PM
Quote from: Arantor on March 24, 2010, 01:21:55 PM
global $user_info;
if (array_intersect($user_info['groups'], array(1, 17, 24, 25)))
  echo '<a href="http://thetwoworldsforum.com/index.php/board,76.0.html">Charter Board</a><br />';

Yep, that worked.
Now to add another link with different ids among those line, how?
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Arantor

Duplicate the last two lines, change the numbers in the array() to the groups, change the link to the other board...

~DS~

Quote from: Arantor on March 24, 2010, 02:33:15 PM
Duplicate the last two lines, change the numbers in the array() to the groups, change the link to the other board...

It works but trying to add a | which brings a parse error, assuming it only works on html, no? Either does normal text.

Show unread: New | Replies | Charter | Beta 
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Arantor

Well that's because it's PHP, which doesn't recognise normal text.

So, are new and replies shown to everyone?

~DS~

Quote from: Arantor on March 24, 2010, 03:00:25 PM
So, are new and replies shown to everyone?
Ugh...no. The code is different too? At least it requires a membership linked to those ids which works well. But it's ugly...
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Arantor

Yes, it's different code, which is why I asked!

So, if you can tell me exactly what links should be there, in their entirety, who they are visible to, I'll write you the entire block complete with | dividers.

~DS~

Ok let's try again.

QuoteShow unread: New | Replies | Support | ASL Community | Charter | Helpdesk | Bug Tacker | Banlist
(Admin/GM view only)

QuoteShow unread: New | Replies | Support | ASL Community | Helpdesk
Thank you for joining the ASL community.
(ASL group)

QuoteShow unread: New | Replies | Support | Charter | Helpdesk | Bug Tacker
Thank you for donating.
(Charter group)

Charter Board, membergroup ID 16: http://thetwoworldsforum.com/index.php/board,75.0.html

ASL Community, membergroup ID 22: http://thetwoworldsforum.com/index.php/board,32.0.html


You know Arantor...when this is done, it should be a tutorial in tips and tricks.  :D
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Arantor

And can any other users see this block? Or are you guaranteed that no regular user will see the block at all?

What I'm getting at: is New / Replies *always* there?

~DS~

Quote from: Arantor on March 24, 2010, 04:37:00 PM
And can any other users see this block? Or are you guaranteed that no regular user will see the block at all?

What I'm getting at: is New / Replies *always* there?
Yes it's good idea too for many useful links without group id for guests and regular user. It's hard to say since it's alot of work but for now this is for based membergroups only.
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Arantor

And what are other links such as helpdesk/banlist/bug t[r]acker? (I'm guessing respectively, action=helpdesk (funny that :P), action=banlist and action=projects)

~DS~

Quote from: Arantor on March 24, 2010, 04:56:08 PM
And what are other links such as helpdesk/banlist/bug t[r]acker? (I'm guessing respectively, action=helpdesk (funny that :P), action=banlist and action=projects)
Ohh, sorry.
Ban list: action=admin;area=ban (Ugh...I believe this action doesn't work on depending on "Forum administration" permission)
Helpdesk: action=helpdesk
Bug Tracker: ?action=projects
"There is no god, and that's the simple truth. If every trace of any single religion were wiped out and nothing were passed on, it would never be created exactly that way again. There might be some other nonsense in its place, but not that exact nonsense. If all of science were wiped out, it would still be true and someone would find a way to figure it all out again."
~Penn Jillette – God, NO! – 2011

Advertisement: