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. git-svn-id: http://piwigo.org/svn/trunk@10538 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
e1fd6aa04b
commit
f5ef4fddd7
6 changed files with 91 additions and 7 deletions
|
@ -1,13 +1,37 @@
|
||||||
{combine_script id='jquery.cluetip' load='async' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'}
|
{combine_script id='jquery.cluetip' load='async' require='jquery' path='themes/default/js/plugins/jquery.cluetip.js'}
|
||||||
|
|
||||||
{footer_script require='jquery.cluetip'}
|
{footer_script require='jquery.cluetip'}
|
||||||
jQuery().ready(function(){ldelim}
|
var piwigo_need_update_msg = '<a href="admin.php?page=updates">{"A new version of Piwigo is available."|@translate|@escape:"javascript"}</a>';
|
||||||
jQuery('.cluetip').cluetip({ldelim}
|
var ext_need_update_msg = '<a href="admin.php?page=updates&tab=ext">{"Some upgrades are available for extensions."|@translate|@escape:"javascript"}</a>';
|
||||||
|
|
||||||
|
{literal}
|
||||||
|
jQuery().ready(function(){
|
||||||
|
jQuery('.cluetip').cluetip({
|
||||||
width: 300,
|
width: 300,
|
||||||
splitTitle: '|',
|
splitTitle: '|',
|
||||||
positionBy: 'bottomTop'
|
positionBy: 'bottomTop'
|
||||||
});
|
});
|
||||||
|
jQuery.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: 'ws.php',
|
||||||
|
dataType: 'json',
|
||||||
|
data: { method: 'pwg.extensions.checkUpdates', format: 'json' },
|
||||||
|
timeout: 5000,
|
||||||
|
success: function (data) {
|
||||||
|
if (data['stat'] != 'ok')
|
||||||
|
return;
|
||||||
|
piwigo_update = data['result']['piwigo_need_update'];
|
||||||
|
ext_update = data['result']['ext_need_update']
|
||||||
|
if ((piwigo_update || ext_update) && !jQuery(".warnings").is('div'))
|
||||||
|
jQuery("#content").prepend('<div class="warnings"><ul></ul></div>');
|
||||||
|
if (piwigo_update)
|
||||||
|
jQuery(".warnings ul").append('<li>'+piwigo_need_update_msg+'</li>');
|
||||||
|
if (ext_update)
|
||||||
|
jQuery(".warnings ul").append('<li>'+ext_need_update_msg+'</li>');
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
{/literal}
|
||||||
{/footer_script}
|
{/footer_script}
|
||||||
|
|
||||||
<h2>{'Piwigo Administration'|@translate}</h2>
|
<h2>{'Piwigo Administration'|@translate}</h2>
|
||||||
|
|
|
@ -29,6 +29,13 @@ function updateAll() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function ignoreAll() {
|
||||||
|
jQuery('.ignoreExtension').each( function() {
|
||||||
|
if (jQuery(this).parents('div').css('display') == 'block')
|
||||||
|
jQuery(this).click();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
function resetIgnored() {
|
function resetIgnored() {
|
||||||
jQuery.ajax({
|
jQuery.ajax({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
|
@ -39,6 +46,7 @@ function resetIgnored() {
|
||||||
if (data['stat'] == 'ok') {
|
if (data['stat'] == 'ok') {
|
||||||
jQuery(".pluginBox, fieldset").show();
|
jQuery(".pluginBox, fieldset").show();
|
||||||
jQuery("#update_all").show();
|
jQuery("#update_all").show();
|
||||||
|
jQuery("#ignore_all").show();
|
||||||
jQuery("#up_to_date").hide();
|
jQuery("#up_to_date").hide();
|
||||||
jQuery("#reset_ignore").hide();
|
jQuery("#reset_ignore").hide();
|
||||||
jQuery("#ignored").hide();
|
jQuery("#ignored").hide();
|
||||||
|
@ -67,6 +75,7 @@ function checkFieldsets() {
|
||||||
|
|
||||||
if (total == 0) {
|
if (total == 0) {
|
||||||
jQuery("#update_all").hide();
|
jQuery("#update_all").hide();
|
||||||
|
jQuery("#ignore_all").hide();
|
||||||
jQuery("#up_to_date").show();
|
jQuery("#up_to_date").show();
|
||||||
}
|
}
|
||||||
if (ignored > 0) {
|
if (ignored > 0) {
|
||||||
|
@ -96,7 +105,7 @@ function updateExtension(type, id, revision) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function ignoreExtension(type, id) {
|
function ignoreExtension(type, id) {
|
||||||
jQuery.ajax({
|
queuedManager.add({
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
url: 'ws.php',
|
url: 'ws.php',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
|
@ -137,10 +146,11 @@ checkFieldsets();
|
||||||
<div class="autoupdate_bar">
|
<div class="autoupdate_bar">
|
||||||
<br>
|
<br>
|
||||||
<input type="submit" id="update_all" value="{'Update All'|@translate}" onClick="updateAll(); return false;">
|
<input type="submit" id="update_all" value="{'Update All'|@translate}" onClick="updateAll(); return false;">
|
||||||
|
<input type="submit" id="ignore_all" value="{'Ignore All'|@translate}" onClick="ignoreAll(); return false;">
|
||||||
<input type="submit" id="reset_ignore" value="{'Reset ignored updates'|@translate}" onClick="resetIgnored(); return false;" {if !$SHOW_RESET}style="display:none;"{/if}>
|
<input type="submit" id="reset_ignore" value="{'Reset ignored updates'|@translate}" onClick="resetIgnored(); return false;" {if !$SHOW_RESET}style="display:none;"{/if}>
|
||||||
</div>
|
</div>
|
||||||
<div class="autoupdate_bar" style="display:none;">
|
<div class="autoupdate_bar" style="display:none;">
|
||||||
{'Update in progress... Please wait.'|@translate}<br><img src="admin/themes/default/images/ajax-loader-bar.gif">
|
{'Please wait...'|@translate}<br><img src="admin/themes/default/images/ajax-loader-bar.gif">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p id="up_to_date" style="display:none; text-align:left; margin-left:20px;">{'All extensions are up to date.'|@translate}</p>
|
<p id="up_to_date" style="display:none; text-align:left; margin-left:20px;">{'All extensions are up to date.'|@translate}</p>
|
||||||
|
@ -159,7 +169,7 @@ checkFieldsets();
|
||||||
<td>
|
<td>
|
||||||
<a href="#" onClick="updateExtension('plugins', '{$plugin.EXT_ID}', {$plugin.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
|
<a href="#" onClick="updateExtension('plugins', '{$plugin.EXT_ID}', {$plugin.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
|
||||||
| <a href="{$plugin.URL_DOWNLOAD}">{'Download'|@translate}</a>
|
| <a href="{$plugin.URL_DOWNLOAD}">{'Download'|@translate}</a>
|
||||||
| <a href="#" onClick="ignoreExtension('plugins', '{$plugin.EXT_ID}'); return false;">{'Ignore this update'|@translate}</a>
|
| <a href="#" onClick="ignoreExtension('plugins', '{$plugin.EXT_ID}'); return false;" class="ignoreExtension">{'Ignore this update'|@translate}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -201,7 +211,7 @@ checkFieldsets();
|
||||||
<td>
|
<td>
|
||||||
<a href="#" onClick="updateExtension('themes', '{$theme.EXT_ID}', {$theme.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
|
<a href="#" onClick="updateExtension('themes', '{$theme.EXT_ID}', {$theme.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
|
||||||
| <a href="{$theme.URL_DOWNLOAD}">{'Download'|@translate}</a>
|
| <a href="{$theme.URL_DOWNLOAD}">{'Download'|@translate}</a>
|
||||||
| <a href="#" onClick="ignoreExtension('themes', '{$theme.EXT_ID}'); return false;">{'Ignore this update'|@translate}</a>
|
| <a href="#" onClick="ignoreExtension('themes', '{$theme.EXT_ID}'); return false;" class="ignoreExtension">{'Ignore this update'|@translate}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -243,7 +253,7 @@ checkFieldsets();
|
||||||
<td>
|
<td>
|
||||||
<a href="#" onClick="updateExtension('languages', '{$language.EXT_ID}', {$language.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
|
<a href="#" onClick="updateExtension('languages', '{$language.EXT_ID}', {$language.REVISION_ID});" class="updateExtension">{'Install'|@translate}</a>
|
||||||
| <a href="{$language.URL_DOWNLOAD}">{'Download'|@translate}</a>
|
| <a href="{$language.URL_DOWNLOAD}">{'Download'|@translate}</a>
|
||||||
| <a href="#" onClick="ignoreExtension('languages', '{$language.EXT_ID}'); return false;">{'Ignore this update'|@translate}</a>
|
| <a href="#" onClick="ignoreExtension('languages', '{$language.EXT_ID}'); return false;" class="ignoreExtension">{'Ignore this update'|@translate}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -2845,6 +2845,7 @@ function ws_extensions_ignoreupdate($params, &$service)
|
||||||
|
|
||||||
$conf['updates_ignored'] = unserialize($conf['updates_ignored']);
|
$conf['updates_ignored'] = unserialize($conf['updates_ignored']);
|
||||||
|
|
||||||
|
// Reset ignored extension
|
||||||
if ($params['reset'])
|
if ($params['reset'])
|
||||||
{
|
{
|
||||||
$conf['updates_ignored'] = array(
|
$conf['updates_ignored'] = array(
|
||||||
|
@ -2871,4 +2872,40 @@ function ws_extensions_ignoreupdate($params, &$service)
|
||||||
unset($_SESSION['extensions_need_update']);
|
unset($_SESSION['extensions_need_update']);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ws_extensions_checkupdates($params, &$service)
|
||||||
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
|
define('IN_ADMIN', true);
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||||
|
include_once(PHPWG_ROOT_PATH.'admin/include/updates.class.php');
|
||||||
|
$update = new updates();
|
||||||
|
|
||||||
|
if (!is_admin())
|
||||||
|
{
|
||||||
|
return new PwgError(401, 'Access denied');
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = array();
|
||||||
|
|
||||||
|
if (!isset($_SESSION['need_update']))
|
||||||
|
$update->check_piwigo_upgrade();
|
||||||
|
|
||||||
|
$result['piwigo_need_update'] = $_SESSION['need_update'];
|
||||||
|
|
||||||
|
$conf['updates_ignored'] = unserialize($conf['updates_ignored']);
|
||||||
|
|
||||||
|
if (!isset($_SESSION['extensions_need_update']))
|
||||||
|
$update->check_extensions();
|
||||||
|
else
|
||||||
|
$update->check_updated_extensions();
|
||||||
|
|
||||||
|
if (!is_array($_SESSION['extensions_need_update']))
|
||||||
|
$result['ext_need_update'] = null;
|
||||||
|
else
|
||||||
|
$result['ext_need_update'] = !empty($_SESSION['extensions_need_update']);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -822,4 +822,7 @@ $lang['Include history data (Warning: server memory limit may be exceeded)'] = '
|
||||||
$lang['Unable to write new local directory.'] = 'Unable to write new local directory.';
|
$lang['Unable to write new local directory.'] = 'Unable to write new local directory.';
|
||||||
$lang['Unable to send template directory.'] = 'Unable to send template directory.';
|
$lang['Unable to send template directory.'] = 'Unable to send template directory.';
|
||||||
$lang['Unable to dump database.'] = 'Unable to dump database.';
|
$lang['Unable to dump database.'] = 'Unable to dump database.';
|
||||||
|
$lang['Some upgrades are available for extensions.'] = 'Some upgrades are available for extensions.';
|
||||||
|
$lang['Please wait...'] = 'Please wait...';
|
||||||
|
$lang['Ignore All'] = 'Ignore All';
|
||||||
?>
|
?>
|
|
@ -833,4 +833,7 @@ $lang['Include history data (Warning: server memory limit may be exceeded)'] = '
|
||||||
$lang['Unable to write new local directory.'] = 'Impossible d\'écrire le nouveau dossier local.';
|
$lang['Unable to write new local directory.'] = 'Impossible d\'écrire le nouveau dossier local.';
|
||||||
$lang['Unable to send template directory.'] = 'Impossible d\'envoyer le dossier template.';
|
$lang['Unable to send template directory.'] = 'Impossible d\'envoyer le dossier template.';
|
||||||
$lang['Unable to dump database.'] = 'Impossible de sauvegarder la base de données.';
|
$lang['Unable to dump database.'] = 'Impossible de sauvegarder la base de données.';
|
||||||
|
$lang['Some upgrades are available for extensions.'] = 'Des mises à jour sont disponibles pour les extensions.';
|
||||||
|
$lang['Please wait...'] = 'Please wait...';
|
||||||
|
$lang['Ignore All'] = 'Tout ignorer';
|
||||||
?>
|
?>
|
7
ws.php
7
ws.php
|
@ -445,6 +445,13 @@ function ws_addDefaultMethods( $arr )
|
||||||
<br>Parameter type must be "plugins", "languages" or "themes".
|
<br>Parameter type must be "plugins", "languages" or "themes".
|
||||||
<br>If reset parameter is true, all ignored extensions will be reinitilized.'
|
<br>If reset parameter is true, all ignored extensions will be reinitilized.'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$service->addMethod(
|
||||||
|
'pwg.extensions.checkUpdates',
|
||||||
|
'ws_extensions_checkupdates',
|
||||||
|
array(),
|
||||||
|
'Check if piwigo or extensions are up to date.'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
add_event_handler('ws_add_methods', 'ws_addDefaultMethods');
|
add_event_handler('ws_add_methods', 'ws_addDefaultMethods');
|
||||||
|
|
Loading…
Reference in a new issue