coppermine-gallery.com/forum

Support => cpg1.5.x Support => cpg1.5 permissions => Topic started by: cherokee on February 18, 2014, 05:54:10 PM

Title: Show link to a specific group of users.
Post by: cherokee on February 18, 2014, 05:54:10 PM
Hello.
I need to create a link is only visible to a particular user group. How I can do?
thanks
regards
Cherokee
Title: Re: Show link to a specific group of users.
Post by: cherokee on February 21, 2014, 01:43:11 PM
Hello.
I think this is how I can show and hide the link.
How could display only a certain group of users?
thanks
regards

// Button "Download"
        if ($CONFIG['plugin_enlargeit_buttondownload'] == '1' || ($CONFIG['plugin_enlargeit_buttondownload'] == 2 && USER_ID)) {
    $meta  .= <<< EOT
        enl_buttonurl[{$loopCounter}] = 'index.php?file=enlargeit/download&pid=';
        enl_buttontxt[{$loopCounter}] = '{$lang_plugin_enlargeit['download_this_file']}';
        enl_buttonoff[{$loopCounter}] = -208;

EOT;
            $loopCounter++;
        }
Title: Re: Show link to a specific group of users.
Post by: Αndré on February 22, 2014, 01:04:01 PM
$USER_DATA['groups'] contains an array of all user group IDs the current user belongs to, so something like
if (in_array(4, $USER_DATA['groups']))
should work if you want to display your button to the group with the ID "4". Depending where you want to add that code, you maybe need to add
global $USER_DATA;
before the if statement. When in doubt, add it as it won't break anything.
Title: Re: Show link to a specific group of users.
Post by: cherokee on February 22, 2014, 03:39:54 PM
Thanks André
I am unable to make it work, I'll keep trying.
regards
Title: Re: Show link to a specific group of users.
Post by: cherokee on February 22, 2014, 06:52:19 PM
Sorry
I think it is
This is how I put it:
// Button "Download"
global $USER_DATA; if (in_array(108, $USER_DATA['groups'])) {
        if ($CONFIG['plugin_enlargeit_buttondownload'] == '1' || ($CONFIG['plugin_enlargeit_buttondownload'] == 2 && USER_ID)) {
    $meta  .= <<< EOT
        enl_buttonurl[{$loopCounter}] = 'index.php?file=enlargeit/download&pid=';
        enl_buttontxt[{$loopCounter}] = '{$lang_plugin_enlargeit['download_this_file']}';
        enl_buttonoff[{$loopCounter}] = -208;

EOT;
            $loopCounter++;
        }
}

Just a question what if I close the post were several groups of users?
Thank you very much
Title: Re: Show link to a specific group of users.
Post by: cherokee on February 22, 2014, 07:01:56 PM
Quote from: cherokee on February 22, 2014, 06:52:19 PM
Sorry
I think it is
This is how I put it:
// Button "Download"
global $USER_DATA; if (in_array(4, $USER_DATA['groups'])) {
        if ($CONFIG['plugin_enlargeit_buttondownload'] == '1' || ($CONFIG['plugin_enlargeit_buttondownload'] == 2 && USER_ID)) {
    $meta  .= <<< EOT
        enl_buttonurl[{$loopCounter}] = 'index.php?file=enlargeit/download&pid=';
        enl_buttontxt[{$loopCounter}] = '{$lang_plugin_enlargeit['download_this_file']}';
        enl_buttonoff[{$loopCounter}] = -208;

EOT;
            $loopCounter++;
        }
}

Just a question what if I close the post were several groups of users?
Thank you very much
Title: Re: Show link to a specific group of users.
Post by: Αndré on February 22, 2014, 07:57:16 PM
Use something like
if (in_array(array(4, 5, 6), $USER_DATA['groups']))
Title: Re: Show link to a specific group of users.
Post by: cherokee on February 22, 2014, 08:19:31 PM
Thank you very much