Skip to content
Extraits de code Groupes Projets
Valider 049e16c4 rédigé par Fil's avatar Fil
Parcourir les fichiers

critère {statut=...}

Ce critère permet de se débarrasser de la vérification par défaut du statut.
En gros, {statut IN publie,prop} permet de faire une boucle "spip indy".
parent 7f0d7ad2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -45,12 +45,16 @@ function boucle_ARTICLES_dist($id_boucle, &$boucles) { ...@@ -45,12 +45,16 @@ function boucle_ARTICLES_dist($id_boucle, &$boucles) {
$boucle = &$boucles[$id_boucle]; $boucle = &$boucles[$id_boucle];
$id_table = $boucle->id_table; $id_table = $boucle->id_table;
$boucle->from[] = "spip_articles AS $id_table"; $boucle->from[] = "spip_articles AS $id_table";
if (!$GLOBALS['var_preview']) {
$boucle->where[] = "$id_table.statut='publie'"; // Restreindre aux elements publies
if (lire_meta("post_dates") == 'non') if (!isset($boucle->where['statut'])) {
$boucle->where[] = "$id_table.date < NOW()"; if (!$GLOBALS['var_preview']) {
} else $boucle->where['statut'] = "$id_table.statut='publie'";
$boucle->where[] = "$id_table.statut IN ('publie','prop')"; if (lire_meta("post_dates") == 'non')
$boucle->where['statut'] .= " AND $id_table.date < NOW()";
} else
$boucle->where['statut'] = "$id_table.statut IN ('publie','prop')";
}
return calculer_boucle($id_boucle, $boucles); return calculer_boucle($id_boucle, $boucles);
} }
...@@ -61,19 +65,24 @@ function boucle_AUTEURS_dist($id_boucle, &$boucles) { ...@@ -61,19 +65,24 @@ function boucle_AUTEURS_dist($id_boucle, &$boucles) {
$boucle = &$boucles[$id_boucle]; $boucle = &$boucles[$id_boucle];
$id_table = $boucle->id_table; $id_table = $boucle->id_table;
$boucle->from[] = "spip_auteurs AS $id_table"; $boucle->from[] = "spip_auteurs AS $id_table";
// Si pas de lien avec un article, selectionner
// uniquement les auteurs d'un article publie // Restreindre aux elements publies
if (!$GLOBALS['var_preview']) if (!isset($boucle->where['statut'])) {
if (!$boucle->lien AND !$boucle->tout) { // Si pas de lien avec un article, selectionner
$boucle->from[] = "spip_auteurs_articles AS lien"; // uniquement les auteurs d'un article publie
$boucle->from[] = "spip_articles AS articles"; if (!$GLOBALS['var_preview'])
$boucle->where[] = "lien.id_auteur=$id_table.id_auteur"; if (!$boucle->lien AND !$boucle->tout) {
$boucle->where[] = 'lien.id_article=articles.id_article'; $boucle->from[] = "spip_auteurs_articles AS lien";
$boucle->where[] = "articles.statut='publie'"; $boucle->from[] = "spip_articles AS articles";
$boucle->group = $boucle->id_table . '.' . $boucle->primary; $boucle->where[] = "lien.id_auteur=$id_table.id_auteur";
$boucle->where[] = 'lien.id_article=articles.id_article';
$boucle->where['statut'] = "articles.statut='publie'";
$boucle->group = $boucle->id_table . '.' . $boucle->primary;
}
// pas d'auteurs poubellises
$boucle->where[] = "NOT($id_table.statut='5poubelle')";
} }
// pas d'auteurs poubellises
$boucle->where[] = "NOT($id_table.statut='5poubelle')";
return calculer_boucle($id_boucle, $boucles); return calculer_boucle($id_boucle, $boucles);
} }
...@@ -84,10 +93,15 @@ function boucle_BREVES_dist($id_boucle, &$boucles) { ...@@ -84,10 +93,15 @@ function boucle_BREVES_dist($id_boucle, &$boucles) {
$boucle = &$boucles[$id_boucle]; $boucle = &$boucles[$id_boucle];
$id_table = $boucle->id_table; $id_table = $boucle->id_table;
$boucle->from[] = "spip_breves AS $id_table"; $boucle->from[] = "spip_breves AS $id_table";
if (!$GLOBALS['var_preview'])
$boucle->where[] = "$id_table.statut='publie'"; // Restreindre aux elements publies
else if (!isset($boucle->where['statut'])) {
$boucle->where[] = "$id_table.statut IN ('publie','prop')"; if (!$GLOBALS['var_preview'])
$boucle->where['statut'] = "$id_table.statut='publie'";
else
$boucle->where['statut'] = "$id_table.statut IN ('publie','prop')";
}
return calculer_boucle($id_boucle, $boucles); return calculer_boucle($id_boucle, $boucles);
} }
...@@ -100,11 +114,14 @@ function boucle_FORUMS_dist($id_boucle, &$boucles) { ...@@ -100,11 +114,14 @@ function boucle_FORUMS_dist($id_boucle, &$boucles) {
$id_table = $boucle->id_table; $id_table = $boucle->id_table;
$boucle->from[] = "spip_forum AS $id_table"; $boucle->from[] = "spip_forum AS $id_table";
// Par defaut, selectionner uniquement les forums sans pere // Par defaut, selectionner uniquement les forums sans pere
if (!$boucle->tout AND !$boucle->plat) if (!$boucle->tout AND !$boucle->plat)
{ $boucle->where[] = "$id_table.id_parent=0";
$boucle->where[] = "$id_table.id_parent=0";
} // Restreindre aux elements publies
$boucle->where[] = "$id_table.statut='publie'"; if (!isset($boucle->where['statut'])) {
$boucle->where['statut'] = "$id_table.statut='publie'";
}
return calculer_boucle($id_boucle, $boucles); return calculer_boucle($id_boucle, $boucles);
} }
...@@ -120,7 +137,12 @@ function boucle_SIGNATURES_dist($id_boucle, &$boucles) { ...@@ -120,7 +137,12 @@ function boucle_SIGNATURES_dist($id_boucle, &$boucles) {
$boucle->from[] = "spip_articles articles"; $boucle->from[] = "spip_articles articles";
$boucle->where[] = "petitions.id_article=articles.id_article"; $boucle->where[] = "petitions.id_article=articles.id_article";
$boucle->where[] = "petitions.id_article=$id_table.id_article"; $boucle->where[] = "petitions.id_article=$id_table.id_article";
$boucle->where[] = "$id_table.statut='publie'";
// Restreindre aux elements publies
if (!isset($boucle->where['statut'])) {
$boucle->where['statut'] = "$id_table.statut='publie'";
}
$boucle->group = $boucle->id_table . '.' . $boucle->primary; $boucle->group = $boucle->id_table . '.' . $boucle->primary;
return calculer_boucle($id_boucle, $boucles); return calculer_boucle($id_boucle, $boucles);
} }
...@@ -182,8 +204,14 @@ function boucle_RUBRIQUES_dist($id_boucle, &$boucles) { ...@@ -182,8 +204,14 @@ function boucle_RUBRIQUES_dist($id_boucle, &$boucles) {
$boucle = &$boucles[$id_boucle]; $boucle = &$boucles[$id_boucle];
$id_table = $boucle->id_table; $id_table = $boucle->id_table;
$boucle->from[] = "spip_rubriques AS $id_table"; $boucle->from[] = "spip_rubriques AS $id_table";
if (!$GLOBALS['var_preview'])
if (!$boucle->tout) $boucle->where[] = "$id_table.statut='publie'"; // Restreindre aux elements publies
if (!isset($boucle->where['statut'])) {
if (!$GLOBALS['var_preview'])
if (!$boucle->tout)
$boucle->where['statut'] = "$id_table.statut='publie'";
}
return calculer_boucle($id_boucle, $boucles); return calculer_boucle($id_boucle, $boucles);
} }
...@@ -220,10 +248,15 @@ function boucle_SYNDICATION_dist($id_boucle, &$boucles) { ...@@ -220,10 +248,15 @@ function boucle_SYNDICATION_dist($id_boucle, &$boucles) {
$boucle = &$boucles[$id_boucle]; $boucle = &$boucles[$id_boucle];
$id_table = $boucle->id_table; $id_table = $boucle->id_table;
$boucle->from[] = "spip_syndic AS $id_table"; $boucle->from[] = "spip_syndic AS $id_table";
if (!$GLOBALS['var_preview']) {
$boucle->where[] = "$id_table.statut='publie'"; // Restreindre aux elements publies
} else if (!isset($boucle->where['statut'])) {
$boucle->where[] = "$id_table.statut IN ('publie','prop')"; if (!$GLOBALS['var_preview']) {
$boucle->where['statut'] = "$id_table.statut='publie'";
} else
$boucle->where['statut'] = "$id_table.statut IN ('publie','prop')";
}
return calculer_boucle($id_boucle, $boucles); return calculer_boucle($id_boucle, $boucles);
} }
...@@ -237,11 +270,16 @@ function boucle_SYNDIC_ARTICLES_dist($id_boucle, &$boucles) { ...@@ -237,11 +270,16 @@ function boucle_SYNDIC_ARTICLES_dist($id_boucle, &$boucles) {
$boucle->from[] = "spip_syndic_articles AS $id_table"; $boucle->from[] = "spip_syndic_articles AS $id_table";
$boucle->from[] = "spip_syndic AS syndic"; $boucle->from[] = "spip_syndic AS syndic";
$boucle->where[] = "$id_table.id_syndic=syndic.id_syndic"; $boucle->where[] = "$id_table.id_syndic=syndic.id_syndic";
if (!$GLOBALS['var_preview']) {
$boucle->where[] = "$id_table.statut='publie'"; // Restreindre aux elements publies
$boucle->where[] = "syndic.statut='publie'"; if (!isset($boucle->where['statut'])) {
} else if (!$GLOBALS['var_preview']) {
$boucle->where[] = "$id_table.statut IN ('publie','prop')"; $boucle->where['statut'] = "$id_table.statut='publie'";
$boucle->where[] = "syndic.statut='publie'";
} else
$boucle->where['statut'] = "$id_table.statut IN ('publie','prop')";
}
$boucle->select[]='syndic.nom_site AS nom_site'; # derogation zarbi $boucle->select[]='syndic.nom_site AS nom_site'; # derogation zarbi
$boucle->select[]='syndic.url_site AS url_site'; # idem $boucle->select[]='syndic.url_site AS url_site'; # idem
return calculer_boucle($id_boucle, $boucles); return calculer_boucle($id_boucle, $boucles);
......
...@@ -279,7 +279,17 @@ function critere_par_dist($idb, &$boucles, $param, $not) { ...@@ -279,7 +279,17 @@ function critere_par_dist($idb, &$boucles, $param, $not) {
} }
} }
// Le critere {statut=...}
// particularite : si on l'invoque dans une boucle il faut interdire
// a la boucle de mettre ses propres criteres de statut
// http://www.spip.net/@statut (a documenter)
function critere_statut_dist($idb, &$boucles, $param, $not) {
// interdire a function boucle_BOUCLE() de regler le statut
$boucle = &$boucles[$idb];
$boucle->where['statut'] = '1';
return calculer_critere_DEFAUT($idb, &$boucles, $param, $not);
}
function calculer_critere_parties($idb, &$boucles, $param, $not, $match) { function calculer_critere_parties($idb, &$boucles, $param, $not, $match) {
$boucle = &$boucles[$idb]; $boucle = &$boucles[$idb];
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter