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
This commit is contained in:
parent
7282a52838
commit
b5592c8228
3 changed files with 22 additions and 37 deletions
|
|
@ -78,14 +78,8 @@ class plugins
|
|||
switch ($action)
|
||||
{
|
||||
case 'install':
|
||||
if (!empty($crt_db_plugin))
|
||||
if (!empty($crt_db_plugin) or !isset($this->fs_plugins[$plugin_id]))
|
||||
{
|
||||
array_push($errors, 'CANNOT INSTALL - ALREADY INSTALLED');
|
||||
break;
|
||||
}
|
||||
if (!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))
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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}&action=deactivate">{'Deactivate'|@translate}</a>
|
||||
| <a href="{$plugin.U_ACTION}&action=restore" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Restore'|@translate}</a>
|
||||
|
||||
{elseif $plugin_state == 'inactive'}
|
||||
<a href="{$plugin.U_ACTION}&action=activate" {if $plugin.INCOMPATIBLE}class="incompatible"{/if}>{'Activate'|@translate}</a>
|
||||
| <a href="{$plugin.U_ACTION}&action=uninstall" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Uninstall'|@translate}</a>
|
||||
|
||||
{elseif $plugin_state == 'uninstalled'}
|
||||
<a href="{$plugin.U_ACTION}&action=install">{'Install'|@translate}</a>
|
||||
| <a href="{$plugin.U_ACTION}&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}&action=delete" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Delete'|@translate}</a>
|
||||
|
||||
{elseif $plugin_state == 'missing'}
|
||||
<a href="{$plugin.U_ACTION}&action=uninstall" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Uninstall'|@translate}</a>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue