X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=www%2Fecrire%2Fpublic%2Fcriteres.php;h=7108eaf19003aa3fd80f283ce3a09018f8d45ae1;hb=5be150361b3c836d9206941ba43f862df11466db;hp=562414a20b1ce7479bffe20ebc995dea535f1cbc;hpb=52cf8ed924d5dcd0c28dde4b6c3196be6ec2d4f7;p=ptitvelo%2Fweb%2Fwww.git diff --git a/www/ecrire/public/criteres.php b/www/ecrire/public/criteres.php index 562414a..7108eaf 100644 --- a/www/ecrire/public/criteres.php +++ b/www/ecrire/public/criteres.php @@ -3,7 +3,7 @@ /***************************************************************************\ * SPIP, Systeme de publication pour l'internet * * * - * Copyright (c) 2001-2012 * + * Copyright (c) 2001-2014 * * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * * * * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * @@ -1604,7 +1604,9 @@ function calculer_critere_infixe_date($idb, &$boucles, $col){ if (!preg_match(",^((age|jour|mois|annee)_relatif|date|mois|annee|jour|heure|age)(_[a-z]+)?$,", $col, $regs)) return ''; $boucle = $boucles[$idb]; $table = $boucle->show; - + // si c'est une colonne de la table, ne rien faire + if(isset($table['field'][$col])) return ''; + if (!$table['date'] && !isset($GLOBALS['table_date'][$table['id_table']])) return ''; $pred = $date_orig = isset($GLOBALS['table_date'][$table['id_table']])? $GLOBALS['table_date'][$table['id_table']] : $table['date']; $col = $regs[1]; @@ -1612,7 +1614,7 @@ function calculer_critere_infixe_date($idb, &$boucles, $col){ # Recherche de l'existence du champ date_xxxx, # si oui choisir ce champ, sinon choisir xxxx - if ($table['field']["date$suite"]) + if (isset($table['field']["date$suite"])) $date_orig = 'date'.$suite; else $date_orig = substr($suite, 1); @@ -1653,12 +1655,7 @@ function calculer_critere_infixe_date($idb, &$boucles, $col){ $col_vraie = "";// comparer a un int (par defaut) break; case 'jour_relatif': - $col = "LEAST(TO_DAYS(".$date_compare.")-TO_DAYS(". - $date_orig."), DAYOFMONTH(".$date_compare. - ")-DAYOFMONTH(".$date_orig.")+30.4368*(MONTH(". - $date_compare.")-MONTH(".$date_orig. - "))+365.2422*(YEAR(".$date_compare.")-YEAR(". - $date_orig.")))"; + $col = "(TO_DAYS(".$date_compare.")-TO_DAYS(".$date_orig."))"; $col_vraie = "";// comparer a un int (par defaut) break; case 'mois_relatif':