Changeset 10037


Ignore:
Timestamp:
04/04/11 16:09:03 (7 years ago)
Author:
patdenice
Message:

Don't deactivate autoupdate when update itself.
Check merged extensions.

Location:
extensions/autoupdate/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/autoupdate/trunk/include/autoupdate.class.php

    r10028 r10037  
    1313  var $default_themes = array(); 
    1414  var $default_languages = array(); 
     15  var $merged_extensions = array(); 
     16  var $merged_extension_url = 'http://piwigo.org/download/merged_extensions.txt'; 
    1517 
    1618  function autoupdate() 
     
    198200      foreach ($this->$type->$fs as $ext_id => $ext) 
    199201      { 
    200         if (isset($ext['extension']) and $id == $ext['extension'] and !in_array($ext_id, $this->$default)) 
     202        if (isset($ext['extension']) and $id == $ext['extension'] 
     203          and !in_array($ext_id, $this->$default) 
     204          and !in_array($ext['extension'], $this->merged_extensions)) 
    201205        { 
    202206          $this->missing[$type][] = $ext; 
     
    207211  } 
    208212 
     213  function get_merged_extensions($version) 
     214  { 
     215    if (fetchRemote($this->merged_extension_url, $result)) 
     216    { 
     217      $rows = explode("\n", $result); 
     218      foreach ($rows as $row) 
     219      { 
     220        if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match)) 
     221        { 
     222          if (version_compare($version, $match[1], '>=')) 
     223          { 
     224            $extensions = explode(',', trim($match[2])); 
     225            $this->merged_extensions = array_merge($this->merged_extensions, $extensions); 
     226          } 
     227        } 
     228      } 
     229    } 
     230  } 
     231 
    209232  function version_compare($a, $b, $type) 
    210233  { 
  • extensions/autoupdate/trunk/update_pwg.inc.php

    r10028 r10037  
    118118  include_once(AUTOUPDATE_PATH.'include/autoupdate.class.php'); 
    119119  $autoupdate = new autoupdate(); 
     120  $autoupdate->get_merged_extensions($upgrade_to); 
    120121  $autoupdate->get_server_extensions($upgrade_to); 
    121122  $template->assign('missing', $autoupdate->missing); 
  • extensions/autoupdate/trunk/ws_functions.inc.php

    r9947 r10037  
    7373  $plugins = new plugins(); 
    7474 
    75   if (isset($params['upgradestatus']) and isset($params['id'])) 
    76   { 
    77     switch ($params['upgradestatus']) 
    78     { 
    79       case 'ok': 
    80         return sprintf(l10n('%s has been successfully upgraded.'), $plugins->fs_plugins[$params['id']]['name']); 
    81  
    82       case 'temp_path_error': 
    83         return new PwgError(null, l10n('Can\'t create temporary file.')); 
    84  
    85       case 'dl_archive_error': 
    86         return new PwgError(null, l10n('Can\'t download archive.')); 
    87  
    88       case 'archive_error': 
    89         return new PwgError(null, l10n('Can\'t read or extract archive.')); 
    90  
    91       default: 
    92         return new PwgError(null, sprintf(l10n('An error occured during extraction (%s).'), $params['upgradestatus'])); 
    93     } 
    94   } 
    95  
    9675  if (empty($params['id']) or empty($params['revision'])) 
    9776  { 
     
    10382 
    10483  if (isset($plugins->db_plugins_by_id[$plugin_id]) 
    105     and $plugins->db_plugins_by_id[$plugin_id]['state'] == 'active') 
     84    and $plugins->db_plugins_by_id[$plugin_id]['state'] == 'active' 
     85    and $plugin_id != 'autoupdate') 
    10686  { 
    10787    $plugins->perform_action('deactivate', $plugin_id); 
     
    128108  $template->delete_compiled_templates(); 
    129109 
    130   redirect(PHPWG_ROOT_PATH 
    131     . 'ws.php' 
    132     . '?method=pwg.plugins.update' 
    133     . '&revision=' . $revision 
    134     . '&id=' . $plugin_id 
    135     . '&upgradestatus='.$upgrade_status 
    136     . '&pwg_token=' . get_pwg_token() 
    137     . '&format=json' 
    138   ); 
     110  switch ($upgrade_status) 
     111  { 
     112    case 'ok': 
     113      return sprintf(l10n('%s has been successfully upgraded.'), $plugins->fs_plugins[$plugin_id]['name']); 
     114 
     115    case 'temp_path_error': 
     116      return new PwgError(null, l10n('Can\'t create temporary file.')); 
     117 
     118    case 'dl_archive_error': 
     119      return new PwgError(null, l10n('Can\'t download archive.')); 
     120 
     121    case 'archive_error': 
     122      return new PwgError(null, l10n('Can\'t read or extract archive.')); 
     123 
     124    default: 
     125      return new PwgError(null, sprintf(l10n('An error occured during extraction (%s).'), $upgrade_status)); 
     126  } 
    139127} 
    140128 
Note: See TracChangeset for help on using the changeset viewer.