aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2011-01-04 10:55:08 +0000
committerplegall <plg@piwigo.org>2011-01-04 10:55:08 +0000
commitb4d2a1362fa6dc15d8a1e849d5e36fe341953baf (patch)
tree3b3a6a2246e00ec50dfc5d57ced6bffaad8e9012
parent621ed0b391f81bb7d636d1e447154e1f5b43fb24 (diff)
feature 2095 added: new column images.added_by (foreign key on users.id)
git-svn-id: http://piwigo.org/svn/trunk@8464 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/include/functions_upload.inc.php3
-rw-r--r--admin/site_update.php1
-rw-r--r--include/ws_functions.inc.php3
-rw-r--r--install/db/92-database.php57
-rw-r--r--install/piwigo_structure-mysql.sql1
-rw-r--r--install/piwigo_structure-pdo-sqlite.sql1
-rw-r--r--install/piwigo_structure-pgsql.sql1
-rw-r--r--install/piwigo_structure-sqlite.sql1
8 files changed, 66 insertions, 2 deletions
diff --git a/admin/include/functions_upload.inc.php b/admin/include/functions_upload.inc.php
index 84c00a90e..fe7b888bb 100644
--- a/admin/include/functions_upload.inc.php
+++ b/admin/include/functions_upload.inc.php
@@ -184,7 +184,7 @@ function add_uploaded_file($source_filepath, $original_filename=null, $categorie
// TODO
// * check md5sum (already exists?)
- global $conf;
+ global $conf, $user;
// current date
list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
@@ -306,6 +306,7 @@ function add_uploaded_file($source_filepath, $original_filename=null, $categorie
'width' => $file_infos['width'],
'height' => $file_infos['height'],
'md5sum' => $md5sum,
+ 'added_by' => $user['id'],
);
if (isset($high_infos))
diff --git a/admin/site_update.php b/admin/site_update.php
index 6c2e74c60..d0577070c 100644
--- a/admin/site_update.php
+++ b/admin/site_update.php
@@ -449,6 +449,7 @@ SELECT file,storage_category_id
? $fs[$path]['tn_ext']
: null,
'storage_category_id' => $db_fulldirs[$dirname],
+ 'added_by' => $user['id'],
);
if ( $_POST['privacy_level']!=0 )
diff --git a/include/ws_functions.inc.php b/include/ws_functions.inc.php
index ab4c342cc..56194f32a 100644
--- a/include/ws_functions.inc.php
+++ b/include/ws_functions.inc.php
@@ -1209,7 +1209,7 @@ SELECT
function ws_images_add($params, &$service)
{
- global $conf;
+ global $conf, $user;
if (!is_admin())
{
return new PwgError(401, 'Access denied');
@@ -1284,6 +1284,7 @@ SELECT
'width' => $file_infos['width'],
'height' => $file_infos['height'],
'md5sum' => $params['original_sum'],
+ 'added_by' => $user['id'],
);
$info_columns = array(
diff --git a/install/db/92-database.php b/install/db/92-database.php
new file mode 100644
index 000000000..7ac5c52da
--- /dev/null
+++ b/install/db/92-database.php
@@ -0,0 +1,57 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program is free software; you can redistribute it and/or modify |
+// | it under the terms of the GNU General Public License as published by |
+// | the Free Software Foundation |
+// | |
+// | This program is distributed in the hope that it will be useful, but |
+// | WITHOUT ANY WARRANTY; without even the implied warranty of |
+// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
+// | General Public License for more details. |
+// | |
+// | You should have received a copy of the GNU General Public License |
+// | along with this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+if (!defined('PHPWG_ROOT_PATH'))
+{
+ die('Hacking attempt!');
+}
+
+$upgrade_description = 'New colum images.added_by, reference to users.id';
+
+// Add column
+$query = 'ALTER TABLE '.IMAGES_TABLE.' ADD COLUMN ';
+
+if ('mysql' == $conf['dblayer'])
+{
+ $query.= ' added_by smallint(5)';
+}
+
+if (in_array($conf['dblayer'], array('pgsql', 'sqlite', 'pdo-sqlite')))
+{
+ $query.= ' "added_by" INTEGER default 0';
+}
+
+$query.= ' NOT NULL;';
+
+pwg_query($query);
+
+// set the existing photos with the webmaster_id as added_by
+$query = 'UPDATE '.IMAGES_TABLE.' SET added_by = '.$conf['webmaster_id'].';';
+pwg_query($query);
+
+echo
+"\n"
+. $upgrade_description
+."\n"
+;
+?> \ No newline at end of file
diff --git a/install/piwigo_structure-mysql.sql b/install/piwigo_structure-mysql.sql
index 44124f072..a241ab1f4 100644
--- a/install/piwigo_structure-mysql.sql
+++ b/install/piwigo_structure-mysql.sql
@@ -195,6 +195,7 @@ CREATE TABLE `piwigo_images` (
`high_filesize` mediumint(9) unsigned default NULL,
`level` tinyint unsigned NOT NULL default '0',
`md5sum` char(32) default NULL,
+ `added_by` smallint(5) NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `images_i2` (`date_available`),
KEY `images_i3` (`average_rate`),
diff --git a/install/piwigo_structure-pdo-sqlite.sql b/install/piwigo_structure-pdo-sqlite.sql
index e4aa71ca3..0c38b4008 100644
--- a/install/piwigo_structure-pdo-sqlite.sql
+++ b/install/piwigo_structure-pdo-sqlite.sql
@@ -191,6 +191,7 @@ CREATE TABLE piwigo_images
"high_filesize" INTEGER,
"level" INTEGER default 0 NOT NULL,
"md5sum" CHAR(32),
+ "added_by" INTEGER default 0 NOT NULL,
PRIMARY KEY ("id")
);
diff --git a/install/piwigo_structure-pgsql.sql b/install/piwigo_structure-pgsql.sql
index f4679cc83..5f9d5a8cf 100644
--- a/install/piwigo_structure-pgsql.sql
+++ b/install/piwigo_structure-pgsql.sql
@@ -235,6 +235,7 @@ CREATE TABLE "piwigo_images"
"high_filesize" INTEGER,
"level" INTEGER default 0 NOT NULL,
"md5sum" CHAR(32),
+ "added_by" INTEGER default 0 NOT NULL,
PRIMARY KEY ("id")
);
diff --git a/install/piwigo_structure-sqlite.sql b/install/piwigo_structure-sqlite.sql
index e4aa71ca3..0c38b4008 100644
--- a/install/piwigo_structure-sqlite.sql
+++ b/install/piwigo_structure-sqlite.sql
@@ -191,6 +191,7 @@ CREATE TABLE piwigo_images
"high_filesize" INTEGER,
"level" INTEGER default 0 NOT NULL,
"md5sum" CHAR(32),
+ "added_by" INTEGER default 0 NOT NULL,
PRIMARY KEY ("id")
);