Advanced search  

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Pages: [1]   Go Down

Author Topic: Permissions for anycontent.php  (Read 13421 times)

0 Members and 1 Guest are viewing this topic.

Fity

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Permissions for anycontent.php
« 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.

Quote
if (!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

Quote
if (!GROUP_GROUP_SET == 119)

To this

Quote
if (!USER_ID)


It detects logged in users.
Logged

Fity

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Permissions for anycontent.php
« Reply #1 on: July 19, 2018, 06:48:47 am »

I just realised that typo on the first line.  :-[

Quote
if (!GROUP_GROUP_SET == 119) {

Is now

Quote
if (!USER_GROUP_SET == 119) {

and the problem remains.
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Permissions for anycontent.php
« Reply #2 on: July 19, 2018, 03:45:49 pm »

USER_GROUP_SET is a comma separated text list. You'll have to do something like:

Code: [Select]
$ugs = explode(',', trim(USER_GROUP_SET, '()'));

if (in_array(119, $ugs)) {
....
Logged

Fity

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Permissions for anycontent.php
« Reply #3 on: July 20, 2018, 01:32:23 am »

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

Fity

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Permissions for anycontent.php
« Reply #4 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?
Logged

ron4mac

  • Administrator
  • Coppermine addict
  • *****
  • Country: us
  • Offline Offline
  • Posts: 2026
Re: Permissions for anycontent.php
« Reply #5 on: July 20, 2018, 02:57:22 pm »

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

Fity

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Permissions for anycontent.php
« Reply #6 on: July 20, 2018, 02:59:20 pm »

Thanks.  I might tackle a plug in one day.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Permissions for anycontent.php
« Reply #7 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:
Code: [Select]
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).
Logged

Fity

  • Coppermine novice
  • *
  • Offline Offline
  • Posts: 36
Re: Permissions for anycontent.php
« Reply #8 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.03 seconds with 20 queries.