From a25fe0c7e86da6c60b22b7785d27832f0bb18b2a Mon Sep 17 00:00:00 2001 From: mistic100 Date: Fri, 10 Feb 2012 14:44:20 +0000 Subject: [PATCH] feature 2567: in IMAGES_TABLE the field "name" is prefilled with the filename git-svn-id: http://piwigo.org/svn/trunk@13082 68402e56-0260-453c-a942-63ccdbb3a9ee --- admin/include/functions_upload.inc.php | 4 +- admin/site_update.php | 1 + install/db/117-database.php | 65 ++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 install/db/117-database.php diff --git a/admin/include/functions_upload.inc.php b/admin/include/functions_upload.inc.php index 648b8ddc6..2a5206c1b 100644 --- a/admin/include/functions_upload.inc.php +++ b/admin/include/functions_upload.inc.php @@ -296,8 +296,10 @@ SELECT else { // database registration + $file = pwg_db_real_escape_string(isset($original_filename) ? $original_filename : basename($file_path)); $insert = array( - 'file' => pwg_db_real_escape_string(isset($original_filename) ? $original_filename : basename($file_path)), + 'file' => $file, + 'name' => get_name_from_file($file), 'date_available' => $dbnow, 'path' => preg_replace('#^'.preg_quote(PHPWG_ROOT_PATH).'#', '', $file_path), 'filesize' => $file_infos['filesize'], diff --git a/admin/site_update.php b/admin/site_update.php index ef73e0104..2021ac984 100644 --- a/admin/site_update.php +++ b/admin/site_update.php @@ -410,6 +410,7 @@ SELECT id, path $insert = array( 'id' => $next_element_id++, 'file' => $filename, + 'name' => get_name_from_file($filename), 'date_available' => CURRENT_DATE, 'path' => $path, 'representative_ext' => $fs[$path]['representative_ext'], diff --git a/install/db/117-database.php b/install/db/117-database.php new file mode 100644 index 000000000..0551b44ae --- /dev/null +++ b/install/db/117-database.php @@ -0,0 +1,65 @@ + $row['id'], + 'name' => get_name_from_file($row['file']), + ); +} + +mass_updates( + IMAGES_TABLE, + array( + 'primary' => array('id'), + 'update' => array('name'), + ), + $updates + ); + + +echo +"\n" +.'"'.$upgrade_description.'"'.' ended' +."\n" +; + +?>