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: XP Publish - Nicer Select Boxes  (Read 10692 times)

0 Members and 1 Guest are viewing this topic.

philipmatarese

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • matarese.org - the pictures
XP Publish - Nicer Select Boxes
« on: September 11, 2006, 10:38:25 pm »

One of the screens in CPG 1.4.9 has a drop down for all albums that uses the OPTGROUP tag to seperate them into categories.  I've done the same thing in the XP Publishing screens.  All of my users are admins, so I don't know if the user part works.

All changes are to xp_publish.php.



First, the queries must return the categories and be sorted by them primarily.

Find this code (Admin):
Code: [Select]
        $public_albums = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category < " . FIRST_USER_CAT . " ORDER BY title");Change to this code:
Code: [Select]
        $public_albums = cpg_db_query("SELECT alb.aid, cat.name, alb.title FROM {$CONFIG['TABLE_ALBUMS']} alb INNER JOIN {$CONFIG['TABLE_CATEGORIES']} cat ON category = cid WHERE category < " . FIRST_USER_CAT . " ORDER BY cat.name, alb.title");
Find this code (User):
Code: [Select]
        $user_albums = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='" . (FIRST_USER_CAT + USER_ID) . "' ORDER BY title");Change to this code:
Code: [Select]
        $public_albums = cpg_db_query("SELECT alb.aid, cat.name, alb.title FROM {$CONFIG['TABLE_ALBUMS']} alb INNER JOIN {$CONFIG['TABLE_CATEGORIES']} cat ON category = cid WHERE category = " . (FIRST_USER_CAT + USER_ID) . " ORDER BY cat.name, alb.title");


Now, display the OPTGROUP tags for each category of albums.

Find this code:
Code: [Select]
    $html = "\n";
    foreach($user_albums_list as $album) {
        $html .= '                        <option value="' . $album['aid'] . '">* ' . $album['title'] . "</option>\n";
    }
    foreach($public_albums_list as $album) {
        $html .= '                        <option value="' . $album['aid'] . '">' . $album['title'] . "</option>\n";
    }
Change to this code:
Code: [Select]
    $html = "\n";
    $last_cat = "";
    foreach($user_albums_list as $album) {
        if ($last_cat != $album['name']) {
            $html .= '                        <optgroup label="' . $album['name'] . '">';
            $last_cat = $album['name'];
        }
        $html .= '                        <option value="' . $album['aid'] . '">* ' . $album['title'] . "</option>\n";
    }
    foreach($public_albums_list as $album) {
        if ($last_cat != $album['name']) {
            $html .= '                        <optgroup label="' . $album['name'] . '">';
            $last_cat = $album['name'];
        }
        $html .= '                        <option value="' . $album['aid'] . '">' . $album['title'] . "</option>\n";
    }

Enjoy.
« Last Edit: September 12, 2006, 05:49:10 pm by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47844
  • aka "GauGau"
    • gaugau.de
Re: XP Publish - Nicer Select Boxes
« Reply #1 on: September 12, 2006, 08:29:51 am »

Logged

philipmatarese

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • matarese.org - the pictures
Re: XP Publish - Nicer Select Boxes
« Reply #2 on: September 12, 2006, 12:38:49 pm »

There are only 4 of us sharing the website.
Logged

philipmatarese

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • matarese.org - the pictures
Re: XP Publish - Nicer Select Boxes
« Reply #3 on: September 12, 2006, 03:50:10 pm »

Ok.  I just read the link you posted (dumb me - reply first read post later) and it's a good point.  I guess I should figure out how to let them have the same functionality as users instead of admins.

Thanks for getting my attention.
Logged
Pages: [1]   Go Up
 

Page created in 0.023 seconds with 22 queries.