mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-05 01:12:29 +02:00
fixes #1841 register system activities
This commit is contained in:
@@ -245,6 +245,7 @@ if (count($errors) == 0)
|
||||
}
|
||||
|
||||
$page['infos'][] = l10n('Your configuration settings are saved');
|
||||
pwg_activity('system', ACTIVITY_SYSTEM_CORE, 'config', array('config_section'=>'sizes'));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -196,6 +196,7 @@ if (count($errors) == 0)
|
||||
}
|
||||
|
||||
$page['infos'][] = l10n('Your configuration settings are saved');
|
||||
pwg_activity('system', ACTIVITY_SYSTEM_CORE, 'config', array('config_section'=>'watermark'));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -117,6 +117,8 @@ class plugins
|
||||
$plugin_maintain = self::build_maintain_class($plugin_id);
|
||||
}
|
||||
|
||||
$activity_details = array('plugin_id'=>$plugin_id);
|
||||
|
||||
$errors = array();
|
||||
|
||||
switch ($action)
|
||||
@@ -128,6 +130,7 @@ class plugins
|
||||
}
|
||||
|
||||
$plugin_maintain->install($this->fs_plugins[$plugin_id]['version'], $errors);
|
||||
$activity_details['version'] = $this->fs_plugins[$plugin_id]['version'];
|
||||
|
||||
if (empty($errors))
|
||||
{
|
||||
@@ -137,16 +140,22 @@ INSERT INTO '. PLUGINS_TABLE .' (id,version)
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
else
|
||||
{
|
||||
$activity_details['result'] = 'error';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$previous_version = $this->fs_plugins[$plugin_id]['version'];
|
||||
$activity_details['from_version'] = $previous_version;
|
||||
$errors[0] = $this->extract_plugin_files('upgrade', $options['revision'], $plugin_id);
|
||||
|
||||
if ($errors[0] === 'ok')
|
||||
{
|
||||
$this->get_fs_plugin($plugin_id); // refresh plugins list
|
||||
$new_version = $this->fs_plugins[$plugin_id]['version'];
|
||||
$activity_details['to_version'] = $new_version;
|
||||
|
||||
$plugin_maintain = self::build_maintain_class($plugin_id);
|
||||
$plugin_maintain->update($previous_version, $new_version, $errors);
|
||||
@@ -161,6 +170,11 @@ UPDATE '. PLUGINS_TABLE .'
|
||||
pwg_query($query);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$activity_details['result'] = 'error';
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
|
||||
@@ -179,6 +193,7 @@ UPDATE '. PLUGINS_TABLE .'
|
||||
if (empty($errors))
|
||||
{
|
||||
$plugin_maintain->activate($crt_db_plugin['version'], $errors);
|
||||
$activity_details['version'] = $crt_db_plugin['version'];
|
||||
}
|
||||
|
||||
if (empty($errors))
|
||||
@@ -190,11 +205,16 @@ UPDATE '. PLUGINS_TABLE .'
|
||||
;';
|
||||
pwg_query($query);
|
||||
}
|
||||
else
|
||||
{
|
||||
$activity_details['result'] = 'error';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'deactivate':
|
||||
if (!isset($crt_db_plugin) or $crt_db_plugin['state'] != 'active')
|
||||
{
|
||||
$activity_details['result'] = 'error';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -206,13 +226,27 @@ UPDATE '. PLUGINS_TABLE .'
|
||||
pwg_query($query);
|
||||
|
||||
$plugin_maintain->deactivate();
|
||||
|
||||
if (isset($crt_db_plugin['version']))
|
||||
{
|
||||
$activity_details['version'] = $crt_db_plugin['version'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'uninstall':
|
||||
if (!isset($crt_db_plugin))
|
||||
{
|
||||
$activity_details['result'] = 'error';
|
||||
$activity_details['error'] = 'plugin not installed';
|
||||
break;
|
||||
}
|
||||
|
||||
if (isset($crt_db_plugin['version']))
|
||||
{
|
||||
$activity_details['version'] = $crt_db_plugin['version'];
|
||||
}
|
||||
|
||||
if ($crt_db_plugin['state'] == 'active')
|
||||
{
|
||||
$this->perform_action('deactivate', $plugin_id);
|
||||
@@ -236,17 +270,29 @@ DELETE FROM '. PLUGINS_TABLE .'
|
||||
case 'delete':
|
||||
if (!empty($crt_db_plugin))
|
||||
{
|
||||
if (isset($crt_db_plugin['version']))
|
||||
{
|
||||
$activity_details['db_version'] = $crt_db_plugin['version'];
|
||||
}
|
||||
|
||||
$this->perform_action('uninstall', $plugin_id);
|
||||
}
|
||||
if (!isset($this->fs_plugins[$plugin_id]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
$activity_details['fs_version'] = $this->fs_plugins[$plugin_id]['version'];
|
||||
}
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
deltree(PHPWG_PLUGINS_PATH . $plugin_id, PHPWG_PLUGINS_PATH . 'trash');
|
||||
break;
|
||||
}
|
||||
|
||||
pwg_activity('system', ACTIVITY_SYSTEM_PLUGIN, $action, $activity_details);
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,7 @@ class themes
|
||||
$theme_maintain = self::build_maintain_class($theme_id);
|
||||
|
||||
$errors = array();
|
||||
$activity_details = array('theme_id'=>$theme_id);
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
@@ -144,6 +145,8 @@ INSERT INTO '.THEMES_TABLE.'
|
||||
;';
|
||||
pwg_query($query);
|
||||
|
||||
$activity_details['version'] = $this->fs_themes[$theme_id]['version'];
|
||||
|
||||
if ($this->fs_themes[$theme_id]['mobile'])
|
||||
{
|
||||
conf_update_param('mobile_theme', $theme_id);
|
||||
@@ -236,6 +239,9 @@ DELETE
|
||||
$this->set_default_theme($theme_id);
|
||||
break;
|
||||
}
|
||||
|
||||
pwg_activity('system', ACTIVITY_SYSTEM_THEME, $action, $activity_details);
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
@@ -577,7 +583,7 @@ SELECT
|
||||
* @param string - remote revision identifier (numeric)
|
||||
* @param string - theme id or extension id
|
||||
*/
|
||||
function extract_theme_files($action, $revision, $dest)
|
||||
function extract_theme_files($action, $revision, $dest, &$theme_id=null)
|
||||
{
|
||||
global $logger;
|
||||
|
||||
@@ -614,13 +620,13 @@ SELECT
|
||||
$root = dirname($main_filepath); // main.inc.php path in archive
|
||||
if ($action == 'upgrade')
|
||||
{
|
||||
$extract_path = PHPWG_THEMES_PATH . $dest;
|
||||
$theme_id = $dest;
|
||||
}
|
||||
else
|
||||
{
|
||||
$extract_path = PHPWG_THEMES_PATH . ($root == '.' ? 'extension_' . $dest : basename($root));
|
||||
$theme_id = ($root == '.' ? 'extension_' . $dest : basename($root));
|
||||
}
|
||||
|
||||
$extract_path = PHPWG_THEMES_PATH . $theme_id;
|
||||
$logger->debug(__FUNCTION__.', $extract_path = '.$extract_path);
|
||||
|
||||
if (
|
||||
|
||||
@@ -460,6 +460,8 @@ class updates
|
||||
|
||||
if ($check_current_version and !version_compare($upgrade_to, PHPWG_VERSION, '>'))
|
||||
{
|
||||
// TODO why redirect to a plugin page? maybe a remaining code from when
|
||||
// the update system was provided as a plugin?
|
||||
redirect(get_root_url().'admin.php?page=plugin-'.basename(dirname(__FILE__)));
|
||||
}
|
||||
|
||||
@@ -552,6 +554,8 @@ class updates
|
||||
|
||||
deltree(PHPWG_ROOT_PATH.$conf['data_location'].'update');
|
||||
invalidate_user_cache(true);
|
||||
pwg_activity('system', ACTIVITY_SYSTEM_CORE, 'update', array('from_version'=>PHPWG_VERSION, 'to_version'=>$upgrade_to));
|
||||
|
||||
if ($step == 2)
|
||||
{
|
||||
// only delete compiled templates on minor update. Doing this on
|
||||
|
||||
Reference in New Issue
Block a user