Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

September 24, 2022, 04:53:05 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 193513
  • Total Topics: 21092
  • Online today: 38
  • Online ever: 3540
  • (September 02, 2022, 06:38:54 PM)
Users Online
Users: 0
Guests: 32
Total: 32

Author Topic: Need Block that provides link to Pre-defined Member group page  (Read 4643 times)

0 Members and 1 Guest are viewing this topic.

penfield

  • Guest
I'm looking for a block that would give a logged-on user the ability to click thru to a pre-defined page that is available only to a given Member group. If that user is a member of several Member groups, he could choose among links to each Group's page...I have created separate javascript blocks for each Member group and made them available only to such Member Group, and that is working perfectly; however, I am concerned that if I need to have 100 separate pages for 100 separate Member groups, there will not be enough real estate (blocks) available to accomodate. Thanks to anybody who can help!
« Last Edit: April 24, 2007, 12:04:26 PM by G6â„¢ »

JPDeni

  • Guest
Re: Need Block that provides link to Pre-defined Member group page
« Reply #1 on: August 26, 2006, 08:09:37 AM »
If I understand correctly, you can do something like
Code: [Select]
$perms = $GLOBALS['user_info']['groups'];

if (in_array('1',$perms))
{
  echo 'The stuff you want group 1 to see';
}
if (in_array('2',$perms))
{
  echo 'The stuff you want group 2 to see';
}

and so on. If you have stuff for more than one group you can use

