forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Miscellaneous => Topic started by: pslawinski on November 13, 2005, 12:16:12 am

Title: Add More Custom Fields via Config
Post by: pslawinski on November 13, 2005, 12:16:12 am
I got tired of having to add more user fields by copying and pasting code each time I wanted to add another custom field.  So, I created this mod that allows you to add more Custom Fields through the Config page.  An extra field is added to the config page that allows you to select how many fields you want. You can have any number greater than 4, though you might have some problems if you try to add an unreasonable number.

Currently this works for 1.4 only, but with a little work it could easlily be adapted for previous versions.

So let's start from the beginning:

First step:
Add the user_field_num row to the config table in mySQL.
(Note: change <tablePrefix> to the prefix you use for your tables.)

Code: [Select]
INSERT INTO `<tablePrefix>_config` ( `name` , `value` ) VALUES ('user_field_num', '4');

Now for the code additions:


lang/english.php
I coded for english.php but you can easlily adapt this for any language by changing the values.

Find:
Code: [Select]
  'Custom fields for image description (leave blank if unused)',
  array('Field 1 name', 'user_field1_name', 0, 'f=index.htm&amp;as=admin_custom_image&amp;ae=admin_custom_image_end'), //cpg1.4
  array('Field 2 name', 'user_field2_name', 0),
  array('Field 3 name', 'user_field3_name', 0),
  array('Field 4 name', 'user_field4_name', 0),

  'Cookies settings',
  array('Cookie name', 'cookie_name', 0, 'f=index.htm&amp;as=admin_cookie_name&amp;ae=admin_cookie_name_end'), //cpg1.4
  array('Cookie path', 'cookie_path', 0, 'f=index.htm&amp;as=admin_cookie_path&amp;ae=admin_cookie_path_end'), //cpg1.4

  'Email settings  (usually nothing has to be changed here; leave all fields blank when not sure)', //cpg1.4
  array('SMTP Host (when left blank, sendmail will be used)', 'smtp_host', 0, 'f=index.htm&amp;as=admin_email&amp;ae=admin_email_end'), //cpg1.4
  array('SMTP Username', 'smtp_username', 0), //cpg1.4
  array('SMTP Password', 'smtp_password', 0), //cpg1.4

  'Logging and statistics', //cpg1.4
  array('Logging mode <a href="#notice3" class="clickable_option">***</a>', 'log_mode', 11, 'f=index.htm&amp;as=admin_logging_log_mode&amp;ae=admin_logging_log_mode_end'), //cpg1.4
  array('Log ecards', 'log_ecards', 1, 'f=index.htm&amp;as=admin_general_log_ecards&amp;ae=admin_general_log_ecards_end'), //cpg1.4
  array('Keep detailed vote statistics','vote_details',1, 'f=index.htm&amp;as=admin_logging_votedetails&amp;ae=admin_logging_votedetails_end'), //cpg1.4
  array('Keep detailed hit statistics','hit_details',1, 'f=index.htm&amp;as=admin_logging_hitdetails&amp;ae=admin_logging_hitdetails_end'), //cpg1.4

  'Maintenance settings', //cpg1.4
  array('Enable debug mode', 'debug_mode', 9, 'f=index.htm&amp;as=debug_mode&amp;ae=debug_mode_end'), //cpg1.4
  array('Display notices in debug mode', 'debug_notice', 1, 'f=index.htm&amp;as=admin_misc_debug_notices&amp;ae=admin_misc_debug_notices_end'), //cpg1.4
  array('Gallery is offline', 'offline', 1, 'f=index.htm&amp;as=admin_general_offline&amp;ae=admin_general_offline_end'), //cpg1.4
);


Replace With:
Code: [Select]
  'Number of custom Fields to display',
  array('Number of user fields', 'user_field_num', 0, 'f=index.htm&amp;as=admin_custom_image&amp;ae=admin_custom_image_end'),

  'Custom fields for image description (leave blank if unused)',
  array('Field 1 name', 'user_field1_name', 0, 'f=index.htm&amp;as=admin_custom_image&amp;ae=admin_custom_image_end'), //cpg1.4
  array('Field 2 name', 'user_field2_name', 0),
  array('Field 3 name', 'user_field3_name', 0),
  array('Field 4 name', 'user_field4_name', 0),
);

//let's start the count at 5 since 4 fields have already been declared
for($i = 5; $i <= $CONFIG['user_field_num']; $i++)
{
$lang_admin_data[] = array("Field " . $i . " name", "user_field" . $i . "_name", 0);
}

$lang_admin_data[] = 'Cookies settings';
$lang_admin_data[] = array('Cookie name', 'cookie_name', 0, 'f=index.htm&amp;as=admin_cookie_name&amp;ae=admin_cookie_name_end'); //cpg1.4
$lang_admin_data[] = array('Cookie path', 'cookie_path', 0, 'f=index.htm&amp;as=admin_cookie_path&amp;ae=admin_cookie_path_end'); //cpg1.4

$lang_admin_data[] = 'Email settings  (usually nothing has to be changed here; leave all fields blank when not sure)'; //cpg1.4
$lang_admin_data[] = array('SMTP Host (when left blank, sendmail will be used)', 'smtp_host', 0, 'f=index.htm&amp;as=admin_email&amp;ae=admin_email_end'); //cpg1.4
$lang_admin_data[] = array('SMTP Username', 'smtp_username', 0); //cpg1.4
$lang_admin_data[] = array('SMTP Password', 'smtp_password', 0); //cpg1.4

$lang_admin_data[] = 'Logging and statistics'; //cpg1.4
$lang_admin_data[] = array('Logging mode <a href="#notice3" class="clickable_option">***</a>', 'log_mode', 11, 'f=index.htm&amp;as=admin_logging_log_mode&amp;ae=admin_logging_log_mode_end'); //cpg1.4
$lang_admin_data[] = array('Log ecards', 'log_ecards', 1, 'f=index.htm&amp;as=admin_general_log_ecards&amp;ae=admin_general_log_ecards_end'); //cpg1.4
$lang_admin_data[] = array('Keep detailed vote statistics','vote_details',1, 'f=index.htm&amp;as=admin_logging_votedetails&amp;ae=admin_logging_votedetails_end'); //cpg1.4
$lang_admin_data[] = array('Keep detailed hit statistics','hit_details',1, 'f=index.htm&amp;as=admin_logging_hitdetails&amp;ae=admin_logging_hitdetails_end'); //cpg1.4

