Commit 4febf644 authored by Dries's avatar Dries

- Patch #35121 by m3avrck: fixed problem with list and description values...

- Patch #35121 by m3avrck: fixed problem with list and description values aren't saved for uploaded files.
parent 61ebf7b5
......@@ -360,11 +360,11 @@ function upload_save($node) {
if ($file = file_save_upload($file, $file->filename)) {
$fid = db_next_id('{files}_fid');
db_query("INSERT INTO {files} (fid, nid, vid, filename, filepath, filemime, filesize, list, description) VALUES (%d, %d, %d, '%s', '%s', '%s', %d, %d, '%s')",
$fid, $node->nid, $node->vid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $node->list[$key], $file->description);
$fid, $node->nid, $node->vid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $node->list[$key], $node->description[$key]);
}
}
}
// Remove or update existing files:
// Remove existing files, as needed
foreach ((array)$node->remove as $key => $value) {
if ($node->remove[$key]) {
db_query('DELETE FROM {files} WHERE fid = %d AND vid = %d', $key, $node->vid);
......@@ -375,20 +375,25 @@ function upload_save($node) {
}
}
}
foreach ((array)$node->list as $key => $value) {
if (!$node->remove[$key]) {
db_query('UPDATE {files} SET list = %d, description = \'%s\' WHERE fid = %d AND vid = %d', $node->list[$key], $node->description[$key], $key, $node->vid);
}
}
// Create a new revision, as needed
if ($node->old_vid) {
foreach ((array)$node->remove as $key => $remove) {
if (!$remove) {
$file = db_fetch_object(db_query('SELECT * FROM {files} WHERE vid = %d AND fid = %d', $node->old_vid, $key));
db_query("INSERT INTO {files} (fid, nid, vid, filename, filepath, filemime, filesize, list, description) VALUES (%d, %d, %d, '%s', '%s', '%s', %d, %d, '%s')",
$key, $node->nid, $node->vid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $file->list, $file->description);
$key, $node->nid, $node->vid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $node->list[$key], $node->description[$key]);
}
}
}
// Update existing files, as needed
else {
foreach ((array)$node->list as $key => $value) {
if (!$node->remove[$key]) {
db_query('UPDATE {files} SET list = %d, description = \'%s\' WHERE fid = %d AND vid = %d', $node->list[$key], $node->description[$key], $key, $node->vid);
}
}
}
return;
}
......
......@@ -360,11 +360,11 @@ function upload_save($node) {
if ($file = file_save_upload($file, $file->filename)) {
$fid = db_next_id('{files}_fid');
db_query("INSERT INTO {files} (fid, nid, vid, filename, filepath, filemime, filesize, list, description) VALUES (%d, %d, %d, '%s', '%s', '%s', %d, %d, '%s')",
$fid, $node->nid, $node->vid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $node->list[$key], $file->description);
$fid, $node->nid, $node->vid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $node->list[$key], $node->description[$key]);
}
}
}
// Remove or update existing files:
// Remove existing files, as needed
foreach ((array)$node->remove as $key => $value) {
if ($node->remove[$key]) {
db_query('DELETE FROM {files} WHERE fid = %d AND vid = %d', $key, $node->vid);
......@@ -375,20 +375,25 @@ function upload_save($node) {
}
}
}
foreach ((array)$node->list as $key => $value) {
if (!$node->remove[$key]) {
db_query('UPDATE {files} SET list = %d, description = \'%s\' WHERE fid = %d AND vid = %d', $node->list[$key], $node->description[$key], $key, $node->vid);
}
}
// Create a new revision, as needed
if ($node->old_vid) {
foreach ((array)$node->remove as $key => $remove) {
if (!$remove) {
$file = db_fetch_object(db_query('SELECT * FROM {files} WHERE vid = %d AND fid = %d', $node->old_vid, $key));
db_query("INSERT INTO {files} (fid, nid, vid, filename, filepath, filemime, filesize, list, description) VALUES (%d, %d, %d, '%s', '%s', '%s', %d, %d, '%s')",
$key, $node->nid, $node->vid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $file->list, $file->description);
$key, $node->nid, $node->vid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $node->list[$key], $node->description[$key]);
}
}
}
// Update existing files, as needed
else {
foreach ((array)$node->list as $key => $value) {
if (!$node->remove[$key]) {
db_query('UPDATE {files} SET list = %d, description = \'%s\' WHERE fid = %d AND vid = %d', $node->list[$key], $node->description[$key], $key, $node->vid);
}
}
}
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment