X-Git-Url: http://git.cyclocoop.org/?p=lhc%2Fweb%2Fclavette_www.git;a=blobdiff_plain;f=www%2Fplugins-dist%2Fsvp%2Finc%2Fsvp_decider.php;h=a3dcc18503527c7efa3ac9309ff704d48799a312;hp=b2326ecc22f0d8a0ee4ace24737717bd00b29968;hb=2f46f5ab9fc0d68a164a1b8025de099896b5586e;hpb=a6c56ccc18c7140954d9601a75e4b8a04de00263 diff --git a/www/plugins-dist/svp/inc/svp_decider.php b/www/plugins-dist/svp/inc/svp_decider.php index b2326ec..a3dcc18 100644 --- a/www/plugins-dist/svp/inc/svp_decider.php +++ b/www/plugins-dist/svp/inc/svp_decider.php @@ -420,36 +420,45 @@ class Decideur { * tableau de description du paquet le plus récent sinon */ function chercher_plugin_compatible($prefixe, $version) { - + $plugin = array(); + // on choisit en priorite dans les paquets locaux ! $locaux = $this->infos_courtes(array( 'pl.prefixe=' . sql_quote($prefixe), 'pa.obsolete=' . sql_quote('non'), 'pa.id_depot='.sql_quote(0)), true); if ($locaux and isset($locaux['p'][$prefixe]) and count($locaux['p'][$prefixe]) > 0) { + $v = '000.000.000'; foreach ($locaux['p'][$prefixe] as $new) { if (plugin_version_compatible($version, $new['v']) - and svp_verifier_compatibilite_spip($new['compatibilite_spip']) ){ - return $new; + and svp_verifier_compatibilite_spip($new['compatibilite_spip']) + and ($new['v'] > $v)){ + $plugin = $new; + $v = $new['v']; } } } - - // sinon dans les paquets distants - $distants = $this->infos_courtes(array( - 'pl.prefixe=' . sql_quote($prefixe), - 'pa.obsolete=' . sql_quote('non'), - 'pa.id_depot>'.sql_quote(0)), true); - if ($distants and isset($distants['p'][$prefixe]) and count($distants['p'][$prefixe]) > 0) { - foreach ($distants['p'][$prefixe] as $new) { - if (plugin_version_compatible($version, $new['v']) - and svp_verifier_compatibilite_spip($new['compatibilite_spip']) ){ - return $new; + + if (!$plugin) { + // sinon dans les paquets distants + $distants = $this->infos_courtes(array( + 'pl.prefixe=' . sql_quote($prefixe), + 'pa.obsolete=' . sql_quote('non'), + 'pa.id_depot>'.sql_quote(0)), true); + if ($distants and isset($distants['p'][$prefixe]) and count($distants['p'][$prefixe]) > 0) { + $v = '000.000.000'; + foreach ($distants['p'][$prefixe] as $new) { + if (plugin_version_compatible($version, $new['v']) + and svp_verifier_compatibilite_spip($new['compatibilite_spip']) + and ($new['v'] > $v)){ + $plugin = $new; + $v = $new['v']; + } } } } - - return false; + + return ($plugin ? $plugin : false); }