Changeset 10538 for trunk


Ignore:
Timestamp:
Apr 21, 2011, 5:12:38 PM (13 years ago)
Author:
patdenice
Message:

feature:2271
Add pwg.extensions.checkUpdates method to webservices.
Add a warning message on intro page if update is availble for piwigo or extensions.
Add an "Ignore All" button on extensions update page.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/themes/default/template/intro.tpl

    r9553 r10538  
    22
    33{footer_script require='jquery.cluetip'}
    4 jQuery().ready(function(){ldelim}
    5         jQuery('.cluetip').cluetip({ldelim}
     4var piwigo_need_update_msg = '<a href="admin.php?page=updates">{"A new version of Piwigo is available."|@translate|@escape:"javascript"}</a>';
     5var ext_need_update_msg = '<a href="admin.php?page=updates&amp;tab=ext">{"Some upgrades are available for extensions."|@translate|@escape:"javascript"}</a>';
     6
     7{literal}
     8jQuery().ready(function(){
     9        jQuery('.cluetip').cluetip({
    610                width: 300,
    711                splitTitle: '|',
    812                positionBy: 'bottomTop'
    913        });
     14  jQuery.ajax({
     15    type: 'GET',
     16    url: 'ws.php',
     17    dataType: 'json',
     18    data: { method: 'pwg.extensions.checkUpdates', format: 'json' },
     19    timeout: 5000,
     20    success: function (data) {
     21      if (data['stat'] != 'ok')
     22        return;
     23      piwigo_update = data['result']['piwigo_need_update'];
     24      ext_update = data['result']['ext_need_update']
     25      if ((piwigo_update || ext_update) && !jQuery(".warnings").is('div'))
     26        jQuery("#content").prepend('<div class="warnings"><ul></ul></div>');
     27      if (piwigo_update)
     28        jQuery(".warnings ul").append('<li>'+piwigo_need_update_msg+'</li>');
     29      if (ext_update)
     30        jQuery(".warnings ul").append('<li>'+ext_need_update_msg+'</li>');
     31    }
     32  }); 
    1033});
     34{/literal}
    1135{/footer_script}
    1236
  • trunk/admin/themes/default/template/updates_ext.tpl

    r10512 r10538  
    2828    });
    2929  }
     30};
     31
     32function ignoreAll() {
     33  jQuery('.ignoreExtension').each( function() {
     34    if (jQuery(this).parents('div').css('display') == 'block')
     35      jQuery(this).click();
     36  });
    3037};
    3138
     
    4047        jQuery(".pluginBox, fieldset").show();
    4148        jQuery("#update_all").show();
     49        jQuery("#ignore_all").show();
    4250        jQuery("#up_to_date").hide();
    4351        jQuery("#reset_ignore").hide();
     
    6876  if (total == 0) {
    6977    jQuery("#update_all").hide();
     78    jQuery("#ignore_all").hide();
    7079    jQuery("#up_to_date").show();
    7180  }
     
    97106
    98107function ignoreExtension(type, id) {
    99   jQuery.ajax({
     108  queuedManager.add({
    100109    type: 'GET',
    101110    url: 'ws.php',
     
    138147<br>
    139148<input type="submit" id="update_all" value="{'Update All'|@translate}" onClick="updateAll(); return false;">
     149<input type="submit" id="ignore_all" value="{'Ignore All'|@translate}" onClick="ignoreAll(); return false;">
    140150<input type="submit" id="reset_ignore" value="{'Reset ignored updates'|@translate}" onClick="resetIgnored(); return false;" {if !$SHOW_RESET}style="display:none;"{/if}>
    141151</div>
    142152<div class="autoupdate_bar" style="display:none;">
    143 {'Update in progress... Please wait.'|@translate}<br><img src="admin/themes/default/images/ajax-loader-bar.gif">
     153{'Please wait...'|@translate}<br><img src="admin/themes/default/images/ajax-loader-bar.gif">
    144154</div>
    145155
     
    160170        <a href="#" onClick="updateExtension('plugins', '{$plugin.EXT_ID}', {$plugin.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
    161171        | <a href="{$plugin.URL_DOWNLOAD}">{'Download'|@translate}</a>
    162         | <a href="#" onClick="ignoreExtension('plugins', '{$plugin.EXT_ID}'); return false;">{'Ignore this update'|@translate}</a>
     172        | <a href="#" onClick="ignoreExtension('plugins', '{$plugin.EXT_ID}'); return false;" class="ignoreExtension">{'Ignore this update'|@translate}</a>
    163173      </td>
    164174    </tr>
     
    202212        <a href="#" onClick="updateExtension('themes', '{$theme.EXT_ID}', {$theme.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
    203213        | <a href="{$theme.URL_DOWNLOAD}">{'Download'|@translate}</a>
    204         | <a href="#" onClick="ignoreExtension('themes', '{$theme.EXT_ID}'); return false;">{'Ignore this update'|@translate}</a>
     214        | <a href="#" onClick="ignoreExtension('themes', '{$theme.EXT_ID}'); return false;" class="ignoreExtension">{'Ignore this update'|@translate}</a>
    205215      </td>
    206216    </tr>
     
    244254        <a href="#" onClick="updateExtension('languages', '{$language.EXT_ID}', {$language.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
    245255        | <a href="{$language.URL_DOWNLOAD}">{'Download'|@translate}</a>
    246         | <a href="#" onClick="ignoreExtension('languages', '{$language.EXT_ID}'); return false;">{'Ignore this update'|@translate}</a>
     256        | <a href="#" onClick="ignoreExtension('languages', '{$language.EXT_ID}'); return false;" class="ignoreExtension">{'Ignore this update'|@translate}</a>
    247257      </td>
    248258    </tr>
  • trunk/include/ws_functions.inc.php

    r10511 r10538  
    28462846  $conf['updates_ignored'] = unserialize($conf['updates_ignored']);
    28472847
     2848  // Reset ignored extension
    28482849  if ($params['reset'])
    28492850  {
     
    28722873  return true;
    28732874}
     2875
     2876function ws_extensions_checkupdates($params, &$service)
     2877{
     2878  global $conf;
     2879
     2880  define('IN_ADMIN', true);
     2881  include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
     2882  include_once(PHPWG_ROOT_PATH.'admin/include/updates.class.php');
     2883  $update = new updates();
     2884
     2885  if (!is_admin())
     2886  {
     2887    return new PwgError(401, 'Access denied');
     2888  }
     2889
     2890  $result = array();
     2891
     2892  if (!isset($_SESSION['need_update']))
     2893    $update->check_piwigo_upgrade();
     2894
     2895  $result['piwigo_need_update'] = $_SESSION['need_update'];
     2896
     2897  $conf['updates_ignored'] = unserialize($conf['updates_ignored']);
     2898
     2899  if (!isset($_SESSION['extensions_need_update']))
     2900    $update->check_extensions();
     2901  else
     2902    $update->check_updated_extensions();
     2903
     2904  if (!is_array($_SESSION['extensions_need_update']))
     2905    $result['ext_need_update'] = null;
     2906  else
     2907    $result['ext_need_update'] = !empty($_SESSION['extensions_need_update']);
     2908
     2909  return $result;
     2910}
    28742911?>
  • trunk/language/en_UK/admin.lang.php

    r10511 r10538  
    823823$lang['Unable to send template directory.'] = 'Unable to send template directory.';
    824824$lang['Unable to dump database.'] = 'Unable to dump database.';
     825$lang['Some upgrades are available for extensions.'] = 'Some upgrades are available for extensions.';
     826$lang['Please wait...'] = 'Please wait...';
     827$lang['Ignore All'] = 'Ignore All';
    825828?>
  • trunk/language/fr_FR/admin.lang.php

    r10511 r10538  
    834834$lang['Unable to send template directory.'] = 'Impossible d\'envoyer le dossier template.';
    835835$lang['Unable to dump database.'] = 'Impossible de sauvegarder la base de données.';
     836$lang['Some upgrades are available for extensions.'] = 'Des mises à jour sont disponibles pour les extensions.';
     837$lang['Please wait...'] = 'Please wait...';
     838$lang['Ignore All'] = 'Tout ignorer';
    836839?>
  • trunk/ws.php

    r10511 r10538  
    446446<br>If reset parameter is true, all ignored extensions will be reinitilized.'
    447447  );
     448
     449  $service->addMethod(
     450    'pwg.extensions.checkUpdates',
     451    'ws_extensions_checkupdates',
     452    array(),
     453    'Check if piwigo or extensions are up to date.'
     454  );
    448455}
    449456
Note: See TracChangeset for help on using the changeset viewer.