aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2011-04-11 10:30:56 +0000
committerpatdenice <patdenice@piwigo.org>2011-04-11 10:30:56 +0000
commitb5592c8228b2decb2e799b2550f83ac963c61e09 (patch)
tree10868884fcca101679aa638ee114c1b92ee39aa3 /admin
parent7282a5283892527cd70de227e681d8b3f4bfefee (diff)
feature:2260
Keep only two states for plugins (active and inactive) git-svn-id: http://piwigo.org/svn/trunk@10293 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/include/plugins.class.php40
-rw-r--r--admin/plugins_list.php9
-rw-r--r--admin/themes/default/template/plugins_list.tpl10
3 files changed, 22 insertions, 37 deletions
diff --git a/admin/include/plugins.class.php b/admin/include/plugins.class.php
index 30242f01b..3f7cf4567 100644
--- a/admin/include/plugins.class.php
+++ b/admin/include/plugins.class.php
@@ -78,14 +78,8 @@ class plugins
switch ($action)
{
case 'install':
- if (!empty($crt_db_plugin))
- {
- array_push($errors, 'CANNOT INSTALL - ALREADY INSTALLED');
- break;
- }
- if (!isset($this->fs_plugins[$plugin_id]))
+ if (!empty($crt_db_plugin) or !isset($this->fs_plugins[$plugin_id]))
{
- array_push($errors, 'CANNOT INSTALL - NO SUCH PLUGIN');
break;
}
if (file_exists($file_to_include))
@@ -109,15 +103,13 @@ INSERT INTO ' . PLUGINS_TABLE . ' (id,version) VALUES (\''
case 'activate':
if (!isset($crt_db_plugin))
{
- array_push($errors, 'CANNOT ACTIVATE - NOT INSTALLED');
- break;
+ $errors = $this->perform_action('install', $plugin_id);
}
- if ($crt_db_plugin['state'] != 'inactive')
+ elseif ($crt_db_plugin['state'] == 'active')
{
- array_push($errors, 'invalid current state ' . $crt_db_plugin['state']);
break;
}
- if (file_exists($file_to_include))
+ if (empty($errors) and file_exists($file_to_include))
{
include_once($file_to_include);
if (function_exists('plugin_activate'))
@@ -136,13 +128,9 @@ WHERE id=\'' . $plugin_id . '\'';
break;
case 'deactivate':
- if (!isset($crt_db_plugin))
+ if (!isset($crt_db_plugin) or $crt_db_plugin['state'] != 'active')
{
- die ('CANNOT DEACTIVATE - NOT INSTALLED');
- }
- if ($crt_db_plugin['state'] != 'active')
- {
- die('invalid current state ' . $crt_db_plugin['state']);
+ break;
}
$query = '
UPDATE ' . PLUGINS_TABLE . ' SET state=\'inactive\' WHERE id=\'' . $plugin_id . '\'';
@@ -160,7 +148,11 @@ UPDATE ' . PLUGINS_TABLE . ' SET state=\'inactive\' WHERE id=\'' . $plugin_id .
case 'uninstall':
if (!isset($crt_db_plugin))
{
- die ('CANNOT UNINSTALL - NOT INSTALLED');
+ break;
+ }
+ if ($crt_db_plugin['state'] == 'active')
+ {
+ $this->perform_action('deactivate', $plugin_id);
}
$query = '
DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
@@ -175,15 +167,19 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
}
break;
+ case 'restore':
+ $this->perform_action('uninstall', $plugin_id);
+ unset($this->db_plugins_by_id[$plugin_id]);
+ $errors = $this->perform_action('activate', $plugin_id);
+ break;
+
case 'delete':
if (!empty($crt_db_plugin))
{
- array_push($errors, 'CANNOT DELETE - PLUGIN IS INSTALLED');
- break;
+ $this->perform_action('uninstall', $plugin_id);
}
if (!isset($this->fs_plugins[$plugin_id]))
{
- array_push($errors, 'CANNOT DELETE - NO SUCH PLUGIN');
break;
}
if (!$this->deltree(PHPWG_PLUGINS_PATH . $plugin_id))
diff --git a/admin/plugins_list.php b/admin/plugins_list.php
index 1af2e239b..4ec64ec29 100644
--- a/admin/plugins_list.php
+++ b/admin/plugins_list.php
@@ -97,16 +97,12 @@ foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
}
else
{
- $tpl_plugin['STATE'] = 'uninstalled';
+ $tpl_plugin['STATE'] = 'inactive';
}
if (isset($fs_plugin['extension']) and in_array($fs_plugin['extension'], $_SESSION['merged_extensions']))
{
- switch($tpl_plugin['STATE'])
- {
- case 'active': $plugins->perform_action('deactivate', $plugin_id);
- case 'inactive': $plugins->perform_action('uninstall', $plugin_id);
- }
+ $plugins->perform_action('uninstall', $plugin_id);
$tpl_plugin['STATE'] = 'merged';
$tpl_plugin['DESC'] = l10n('THIS PLUGIN IS NOW PART OF PIWIGO CORE! DELETE IT NOW.');
$merged_plugins = true;
@@ -117,7 +113,6 @@ foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
$template->append('plugin_states', 'active');
$template->append('plugin_states', 'inactive');
-$template->append('plugin_states', 'uninstalled');
if ($merged_plugins)
{
diff --git a/admin/themes/default/template/plugins_list.tpl b/admin/themes/default/template/plugins_list.tpl
index 618104ca5..101227231 100644
--- a/admin/themes/default/template/plugins_list.tpl
+++ b/admin/themes/default/template/plugins_list.tpl
@@ -31,9 +31,6 @@ jQuery(document).ready(function() {
{elseif $plugin_state == 'inactive'}
{'Inactive Plugins'|@translate}
- {elseif $plugin_state == 'uninstalled'}
- {'Uninstalled Plugins'|@translate}
-
{elseif $plugin_state == 'missing'}
{'Missing Plugins'|@translate}
@@ -56,14 +53,11 @@ jQuery(document).ready(function() {
<td>
{if $plugin.STATE == 'active'}
<a href="{$plugin.U_ACTION}&amp;action=deactivate">{'Deactivate'|@translate}</a>
+ | <a href="{$plugin.U_ACTION}&amp;action=restore" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Restore'|@translate}</a>
{elseif $plugin_state == 'inactive'}
<a href="{$plugin.U_ACTION}&amp;action=activate" {if $plugin.INCOMPATIBLE}class="incompatible"{/if}>{'Activate'|@translate}</a>
- | <a href="{$plugin.U_ACTION}&amp;action=uninstall" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Uninstall'|@translate}</a>
-
- {elseif $plugin_state == 'uninstalled'}
- <a href="{$plugin.U_ACTION}&amp;action=install">{'Install'|@translate}</a>
- | <a href="{$plugin.U_ACTION}&amp;action=delete" onclick="return confirm('{'Are you sure you want to delete this plugin?'|@translate|@escape:'javascript'}');">{'Delete'|@translate}</a>
+ | <a href="{$plugin.U_ACTION}&amp;action=delete" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Delete'|@translate}</a>
{elseif $plugin_state == 'missing'}
<a href="{$plugin.U_ACTION}&amp;action=uninstall" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Uninstall'|@translate}</a>