@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\SQL\Tables |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | include_spip('base/objets'); |
| 22 | 22 | |
@@ -64,138 +64,138 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | **/ |
| 66 | 66 | function base_trouver_table_dist($nom, $serveur = '', $table_spip = true) { |
| 67 | - static $nom_cache_desc_sql = array(); |
|
| 68 | - |
|
| 69 | - if (!spip_connect($serveur) |
|
| 70 | - or !preg_match('/^[a-zA-Z0-9._-]*/', $nom) |
|
| 71 | - ) { |
|
| 72 | - return null; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - $connexion = &$GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0]; |
|
| 76 | - $objets_sql = lister_tables_objets_sql("::md5"); |
|
| 77 | - |
|
| 78 | - // le nom du cache depend du serveur mais aussi du nom de la db et du prefixe |
|
| 79 | - // ce qui permet une auto invalidation en cas de modif manuelle du fichier |
|
| 80 | - // de connexion, et tout risque d'ambiguite |
|
| 81 | - if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])) { |
|
| 82 | - $nom_cache_desc_sql[$serveur][$objets_sql] = |
|
| 83 | - _DIR_CACHE . 'sql_desc_' |
|
| 84 | - . ($serveur ? "{$serveur}_" : "") |
|
| 85 | - . substr(md5($connexion['db'] . ":" . $connexion['prefixe'] . ":$objets_sql"), 0, 8) |
|
| 86 | - . '.txt'; |
|
| 87 | - // nouveau nom de cache = nouvelle version en memoire |
|
| 88 | - unset($connexion['tables']); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - // un appel avec $nom vide est une demande explicite de vidange du cache des descriptions |
|
| 92 | - if (!$nom) { |
|
| 93 | - spip_unlink($nom_cache_desc_sql[$serveur][$objets_sql]); |
|
| 94 | - $connexion['tables'] = array(); |
|
| 95 | - |
|
| 96 | - return null; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - $nom_sql = $nom; |
|
| 100 | - if (preg_match('/\.(.*)$/', $nom, $s)) { |
|
| 101 | - $nom_sql = $s[1]; |
|
| 102 | - } else { |
|
| 103 | - $nom_sql = $nom; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $fdesc = $desc = ''; |
|
| 107 | - $connexion = &$GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 108 | - |
|
| 109 | - // base sous SPIP: gerer les abreviations explicites des noms de table |
|
| 110 | - if ($connexion['spip_connect_version']) { |
|
| 111 | - if ($table_spip and isset($GLOBALS['table_des_tables'][$nom])) { |
|
| 112 | - $nom = $GLOBALS['table_des_tables'][$nom]; |
|
| 113 | - $nom_sql = 'spip_' . $nom; |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - // si c'est la premiere table qu'on cherche |
|
| 118 | - // et si on est pas explicitement en recalcul |
|
| 119 | - // on essaye de recharger le cache des decriptions de ce serveur |
|
| 120 | - // dans le fichier cache |
|
| 121 | - if (!isset($connexion['tables'][$nom_sql]) |
|
| 122 | - and defined('_VAR_MODE') and _VAR_MODE !== 'recalcul' |
|
| 123 | - and (!isset($connexion['tables']) or !$connexion['tables']) |
|
| 124 | - ) { |
|
| 125 | - if (lire_fichier($nom_cache_desc_sql[$serveur][$objets_sql], $desc_cache) |
|
| 126 | - and $desc_cache = unserialize($desc_cache) |
|
| 127 | - ) { |
|
| 128 | - $connexion['tables'] = $desc_cache; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - if ($table_spip and !isset($connexion['tables'][$nom_sql])) { |
|
| 132 | - |
|
| 133 | - if (isset($GLOBALS['tables_principales'][$nom_sql])) { |
|
| 134 | - $fdesc = $GLOBALS['tables_principales'][$nom_sql]; |
|
| 135 | - } |
|
| 136 | - // meme si pas d'abreviation declaree, trouver la table spip_$nom |
|
| 137 | - // si c'est une table principale, |
|
| 138 | - // puisqu'on le fait aussi pour les tables auxiliaires |
|
| 139 | - elseif ($nom_sql == $nom and isset($GLOBALS['tables_principales']['spip_' . $nom])) { |
|
| 140 | - $nom_sql = 'spip_' . $nom; |
|
| 141 | - $fdesc = &$GLOBALS['tables_principales'][$nom_sql]; |
|
| 142 | - } elseif (isset($GLOBALS['tables_auxiliaires'][$n = $nom]) |
|
| 143 | - or isset($GLOBALS['tables_auxiliaires'][$n = 'spip_' . $nom]) |
|
| 144 | - ) { |
|
| 145 | - $nom_sql = $n; |
|
| 146 | - $fdesc = &$GLOBALS['tables_auxiliaires'][$n]; |
|
| 147 | - } # table locale a cote de SPIP, comme non SPIP: |
|
| 148 | - } |
|
| 149 | - if (!isset($connexion['tables'][$nom_sql])) { |
|
| 150 | - |
|
| 151 | - // La *vraie* base a la priorite |
|
| 152 | - $desc = sql_showtable($nom_sql, $table_spip, $serveur); |
|
| 153 | - if (!$desc or !$desc['field']) { |
|
| 154 | - if (!$fdesc) { |
|
| 155 | - spip_log("trouver_table: table inconnue '$serveur' '$nom'", 'base' . _LOG_INFO_IMPORTANTE); |
|
| 156 | - |
|
| 157 | - return null; |
|
| 158 | - } |
|
| 159 | - // on ne sait pas lire la structure de la table : |
|
| 160 | - // on retombe sur la description donnee dans les fichiers spip |
|
| 161 | - $desc = $fdesc; |
|
| 162 | - $desc['exist'] = false; |
|
| 163 | - } else { |
|
| 164 | - $desc['exist'] = true; |
|
| 165 | - // gerer le cas des cles vides (echec de l'analyse sur une vue par exemple) |
|
| 166 | - // pour recuperer la declaration de lister_tables_objets_sql() si il y en a une |
|
| 167 | - if (! $desc['key']) { |
|
| 168 | - spip_log("trouver_table: table sans cle '$serveur' '$nom'", 'base'); |
|
| 169 | - unset($desc['key']); |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - $desc['table'] = $desc['table_sql'] = $nom_sql; |
|
| 174 | - $desc['connexion'] = $serveur; |
|
| 175 | - |
|
| 176 | - // charger les infos declarees pour cette table |
|
| 177 | - // en lui passant les infos connues |
|
| 178 | - // $desc est prioritaire pour la description de la table |
|
| 179 | - $desc = array_merge(lister_tables_objets_sql($nom_sql, $desc), $desc); |
|
| 180 | - // s'assurer qu'on a toujours un 'key' |
|
| 181 | - if (! isset($desc['key'])) { |
|
| 182 | - $desc['key'] = array(); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - // si tables_objets_sql est bien fini d'init, on peut cacher |
|
| 186 | - $connexion['tables'][$nom_sql] = $desc; |
|
| 187 | - $res = &$connexion['tables'][$nom_sql]; |
|
| 188 | - // une nouvelle table a ete decrite |
|
| 189 | - // mettons donc a jour le cache des descriptions de ce serveur |
|
| 190 | - if (is_writeable(_DIR_CACHE)) { |
|
| 191 | - ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql], serialize($connexion['tables']), true); |
|
| 192 | - } |
|
| 193 | - } else { |
|
| 194 | - $res = &$connexion['tables'][$nom_sql]; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - // toujours retourner $nom dans id_table |
|
| 198 | - $res['id_table'] = $nom; |
|
| 199 | - |
|
| 200 | - return $res; |
|
| 67 | + static $nom_cache_desc_sql = array(); |
|
| 68 | + |
|
| 69 | + if (!spip_connect($serveur) |
|
| 70 | + or !preg_match('/^[a-zA-Z0-9._-]*/', $nom) |
|
| 71 | + ) { |
|
| 72 | + return null; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + $connexion = &$GLOBALS['connexions'][$serveur ? strtolower($serveur) : 0]; |
|
| 76 | + $objets_sql = lister_tables_objets_sql("::md5"); |
|
| 77 | + |
|
| 78 | + // le nom du cache depend du serveur mais aussi du nom de la db et du prefixe |
|
| 79 | + // ce qui permet une auto invalidation en cas de modif manuelle du fichier |
|
| 80 | + // de connexion, et tout risque d'ambiguite |
|
| 81 | + if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])) { |
|
| 82 | + $nom_cache_desc_sql[$serveur][$objets_sql] = |
|
| 83 | + _DIR_CACHE . 'sql_desc_' |
|
| 84 | + . ($serveur ? "{$serveur}_" : "") |
|
| 85 | + . substr(md5($connexion['db'] . ":" . $connexion['prefixe'] . ":$objets_sql"), 0, 8) |
|
| 86 | + . '.txt'; |
|
| 87 | + // nouveau nom de cache = nouvelle version en memoire |
|
| 88 | + unset($connexion['tables']); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + // un appel avec $nom vide est une demande explicite de vidange du cache des descriptions |
|
| 92 | + if (!$nom) { |
|
| 93 | + spip_unlink($nom_cache_desc_sql[$serveur][$objets_sql]); |
|
| 94 | + $connexion['tables'] = array(); |
|
| 95 | + |
|
| 96 | + return null; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + $nom_sql = $nom; |
|
| 100 | + if (preg_match('/\.(.*)$/', $nom, $s)) { |
|
| 101 | + $nom_sql = $s[1]; |
|
| 102 | + } else { |
|
| 103 | + $nom_sql = $nom; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $fdesc = $desc = ''; |
|
| 107 | + $connexion = &$GLOBALS['connexions'][$serveur ? $serveur : 0]; |
|
| 108 | + |
|
| 109 | + // base sous SPIP: gerer les abreviations explicites des noms de table |
|
| 110 | + if ($connexion['spip_connect_version']) { |
|
| 111 | + if ($table_spip and isset($GLOBALS['table_des_tables'][$nom])) { |
|
| 112 | + $nom = $GLOBALS['table_des_tables'][$nom]; |
|
| 113 | + $nom_sql = 'spip_' . $nom; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + // si c'est la premiere table qu'on cherche |
|
| 118 | + // et si on est pas explicitement en recalcul |
|
| 119 | + // on essaye de recharger le cache des decriptions de ce serveur |
|
| 120 | + // dans le fichier cache |
|
| 121 | + if (!isset($connexion['tables'][$nom_sql]) |
|
| 122 | + and defined('_VAR_MODE') and _VAR_MODE !== 'recalcul' |
|
| 123 | + and (!isset($connexion['tables']) or !$connexion['tables']) |
|
| 124 | + ) { |
|
| 125 | + if (lire_fichier($nom_cache_desc_sql[$serveur][$objets_sql], $desc_cache) |
|
| 126 | + and $desc_cache = unserialize($desc_cache) |
|
| 127 | + ) { |
|
| 128 | + $connexion['tables'] = $desc_cache; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + if ($table_spip and !isset($connexion['tables'][$nom_sql])) { |
|
| 132 | + |
|
| 133 | + if (isset($GLOBALS['tables_principales'][$nom_sql])) { |
|
| 134 | + $fdesc = $GLOBALS['tables_principales'][$nom_sql]; |
|
| 135 | + } |
|
| 136 | + // meme si pas d'abreviation declaree, trouver la table spip_$nom |
|
| 137 | + // si c'est une table principale, |
|
| 138 | + // puisqu'on le fait aussi pour les tables auxiliaires |
|
| 139 | + elseif ($nom_sql == $nom and isset($GLOBALS['tables_principales']['spip_' . $nom])) { |
|
| 140 | + $nom_sql = 'spip_' . $nom; |
|
| 141 | + $fdesc = &$GLOBALS['tables_principales'][$nom_sql]; |
|
| 142 | + } elseif (isset($GLOBALS['tables_auxiliaires'][$n = $nom]) |
|
| 143 | + or isset($GLOBALS['tables_auxiliaires'][$n = 'spip_' . $nom]) |
|
| 144 | + ) { |
|
| 145 | + $nom_sql = $n; |
|
| 146 | + $fdesc = &$GLOBALS['tables_auxiliaires'][$n]; |
|
| 147 | + } # table locale a cote de SPIP, comme non SPIP: |
|
| 148 | + } |
|
| 149 | + if (!isset($connexion['tables'][$nom_sql])) { |
|
| 150 | + |
|
| 151 | + // La *vraie* base a la priorite |
|
| 152 | + $desc = sql_showtable($nom_sql, $table_spip, $serveur); |
|
| 153 | + if (!$desc or !$desc['field']) { |
|
| 154 | + if (!$fdesc) { |
|
| 155 | + spip_log("trouver_table: table inconnue '$serveur' '$nom'", 'base' . _LOG_INFO_IMPORTANTE); |
|
| 156 | + |
|
| 157 | + return null; |
|
| 158 | + } |
|
| 159 | + // on ne sait pas lire la structure de la table : |
|
| 160 | + // on retombe sur la description donnee dans les fichiers spip |
|
| 161 | + $desc = $fdesc; |
|
| 162 | + $desc['exist'] = false; |
|
| 163 | + } else { |
|
| 164 | + $desc['exist'] = true; |
|
| 165 | + // gerer le cas des cles vides (echec de l'analyse sur une vue par exemple) |
|
| 166 | + // pour recuperer la declaration de lister_tables_objets_sql() si il y en a une |
|
| 167 | + if (! $desc['key']) { |
|
| 168 | + spip_log("trouver_table: table sans cle '$serveur' '$nom'", 'base'); |
|
| 169 | + unset($desc['key']); |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + $desc['table'] = $desc['table_sql'] = $nom_sql; |
|
| 174 | + $desc['connexion'] = $serveur; |
|
| 175 | + |
|
| 176 | + // charger les infos declarees pour cette table |
|
| 177 | + // en lui passant les infos connues |
|
| 178 | + // $desc est prioritaire pour la description de la table |
|
| 179 | + $desc = array_merge(lister_tables_objets_sql($nom_sql, $desc), $desc); |
|
| 180 | + // s'assurer qu'on a toujours un 'key' |
|
| 181 | + if (! isset($desc['key'])) { |
|
| 182 | + $desc['key'] = array(); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + // si tables_objets_sql est bien fini d'init, on peut cacher |
|
| 186 | + $connexion['tables'][$nom_sql] = $desc; |
|
| 187 | + $res = &$connexion['tables'][$nom_sql]; |
|
| 188 | + // une nouvelle table a ete decrite |
|
| 189 | + // mettons donc a jour le cache des descriptions de ce serveur |
|
| 190 | + if (is_writeable(_DIR_CACHE)) { |
|
| 191 | + ecrire_fichier($nom_cache_desc_sql[$serveur][$objets_sql], serialize($connexion['tables']), true); |
|
| 192 | + } |
|
| 193 | + } else { |
|
| 194 | + $res = &$connexion['tables'][$nom_sql]; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + // toujours retourner $nom dans id_table |
|
| 198 | + $res['id_table'] = $nom; |
|
| 199 | + |
|
| 200 | + return $res; |
|
| 201 | 201 | } |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | // de connexion, et tout risque d'ambiguite |
| 81 | 81 | if (!isset($nom_cache_desc_sql[$serveur][$objets_sql])) { |
| 82 | 82 | $nom_cache_desc_sql[$serveur][$objets_sql] = |
| 83 | - _DIR_CACHE . 'sql_desc_' |
|
| 83 | + _DIR_CACHE.'sql_desc_' |
|
| 84 | 84 | . ($serveur ? "{$serveur}_" : "") |
| 85 | - . substr(md5($connexion['db'] . ":" . $connexion['prefixe'] . ":$objets_sql"), 0, 8) |
|
| 85 | + . substr(md5($connexion['db'].":".$connexion['prefixe'].":$objets_sql"), 0, 8) |
|
| 86 | 86 | . '.txt'; |
| 87 | 87 | // nouveau nom de cache = nouvelle version en memoire |
| 88 | 88 | unset($connexion['tables']); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | if ($connexion['spip_connect_version']) { |
| 111 | 111 | if ($table_spip and isset($GLOBALS['table_des_tables'][$nom])) { |
| 112 | 112 | $nom = $GLOBALS['table_des_tables'][$nom]; |
| 113 | - $nom_sql = 'spip_' . $nom; |
|
| 113 | + $nom_sql = 'spip_'.$nom; |
|
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
@@ -136,11 +136,11 @@ discard block |
||
| 136 | 136 | // meme si pas d'abreviation declaree, trouver la table spip_$nom |
| 137 | 137 | // si c'est une table principale, |
| 138 | 138 | // puisqu'on le fait aussi pour les tables auxiliaires |
| 139 | - elseif ($nom_sql == $nom and isset($GLOBALS['tables_principales']['spip_' . $nom])) { |
|
| 140 | - $nom_sql = 'spip_' . $nom; |
|
| 139 | + elseif ($nom_sql == $nom and isset($GLOBALS['tables_principales']['spip_'.$nom])) { |
|
| 140 | + $nom_sql = 'spip_'.$nom; |
|
| 141 | 141 | $fdesc = &$GLOBALS['tables_principales'][$nom_sql]; |
| 142 | 142 | } elseif (isset($GLOBALS['tables_auxiliaires'][$n = $nom]) |
| 143 | - or isset($GLOBALS['tables_auxiliaires'][$n = 'spip_' . $nom]) |
|
| 143 | + or isset($GLOBALS['tables_auxiliaires'][$n = 'spip_'.$nom]) |
|
| 144 | 144 | ) { |
| 145 | 145 | $nom_sql = $n; |
| 146 | 146 | $fdesc = &$GLOBALS['tables_auxiliaires'][$n]; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $desc = sql_showtable($nom_sql, $table_spip, $serveur); |
| 153 | 153 | if (!$desc or !$desc['field']) { |
| 154 | 154 | if (!$fdesc) { |
| 155 | - spip_log("trouver_table: table inconnue '$serveur' '$nom'", 'base' . _LOG_INFO_IMPORTANTE); |
|
| 155 | + spip_log("trouver_table: table inconnue '$serveur' '$nom'", 'base'._LOG_INFO_IMPORTANTE); |
|
| 156 | 156 | |
| 157 | 157 | return null; |
| 158 | 158 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | $desc['exist'] = true; |
| 165 | 165 | // gerer le cas des cles vides (echec de l'analyse sur une vue par exemple) |
| 166 | 166 | // pour recuperer la declaration de lister_tables_objets_sql() si il y en a une |
| 167 | - if (! $desc['key']) { |
|
| 167 | + if (!$desc['key']) { |
|
| 168 | 168 | spip_log("trouver_table: table sans cle '$serveur' '$nom'", 'base'); |
| 169 | 169 | unset($desc['key']); |
| 170 | 170 | } |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | // $desc est prioritaire pour la description de la table |
| 179 | 179 | $desc = array_merge(lister_tables_objets_sql($nom_sql, $desc), $desc); |
| 180 | 180 | // s'assurer qu'on a toujours un 'key' |
| 181 | - if (! isset($desc['key'])) { |
|
| 181 | + if (!isset($desc['key'])) { |
|
| 182 | 182 | $desc['key'] = array(); |
| 183 | 183 | } |
| 184 | 184 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | */ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/filtres_boites'); |
@@ -40,27 +40,27 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function parametres_css_prive() { |
| 42 | 42 | |
| 43 | - $args = array(); |
|
| 44 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 45 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 46 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 47 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 48 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 49 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 43 | + $args = array(); |
|
| 44 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 45 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 46 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 47 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 48 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 49 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 50 | 50 | |
| 51 | - $c = isset($GLOBALS['visiteur_session']['prefs']['couleur']) |
|
| 52 | - ? $GLOBALS['visiteur_session']['prefs']['couleur'] |
|
| 53 | - : 9; |
|
| 51 | + $c = isset($GLOBALS['visiteur_session']['prefs']['couleur']) |
|
| 52 | + ? $GLOBALS['visiteur_session']['prefs']['couleur'] |
|
| 53 | + : 9; |
|
| 54 | 54 | |
| 55 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 56 | - parse_str($couleurs($c), $c); |
|
| 57 | - $args = array_merge($args, $c); |
|
| 55 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 56 | + parse_str($couleurs($c), $c); |
|
| 57 | + $args = array_merge($args, $c); |
|
| 58 | 58 | |
| 59 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 60 | - $args['var_mode'] = 'recalcul'; |
|
| 61 | - } |
|
| 59 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 60 | + $args['var_mode'] = 'recalcul'; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return http_build_query($args); |
|
| 63 | + return http_build_query($args); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | |
@@ -83,79 +83,79 @@ discard block |
||
| 83 | 83 | * @return string |
| 84 | 84 | */ |
| 85 | 85 | function chercher_rubrique( |
| 86 | - $titre, |
|
| 87 | - $id_objet, |
|
| 88 | - $id_parent, |
|
| 89 | - $objet, |
|
| 90 | - $id_secteur, |
|
| 91 | - $restreint, |
|
| 92 | - $actionable = false, |
|
| 93 | - $retour_sans_cadre = false |
|
| 86 | + $titre, |
|
| 87 | + $id_objet, |
|
| 88 | + $id_parent, |
|
| 89 | + $objet, |
|
| 90 | + $id_secteur, |
|
| 91 | + $restreint, |
|
| 92 | + $actionable = false, |
|
| 93 | + $retour_sans_cadre = false |
|
| 94 | 94 | ) { |
| 95 | 95 | |
| 96 | - include_spip('inc/autoriser'); |
|
| 97 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 98 | - return ""; |
|
| 99 | - } |
|
| 100 | - if (!sql_countsel('spip_rubriques')) { |
|
| 101 | - return ""; |
|
| 102 | - } |
|
| 103 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 104 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 105 | - |
|
| 106 | - if ($id_parent == 0) { |
|
| 107 | - $logo = "racine-24.png"; |
|
| 108 | - } elseif ($id_secteur == $id_parent) { |
|
| 109 | - $logo = "secteur-24.png"; |
|
| 110 | - } else { |
|
| 111 | - $logo = "rubrique-24.png"; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - $confirm = ""; |
|
| 115 | - if ($objet == 'rubrique') { |
|
| 116 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 117 | - // confirmation du deplacement |
|
| 118 | - $contient_breves = sql_countsel('spip_breves', "id_rubrique=" . intval($id_objet)); |
|
| 119 | - |
|
| 120 | - if ($contient_breves > 0) { |
|
| 121 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 122 | - $scb = _T('avis_deplacement_rubrique', |
|
| 123 | - array( |
|
| 124 | - 'contient_breves' => $contient_breves, |
|
| 125 | - 'scb' => $scb |
|
| 126 | - )); |
|
| 127 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 128 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 129 | - . $scb . |
|
| 130 | - "</label></div></div>\n"; |
|
| 131 | - } else { |
|
| 132 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - $form .= $confirm; |
|
| 136 | - if ($actionable) { |
|
| 137 | - if (strpos($form, '<select') !== false) { |
|
| 138 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 139 | - . '<input class="fondo" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 140 | - . "</div>"; |
|
| 141 | - } |
|
| 142 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 143 | - if ($action = charger_fonction("editer_$objet", "action", true)) { |
|
| 144 | - $form = generer_action_auteur("editer_$objet", $id_objet, self(), $form, |
|
| 145 | - " method='post' class='submit_plongeur'"); |
|
| 146 | - } else { |
|
| 147 | - $form = generer_action_auteur("editer_objet", "$objet/$id_objet", self(), $form, |
|
| 148 | - " method='post' class='submit_plongeur'"); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - if ($retour_sans_cadre) { |
|
| 153 | - return $form; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - include_spip('inc/presentation'); |
|
| 157 | - |
|
| 158 | - return debut_cadre_couleur($logo, true, "", $titre) . $form . fin_cadre_couleur(true); |
|
| 96 | + include_spip('inc/autoriser'); |
|
| 97 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 98 | + return ""; |
|
| 99 | + } |
|
| 100 | + if (!sql_countsel('spip_rubriques')) { |
|
| 101 | + return ""; |
|
| 102 | + } |
|
| 103 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 104 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 105 | + |
|
| 106 | + if ($id_parent == 0) { |
|
| 107 | + $logo = "racine-24.png"; |
|
| 108 | + } elseif ($id_secteur == $id_parent) { |
|
| 109 | + $logo = "secteur-24.png"; |
|
| 110 | + } else { |
|
| 111 | + $logo = "rubrique-24.png"; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + $confirm = ""; |
|
| 115 | + if ($objet == 'rubrique') { |
|
| 116 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 117 | + // confirmation du deplacement |
|
| 118 | + $contient_breves = sql_countsel('spip_breves', "id_rubrique=" . intval($id_objet)); |
|
| 119 | + |
|
| 120 | + if ($contient_breves > 0) { |
|
| 121 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 122 | + $scb = _T('avis_deplacement_rubrique', |
|
| 123 | + array( |
|
| 124 | + 'contient_breves' => $contient_breves, |
|
| 125 | + 'scb' => $scb |
|
| 126 | + )); |
|
| 127 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 128 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 129 | + . $scb . |
|
| 130 | + "</label></div></div>\n"; |
|
| 131 | + } else { |
|
| 132 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + $form .= $confirm; |
|
| 136 | + if ($actionable) { |
|
| 137 | + if (strpos($form, '<select') !== false) { |
|
| 138 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 139 | + . '<input class="fondo" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 140 | + . "</div>"; |
|
| 141 | + } |
|
| 142 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 143 | + if ($action = charger_fonction("editer_$objet", "action", true)) { |
|
| 144 | + $form = generer_action_auteur("editer_$objet", $id_objet, self(), $form, |
|
| 145 | + " method='post' class='submit_plongeur'"); |
|
| 146 | + } else { |
|
| 147 | + $form = generer_action_auteur("editer_objet", "$objet/$id_objet", self(), $form, |
|
| 148 | + " method='post' class='submit_plongeur'"); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + if ($retour_sans_cadre) { |
|
| 153 | + return $form; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + include_spip('inc/presentation'); |
|
| 157 | + |
|
| 158 | + return debut_cadre_couleur($logo, true, "", $titre) . $form . fin_cadre_couleur(true); |
|
| 159 | 159 | |
| 160 | 160 | } |
| 161 | 161 | |
@@ -170,21 +170,21 @@ discard block |
||
| 170 | 170 | * @return bool |
| 171 | 171 | */ |
| 172 | 172 | function avoir_visiteurs($past = false, $accepter = true) { |
| 173 | - if ($GLOBALS['meta']["forums_publics"] == 'abo') { |
|
| 174 | - return true; |
|
| 175 | - } |
|
| 176 | - if ($accepter and $GLOBALS['meta']["accepter_visiteurs"] <> 'non') { |
|
| 177 | - return true; |
|
| 178 | - } |
|
| 179 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 180 | - return true; |
|
| 181 | - } |
|
| 182 | - if (!$past) { |
|
| 183 | - return false; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - return sql_countsel('spip_auteurs', |
|
| 187 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 173 | + if ($GLOBALS['meta']["forums_publics"] == 'abo') { |
|
| 174 | + return true; |
|
| 175 | + } |
|
| 176 | + if ($accepter and $GLOBALS['meta']["accepter_visiteurs"] <> 'non') { |
|
| 177 | + return true; |
|
| 178 | + } |
|
| 179 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 180 | + return true; |
|
| 181 | + } |
|
| 182 | + if (!$past) { |
|
| 183 | + return false; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + return sql_countsel('spip_auteurs', |
|
| 187 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 188 | 188 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))"); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -201,18 +201,18 @@ discard block |
||
| 201 | 201 | * @return array |
| 202 | 202 | */ |
| 203 | 203 | function statuts_articles_visibles($statut_auteur) { |
| 204 | - static $auth = array(); |
|
| 205 | - if (!isset($auth[$statut_auteur])) { |
|
| 206 | - $auth[$statut_auteur] = array(); |
|
| 207 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 208 | - foreach ($statuts as $s) { |
|
| 209 | - if (autoriser('voir', 'article', 0, array('statut' => $statut_auteur), array('statut' => $s))) { |
|
| 210 | - $auth[$statut_auteur][] = $s; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - return $auth[$statut_auteur]; |
|
| 204 | + static $auth = array(); |
|
| 205 | + if (!isset($auth[$statut_auteur])) { |
|
| 206 | + $auth[$statut_auteur] = array(); |
|
| 207 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 208 | + foreach ($statuts as $s) { |
|
| 209 | + if (autoriser('voir', 'article', 0, array('statut' => $statut_auteur), array('statut' => $s))) { |
|
| 210 | + $auth[$statut_auteur][] = $s; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + return $auth[$statut_auteur]; |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | /** |
@@ -226,38 +226,38 @@ discard block |
||
| 226 | 226 | * @return string |
| 227 | 227 | */ |
| 228 | 228 | function traduire_statut_auteur($statut, $attente = "") { |
| 229 | - $plus = ""; |
|
| 230 | - if ($statut == 'nouveau') { |
|
| 231 | - if ($attente) { |
|
| 232 | - $statut = $attente; |
|
| 233 | - $plus = " (" . _T('info_statut_auteur_a_confirmer') . ")"; |
|
| 234 | - } else { |
|
| 235 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 236 | - } |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - $recom = array( |
|
| 240 | - "info_administrateurs" => _T('item_administrateur_2'), |
|
| 241 | - "info_redacteurs" => _T('intem_redacteur'), |
|
| 242 | - "info_visiteurs" => _T('item_visiteur'), |
|
| 243 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 244 | - ); |
|
| 245 | - if (isset($recom[$statut])) { |
|
| 246 | - return $recom[$statut] . $plus; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - // retrouver directement par le statut sinon |
|
| 250 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 251 | - if (isset($recom[$t])) { |
|
| 252 | - return $recom[$t] . $plus; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - return _T($t) . $plus; |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 259 | - // c'est toujours plus informatif que rien du tout |
|
| 260 | - return $statut; |
|
| 229 | + $plus = ""; |
|
| 230 | + if ($statut == 'nouveau') { |
|
| 231 | + if ($attente) { |
|
| 232 | + $statut = $attente; |
|
| 233 | + $plus = " (" . _T('info_statut_auteur_a_confirmer') . ")"; |
|
| 234 | + } else { |
|
| 235 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 236 | + } |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + $recom = array( |
|
| 240 | + "info_administrateurs" => _T('item_administrateur_2'), |
|
| 241 | + "info_redacteurs" => _T('intem_redacteur'), |
|
| 242 | + "info_visiteurs" => _T('item_visiteur'), |
|
| 243 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 244 | + ); |
|
| 245 | + if (isset($recom[$statut])) { |
|
| 246 | + return $recom[$statut] . $plus; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + // retrouver directement par le statut sinon |
|
| 250 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 251 | + if (isset($recom[$t])) { |
|
| 252 | + return $recom[$t] . $plus; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + return _T($t) . $plus; |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 259 | + // c'est toujours plus informatif que rien du tout |
|
| 260 | + return $statut; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | /** |
@@ -268,28 +268,28 @@ discard block |
||
| 268 | 268 | * @return string |
| 269 | 269 | */ |
| 270 | 270 | function afficher_qui_edite($id_objet, $objet) { |
| 271 | - static $qui = array(); |
|
| 272 | - if (isset($qui[$objet][$id_objet])) { |
|
| 273 | - return $qui[$objet][$id_objet]; |
|
| 274 | - } |
|
| 275 | - |
|
| 276 | - if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 277 | - return $qui[$objet][$id_objet] = ''; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - include_spip('inc/drapeau_edition'); |
|
| 281 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 282 | - if (!$modif) { |
|
| 283 | - return $qui[$objet][$id_objet] = ''; |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - include_spip('base/objets'); |
|
| 287 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 288 | - if (isset($infos['texte_signale_edition'])) { |
|
| 289 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 271 | + static $qui = array(); |
|
| 272 | + if (isset($qui[$objet][$id_objet])) { |
|
| 273 | + return $qui[$objet][$id_objet]; |
|
| 274 | + } |
|
| 275 | + |
|
| 276 | + if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 277 | + return $qui[$objet][$id_objet] = ''; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + include_spip('inc/drapeau_edition'); |
|
| 281 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 282 | + if (!$modif) { |
|
| 283 | + return $qui[$objet][$id_objet] = ''; |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + include_spip('base/objets'); |
|
| 287 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 288 | + if (isset($infos['texte_signale_edition'])) { |
|
| 289 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -307,57 +307,57 @@ discard block |
||
| 307 | 307 | * @return array |
| 308 | 308 | */ |
| 309 | 309 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true) { |
| 310 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 311 | - define('AUTEURS_MIN_REDAC', "0minirezo,1comite,5poubelle"); |
|
| 312 | - } |
|
| 313 | - |
|
| 314 | - switch ($quoi) { |
|
| 315 | - case "redacteurs": |
|
| 316 | - $statut = AUTEURS_MIN_REDAC; |
|
| 317 | - $statut = explode(',', $statut); |
|
| 318 | - if ($en_base) { |
|
| 319 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 320 | - $retire = array_diff($statut, $check); |
|
| 321 | - $statut = array_diff($statut, $retire); |
|
| 322 | - } |
|
| 323 | - |
|
| 324 | - return array_unique($statut); |
|
| 325 | - break; |
|
| 326 | - case "visiteurs": |
|
| 327 | - $statut = array(); |
|
| 328 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 329 | - $exclus = explode(',', $exclus); |
|
| 330 | - if (!$en_base) { |
|
| 331 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 332 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 333 | - } |
|
| 334 | - $s_complement = array_column( |
|
| 335 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 336 | - 'statut' |
|
| 337 | - ); |
|
| 338 | - |
|
| 339 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 340 | - break; |
|
| 341 | - default: |
|
| 342 | - case "tous": |
|
| 343 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 344 | - $s_complement = array_column( |
|
| 345 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 346 | - 'statut' |
|
| 347 | - ); |
|
| 348 | - $statut = array_merge($statut, $s_complement); |
|
| 349 | - if ($en_base) { |
|
| 350 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 351 | - $retire = array_diff($statut, $check); |
|
| 352 | - $statut = array_diff($statut, $retire); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - return array_unique($statut); |
|
| 356 | - break; |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - // on arrive jamais ici |
|
| 360 | - return array_values($GLOBALS['liste_des_statuts']); |
|
| 310 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 311 | + define('AUTEURS_MIN_REDAC', "0minirezo,1comite,5poubelle"); |
|
| 312 | + } |
|
| 313 | + |
|
| 314 | + switch ($quoi) { |
|
| 315 | + case "redacteurs": |
|
| 316 | + $statut = AUTEURS_MIN_REDAC; |
|
| 317 | + $statut = explode(',', $statut); |
|
| 318 | + if ($en_base) { |
|
| 319 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 320 | + $retire = array_diff($statut, $check); |
|
| 321 | + $statut = array_diff($statut, $retire); |
|
| 322 | + } |
|
| 323 | + |
|
| 324 | + return array_unique($statut); |
|
| 325 | + break; |
|
| 326 | + case "visiteurs": |
|
| 327 | + $statut = array(); |
|
| 328 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 329 | + $exclus = explode(',', $exclus); |
|
| 330 | + if (!$en_base) { |
|
| 331 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 332 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 333 | + } |
|
| 334 | + $s_complement = array_column( |
|
| 335 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 336 | + 'statut' |
|
| 337 | + ); |
|
| 338 | + |
|
| 339 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 340 | + break; |
|
| 341 | + default: |
|
| 342 | + case "tous": |
|
| 343 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 344 | + $s_complement = array_column( |
|
| 345 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 346 | + 'statut' |
|
| 347 | + ); |
|
| 348 | + $statut = array_merge($statut, $s_complement); |
|
| 349 | + if ($en_base) { |
|
| 350 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 351 | + $retire = array_diff($statut, $check); |
|
| 352 | + $statut = array_diff($statut, $retire); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + return array_unique($statut); |
|
| 356 | + break; |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + // on arrive jamais ici |
|
| 360 | + return array_values($GLOBALS['liste_des_statuts']); |
|
| 361 | 361 | } |
| 362 | 362 | |
| 363 | 363 | /** |
@@ -373,28 +373,28 @@ discard block |
||
| 373 | 373 | */ |
| 374 | 374 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 375 | 375 | |
| 376 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 377 | - $in = !count($GLOBALS['connect_id_rubrique']) |
|
| 378 | - ? '' |
|
| 379 | - : (" AND " . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 380 | - |
|
| 381 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 382 | - if ($objet == 'rubrique') { |
|
| 383 | - $id_rubrique = 0; |
|
| 384 | - } else { |
|
| 385 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', "id_rubrique DESC", 1); |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 389 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 390 | - $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); |
|
| 391 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 392 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 393 | - } |
|
| 394 | - } |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - return $id_rubrique; |
|
| 376 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 377 | + $in = !count($GLOBALS['connect_id_rubrique']) |
|
| 378 | + ? '' |
|
| 379 | + : (" AND " . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 380 | + |
|
| 381 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 382 | + if ($objet == 'rubrique') { |
|
| 383 | + $id_rubrique = 0; |
|
| 384 | + } else { |
|
| 385 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', "id_rubrique DESC", 1); |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 389 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 390 | + $res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0"); |
|
| 391 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 392 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 393 | + } |
|
| 394 | + } |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + return $id_rubrique; |
|
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | /** |
@@ -405,12 +405,12 @@ discard block |
||
| 405 | 405 | * @return string |
| 406 | 406 | */ |
| 407 | 407 | function lien_article_virtuel($virtuel) { |
| 408 | - include_spip('inc/lien'); |
|
| 409 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 410 | - return ''; |
|
| 411 | - } |
|
| 408 | + include_spip('inc/lien'); |
|
| 409 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 410 | + return ''; |
|
| 411 | + } |
|
| 412 | 412 | |
| 413 | - return propre("[->" . $virtuel . "]"); |
|
| 413 | + return propre("[->" . $virtuel . "]"); |
|
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | |
@@ -433,12 +433,12 @@ discard block |
||
| 433 | 433 | * Code HTML du lien |
| 434 | 434 | */ |
| 435 | 435 | function bouton_spip_rss($op, $args = array(), $lang = '', $title = 'RSS') { |
| 436 | - include_spip('inc/acces'); |
|
| 437 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 438 | - $args = param_low_sec($op, $args, $lang, 'rss'); |
|
| 439 | - $url = generer_url_public('rss', $args); |
|
| 436 | + include_spip('inc/acces'); |
|
| 437 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 438 | + $args = param_low_sec($op, $args, $lang, 'rss'); |
|
| 439 | + $url = generer_url_public('rss', $args); |
|
| 440 | 440 | |
| 441 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 441 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | |
@@ -450,70 +450,70 @@ discard block |
||
| 450 | 450 | */ |
| 451 | 451 | function alertes_auteur($id_auteur) { |
| 452 | 452 | |
| 453 | - $alertes = array(); |
|
| 454 | - |
|
| 455 | - if (isset($GLOBALS['meta']['message_crash_tables']) |
|
| 456 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 457 | - ) { |
|
| 458 | - include_spip('genie/maintenance'); |
|
| 459 | - if ($msg = message_crash_tables()) { |
|
| 460 | - $alertes[] = $msg; |
|
| 461 | - } |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - if (isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 465 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 466 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 467 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 468 | - ) { |
|
| 469 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 470 | - $alertes[] = _T('plugins_erreur', array('plugins' => $msg)); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; |
|
| 474 | - if ($a |
|
| 475 | - and is_array($a = unserialize($a)) |
|
| 476 | - and count($a) |
|
| 477 | - ) { |
|
| 478 | - $update = false; |
|
| 479 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 480 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 481 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 482 | - $update = true; |
|
| 483 | - } |
|
| 484 | - if (isset($a[''])) { |
|
| 485 | - $alertes = array_merge($alertes, $a['']); |
|
| 486 | - unset($a['']); |
|
| 487 | - $update = true; |
|
| 488 | - } |
|
| 489 | - if ($update) { |
|
| 490 | - ecrire_meta("message_alertes_auteurs", serialize($a)); |
|
| 491 | - } |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - if (isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 495 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 496 | - ) { |
|
| 497 | - include_spip('inc/plugin'); |
|
| 498 | - $alertes[] = plugin_donne_erreurs(); |
|
| 499 | - } |
|
| 500 | - |
|
| 501 | - $alertes = pipeline( |
|
| 502 | - 'alertes_auteur', |
|
| 503 | - array( |
|
| 504 | - 'args' => array( |
|
| 505 | - 'id_auteur' => $id_auteur, |
|
| 506 | - 'exec' => _request('exec'), |
|
| 507 | - ), |
|
| 508 | - 'data' => $alertes |
|
| 509 | - ) |
|
| 510 | - ); |
|
| 511 | - |
|
| 512 | - if ($alertes = array_filter($alertes)) { |
|
| 513 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 514 | - join(' | ', $alertes) |
|
| 515 | - . "</div></div>"; |
|
| 516 | - } |
|
| 453 | + $alertes = array(); |
|
| 454 | + |
|
| 455 | + if (isset($GLOBALS['meta']['message_crash_tables']) |
|
| 456 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 457 | + ) { |
|
| 458 | + include_spip('genie/maintenance'); |
|
| 459 | + if ($msg = message_crash_tables()) { |
|
| 460 | + $alertes[] = $msg; |
|
| 461 | + } |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + if (isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 465 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 466 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 467 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 468 | + ) { |
|
| 469 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 470 | + $alertes[] = _T('plugins_erreur', array('plugins' => $msg)); |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; |
|
| 474 | + if ($a |
|
| 475 | + and is_array($a = unserialize($a)) |
|
| 476 | + and count($a) |
|
| 477 | + ) { |
|
| 478 | + $update = false; |
|
| 479 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 480 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 481 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 482 | + $update = true; |
|
| 483 | + } |
|
| 484 | + if (isset($a[''])) { |
|
| 485 | + $alertes = array_merge($alertes, $a['']); |
|
| 486 | + unset($a['']); |
|
| 487 | + $update = true; |
|
| 488 | + } |
|
| 489 | + if ($update) { |
|
| 490 | + ecrire_meta("message_alertes_auteurs", serialize($a)); |
|
| 491 | + } |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + if (isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 495 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 496 | + ) { |
|
| 497 | + include_spip('inc/plugin'); |
|
| 498 | + $alertes[] = plugin_donne_erreurs(); |
|
| 499 | + } |
|
| 500 | + |
|
| 501 | + $alertes = pipeline( |
|
| 502 | + 'alertes_auteur', |
|
| 503 | + array( |
|
| 504 | + 'args' => array( |
|
| 505 | + 'id_auteur' => $id_auteur, |
|
| 506 | + 'exec' => _request('exec'), |
|
| 507 | + ), |
|
| 508 | + 'data' => $alertes |
|
| 509 | + ) |
|
| 510 | + ); |
|
| 511 | + |
|
| 512 | + if ($alertes = array_filter($alertes)) { |
|
| 513 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 514 | + join(' | ', $alertes) |
|
| 515 | + . "</div></div>"; |
|
| 516 | + } |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -523,9 +523,9 @@ discard block |
||
| 523 | 523 | * @return string |
| 524 | 524 | */ |
| 525 | 525 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 526 | - include_spip('inc/presenter_enfants'); |
|
| 526 | + include_spip('inc/presenter_enfants'); |
|
| 527 | 527 | |
| 528 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 528 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 529 | 529 | } |
| 530 | 530 | |
| 531 | 531 | /** |
@@ -543,15 +543,15 @@ discard block |
||
| 543 | 543 | * @return string |
| 544 | 544 | */ |
| 545 | 545 | function afficher_plus_info($lien, $titre = "+", $titre_lien = "") { |
| 546 | - $titre = attribut_html($titre); |
|
| 547 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 548 | - http_img_pack("information-16.png", $titre) . "</a>"; |
|
| 549 | - |
|
| 550 | - if (!$titre_lien) { |
|
| 551 | - return $icone; |
|
| 552 | - } else { |
|
| 553 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 554 | - } |
|
| 546 | + $titre = attribut_html($titre); |
|
| 547 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 548 | + http_img_pack("information-16.png", $titre) . "</a>"; |
|
| 549 | + |
|
| 550 | + if (!$titre_lien) { |
|
| 551 | + return $icone; |
|
| 552 | + } else { |
|
| 553 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 554 | + } |
|
| 555 | 555 | } |
| 556 | 556 | |
| 557 | 557 | |
@@ -570,18 +570,18 @@ discard block |
||
| 570 | 570 | * @return array |
| 571 | 571 | */ |
| 572 | 572 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 573 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 574 | - if (!count($res)) { |
|
| 575 | - return []; |
|
| 576 | - } |
|
| 577 | - $r = reset($res); |
|
| 578 | - if (isset($r['rang_lien'])) { |
|
| 579 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 580 | - asort($l); |
|
| 581 | - $l = array_keys($l); |
|
| 582 | - } else { |
|
| 583 | - $l = array_column($res, $objet_source); |
|
| 584 | - } |
|
| 585 | - return $l; |
|
| 573 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 574 | + if (!count($res)) { |
|
| 575 | + return []; |
|
| 576 | + } |
|
| 577 | + $r = reset($res); |
|
| 578 | + if (isset($r['rang_lien'])) { |
|
| 579 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 580 | + asort($l); |
|
| 581 | + $l = array_keys($l); |
|
| 582 | + } else { |
|
| 583 | + $l = array_column($res, $objet_source); |
|
| 584 | + } |
|
| 585 | + return $l; |
|
| 586 | 586 | } |
| 587 | 587 | |