New Feature Request New Feature Request
 

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

Main Menu

New Feature Request

Started by Sw0rDz, February 12, 2011, 12:46:42 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Sw0rDz

I love using coppermine like the next guy, but there is one tiny nuisance.  When editing one or more pictures, you can't see the parent categories.  If you're dealing with multiple categories with same file names it can get fairly confusing.  If you don't wish to build this into the next version, feel free to move this to plugins and I'll edit the post.  I'll post the how-to below.  Thanks!!

File:  edit_one_pic.php

FIND 
function get_user_albums($user_id = 0)
{
    global $CONFIG, $USER_ALBUMS_ARRAY, $user_albums_list;

    if ($user_id) {
        $or = " OR category = " . (FIRST_USER_CAT + $user_id);
    } else {
        $or = '';
    }

    if (!isset($USER_ALBUMS_ARRAY[USER_ID])) {
        $user_albums = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category='".(FIRST_USER_CAT + USER_ID)."' $or ORDER BY title");

        if (mysql_num_rows($user_albums)) {
            $user_albums_list = cpg_db_fetch_rowset($user_albums);
        } else {
            $user_albums_list = array();
        }
        mysql_free_result($user_albums);
        $USER_ALBUMS_ARRAY[USER_ID] = $user_albums_list;
    } else {
        $user_albums_list = &$USER_ALBUMS_ARRAY[USER_ID];
    }
} // end



ADD AFTER

function get_parent($aid, $category=-1)
{
global $CONFIG;
$conn = mysql_connect("localhost", $CONFIG['dbuser'], $CONFIG['dbpass'])
    or die("Connection Failure to Database");

mysql_select_db($CONFIG['dbname'], $conn) or die ($CONFIG['dbname'] . " Database not

found. " . $CONFIG['dbuser']);

if($category < 0)
{
$table = $CONFIG['TABLE_PREFIX'] . "albums";
$sql = "SELECT `category` FROM " . $table . " WHERE `aid` = '" . intval($aid) .

"'";

$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);

get_parent($aid, $row['category']);
}
else
{
$table = $CONFIG['TABLE_PREFIX'] . "categories";
$sql = "SELECT * FROM   " . $table . " WHERE `cid` = '" . intval($category) .

"'";

$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);
if(intval($row['parent']) < 1)
{
//return $row['cid'];
echo $row['name'];
return;

}
else
{
get_parent($aid, $row['parent']);

}
}
}

//END



FIND

   foreach ($public_albums_list as $album) {
        echo '                <option value="' . $album['aid'] . '"'
            . ($album['aid'] == $sel_album ? ' selected="selected"' : '') . '>'
            . $album['cat_title'] . '</option>' . $LINEBREAK;
        $hidden_public .= ($hidden_public ? ',' : '') . $album['aid'];
    }


REPLACE

     foreach ($public_albums_list as $album) {
        echo '                <option value="' . $album['aid'] . '"'
            . ($album['aid'] == $sel_album ? ' selected="selected"' : '') . '>';
          echo get_parent($album['aid']);
echo " < " . $album['cat_title'] . '</option>' . $LINEBREAK;
        $hidden_public .= ($hidden_public ? ',' : '') . $album['aid'];
    }



File:  editpics.php


FIND

function form_input($text, $name, $max_length,$field_width = 100)
{
    global $CURRENT_PIC, $LINEBREAK, $row_style_class;

    $value = array_key_exists($name, $CURRENT_PIC) ? $CURRENT_PIC[$name] : '';

    $name .= $CURRENT_PIC['pid'];

    $text = sprintf($text, $CURRENT_PIC['pid']);

    if ($text == '') {
        echo '        <input type="hidden" name="'.$name.'" value="" />' . $LINEBREAK;
        return;
    }

    echo <<<EOT
        <tr>
            <td class="{$row_style_class}" style="white-space: nowrap;">
                $text
            </td>
            <td width="100%" class="{$row_style_class}" valign="top">
                <input type="text" style="width: {$field_width}%" name="$name" id="$name" maxlength="$max_length" value="$value" class="textinput" />
            </td>
        </tr>

EOT;
}



ADD AFTER

function get_parent($aid, $category=-1)
{
global $CONFIG;
$conn = mysql_connect("localhost", $CONFIG['dbuser'], $CONFIG['dbpass'])
    or die("Connection Failure to Database");

mysql_select_db($CONFIG['dbname'], $conn) or die ($CONFIG['dbname'] . " Database not found. " . $CONFIG

['dbuser']);

if($category < 0)
{
$table = $CONFIG['TABLE_PREFIX'] . "albums";
$sql = "SELECT `category` FROM " . $table . " WHERE `aid` = '" . intval($aid) . "'";

$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);

get_parent($aid, $row['category']);
}
else
{
$table = $CONFIG['TABLE_PREFIX'] . "categories";
$sql = "SELECT * FROM   " . $table . " WHERE `cid` = '" . intval($category) . "'";

$result = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_assoc($result);
if(intval($row['parent']) < 1)
{

echo $row['name'];
return;

}
else
{
get_parent($aid, $row['parent']);

}
}
}




FIND

     echo '              <option value="' , $album['aid'] , '"' , ($album['aid'] == $sel_album ? ' selected="selected"' : '') , '>' , $album['cat_title'] , '</option>' . $LINEBREAK;



REPLACE

   foreach ($public_albums_list as $album) {
   echo '              <option value="' , $album['aid'] , '"' , ($album['aid'] == $sel_album ? ' selected="selected"' :

'') , '>' , get_parent($album['aid'], -1) , " < " , $album['cat_title'] , '</option>' . $LINEBREAK;
   
    }

ΑndrĂ©

Moving to feature requests board.