$lang_admin_data[] = 'Maintenance settings'; //cpg1.4
$lang_admin_data[] = array('Enable debug mode', 'debug_mode', 9, 'f=index.htm&amp;as=debug_mode&amp;ae=debug_mode_end'); //cpg1.4
$lang_admin_data[] = array('Display notices in debug mode', 'debug_notice', 1, 'f=index.htm&amp;as=admin_misc_debug_notices&amp;ae=admin_misc_debug_notices_end'); //cpg1.4
$lang_admin_data[] = array('Gallery is offline', 'offline', 1, 'f=index.htm&amp;as=admin_general_offline&amp;ae=admin_general_offline_end'); //cpg1.4


admin.php

Find:
Code: [Select]
if ($CONFIG[$element[1]] !== stripslashes($value))
Replace with:
Code: [Select]

//create field if it does not exist
if (!isset($CONFIG[$element[1]]))
{
cpg_db_query("INSERT INTO {$CONFIG['TABLE_CONFIG']} ( `name` , `value` ) VALUES ('{$element[1]}', '$value')");
$processAnyways = true;
}

if ($CONFIG[$element[1]] !== stripslashes($value) || isset($processAnyways))


include/search.inc.php

Find:
Code: [Select]
$allowed = array('title', 'caption', 'keywords', 'owner_name', 'filename', 'pic_raw_ip', 'pic_hrd_ip', 'user1', 'user2', 'user3', 'user4');

Replace with:
Code: [Select]
$allowed = array('title', 'caption', 'keywords', 'owner_name', 'filename', 'pic_raw_ip', 'pic_hrd_ip');
//add user fields to allowed array
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uI = "user" . $i;
$allowed[] = $uI;
}


xp_publish.php
I have not tested this code since I do not use this

Find:
Code: [Select]
$keywords = '';

Replace all the user vars with:
Code: [Select]
$userFields = array();

Find:
Code: [Select]
$result = add_picture($album, $filepath, $picture_name, $position, $title, $caption, $keywords, $user1, $user2, $user3, $user4, $category);

Replace with:
Code: [Select]
$result = add_picture($album, $filepath, $picture_name, $position, $title, $caption, $keywords, $userFields, $category);


upload.php

Find
Code: [Select]
        // We have incoming placement data. Let's capture it.

        $album = (int)$_POST['album'];
        $title = addslashes($_POST['title']);
        $caption = addslashes($_POST['caption']);
        $keywords = addslashes($_POST['keywords']);

Replace all the user vars with:
Code: [Select]
//add user fields to userFields array
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uI = "user" . $i;
$userFields[] = addslashes($HTTP_POST_VARS[$uI]);
}


Find:
Code: [Select]
$result = add_picture($album, $filepath, $picture_name, 0,$title, $caption, $keywords, $user1, $user2, $user3, $user4, $category, $raw_ip, $hdr_ip, $movie_wd, $movie_ht);

Replace With:
Code: [Select]
$result = add_picture($album, $filepath, $picture_name, 0,$title, $caption, $keywords, $userFields, $category, $raw_ip, $hdr_ip, $movie_wd, $movie_ht);

Find:
Code: [Select]
    array($CONFIG['user_field1_name'], 'user1', 0, 255, 1),
    array($CONFIG['user_field2_name'], 'user2', 0, 255, 1),
    array($CONFIG['user_field3_name'], 'user3', 0, 255, 1),
    array($CONFIG['user_field4_name'], 'user4', 0, 255, 1),
    );

Replace With:
Code: [Select]
    );

    // Check for user defined fields.
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uFN = "user_field". $i . "_name";
$uI = "user" . $i;
if(!empty($CONFIG[$uFN]))
{
$form_array[] = array($CONFIG[$uFN], $uI, 0, 255, 1);
}
}



image_processor.php

Find:
Code: [Select]
global $user1;
global $user2;
global $user3;
global $user4;

Replace with:
Code: [Select]
global $userFields;

Find:
Code: [Select]
print "<input type=\"hidden\" name=\"user1\" value=\"$user1\">";
print "<input type=\"hidden\" name=\"user2\" value=\"$user2\">";
print "<input type=\"hidden\" name=\"user3\" value=\"$user3\">";
print "<input type=\"hidden\" name=\"user4\" value=\"$user4\">";

Replace with:
Code: [Select]
//print user fields
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$userData = $userFields[$i-1];
print "<input type=\"hidden\" name=\"user$i\" value=\"$userData\">";
}

Find:
Code: [Select]
$user1 = $HTTP_POST_VARS['$user1'];
$user2 = $HTTP_POST_VARS['$user2'];
$user3 = $HTTP_POST_VARS['$user3'];
$user4 = $HTTP_POST_VARS['$user4'];

Replace With:
Code: [Select]
//set user fields
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uI = "user" . $i;
$userFields[] = $HTTP_POST_VARS['$uI'];
}


Find:
Code: [Select]
$user1 = $_POST['$user1'];
$user2 = $_POST['$user2'];
$user3 = $_POST['$user3'];
$user4 = $_POST['$user4'];

Replace With:
Code: [Select]
//set user fields
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uI = "user" . $i;
$userFields[] = $_POST['$uI'];
}


Find:
Code: [Select]
print "<input type=\"hidden\" name=\"user1\" value=\"$user1\">";
print "<input type=\"hidden\" name=\"user2\" value=\"$user2\">";
print "<input type=\"hidden\" name=\"user3\" value=\"$user3\">";
print "<input type=\"hidden\" name=\"user4\" value=\"$user4\">";

Replace with:
Code: [Select]
//print user fields
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$userData = $userFields[$i-1];
print "<input type=\"hidden\" name=\"user$i\" value=\"$userData\">";
}


editpics.php

Find:
Code: [Select]
$THUMB_ROWSPAN=5;
if ($CONFIG['user_field1_name'] != '') $THUMB_ROWSPAN++;
if ($CONFIG['user_field2_name'] != '') $THUMB_ROWSPAN++;
if ($CONFIG['user_field3_name'] != '') $THUMB_ROWSPAN++;
if ($CONFIG['user_field4_name'] != '') $THUMB_ROWSPAN++;

