mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-20 08:33:03 +02:00
merge r10098,r10100,r10101,r10113,r10128,r10129 from trunk to branch 2.2
feature:2250 Incompatible plugins and obsolete plugins may not be activated. Deactivate and uninstall obsolete plugins. Add warning icon and tiptip Add languages keys. Add expire parameter. Clean code. Remove useless query for delete. git-svn-id: http://piwigo.org/svn/branches/2.2@10131 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
+115
-17
@@ -26,6 +26,7 @@ class plugins
|
||||
var $fs_plugins = array();
|
||||
var $db_plugins_by_id = array();
|
||||
var $server_plugins = array();
|
||||
var $default_plugins = array('LocalFilesEditor', 'language_switch', 'c13y_upgrade', 'admin_multi_view');
|
||||
|
||||
/**
|
||||
* Initialize $fs_plugins and $db_plugins_by_id
|
||||
@@ -283,23 +284,12 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve PEM server datas to $server_plugins
|
||||
*/
|
||||
function get_server_plugins($new=false)
|
||||
// Retrieve PEM versions
|
||||
function get_versions_to_check($version=PHPWG_VERSION)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$get_data = array(
|
||||
'category_id' => 12,
|
||||
'format' => 'php',
|
||||
);
|
||||
|
||||
// Retrieve PEM versions
|
||||
$version = PHPWG_VERSION;
|
||||
$versions_to_check = array();
|
||||
$url = PEM_URL . '/api/get_version_list.php';
|
||||
if (fetchRemote($url, $result, $get_data) and $pem_versions = @unserialize($result))
|
||||
$url = PEM_URL . '/api/get_version_list.php?category=12&format=php';
|
||||
if (fetchRemote($url, $result) and $pem_versions = @unserialize($result))
|
||||
{
|
||||
if (!preg_match('/^\d+\.\d+\.\d+/', $version))
|
||||
{
|
||||
@@ -314,6 +304,17 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
|
||||
}
|
||||
}
|
||||
}
|
||||
return $versions_to_check;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve PEM server datas to $server_plugins
|
||||
*/
|
||||
function get_server_plugins($new=false)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$versions_to_check = $this->get_versions_to_check();
|
||||
if (empty($versions_to_check))
|
||||
{
|
||||
return false;
|
||||
@@ -331,12 +332,13 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
|
||||
|
||||
// Retrieve PEM plugins infos
|
||||
$url = PEM_URL . '/api/get_revision_list.php';
|
||||
$get_data = array_merge($get_data, array(
|
||||
$get_data = array(
|
||||
'category_id' => 12,
|
||||
'format' => 'php',
|
||||
'last_revision_only' => 'true',
|
||||
'version' => implode(',', $versions_to_check),
|
||||
'lang' => substr($user['language'], 0, 2),
|
||||
'get_nb_downloads' => 'true',
|
||||
)
|
||||
);
|
||||
|
||||
if (!empty($plugins_to_check))
|
||||
@@ -365,6 +367,74 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function get_incompatible_plugins($actualize=false)
|
||||
{
|
||||
if (isset($_SESSION['incompatible_plugins']) and !$actualize
|
||||
and $_SESSION['incompatible_plugins']['~~expire~~'] > time())
|
||||
{
|
||||
return $_SESSION['incompatible_plugins'];
|
||||
}
|
||||
|
||||
$_SESSION['incompatible_plugins'] = array('~~expire~~' => time() + 300);
|
||||
|
||||
$versions_to_check = $this->get_versions_to_check();
|
||||
if (empty($versions_to_check))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Plugins to check
|
||||
$plugins_to_check = array();
|
||||
foreach($this->fs_plugins as $fs_plugin)
|
||||
{
|
||||
if (isset($fs_plugin['extension']))
|
||||
{
|
||||
$plugins_to_check[] = $fs_plugin['extension'];
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve PEM plugins infos
|
||||
$url = PEM_URL . '/api/get_revision_list.php';
|
||||
$get_data = array(
|
||||
'category_id' => 12,
|
||||
'format' => 'php',
|
||||
'version' => implode(',', $versions_to_check),
|
||||
'extension_include' => implode(',', $plugins_to_check),
|
||||
);
|
||||
|
||||
if (fetchRemote($url, $result, $get_data))
|
||||
{
|
||||
$pem_plugins = @unserialize($result);
|
||||
if (!is_array($pem_plugins))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$server_plugins = array();
|
||||
foreach ($pem_plugins as $plugin)
|
||||
{
|
||||
if (!isset($server_plugins[$plugin['extension_id']]))
|
||||
{
|
||||
$server_plugins[$plugin['extension_id']] = array();
|
||||
}
|
||||
array_push($server_plugins[$plugin['extension_id']], $plugin['revision_name']);
|
||||
}
|
||||
|
||||
foreach ($this->fs_plugins as $plugin_id => $fs_plugin)
|
||||
{
|
||||
if (isset($fs_plugin['extension'])
|
||||
and !in_array($plugin_id, $this->default_plugins)
|
||||
and $fs_plugin['version'] != 'auto'
|
||||
and (!isset($server_plugins[$fs_plugin['extension']]) or !in_array($fs_plugin['version'], $server_plugins[$fs_plugin['extension']])))
|
||||
{
|
||||
$_SESSION['incompatible_plugins'][$plugin_id] = $fs_plugin['version'];
|
||||
}
|
||||
}
|
||||
return $_SESSION['incompatible_plugins'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort $server_plugins
|
||||
@@ -483,6 +553,34 @@ DELETE FROM ' . PLUGINS_TABLE . ' WHERE id=\'' . $plugin_id . '\'';
|
||||
@unlink($archive);
|
||||
return $status;
|
||||
}
|
||||
|
||||
function get_merged_extensions($version=PHPWG_VERSION)
|
||||
{
|
||||
if (isset($_SESSION['merged_extensions']) and $_SESSION['merged_extensions']['~~expire~~'] > time())
|
||||
{
|
||||
return $_SESSION['merged_extensions'];
|
||||
}
|
||||
|
||||
$_SESSION['merged_extensions'] = array('~~expire~~' => time() + 600);
|
||||
|
||||
if (fetchRemote(PHPWG_URL.'/download/merged_extensions.txt', $result))
|
||||
{
|
||||
$rows = explode("\n", $result);
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
if (preg_match('/^(\d+\.\d+): *(.*)$/', $row, $match))
|
||||
{
|
||||
if (version_compare($version, $match[1], '>='))
|
||||
{
|
||||
$extensions = explode(',', trim($match[2]));
|
||||
$_SESSION['merged_extensions'] = array_merge($_SESSION['merged_extensions'], $extensions);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $_SESSION['merged_extensions'];
|
||||
}
|
||||
|
||||
/**
|
||||
* delete $path directory
|
||||
|
||||
+46
-19
@@ -67,9 +67,19 @@ $plugins->set_tabsheet($page['page']);
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
$plugins->sort_fs_plugins('name');
|
||||
$plugins->get_merged_extensions();
|
||||
$plugins->get_incompatible_plugins();
|
||||
$merged_plugins = false;
|
||||
|
||||
foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
|
||||
{
|
||||
if (isset($_SESSION['incompatible_plugins'][$plugin_id])
|
||||
and $fs_plugin['version'] != $_SESSION['incompatible_plugins'][$plugin_id])
|
||||
{
|
||||
// Incompatible plugins must be reinitilized
|
||||
$plugins->get_incompatible_plugins(true);
|
||||
}
|
||||
|
||||
$tpl_plugin = array(
|
||||
'NAME' => $fs_plugin['name'],
|
||||
'VISIT_URL' => $fs_plugin['uri'],
|
||||
@@ -77,7 +87,8 @@ foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
|
||||
'DESC' => $fs_plugin['description'],
|
||||
'AUTHOR' => $fs_plugin['author'],
|
||||
'AUTHOR_URL' => @$fs_plugin['author uri'],
|
||||
'U_ACTION' => sprintf($action_url, $plugin_id)
|
||||
'U_ACTION' => sprintf($action_url, $plugin_id),
|
||||
'INCOMPATIBLE' => isset($_SESSION['incompatible_plugins'][$plugin_id]),
|
||||
);
|
||||
|
||||
if (isset($plugins->db_plugins_by_id[$plugin_id]))
|
||||
@@ -89,34 +100,50 @@ foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
|
||||
$tpl_plugin['STATE'] = 'uninstalled';
|
||||
}
|
||||
|
||||
if (isset($fs_plugin['extension']) and in_array($fs_plugin['extension'], $_SESSION['merged_extensions']))
|
||||
{
|
||||
switch($tpl_plugin['STATE'])
|
||||
{
|
||||
case 'active': $plugins->perform_action('deactivate', $plugin_id);
|
||||
case 'inactive': $plugins->perform_action('uninstall', $plugin_id);
|
||||
}
|
||||
$tpl_plugin['STATE'] = 'merged';
|
||||
$tpl_plugin['DESC'] = l10n('THIS PLUGIN IS NOW PART OF PIWIGO CORE! DELETE IT NOW.');
|
||||
$merged_plugins = true;
|
||||
}
|
||||
|
||||
$template->append('plugins', $tpl_plugin);
|
||||
}
|
||||
|
||||
$template->append('plugin_states', 'active');
|
||||
$template->append('plugin_states', 'inactive');
|
||||
$template->append('plugin_states', 'uninstalled');
|
||||
|
||||
if ($merged_plugins)
|
||||
{
|
||||
$template->append('plugin_states', 'merged');
|
||||
}
|
||||
|
||||
$missing_plugin_ids = array_diff(
|
||||
array_keys($plugins->db_plugins_by_id),
|
||||
array_keys($plugins->fs_plugins)
|
||||
);
|
||||
|
||||
foreach($missing_plugin_ids as $plugin_id)
|
||||
{
|
||||
$template->append(
|
||||
'plugins',
|
||||
array(
|
||||
'NAME' => $plugin_id,
|
||||
'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'],
|
||||
'DESC' => "ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW !",
|
||||
'U_ACTION' => sprintf($action_url, $plugin_id),
|
||||
'STATE' => 'missing',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$template->append('plugin_states', 'active');
|
||||
$template->append('plugin_states', 'inactive');
|
||||
$template->append('plugin_states', 'uninstalled');
|
||||
|
||||
if (count($missing_plugin_ids) > 0)
|
||||
{
|
||||
foreach($missing_plugin_ids as $plugin_id)
|
||||
{
|
||||
$template->append(
|
||||
'plugins',
|
||||
array(
|
||||
'NAME' => $plugin_id,
|
||||
'VERSION' => $plugins->db_plugins_by_id[$plugin_id]['version'],
|
||||
'DESC' => l10n('ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW.'),
|
||||
'U_ACTION' => sprintf($action_url, $plugin_id),
|
||||
'STATE' => 'missing',
|
||||
)
|
||||
);
|
||||
}
|
||||
$template->append('plugin_states', 'missing');
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 680 B |
Binary file not shown.
|
After Width: | Height: | Size: 680 B |
@@ -1,3 +1,21 @@
|
||||
{footer_script}
|
||||
var incompatible_msg = '{'WARNING! This plugin does not seem to be compatible with this version of Piwigo.'|@translate|@escape:'javascript'}';
|
||||
incompatible_msg += '\n';
|
||||
incompatible_msg += '{'Do you want to activate anyway?'|@translate|@escape:'javascript'}';
|
||||
|
||||
{literal}
|
||||
jQuery(document).ready(function() {
|
||||
jQuery('.incompatible').click(function() {
|
||||
return confirm(incompatible_msg);
|
||||
});
|
||||
jQuery('.warning').tipTip({
|
||||
'delay' : 0,
|
||||
'fadeIn' : 200,
|
||||
'fadeOut' : 200
|
||||
});
|
||||
});
|
||||
{/literal}{/footer_script}
|
||||
|
||||
<div class="titrePage">
|
||||
<h2>{'Plugins'|@translate}</h2>
|
||||
</div>
|
||||
@@ -19,6 +37,9 @@
|
||||
{elseif $plugin_state == 'missing'}
|
||||
{'Missing Plugins'|@translate}
|
||||
|
||||
{elseif $plugin_state == 'merged'}
|
||||
{'Obsolete Plugins'|@translate}
|
||||
|
||||
{/if}
|
||||
</legend>
|
||||
{foreach from=$plugins item=plugin name=plugins_loop}
|
||||
@@ -26,7 +47,9 @@
|
||||
<div class="pluginBox">
|
||||
<table>
|
||||
<tr>
|
||||
<td class="pluginBoxNameCell">{$plugin.NAME}</td>
|
||||
<td class="pluginBoxNameCell{if $plugin.INCOMPATIBLE} warning" title="{'WARNING! This plugin does not seem to be compatible with this version of Piwigo.'|@translate|@escape:'html'}{/if}">
|
||||
{$plugin.NAME}
|
||||
</td>
|
||||
<td>{$plugin.DESC}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -35,7 +58,7 @@
|
||||
<a href="{$plugin.U_ACTION}&action=deactivate">{'Deactivate'|@translate}</a>
|
||||
|
||||
{elseif $plugin_state == 'inactive'}
|
||||
<a href="{$plugin.U_ACTION}&action=activate">{'Activate'|@translate}</a>
|
||||
<a href="{$plugin.U_ACTION}&action=activate" {if $plugin.INCOMPATIBLE}class="incompatible"{/if}>{'Activate'|@translate}</a>
|
||||
| <a href="{$plugin.U_ACTION}&action=uninstall" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Uninstall'|@translate}</a>
|
||||
|
||||
{elseif $plugin_state == 'uninstalled'}
|
||||
@@ -45,6 +68,8 @@
|
||||
{elseif $plugin_state == 'missing'}
|
||||
<a href="{$plugin.U_ACTION}&action=uninstall" onclick="return confirm('{'Are you sure?'|@translate|@escape:'javascript'}');">{'Uninstall'|@translate}</a>
|
||||
|
||||
{elseif $plugin_state == 'merged'}
|
||||
<a href="{$plugin.U_ACTION}&action=delete">{'Delete'|@translate}</a>
|
||||
{/if}
|
||||
</td>
|
||||
<td>
|
||||
|
||||
@@ -1043,3 +1043,9 @@ LEGEND {
|
||||
#batchManagerGlobal .removeFilter span {display:none}
|
||||
#batchManagerGlobal #applyFilterBlock {margin-top:20px;}
|
||||
#batchManagerGlobal .useFilterCheckbox {display:none}
|
||||
|
||||
.warning {
|
||||
background:url(icon/warning.png) no-repeat top left;
|
||||
width: 130px;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
@@ -157,7 +157,6 @@ else
|
||||
define('PEM_URL', 'http://'.PHPWG_DOMAIN.'/ext');
|
||||
}
|
||||
|
||||
|
||||
// language files
|
||||
load_language('common.lang');
|
||||
if ( is_admin() || (defined('IN_ADMIN') and IN_ADMIN) )
|
||||
|
||||
@@ -777,4 +777,9 @@ $lang['All languages are up to date.'] = 'All languages are up to date.';
|
||||
$lang['Visit theme site'] = 'Visit theme site';
|
||||
$lang['Visit language site'] = 'Visit language site';
|
||||
$lang['New Version'] = 'New Version';
|
||||
$lang['Obsolete Plugins'] = 'Obsolete Plugins';
|
||||
$lang['WARNING! This plugin does not seem to be compatible with this version of Piwigo.'] = 'WARNING! This plugin does not seem to be compatible with this version of Piwigo.';
|
||||
$lang['Do you want to activate anyway?'] = 'Do you want to activate anyway?';
|
||||
$lang['THIS PLUGIN IS NOW PART OF PIWIGO CORE! DELETE IT NOW.'] = 'THIS PLUGIN IS NOW PART OF PIWIGO CORE! UNINSTALL IT NOW!';
|
||||
$lang['ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW.'] = 'ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW.';
|
||||
?>
|
||||
@@ -788,4 +788,9 @@ $lang['All languages are up to date.'] = 'Toutes les langues sont à jour.';
|
||||
$lang['Visit theme site'] = 'Visitez le site du thème';
|
||||
$lang['Visit language site'] = 'Visitez le site de la langue';
|
||||
$lang['New Version'] = 'Nouvelle version';
|
||||
$lang['Obsolete Plugins'] = 'Plugins obsolètes';
|
||||
$lang['WARNING! This plugin does not seem to be compatible with this version of Piwigo.'] = 'ATTENTION! Ce plugin n\'a pas l\'air d\'être compatible avec votre version de Piwigo.';
|
||||
$lang['Do you want to activate anyway?'] = 'Voulez-vous l\'activer quand même?';
|
||||
$lang['THIS PLUGIN IS NOW PART OF PIWIGO CORE! DELETE IT NOW.'] = 'CE PLUGIN FAIT DÉSORMAIS PARTIE DU CORE DE PIWIGO! SUPPRIMEZ-LE.';
|
||||
$lang['ERROR: THIS PLUGIN IS MISSING BUT IT IS INSTALLED! UNINSTALL IT NOW.'] = 'ERREUR: CE PLUGIN EST MANQUANT MAIS TOUJOURS INSTALLÉ! DÉSINSTALLEZ-LE.';
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user