SMFHacks.com

SMF Gallery Pro => Support => Bugs => Topic started by: iosarian on December 06, 2007, 02:44:48 pm

Title: Edit picture problems
Post by: iosarian on December 06, 2007, 02:44:48 pm
1. After I edit picture uploaded by other administrator, it shows to me that the picture is uploaded by "guest".
2. The members can Bulk upload pictures without titles. But in edit view the titles are required.
3. When member edits picture and replaces the picture file, "next" and "previous" don't work.
Title: Re: Edit picture problems
Post by: SMFHacks on December 06, 2007, 09:53:46 pm
On list of things to look into this weekend
Title: Re: Edit picture problems
Post by: iosarian on December 07, 2007, 05:23:41 pm
In function EditPicture2(),                
// Update the Database entry
The query updates the ID_CAT and when user edits picture the ID_CAT in database is not "0". I think there is no need to update ID_CAT.
Title: Re: Edit picture problems
Post by: SMFHacks on December 08, 2007, 11:32:23 am
Couldn't recreate number #1, #3 on my test gallery using the latest version.

#2 added in next update to for non gallery admin's to require the title.
Title: Re: Edit picture problems
Post by: iosarian on December 08, 2007, 02:08:05 pm
#3: If member edits pictire and replace the file in gallery smf_gallery_pic table for this picture that ID_CAT is the same USER_ID_CAT. It happens after editing.
And if I have picture 1, 2, 3, 4 in one category and edit number 3, with "next" link in picture view it takes from number 2 to number 4 (skiping number 3)
I removed ID_CAT in update query and for now it seems it works.

#1: I only can tell you what happens in the database. After editing it show that ID_MEMBER is 99999.
Title: Re: Edit picture problems
Post by: SMFHacks on December 08, 2007, 02:15:56 pm
For #3. USER_ID_CAT and ID_CAT can not be both set one needs to be zero otherwise it would cause problems.

For #1 This is the only portion of the code that deals with changing the picture owner and only updates if that member's name is found.
Code: [Select]
// Change the picture owner if selected
if (allowedTo('smfgallery_manage') && isset($_REQUEST['pic_postername']))
{
$pic_postername = str_replace('"','', $_REQUEST['pic_postername']);
$pic_postername = str_replace("'",'', $pic_postername);
$pic_postername = str_replace('\\','', $pic_postername);
$pic_postername = htmlspecialchars($pic_postername, ENT_QUOTES);

$memid = 0;

$dbresult = db_query("
SELECT
realName, ID_MEMBER
FROM {$db_prefix}members
WHERE realName = '$pic_postername' OR memberName = '$pic_postername'  LIMIT 1", __FILE__, __LINE__);
$row = mysql_fetch_assoc($dbresult);
mysql_free_result($dbresult);

if (db_affected_rows() != 0)
{
// Member found update the picture owner

$memid = $row['ID_MEMBER'];
db_query("UPDATE {$db_prefix}gallery_pic
SET ID_MEMBER = $memid WHERE ID_PICTURE = $id LIMIT 1", __FILE__, __LINE__);


}

}
Title: Re: Edit picture problems
Post by: iosarian on December 08, 2007, 02:41:20 pm
For #3. USER_ID_CAT and ID_CAT can not be both set one needs to be zero otherwise it would cause problems.
In EditPicture2():
$cat = (int) $_REQUEST['cat'] but the link is "action=gallery;su=user;u=XXXX;cat=YYY" and I think $cat takes the YYY value which in this case is user category ID.
After that udate query updates the ID_CAT with $cat.
Title: Re: Edit picture problems
Post by: SMFHacks on December 08, 2007, 03:06:32 pm
Fixed for next update

Open Sources/Gallery.php

Find
Code: [Select]
// Update the Database entry
$t = time();

db_query("UPDATE {$db_prefix}gallery_pic
SET ID_CAT = $cat, filesize = $filesize, filename = '" . $extrafolder . $filename . "',  thumbfilename = '" . $extrafolder . $thumbname . "', height = $sizes[1], width = $sizes[0], approved = $approved, date =  $t, title = '$title', description = '$description', keywords = '$keywords', allowcomments = $allowcomments, sendemail = $sendemail WHERE ID_PICTURE = $id LIMIT 1", __FILE__, __LINE__);


Change to
Code: [Select]

// Update the Database entry
$t = time();
if ($row['USER_ID_CAT'] == 0)
{
db_query("UPDATE {$db_prefix}gallery_pic
SET ID_CAT = $cat, filesize = $filesize, filename = '" . $extrafolder . $filename . "',  thumbfilename = '" . $extrafolder . $thumbname . "', height = $sizes[1], width = $sizes[0], approved = $approved, date =  $t, title = '$title', description = '$description', keywords = '$keywords', allowcomments = $allowcomments, sendemail = $sendemail WHERE ID_PICTURE = $id LIMIT 1", __FILE__, __LINE__);
}
else
{
db_query("UPDATE {$db_prefix}gallery_pic
SET USER_ID_CAT = $cat, filesize = $filesize, filename = '" . $extrafolder . $filename . "',  thumbfilename = '" . $extrafolder . $thumbname . "', height = $sizes[1], width = $sizes[0], approved = $approved, date =  $t, title = '$title', description = '$description', keywords = '$keywords', allowcomments = $allowcomments, sendemail = $sendemail WHERE ID_PICTURE = $id LIMIT 1", __FILE__, __LINE__);
}