Replace With:
Code: [Select]
$THUMB_ROWSPAN=5;
//get rowspan value
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uFN = "user_field" . $i . "_name";
if ($CONFIG[$uFN] != '') $THUMB_ROWSPAN++;
}

Find:
Code: [Select]
$data = array(
        array($lang_editpics_php['pic_info'], '', 3),
        array($lang_editpics_php['album'], 'aid', 1),
        array($lang_editpics_php['title'], 'title', 0, 255),
        array($captionLabel, 'caption', 2, $CONFIG['max_img_desc_length']),
        array($lang_editpics_php['keywords'], 'keywords', 0, 255),
        array($CONFIG['user_field1_name'], 'user1', 0, 255),
        array($CONFIG['user_field2_name'], 'user2', 0, 255),
        array($CONFIG['user_field3_name'], 'user3', 0, 255),
        array($CONFIG['user_field4_name'], 'user4', 0, 255),
        array('', '', 4)
);

Replace With:
Code: [Select]
$data = array(
        array($lang_editpics_php['pic_info'], '', 3),
        array($lang_editpics_php['album'], 'aid', 1),
        array($lang_editpics_php['title'], 'title', 0, 255),
        array($captionLabel, 'caption', 2, $CONFIG['max_img_desc_length']),
        array($lang_editpics_php['keywords'], 'keywords', 0, 255),
);

//add user fields to data
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uFN = "user_field" . $i . "_name";
$uI = "user" . $i;
$data[] = array($CONFIG[$uFN], $uI, 0, 255);
}

$data[] = array('', '', 4);

Find:
Code: [Select]
                $user1       = get_post_var('user1', $pid);
                $user2       = get_post_var('user2', $pid);
                $user3       = get_post_var('user3', $pid);
                $user4       = get_post_var('user4', $pid);


Replace With:
Code: [Select]
//set userFields
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$userFields[] = get_post_var("user$i", $pid);
}


Find:
Code: [Select]
                $update .= ", user1 = '".addslashes($user1)."'";
                $update .= ", user2 = '".addslashes($user2)."'";
                $update .= ", user3 = '".addslashes($user3)."'";
                $update .= ", user4 = '".addslashes($user4)."'";


Replace With:
Code: [Select]
//add user fields to update
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$update .= ", user$i = '".addslashes($userFields[$i-1])."'";
}


editOnePic.php

Find:
Code: [Select]
$user1        = $_POST['user1'];
                $user2        = $_POST['user2'];
                $user3        = $_POST['user3'];
                $user4        = $_POST['user4'];

Replace With:
Code: [Select]
//add user fields to array
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$userFields[]=$_POST["user$i"];
}

Find:
Code: [Select]
$THUMB_ROWSPAN=6;
if ($CONFIG['user_field1_name'] != '') $THUMB_ROWSPAN++;
if ($CONFIG['user_field2_name'] != '') $THUMB_ROWSPAN++;
if ($CONFIG['user_field3_name'] != '') $THUMB_ROWSPAN++;
if ($CONFIG['user_field4_name'] != '') $THUMB_ROWSPAN++;

Replace With:
Code: [Select]
$THUMB_ROWSPAN=6;
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
if ($CONFIG["user_field$1_name"] != '') $THUMB_ROWSPAN++;
}

Find:
Code: [Select]
                $update .= ", user1 = '".addslashes($user1)."'";
                $update .= ", user2 = '".addslashes($user2)."'";
                $update .= ", user3 = '".addslashes($user3)."'";
                $update .= ", user4 = '".addslashes($user4)."'";


Replace With:
Code: [Select]
//add user fields to update
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$update .= ", user$i = '".addslashes($userFields[$i-1])."'";
}


Find:
Code: [Select]
if ($CONFIG['user_field1_name'] != ''){
echo <<<EOT
        <tr>
            <td class="tableb" style="white-space: nowrap;">
                {$CONFIG['user_field1_name']}
                </td>
                <td width="100%" class="tableb" valign="top">
                                <input type="text" style="width: 100%" name="user1" maxlength="255" value="{$CURRENT_PIC['user1']}" class="textinput" />
                        </td>
        </tr>
EOT;
}
if ($CONFIG['user_field2_name'] != ''){
echo <<<EOT
        <tr>
            <td class="tableb" style="white-space: nowrap;">
                {$CONFIG['user_field2_name']}
                </td>
                <td width="100%" class="tableb" valign="top">
                <input type="text" style="width: 100%" name="user2" maxlength="255" value="{$CURRENT_PIC['user2']}" class="textinput" />
                        </td>
        </tr>
EOT;
}if ($CONFIG['user_field3_name'] != ''){
echo <<<EOT
        <tr>
            <td class="tableb" style="white-space: nowrap;">
                {$CONFIG['user_field3_name']}
                </td>
                <td width="100%" class="tableb" valign="top">
                <input type="text" style="width: 100%" name="user3" maxlength="255" value="{$CURRENT_PIC['user3']}" class="textinput" />
                        </td>
        </tr>
EOT;
}if ($CONFIG['user_field4_name'] != ''){
echo <<<EOT
        <tr>
            <td class="tableb" style="white-space: nowrap;">
                {$CONFIG['user_field4_name']}
                </td>
                <td width="100%" class="tableb" valign="top">
                <input type="text" style="width: 100%" name="user4" maxlength="255" value="{$CURRENT_PIC['user4']}" class="textinput" />
                        </td>
        </tr>
EOT;
}

Replace With:
Code: [Select]
//print out form fields
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uFN = "user_field" . $i . "_name";
$uI = "user" . $i;
if ($CONFIG[$uFN] != ''){
echo <<<EOT
        <tr>
            <td class="tableb" style="white-space: nowrap;">
                {$CONFIG[$uFN]}
                </td>
                <td width="100%" class="tableb" valign="top">
                                <input type="text" style="width: 97%" name="$uI" maxlength="255" value="{$CURRENT_PIC[$uI]}" class="textinput" />
                        </td>
        </tr>
EOT;
}
}

