mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-06 01:42:29 +02:00
@@ -30,6 +30,11 @@ define('ACCESS_ADMINISTRATOR', 3);
|
||||
define('ACCESS_WEBMASTER', 4);
|
||||
define('ACCESS_CLOSED', 5);
|
||||
|
||||
// System activities
|
||||
define('ACTIVITY_SYSTEM_CORE', 1);
|
||||
define('ACTIVITY_SYSTEM_PLUGIN', 2);
|
||||
define('ACTIVITY_SYSTEM_THEME', 3);
|
||||
|
||||
// Sanity checks
|
||||
define('PATTERN_ID', '/^\d+$/');
|
||||
|
||||
|
||||
@@ -536,6 +536,13 @@ function pwg_activity($object, $object_id, $action, $details=array())
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['method']) and 'pwg.plugins.performAction' == $_REQUEST['method'] and $_REQUEST['action'] != $action)
|
||||
{
|
||||
// for example, if you "restore" a plugin, the internal sequence will perform deactivate/uninstall/install/activate.
|
||||
// We only want to keep the last call to pwg_activity with the "restore" action.
|
||||
return;
|
||||
}
|
||||
|
||||
$object_ids = $object_id;
|
||||
if (!is_array($object_id))
|
||||
{
|
||||
@@ -556,6 +563,13 @@ function pwg_activity($object, $object_id, $action, $details=array())
|
||||
}
|
||||
}
|
||||
|
||||
if ('autoupdate' == $action)
|
||||
{
|
||||
// autoupdate on a plugin can happen anywhere, the "script/method" is not meaningfull
|
||||
unset($details['method']);
|
||||
unset($details['script']);
|
||||
}
|
||||
|
||||
$user_agent = null;
|
||||
if ('user' == $object and 'login' == $action and isset($_SERVER['HTTP_USER_AGENT']))
|
||||
{
|
||||
@@ -588,7 +602,7 @@ function pwg_activity($object, $object_id, $action, $details=array())
|
||||
|
||||
foreach ($object_ids as $loop_object_id)
|
||||
{
|
||||
$performed_by = $user['id'];
|
||||
$performed_by = $user['id'] ?? 0; // on a plugin autoupdate, $user is not yet loaded
|
||||
|
||||
if ('logout' == $action)
|
||||
{
|
||||
|
||||
@@ -385,6 +385,9 @@ function autoupdate_plugin(&$plugin)
|
||||
safe_version_compare($plugin['version'], $fs_version, '<')
|
||||
)
|
||||
) {
|
||||
$old_version = $plugin['version'];
|
||||
$new_version = $fs_version;
|
||||
|
||||
$plugin['version'] = $fs_version;
|
||||
|
||||
$maintain_file = PHPWG_PLUGINS_PATH.$plugin['id'].'/maintain.class.php';
|
||||
@@ -407,8 +410,9 @@ function autoupdate_plugin(&$plugin)
|
||||
$plugin_maintain->update($plugin['version'], $fs_version, $page['errors']);
|
||||
}
|
||||
|
||||
// update database (only on production)
|
||||
if ($plugin['version'] != 'auto')
|
||||
// update database (only on production). We want to avoid registering an "auto" to "auto" update,
|
||||
// which happens for each "version=auto" plugin on each page load.
|
||||
if ($new_version != $old_version)
|
||||
{
|
||||
$query = '
|
||||
UPDATE '. PLUGINS_TABLE .'
|
||||
@@ -416,6 +420,8 @@ UPDATE '. PLUGINS_TABLE .'
|
||||
WHERE id = "'. $plugin['id'] .'"
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
pwg_activity('system', ACTIVITY_SYSTEM_PLUGIN, 'autoupdate', array('plugin_id'=>$plugin['id'], 'from_version'=>$old_version, 'to_version'=>$new_version));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,6 +190,20 @@ function ws_extensions_update($params, $service)
|
||||
{
|
||||
$upgrade_status = $extension->extract_theme_files('upgrade', $revision, $extension_id);
|
||||
$extension_name = $extension->fs_themes[$extension_id]['name'];
|
||||
|
||||
$activity_details = array('theme_id'=>$extension_id, 'from_version'=>$extension->fs_themes[$extension_id]['version']);
|
||||
|
||||
if ('ok' == $upgrade_status)
|
||||
{
|
||||
$extension->get_fs_themes(); // refresh list
|
||||
$activity_details['to_version'] = $extension->fs_themes[$extension_id]['version'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$activity_details['result'] = 'error';
|
||||
}
|
||||
|
||||
pwg_activity('system', ACTIVITY_SYSTEM_THEME, 'update', $activity_details);
|
||||
}
|
||||
else if ($type == 'languages')
|
||||
{
|
||||
|
||||
@@ -446,23 +446,24 @@ SELECT
|
||||
occured_on,
|
||||
details,
|
||||
user_agent
|
||||
FROM '.ACTIVITY_TABLE;
|
||||
FROM '.ACTIVITY_TABLE.'
|
||||
WHERE object != \'system\'';
|
||||
|
||||
if (isset($param['uid']))
|
||||
{
|
||||
$query.= '
|
||||
WHERE performed_by = '.$param['uid'];
|
||||
AND performed_by = '.$param['uid'];
|
||||
}
|
||||
elseif ('none' == $conf['activity_display_connections'])
|
||||
{
|
||||
$query.= '
|
||||
WHERE action NOT IN (\'login\', \'logout\')';
|
||||
AND action NOT IN (\'login\', \'logout\')';
|
||||
}
|
||||
elseif ('admins_only' == $conf['activity_display_connections'])
|
||||
{
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
$query.= '
|
||||
WHERE NOT (action IN (\'login\', \'logout\') AND object_id NOT IN ('.implode(',', get_admins()).'))';
|
||||
AND NOT (action IN (\'login\', \'logout\') AND object_id NOT IN ('.implode(',', get_admins()).'))';
|
||||
}
|
||||
|
||||
$query.= '
|
||||
|
||||
Reference in New Issue
Block a user