Skip to content

Commit

Permalink
feature 2095 added: new column images.added_by (foreign key on users.id)
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@8464 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Jan 4, 2011
1 parent 621ed0b commit b4d2a13
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 2 deletions.
3 changes: 2 additions & 1 deletion admin/include/functions_upload.inc.php
Expand Up @@ -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();'));
Expand Down Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions admin/site_update.php
Expand Up @@ -449,6 +449,7 @@
? $fs[$path]['tn_ext']
: null,
'storage_category_id' => $db_fulldirs[$dirname],
'added_by' => $user['id'],
);

if ( $_POST['privacy_level']!=0 )
Expand Down
3 changes: 2 additions & 1 deletion include/ws_functions.inc.php
Expand Up @@ -1209,7 +1209,7 @@ function ws_images_addFile($params, &$service)

function ws_images_add($params, &$service)
{
global $conf;
global $conf, $user;
if (!is_admin())
{
return new PwgError(401, 'Access denied');
Expand Down Expand Up @@ -1284,6 +1284,7 @@ function ws_images_add($params, &$service)
'width' => $file_infos['width'],
'height' => $file_infos['height'],
'md5sum' => $params['original_sum'],
'added_by' => $user['id'],
);

$info_columns = array(
Expand Down
57 changes: 57 additions & 0 deletions 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"
;
?>
1 change: 1 addition & 0 deletions install/piwigo_structure-mysql.sql
Expand Up @@ -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`),
Expand Down
1 change: 1 addition & 0 deletions install/piwigo_structure-pdo-sqlite.sql
Expand Up @@ -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")
);

Expand Down
1 change: 1 addition & 0 deletions install/piwigo_structure-pgsql.sql
Expand Up @@ -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")
);

Expand Down
1 change: 1 addition & 0 deletions install/piwigo_structure-sqlite.sql
Expand Up @@ -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")
);

Expand Down

0 comments on commit b4d2a13

Please sign in to comment.