Title: Re: Add More Custom Fields via Config
Post by: pslawinski on November 13, 2005, 12:16:54 am
db_input.php

Find:
Code: [Select]
        $user1 = addslashes($_POST['user1']);
        $user2 = addslashes($_POST['user2']);
        $user3 = addslashes($_POST['user3']);
        $user4 = addslashes($_POST['user4']);


Replace With;
Code: [Select]
//add user fields to array
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uI = "user" . $i;
$userFields[]=addslashes($HTTP_POST_VARS[$uI]);
}


Find:
Code: [Select]
$result = add_picture($album, $filepath, $picture_name, 0, $title, $caption, $keywords, $user1, $user2, $user3, $user4, $category, $raw_ip, $hdr_ip,(int) $_POST['width'],(int) $_POST['height']);

Replace With:
Code: [Select]
$result = add_picture($album, $filepath, $picture_name, 0, $title, $caption, $keywords, $userFields, $category, $raw_ip, $hdr_ip,(int) $_POST['width'],(int) $_POST['height']);


include/picmgmt.inc.php

Find:
Code: [Select]
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '')

Replace With:
Code: [Select]
function add_picture($aid, $filepath, $filename, $position = 0, $title = '', $caption = '', $keywords = '', $userFields = array(), $category = 0, $raw_ip = '', $hdr_ip = '')

Find:
Code: [Select]
    $CURRENT_PIC_DATA['user1'] = $user1;
    $CURRENT_PIC_DATA['user2'] = $user2;
    $CURRENT_PIC_DATA['user3'] = $user3;
    $CURRENT_PIC_DATA['user4'] = $user4;
    $CURRENT_PIC_DATA['pic_raw_ip'] = $raw_ip;
    $CURRENT_PIC_DATA['pic_hdr_ip'] = $hdr_ip;
    $CURRENT_PIC_DATA['position'] = $position;
    $CURRENT_PIC_DATA = CPGPluginAPI::filter('add_file_data',$CURRENT_PIC_DATA);

    $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip, position) VALUES ('', '{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', '{$CURRENT_PIC_DATA['user1']}', '{$CURRENT_PIC_DATA['user2']}', '{$CURRENT_PIC_DATA['user3']}', '{$CURRENT_PIC_DATA['user4']}', '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";

Replace With:
Code: [Select]
    for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$CURRENT_PIC_DATA["user$i"] = $userFields[$i-1];
}
    $CURRENT_PIC_DATA['pic_raw_ip'] = $raw_ip;
    $CURRENT_PIC_DATA['pic_hdr_ip'] = $hdr_ip;
    $CURRENT_PIC_DATA['position'] = $position;
    $CURRENT_PIC_DATA = CPGPluginAPI::filter('add_file_data',$CURRENT_PIC_DATA);

//Create query string
$rowNames = '';
$rowData = '';
    for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$rowNames .= "user$i, ";
$rowData .= "'" . $userFields[$i-1] . "', ";
}

    $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, $rowNames pic_raw_ip, pic_hdr_ip, position) VALUES ('', '{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', $rowData '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";


displayimage.php

Find:
Code: [Select]
    for ($i = 1; $i <= 4; $i++) {
        if ($CONFIG['user_field' . $i . '_name']) {
            if ($CURRENT_PIC_DATA['user' . $i] != "") {
                $info[$CONFIG['user_field' . $i . '_name']] = make_clickable($CURRENT_PIC_DATA['user' . $i]);
            }
        }
    }


Replace With:
Code: [Select]
    for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
        if ($CONFIG['user_field' . $i . '_name'])
{
            if ($CURRENT_PIC_DATA['user' . $i] != "")
    {
                $info[$CONFIG['user_field' . $i . '_name']] = make_clickable($CURRENT_PIC_DATA['user' . $i]);
            }
        }
    }



After editing all files upload them to your server and enjoy being able to add custom fields from the config page.

I've added a grab from my admin menu showing the fields.
Title: Re: Add More Custom Fields via Config
Post by: rrhode on January 27, 2006, 04:04:32 am
I like the looks of this mod, and got it nearly working.  But it is telling me a database error when I try to save a picture.

Critical error
There was an error while processing a database query

I am not sure which file it is, possible the database one.  db_input.php on account it is a database query.  But maybe it is the picmgmt.inc.php file even.  I am not sure.  Maybe it is the image_processor.php or admin.php.  I susplect one of these 4 files but I am not sure which it could be.  Is there any way to fix this?  I copied everything alright but still get this error.

Thanks!  This is an awesome mod and I got to to work in the config and show the fields and everything.  Its really cool.  Thank you for your marvelous work!

Ryan
Title: Re: Add More Custom Fields via Config
Post by: rrhode on January 27, 2006, 04:40:06 am
I feel like this is a bit odd.

Code: [Select]
//Create query string
$rowNames = '';
$rowData = '';
    for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$rowNames .= "user$i, ";
$rowData .= "'" . $userFields[$i-1] . "', ";
}

    $query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, [b]$rowNames[/b] pic_raw_ip, pic_hdr_ip, position) VALUES ('', '{$CURRENT_PIC_DATA['aid']}', '" . addslashes($CURRENT_PIC_DATA['filepath']) . "', '" . addslashes($CURRENT_PIC_DATA['filename']) . "', '{$CURRENT_PIC_DATA['filesize']}', '{$CURRENT_PIC_DATA['total_filesize']}', '{$CURRENT_PIC_DATA['pwidth']}', '{$CURRENT_PIC_DATA['pheight']}', '" . time() . "', '{$CURRENT_PIC_DATA['owner_id']}', '{$CURRENT_PIC_DATA['owner_name']}','{$CURRENT_PIC_DATA['title']}', '{$CURRENT_PIC_DATA['caption']}', '{$CURRENT_PIC_DATA['keywords']}', '{$CURRENT_PIC_DATA['approved']}', [b]$rowData[/b] '{$CURRENT_PIC_DATA['pic_raw_ip']}', '{$CURRENT_PIC_DATA['pic_hdr_ip']}', '{$CURRENT_PIC_DATA['position']}')";

