issue #552 new table activity and log add/edit/delete on albums

This commit is contained in:
plegall 2019-03-25 16:50:45 +01:00
parent 6a336ed4ec
commit 27a6504284
8 changed files with 101 additions and 0 deletions

View file

@ -170,6 +170,7 @@ UPDATE '.CATEGORIES_TABLE.'
}
$_SESSION['page_infos'][] = l10n('Album updated successfully');
pwg_activity('album', $_GET['cat_id'], 'edit');
$redirect = true;
}

View file

@ -163,6 +163,7 @@ DELETE FROM '.USER_CACHE_CATEGORIES_TABLE.'
pwg_query($query);
trigger_notify('delete_categories', $ids);
pwg_activity('album', $ids, 'delete', 'photo_deletion_mode='.$photo_deletion_mode);
}
/**
@ -1589,6 +1590,7 @@ SELECT id, uppercats, global_rank, visible, status
}
trigger_notify('create_virtual_category', array_merge(array('id'=>$inserted_id), $insert));
pwg_activity('album', $inserted_id, 'add');
return array(
'info' => l10n('Virtual album added'),

View file

@ -109,5 +109,7 @@ if (!defined('LANGUAGES_TABLE'))
define('LANGUAGES_TABLE', $prefixeTable.'languages');
if (!defined('IMAGE_FORMAT_TABLE'))
define('IMAGE_FORMAT_TABLE', $prefixeTable.'image_format');
if (!defined('ACTIVITY_TABLE'))
define('ACTIVITY_TABLE', $prefixeTable.'activity');
?>

View file

@ -511,6 +511,31 @@ INSERT INTO '.HISTORY_TABLE.'
return true;
}
function pwg_activity($object, $object_id, $action, $details=null)
{
global $user;
$object_ids = $object_id;
if (!is_array($object_id))
{
$object_ids = array($object_id);
}
foreach ($object_ids as $loop_object_id)
{
single_insert(
ACTIVITY_TABLE,
array(
'object' => $object,
'object_id' => $loop_object_id,
'action' => $action,
'performed_by' => $user['id'],
'details' => pwg_db_real_escape_string($details),
)
);
}
}
/**
* Computes the difference between two dates.
* returns a DateInterval object or a stdClass with the same attributes

View file

@ -730,6 +730,8 @@ SELECT *
array('id' => $update['id'])
);
}
pwg_activity('album', $params['category_id'], 'edit', 'method='.$_REQUEST['method'].' fields='.implode(',', array_keys($update)));
}
/**
@ -779,6 +781,8 @@ UPDATE '. USER_CACHE_CATEGORIES_TABLE .'
WHERE cat_id = '. $params['category_id'] .'
;';
pwg_query($query);
pwg_activity('album', $params['category_id'], 'edit', 'method='.$_REQUEST['method'].' image_id='.$params['image_id']);
}
/**
@ -824,6 +828,8 @@ UPDATE '.CATEGORIES_TABLE.'
WHERE id = '.$params['category_id'].'
;';
pwg_query($query);
pwg_activity('album', $params['category_id'], 'edit', 'method='.$_REQUEST['method']);
}
/**
@ -869,6 +875,8 @@ SELECT
set_random_representant(array($params['category_id']));
pwg_activity('album', $params['category_id'], 'edit', 'method='.$_REQUEST['method']);
// return url of the new representative
$query = '
SELECT *

View file

@ -0,0 +1,46 @@
<?php
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based photo gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2016 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 = 'add activity table';
pwg_query('
CREATE TABLE `'.PREFIX_TABLE.'activity` (
`activity_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`object` varchar(255) NOT NULL,
`object_id` int(11) unsigned NOT NULL,
`action` varchar(255) NOT NULL,
`performed_by` mediumint(8) unsigned NOT NULL,
`occured_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`details` varchar(255) DEFAULT NULL,
PRIMARY KEY (`activity_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
;');
echo "\n".$upgrade_description."\n";
?>

View file

@ -4,6 +4,22 @@
-- ------------------------------------------------------
-- Server version 4.0.24_Debian-10-log
--
-- Table structure for table `piwigo_activity`
--
DROP TABLE IF EXISTS `piwigo_activity`;
CREATE TABLE `piwigo_activity` (
`activity_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`object` varchar(255) NOT NULL,
`object_id` int(11) unsigned NOT NULL,
`action` varchar(255) NOT NULL,
`performed_by` mediumint(8) unsigned NOT NULL,
`occured_on` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`details` varchar(255) DEFAULT NULL,
PRIMARY KEY (`activity_id`)
) ENGINE=MyISAM;
--
-- Table structure for table `piwigo_caddie`
--

View file

@ -316,6 +316,7 @@ UPDATE '.CATEGORIES_TABLE.'
WHERE id = '.$page['category']['id'].'
;';
pwg_query($query);
pwg_activity('album', $page['category']['id'], 'edit', 'script='.script_basename().' action='.$_GET['action'].' image_id='.$page['image_id']);
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
invalidate_user_cache();