forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Uploading => Topic started by: philipmatarese on September 11, 2006, 10:38:25 pm

Title: XP Publish - Nicer Select Boxes
Post by: philipmatarese 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.
Title: Re: XP Publish - Nicer Select Boxes
Post by: Joachim Müller on September 12, 2006, 08:29:51 am
All of my users are admins
Ouch! You mustn't do that, see Be Careful Giving Admin Rights to Others (http://forum.coppermine-gallery.net/index.php?topic=34643.0)
Title: Re: XP Publish - Nicer Select Boxes
Post by: philipmatarese on September 12, 2006, 12:38:49 pm
There are only 4 of us sharing the website.
Title: Re: XP Publish - Nicer Select Boxes
Post by: philipmatarese 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.