très mauvaise idée, qui revient directement à rendre l'exclusion inopérante.
Il suffit de faire ?page=article&id_article=XX
pour passer outre l'exclusion du coup.
Cédric
Le 24 août 09 à 14:14, maieulrouquette@sfr.fr a écrit :
Author: maieulrouquette@sfr.fr
Date: Mon Aug 24 14:14:54 2009
New Revision: 31090Log:
permettre que si on passe explicitement l'id cela annule l'exclusion par secteur->c'est configurable (à documenter)Modified:
_plugins_/exclure_secteur/exclurepip.php
_plugins_/exclure_secteur/fonds/cfg_secteur.html
_plugins_/exclure_secteur/inc/exclure_utils.php
_plugins_/exclure_secteur/plugin.xmlModified: _plugins_/exclure_secteur/exclurepip.php
--- _plugins_/exclure_secteur/exclurepip.php (original)
+++ _plugins_/exclure_secteur/exclurepip.php Mon Aug 24 14:14:54 2009
@@ -2,6 +2,7 @@
include_spip('inc/exclure_utils');function exclure_sect_pre_boucle(&$boucle){
+
if ($boucle->modificateur['tout_voir'] or ($boucle->modificateur['tout'] and lire_config('secteur/tout') == 'oui') or test_espace_prive()==1){
return $boucle;
}
@@ -11,7 +12,7 @@
if ($type == 'articles' or $type == 'rubriques' or $type == 'syndic'){$crit = $boucle->criteres;
- $exclut = exclure_sect_choisir($crit);
+ $exclut = exclure_sect_choisir($crit,$type);
$boucle->where = array("'NOT IN'", "'$type.id_secteur'",sql_quote($exclut));}
@@ -19,14 +20,14 @@
if ($type == 'breves'){$crit = $boucle->criteres;
- $exclut = exclure_sect_choisir($crit);
+ $exclut = exclure_sect_choisir($crit,$type);
$boucle->where = array("'NOT IN'", "'$type.id_rubrique'",sql_quote($exclut));}
if ($type == 'forum'){
$crit = $boucle->criteres;
- $exclut = exclure_sect_choisir($crit);
+ $exclut = exclure_sect_choisir($crit,$type);
global $table_prefix;
$boucle->from['L1']=$table_prefix.'_articles';
$boucle->where = array("'NOT IN'", "'L1.id_secteur'",sql_quote($exclut));Modified: _plugins_/exclure_secteur/fonds/cfg_secteur.html
--- _plugins_/exclure_secteur/fonds/cfg_secteur.html (original)
+++ _plugins_/exclure_secteur/fonds/cfg_secteur.html Mon Aug 24 14:14:54 2009
@@ -22,13 +22,20 @@
</fieldset>
<fieldset>
<ul>
- <legend id="explication">Réglage avancé du plugin</legend>
+ <legend id="explication">Réglages avancés du plugin</legend><li>
<label for="tout">Est-ce que le critére <code>{tout}</code> est équivalent au critére <code>{tout_secteur}</code> ?</label>
<input type="checkbox" name="tout" value="oui"[(#ENV{tout}|=={oui}|oui) checked="checked"] />
</li>
+
+ <li>
+ <label for="idexplicite">Expliciter l'id sur lequel on boucle est-il équivalent à {tout_voir} (ne s'applique pas au '!' et aux critères de comparaison) </label>
+ <input type="checkbox" name="idexplicite" value="oui"[(#ENV{idexplicite}|=={oui}|oui) checked="checked"] />
</li>
+
+ </ul>
</fieldset>
<p class="boutons">
<input type="submit" name="_cfg_ok" value="<:OK:>" />Modified: _plugins_/exclure_secteur/inc/exclure_utils.php
--- _plugins_/exclure_secteur/inc/exclure_utils.php (original)
+++ _plugins_/exclure_secteur/inc/exclure_utils.php Mon Aug 24 14:14:54 2009
@@ -22,10 +22,46 @@
return false;
}-function exclure_sect_choisir($crit){
+function id_explicite($crit,$type){
+ //test de cfg
+ $cfg = lire_config('secteur/idexplicite');
+
+ if ($cfg == false){
+ return false;
+ }
+ $id = 'id_'.substr($type,0,-1);
+
+ foreach($crit as $critere){
+ if ($critere->param[0][0]->texte == $id and $critere->not!='!') {
+
+ switch ($critere->op){
+ case '=' :
+ return true;
+ case '==':
+ return true;
+ case 'IN':
+ return true;
+ }
+ }
+ if ($critere->op == $id and $critere->not!='!'){
+ return true;
+
+ }
+ }
+ return false;
+
+ //var_dump($crit);
+}
+
+function exclure_sect_choisir($crit,$type){
$cfg =lire_config('secteur/exclure_sect');
$sect_afficher = secteur_explicite($crit);
- if ($cfg = array_map('sql_quote', $cfg) and !$sect_afficher ) {
+ $id_explicite = id_explicite($crit,$type); //l'id de la table sur laquelle on boucle est-il explicite ?
+ if ($cfg = array_map('sql_quote', $cfg) and !$sect_afficher and !$id_explicite) {
$cfg = implode($cfg, ',');
}
else {Modified: _plugins_/exclure_secteur/plugin.xml
--- _plugins_/exclure_secteur/plugin.xml (original)
+++ _plugins_/exclure_secteur/plugin.xml Mon Aug 24 14:14:54 2009
@@ -5,10 +5,10 @@
Licence : GPL3
</auteur>
<version>
- 1.1.1
+ 1.2
</version>
<etat>
- test
+ stable
</etat>
<necessite id='CFG' />@@ -22,6 +22,8 @@
Possibilité aussi de configurer le plugin pour que <code>{tout}</code> soit équivalent à <code>{tout_voir}</code>.
+ On peut aussi configurer pour que que si l'id principal du nom de boucle est passée via <code>{id_boucle}</code> ou <code>{id_boucle==X}</code> ou <code>{id_boucle=X}</code> ou <code>{id_boucle IN X}</code>, cela fait sauter l'exclusion des secteurs. (Depuis la 1.2)
+_______________________________________________
Spip-zone-commit@rezo.net - http://listes.rezo.net/mailman/listinfo/spip-zone-commit