mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-03-28 17:42:57 +01:00
fixes #1841 register system activities
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user