The way it uses the $rowNames and $rowdata just doesnt seem right to me but I cant figure out what to do with it.  Any ideas?
Title: Re: Add More Custom Fields via Config
Post by: Tranz on January 27, 2006, 05:02:49 am
Go to Config and enable debug mode. Then go back to the page and you should get a more detailed error message.
Title: Re: Add More Custom Fields via Config
Post by: rrhode on January 27, 2006, 11:33:16 pm
Thanks!  That did the trick.  I never even realized there was a debug mode I should use.  Very nice!

Ok, well the message it is saying is mySQL error: Unknown column 'user5' in 'field list'

Which means I have to create those extra fields in the database which is fine.  I thought I saw some code that did that though but maybe I am wrong.  It is the only problem and I can easily create those columns in the database.

Thanks again!

Ryan
Title: Re: Add More Custom Fields via Config
Post by: rrhode on January 27, 2006, 11:41:31 pm
oh and maybe it has something to do with the google maps thing I am using too but I dont think it is.  I think it fails to create the extra user fields thats all.

I will send you the debug info so you can see it.

This appears at the error box.

While executing query "UPDATE cpg142_pictures SET aid = '6', title = 'test', caption = 'test', keywords = 'test', user1 = '', user2 = '', user3 = '', user4 = '', user5 = '', user6 = '', user7 = '', user8 = '', user9 = '', user10 = '', latitude = '33.74832232784014', longitude = '-84.39216613769531' WHERE pid='5' LIMIT 1" on 0

mySQL error: Unknown column 'user5' in 'field list'


This is the debug info.

USER:
------------------
Array
(
    [ID] => 25279aea3d53206717f5cbe9960ee4fb
    [am] => 1
    [lang] => english
    [liv] => Array
        (
            [user_id] => 1
    [user_name] => admin
    [groups] => Array
        (
           
        )

    [disk_max] => 0
    [disk_min] => 0
    [can_rate_pictures] => 0
    [can_send_ecards] => 1
    [ufc_max] => 3
    [ufc_min] => 3
    [custom_user_upload] => 0
    [num_file_upload] => 5
    [num_URI_upload] => 3
    [can_post_comments] => 0
    [can_upload_pictures] => 0
    [can_create_albums] => 1
    [has_admin_access] => 1
    [pub_upl_need_approval] => 0
    [priv_upl_need_approval] => 0
    [group_name] => Administrators
    [upload_form_config] => 3
    [group_quota] => 0
    [can_see_all_albums] => 1
    [group_id] => 1
)

==========================
Queries:
------------------
Array
(
    [id] => 5
    [aid] => 6
    [title] => test
    [filename] => 8sheet.jpg
    [caption] => test
    [keywords] => test
    [user1] => test
    [user2] => test
    [user3] => test
    [user4] => test
    [user5] =>
    [user6] =>
    [user7] =>
    [user8] =>
    [user9] =>
    [user10] =>
    [coordinates] => 33.74832232784014,-84.39216613769531
    [submitDescription] => Apply modifications
)

==========================
VERSION INFO :
------------------
PHP version: 4.3.11 - OK
------------------
mySQL version: 4.0.24-max-log
------------------
Coppermine version: 1.4.3(stable)
==========================
Module: GD
------------------
GD Version: bundled (2.0.28 compatible)
FreeType Support: 1
FreeType Linkage: with freetype
T1Lib Support:
GIF Read Support: 1
GIF Create Support: 1
JPG Support: 1
PNG Support: 1
WBMP Support: 1
XBM Support: 1
JIS-mapped Japanese Font Support:

==========================
Module: mysql
------------------
MySQL Supportenabled
Active Persistent Links 0
Active Links 1
Client API version 3.23.49
MYSQL_MODULE_TYPE builtin
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_INCLUDE no value
MYSQL_LIBS no value
==========================
Module: zlib
------------------
ZLib Support enabled
Compiled Version 1.1.4
Linked Version 1.1.4
==========================
Server restrictions (safe mode)?
------------------
Directive | Local Value | Master Value
safe_mode | Off | Off
safe_mode_exec_dir | no value | no value
safe_mode_gid | Off | Off
safe_mode_include_dir | ~ | ~
safe_mode_exec_dir | no value | no value
sql.safe_mode | Off | Off
disable_functions | no value | no value
file_uploads | On | On
include_path | .:/usr/local/lib/php | .:/usr/local/lib/php
open_basedir | no value | no value
==========================
email
------------------
Directive | Local Value | Master Value
sendmail_from | me@localhost.com | me@localhost.com
sendmail_path | /usr/sbin/sendmail -t -i  | /usr/sbin/sendmail -t -i
SMTP | relay-hosting.secureserver.net | relay-hosting.secureserver.net
smtp_port | 25 | 25
==========================
Size and Time
------------------
Directive | Local Value | Master Value
max_execution_time | 30 | 30
max_input_time | 60 | 60
upload_max_filesize | 8M | 8M
post_max_size | 8M | 8M
==========================
Page generated in 0.097 seconds - 17 queries in 0.018 seconds - Album set : ; Meta set: ;
Title: Re: Add More Custom Fields via Config
Post by: rrhode on January 28, 2006, 12:05:03 am
Hmmm, interesting.  Now it saves nothing to the user fields.  blank.

So maybe my theory that the $rowname and $rowuser was right because they dont appear to be sending the info through.  Or maybe there is something before that even that isnt working right.   ???

I dont know but I will have to soon find out, but first, some really awesome veggie lasagna.  My girlfriend makes the best lasagna in the world I think and I am not going to think clearly until I eat some.
Title: Re: Add More Custom Fields via Config
Post by: rrhode on January 30, 2006, 09:52:05 pm
Does anyone have any idea from what i have posted here why it isnt saving the user fields?  Thanks :D
Title: Re: Add More Custom Fields via Config
Post by: Ian MacMillan on February 08, 2006, 07:13:36 pm
Same issues here, nothing saving and having to manually add the fields in the db.
Title: Re: Add More Custom Fields via Config
Post by: pslawinski on February 08, 2006, 09:03:59 pm
Okay, I think I see the problem here.  It appears that the extra user info fields in the pictures table are missing.  I'll look over the code and try this again later today.  For now I suggest that you manually add the extra cols to your pictures table e.g. user5, user6...
Title: Re: Add More Custom Fields via Config
Post by: fredt on April 19, 2006, 09:09:14 am
Where did this get to?
I love the mod - it became the tipping point for selecting Coppermine.

I added 16 fields - all came up in the config files.  Uploaded some images using Batch upload. The first image accepted my data in each fieled - and every image after that repeated the same data as contained in the first image.   Checked the datatbase - all 20 user fields are there.

Then went to edit the data for each image - nothing changed.  Checked with debug running.  Debug does not report anything - in fact it appears that nothing happened at all.
Any thoughts?
Fred
Title: Re: Add More Custom Fields via Config
Post by: pslawinski on April 19, 2006, 06:26:31 pm
Perhaps what this mod really needs is a rewrite.  I coded the mod for my coppermine install specifically and then rewrote it to work on the regular version.  It appears that the error is occuring with the code that automatically adds the necessary fields to the DB.  I can look into this later this week perhaps, unless someone beats me to it.

@Fred  It sounds as if the data is not being written to your database, however, I can't be sure.
Title: Re: Add More Custom Fields via Config
Post by: flar on April 24, 2006, 03:15:11 pm
One contribution to make this change (slightly) smaller in scope.  The first mod to lang/english.php to add the new form fields to $lang_admin_data can be made less invasive using the array_push() function as follows (with 1 unmodified line at top and bottom for context):
Code: [Select]
  array('Field 4 name', 'user_field4_name', 0),
);

