Permissions for anycontent.php Permissions for anycontent.php
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Permissions for anycontent.php

Started by Fity, July 19, 2018, 06:28:54 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Fity

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.

Fity

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.

ron4mac

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)) {
....

Fity

Thanks ron4mac, that worked perfectly.  Your speedy help is appreciated.  :)

Fity

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?

ron4mac

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.

Fity

Thanks.  I might tackle a plug in one day.

Αndré

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).

Fity

Thanks André, I will give that a try.  In the meantime i have written a menu that changes with the user group. Works ok.