Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: New Feature Request  (Read 4056 times)

0 Members and 1 Guest are viewing this topic.

Sw0rDz

  • Contributor
  • Coppermine newbie
  • ***
  • Offline Offline
  • Posts: 5
New Feature Request
« on: February 12, 2011, 12:46:42 am »

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 
Code: [Select]
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
Code: [Select]
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
Code: [Select]
   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
Code: [Select]
     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
Code: [Select]
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
Code: [Select]
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
Code: [Select]
     echo '              <option value="' , $album['aid'] , '"' , ($album['aid'] == $sel_album ? ' selected="selected"' : '') , '>' , $album['cat_title'] , '</option>' . $LINEBREAK;


REPLACE
Code: [Select]
   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;
   
    }
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15765
Re: New Feature Request
« Reply #1 on: February 12, 2011, 11:09:22 am »

Moving to feature requests board.
Logged
Pages: [1]   Go Up
 

Page created in 0.018 seconds with 21 queries.