Code: [Select]
if (in_array('1',$perms) || (in_array('2',$perms))
The || means "or". You can have several of them in a line, but if you get too many it can get confusing for you to edit.

Just be sure that you have matching braces -- { and } for each one that that you end every "echo" statement with a ;

Offline Jpg

  • Hero Member
  • *****
  • Posts: 591
Re: Need Block that provides link to Pre-defined Member group page
« Reply #2 on: August 26, 2006, 08:23:15 AM »
That could be helpful for a news page. Where you can set up different news for each group based on their ranking. Would be great for a roleplaying forum too.

akulion

  • Guest
Re: Need Block that provides link to Pre-defined Member group page
« Reply #3 on: August 26, 2006, 08:59:12 AM »
For Membergroup based Links

Code: [Select]

global $user_info;

    if ($user_info['is_guest']) echo '<a href="...Guest link target here...">Link Text</a>';
    elseif (in_array(#, $user_info['groups'])) echo '<a href="...Group# link target here...">Link Text</a>';
    else echo '<a href="...Default link target here...">Link Text</a>';


the code above modify following:
Replace the '#' in the 'in_array(#, $user_info['groups'])' with the number of the membergroup you want to supply with the particular link or content (you could actually have mulitple 'elseif' lines before the 'else' for default).

And put all the correct links in the 'a href="', of course.

Using the same Link Text, the link would appear the same to all, but clicking would take user to the appropriate place.

=======================================
For membergroup based content

alternatively u could also specify different content using the same code as follows:

Code: [Select]

global $user_info;

    if ($user_info['is_guest']) echo 'Your content goes here....';
    elseif (in_array(#, $user_info['groups'])) echo 'Your content goes here....';
    else echo 'Your content goes here....';


please note that for EACH member group that u add, IF you want them to have a special content then u have to add one more line for each group as such specifying the membergroup number

Code: [Select]
elseif (in_array(#, $user_info['groups'])) echo 'Your content goes here....';


Explanation of code

    if ($user_info['is_guest']) echo 'Your content goes here....';

This basically says that if the user is a guest display this

    elseif (in_array(#, $user_info['groups'])) echo 'Your content goes here....';

This says but if the member belongs to this membergroup then display this

    else echo 'Your content goes here....';

Other wise if the member is not a guest or belong to any of the specified membergroups then display this

jacortina

  • Guest
Re: Need Block that provides link to Pre-defined Member group page
« Reply #4 on: August 26, 2006, 09:01:37 AM »
For a block with "Link-per-group" (for all groups user is in), this might be easier to maintain (since you're only going to show the block to groups who have links anyway):

Code: [Select]
global $user_info, $boardurl, $db_prefix;

//  Assumes group pages ar somwhere under board directory ($boardurl)
//     $boardurl . page_url
//
$group_pages[] = array('group_num' => '4', 'page_url' => '/pagedir/pagea.html');
$group_pages[] = array('group_num' => '5', 'page_url' => '/pagedir/pageb.html');
$group_pages[] = array('group_num' => '6', 'page_url' => '/pagedir/pagec.html');
$group_pages[] = array('group_num' => '7', 'page_url' => '/pagedir/paged.html');
$group_pages[] = array('group_num' => '8', 'page_url' => '/pagedir/pagee.html');
$group_pages[] = array('group_num' => '9', 'page_url' => '/pagedir/pagef.html');
$group_pages[] = array('group_num' => '10', 'page_url' => '/pagedir/pageg.html');
$group_pages[] = array('group_num' => '11', 'page_url' => '/pagedir/pageh.html');
$group_pages[] = array('group_num' => '12', 'page_url' => '/pagedir/pagei.html');
$group_pages[] = array('group_num' => '13', 'page_url' => '/pagedir/pagej.html');
$group_pages[] = array('group_num' => '14', 'page_url' => '/pagedir/pagek.html');
$group_pages[] = array('group_num' => '15', 'page_url' => '/pagedir/pagel.html');
$group_pages[] = array('group_num' => '16', 'page_url' => '/pagedir/pagem.html');
$group_pages[] = array('group_num' => '17', 'page_url' => '/pagedir/pagen.html');

foreach ($group_pages as $group_page)
{
if ( in_array($group_page['group_num'], $user_info['groups']) )
{
$request = db_query("
SELECT groupName
FROM {$db_prefix}membergroups
WHERE ID_GROUP = " . $group_page['group_num'] . "
LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($request);
mysql_free_result($request);
echo '<a href="' . $boardurl . $group_page['page_url'] . '">' . $row['groupName'] . '</a><br \>';
}
}


penfield

  • Guest
Re: Need Block that provides link to Pre-defined Member group page
« Reply #5 on: August 26, 2006, 03:56:21 PM »
Thanks to everyone for great thoughts! I'd especially like to thank jacortina who generously helped outside the forum.

akulion

  • Guest
Re: Need Block that provides link to Pre-defined Member group page
« Reply #6 on: August 26, 2006, 04:02:39 PM »
yes Jacortina is cool

even the code i gave u is adapted from a code she gave me to a similar question i had long time ago about conditional links

penfield

  • Guest
"Link-per-Group" code question
« Reply #7 on: April 22, 2007, 03:01:48 PM »
Does anyone know how I could modify J.A.Cortina's "Link-per-Group" to open target url in an iframe? I need to mask the url of the link opened and am thinking that opening it in an iframe is the way to go..?..thanks!

jacortina

  • Guest
Re: Need Block that provides link to Pre-defined Member group page
« Reply #8 on: April 24, 2007, 08:23:25 AM »
I don't think an IFrame will really keep the URL info secret (right-clicking on it will allow the properties to be displayed), though it should keep it not obviously visible.

But you could try to put this in an article (yeah, that's all):
Code: [Select]
if( isset($_GET['link']) )
echo '<iframe id="myframe" src="', $_GET['link'], '" marginwidth="0" marginheight="0" style="width: 100%;height: 500px;" frameborder="0" scrolling="yes"></iframe>';

Then, based off code above (plus the tweaks we talked about via PM), change the code (well, make a new block with this version of code):
Code: [Select]
global $user_info, $boardurl, $db_prefix;

$use_iframe = true;

//  Assumes group pages are anywhere
//  Can use  $boardurl . page_url  for pages at/under the forum root
//
$group_pages[] = array('group_num' => '3',   'page_url' => $boardurl . '/filetransfer/xxxxxxxxxxxx/sftpapplet/index.html');
$group_pages[] = array('group_num' => '6',   'page_url' => $boardurl . '/pagedir/pagec.html');
$group_pages[] = array('group_num' => '7',   'page_url' => $boardurl . '/pagedir/paged.html');
$group_pages[] = array('group_num' => '8',   'page_url' => $boardurl . '/pagedir/pagee.html');
$group_pages[] = array('group_num' => '10',   'page_url' => $boardurl . '/filetransfer/xxxxxxxxxxxx/sftpapplet/index.html');
$group_pages[] = array('group_num' => '4',   'page_url' => $boardurl . '/pagedir/pageg.html');
$group_pages[] = array('group_num' => '11',   'page_url' => $boardurl . '/pagedir/pageh.html');
$group_pages[] = array('group_num' => '12',   'page_url' => $boardurl . '/pagedir/pagei.html');
$group_pages[] = array('group_num' => '13',   'page_url' => $boardurl . '/pagedir/pagej.html');
$group_pages[] = array('group_num' => '14',   'page_url' => $boardurl . '/pagedir/pagek.html');
$group_pages[] = array('group_num' => '15',   'page_url' => $boardurl . '/pagedir/pagel.html');
$group_pages[] = array('group_num' => '16',   'page_url' => $boardurl . '/pagedir/pagem.html');
$group_pages[] = array('group_num' => '17',   'page_url' => $boardurl . '/pagedir/pagen.html');

// $group_pages[] = array('group_num' => '99',   'page_url' => 'http://www.google.com');

foreach ($group_pages as $group_page)
{
   if ( in_array($group_page['group_num'], $user_info['groups']) )
   {
      $request = db_query("
         SELECT groupName
         FROM {$db_prefix}membergroups
         WHERE ID_GROUP = " . $group_page['group_num'] . "
         LIMIT 1", __FILE__, __LINE__);
      $row = mysql_fetch_assoc($request);
      mysql_free_result($request);
      if (!$use_iframe)
        echo '<a href="' , $group_page['page_url'] , '">' , $row['groupName'] , '</a><br \>';
      else
        echo '<a href="' , $boardurl, 'index.php?page=##;link=', $group_page['page_url'] , '">' , $row['groupName'] , '</a><br \>';
   }
}

Make sure to change the '##' in that last line to the number of the article you made above.

penfield

  • Guest
Re: Need Block that provides link to Pre-defined Member group page
« Reply #9 on: April 24, 2007, 12:03:05 PM »
Thanks! Works great! You're the best!...now if I can find a way to mask the urls... ;)
« Last Edit: April 24, 2007, 12:05:33 PM by penfield »