Changeset 10511


Ignore:
Timestamp:
Apr 20, 2011, 4:52:52 PM (9 years ago)
Author:
patdenice
Message:

feature:2271
Merge autoupdate plugin into piwigo core.

Location:
trunk
Files:
9 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin.php

    r9368 r10511  
    169169    'U_CHANGE_THEME' => PHPWG_ROOT_PATH.'admin.php?change_theme=1',
    170170    'U_PENDING_COMMENTS' => $link_start.'comments',
     171    'U_UPDATES' => $link_start.'updates',
    171172    )
    172173  );
  • trunk/admin/include/functions.php

    r10110 r10511  
    20862086    case 'thumbnail':
    20872087    case 'comments':
     2088    case 'updates':
    20882089      return 4;
    20892090
  • trunk/admin/themes/default/template/admin.tpl

    r10503 r10511  
    7676        <li><a href="{$U_MAINTENANCE}">{'Maintenance'|@translate}</a></li>
    7777        <li><a href="{$U_PENDING_COMMENTS}">{'Pending Comments'|@translate}</a></li>
     78        <li><a href="{$U_UPDATES}">{'Updates'|@translate}</a></li>
    7879      </ul>
    7980    </dd>
  • trunk/include/ws_functions.inc.php

    r10454 r10511  
    27362736  return false;
    27372737}
     2738
     2739function ws_extensions_update($params, &$service)
     2740{
     2741  if (!is_webmaster())
     2742  {
     2743    return new PwgError(401, l10n('Webmaster status is required.'));
     2744  }
     2745
     2746  if (empty($params['pwg_token']) or get_pwg_token() != $params['pwg_token'])
     2747  {
     2748    return new PwgError(403, 'Invalid security token');
     2749  }
     2750
     2751  if (empty($params['type']) or !in_array($params['type'], array('plugins', 'themes', 'languages')))
     2752  {
     2753    return new PwgError(403, "invalid extension type");
     2754  }
     2755
     2756  if (empty($params['id']) or empty($params['revision']))
     2757  {
     2758    return new PwgError(null, 'Wrong parameters');
     2759  }
     2760
     2761  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     2762  include_once(PHPWG_ROOT_PATH.'admin/include/'.$params['type'].'.class.php');
     2763
     2764  $type = $params['type'];
     2765  $extension_id = $params['id'];
     2766  $revision = $params['revision'];
     2767
     2768  $extension = new $type();
     2769
     2770  if ($type == 'plugins')
     2771  {
     2772    if (isset($extension->db_plugins_by_id[$extension_id]) and $extension->db_plugins_by_id[$extension_id]['state'] == 'active')
     2773    {
     2774      $extension->perform_action('deactivate', $extension_id);
     2775
     2776      redirect(PHPWG_ROOT_PATH
     2777        . 'ws.php'
     2778        . '?method=pwg.extensions.update'
     2779        . '&type=plugins'
     2780        . '&id=' . $extension_id
     2781        . '&revision=' . $revision
     2782        . '&reactivate=true'
     2783        . '&pwg_token=' . get_pwg_token()
     2784        . '&format=json'
     2785      );
     2786    }
     2787   
     2788    $upgrade_status = $extension->extract_plugin_files('upgrade', $revision, $extension_id);
     2789    $extension_name = $extension->fs_plugins[$extension_id]['name'];
     2790
     2791    if (isset($params['reactivate']))
     2792    {
     2793      $extension->perform_action('activate', $extension_id);
     2794    }
     2795  }
     2796  elseif ($type == 'themes')
     2797  {
     2798    $upgrade_status = $extension->extract_theme_files('upgrade', $revision, $extension_id);
     2799    $extension_name = $extension->fs_themes[$extension_id]['name'];
     2800  }
     2801  elseif ($type == 'languages')
     2802  {
     2803    $upgrade_status = $extension->extract_language_files('upgrade', $revision, $extension_id);
     2804    $extension_name = $extension->fs_languages[$extension_id]['name'];
     2805  }
     2806
     2807  global $template;
     2808  $template->delete_compiled_templates();
     2809
     2810  switch ($upgrade_status)
     2811  {
     2812    case 'ok':
     2813      return sprintf(l10n('%s has been successfully updated.'), $extension_name);
     2814
     2815    case 'temp_path_error':
     2816      return new PwgError(null, l10n('Can\'t create temporary file.'));
     2817
     2818    case 'dl_archive_error':
     2819      return new PwgError(null, l10n('Can\'t download archive.'));
     2820
     2821    case 'archive_error':
     2822      return new PwgError(null, l10n('Can\'t read or extract archive.'));
     2823
     2824    default:
     2825      return new PwgError(null, sprintf(l10n('An error occured during extraction (%s).'), $upgrade_status));
     2826  }
     2827}
     2828
     2829function ws_extensions_ignoreupdate($params, &$service)
     2830{
     2831  global $conf;
     2832
     2833  define('IN_ADMIN', true);
     2834  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     2835
     2836  if (!is_webmaster())
     2837  {
     2838    return new PwgError(401, 'Access denied');
     2839  }
     2840
     2841  if (empty($params['pwg_token']) or get_pwg_token() != $params['pwg_token'])
     2842  {
     2843    return new PwgError(403, 'Invalid security token');
     2844  }
     2845
     2846  $conf['updates_ignored'] = unserialize($conf['updates_ignored']);
     2847
     2848  if ($params['reset'])
     2849  {
     2850    $conf['updates_ignored'] = array(
     2851      'plugins'=>array(),
     2852      'themes'=>array(),
     2853      'languages'=>array()
     2854    );
     2855    conf_update_param('updates_ignored', pwg_db_real_escape_string(serialize($conf['updates_ignored'])));
     2856    unset($_SESSION['extensions_need_update']);
     2857    return true;
     2858  }
     2859
     2860  if (empty($params['id']) or empty($params['type']) or !in_array($params['type'], array('plugins', 'themes', 'languages')))
     2861  {
     2862    return new PwgError(403, 'Invalid parameters');
     2863  }
     2864
     2865  // Add or remove extension from ignore list
     2866  if (!in_array($params['id'], $conf['updates_ignored'][$params['type']]))
     2867  {
     2868    array_push($conf['updates_ignored'][$params['type']], $params['id']);
     2869  }
     2870  conf_update_param('updates_ignored', pwg_db_real_escape_string(serialize($conf['updates_ignored'])));
     2871  unset($_SESSION['extensions_need_update']);
     2872  return true;
     2873}
    27382874?>
  • trunk/install/config.sql

    r10122 r10511  
    5050  );
    5151INSERT INTO piwigo_config (param,value,comment) VALUES ('week_starts_on','monday','Monday may not be the first day of the week');
     52INSERT INTO piwigo_config (param,value,comment) VALUES ('updates_ignored','a:3:{s:7:"plugins";a:0:{}s:6:"themes";a:0:{}s:9:"languages";a:0:{}}','Extensions ignored for update');
  • trunk/language/en_UK/admin.lang.php

    r10455 r10511  
    797797$lang['%s photos can not be regenerated'] = '%s photos can not be regenerated';
    798798$lang['Only photos with HD can be regenerated!'] = 'Only photos with HD can be regenerated!';
     799
     800$lang['Updates'] = 'Updates';
     801$lang['Update in progress... Please wait.'] = 'Update in progress... Please wait.';
     802$lang['Ignore this update'] = 'Ignore this update';
     803$lang['Reset ignored updates'] = 'Reset ignored updates';
     804$lang['Update All'] = 'Update All';
     805$lang['ERROR'] = 'ERROR';
     806$lang['Update Complete'] = 'Update Complete';
     807$lang['Piwigo Update'] = 'Piwigo Update';
     808$lang['Extensions Update'] = 'Extensions Update';
     809$lang['All extensions are up to date.'] = 'All extensions are up to date.';
     810$lang['Following plugins may not be compatible with the new version of Piwigo:'] = 'Following plugins may not be compatible with the new version of Piwigo:';
     811$lang['Following themes may not be compatible with the new version of Piwigo:'] = 'Following themes may not be compatible with the new version of Piwigo:';
     812$lang['I decide to update anyway'] = 'I decide to update anyway';
     813$lang['Update to Piwigo %s'] = 'Update to Piwigo %s';
     814$lang['Two updates are available'] = 'Two updates are available';
     815$lang['This is a minor update, with only bug corrections.'] = 'This is a minor update, with only bug corrections.';
     816$lang['This is a major update, with <a href="%s">new exciting features</a>.'] = 'This is a major update, with <a href="%s">new exciting features</a>.';
     817$lang['Some themes and plugins may be not available yet.'] = 'Some themes and plugins may be not available yet.';
     818$lang['You can update to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'You can update to Piwigo %s directly, without upgrading to Piwigo %s (recommended).';
     819$lang['Save Template Directory'] = 'Save template directory';
     820$lang['Dump Database'] = 'Dump Database';
     821$lang['Include history data (Warning: server memory limit may be exceeded)'] = 'Include history data (Warning: server memory limit may be exceeded)';
     822$lang['Unable to write new local directory.'] = 'Unable to write new local directory.';
     823$lang['Unable to send template directory.'] = 'Unable to send template directory.';
     824$lang['Unable to dump database.'] = 'Unable to dump database.';
    799825?>
  • trunk/language/fr_FR/admin.lang.php

    r10455 r10511  
    808808$lang['%s photos can not be regenerated'] = '%s photos ne peuvent pas être régénérées';
    809809$lang['Only photos with HD can be regenerated!'] = 'Seules les photos avec HD peuvent être régénérées';
     810
     811$lang['Updates'] = 'Mises à jour';
     812$lang['Update in progress... Please wait.'] = 'Mise à jour en cours... Veuillez patienter.';
     813$lang['Ignore this update'] = 'Ignorer cette mise à jour';
     814$lang['Reset ignored updates'] = 'Réinitialiser les mises à jour ignorées';
     815$lang['Update All'] = 'Tout mettre à jour';
     816$lang['ERROR'] = 'ERREUR';
     817$lang['Update Complete'] = 'Mise à jour effectuée';
     818$lang['Piwigo Update'] = 'Mise à jour de Piwigo';
     819$lang['Extensions Update'] = 'Mise à jour des extensions';
     820$lang['All extensions are up to date.'] = 'Toutes les extensions sont à jour.';
     821$lang['Following plugins may not be compatible with the new version of Piwigo:'] = 'Les plugins suivants ne seront peut-être pas compatibles avec la nouvelle version de Piwigo:';
     822$lang['Following themes may not be compatible with the new version of Piwigo:'] = 'Les thèmes suivants ne seront peut-être pas compatibles avec la nouvelle version de Piwigo:';
     823$lang['I decide to update anyway'] = 'Je décide de migrer quand même';
     824$lang['Update to Piwigo %s'] = 'Mettre à jour vers Piwigo %s';
     825$lang['Two updates are available'] = 'Deux mises à jour sont disponibles';
     826$lang['This is a minor update, with only bug corrections.'] = 'Ceci est une mise à jour mineure, avec uniquement des corrections de bugs.';
     827$lang['This is a major update, with <a href="%s">new exciting features</a>.'] = 'Ceci est une mise à jour majeure, qui contient <a href="%s">un tas de nouveautés</a>.';
     828$lang['Some themes and plugins may be not available yet.'] = 'Certains thèmes ou plugins ne sont peut-être pas encore disponibles.';
     829$lang['You can update to Piwigo %s directly, without upgrading to Piwigo %s (recommended).'] = 'Vous pouvez mettre à jour vers Piwigo %s directement, sans passer par Piwigo %s (recommandé).';
     830$lang['Save Template Directory'] = 'Sauvegarder le dossier template';
     831$lang['Dump Database'] = 'Sauvegarder la base de données';
     832$lang['Include history data (Warning: server memory limit may be exceeded)'] = 'Inclure les données de l\'historique (Attention: risque de dépassement de la limite mémoire du serveur)';
     833$lang['Unable to write new local directory.'] = 'Impossible d\'écrire le nouveau dossier local.';
     834$lang['Unable to send template directory.'] = 'Impossible d\'envoyer le dossier template.';
     835$lang['Unable to dump database.'] = 'Impossible de sauvegarder la base de données.';
    810836?>
  • trunk/ws.php

    r10502 r10511  
    419419<br>If maxwidth, maxheight or quality are missing, default parameters of upload will be used.'
    420420);
     421
     422  $service->addMethod(
     423    'pwg.extensions.update',
     424    'ws_extensions_update',
     425    array(
     426      'type' => array(),
     427      'id' => array(),
     428      'revision'=> array(),
     429      'pwg_token' => array(),
     430    ),
     431    'Update an extension. Webmaster only.
     432<br>Parameter type must be "plugins", "languages" or "themes".'
     433  );
     434
     435  $service->addMethod(
     436    'pwg.extensions.ignoreUpdate',
     437    'ws_extensions_ignoreupdate',
     438    array(
     439      'type' => array('default'=>null),
     440      'id' => array('default'=>null),
     441      'reset' => array('default'=>null),
     442      'pwg_token' => array(),
     443    ),
     444    'Ignore an extension if it need update.
     445<br>Parameter type must be "plugins", "languages" or "themes".
     446<br>If reset parameter is true, all ignored extensions will be reinitilized.'
     447  );
    421448}
    422449
Note: See TracChangeset for help on using the changeset viewer.