//let's start the count at 5 since 4 fields have already been declared
for($i = 5; $i <= $CONFIG['user_field_num']; $i++)
{
       $lang_admin_data[] = array("Field " . $i . " name", "user_field" . $i . "_name", 0);
}

array_push($lang_admin_data,
  'Cookies settings',
With this code, one more change is needed, which is to remove the final comma from the last line in the array() initializer since a trailing comma is valid in an array() operator, but not in an array_push() function call.  Change this (only middle line has changed):
Code: [Select]
  array('Display notices in debug mode', 'debug_notice', 1, 'f=index.htm&amp;as=admin_misc_debug_notices&amp;ae=admin_misc_debug_notices_end'), //cpg1.4
  array('Gallery is offline', 'offline', 1, 'f=index.htm&amp;as=admin_general_offline&amp;ae=admin_general_offline_end'), //cpg1.4
);
to this:
Code: [Select]
  array('Display notices in debug mode', 'debug_notice', 1, 'f=index.htm&amp;as=admin_misc_debug_notices&amp;ae=admin_misc_debug_notices_end'), //cpg1.4
  array('Gallery is offline', 'offline', 1, 'f=index.htm&amp;as=admin_general_offline&amp;ae=admin_general_offline_end') //cpg1.4
);
Title: Re: Add More Custom Fields via Config
Post by: flar on April 25, 2006, 01:26:37 am
[My apologies if some of the following sounds like newbie SQL questions - I do not come from an SQL background, though I've done a small bit of cut-and-past SQL work based on reading some tutorials.]

I was looking to modify this in a couple of ways, but I have some questions which someone who is more familiar with SQL can help me with:

First, the ideas I was going to pursue:
Feedback on those plans would be appreciated, but meanwhile...

I'm pretty sure I can get started on this if I keep a field 'user_field_created_count' in the _config table that remembers how many such fields have already been created, but it would be nice to base it on the structure of the database instead as I think it is a weak design to store (meta-)data in the database which describes the structure of the database.  Unfortunately, that is where my SQL knowledge reaches its point of confusion over what kinds of statements are portable (in general and/or relative to the portability concerns of this code base).  Tutorials and code inspection have taught me the basics, but I have no formal SQL training nor much experience to know what is good for the long run.

I suppose I could also do queries on the _config table for "user_fieldN_name" and check the cardinality of the result set, but that doesn't help with the columns in the _pictures table (though I suppose I could infer that the columns exist from whether or not the field_name row exists in _config).  Also, if I'm going to go with a meta-data solution, 'user_field_created_count' is a bit more straightforward and quick to implement.
Title: Re: Add More Custom Fields via Config
Post by: flar on April 25, 2006, 04:58:19 am
OK, here is some code to automatically add the field_name rows to the _config table and the userN columns to the _pictures table.  Note that it modifies the database as soon as you change the number of fields on the config web page.  Also, it deletes all of the old data if you lower the value (but doesn't let you lower it below 4):

Find this in admin.php (near line 820):
Code: [Select]
                if ($CONFIG[$element[1]] !== stripslashes($value))
                     {

and add this right after it (inside the braces):
Code: [Select]
                        //handle changes in 'user_field_num'
                        if ($element[1] == 'user_field_num') {
                            if (!isset($CONFIG['user_field_count'])) {
                                cpg_db_query("INSERT INTO {$CONFIG['TABLE_CONFIG']} ( `name` , `value` ) VALUES ('user_field_count', '4')");
                                $userfieldcount = 4;
                            } else {
                                $userfieldcount = $CONFIG['user_field_count'];
                            }
                            $newfieldcount = max(4, (int)$value);
                            for ($i = $userfieldcount+1; $i <= $newfieldcount; $i++) {
                                $fldname = "user_field" . $i . "_name";
                                cpg_db_query("INSERT INTO {$CONFIG['TABLE_CONFIG']} ( `name` , `value` ) VALUES ('{$fldname}', '')");
                                $fldname = "user" . $i;
                                cpg_db_query("ALTER TABLE {$CONFIG['TABLE_PICTURES']} ADD $fldname varchar(255) NOT NULL");
                            }
                            for ($i = $userfieldcount; $i > $newfieldcount; $i--) {
                                $fldname = "user_field" . $i . "_name";
                                cpg_db_query("DELETE FROM {$CONFIG['TABLE_CONFIG']} WHERE name = '{$fldname}'");
                                $fldname = "user" . $i;
                                cpg_db_query("ALTER TABLE {$CONFIG['TABLE_PICTURES']} DROP COLUMN $fldname");
                            }
                            cpg_db_query("UPDATE {$CONFIG['TABLE_CONFIG']} SET value = '$newfieldcount' WHERE name = 'user_field_count'");
                            $value = $newfieldcount;  // make sure minimum value is 4
                        }

Using this code the only manual change you need to make to your database is to create the 'user_field_num' entry in your _config table, modify your other files as indicated previously, then go to the Config page, change the number of fields, save the new configuration, and the database should be modified.  Go back to the Config page and now you should be able to enter field names for all of the new user fields, etc.
Title: Re: Add More Custom Fields via Config
Post by: pslawinski on April 25, 2006, 05:04:52 am
Thanks for your additions flar.  I have to admit that I have not looked at this code for quite some time and I was not looking forward to the prospect of having to dig it back up.
Title: Re: Add More Custom Fields via Config
Post by: Dr Preacox on May 23, 2006, 08:32:50 pm
any chance of getting this in a plugin?
Title: Re: Add More Custom Fields via Config
Post by: pslawinski on May 24, 2006, 03:59:11 am
Unfortunately it is impossible to make this a plugin.
Title: Re: Add More Custom Fields via Config
Post by: Dr Preacox on May 26, 2006, 10:32:06 am
god this will take a whie to add this into the gallery, if i upgrade the gallery i lose all the changes right?
Title: Re: Add More Custom Fields via Config
Post by: pslawinski on May 26, 2006, 04:54:53 pm
Yes, you will have to reinstall the mod if you upgrade to another version of CPG
Title: Re: Add More Custom Fields via Config
Post by: Joachim Müller on May 27, 2006, 10:13:52 am
Yes. After upgrading, you will have to re-apply every mod.
Title: Re: Add More Custom Fields via Config
Post by: Dr Preacox on May 28, 2006, 10:50:51 am
Its just a shame that you cant make every mod into a plugin, maybe for the future, but im content at the moment.
Title: Re: Add More Custom Fields via Config
Post by: flar on May 28, 2006, 12:01:55 pm
GauGau, what would it take to get this considered for integration into the main source?  I'd be willing to do some work to clean it up to make it worthwhile to integrate.
Title: Re: Add More Custom Fields via Config
Post by: flar on May 28, 2006, 12:20:43 pm
In my last updates to this mod I created a "number of user fields" form entry on the config page to change the num_user_fields.  This does the job, but I'm wondering if that is the best UI for this.  The main issue I see with it is that you have to change the number, then commit the changes, then reload the config page to be able to type in the field names.  It's relatively straightforward, but a little indirect.

An alternative that I considered was to always show "N+1" textfield form items on that page with the extra "N+1th" field being blank, obviously.  If it gets filled in, then the number of user fields is automatically increased to match and the next time the page is loaded there will now be a new N+2th blank textfield.  I didn't really like that idea as it seemed a little indirect and it raises bizarre issues like "what if they fill in the N+1 textfield, but empty out the N-1 textfield - should we try to compact which fields are named or reuse the now unused N-1th field?"  Also, to add several fields you have to add them one at a time and commit each new field separately.

Another alternative would be to add a form button to the bottom of that tab that says "Add another user field".  Ideally some javascript could add the new field dynamically and immediately without having to reload the page, but I'm not the world's greatest javascript expert.  If it did have to reload the page then that raises the question of whether or not to commit any current changes, and if not then ideally we should reload it with all of the current edits intact without commiting them which I'm guessing isn't trivial.

I suppose that some javascript could also be written to automatically add the new textfield entries when the user changes the "number of user fields" item in the current solution as well.  Some javascript could/should probably also be added to verify that the field contains a number and it is >= 4.

Any other ideas or thoughts on these alternatives?
Title: Re: Add More Custom Fields via Config
Post by: Dr Preacox on May 29, 2006, 05:11:11 pm
or the other option is having the custom feilds manager seperate, like the plugins, then you'd have something like this

(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fwww.dc-6.com%2Fdrpreacox%2Fidea.jpg&hash=67562ea0da21427dd69ec6ca7764019c27a2199e)

I think this would be a good option. what say you?

postscript: if the image is taking bandwith (its on my server) then I'll make it a link.
Title: Re: Add More Custom Fields via Config
Post by: Tranz on May 29, 2006, 08:03:05 pm
postscript: if the image is taking bandwith (its on my server) then I'll make it a link.
You can attach the image in advanced post options.
Title: Re: Add More Custom Fields via Config
Post by: dbh123 on June 01, 2006, 09:12:59 am
Hi,

I also had the problem that the custom fields were set back to empty when I set the custom fields. The problem turned out to be that the line

Code: [Select]
$userFields[]=$_POST['user$i'];
in editOnePic.php (around line 45) should have been:

Code: [Select]
$userFields[]=$_POST["user$i"];
The single quotes were preventing variable substitution.

Thanks for the great modification. Should definitely be a part of the release version.

Darren.



Where did this get to?
I love the mod - it became the tipping point for selecting Coppermine.

I added 16 fields - all came up in the config files.  Uploaded some images using Batch upload. The first image accepted my data in each fieled - and every image after that repeated the same data as contained in the first image.   Checked the datatbase - all 20 user fields are there.

Then went to edit the data for each image - nothing changed.  Checked with debug running.  Debug does not report anything - in fact it appears that nothing happened at all.
Any thoughts?
Fred
Title: Re: Add More Custom Fields via Config
Post by: pslawinski on July 08, 2006, 07:41:43 pm
Thanks for pointing out that error dbh123.

I used code which was slightly different than what you see here for my own gallery.

I have fixed the errors you mentioned in the code posted at the beginning of this topic.
Title: Re: Add More Custom Fields via Config
Post by: lemonlime on November 04, 2007, 05:19:08 pm
I got it working after a bit of trial and error. Thank you.

Only issue is that is that the additional fields don't work in the search: they are listed but always return a result of no matches.

Title: Re: Add More Custom Fields via Config
Post by: pcinfoman on January 10, 2008, 06:42:16 pm
Well, it seems that several people are having a problem with the database error of:
----------------------
While executing query "UPDATE cpg14x_pictures SET aid = '107', title = 'Frog', caption = '', keywords = '', user1 = 'Jul 1996', user2 = 'Fiberglass', user3 = 'H2', user4 = '1840', user5 = '' WHERE pid='348' LIMIT 1" on 0

mySQL error: Unknown column 'user5' in 'field list'
----------------------
However, I do not see any solutions.

What is the mysql command in order to add this to the database?
Title: Re: Add More Custom Fields via Config
Post by: Nibbler on January 10, 2008, 07:10:33 pm
Code: [Select]
ALTER TABLE cpg14x_pictures ADD user5 VARCHAR(255)
or use a GUI like phpmyadmin.
Title: Re: Add More Custom Fields via Config
Post by: pcinfoman on January 11, 2008, 06:40:20 pm
Code: [Select]
ALTER TABLE cpg14x_pictures ADD user5 VARCHAR(255)
or use a GUI like phpmyadmin.

Thank you. Works like a charm. Too bad I have to do this everytime I add a new custom field, but nevermind. I appreciate the work you all did and thank you for solving my problem..
Title: Re: Add More Custom Fields via Config
Post by: bgrega on September 30, 2008, 03:59:53 am
I'm no coder by any means and I'm trying to edit my files and use this awesome mod.
But This is what I run into.  I'm running the latest version of Coppermine and my upload.php file looks like this:
Code: [Select]
if(!empty($CONFIG['user_field1_name'])) {
            $form_array[] = array($CONFIG['user_field1_name'], 'user1', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field2_name'])) {
            $form_array[] = array($CONFIG['user_field2_name'], 'user2', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field3_name'])) {
            $form_array[] = array($CONFIG['user_field3_name'], 'user3', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field4_name'])) {
            $form_array[] = array($CONFIG['user_field4_name'], 'user4', 0, 255, 1);
        }

The instruction say to look for:
Code: [Select]
array($CONFIG['user_field1_name'], 'user1', 0, 255, 1),
    array($CONFIG['user_field2_name'], 'user2', 0, 255, 1),
    array($CONFIG['user_field3_name'], 'user3', 0, 255, 1),
    array($CONFIG['user_field4_name'], 'user4', 0, 255, 1),
    );

and replace it with:

// Check for user defined fields.
for($i = 1; $i <= $CONFIG['user_field_num']; $i++)
{
$uFN = "user_field". $i . "_name";
$uI = "user" . $i;
if(!empty($CONFIG[$uFN]))
{
$form_array[] = array($CONFIG[$uFN], $uI, 0, 255, 1);
}
}

I've tried it and I get a blank screen when upload.php tries to run.
The code is not the same but it is similar, there has to be someway to code it, but I'm like code stupid.

Any help is greatly appreciated.

Thanks,

Bryan
Title: Re: Add More Custom Fields via Config
Post by: Nibbler on September 30, 2008, 06:26:46 pm
Zip up and attach your upload.php.
Title: Re: Add More Custom Fields via Config
Post by: bgrega on October 01, 2008, 05:03:14 pm
The only way I could get it to work was to continue the code on like it was originally.
Code: [Select]
if(!empty($CONFIG['user_field6_name'])) {
            $form_array[] = array($CONFIG['user_field6_name'], 'user6', 0, 255, 1);
        }
etc........

Thanks,

Bryan
Title: Re: Add More Custom Fields via Config
Post by: Nibbler on October 01, 2008, 07:36:09 pm
You need to post the code that doesn't work so we can tell you why it doesn't work.
Title: Re: Add More Custom Fields via Config
Post by: bgrega on October 02, 2008, 03:04:50 pm
Sorry,  I must not have explained it properly.
I'm suppossed to be looking in my upload.php code for code that looks like this
Code: [Select]
array($CONFIG['user_field1_name'], 'user1', 0, 255, 1),
    array($CONFIG['user_field2_name'], 'user2', 0, 255, 1),
    array($CONFIG['user_field3_name'], 'user3', 0, 255, 1),
    array($CONFIG['user_field4_name'], 'user4', 0, 255, 1),
    );
Unfortunately I can't find the code I'm supposed to look for, the only thing that comes close to looking like what I'm supposed to replace is this
Code: [Select]
if(!empty($CONFIG['user_field1_name'])) {
            $form_array[] = array($CONFIG['user_field1_name'], 'user1', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field2_name'])) {
            $form_array[] = array($CONFIG['user_field2_name'], 'user2', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field3_name'])) {
            $form_array[] = array($CONFIG['user_field3_name'], 'user3', 0, 255, 1);
        }

        if(!empty($CONFIG['user_field4_name'])) {
            $form_array[] = array($CONFIG['user_field4_name'], 'user4', 0, 255, 1);
        }
I Have no idea how to replace this section of code as it is similar yet not the same, and I know that some how, it's doing the same thing, so I just added all the extra fields as opposed to letting the loop do it.
Hope that helps, as I stated I'm no coder, wish I was.

Thanks

Bryan
Title: Re: Add More Custom Fields via Config
Post by: Kaeghl on October 17, 2008, 08:06:32 pm
I am having a related issue.

When an image is uploaded none of the user defined information is saved to the database.

Everything  else is fine.

If I go into the image information after the upload and add information to the user defined fields and update, it saves fine.

any ideas?
Title: Re: Add More Custom Fields via Config
Post by: Kaeghl on October 17, 2008, 08:08:51 pm
the debug dump like looks like this
[19] => INSERT INTO cpg1410_pictures (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, user5,  pic_raw_ip, pic_hdr_ip, position) VALUES ('', '77', 'userpics/10001/', 'bigpiechart.JPG', '58979', '135721', '876', '624', '1224266517', '1', 'Admin','test1', 'test2', 'test3', 'YES', '', '', '', '', '',  '10.222.202.159', '10.222.202.159', '0') (0.003s)



POST :
------------------
Array
(
    [album] => 77
    [title] => test1
    [caption] => test2
    [keywords] => test3
    [control] => phase_2
    [unique_ID] => ff749777
    [user1] => test4
    [user2] => test5
    [user3] => test6
    [user4] => test7
    [user5] => test8
    [debugtext] => USER:
------------------
Title: Re: Add More Custom Fields via Config
Post by: Nibbler on October 17, 2008, 08:11:36 pm
Replace $HTTP_POST_VARS with $_POST throughout the mod or enable long arrays in your php configuration (if you can).
Title: Re: Add More Custom Fields via Config
Post by: Kaeghl on October 20, 2008, 09:58:50 pm
ah excellent, i changed it to the $_POST and it works fine now.

thanks a lot.