Skip to content
Permalink
Browse files
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
  • Loading branch information
patdenice committed Apr 11, 2011
1 parent 7282a52 commit b5592c8228b2decb2e799b2550f83ac963c61e09
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 37 deletions.
@@ -78,14 +78,8 @@ function perform_action($action, $plugin_id)
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 @@ function perform_action($action, $plugin_id)
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 @@ function perform_action($action, $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 @@ function perform_action($action, $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 @@ function perform_action($action, $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))
@@ -97,16 +97,12 @@
}
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 @@

$template->append('plugin_states', 'active');
$template->append('plugin_states', 'inactive');
$template->append('plugin_states', 'uninstalled');

if ($merged_plugins)
{
@@ -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>

0 comments on commit b5592c8

Please sign in to comment.