Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: Fixing cpg_show_private_album notice  (Read 5468 times)

0 Members and 1 Guest are viewing this topic.

flar

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
Fixing cpg_show_private_album notice
« on: April 28, 2006, 09:32:25 am »

I turned on debug and notices today to see what it might turn up and found a couple of niggly problems.  One of these is the notice:

Quote
/include/themes.inc.php
  • Notice line 88: Undefined variable: cpg_show_private_album

which a search turns up on many support messages in this forum and it turned out to be easy to fix.  First I noticed that it is used in the get_meta_album_set function which index.php calls before it sets the variable.  This was easy to fix by just moving the line in index.php:

Find this in index.php:
Code: [Select]
    if (isset($cat)) {
        get_meta_album_set($cat,$META_ALBUM_SET);
    } else {
        get_meta_album_set(0,$META_ALBUM_SET);
    }

    $cpg_show_private_album = ($CONFIG['allow_private_albums'])?($CONFIG['show_private']):(true);

    get_cat_list($breadcrumb, $cat_data, $statistics);
and change it to this:
Code: [Select]
    $cpg_show_private_album = ($CONFIG['allow_private_albums'])?($CONFIG['show_private']):(true);

    if (isset($cat)) {
        get_meta_album_set($cat,$META_ALBUM_SET);
    } else {
        get_meta_album_set(0,$META_ALBUM_SET);
    }

    get_cat_list($breadcrumb, $cat_data, $statistics);

While that is probably needed for proper function (I didn't actually test this as I don't use private albums), it didn't silence the notice.  To do that you need to add $cpg_show_private_album to the list of globals in get_meta_album_set.

Find this in include/functions.inc.php:
Code: [Select]
function get_meta_album_set($cat, &$meta_album_set)
{
    global $USER_DATA, $FORBIDDEN_SET_DATA, $CONFIG;
and change it to this:
Code: [Select]
function get_meta_album_set($cat, &$meta_album_set)
{
    global $USER_DATA, $FORBIDDEN_SET_DATA, $CONFIG, $cpg_show_private_album;

and the notice disappears.

Please note that I didn't test the proper operation of any of these changes on the use of private albums as I don't use them on my site, but they do fix the notice and they appear to be fairly straightforward and otherwise harmless code fixes from inspection alone so I hope they help someone.
« Last Edit: June 04, 2006, 11:26:38 pm by Paver »
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1608
  • Paul Van Rompay
Re: Fixing cpg_show_private_album notice
« Reply #1 on: May 18, 2006, 05:44:55 am »

Thanks for the bug report & fix.  It works just as you wrote.

Committed to stable & devel branches.
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1608
  • Paul Van Rompay
Re: Fixing cpg_show_private_album notice
« Reply #2 on: June 03, 2006, 04:04:06 am »

This fix will be effectively reversed due to a follow-on bug caused by it.

The new fix is to remove $cpg_show_private_album from the function get_meta_album_set() in functions.inc.php.

So, replace this line:
Code: [Select]
if (($cpg_show_private_album || $USER_DATA['can_see_all_albums']) && $cat == 0) {with this line:
Code: [Select]
if ($USER_DATA['can_see_all_albums'] && $cat == 0) {
Will be committed once fully tested.
Logged

Paver

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 1608
  • Paul Van Rompay
Re: Fixing cpg_show_private_album notice
« Reply #3 on: June 04, 2006, 11:27:04 pm »

New correct fix committed to stable & devel.
Logged
Pages: [1]   Go Up
 

Page created in 0.014 seconds with 21 queries.