coppermine-gallery.com/forum

Support => cpg1.6.x Support => cpg1.6 permissions => Topic started by: Fity on July 19, 2018, 06:28:54 AM

Title: Permissions for anycontent.php
Post by: Fity on July 19, 2018, 06:28:54 AM
I am trying to create an anycontent.php file that will display a different message depending on users groups.

This is the code that I am using.  With this code it always outputs the ELSE option.  I have tried several different conditions but nothing works.  CPG1.6 is bridged with VB4 and all users have a common secondary user group.

Quoteif (!GROUP_GROUP_SET == 119) {

starttable("100%", $lang_index_php['welcome']);

echo <<<EOT
    <tr>
        <td class="tableb">
            Welcome to the photo gallery.<br />
            Browse through and see what we have been up to lately.<br />
        </td>
    </tr>

EOT;

endtable();

//EOF

}
ELSE {

starttable("100%", $lang_index_php['welcome']);

echo <<<EOT
    <tr>
        <td class="tableb">
            Welcome to the photo gallery.<br />
            Please log in to view more images.<br />
        </td>
    </tr>

EOT;

endtable();

//EOF
}

When I change the first line from this

Quoteif (!GROUP_GROUP_SET == 119)

To this

Quoteif (!USER_ID)

It detects logged in users.
Title: Re: Permissions for anycontent.php
Post by: Fity on July 19, 2018, 06:48:47 AM
I just realised that typo on the first line.  :-[

Quoteif (!GROUP_GROUP_SET == 119) {

Is now

Quoteif (!USER_GROUP_SET == 119) {

and the problem remains.
Title: Re: Permissions for anycontent.php
Post by: ron4mac on July 19, 2018, 03:45:49 PM
USER_GROUP_SET is a comma separated text list. You'll have to do something like:

$ugs = explode(',', trim(USER_GROUP_SET, '()'));

if (in_array(119, $ugs)) {
....
Title: Re: Permissions for anycontent.php
Post by: Fity on July 20, 2018, 01:32:23 AM
Thanks ron4mac, that worked perfectly.  Your speedy help is appreciated.  :)
Title: Re: Permissions for anycontent.php
Post by: Fity on July 20, 2018, 07:17:04 AM
Now that I can have different front page welcome messages based on the user groups using the anycontent.php file, I would like to display different content also.

Example:
For non logged in / unregistered users I don't want to display random images, however for logged in users I do. Is this possible?
Title: Re: Permissions for anycontent.php
Post by: ron4mac on July 20, 2018, 02:57:22 PM
Quote from: Fity on July 20, 2018, 07:17:04 AM
Now that I can have different front page welcome messages based on the user groups using the anycontent.php file, I would like to display different content also.

You would need a plugin to accomplish that.

Core files could be modified to do that but doing so is definitely not recommended.
Title: Re: Permissions for anycontent.php
Post by: Fity on July 20, 2018, 02:59:20 PM
Thanks.  I might tackle a plug in one day.
Title: Re: Permissions for anycontent.php
Post by: ΑndrĂ© on August 16, 2018, 03:05:10 PM
I'd solve it this way. Disable the random images meta album in the config and add this to anycontent.php:
if (USER_ID) {
    display_thumbnails('random', 0, 1, 4, 1, false);
}

(maybe you need to adjust the numbers to your needs or use values from the $CONFIG array).
Title: Re: Permissions for anycontent.php
Post by: Fity on August 22, 2018, 01:09:21 AM
Thanks AndrĂ©, I will give that a try.  In the meantime i have written a menu that changes with the user group. Works ok.