Changeset 10293 for trunk/admin/include


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

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

File:
1 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        }
Note: See TracChangeset for help on using the changeset viewer.