Changeset 10293


Ignore:
Timestamp:
Apr 11, 2011, 12:30:56 PM (10 years ago)
Author:
patdenice
Message:

feature:2260
Keep only two states for plugins (active and inactive)

Location:
trunk/admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/plugins.class.php

    r10129 r10293  
    7979    {
    8080      case 'install':
    81         if (!empty($crt_db_plugin))
    82         {
    83           array_push($errors, 'CANNOT INSTALL - ALREADY INSTALLED');
    84           break;
    85         }
    86         if (!isset($this->fs_plugins[$plugin_id]))
    87         {
    88           array_push($errors, 'CANNOT INSTALL - NO SUCH PLUGIN');
     81        if (!empty($crt_db_plugin) or !isset($this->fs_plugins[$plugin_id]))
     82        {
    8983          break;
    9084        }
     
    110104        if (!isset($crt_db_plugin))
    111105        {
    112           array_push($errors, 'CANNOT ACTIVATE - NOT INSTALLED');
     106          $errors = $this->perform_action('install', $plugin_id);
     107        }
     108        elseif ($crt_db_plugin['state'] == 'active')
     109        {
    113110          break;
    114111        }
    115         if ($crt_db_plugin['state'] != 'inactive')
    116         {
    117           array_push($errors, 'invalid current state ' . $crt_db_plugin['state']);
    118           break;
    119         }
    120         if (file_exists($file_to_include))
     112        if (empty($errors) and file_exists($file_to_include))
    121113        {
    122114          include_once($file_to_include);
     
    137129
    138130      case 'deactivate':
    139         if (!isset($crt_db_plugin))
    140         {
    141           die ('CANNOT DEACTIVATE - NOT INSTALLED');
    142         }
    143         if ($crt_db_plugin['state'] != 'active')
    144         {
    145           die('invalid current state ' . $crt_db_plugin['state']);
     131        if (!isset($crt_db_plugin) or $crt_db_plugin['state'] != 'active')
     132        {
     133          break;
    146134        }
    147135        $query = '
     
    161149        if (!isset($crt_db_plugin))
    162150        {
    163           die ('CANNOT UNINSTALL - NOT INSTALLED');
     151          break;
     152        }
     153        if ($crt_db_plugin['state'] == 'active')
     154        {
     155          $this->perform_action('deactivate', $plugin_id);
    164156        }
    165157        $query = '
     
    176168        break;
    177169
     170      case 'restore':
     171        $this->perform_action('uninstall', $plugin_id);
     172        unset($this->db_plugins_by_id[$plugin_id]);
     173        $errors = $this->perform_action('activate', $plugin_id);
     174        break;
     175
    178176      case 'delete':
    179177        if (!empty($crt_db_plugin))
    180178        {
    181           array_push($errors, 'CANNOT DELETE - PLUGIN IS INSTALLED');
    182           break;
     179          $this->perform_action('uninstall', $plugin_id);
    183180        }
    184181        if (!isset($this->fs_plugins[$plugin_id]))
    185182        {
    186           array_push($errors, 'CANNOT DELETE - NO SUCH PLUGIN');
    187183          break;
    188184        }
  • trunk/admin/plugins_list.php

    r10128 r10293  
    9898  else
    9999  {
    100     $tpl_plugin['STATE'] = 'uninstalled';
     100    $tpl_plugin['STATE'] = 'inactive';
    101101  }
    102102
    103103  if (isset($fs_plugin['extension']) and in_array($fs_plugin['extension'], $_SESSION['merged_extensions']))
    104104  {
    105     switch($tpl_plugin['STATE'])
    106     {
    107       case 'active': $plugins->perform_action('deactivate', $plugin_id);
    108       case 'inactive': $plugins->perform_action('uninstall', $plugin_id);
    109     }
     105    $plugins->perform_action('uninstall', $plugin_id);
    110106    $tpl_plugin['STATE'] = 'merged';
    111107    $tpl_plugin['DESC'] = l10n('THIS PLUGIN IS NOW PART OF PIWIGO CORE! DELETE IT NOW.');
     
    118114$template->append('plugin_states', 'active');
    119115$template->append('plugin_states', 'inactive');
    120 $template->append('plugin_states', 'uninstalled');
    121116
    122117if ($merged_plugins)
  • trunk/admin/themes/default/template/plugins_list.tpl

    r10113 r10293  
    3232  {'Inactive Plugins'|@translate}
    3333
    34   {elseif $plugin_state == 'uninstalled'}
    35   {'Uninstalled Plugins'|@translate}
    36 
    3734  {elseif $plugin_state == 'missing'}
    3835  {'Missing Plugins'|@translate}
     
    5754    {if $plugin.STATE == 'active'}
    5855          <a href="{$plugin.U_ACTION}&amp;action=deactivate">{'Deactivate'|@translate}</a>
     56          | <a href="{$plugin.U_ACTION}&amp;action=restore" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Restore'|@translate}</a>
    5957
    6058    {elseif $plugin_state == 'inactive'}
    6159          <a href="{$plugin.U_ACTION}&amp;action=activate" {if $plugin.INCOMPATIBLE}class="incompatible"{/if}>{'Activate'|@translate}</a>
    62           | <a href="{$plugin.U_ACTION}&amp;action=uninstall" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Uninstall'|@translate}</a>
    63 
    64     {elseif $plugin_state == 'uninstalled'}
    65           <a href="{$plugin.U_ACTION}&amp;action=install">{'Install'|@translate}</a>
    66           | <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>
     60          | <a href="{$plugin.U_ACTION}&amp;action=delete" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Delete'|@translate}</a>
    6761
    6862    {elseif $plugin_state == 'missing'}
Note: See TracChangeset for help on using the changeset viewer.