@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('base/serial'); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | * en droit de l'éliminer |
| 28 | 28 | */ |
| 29 | 29 | if (!defined('_AGE_CACHE_ATIME')) { |
| 30 | - define('_AGE_CACHE_ATIME', 3600); |
|
| 30 | + define('_AGE_CACHE_ATIME', 3600); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | |
@@ -40,31 +40,31 @@ discard block |
||
| 40 | 40 | * @return int Taille approximative en octets |
| 41 | 41 | **/ |
| 42 | 42 | function taille_du_cache() { |
| 43 | - # check dirs until we reach > 500 files |
|
| 44 | - $t = 0; |
|
| 45 | - $n = 0; |
|
| 46 | - $time = isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0; |
|
| 47 | - for ($i = 0; $i < 256; $i++) { |
|
| 48 | - $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 49 | - if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 50 | - while (($f = readdir($d)) !== false) { |
|
| 51 | - if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
|
| 52 | - $n++; |
|
| 53 | - if ($a['mtime'] >= $time) { |
|
| 54 | - if ($a['blocks'] > 0) { |
|
| 55 | - $t += 512 * $a['blocks']; |
|
| 56 | - } else { |
|
| 57 | - $t += $a['size']; |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - if ($n > 500) { |
|
| 64 | - return intval(256 * $t / (1 + $i)); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - return $t; |
|
| 43 | + # check dirs until we reach > 500 files |
|
| 44 | + $t = 0; |
|
| 45 | + $n = 0; |
|
| 46 | + $time = isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0; |
|
| 47 | + for ($i = 0; $i < 256; $i++) { |
|
| 48 | + $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 49 | + if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
|
| 50 | + while (($f = readdir($d)) !== false) { |
|
| 51 | + if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
|
| 52 | + $n++; |
|
| 53 | + if ($a['mtime'] >= $time) { |
|
| 54 | + if ($a['blocks'] > 0) { |
|
| 55 | + $t += 512 * $a['blocks']; |
|
| 56 | + } else { |
|
| 57 | + $t += $a['size']; |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + if ($n > 500) { |
|
| 64 | + return intval(256 * $t / (1 + $i)); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + return $t; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -91,30 +91,30 @@ discard block |
||
| 91 | 91 | * Inutilisé |
| 92 | 92 | **/ |
| 93 | 93 | function inc_suivre_invalideur_dist($cond, $modif = true) { |
| 94 | - if (!$modif) { |
|
| 95 | - return; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - // determiner l'objet modifie : forum, article, etc |
|
| 99 | - if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) { |
|
| 100 | - $objet = objet_type($r[1]); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - // stocker la date_modif_$objet (ne sert a rien pour le moment) |
|
| 104 | - if (isset($objet)) { |
|
| 105 | - ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // si $derniere_modif_invalide est un array('article', 'rubrique') |
|
| 109 | - // n'affecter la meta que si un de ces objets est modifie |
|
| 110 | - if (is_array($GLOBALS['derniere_modif_invalide'])) { |
|
| 111 | - if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) { |
|
| 112 | - ecrire_meta('derniere_modif', time()); |
|
| 113 | - } |
|
| 114 | - } // sinon, cas standard, toujours affecter la meta |
|
| 115 | - else { |
|
| 116 | - ecrire_meta('derniere_modif', time()); |
|
| 117 | - } |
|
| 94 | + if (!$modif) { |
|
| 95 | + return; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + // determiner l'objet modifie : forum, article, etc |
|
| 99 | + if (preg_match(',["\']([a-z_]+)[/"\'],', $cond, $r)) { |
|
| 100 | + $objet = objet_type($r[1]); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + // stocker la date_modif_$objet (ne sert a rien pour le moment) |
|
| 104 | + if (isset($objet)) { |
|
| 105 | + ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // si $derniere_modif_invalide est un array('article', 'rubrique') |
|
| 109 | + // n'affecter la meta que si un de ces objets est modifie |
|
| 110 | + if (is_array($GLOBALS['derniere_modif_invalide'])) { |
|
| 111 | + if (in_array($objet, $GLOBALS['derniere_modif_invalide'])) { |
|
| 112 | + ecrire_meta('derniere_modif', time()); |
|
| 113 | + } |
|
| 114 | + } // sinon, cas standard, toujours affecter la meta |
|
| 115 | + else { |
|
| 116 | + ecrire_meta('derniere_modif', time()); |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -139,50 +139,50 @@ discard block |
||
| 139 | 139 | * Nombre de fichiers supprimés |
| 140 | 140 | **/ |
| 141 | 141 | function purger_repertoire($dir, $options = []) { |
| 142 | - if (!is_dir($dir) or !is_readable($dir)) { |
|
| 143 | - return; |
|
| 144 | - } |
|
| 145 | - $handle = opendir($dir); |
|
| 146 | - if (!$handle) { |
|
| 147 | - return; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - $total = 0; |
|
| 151 | - |
|
| 152 | - while (($fichier = @readdir($handle)) !== false) { |
|
| 153 | - // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG |
|
| 154 | - if ($fichier[0] == '.' or $fichier == 'CACHEDIR.TAG') { |
|
| 155 | - continue; |
|
| 156 | - } |
|
| 157 | - $chemin = "$dir/$fichier"; |
|
| 158 | - if (is_file($chemin)) { |
|
| 159 | - if ( |
|
| 160 | - (!isset($options['atime']) or (@fileatime($chemin) < $options['atime'])) |
|
| 161 | - and (!isset($options['mtime']) or (@filemtime($chemin) < $options['mtime'])) |
|
| 162 | - ) { |
|
| 163 | - supprimer_fichier($chemin); |
|
| 164 | - $total++; |
|
| 165 | - } |
|
| 166 | - } else { |
|
| 167 | - if (is_dir($chemin)) { |
|
| 168 | - $opts = $options; |
|
| 169 | - if (isset($options['limit'])) { |
|
| 170 | - $opts['limit'] = $options['limit'] - $total; |
|
| 171 | - } |
|
| 172 | - $total += purger_repertoire($chemin, $opts); |
|
| 173 | - if (isset($options['subdir']) && $options['subdir']) { |
|
| 174 | - spip_unlink($chemin); |
|
| 175 | - } |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - if (isset($options['limit']) and $total >= $options['limit']) { |
|
| 180 | - break; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - closedir($handle); |
|
| 184 | - |
|
| 185 | - return $total; |
|
| 142 | + if (!is_dir($dir) or !is_readable($dir)) { |
|
| 143 | + return; |
|
| 144 | + } |
|
| 145 | + $handle = opendir($dir); |
|
| 146 | + if (!$handle) { |
|
| 147 | + return; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + $total = 0; |
|
| 151 | + |
|
| 152 | + while (($fichier = @readdir($handle)) !== false) { |
|
| 153 | + // Eviter ".", "..", ".htaccess", ".svn" etc & CACHEDIR.TAG |
|
| 154 | + if ($fichier[0] == '.' or $fichier == 'CACHEDIR.TAG') { |
|
| 155 | + continue; |
|
| 156 | + } |
|
| 157 | + $chemin = "$dir/$fichier"; |
|
| 158 | + if (is_file($chemin)) { |
|
| 159 | + if ( |
|
| 160 | + (!isset($options['atime']) or (@fileatime($chemin) < $options['atime'])) |
|
| 161 | + and (!isset($options['mtime']) or (@filemtime($chemin) < $options['mtime'])) |
|
| 162 | + ) { |
|
| 163 | + supprimer_fichier($chemin); |
|
| 164 | + $total++; |
|
| 165 | + } |
|
| 166 | + } else { |
|
| 167 | + if (is_dir($chemin)) { |
|
| 168 | + $opts = $options; |
|
| 169 | + if (isset($options['limit'])) { |
|
| 170 | + $opts['limit'] = $options['limit'] - $total; |
|
| 171 | + } |
|
| 172 | + $total += purger_repertoire($chemin, $opts); |
|
| 173 | + if (isset($options['subdir']) && $options['subdir']) { |
|
| 174 | + spip_unlink($chemin); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + if (isset($options['limit']) and $total >= $options['limit']) { |
|
| 180 | + break; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + closedir($handle); |
|
| 184 | + |
|
| 185 | + return $total; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
@@ -194,17 +194,17 @@ discard block |
||
| 194 | 194 | // https://code.spip.net/@retire_cache |
| 195 | 195 | function retire_cache($cache) { |
| 196 | 196 | |
| 197 | - if ( |
|
| 198 | - preg_match( |
|
| 199 | - ',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i', |
|
| 200 | - $cache |
|
| 201 | - ) |
|
| 202 | - ) { |
|
| 203 | - // supprimer le fichier (de facon propre) |
|
| 204 | - supprimer_fichier(_DIR_CACHE . $cache); |
|
| 205 | - } else { |
|
| 206 | - spip_log("Nom de fichier cache incorrect : $cache"); |
|
| 207 | - } |
|
| 197 | + if ( |
|
| 198 | + preg_match( |
|
| 199 | + ',^([0-9a-f]/)?([0-9]+/)?[0-9a-f]+\.cache(\.gz)?$,i', |
|
| 200 | + $cache |
|
| 201 | + ) |
|
| 202 | + ) { |
|
| 203 | + // supprimer le fichier (de facon propre) |
|
| 204 | + supprimer_fichier(_DIR_CACHE . $cache); |
|
| 205 | + } else { |
|
| 206 | + spip_log("Nom de fichier cache incorrect : $cache"); |
|
| 207 | + } |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // Supprimer les caches marques "x" |
@@ -212,9 +212,9 @@ discard block |
||
| 212 | 212 | // la meta est toujours false ; mais evitons un bug si elle est appellee |
| 213 | 213 | // https://code.spip.net/@retire_caches |
| 214 | 214 | function inc_retire_caches_dist($chemin = '') { |
| 215 | - if (isset($GLOBALS['meta']['invalider_caches'])) { |
|
| 216 | - effacer_meta('invalider_caches'); |
|
| 217 | - } # concurrence |
|
| 215 | + if (isset($GLOBALS['meta']['invalider_caches'])) { |
|
| 216 | + effacer_meta('invalider_caches'); |
|
| 217 | + } # concurrence |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | ####################################################################### |
@@ -225,9 +225,9 @@ discard block |
||
| 225 | 225 | ## |
| 226 | 226 | |
| 227 | 227 | function retire_caches($chemin = '') { |
| 228 | - if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) { |
|
| 229 | - return $retire_caches($chemin); |
|
| 230 | - } |
|
| 228 | + if ($retire_caches = charger_fonction('retire_caches', 'inc', true)) { |
|
| 229 | + return $retire_caches($chemin); |
|
| 230 | + } |
|
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | |
@@ -236,10 +236,10 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | // https://code.spip.net/@calcul_invalideurs |
| 238 | 238 | function calcul_invalideurs($corps, $primary, &$boucles, $id_boucle) { |
| 239 | - if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) { |
|
| 240 | - return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle); |
|
| 241 | - } |
|
| 242 | - return $corps; |
|
| 239 | + if ($calcul_invalideurs = charger_fonction('calcul_invalideurs', 'inc', true)) { |
|
| 240 | + return $calcul_invalideurs($corps, $primary, $boucles, $id_boucle); |
|
| 241 | + } |
|
| 242 | + return $corps; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
@@ -249,27 +249,27 @@ discard block |
||
| 249 | 249 | // |
| 250 | 250 | // https://code.spip.net/@supprime_invalideurs |
| 251 | 251 | function supprime_invalideurs() { |
| 252 | - if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) { |
|
| 253 | - return $supprime_invalideurs(); |
|
| 254 | - } |
|
| 252 | + if ($supprime_invalideurs = charger_fonction('supprime_invalideurs', 'inc', true)) { |
|
| 253 | + return $supprime_invalideurs(); |
|
| 254 | + } |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | |
| 258 | 258 | // Calcul des pages : noter dans la base les liens d'invalidation |
| 259 | 259 | // https://code.spip.net/@maj_invalideurs |
| 260 | 260 | function maj_invalideurs($fichier, &$page) { |
| 261 | - if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) { |
|
| 262 | - return $maj_invalideurs($fichier, $page); |
|
| 263 | - } |
|
| 261 | + if ($maj_invalideurs = charger_fonction('maj_invalideurs', 'inc', true)) { |
|
| 262 | + return $maj_invalideurs($fichier, $page); |
|
| 263 | + } |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | |
| 267 | 267 | // les invalideurs sont de la forme "objet/id_objet" |
| 268 | 268 | // https://code.spip.net/@insere_invalideur |
| 269 | 269 | function insere_invalideur($inval, $fichier) { |
| 270 | - if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) { |
|
| 271 | - return $insere_invalideur($inval, $fichier); |
|
| 272 | - } |
|
| 270 | + if ($insere_invalideur = charger_fonction('insere_invalideur', 'inc', true)) { |
|
| 271 | + return $insere_invalideur($inval, $fichier); |
|
| 272 | + } |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | // |
@@ -277,16 +277,16 @@ discard block |
||
| 277 | 277 | // |
| 278 | 278 | // https://code.spip.net/@applique_invalideur |
| 279 | 279 | function applique_invalideur($depart) { |
| 280 | - if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) { |
|
| 281 | - return $applique_invalideur($depart); |
|
| 282 | - } |
|
| 280 | + if ($applique_invalideur = charger_fonction('applique_invalideur', 'inc', true)) { |
|
| 281 | + return $applique_invalideur($depart); |
|
| 282 | + } |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | // |
| 286 | 286 | // Invalider les caches liés à telle condition |
| 287 | 287 | // |
| 288 | 288 | function suivre_invalideur($cond, $modif = true) { |
| 289 | - if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) { |
|
| 290 | - return $suivre_invalideur($cond, $modif); |
|
| 291 | - } |
|
| 289 | + if ($suivre_invalideur = charger_fonction('suivre_invalideur', 'inc', true)) { |
|
| 290 | + return $suivre_invalideur($cond, $modif); |
|
| 291 | + } |
|
| 292 | 292 | } |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | $n = 0; |
| 46 | 46 | $time = isset($GLOBALS['meta']['cache_mark']) ? $GLOBALS['meta']['cache_mark'] : 0; |
| 47 | 47 | for ($i = 0; $i < 256; $i++) { |
| 48 | - $dir = _DIR_CACHE . sprintf('%02s', dechex($i)); |
|
| 48 | + $dir = _DIR_CACHE.sprintf('%02s', dechex($i)); |
|
| 49 | 49 | if (@is_dir($dir) and is_readable($dir) and $d = opendir($dir)) { |
| 50 | 50 | while (($f = readdir($d)) !== false) { |
| 51 | 51 | if (preg_match(',^[[0-9a-f]+\.cache$,S', $f) and $a = stat("$dir/$f")) { |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | // stocker la date_modif_$objet (ne sert a rien pour le moment) |
| 104 | 104 | if (isset($objet)) { |
| 105 | - ecrire_meta('derniere_modif_' . $objet, time()); |
|
| 105 | + ecrire_meta('derniere_modif_'.$objet, time()); |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // si $derniere_modif_invalide est un array('article', 'rubrique') |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | ) |
| 202 | 202 | ) { |
| 203 | 203 | // supprimer le fichier (de facon propre) |
| 204 | - supprimer_fichier(_DIR_CACHE . $cache); |
|
| 204 | + supprimer_fichier(_DIR_CACHE.$cache); |
|
| 205 | 205 | } else { |
| 206 | 206 | spip_log("Nom de fichier cache incorrect : $cache"); |
| 207 | 207 | } |
@@ -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'); |
@@ -41,27 +41,27 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function parametres_css_prive() { |
| 43 | 43 | |
| 44 | - $args = []; |
|
| 45 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 44 | + $args = []; |
|
| 45 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 51 | 51 | |
| 52 | - $c = isset($GLOBALS['visiteur_session']['prefs']['couleur']) |
|
| 53 | - ? $GLOBALS['visiteur_session']['prefs']['couleur'] |
|
| 54 | - : 2; |
|
| 52 | + $c = isset($GLOBALS['visiteur_session']['prefs']['couleur']) |
|
| 53 | + ? $GLOBALS['visiteur_session']['prefs']['couleur'] |
|
| 54 | + : 2; |
|
| 55 | 55 | |
| 56 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 57 | - parse_str($couleurs($c), $c); |
|
| 58 | - $args = array_merge($args, $c); |
|
| 56 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 57 | + parse_str($couleurs($c), $c); |
|
| 58 | + $args = array_merge($args, $c); |
|
| 59 | 59 | |
| 60 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 61 | - $args['var_mode'] = 'recalcul'; |
|
| 62 | - } |
|
| 60 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 61 | + $args['var_mode'] = 'recalcul'; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - return http_build_query($args); |
|
| 64 | + return http_build_query($args); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | |
@@ -84,91 +84,91 @@ discard block |
||
| 84 | 84 | * @return string |
| 85 | 85 | */ |
| 86 | 86 | function chercher_rubrique( |
| 87 | - $titre, |
|
| 88 | - $id_objet, |
|
| 89 | - $id_parent, |
|
| 90 | - $objet, |
|
| 91 | - $id_secteur, |
|
| 92 | - $restreint, |
|
| 93 | - $actionable = false, |
|
| 94 | - $retour_sans_cadre = false |
|
| 87 | + $titre, |
|
| 88 | + $id_objet, |
|
| 89 | + $id_parent, |
|
| 90 | + $objet, |
|
| 91 | + $id_secteur, |
|
| 92 | + $restreint, |
|
| 93 | + $actionable = false, |
|
| 94 | + $retour_sans_cadre = false |
|
| 95 | 95 | ) { |
| 96 | 96 | |
| 97 | - include_spip('inc/autoriser'); |
|
| 98 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 99 | - return ''; |
|
| 100 | - } |
|
| 101 | - if (!sql_countsel('spip_rubriques')) { |
|
| 102 | - return ''; |
|
| 103 | - } |
|
| 104 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 105 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 106 | - |
|
| 107 | - if ($id_parent == 0) { |
|
| 108 | - $logo = 'racine-24.png'; |
|
| 109 | - } elseif ($id_secteur == $id_parent) { |
|
| 110 | - $logo = 'secteur-24.png'; |
|
| 111 | - } else { |
|
| 112 | - $logo = 'rubrique-24.png'; |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - $confirm = ''; |
|
| 116 | - if ($objet == 'rubrique') { |
|
| 117 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 118 | - // confirmation du deplacement |
|
| 119 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 120 | - |
|
| 121 | - if ($contient_breves > 0) { |
|
| 122 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 123 | - $scb = _T( |
|
| 124 | - 'avis_deplacement_rubrique', |
|
| 125 | - [ |
|
| 126 | - 'contient_breves' => $contient_breves, |
|
| 127 | - 'scb' => $scb |
|
| 128 | - ] |
|
| 129 | - ); |
|
| 130 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 131 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 132 | - . $scb . |
|
| 133 | - "</label></div></div>\n"; |
|
| 134 | - } else { |
|
| 135 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - $form .= $confirm; |
|
| 139 | - if ($actionable) { |
|
| 140 | - if (strpos($form, '<select') !== false) { |
|
| 141 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 142 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 143 | - . '</div>'; |
|
| 144 | - } |
|
| 145 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 146 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 147 | - $form = generer_action_auteur( |
|
| 148 | - "editer_$objet", |
|
| 149 | - $id_objet, |
|
| 150 | - self(), |
|
| 151 | - $form, |
|
| 152 | - " method='post' class='submit_plongeur'" |
|
| 153 | - ); |
|
| 154 | - } else { |
|
| 155 | - $form = generer_action_auteur( |
|
| 156 | - 'editer_objet', |
|
| 157 | - "$objet/$id_objet", |
|
| 158 | - self(), |
|
| 159 | - $form, |
|
| 160 | - " method='post' class='submit_plongeur'" |
|
| 161 | - ); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - if ($retour_sans_cadre) { |
|
| 166 | - return $form; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - include_spip('inc/presentation'); |
|
| 170 | - |
|
| 171 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(true); |
|
| 97 | + include_spip('inc/autoriser'); |
|
| 98 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 99 | + return ''; |
|
| 100 | + } |
|
| 101 | + if (!sql_countsel('spip_rubriques')) { |
|
| 102 | + return ''; |
|
| 103 | + } |
|
| 104 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 105 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 106 | + |
|
| 107 | + if ($id_parent == 0) { |
|
| 108 | + $logo = 'racine-24.png'; |
|
| 109 | + } elseif ($id_secteur == $id_parent) { |
|
| 110 | + $logo = 'secteur-24.png'; |
|
| 111 | + } else { |
|
| 112 | + $logo = 'rubrique-24.png'; |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + $confirm = ''; |
|
| 116 | + if ($objet == 'rubrique') { |
|
| 117 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 118 | + // confirmation du deplacement |
|
| 119 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 120 | + |
|
| 121 | + if ($contient_breves > 0) { |
|
| 122 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 123 | + $scb = _T( |
|
| 124 | + 'avis_deplacement_rubrique', |
|
| 125 | + [ |
|
| 126 | + 'contient_breves' => $contient_breves, |
|
| 127 | + 'scb' => $scb |
|
| 128 | + ] |
|
| 129 | + ); |
|
| 130 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 131 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 132 | + . $scb . |
|
| 133 | + "</label></div></div>\n"; |
|
| 134 | + } else { |
|
| 135 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + $form .= $confirm; |
|
| 139 | + if ($actionable) { |
|
| 140 | + if (strpos($form, '<select') !== false) { |
|
| 141 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 142 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 143 | + . '</div>'; |
|
| 144 | + } |
|
| 145 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 146 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 147 | + $form = generer_action_auteur( |
|
| 148 | + "editer_$objet", |
|
| 149 | + $id_objet, |
|
| 150 | + self(), |
|
| 151 | + $form, |
|
| 152 | + " method='post' class='submit_plongeur'" |
|
| 153 | + ); |
|
| 154 | + } else { |
|
| 155 | + $form = generer_action_auteur( |
|
| 156 | + 'editer_objet', |
|
| 157 | + "$objet/$id_objet", |
|
| 158 | + self(), |
|
| 159 | + $form, |
|
| 160 | + " method='post' class='submit_plongeur'" |
|
| 161 | + ); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + if ($retour_sans_cadre) { |
|
| 166 | + return $form; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + include_spip('inc/presentation'); |
|
| 170 | + |
|
| 171 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(true); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
@@ -182,24 +182,24 @@ discard block |
||
| 182 | 182 | * @return bool |
| 183 | 183 | */ |
| 184 | 184 | function avoir_visiteurs($past = false, $accepter = true) { |
| 185 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 186 | - return true; |
|
| 187 | - } |
|
| 188 | - if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 189 | - return true; |
|
| 190 | - } |
|
| 191 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 192 | - return true; |
|
| 193 | - } |
|
| 194 | - if (!$past) { |
|
| 195 | - return false; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - return sql_countsel( |
|
| 199 | - 'spip_auteurs', |
|
| 200 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 185 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 186 | + return true; |
|
| 187 | + } |
|
| 188 | + if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 189 | + return true; |
|
| 190 | + } |
|
| 191 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 192 | + return true; |
|
| 193 | + } |
|
| 194 | + if (!$past) { |
|
| 195 | + return false; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + return sql_countsel( |
|
| 199 | + 'spip_auteurs', |
|
| 200 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 201 | 201 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 202 | - ); |
|
| 202 | + ); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -215,18 +215,18 @@ discard block |
||
| 215 | 215 | * @return array |
| 216 | 216 | */ |
| 217 | 217 | function statuts_articles_visibles($statut_auteur) { |
| 218 | - static $auth = []; |
|
| 219 | - if (!isset($auth[$statut_auteur])) { |
|
| 220 | - $auth[$statut_auteur] = []; |
|
| 221 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 222 | - foreach ($statuts as $s) { |
|
| 223 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 224 | - $auth[$statut_auteur][] = $s; |
|
| 225 | - } |
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - return $auth[$statut_auteur]; |
|
| 218 | + static $auth = []; |
|
| 219 | + if (!isset($auth[$statut_auteur])) { |
|
| 220 | + $auth[$statut_auteur] = []; |
|
| 221 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 222 | + foreach ($statuts as $s) { |
|
| 223 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 224 | + $auth[$statut_auteur][] = $s; |
|
| 225 | + } |
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + return $auth[$statut_auteur]; |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -240,38 +240,38 @@ discard block |
||
| 240 | 240 | * @return string |
| 241 | 241 | */ |
| 242 | 242 | function traduire_statut_auteur($statut, $attente = '') { |
| 243 | - $plus = ''; |
|
| 244 | - if ($statut == 'nouveau') { |
|
| 245 | - if ($attente) { |
|
| 246 | - $statut = $attente; |
|
| 247 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 248 | - } else { |
|
| 249 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - $recom = [ |
|
| 254 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 255 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 256 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 257 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 258 | - ]; |
|
| 259 | - if (isset($recom[$statut])) { |
|
| 260 | - return $recom[$statut] . $plus; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - // retrouver directement par le statut sinon |
|
| 264 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 265 | - if (isset($recom[$t])) { |
|
| 266 | - return $recom[$t] . $plus; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - return _T($t) . $plus; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 273 | - // c'est toujours plus informatif que rien du tout |
|
| 274 | - return $statut; |
|
| 243 | + $plus = ''; |
|
| 244 | + if ($statut == 'nouveau') { |
|
| 245 | + if ($attente) { |
|
| 246 | + $statut = $attente; |
|
| 247 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 248 | + } else { |
|
| 249 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + $recom = [ |
|
| 254 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 255 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 256 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 257 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 258 | + ]; |
|
| 259 | + if (isset($recom[$statut])) { |
|
| 260 | + return $recom[$statut] . $plus; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + // retrouver directement par le statut sinon |
|
| 264 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 265 | + if (isset($recom[$t])) { |
|
| 266 | + return $recom[$t] . $plus; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + return _T($t) . $plus; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 273 | + // c'est toujours plus informatif que rien du tout |
|
| 274 | + return $statut; |
|
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | /** |
@@ -282,28 +282,28 @@ discard block |
||
| 282 | 282 | * @return string |
| 283 | 283 | */ |
| 284 | 284 | function afficher_qui_edite($id_objet, $objet) { |
| 285 | - static $qui = []; |
|
| 286 | - if (isset($qui[$objet][$id_objet])) { |
|
| 287 | - return $qui[$objet][$id_objet]; |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 291 | - return $qui[$objet][$id_objet] = ''; |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - include_spip('inc/drapeau_edition'); |
|
| 295 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 296 | - if (!$modif) { |
|
| 297 | - return $qui[$objet][$id_objet] = ''; |
|
| 298 | - } |
|
| 299 | - |
|
| 300 | - include_spip('base/objets'); |
|
| 301 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 302 | - if (isset($infos['texte_signale_edition'])) { |
|
| 303 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 285 | + static $qui = []; |
|
| 286 | + if (isset($qui[$objet][$id_objet])) { |
|
| 287 | + return $qui[$objet][$id_objet]; |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + if ($GLOBALS['meta']['articles_modif'] == 'non') { |
|
| 291 | + return $qui[$objet][$id_objet] = ''; |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + include_spip('inc/drapeau_edition'); |
|
| 295 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 296 | + if (!$modif) { |
|
| 297 | + return $qui[$objet][$id_objet] = ''; |
|
| 298 | + } |
|
| 299 | + |
|
| 300 | + include_spip('base/objets'); |
|
| 301 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 302 | + if (isset($infos['texte_signale_edition'])) { |
|
| 303 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | /** |
@@ -321,57 +321,57 @@ discard block |
||
| 321 | 321 | * @return array |
| 322 | 322 | */ |
| 323 | 323 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true) { |
| 324 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 325 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - switch ($quoi) { |
|
| 329 | - case 'redacteurs': |
|
| 330 | - $statut = AUTEURS_MIN_REDAC; |
|
| 331 | - $statut = explode(',', $statut); |
|
| 332 | - if ($en_base) { |
|
| 333 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 334 | - $retire = array_diff($statut, $check); |
|
| 335 | - $statut = array_diff($statut, $retire); |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - return array_unique($statut); |
|
| 339 | - break; |
|
| 340 | - case 'visiteurs': |
|
| 341 | - $statut = []; |
|
| 342 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 343 | - $exclus = explode(',', $exclus); |
|
| 344 | - if (!$en_base) { |
|
| 345 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 346 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 347 | - } |
|
| 348 | - $s_complement = array_column( |
|
| 349 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 350 | - 'statut' |
|
| 351 | - ); |
|
| 352 | - |
|
| 353 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 354 | - break; |
|
| 355 | - default: |
|
| 356 | - case 'tous': |
|
| 357 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 358 | - $s_complement = array_column( |
|
| 359 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 360 | - 'statut' |
|
| 361 | - ); |
|
| 362 | - $statut = array_merge($statut, $s_complement); |
|
| 363 | - if ($en_base) { |
|
| 364 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 365 | - $retire = array_diff($statut, $check); |
|
| 366 | - $statut = array_diff($statut, $retire); |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - return array_unique($statut); |
|
| 370 | - break; |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - // on arrive jamais ici |
|
| 374 | - return array_values($GLOBALS['liste_des_statuts']); |
|
| 324 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 325 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + switch ($quoi) { |
|
| 329 | + case 'redacteurs': |
|
| 330 | + $statut = AUTEURS_MIN_REDAC; |
|
| 331 | + $statut = explode(',', $statut); |
|
| 332 | + if ($en_base) { |
|
| 333 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 334 | + $retire = array_diff($statut, $check); |
|
| 335 | + $statut = array_diff($statut, $retire); |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + return array_unique($statut); |
|
| 339 | + break; |
|
| 340 | + case 'visiteurs': |
|
| 341 | + $statut = []; |
|
| 342 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 343 | + $exclus = explode(',', $exclus); |
|
| 344 | + if (!$en_base) { |
|
| 345 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 346 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 347 | + } |
|
| 348 | + $s_complement = array_column( |
|
| 349 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 350 | + 'statut' |
|
| 351 | + ); |
|
| 352 | + |
|
| 353 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 354 | + break; |
|
| 355 | + default: |
|
| 356 | + case 'tous': |
|
| 357 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 358 | + $s_complement = array_column( |
|
| 359 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 360 | + 'statut' |
|
| 361 | + ); |
|
| 362 | + $statut = array_merge($statut, $s_complement); |
|
| 363 | + if ($en_base) { |
|
| 364 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 365 | + $retire = array_diff($statut, $check); |
|
| 366 | + $statut = array_diff($statut, $retire); |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + return array_unique($statut); |
|
| 370 | + break; |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + // on arrive jamais ici |
|
| 374 | + return array_values($GLOBALS['liste_des_statuts']); |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | /** |
@@ -387,28 +387,28 @@ discard block |
||
| 387 | 387 | */ |
| 388 | 388 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 389 | 389 | |
| 390 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 391 | - $in = !count($GLOBALS['connect_id_rubrique']) |
|
| 392 | - ? '' |
|
| 393 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 394 | - |
|
| 395 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 396 | - if ($objet == 'rubrique') { |
|
| 397 | - $id_rubrique = 0; |
|
| 398 | - } else { |
|
| 399 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 400 | - } |
|
| 401 | - |
|
| 402 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 403 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 404 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 405 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 406 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 407 | - } |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - return $id_rubrique; |
|
| 390 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 391 | + $in = !count($GLOBALS['connect_id_rubrique']) |
|
| 392 | + ? '' |
|
| 393 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 394 | + |
|
| 395 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 396 | + if ($objet == 'rubrique') { |
|
| 397 | + $id_rubrique = 0; |
|
| 398 | + } else { |
|
| 399 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 400 | + } |
|
| 401 | + |
|
| 402 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 403 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 404 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 405 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 406 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 407 | + } |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + return $id_rubrique; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -419,12 +419,12 @@ discard block |
||
| 419 | 419 | * @return string |
| 420 | 420 | */ |
| 421 | 421 | function lien_article_virtuel($virtuel) { |
| 422 | - include_spip('inc/lien'); |
|
| 423 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 424 | - return ''; |
|
| 425 | - } |
|
| 422 | + include_spip('inc/lien'); |
|
| 423 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 424 | + return ''; |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | - return propre('[->' . $virtuel . ']'); |
|
| 427 | + return propre('[->' . $virtuel . ']'); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | |
@@ -447,12 +447,12 @@ discard block |
||
| 447 | 447 | * Code HTML du lien |
| 448 | 448 | */ |
| 449 | 449 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 450 | - include_spip('inc/acces'); |
|
| 451 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 452 | - $args = param_low_sec($op, $args, $lang, 'rss'); |
|
| 453 | - $url = generer_url_public('rss', $args); |
|
| 450 | + include_spip('inc/acces'); |
|
| 451 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 452 | + $args = param_low_sec($op, $args, $lang, 'rss'); |
|
| 453 | + $url = generer_url_public('rss', $args); |
|
| 454 | 454 | |
| 455 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 455 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | |
@@ -464,74 +464,74 @@ discard block |
||
| 464 | 464 | */ |
| 465 | 465 | function alertes_auteur($id_auteur) { |
| 466 | 466 | |
| 467 | - $alertes = []; |
|
| 468 | - |
|
| 469 | - if ( |
|
| 470 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 471 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 472 | - ) { |
|
| 473 | - include_spip('genie/maintenance'); |
|
| 474 | - if ($msg = message_crash_tables()) { |
|
| 475 | - $alertes[] = $msg; |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - if ( |
|
| 480 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 481 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 482 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 483 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 484 | - ) { |
|
| 485 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 486 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; |
|
| 490 | - if ( |
|
| 491 | - $a |
|
| 492 | - and is_array($a = unserialize($a)) |
|
| 493 | - and count($a) |
|
| 494 | - ) { |
|
| 495 | - $update = false; |
|
| 496 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 497 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 498 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 499 | - $update = true; |
|
| 500 | - } |
|
| 501 | - if (isset($a[''])) { |
|
| 502 | - $alertes = array_merge($alertes, $a['']); |
|
| 503 | - unset($a['']); |
|
| 504 | - $update = true; |
|
| 505 | - } |
|
| 506 | - if ($update) { |
|
| 507 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 508 | - } |
|
| 509 | - } |
|
| 510 | - |
|
| 511 | - if ( |
|
| 512 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 513 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 514 | - ) { |
|
| 515 | - include_spip('inc/plugin'); |
|
| 516 | - $alertes[] = plugin_donne_erreurs(); |
|
| 517 | - } |
|
| 518 | - |
|
| 519 | - $alertes = pipeline( |
|
| 520 | - 'alertes_auteur', |
|
| 521 | - [ |
|
| 522 | - 'args' => [ |
|
| 523 | - 'id_auteur' => $id_auteur, |
|
| 524 | - 'exec' => _request('exec'), |
|
| 525 | - ], |
|
| 526 | - 'data' => $alertes |
|
| 527 | - ] |
|
| 528 | - ); |
|
| 529 | - |
|
| 530 | - if ($alertes = array_filter($alertes)) { |
|
| 531 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 532 | - join(' | ', $alertes) |
|
| 533 | - . '</div></div>'; |
|
| 534 | - } |
|
| 467 | + $alertes = []; |
|
| 468 | + |
|
| 469 | + if ( |
|
| 470 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 471 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 472 | + ) { |
|
| 473 | + include_spip('genie/maintenance'); |
|
| 474 | + if ($msg = message_crash_tables()) { |
|
| 475 | + $alertes[] = $msg; |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + if ( |
|
| 480 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 481 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 482 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 483 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 484 | + ) { |
|
| 485 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 486 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + $a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : ''; |
|
| 490 | + if ( |
|
| 491 | + $a |
|
| 492 | + and is_array($a = unserialize($a)) |
|
| 493 | + and count($a) |
|
| 494 | + ) { |
|
| 495 | + $update = false; |
|
| 496 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 497 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 498 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 499 | + $update = true; |
|
| 500 | + } |
|
| 501 | + if (isset($a[''])) { |
|
| 502 | + $alertes = array_merge($alertes, $a['']); |
|
| 503 | + unset($a['']); |
|
| 504 | + $update = true; |
|
| 505 | + } |
|
| 506 | + if ($update) { |
|
| 507 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 508 | + } |
|
| 509 | + } |
|
| 510 | + |
|
| 511 | + if ( |
|
| 512 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 513 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 514 | + ) { |
|
| 515 | + include_spip('inc/plugin'); |
|
| 516 | + $alertes[] = plugin_donne_erreurs(); |
|
| 517 | + } |
|
| 518 | + |
|
| 519 | + $alertes = pipeline( |
|
| 520 | + 'alertes_auteur', |
|
| 521 | + [ |
|
| 522 | + 'args' => [ |
|
| 523 | + 'id_auteur' => $id_auteur, |
|
| 524 | + 'exec' => _request('exec'), |
|
| 525 | + ], |
|
| 526 | + 'data' => $alertes |
|
| 527 | + ] |
|
| 528 | + ); |
|
| 529 | + |
|
| 530 | + if ($alertes = array_filter($alertes)) { |
|
| 531 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 532 | + join(' | ', $alertes) |
|
| 533 | + . '</div></div>'; |
|
| 534 | + } |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | /** |
@@ -541,9 +541,9 @@ discard block |
||
| 541 | 541 | * @return string |
| 542 | 542 | */ |
| 543 | 543 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 544 | - include_spip('inc/presenter_enfants'); |
|
| 544 | + include_spip('inc/presenter_enfants'); |
|
| 545 | 545 | |
| 546 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 546 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 547 | 547 | } |
| 548 | 548 | |
| 549 | 549 | /** |
@@ -561,15 +561,15 @@ discard block |
||
| 561 | 561 | * @return string |
| 562 | 562 | */ |
| 563 | 563 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 564 | - $titre = attribut_html($titre); |
|
| 565 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 566 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 567 | - |
|
| 568 | - if (!$titre_lien) { |
|
| 569 | - return $icone; |
|
| 570 | - } else { |
|
| 571 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 572 | - } |
|
| 564 | + $titre = attribut_html($titre); |
|
| 565 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 566 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 567 | + |
|
| 568 | + if (!$titre_lien) { |
|
| 569 | + return $icone; |
|
| 570 | + } else { |
|
| 571 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 572 | + } |
|
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | |
@@ -588,17 +588,17 @@ discard block |
||
| 588 | 588 | * @return array |
| 589 | 589 | */ |
| 590 | 590 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 591 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 592 | - if (!count($res)) { |
|
| 593 | - return []; |
|
| 594 | - } |
|
| 595 | - $r = reset($res); |
|
| 596 | - if (isset($r['rang_lien'])) { |
|
| 597 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 598 | - asort($l); |
|
| 599 | - $l = array_keys($l); |
|
| 600 | - } else { |
|
| 601 | - $l = array_column($res, $objet_source); |
|
| 602 | - } |
|
| 603 | - return $l; |
|
| 591 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 592 | + if (!count($res)) { |
|
| 593 | + return []; |
|
| 594 | + } |
|
| 595 | + $r = reset($res); |
|
| 596 | + if (isset($r['rang_lien'])) { |
|
| 597 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 598 | + asort($l); |
|
| 599 | + $l = array_keys($l); |
|
| 600 | + } else { |
|
| 601 | + $l = array_column($res, $objet_source); |
|
| 602 | + } |
|
| 603 | + return $l; |
|
| 604 | 604 | } |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | if ($objet == 'rubrique') { |
| 117 | 117 | // si c'est une rubrique-secteur contenant des breves, demander la |
| 118 | 118 | // confirmation du deplacement |
| 119 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 119 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique='.intval($id_objet)); |
|
| 120 | 120 | |
| 121 | 121 | if ($contient_breves > 0) { |
| 122 | 122 | $scb = ($contient_breves > 1 ? 's' : ''); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | ); |
| 130 | 130 | $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
| 131 | 131 | . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
| 132 | - . $scb . |
|
| 132 | + . $scb. |
|
| 133 | 133 | "</label></div></div>\n"; |
| 134 | 134 | } else { |
| 135 | 135 | $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
@@ -138,11 +138,11 @@ discard block |
||
| 138 | 138 | $form .= $confirm; |
| 139 | 139 | if ($actionable) { |
| 140 | 140 | if (strpos($form, '<select') !== false) { |
| 141 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 142 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | + $form .= "<div style='text-align: ".$GLOBALS['spip_lang_right'].";'>" |
|
| 142 | + . '<input class="fondo submit btn" type="submit" value="'._T('bouton_choisir').'"/>' |
|
| 143 | 143 | . '</div>'; |
| 144 | 144 | } |
| 145 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 145 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n".$form; |
|
| 146 | 146 | if ($action = charger_fonction("editer_$objet", 'action', true)) { |
| 147 | 147 | $form = generer_action_auteur( |
| 148 | 148 | "editer_$objet", |
@@ -168,7 +168,7 @@ discard block |
||
| 168 | 168 | |
| 169 | 169 | include_spip('inc/presentation'); |
| 170 | 170 | |
| 171 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(true); |
|
| 171 | + return debut_cadre_couleur($logo, true, '', $titre).$form.fin_cadre_couleur(true); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | if ($statut == 'nouveau') { |
| 245 | 245 | if ($attente) { |
| 246 | 246 | $statut = $attente; |
| 247 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 247 | + $plus = ' ('._T('info_statut_auteur_a_confirmer').')'; |
|
| 248 | 248 | } else { |
| 249 | 249 | return _T('info_statut_auteur_a_confirmer'); |
| 250 | 250 | } |
@@ -257,16 +257,16 @@ discard block |
||
| 257 | 257 | '5poubelle' => _T('texte_statut_poubelle'), // bouh |
| 258 | 258 | ]; |
| 259 | 259 | if (isset($recom[$statut])) { |
| 260 | - return $recom[$statut] . $plus; |
|
| 260 | + return $recom[$statut].$plus; |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | // retrouver directement par le statut sinon |
| 264 | 264 | if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
| 265 | 265 | if (isset($recom[$t])) { |
| 266 | - return $recom[$t] . $plus; |
|
| 266 | + return $recom[$t].$plus; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - return _T($t) . $plus; |
|
| 269 | + return _T($t).$plus; |
|
| 270 | 270 | } |
| 271 | 271 | |
| 272 | 272 | // si on a pas reussi a le traduire, retournons la chaine telle quelle |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
| 391 | 391 | $in = !count($GLOBALS['connect_id_rubrique']) |
| 392 | 392 | ? '' |
| 393 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 393 | + : (' AND '.sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 394 | 394 | |
| 395 | 395 | // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
| 396 | 396 | if ($objet == 'rubrique') { |
@@ -424,7 +424,7 @@ discard block |
||
| 424 | 424 | return ''; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | - return propre('[->' . $virtuel . ']'); |
|
| 427 | + return propre('[->'.$virtuel.']'); |
|
| 428 | 428 | } |
| 429 | 429 | |
| 430 | 430 | |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $args = param_low_sec($op, $args, $lang, 'rss'); |
| 453 | 453 | $url = generer_url_public('rss', $args); |
| 454 | 454 | |
| 455 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 455 | + return "<a style='float: ".$GLOBALS['spip_lang_right'].";' href='$url'>$clic</a>"; |
|
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | |
@@ -528,7 +528,7 @@ discard block |
||
| 528 | 528 | ); |
| 529 | 529 | |
| 530 | 530 | if ($alertes = array_filter($alertes)) { |
| 531 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 531 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>". |
|
| 532 | 532 | join(' | ', $alertes) |
| 533 | 533 | . '</div></div>'; |
| 534 | 534 | } |
@@ -562,13 +562,13 @@ discard block |
||
| 562 | 562 | */ |
| 563 | 563 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 564 | 564 | $titre = attribut_html($titre); |
| 565 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 566 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 565 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>". |
|
| 566 | + http_img_pack('information-16.png', $titre).'</a>'; |
|
| 567 | 567 | |
| 568 | 568 | if (!$titre_lien) { |
| 569 | 569 | return $icone; |
| 570 | 570 | } else { |
| 571 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 571 | + return $icone."\n<a href='$lien'>$titre_lien</a>"; |
|
| 572 | 572 | } |
| 573 | 573 | } |
| 574 | 574 | |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/filtres'); |
@@ -46,56 +46,56 @@ discard block |
||
| 46 | 46 | **/ |
| 47 | 47 | function inc_selectionner_dist($sel, $idom = '', $exclus = 0, $aff_racine = false, $recur = true, $do = 'aff') { |
| 48 | 48 | |
| 49 | - if ($recur) { |
|
| 50 | - $recur = mini_hier($sel); |
|
| 51 | - } else { |
|
| 52 | - $sel = 0; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - if ($aff_racine) { |
|
| 56 | - $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 57 | - $idom3 = $idom . '_selection'; |
|
| 58 | - |
|
| 59 | - $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
|
| 60 | - |
|
| 61 | - $ondbClick = strtr( |
|
| 62 | - str_replace( |
|
| 63 | - "'", |
|
| 64 | - '’', |
|
| 65 | - str_replace( |
|
| 66 | - '"', |
|
| 67 | - '"', |
|
| 68 | - textebrut(_T('info_racine_site')) |
|
| 69 | - ) |
|
| 70 | - ), |
|
| 71 | - "\n\r", |
|
| 72 | - ' ' |
|
| 73 | - ); |
|
| 74 | - |
|
| 75 | - $js_func = $do . '_selection_titre'; |
|
| 76 | - $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
|
| 77 | - |
|
| 78 | - $aff_racine = "<div class='petit-item petite-racine item'>" |
|
| 79 | - . "<a href='#'" |
|
| 80 | - . 'onclick="' |
|
| 81 | - . $onClick |
|
| 82 | - . "\"\nondbclick=\"" |
|
| 83 | - . $ondbClick |
|
| 84 | - . $onClick |
|
| 85 | - . '">' |
|
| 86 | - . _T('info_racine_site') |
|
| 87 | - . '</a></div>'; |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do"); |
|
| 91 | - |
|
| 92 | - $plonger = charger_fonction('plonger', 'inc'); |
|
| 93 | - $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do); |
|
| 94 | - |
|
| 95 | - // url completee par la fonction JS onkeypress_rechercher |
|
| 96 | - $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type="); |
|
| 97 | - |
|
| 98 | - return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init); |
|
| 49 | + if ($recur) { |
|
| 50 | + $recur = mini_hier($sel); |
|
| 51 | + } else { |
|
| 52 | + $sel = 0; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + if ($aff_racine) { |
|
| 56 | + $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
|
| 57 | + $idom3 = $idom . '_selection'; |
|
| 58 | + |
|
| 59 | + $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
|
| 60 | + |
|
| 61 | + $ondbClick = strtr( |
|
| 62 | + str_replace( |
|
| 63 | + "'", |
|
| 64 | + '’', |
|
| 65 | + str_replace( |
|
| 66 | + '"', |
|
| 67 | + '"', |
|
| 68 | + textebrut(_T('info_racine_site')) |
|
| 69 | + ) |
|
| 70 | + ), |
|
| 71 | + "\n\r", |
|
| 72 | + ' ' |
|
| 73 | + ); |
|
| 74 | + |
|
| 75 | + $js_func = $do . '_selection_titre'; |
|
| 76 | + $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
|
| 77 | + |
|
| 78 | + $aff_racine = "<div class='petit-item petite-racine item'>" |
|
| 79 | + . "<a href='#'" |
|
| 80 | + . 'onclick="' |
|
| 81 | + . $onClick |
|
| 82 | + . "\"\nondbclick=\"" |
|
| 83 | + . $ondbClick |
|
| 84 | + . $onClick |
|
| 85 | + . '">' |
|
| 86 | + . _T('info_racine_site') |
|
| 87 | + . '</a></div>'; |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + $url_init = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclus&id=0&col=1&do=$do"); |
|
| 91 | + |
|
| 92 | + $plonger = charger_fonction('plonger', 'inc'); |
|
| 93 | + $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do); |
|
| 94 | + |
|
| 95 | + // url completee par la fonction JS onkeypress_rechercher |
|
| 96 | + $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type="); |
|
| 97 | + |
|
| 98 | + return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init); |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | /** |
@@ -113,58 +113,58 @@ discard block |
||
| 113 | 113 | **/ |
| 114 | 114 | function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') { |
| 115 | 115 | |
| 116 | - $idom1 = $idom . '_champ_recherche'; |
|
| 117 | - $idom2 = $idom . '_principal'; |
|
| 118 | - $idom3 = $idom . '_selection'; |
|
| 119 | - $idom4 = $idom . '_col_1'; |
|
| 120 | - $idom5 = 'img_' . $idom4; |
|
| 121 | - $idom6 = $idom . '_fonc'; |
|
| 122 | - |
|
| 123 | - return "<div id='$idom'>" |
|
| 124 | - . "<a id='$idom6' style='visibility: hidden;'" |
|
| 125 | - . ($url_init ? "\nhref='$url_init'" : '') |
|
| 126 | - . '></a>' |
|
| 127 | - . "<div class='recherche_rapide_parent formulaire_recherche'>" |
|
| 128 | - . http_img_pack( |
|
| 129 | - 'loader.svg', |
|
| 130 | - '', |
|
| 131 | - "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 132 | - ) |
|
| 133 | - . '' |
|
| 134 | - . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 135 | - // eliminer Return car il provoque la soumission (balise unique) |
|
| 136 | - // et eliminer Tab pour la navigation au clavier |
|
| 137 | - // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
|
| 138 | - // resultats retournes par la recherche |
|
| 139 | - . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\"" |
|
| 140 | - // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier) |
|
| 141 | - . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value," |
|
| 142 | - // la destination de la recherche |
|
| 143 | - . "'$idom4'" |
|
| 116 | + $idom1 = $idom . '_champ_recherche'; |
|
| 117 | + $idom2 = $idom . '_principal'; |
|
| 118 | + $idom3 = $idom . '_selection'; |
|
| 119 | + $idom4 = $idom . '_col_1'; |
|
| 120 | + $idom5 = 'img_' . $idom4; |
|
| 121 | + $idom6 = $idom . '_fonc'; |
|
| 122 | + |
|
| 123 | + return "<div id='$idom'>" |
|
| 124 | + . "<a id='$idom6' style='visibility: hidden;'" |
|
| 125 | + . ($url_init ? "\nhref='$url_init'" : '') |
|
| 126 | + . '></a>' |
|
| 127 | + . "<div class='recherche_rapide_parent formulaire_recherche'>" |
|
| 128 | + . http_img_pack( |
|
| 129 | + 'loader.svg', |
|
| 130 | + '', |
|
| 131 | + "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 132 | + ) |
|
| 133 | + . '' |
|
| 134 | + . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 135 | + // eliminer Return car il provoque la soumission (balise unique) |
|
| 136 | + // et eliminer Tab pour la navigation au clavier |
|
| 137 | + // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
|
| 138 | + // resultats retournes par la recherche |
|
| 139 | + . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3 || k==9){return false;}\"" |
|
| 140 | + // lancer la recherche apres le filtrage ci-dessus sauf sur le tab (navigation au clavier) |
|
| 141 | + . "\nonkeyup=\"if(event.keyCode==9){return false;};return onkey_rechercher(this.value," |
|
| 142 | + // la destination de la recherche |
|
| 143 | + . "'$idom4'" |
|
| 144 | 144 | # . "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id" |
| 145 | - . ",'" |
|
| 146 | - // l'url effectuant la recherche |
|
| 147 | - . $url |
|
| 148 | - . "'," |
|
| 149 | - // le noeud contenant un gif anime |
|
| 150 | - // . "'idom5'" |
|
| 151 | - . 'this.parentNode.previousSibling.firstChild' |
|
| 152 | - . ",'" |
|
| 153 | - // la valeur de l'attribut Name a remplir |
|
| 154 | - . $name |
|
| 155 | - . "','" |
|
| 156 | - // noeud invisible memorisant l'URL initiale (pour re-initialisation) |
|
| 157 | - . $idom6 |
|
| 158 | - . "')\"" |
|
| 159 | - . ' />' |
|
| 160 | - . "\n</div>" |
|
| 161 | - . ($racine ? "<div>$racine</div>" : '') |
|
| 162 | - . "<div id='" |
|
| 163 | - . $idom2 |
|
| 164 | - . "'><div id='$idom4'" |
|
| 165 | - . " class=''>" |
|
| 166 | - . $liste |
|
| 167 | - . "</div></div>\n<div id='$idom3'></div></div>\n"; |
|
| 145 | + . ",'" |
|
| 146 | + // l'url effectuant la recherche |
|
| 147 | + . $url |
|
| 148 | + . "'," |
|
| 149 | + // le noeud contenant un gif anime |
|
| 150 | + // . "'idom5'" |
|
| 151 | + . 'this.parentNode.previousSibling.firstChild' |
|
| 152 | + . ",'" |
|
| 153 | + // la valeur de l'attribut Name a remplir |
|
| 154 | + . $name |
|
| 155 | + . "','" |
|
| 156 | + // noeud invisible memorisant l'URL initiale (pour re-initialisation) |
|
| 157 | + . $idom6 |
|
| 158 | + . "')\"" |
|
| 159 | + . ' />' |
|
| 160 | + . "\n</div>" |
|
| 161 | + . ($racine ? "<div>$racine</div>" : '') |
|
| 162 | + . "<div id='" |
|
| 163 | + . $idom2 |
|
| 164 | + . "'><div id='$idom4'" |
|
| 165 | + . " class=''>" |
|
| 166 | + . $liste |
|
| 167 | + . "</div></div>\n<div id='$idom3'></div></div>\n"; |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | /** |
@@ -176,11 +176,11 @@ discard block |
||
| 176 | 176 | **/ |
| 177 | 177 | function mini_hier($id_rubrique) { |
| 178 | 178 | |
| 179 | - $liste = $id_rubrique; |
|
| 180 | - $id_rubrique = intval($id_rubrique); |
|
| 181 | - while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 182 | - $liste = $id_rubrique . ",$liste"; |
|
| 183 | - } |
|
| 179 | + $liste = $id_rubrique; |
|
| 180 | + $id_rubrique = intval($id_rubrique); |
|
| 181 | + while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 182 | + $liste = $id_rubrique . ",$liste"; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - return explode(',', "0,$liste"); |
|
| 185 | + return explode(',', "0,$liste"); |
|
| 186 | 186 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | if ($aff_racine) { |
| 56 | 56 | $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
| 57 | - $idom3 = $idom . '_selection'; |
|
| 57 | + $idom3 = $idom.'_selection'; |
|
| 58 | 58 | |
| 59 | 59 | $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;"; |
| 60 | 60 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | ' ' |
| 73 | 73 | ); |
| 74 | 74 | |
| 75 | - $js_func = $do . '_selection_titre'; |
|
| 75 | + $js_func = $do.'_selection_titre'; |
|
| 76 | 76 | $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');"; |
| 77 | 77 | |
| 78 | 78 | $aff_racine = "<div class='petit-item petite-racine item'>" |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | **/ |
| 114 | 114 | function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init = '') { |
| 115 | 115 | |
| 116 | - $idom1 = $idom . '_champ_recherche'; |
|
| 117 | - $idom2 = $idom . '_principal'; |
|
| 118 | - $idom3 = $idom . '_selection'; |
|
| 119 | - $idom4 = $idom . '_col_1'; |
|
| 120 | - $idom5 = 'img_' . $idom4; |
|
| 121 | - $idom6 = $idom . '_fonc'; |
|
| 116 | + $idom1 = $idom.'_champ_recherche'; |
|
| 117 | + $idom2 = $idom.'_principal'; |
|
| 118 | + $idom3 = $idom.'_selection'; |
|
| 119 | + $idom4 = $idom.'_col_1'; |
|
| 120 | + $idom5 = 'img_'.$idom4; |
|
| 121 | + $idom6 = $idom.'_fonc'; |
|
| 122 | 122 | |
| 123 | 123 | return "<div id='$idom'>" |
| 124 | 124 | . "<a id='$idom6' style='visibility: hidden;'" |
@@ -128,10 +128,10 @@ discard block |
||
| 128 | 128 | . http_img_pack( |
| 129 | 129 | 'loader.svg', |
| 130 | 130 | '', |
| 131 | - "class='loader' style='visibility: hidden;float:" . $GLOBALS['spip_lang_right'] . "' id='$idom5'" |
|
| 131 | + "class='loader' style='visibility: hidden;float:".$GLOBALS['spip_lang_right']."' id='$idom5'" |
|
| 132 | 132 | ) |
| 133 | 133 | . '' |
| 134 | - . "<input style='width: 10em;float:" . $GLOBALS['spip_lang_right'] . ";' type='text' class='text search' id='$idom1' placeholder='" . _T('info_rechercher') . "'" |
|
| 134 | + . "<input style='width: 10em;float:".$GLOBALS['spip_lang_right'].";' type='text' class='text search' id='$idom1' placeholder='"._T('info_rechercher')."'" |
|
| 135 | 135 | // eliminer Return car il provoque la soumission (balise unique) |
| 136 | 136 | // et eliminer Tab pour la navigation au clavier |
| 137 | 137 | // ce serait encore mieux de ne le faire que s'il y a encore plusieurs |
@@ -178,8 +178,8 @@ discard block |
||
| 178 | 178 | |
| 179 | 179 | $liste = $id_rubrique; |
| 180 | 180 | $id_rubrique = intval($id_rubrique); |
| 181 | - while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = ' . $id_rubrique)) { |
|
| 182 | - $liste = $id_rubrique . ",$liste"; |
|
| 181 | + while ($id_rubrique = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique = '.$id_rubrique)) { |
|
| 182 | + $liste = $id_rubrique.",$liste"; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | return explode(',', "0,$liste"); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Notifications |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function inc_notifications_dist($quoi, $id = 0, $options = []) { |
| 35 | 35 | |
| 36 | - // charger les fichiers qui veulent ajouter des definitions |
|
| 37 | - // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ... |
|
| 38 | - pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]); |
|
| 36 | + // charger les fichiers qui veulent ajouter des definitions |
|
| 37 | + // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ... |
|
| 38 | + pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]); |
|
| 39 | 39 | |
| 40 | - if ($notification = charger_fonction($quoi, 'notifications', true)) { |
|
| 41 | - spip_log("$notification($quoi,$id" |
|
| 42 | - . ($options ? ',' . serialize($options) : '') |
|
| 43 | - . ')', 'notifications'); |
|
| 44 | - $notification($quoi, $id, $options); |
|
| 45 | - } |
|
| 40 | + if ($notification = charger_fonction($quoi, 'notifications', true)) { |
|
| 41 | + spip_log("$notification($quoi,$id" |
|
| 42 | + . ($options ? ',' . serialize($options) : '') |
|
| 43 | + . ')', 'notifications'); |
|
| 44 | + $notification($quoi, $id, $options); |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -56,14 +56,14 @@ discard block |
||
| 56 | 56 | * @param array $exclure |
| 57 | 57 | */ |
| 58 | 58 | function notifications_nettoyer_emails(&$emails, $exclure = []) { |
| 59 | - // filtrer et unifier |
|
| 60 | - $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails)))); |
|
| 61 | - if ($exclure and count($exclure)) { |
|
| 62 | - // nettoyer les exclusions d'abord |
|
| 63 | - notifications_nettoyer_emails($exclure); |
|
| 64 | - // faire un diff |
|
| 65 | - $emails = array_diff($emails, $exclure); |
|
| 66 | - } |
|
| 59 | + // filtrer et unifier |
|
| 60 | + $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails)))); |
|
| 61 | + if ($exclure and count($exclure)) { |
|
| 62 | + // nettoyer les exclusions d'abord |
|
| 63 | + notifications_nettoyer_emails($exclure); |
|
| 64 | + // faire un diff |
|
| 65 | + $emails = array_diff($emails, $exclure); |
|
| 66 | + } |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | /** |
@@ -78,90 +78,90 @@ discard block |
||
| 78 | 78 | * @param string $headers |
| 79 | 79 | */ |
| 80 | 80 | function notifications_envoyer_mails($emails, $texte, $sujet = '', $from = '', $headers = '') { |
| 81 | - // rien a faire si pas de texte ! |
|
| 82 | - if (!strlen($texte)) { |
|
| 83 | - return; |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - // si on ne specifie qu'un email, le mettre dans un tableau |
|
| 87 | - if (!is_array($emails)) { |
|
| 88 | - $emails = explode(',', $emails); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - notifications_nettoyer_emails($emails); |
|
| 92 | - |
|
| 93 | - // tester si le mail est deja en html |
|
| 94 | - if ( |
|
| 95 | - strpos($texte, '<') !== false // eviter les tests suivants si possible |
|
| 96 | - and $ttrim = trim($texte) |
|
| 97 | - and substr($ttrim, 0, 1) == '<' |
|
| 98 | - and substr($ttrim, -1, 1) == '>' |
|
| 99 | - and stripos($ttrim, '</html>') !== false |
|
| 100 | - ) { |
|
| 101 | - if (!strlen($sujet)) { |
|
| 102 | - // dans ce cas on ruse un peu : extraire le sujet du title |
|
| 103 | - if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) { |
|
| 104 | - $sujet = $m[1]; |
|
| 105 | - } else { |
|
| 106 | - // fallback, on prend le body si on le trouve |
|
| 107 | - if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) { |
|
| 108 | - $ttrim = $m[1]; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - // et on extrait la premiere ligne de vrai texte... |
|
| 112 | - // nettoyer le html et les retours chariots |
|
| 113 | - $ttrim = textebrut($ttrim); |
|
| 114 | - $ttrim = str_replace("\r\n", "\r", $ttrim); |
|
| 115 | - $ttrim = str_replace("\r", "\n", $ttrim); |
|
| 116 | - // decouper |
|
| 117 | - $ttrim = explode("\n", trim($ttrim)); |
|
| 118 | - // extraire la premiere ligne de texte brut |
|
| 119 | - $sujet = array_shift($ttrim); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - // si besoin on ajoute le content-type dans les headers |
|
| 124 | - if (stripos($headers, 'Content-Type') === false) { |
|
| 125 | - $headers .= "Content-Type: text/html\n"; |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - // si le sujet est vide, extraire la premiere ligne du corps |
|
| 130 | - // du mail qui est donc du texte |
|
| 131 | - if (!strlen($sujet)) { |
|
| 132 | - // nettoyer un peu les retours chariots |
|
| 133 | - $texte = str_replace("\r\n", "\r", $texte); |
|
| 134 | - $texte = str_replace("\r", "\n", $texte); |
|
| 135 | - // decouper |
|
| 136 | - $texte = explode("\n", trim($texte)); |
|
| 137 | - // extraire la premiere ligne |
|
| 138 | - $sujet = array_shift($texte); |
|
| 139 | - $texte = trim(implode("\n", $texte)); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 143 | - foreach ($emails as $email) { |
|
| 144 | - // passer dans un pipeline qui permet un ajout eventuel |
|
| 145 | - // (url de suivi des notifications par exemple) |
|
| 146 | - $envoi = pipeline( |
|
| 147 | - 'notifications_envoyer_mails', |
|
| 148 | - [ |
|
| 149 | - 'email' => $email, |
|
| 150 | - 'sujet' => $sujet, |
|
| 151 | - 'texte' => $texte, |
|
| 152 | - 'from' => $from, |
|
| 153 | - 'headers' => $headers, |
|
| 154 | - ] |
|
| 155 | - ); |
|
| 156 | - $email = $envoi['email']; |
|
| 157 | - |
|
| 158 | - job_queue_add( |
|
| 159 | - 'envoyer_mail', |
|
| 160 | - ">$email : " . $envoi['sujet'], |
|
| 161 | - [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
|
| 162 | - 'inc/' |
|
| 163 | - ); |
|
| 164 | - } |
|
| 81 | + // rien a faire si pas de texte ! |
|
| 82 | + if (!strlen($texte)) { |
|
| 83 | + return; |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + // si on ne specifie qu'un email, le mettre dans un tableau |
|
| 87 | + if (!is_array($emails)) { |
|
| 88 | + $emails = explode(',', $emails); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + notifications_nettoyer_emails($emails); |
|
| 92 | + |
|
| 93 | + // tester si le mail est deja en html |
|
| 94 | + if ( |
|
| 95 | + strpos($texte, '<') !== false // eviter les tests suivants si possible |
|
| 96 | + and $ttrim = trim($texte) |
|
| 97 | + and substr($ttrim, 0, 1) == '<' |
|
| 98 | + and substr($ttrim, -1, 1) == '>' |
|
| 99 | + and stripos($ttrim, '</html>') !== false |
|
| 100 | + ) { |
|
| 101 | + if (!strlen($sujet)) { |
|
| 102 | + // dans ce cas on ruse un peu : extraire le sujet du title |
|
| 103 | + if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) { |
|
| 104 | + $sujet = $m[1]; |
|
| 105 | + } else { |
|
| 106 | + // fallback, on prend le body si on le trouve |
|
| 107 | + if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) { |
|
| 108 | + $ttrim = $m[1]; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + // et on extrait la premiere ligne de vrai texte... |
|
| 112 | + // nettoyer le html et les retours chariots |
|
| 113 | + $ttrim = textebrut($ttrim); |
|
| 114 | + $ttrim = str_replace("\r\n", "\r", $ttrim); |
|
| 115 | + $ttrim = str_replace("\r", "\n", $ttrim); |
|
| 116 | + // decouper |
|
| 117 | + $ttrim = explode("\n", trim($ttrim)); |
|
| 118 | + // extraire la premiere ligne de texte brut |
|
| 119 | + $sujet = array_shift($ttrim); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + // si besoin on ajoute le content-type dans les headers |
|
| 124 | + if (stripos($headers, 'Content-Type') === false) { |
|
| 125 | + $headers .= "Content-Type: text/html\n"; |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + // si le sujet est vide, extraire la premiere ligne du corps |
|
| 130 | + // du mail qui est donc du texte |
|
| 131 | + if (!strlen($sujet)) { |
|
| 132 | + // nettoyer un peu les retours chariots |
|
| 133 | + $texte = str_replace("\r\n", "\r", $texte); |
|
| 134 | + $texte = str_replace("\r", "\n", $texte); |
|
| 135 | + // decouper |
|
| 136 | + $texte = explode("\n", trim($texte)); |
|
| 137 | + // extraire la premiere ligne |
|
| 138 | + $sujet = array_shift($texte); |
|
| 139 | + $texte = trim(implode("\n", $texte)); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 143 | + foreach ($emails as $email) { |
|
| 144 | + // passer dans un pipeline qui permet un ajout eventuel |
|
| 145 | + // (url de suivi des notifications par exemple) |
|
| 146 | + $envoi = pipeline( |
|
| 147 | + 'notifications_envoyer_mails', |
|
| 148 | + [ |
|
| 149 | + 'email' => $email, |
|
| 150 | + 'sujet' => $sujet, |
|
| 151 | + 'texte' => $texte, |
|
| 152 | + 'from' => $from, |
|
| 153 | + 'headers' => $headers, |
|
| 154 | + ] |
|
| 155 | + ); |
|
| 156 | + $email = $envoi['email']; |
|
| 157 | + |
|
| 158 | + job_queue_add( |
|
| 159 | + 'envoyer_mail', |
|
| 160 | + ">$email : " . $envoi['sujet'], |
|
| 161 | + [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
|
| 162 | + 'inc/' |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | * @return string |
| 178 | 178 | */ |
| 179 | 179 | function email_notification_objet($id_objet, $type_objet, $modele) { |
| 180 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 181 | - $id_type = id_table_objet($type_objet); |
|
| 180 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 181 | + $id_type = id_table_objet($type_objet); |
|
| 182 | 182 | |
| 183 | - return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]); |
|
| 183 | + return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]); |
|
| 184 | 184 | } |
| 185 | 185 | |
| 186 | 186 | /** |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @return string |
| 196 | 196 | */ |
| 197 | 197 | function email_notification_article($id_article, $modele) { |
| 198 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 198 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 199 | 199 | |
| 200 | - return recuperer_fond($modele, ['id_article' => $id_article]); |
|
| 200 | + return recuperer_fond($modele, ['id_article' => $id_article]); |
|
| 201 | 201 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | if ($notification = charger_fonction($quoi, 'notifications', true)) { |
| 41 | 41 | spip_log("$notification($quoi,$id" |
| 42 | - . ($options ? ',' . serialize($options) : '') |
|
| 42 | + . ($options ? ','.serialize($options) : '') |
|
| 43 | 43 | . ')', 'notifications'); |
| 44 | 44 | $notification($quoi, $id, $options); |
| 45 | 45 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | job_queue_add( |
| 159 | 159 | 'envoyer_mail', |
| 160 | - ">$email : " . $envoi['sujet'], |
|
| 160 | + ">$email : ".$envoi['sujet'], |
|
| 161 | 161 | [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
| 162 | 162 | 'inc/' |
| 163 | 163 | ); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Mail |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -31,27 +31,27 @@ discard block |
||
| 31 | 31 | * - la normalisation de la dernière adresse donnée sinon |
| 32 | 32 | **/ |
| 33 | 33 | function inc_email_valide_dist($adresses) { |
| 34 | - // eviter d'injecter n'importe quoi dans preg_match |
|
| 35 | - if (!is_string($adresses)) { |
|
| 36 | - return false; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - // Si c'est un spammeur autant arreter tout de suite |
|
| 40 | - if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) { |
|
| 41 | - spip_log("Tentative d'injection de mail : $adresses"); |
|
| 42 | - |
|
| 43 | - return false; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - foreach (explode(',', $adresses) as $v) { |
|
| 47 | - // nettoyer certains formats |
|
| 48 | - // "Marie Toto <[email protected]>" |
|
| 49 | - $adresse = trim(preg_replace(',^[^<>"]*<([^<>"]+)>$,i', "\\1", $v)); |
|
| 50 | - // RFC 822 |
|
| 51 | - if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) { |
|
| 52 | - return false; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return $adresse; |
|
| 34 | + // eviter d'injecter n'importe quoi dans preg_match |
|
| 35 | + if (!is_string($adresses)) { |
|
| 36 | + return false; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + // Si c'est un spammeur autant arreter tout de suite |
|
| 40 | + if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) { |
|
| 41 | + spip_log("Tentative d'injection de mail : $adresses"); |
|
| 42 | + |
|
| 43 | + return false; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + foreach (explode(',', $adresses) as $v) { |
|
| 47 | + // nettoyer certains formats |
|
| 48 | + // "Marie Toto <[email protected]>" |
|
| 49 | + $adresse = trim(preg_replace(',^[^<>"]*<([^<>"]+)>$,i', "\\1", $v)); |
|
| 50 | + // RFC 822 |
|
| 51 | + if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) { |
|
| 52 | + return false; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return $adresse; |
|
| 57 | 57 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Logos |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -37,34 +37,34 @@ discard block |
||
| 37 | 37 | **/ |
| 38 | 38 | function inc_chercher_logo_dist($id, $_id_objet, $mode = 'on', $compat_old_logos = true) { |
| 39 | 39 | |
| 40 | - $mode = preg_replace(',\W,', '', $mode); |
|
| 41 | - if ($mode) { |
|
| 42 | - // chercher dans la base |
|
| 43 | - $mode_document = 'logo' . $mode; |
|
| 44 | - $objet = objet_type($_id_objet); |
|
| 45 | - $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id)); |
|
| 46 | - if ($doc) { |
|
| 47 | - include_spip('inc/documents'); |
|
| 48 | - $d = get_spip_doc($doc['fichier']); |
|
| 49 | - return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc]; |
|
| 50 | - } |
|
| 40 | + $mode = preg_replace(',\W,', '', $mode); |
|
| 41 | + if ($mode) { |
|
| 42 | + // chercher dans la base |
|
| 43 | + $mode_document = 'logo' . $mode; |
|
| 44 | + $objet = objet_type($_id_objet); |
|
| 45 | + $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id)); |
|
| 46 | + if ($doc) { |
|
| 47 | + include_spip('inc/documents'); |
|
| 48 | + $d = get_spip_doc($doc['fichier']); |
|
| 49 | + return [$d, _DIR_IMG, basename($d), $doc['extension'], @filemtime($d), $doc]; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - # deprecated TODO remove |
|
| 53 | - if ($compat_old_logos) { |
|
| 54 | - # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval() |
|
| 55 | - $type = type_du_logo($_id_objet); |
|
| 56 | - $nom = $type . $mode . intval($id); |
|
| 52 | + # deprecated TODO remove |
|
| 53 | + if ($compat_old_logos) { |
|
| 54 | + # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval() |
|
| 55 | + $type = type_du_logo($_id_objet); |
|
| 56 | + $nom = $type . $mode . intval($id); |
|
| 57 | 57 | |
| 58 | - foreach ($GLOBALS['formats_logos'] as $format) { |
|
| 59 | - if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) { |
|
| 60 | - return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)]; |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - } |
|
| 64 | - } |
|
| 58 | + foreach ($GLOBALS['formats_logos'] as $format) { |
|
| 59 | + if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) { |
|
| 60 | + return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)]; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + } |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - # coherence de type pour servir comme filtre (formulaire_login) |
|
| 67 | - return []; |
|
| 66 | + # coherence de type pour servir comme filtre (formulaire_login) |
|
| 67 | + return []; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | * @deprecated 4.0 MAIS NE PAS SUPPRIMER CAR SERT POUR L'UPGRADE des logos et leur mise en base |
| 84 | 84 | **/ |
| 85 | 85 | function type_du_logo($_id_objet) { |
| 86 | - return isset($GLOBALS['table_logos'][$_id_objet]) |
|
| 87 | - ? $GLOBALS['table_logos'][$_id_objet] |
|
| 88 | - : objet_type(preg_replace(',^id_,', '', $_id_objet)); |
|
| 86 | + return isset($GLOBALS['table_logos'][$_id_objet]) |
|
| 87 | + ? $GLOBALS['table_logos'][$_id_objet] |
|
| 88 | + : objet_type(preg_replace(',^id_,', '', $_id_objet)); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Exceptions standards (historique) |
| 92 | 92 | $GLOBALS['table_logos'] = [ |
| 93 | - 'id_article' => 'art', |
|
| 94 | - 'id_auteur' => 'aut', |
|
| 95 | - 'id_rubrique' => 'rub', |
|
| 96 | - 'id_groupe' => 'groupe', |
|
| 93 | + 'id_article' => 'art', |
|
| 94 | + 'id_auteur' => 'aut', |
|
| 95 | + 'id_rubrique' => 'rub', |
|
| 96 | + 'id_groupe' => 'groupe', |
|
| 97 | 97 | ]; |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | $mode = preg_replace(',\W,', '', $mode); |
| 41 | 41 | if ($mode) { |
| 42 | 42 | // chercher dans la base |
| 43 | - $mode_document = 'logo' . $mode; |
|
| 43 | + $mode_document = 'logo'.$mode; |
|
| 44 | 44 | $objet = objet_type($_id_objet); |
| 45 | - $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode=' . sql_quote($mode_document) . ' AND L.objet=' . sql_quote($objet) . ' AND id_objet=' . intval($id)); |
|
| 45 | + $doc = sql_fetsel('D.*', 'spip_documents AS D JOIN spip_documents_liens AS L ON L.id_document=D.id_document', 'D.mode='.sql_quote($mode_document).' AND L.objet='.sql_quote($objet).' AND id_objet='.intval($id)); |
|
| 46 | 46 | if ($doc) { |
| 47 | 47 | include_spip('inc/documents'); |
| 48 | 48 | $d = get_spip_doc($doc['fichier']); |
@@ -53,10 +53,10 @@ discard block |
||
| 53 | 53 | if ($compat_old_logos) { |
| 54 | 54 | # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval() |
| 55 | 55 | $type = type_du_logo($_id_objet); |
| 56 | - $nom = $type . $mode . intval($id); |
|
| 56 | + $nom = $type.$mode.intval($id); |
|
| 57 | 57 | |
| 58 | 58 | foreach ($GLOBALS['formats_logos'] as $format) { |
| 59 | - if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) { |
|
| 59 | + if (@file_exists($d = (_DIR_LOGOS.$nom.'.'.$format))) { |
|
| 60 | 60 | return [$d, _DIR_LOGOS, $nom, $format, @filemtime($d)]; |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -29,51 +29,51 @@ discard block |
||
| 29 | 29 | * @return string Erreur éventuelle |
| 30 | 30 | */ |
| 31 | 31 | function inc_completer_traduction_dist($objet, $id_objet, $id_trad) { |
| 32 | - // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit |
|
| 33 | - // cf API editer_liens |
|
| 34 | - include_spip('action/editer_liens'); |
|
| 35 | - objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']); |
|
| 36 | - $_id_table = id_table_objet($objet); |
|
| 32 | + // dupliquer tous les liens sauf les auteurs : le nouvel auteur est celui qui traduit |
|
| 33 | + // cf API editer_liens |
|
| 34 | + include_spip('action/editer_liens'); |
|
| 35 | + objet_dupliquer_liens($objet, $id_trad, $id_objet, null, ['auteur']); |
|
| 36 | + $_id_table = id_table_objet($objet); |
|
| 37 | 37 | |
| 38 | - // recuperer le logo |
|
| 39 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 40 | - include_spip('action/editer_logo'); |
|
| 41 | - foreach (['on', 'off'] as $etat) { |
|
| 42 | - $logo = $chercher_logo($id_trad, $_id_table, $etat); |
|
| 43 | - if ($logo and $file = reset($logo)) { |
|
| 44 | - logo_modifier($objet, $id_objet, $etat, $file); |
|
| 45 | - } |
|
| 46 | - } |
|
| 38 | + // recuperer le logo |
|
| 39 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 40 | + include_spip('action/editer_logo'); |
|
| 41 | + foreach (['on', 'off'] as $etat) { |
|
| 42 | + $logo = $chercher_logo($id_trad, $_id_table, $etat); |
|
| 43 | + if ($logo and $file = reset($logo)) { |
|
| 44 | + logo_modifier($objet, $id_objet, $etat, $file); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - // dupliquer certains champs |
|
| 49 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 50 | - $desc = $trouver_table(table_objet_sql($objet)); |
|
| 51 | - $champs = $set = []; |
|
| 48 | + // dupliquer certains champs |
|
| 49 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 50 | + $desc = $trouver_table(table_objet_sql($objet)); |
|
| 51 | + $champs = $set = []; |
|
| 52 | 52 | |
| 53 | - // un éventuel champ 'virtuel' (redirections) |
|
| 54 | - if (!empty($desc['field']['virtuel'])) { |
|
| 55 | - $champs[] = 'virtuel'; |
|
| 56 | - } |
|
| 53 | + // un éventuel champ 'virtuel' (redirections) |
|
| 54 | + if (!empty($desc['field']['virtuel'])) { |
|
| 55 | + $champs[] = 'virtuel'; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad)); |
|
| 58 | + $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad)); |
|
| 59 | 59 | |
| 60 | - foreach ($champs as $c) { |
|
| 61 | - $set[$c] = $data[$c]; |
|
| 62 | - } |
|
| 60 | + foreach ($champs as $c) { |
|
| 61 | + $set[$c] = $data[$c]; |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /* |
|
| 64 | + /* |
|
| 65 | 65 | * Le pipeline 'pre_edition' sera appelé avec l'action 'completer_traduction'. |
| 66 | 66 | * Des plugins pourront ainsi compléter les champs d'un objet traduit lors d'une nouvelle traduction. |
| 67 | 67 | */ |
| 68 | - $err = objet_modifier_champs( |
|
| 69 | - $objet, |
|
| 70 | - $id_objet, |
|
| 71 | - [ |
|
| 72 | - 'data' => $data, |
|
| 73 | - 'action' => 'completer_traduction', |
|
| 74 | - ], |
|
| 75 | - $set |
|
| 76 | - ); |
|
| 68 | + $err = objet_modifier_champs( |
|
| 69 | + $objet, |
|
| 70 | + $id_objet, |
|
| 71 | + [ |
|
| 72 | + 'data' => $data, |
|
| 73 | + 'action' => 'completer_traduction', |
|
| 74 | + ], |
|
| 75 | + $set |
|
| 76 | + ); |
|
| 77 | 77 | |
| 78 | - return $err; |
|
| 78 | + return $err; |
|
| 79 | 79 | } |
@@ -55,7 +55,7 @@ |
||
| 55 | 55 | $champs[] = 'virtuel'; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - $data = sql_fetsel('*', $desc['table'], $_id_table . '=' . intval($id_trad)); |
|
| 58 | + $data = sql_fetsel('*', $desc['table'], $_id_table.'='.intval($id_trad)); |
|
| 59 | 59 | |
| 60 | 60 | foreach ($champs as $c) { |
| 61 | 61 | $set[$c] = $data[$c]; |
@@ -11,107 +11,107 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function inc_log_dist($message, $logname = null, $logdir = null, $logsuf = null) { |
| 18 | - static $test_repertoire = []; |
|
| 19 | - static $compteur = []; |
|
| 20 | - static $debugverb = ''; // pour ne pas le recalculer au reappel |
|
| 21 | - |
|
| 22 | - if (is_null($logname) or !is_string($logname)) { |
|
| 23 | - $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; |
|
| 24 | - } |
|
| 25 | - if (!isset($compteur[$logname])) { |
|
| 26 | - $compteur[$logname] = 0; |
|
| 27 | - } |
|
| 28 | - if ( |
|
| 29 | - $logname != 'maj' |
|
| 30 | - and defined('_MAX_LOG') |
|
| 31 | - and ( |
|
| 32 | - $compteur[$logname]++ > _MAX_LOG |
|
| 33 | - or !$GLOBALS['nombre_de_logs'] |
|
| 34 | - or !$GLOBALS['taille_des_logs'] |
|
| 35 | - ) |
|
| 36 | - ) { |
|
| 37 | - return; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - $logfile = ($logdir === null ? _DIR_LOG : $logdir) |
|
| 41 | - . ($logname) |
|
| 42 | - . ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf); |
|
| 43 | - |
|
| 44 | - if (!isset($test_repertoire[$d = dirname($logfile)])) { |
|
| 45 | - $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
|
| 46 | - $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire( |
|
| 47 | - $d, |
|
| 48 | - '', |
|
| 49 | - false, |
|
| 50 | - true |
|
| 51 | - ) : false)); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
|
| 55 | - if (!defined('_DIR_LOG') or !$test_repertoire[$d]) { |
|
| 56 | - $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - $rotate = 0; |
|
| 60 | - $pid = '(pid ' . @getmypid() . ')'; |
|
| 61 | - |
|
| 62 | - // accepter spip_log( Array ) |
|
| 63 | - if (!is_string($message)) { |
|
| 64 | - $message = var_export($message, true); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) { |
|
| 68 | - $debug = debug_backtrace(); |
|
| 69 | - $l = $debug[1]['line']; |
|
| 70 | - $fi = $debug[1]['file']; |
|
| 71 | - if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) { |
|
| 72 | - $fi = substr($fi, strlen(_ROOT_RACINE)); |
|
| 73 | - } |
|
| 74 | - $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
|
| 75 | - $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' ' |
|
| 79 | - //distinguer les logs prives et publics dans les grep |
|
| 80 | - . $debugverb |
|
| 81 | - . (test_espace_prive() ? ':Pri:' : ':Pub:') |
|
| 82 | - . preg_replace("/\n*$/", "\n", $message); |
|
| 83 | - |
|
| 84 | - |
|
| 85 | - if ( |
|
| 86 | - @is_readable($logfile) |
|
| 87 | - and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024) |
|
| 88 | - ) { |
|
| 89 | - $rotate = $GLOBALS['nombre_de_logs']; |
|
| 90 | - $m .= "[-- rotate --]\n"; |
|
| 91 | - } |
|
| 92 | - |
|
| 93 | - $f = @fopen($logfile, 'ab'); |
|
| 94 | - if ($f) { |
|
| 95 | - fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '<', $m)); |
|
| 96 | - fclose($f); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if ( |
|
| 100 | - $rotate-- > 0 |
|
| 101 | - and function_exists('spip_unlink') |
|
| 102 | - ) { |
|
| 103 | - spip_unlink($logfile . '.' . $rotate); |
|
| 104 | - while ($rotate--) { |
|
| 105 | - @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - // Dupliquer les erreurs specifiques dans le log general |
|
| 110 | - if ( |
|
| 111 | - $logname !== _FILE_LOG |
|
| 112 | - and defined('_FILE_LOG') |
|
| 113 | - ) { |
|
| 114 | - inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message); |
|
| 115 | - } |
|
| 116 | - $debugverb = ''; |
|
| 18 | + static $test_repertoire = []; |
|
| 19 | + static $compteur = []; |
|
| 20 | + static $debugverb = ''; // pour ne pas le recalculer au reappel |
|
| 21 | + |
|
| 22 | + if (is_null($logname) or !is_string($logname)) { |
|
| 23 | + $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; |
|
| 24 | + } |
|
| 25 | + if (!isset($compteur[$logname])) { |
|
| 26 | + $compteur[$logname] = 0; |
|
| 27 | + } |
|
| 28 | + if ( |
|
| 29 | + $logname != 'maj' |
|
| 30 | + and defined('_MAX_LOG') |
|
| 31 | + and ( |
|
| 32 | + $compteur[$logname]++ > _MAX_LOG |
|
| 33 | + or !$GLOBALS['nombre_de_logs'] |
|
| 34 | + or !$GLOBALS['taille_des_logs'] |
|
| 35 | + ) |
|
| 36 | + ) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + $logfile = ($logdir === null ? _DIR_LOG : $logdir) |
|
| 41 | + . ($logname) |
|
| 42 | + . ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf); |
|
| 43 | + |
|
| 44 | + if (!isset($test_repertoire[$d = dirname($logfile)])) { |
|
| 45 | + $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
|
| 46 | + $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire( |
|
| 47 | + $d, |
|
| 48 | + '', |
|
| 49 | + false, |
|
| 50 | + true |
|
| 51 | + ) : false)); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
|
| 55 | + if (!defined('_DIR_LOG') or !$test_repertoire[$d]) { |
|
| 56 | + $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + $rotate = 0; |
|
| 60 | + $pid = '(pid ' . @getmypid() . ')'; |
|
| 61 | + |
|
| 62 | + // accepter spip_log( Array ) |
|
| 63 | + if (!is_string($message)) { |
|
| 64 | + $message = var_export($message, true); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) { |
|
| 68 | + $debug = debug_backtrace(); |
|
| 69 | + $l = $debug[1]['line']; |
|
| 70 | + $fi = $debug[1]['file']; |
|
| 71 | + if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) { |
|
| 72 | + $fi = substr($fi, strlen(_ROOT_RACINE)); |
|
| 73 | + } |
|
| 74 | + $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
|
| 75 | + $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' ' |
|
| 79 | + //distinguer les logs prives et publics dans les grep |
|
| 80 | + . $debugverb |
|
| 81 | + . (test_espace_prive() ? ':Pri:' : ':Pub:') |
|
| 82 | + . preg_replace("/\n*$/", "\n", $message); |
|
| 83 | + |
|
| 84 | + |
|
| 85 | + if ( |
|
| 86 | + @is_readable($logfile) |
|
| 87 | + and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024) |
|
| 88 | + ) { |
|
| 89 | + $rotate = $GLOBALS['nombre_de_logs']; |
|
| 90 | + $m .= "[-- rotate --]\n"; |
|
| 91 | + } |
|
| 92 | + |
|
| 93 | + $f = @fopen($logfile, 'ab'); |
|
| 94 | + if ($f) { |
|
| 95 | + fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '<', $m)); |
|
| 96 | + fclose($f); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if ( |
|
| 100 | + $rotate-- > 0 |
|
| 101 | + and function_exists('spip_unlink') |
|
| 102 | + ) { |
|
| 103 | + spip_unlink($logfile . '.' . $rotate); |
|
| 104 | + while ($rotate--) { |
|
| 105 | + @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + // Dupliquer les erreurs specifiques dans le log general |
|
| 110 | + if ( |
|
| 111 | + $logname !== _FILE_LOG |
|
| 112 | + and defined('_FILE_LOG') |
|
| 113 | + ) { |
|
| 114 | + inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message); |
|
| 115 | + } |
|
| 116 | + $debugverb = ''; |
|
| 117 | 117 | } |
@@ -53,11 +53,11 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/ |
| 55 | 55 | if (!defined('_DIR_LOG') or !$test_repertoire[$d]) { |
| 56 | - $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 56 | + $logfile = _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES.$logname.'.log'; |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | $rotate = 0; |
| 60 | - $pid = '(pid ' . @getmypid() . ')'; |
|
| 60 | + $pid = '(pid '.@getmypid().')'; |
|
| 61 | 61 | |
| 62 | 62 | // accepter spip_log( Array ) |
| 63 | 63 | if (!is_string($message)) { |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | $fi = substr($fi, strlen(_ROOT_RACINE)); |
| 73 | 73 | } |
| 74 | 74 | $fu = isset($debug[2]['function']) ? $debug[2]['function'] : ''; |
| 75 | - $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 75 | + $debugverb = "$fi:L$l:$fu".'():'; |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' ' |
|
| 78 | + $m = date('Y-m-d H:i:s').' '.(isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '').' '.$pid.' ' |
|
| 79 | 79 | //distinguer les logs prives et publics dans les grep |
| 80 | 80 | . $debugverb |
| 81 | 81 | . (test_espace_prive() ? ':Pri:' : ':Pub:') |
@@ -100,9 +100,9 @@ discard block |
||
| 100 | 100 | $rotate-- > 0 |
| 101 | 101 | and function_exists('spip_unlink') |
| 102 | 102 | ) { |
| 103 | - spip_unlink($logfile . '.' . $rotate); |
|
| 103 | + spip_unlink($logfile.'.'.$rotate); |
|
| 104 | 104 | while ($rotate--) { |
| 105 | - @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 105 | + @rename($logfile.($rotate ? '.'.$rotate : ''), $logfile.'.'.($rotate + 1)); |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Autorisations |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -38,83 +38,83 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | |
| 40 | 40 | if (!function_exists('autoriser')) { |
| 41 | - /** |
|
| 42 | - * Autoriser une action |
|
| 43 | - * |
|
| 44 | - * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 45 | - * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 46 | - * les autorisations. |
|
| 47 | - * |
|
| 48 | - * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 49 | - * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 50 | - * dans cet ordre : |
|
| 51 | - * |
|
| 52 | - * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 53 | - * - autoriser_{type}, sinon avec _dist |
|
| 54 | - * - autoriser_{faire}, sinon avec _dist |
|
| 55 | - * - autoriser_{defaut}, sinon avec _dist |
|
| 56 | - * |
|
| 57 | - * Seul le premier argument est obligatoire. |
|
| 58 | - * |
|
| 59 | - * @note |
|
| 60 | - * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 61 | - * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 62 | - * cette valeur. |
|
| 63 | - * |
|
| 64 | - * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 65 | - * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 66 | - * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 67 | - * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 68 | - * |
|
| 69 | - * @note |
|
| 70 | - * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 71 | - * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 72 | - * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 73 | - * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 74 | - * quel serait le type, quel serait l'action ? |
|
| 75 | - * |
|
| 76 | - * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 77 | - * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 78 | - * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 79 | - * |
|
| 80 | - * @api |
|
| 81 | - * @see autoriser_dist() |
|
| 82 | - * |
|
| 83 | - * @param string $faire |
|
| 84 | - * une action ('modifier', 'publier'...) |
|
| 85 | - * @param string $type |
|
| 86 | - * type d'objet ou nom de table ('article') |
|
| 87 | - * @param int $id |
|
| 88 | - * id de l'objet sur lequel on veut agir |
|
| 89 | - * @param null|int|array $qui |
|
| 90 | - * - si null on prend alors visiteur_session |
|
| 91 | - * - un id_auteur (on regarde dans la base) |
|
| 92 | - * - un tableau auteur complet, y compris [restreint] |
|
| 93 | - * @param null|array $opt |
|
| 94 | - * options sous forme de tableau associatif |
|
| 95 | - * @return bool |
|
| 96 | - * true si la personne peut effectuer l'action |
|
| 97 | - */ |
|
| 98 | - function autoriser($faire, $type = '', $id = 0, $qui = null, $opt = null) { |
|
| 99 | - // Charger les fonctions d'autorisation supplementaires |
|
| 100 | - static $pipe; |
|
| 101 | - if (!isset($pipe)) { |
|
| 102 | - $pipe = 1; |
|
| 103 | - pipeline('autoriser'); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $args = func_get_args(); |
|
| 107 | - |
|
| 108 | - return call_user_func_array('autoriser_dist', $args); |
|
| 109 | - } |
|
| 41 | + /** |
|
| 42 | + * Autoriser une action |
|
| 43 | + * |
|
| 44 | + * Teste si une personne (par défaut le visiteur en cours) peut effectuer |
|
| 45 | + * une certaine action. Cette fonction est le point d'entrée de toutes |
|
| 46 | + * les autorisations. |
|
| 47 | + * |
|
| 48 | + * La fonction se charge d'appeler des fonctions d'autorisations spécifiques |
|
| 49 | + * aux actions demandées si elles existent. Elle cherche donc les fonctions |
|
| 50 | + * dans cet ordre : |
|
| 51 | + * |
|
| 52 | + * - autoriser_{type}_{faire}, sinon avec _dist |
|
| 53 | + * - autoriser_{type}, sinon avec _dist |
|
| 54 | + * - autoriser_{faire}, sinon avec _dist |
|
| 55 | + * - autoriser_{defaut}, sinon avec _dist |
|
| 56 | + * |
|
| 57 | + * Seul le premier argument est obligatoire. |
|
| 58 | + * |
|
| 59 | + * @note |
|
| 60 | + * Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre, |
|
| 61 | + * la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser |
|
| 62 | + * cette valeur. |
|
| 63 | + * |
|
| 64 | + * Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple |
|
| 65 | + * 'statistiques', un souligné avant le terme est ajouté afin d'indiquer |
|
| 66 | + * explicitement à la fonction autoriser de ne pas transformer la chaîne en type |
|
| 67 | + * d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')` |
|
| 68 | + * |
|
| 69 | + * @note |
|
| 70 | + * Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer |
|
| 71 | + * tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart` |
|
| 72 | + * et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet |
|
| 73 | + * d'éviter une possible confusion si une fonction `autoriser_livre_art` existait : |
|
| 74 | + * quel serait le type, quel serait l'action ? |
|
| 75 | + * |
|
| 76 | + * Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art', |
|
| 77 | + * la fonction d'autorisation correspondante ne l'aura pas. |
|
| 78 | + * Exemple : `function autoriser_livreart_modifier_dist(...){...}` |
|
| 79 | + * |
|
| 80 | + * @api |
|
| 81 | + * @see autoriser_dist() |
|
| 82 | + * |
|
| 83 | + * @param string $faire |
|
| 84 | + * une action ('modifier', 'publier'...) |
|
| 85 | + * @param string $type |
|
| 86 | + * type d'objet ou nom de table ('article') |
|
| 87 | + * @param int $id |
|
| 88 | + * id de l'objet sur lequel on veut agir |
|
| 89 | + * @param null|int|array $qui |
|
| 90 | + * - si null on prend alors visiteur_session |
|
| 91 | + * - un id_auteur (on regarde dans la base) |
|
| 92 | + * - un tableau auteur complet, y compris [restreint] |
|
| 93 | + * @param null|array $opt |
|
| 94 | + * options sous forme de tableau associatif |
|
| 95 | + * @return bool |
|
| 96 | + * true si la personne peut effectuer l'action |
|
| 97 | + */ |
|
| 98 | + function autoriser($faire, $type = '', $id = 0, $qui = null, $opt = null) { |
|
| 99 | + // Charger les fonctions d'autorisation supplementaires |
|
| 100 | + static $pipe; |
|
| 101 | + if (!isset($pipe)) { |
|
| 102 | + $pipe = 1; |
|
| 103 | + pipeline('autoriser'); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $args = func_get_args(); |
|
| 107 | + |
|
| 108 | + return call_user_func_array('autoriser_dist', $args); |
|
| 109 | + } |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
| 113 | 113 | // mes_fonctions peut aussi declarer des autorisations, il faut donc le charger |
| 114 | 114 | // mais apres la fonction autoriser() |
| 115 | 115 | if ($f = find_in_path('mes_fonctions.php')) { |
| 116 | - global $dossier_squelettes; |
|
| 117 | - include_once(_ROOT_CWD . $f); |
|
| 116 | + global $dossier_squelettes; |
|
| 117 | + include_once(_ROOT_CWD . $f); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -142,73 +142,73 @@ discard block |
||
| 142 | 142 | */ |
| 143 | 143 | function autoriser_dist($faire, $type = '', $id = 0, $qui = null, $opt = null) { |
| 144 | 144 | |
| 145 | - // Qui ? visiteur_session ? |
|
| 146 | - // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 147 | - if ($qui === null or $qui === '') { |
|
| 148 | - $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : []; |
|
| 149 | - $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 150 | - } elseif (is_numeric($qui)) { |
|
| 151 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - // Admins restreints, on construit ici (pas generique mais...) |
|
| 155 | - // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 156 | - if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 157 | - $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : []; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - spip_log( |
|
| 161 | - "autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?', |
|
| 162 | - 'autoriser' . _LOG_DEBUG |
|
| 163 | - ); |
|
| 164 | - |
|
| 165 | - // passer par objet_type pour avoir les alias |
|
| 166 | - // et supprimer les _ |
|
| 167 | - $type = str_replace('_', '', strncmp($type, '_', 1) == 0 ? $type : objet_type($type, false)); |
|
| 168 | - |
|
| 169 | - // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 170 | - if ( |
|
| 171 | - (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 172 | - or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 173 | - ) { |
|
| 174 | - spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 175 | - return true; |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - // Chercher une fonction d'autorisation |
|
| 179 | - // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 180 | - // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 181 | - $fonctions = $type |
|
| 182 | - ? [ |
|
| 183 | - 'autoriser_' . $type . '_' . $faire, |
|
| 184 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 185 | - 'autoriser_' . $type, |
|
| 186 | - 'autoriser_' . $type . '_dist', |
|
| 187 | - 'autoriser_' . $faire, |
|
| 188 | - 'autoriser_' . $faire . '_dist', |
|
| 189 | - 'autoriser_defaut', |
|
| 190 | - 'autoriser_defaut_dist' |
|
| 191 | - ] |
|
| 192 | - : [ |
|
| 193 | - 'autoriser_' . $faire, |
|
| 194 | - 'autoriser_' . $faire . '_dist', |
|
| 195 | - 'autoriser_defaut', |
|
| 196 | - 'autoriser_defaut_dist' |
|
| 197 | - ]; |
|
| 198 | - |
|
| 199 | - foreach ($fonctions as $f) { |
|
| 200 | - if (function_exists($f)) { |
|
| 201 | - $a = $f($faire, $type, $id, $qui, $opt); |
|
| 202 | - break; |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - spip_log( |
|
| 207 | - "$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 208 | - 'autoriser' . _LOG_DEBUG |
|
| 209 | - ); |
|
| 210 | - |
|
| 211 | - return $a; |
|
| 145 | + // Qui ? visiteur_session ? |
|
| 146 | + // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge |
|
| 147 | + if ($qui === null or $qui === '') { |
|
| 148 | + $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : []; |
|
| 149 | + $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
|
| 150 | + } elseif (is_numeric($qui)) { |
|
| 151 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + // Admins restreints, on construit ici (pas generique mais...) |
|
| 155 | + // le tableau de toutes leurs rubriques (y compris les sous-rubriques) |
|
| 156 | + if (_ADMINS_RESTREINTS and is_array($qui)) { |
|
| 157 | + $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : []; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + spip_log( |
|
| 161 | + "autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?', |
|
| 162 | + 'autoriser' . _LOG_DEBUG |
|
| 163 | + ); |
|
| 164 | + |
|
| 165 | + // passer par objet_type pour avoir les alias |
|
| 166 | + // et supprimer les _ |
|
| 167 | + $type = str_replace('_', '', strncmp($type, '_', 1) == 0 ? $type : objet_type($type, false)); |
|
| 168 | + |
|
| 169 | + // Si une exception a ete decretee plus haut dans le code, l'appliquer |
|
| 170 | + if ( |
|
| 171 | + (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
|
| 172 | + or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
|
| 173 | + ) { |
|
| 174 | + spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 175 | + return true; |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + // Chercher une fonction d'autorisation |
|
| 179 | + // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist], |
|
| 180 | + // autoriser_faire[_dist], autoriser_defaut[_dist] |
|
| 181 | + $fonctions = $type |
|
| 182 | + ? [ |
|
| 183 | + 'autoriser_' . $type . '_' . $faire, |
|
| 184 | + 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 185 | + 'autoriser_' . $type, |
|
| 186 | + 'autoriser_' . $type . '_dist', |
|
| 187 | + 'autoriser_' . $faire, |
|
| 188 | + 'autoriser_' . $faire . '_dist', |
|
| 189 | + 'autoriser_defaut', |
|
| 190 | + 'autoriser_defaut_dist' |
|
| 191 | + ] |
|
| 192 | + : [ |
|
| 193 | + 'autoriser_' . $faire, |
|
| 194 | + 'autoriser_' . $faire . '_dist', |
|
| 195 | + 'autoriser_defaut', |
|
| 196 | + 'autoriser_defaut_dist' |
|
| 197 | + ]; |
|
| 198 | + |
|
| 199 | + foreach ($fonctions as $f) { |
|
| 200 | + if (function_exists($f)) { |
|
| 201 | + $a = $f($faire, $type, $id, $qui, $opt); |
|
| 202 | + break; |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + spip_log( |
|
| 207 | + "$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 208 | + 'autoriser' . _LOG_DEBUG |
|
| 209 | + ); |
|
| 210 | + |
|
| 211 | + return $a; |
|
| 212 | 212 | } |
| 213 | 213 | |
| 214 | 214 | // une globale pour aller au plus vite dans la fonction generique ci dessus |
@@ -226,26 +226,26 @@ discard block |
||
| 226 | 226 | * @return bool |
| 227 | 227 | */ |
| 228 | 228 | function autoriser_exception($faire, $type, $id, $autoriser = true) { |
| 229 | - // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 230 | - static $autorisation; |
|
| 231 | - if ($autoriser === 'verifier') { |
|
| 232 | - return isset($autorisation[$faire][$type][$id]); |
|
| 233 | - } |
|
| 234 | - if ($autoriser === true) { |
|
| 235 | - $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 236 | - } |
|
| 237 | - if ($autoriser === false) { |
|
| 238 | - if ($id === '*') { |
|
| 239 | - unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 240 | - unset($autorisation[$faire][$type]); |
|
| 241 | - } |
|
| 242 | - else { |
|
| 243 | - unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 244 | - unset($autorisation[$faire][$type][$id]); |
|
| 245 | - } |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - return false; |
|
| 229 | + // une static innaccessible par url pour verifier que la globale est positionnee a bon escient |
|
| 230 | + static $autorisation; |
|
| 231 | + if ($autoriser === 'verifier') { |
|
| 232 | + return isset($autorisation[$faire][$type][$id]); |
|
| 233 | + } |
|
| 234 | + if ($autoriser === true) { |
|
| 235 | + $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true; |
|
| 236 | + } |
|
| 237 | + if ($autoriser === false) { |
|
| 238 | + if ($id === '*') { |
|
| 239 | + unset($GLOBALS['autoriser_exception'][$faire][$type]); |
|
| 240 | + unset($autorisation[$faire][$type]); |
|
| 241 | + } |
|
| 242 | + else { |
|
| 243 | + unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
|
| 244 | + unset($autorisation[$faire][$type][$id]); |
|
| 245 | + } |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + return false; |
|
| 249 | 249 | } |
| 250 | 250 | |
| 251 | 251 | |
@@ -262,9 +262,9 @@ discard block |
||
| 262 | 262 | * @return bool true s'il a le droit, false sinon |
| 263 | 263 | **/ |
| 264 | 264 | function autoriser_defaut_dist($faire, $type, $id, $qui, $opt) { |
| 265 | - return |
|
| 266 | - $qui['statut'] == '0minirezo' |
|
| 267 | - and !$qui['restreint']; |
|
| 265 | + return |
|
| 266 | + $qui['statut'] == '0minirezo' |
|
| 267 | + and !$qui['restreint']; |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -280,10 +280,10 @@ discard block |
||
| 280 | 280 | * @return bool |
| 281 | 281 | */ |
| 282 | 282 | function autoriser_loger_dist($faire, $type, $id, $qui, $opt) { |
| 283 | - if ($qui['statut'] == '5poubelle') { |
|
| 284 | - return false; |
|
| 285 | - } |
|
| 286 | - return true; |
|
| 283 | + if ($qui['statut'] == '5poubelle') { |
|
| 284 | + return false; |
|
| 285 | + } |
|
| 286 | + return true; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | /** |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | * @return bool true s'il a le droit, false sinon |
| 298 | 298 | **/ |
| 299 | 299 | function autoriser_ecrire_dist($faire, $type, $id, $qui, $opt) { |
| 300 | - return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 300 | + return isset($qui['statut']) and in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * @return bool true s'il a le droit, false sinon |
| 315 | 315 | **/ |
| 316 | 316 | function autoriser_creer_dist($faire, $type, $id, $qui, $opt) { |
| 317 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 317 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | /** |
@@ -332,18 +332,18 @@ discard block |
||
| 332 | 332 | **/ |
| 333 | 333 | function autoriser_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 334 | 334 | |
| 335 | - // Le visiteur a-t-il un statut prevu par la config ? |
|
| 336 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 337 | - return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 338 | - } |
|
| 335 | + // Le visiteur a-t-il un statut prevu par la config ? |
|
| 336 | + if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 337 | + return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
|
| 338 | + } |
|
| 339 | 339 | |
| 340 | - // A-t-on un token de prévisualisation valable ? |
|
| 341 | - include_spip('inc/securiser_action'); |
|
| 342 | - if (decrire_token_previsu()) { |
|
| 343 | - return true; |
|
| 344 | - } |
|
| 340 | + // A-t-on un token de prévisualisation valable ? |
|
| 341 | + include_spip('inc/securiser_action'); |
|
| 342 | + if (decrire_token_previsu()) { |
|
| 343 | + return true; |
|
| 344 | + } |
|
| 345 | 345 | |
| 346 | - return false; |
|
| 346 | + return false; |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -371,58 +371,58 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | function test_previsualiser_objet_champ($type = null, $id = 0, $qui = [], $opt = []) { |
| 373 | 373 | |
| 374 | - // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 375 | - if (!$type) { |
|
| 376 | - return true; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - include_spip('base/objets'); |
|
| 380 | - $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 381 | - if (isset($infos['statut'])) { |
|
| 382 | - foreach ($infos['statut'] as $c) { |
|
| 383 | - if (isset($c['publie'])) { |
|
| 384 | - if (!isset($c['previsu'])) { |
|
| 385 | - return false; |
|
| 386 | - } // pas de previsu definie => NIET |
|
| 387 | - $champ = $c['champ']; |
|
| 388 | - if (!isset($opt[$champ])) { |
|
| 389 | - return false; |
|
| 390 | - } // pas de champ passe a la demande => NIET |
|
| 391 | - $previsu = explode(',', $c['previsu']); |
|
| 392 | - // regarder si ce statut est autorise pour l'auteur |
|
| 393 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 394 | - // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 395 | - // sinon l’auteur en session |
|
| 396 | - include_spip('inc/securiser_action'); |
|
| 397 | - if ($desc = decrire_token_previsu()) { |
|
| 398 | - $id_auteur = $desc['id_auteur']; |
|
| 399 | - } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 400 | - $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 401 | - } else { |
|
| 402 | - $id_auteur = null; |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - if (!$id_auteur) { |
|
| 406 | - return false; |
|
| 407 | - } elseif (autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) { |
|
| 408 | - // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 409 | - } elseif ( |
|
| 410 | - !sql_countsel( |
|
| 411 | - 'spip_auteurs_liens', |
|
| 412 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 413 | - ) |
|
| 414 | - ) { |
|
| 415 | - return false; |
|
| 416 | - } // pas auteur de cet objet => NIET |
|
| 417 | - } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 418 | - // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 419 | - return false; |
|
| 420 | - } |
|
| 421 | - } |
|
| 422 | - } |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - return true; |
|
| 374 | + // si pas de type et statut fourni, c'est une autorisation generale => OK |
|
| 375 | + if (!$type) { |
|
| 376 | + return true; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + include_spip('base/objets'); |
|
| 380 | + $infos = lister_tables_objets_sql(table_objet_sql($type)); |
|
| 381 | + if (isset($infos['statut'])) { |
|
| 382 | + foreach ($infos['statut'] as $c) { |
|
| 383 | + if (isset($c['publie'])) { |
|
| 384 | + if (!isset($c['previsu'])) { |
|
| 385 | + return false; |
|
| 386 | + } // pas de previsu definie => NIET |
|
| 387 | + $champ = $c['champ']; |
|
| 388 | + if (!isset($opt[$champ])) { |
|
| 389 | + return false; |
|
| 390 | + } // pas de champ passe a la demande => NIET |
|
| 391 | + $previsu = explode(',', $c['previsu']); |
|
| 392 | + // regarder si ce statut est autorise pour l'auteur |
|
| 393 | + if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 394 | + // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
|
| 395 | + // sinon l’auteur en session |
|
| 396 | + include_spip('inc/securiser_action'); |
|
| 397 | + if ($desc = decrire_token_previsu()) { |
|
| 398 | + $id_auteur = $desc['id_auteur']; |
|
| 399 | + } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 400 | + $id_auteur = intval($GLOBALS['visiteur_session']['id_auteur']); |
|
| 401 | + } else { |
|
| 402 | + $id_auteur = null; |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + if (!$id_auteur) { |
|
| 406 | + return false; |
|
| 407 | + } elseif (autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) { |
|
| 408 | + // dans ce cas (admin en general), pas de filtrage sur ce statut |
|
| 409 | + } elseif ( |
|
| 410 | + !sql_countsel( |
|
| 411 | + 'spip_auteurs_liens', |
|
| 412 | + 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 413 | + ) |
|
| 414 | + ) { |
|
| 415 | + return false; |
|
| 416 | + } // pas auteur de cet objet => NIET |
|
| 417 | + } elseif (!in_array($opt[$champ], $previsu)) { |
|
| 418 | + // le statut n'est pas dans ceux definis par la previsu => NIET |
|
| 419 | + return false; |
|
| 420 | + } |
|
| 421 | + } |
|
| 422 | + } |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + return true; |
|
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | /** |
@@ -436,51 +436,51 @@ discard block |
||
| 436 | 436 | * @return bool true s'il a le droit, false sinon |
| 437 | 437 | **/ |
| 438 | 438 | function autoriser_changerlangue_dist($faire, $type, $id, $qui, $opt) { |
| 439 | - $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 440 | - $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 441 | - $table = table_objet_sql($type); |
|
| 442 | - if ( |
|
| 443 | - in_array($table, $multi_objets) |
|
| 444 | - or in_array($table, $gerer_trad_objets) |
|
| 445 | - ) { // affichage du formulaire si la configuration l'accepte |
|
| 446 | - $multi_secteurs = lire_config('multi_secteurs'); |
|
| 447 | - $champs = objet_info($type, 'field'); |
|
| 448 | - if ( |
|
| 449 | - $multi_secteurs == 'oui' |
|
| 450 | - and array_key_exists('id_rubrique', $champs) |
|
| 451 | - ) { |
|
| 452 | - // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 453 | - $primary = id_table_objet($type); |
|
| 454 | - if ($table != 'spip_rubriques') { |
|
| 455 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 456 | - } else { |
|
| 457 | - $id_rubrique = $id; |
|
| 458 | - } |
|
| 459 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 460 | - if (!$id_secteur > 0) { |
|
| 461 | - $id_secteur = $id_rubrique; |
|
| 462 | - } |
|
| 463 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 464 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 465 | - if ($langue_secteur != $langue_objet) { |
|
| 466 | - // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 467 | - return true; |
|
| 468 | - } |
|
| 469 | - if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 470 | - return false; |
|
| 471 | - } else { |
|
| 472 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 473 | - if ($id_parent != 0) { |
|
| 474 | - // sous-rubriques : pas de choix de langue |
|
| 475 | - return false; |
|
| 476 | - } |
|
| 477 | - } |
|
| 478 | - } |
|
| 479 | - } else { |
|
| 480 | - return false; |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 439 | + $multi_objets = explode(',', lire_config('multi_objets')); |
|
| 440 | + $gerer_trad_objets = explode(',', lire_config('gerer_trad_objets')); |
|
| 441 | + $table = table_objet_sql($type); |
|
| 442 | + if ( |
|
| 443 | + in_array($table, $multi_objets) |
|
| 444 | + or in_array($table, $gerer_trad_objets) |
|
| 445 | + ) { // affichage du formulaire si la configuration l'accepte |
|
| 446 | + $multi_secteurs = lire_config('multi_secteurs'); |
|
| 447 | + $champs = objet_info($type, 'field'); |
|
| 448 | + if ( |
|
| 449 | + $multi_secteurs == 'oui' |
|
| 450 | + and array_key_exists('id_rubrique', $champs) |
|
| 451 | + ) { |
|
| 452 | + // multilinguisme par secteur et objet rattaché à une rubrique |
|
| 453 | + $primary = id_table_objet($type); |
|
| 454 | + if ($table != 'spip_rubriques') { |
|
| 455 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 456 | + } else { |
|
| 457 | + $id_rubrique = $id; |
|
| 458 | + } |
|
| 459 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 460 | + if (!$id_secteur > 0) { |
|
| 461 | + $id_secteur = $id_rubrique; |
|
| 462 | + } |
|
| 463 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 464 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 465 | + if ($langue_secteur != $langue_objet) { |
|
| 466 | + // configuration incohérente, on laisse l'utilisateur corriger la situation |
|
| 467 | + return true; |
|
| 468 | + } |
|
| 469 | + if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
|
| 470 | + return false; |
|
| 471 | + } else { |
|
| 472 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 473 | + if ($id_parent != 0) { |
|
| 474 | + // sous-rubriques : pas de choix de langue |
|
| 475 | + return false; |
|
| 476 | + } |
|
| 477 | + } |
|
| 478 | + } |
|
| 479 | + } else { |
|
| 480 | + return false; |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | * @return bool true s'il a le droit, false sinon |
| 495 | 495 | **/ |
| 496 | 496 | function autoriser_changertraduction_dist($faire, $type, $id, $qui, $opt) { |
| 497 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 497 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | /** |
@@ -508,41 +508,41 @@ discard block |
||
| 508 | 508 | * @return bool true s'il a le droit, false sinon |
| 509 | 509 | **/ |
| 510 | 510 | function autoriser_dater_dist($faire, $type, $id, $qui, $opt) { |
| 511 | - $table = table_objet($type); |
|
| 512 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 513 | - $desc = $trouver_table($table); |
|
| 514 | - if (!$desc) { |
|
| 515 | - return false; |
|
| 516 | - } |
|
| 517 | - |
|
| 518 | - if (!isset($opt['statut'])) { |
|
| 519 | - if (isset($desc['field']['statut'])) { |
|
| 520 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 521 | - } else { |
|
| 522 | - $statut = 'publie'; |
|
| 523 | - } // pas de statut => publie |
|
| 524 | - } else { |
|
| 525 | - $statut = $opt['statut']; |
|
| 526 | - } |
|
| 527 | - |
|
| 528 | - // Liste des statuts publiés pour cet objet |
|
| 529 | - if (isset($desc['statut'][0]['publie'])) { |
|
| 530 | - $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 531 | - } |
|
| 532 | - // Sinon en dur le statut "publie" |
|
| 533 | - else { |
|
| 534 | - $statuts_publies = ['publie']; |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - if ( |
|
| 538 | - in_array($statut, $statuts_publies) |
|
| 539 | - // Ou cas particulier géré en dur ici pour les articles |
|
| 540 | - or ($statut == 'prop' and $type == 'article' and $GLOBALS['meta']['post_dates'] == 'non') |
|
| 541 | - ) { |
|
| 542 | - return autoriser('modifier', $type, $id); |
|
| 543 | - } |
|
| 544 | - |
|
| 545 | - return false; |
|
| 511 | + $table = table_objet($type); |
|
| 512 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 513 | + $desc = $trouver_table($table); |
|
| 514 | + if (!$desc) { |
|
| 515 | + return false; |
|
| 516 | + } |
|
| 517 | + |
|
| 518 | + if (!isset($opt['statut'])) { |
|
| 519 | + if (isset($desc['field']['statut'])) { |
|
| 520 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 521 | + } else { |
|
| 522 | + $statut = 'publie'; |
|
| 523 | + } // pas de statut => publie |
|
| 524 | + } else { |
|
| 525 | + $statut = $opt['statut']; |
|
| 526 | + } |
|
| 527 | + |
|
| 528 | + // Liste des statuts publiés pour cet objet |
|
| 529 | + if (isset($desc['statut'][0]['publie'])) { |
|
| 530 | + $statuts_publies = explode(',', $desc['statut'][0]['publie']); |
|
| 531 | + } |
|
| 532 | + // Sinon en dur le statut "publie" |
|
| 533 | + else { |
|
| 534 | + $statuts_publies = ['publie']; |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + if ( |
|
| 538 | + in_array($statut, $statuts_publies) |
|
| 539 | + // Ou cas particulier géré en dur ici pour les articles |
|
| 540 | + or ($statut == 'prop' and $type == 'article' and $GLOBALS['meta']['post_dates'] == 'non') |
|
| 541 | + ) { |
|
| 542 | + return autoriser('modifier', $type, $id); |
|
| 543 | + } |
|
| 544 | + |
|
| 545 | + return false; |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | /** |
@@ -559,7 +559,7 @@ discard block |
||
| 559 | 559 | * @return bool true s'il a le droit, false sinon |
| 560 | 560 | **/ |
| 561 | 561 | function autoriser_instituer_dist($faire, $type, $id, $qui, $opt) { |
| 562 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 562 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 563 | 563 | } |
| 564 | 564 | |
| 565 | 565 | /** |
@@ -575,12 +575,12 @@ discard block |
||
| 575 | 575 | * @return bool true s'il a le droit, false sinon |
| 576 | 576 | **/ |
| 577 | 577 | function autoriser_rubrique_publierdans_dist($faire, $type, $id, $qui, $opt) { |
| 578 | - return |
|
| 579 | - ($qui['statut'] == '0minirezo') |
|
| 580 | - and ( |
|
| 581 | - !$qui['restreint'] or !$id |
|
| 582 | - or in_array($id, $qui['restreint']) |
|
| 583 | - ); |
|
| 578 | + return |
|
| 579 | + ($qui['statut'] == '0minirezo') |
|
| 580 | + and ( |
|
| 581 | + !$qui['restreint'] or !$id |
|
| 582 | + or in_array($id, $qui['restreint']) |
|
| 583 | + ); |
|
| 584 | 584 | } |
| 585 | 585 | |
| 586 | 586 | /** |
@@ -596,12 +596,12 @@ discard block |
||
| 596 | 596 | * @return bool true s'il a le droit, false sinon |
| 597 | 597 | **/ |
| 598 | 598 | function autoriser_rubrique_creer_dist($faire, $type, $id, $qui, $opt) { |
| 599 | - if (!empty($opt['id_parent'])) { |
|
| 600 | - return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 601 | - } |
|
| 602 | - else { |
|
| 603 | - return autoriser('defaut', null, null, $qui, $opt); |
|
| 604 | - } |
|
| 599 | + if (!empty($opt['id_parent'])) { |
|
| 600 | + return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
|
| 601 | + } |
|
| 602 | + else { |
|
| 603 | + return autoriser('defaut', null, null, $qui, $opt); |
|
| 604 | + } |
|
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | /** |
@@ -617,10 +617,10 @@ discard block |
||
| 617 | 617 | * @return bool true s'il a le droit, false sinon |
| 618 | 618 | **/ |
| 619 | 619 | function autoriser_rubrique_creerrubriquedans_dist($faire, $type, $id, $qui, $opt) { |
| 620 | - return |
|
| 621 | - ($id or ($qui['statut'] == '0minirezo' and !$qui['restreint'])) |
|
| 622 | - and autoriser('voir', 'rubrique', $id) |
|
| 623 | - and autoriser('publierdans', 'rubrique', $id); |
|
| 620 | + return |
|
| 621 | + ($id or ($qui['statut'] == '0minirezo' and !$qui['restreint'])) |
|
| 622 | + and autoriser('voir', 'rubrique', $id) |
|
| 623 | + and autoriser('publierdans', 'rubrique', $id); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | /** |
@@ -636,10 +636,10 @@ discard block |
||
| 636 | 636 | * @return bool true s'il a le droit, false sinon |
| 637 | 637 | **/ |
| 638 | 638 | function autoriser_rubrique_creerarticledans_dist($faire, $type, $id, $qui, $opt) { |
| 639 | - return |
|
| 640 | - $id |
|
| 641 | - and autoriser('voir', 'rubrique', $id) |
|
| 642 | - and autoriser('creer', 'article'); |
|
| 639 | + return |
|
| 640 | + $id |
|
| 641 | + and autoriser('voir', 'rubrique', $id) |
|
| 642 | + and autoriser('creer', 'article'); |
|
| 643 | 643 | } |
| 644 | 644 | |
| 645 | 645 | |
@@ -656,8 +656,8 @@ discard block |
||
| 656 | 656 | * @return bool true s'il a le droit, false sinon |
| 657 | 657 | **/ |
| 658 | 658 | function autoriser_rubrique_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 659 | - return |
|
| 660 | - autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 659 | + return |
|
| 660 | + autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | /** |
@@ -673,29 +673,29 @@ discard block |
||
| 673 | 673 | * @return bool true s'il a le droit, false sinon |
| 674 | 674 | **/ |
| 675 | 675 | function autoriser_rubrique_supprimer_dist($faire, $type, $id, $qui, $opt) { |
| 676 | - if (!$id = intval($id)) { |
|
| 677 | - return false; |
|
| 678 | - } |
|
| 676 | + if (!$id = intval($id)) { |
|
| 677 | + return false; |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 681 | - return false; |
|
| 682 | - } |
|
| 680 | + if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 681 | + return false; |
|
| 682 | + } |
|
| 683 | 683 | |
| 684 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 685 | - return false; |
|
| 686 | - } |
|
| 684 | + if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 685 | + return false; |
|
| 686 | + } |
|
| 687 | 687 | |
| 688 | - $compte = pipeline( |
|
| 689 | - 'objet_compte_enfants', |
|
| 690 | - ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 691 | - ); |
|
| 692 | - foreach ($compte as $objet => $n) { |
|
| 693 | - if ($n) { |
|
| 694 | - return false; |
|
| 695 | - } |
|
| 696 | - } |
|
| 688 | + $compte = pipeline( |
|
| 689 | + 'objet_compte_enfants', |
|
| 690 | + ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []] |
|
| 691 | + ); |
|
| 692 | + foreach ($compte as $objet => $n) { |
|
| 693 | + if ($n) { |
|
| 694 | + return false; |
|
| 695 | + } |
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | - return autoriser('modifier', 'rubrique', $id); |
|
| 698 | + return autoriser('modifier', 'rubrique', $id); |
|
| 699 | 699 | } |
| 700 | 700 | |
| 701 | 701 | |
@@ -713,20 +713,20 @@ discard block |
||
| 713 | 713 | * @return bool true s'il a le droit, false sinon |
| 714 | 714 | **/ |
| 715 | 715 | function autoriser_article_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 716 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 716 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 717 | 717 | |
| 718 | - return |
|
| 719 | - $r |
|
| 720 | - and |
|
| 721 | - ( |
|
| 722 | - autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 723 | - or ( |
|
| 724 | - (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
|
| 725 | - and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 726 | - and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 727 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 728 | - ) |
|
| 729 | - ); |
|
| 718 | + return |
|
| 719 | + $r |
|
| 720 | + and |
|
| 721 | + ( |
|
| 722 | + autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt) |
|
| 723 | + or ( |
|
| 724 | + (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
|
| 725 | + and in_array($qui['statut'], ['0minirezo', '1comite']) |
|
| 726 | + and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
|
| 727 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 728 | + ) |
|
| 729 | + ); |
|
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | /** |
@@ -742,13 +742,13 @@ discard block |
||
| 742 | 742 | * @return bool true s'il a le droit, false sinon |
| 743 | 743 | **/ |
| 744 | 744 | function autoriser_article_creer_dist($faire, $type, $id, $qui, $opt) { |
| 745 | - if (!empty($opt['id_parent'])) { |
|
| 746 | - // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 747 | - return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 748 | - } |
|
| 749 | - else { |
|
| 750 | - return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 751 | - } |
|
| 745 | + if (!empty($opt['id_parent'])) { |
|
| 746 | + // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
|
| 747 | + return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
|
| 748 | + } |
|
| 749 | + else { |
|
| 750 | + return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
|
| 751 | + } |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | /** |
@@ -768,28 +768,28 @@ discard block |
||
| 768 | 768 | * @return bool true s'il a le droit, false sinon |
| 769 | 769 | */ |
| 770 | 770 | function autoriser_article_voir_dist($faire, $type, $id, $qui, $opt) { |
| 771 | - if ($qui['statut'] == '0minirezo') { |
|
| 772 | - return true; |
|
| 773 | - } |
|
| 774 | - // cas des articles : depend du statut de l'article et de l'auteur |
|
| 775 | - if (isset($opt['statut'])) { |
|
| 776 | - $statut = $opt['statut']; |
|
| 777 | - } else { |
|
| 778 | - if (!$id) { |
|
| 779 | - return false; |
|
| 780 | - } |
|
| 781 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 782 | - } |
|
| 783 | - |
|
| 784 | - return |
|
| 785 | - // si on est pas auteur de l'article, |
|
| 786 | - // seuls les propose et publies sont visibles |
|
| 787 | - in_array($statut, ['prop', 'publie']) |
|
| 788 | - // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 789 | - or |
|
| 790 | - ($id |
|
| 791 | - and $qui['id_auteur'] |
|
| 792 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 771 | + if ($qui['statut'] == '0minirezo') { |
|
| 772 | + return true; |
|
| 773 | + } |
|
| 774 | + // cas des articles : depend du statut de l'article et de l'auteur |
|
| 775 | + if (isset($opt['statut'])) { |
|
| 776 | + $statut = $opt['statut']; |
|
| 777 | + } else { |
|
| 778 | + if (!$id) { |
|
| 779 | + return false; |
|
| 780 | + } |
|
| 781 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 782 | + } |
|
| 783 | + |
|
| 784 | + return |
|
| 785 | + // si on est pas auteur de l'article, |
|
| 786 | + // seuls les propose et publies sont visibles |
|
| 787 | + in_array($statut, ['prop', 'publie']) |
|
| 788 | + // sinon si on est auteur, on a le droit de le voir, evidemment ! |
|
| 789 | + or |
|
| 790 | + ($id |
|
| 791 | + and $qui['id_auteur'] |
|
| 792 | + and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | |
@@ -806,24 +806,24 @@ discard block |
||
| 806 | 806 | * @return bool true s'il a le droit, false sinon |
| 807 | 807 | **/ |
| 808 | 808 | function autoriser_voir_dist($faire, $type, $id, $qui, $opt) { |
| 809 | - # securite, mais on aurait pas du arriver ici ! |
|
| 810 | - if ( |
|
| 811 | - function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 812 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 813 | - ) { |
|
| 814 | - return $f($faire, $type, $id, $qui, $opt); |
|
| 815 | - } |
|
| 809 | + # securite, mais on aurait pas du arriver ici ! |
|
| 810 | + if ( |
|
| 811 | + function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 812 | + or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 813 | + ) { |
|
| 814 | + return $f($faire, $type, $id, $qui, $opt); |
|
| 815 | + } |
|
| 816 | 816 | |
| 817 | - if ($qui['statut'] == '0minirezo') { |
|
| 818 | - return true; |
|
| 819 | - } |
|
| 820 | - // admins et redacteurs peuvent voir un auteur |
|
| 821 | - if ($type == 'auteur') { |
|
| 822 | - return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 823 | - } |
|
| 824 | - // sinon par defaut tout est visible |
|
| 825 | - // sauf cas particuliers traites separemment (ie article) |
|
| 826 | - return true; |
|
| 817 | + if ($qui['statut'] == '0minirezo') { |
|
| 818 | + return true; |
|
| 819 | + } |
|
| 820 | + // admins et redacteurs peuvent voir un auteur |
|
| 821 | + if ($type == 'auteur') { |
|
| 822 | + return in_array($qui['statut'], ['0minirezo', '1comite']); |
|
| 823 | + } |
|
| 824 | + // sinon par defaut tout est visible |
|
| 825 | + // sauf cas particuliers traites separemment (ie article) |
|
| 826 | + return true; |
|
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | |
@@ -844,12 +844,12 @@ discard block |
||
| 844 | 844 | * @return bool true s'il a le droit, false sinon |
| 845 | 845 | **/ |
| 846 | 846 | function autoriser_webmestre_dist($faire, $type, $id, $qui, $opt) { |
| 847 | - return |
|
| 848 | - (defined('_ID_WEBMESTRES') ? |
|
| 849 | - in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 850 | - : $qui['webmestre'] == 'oui') |
|
| 851 | - and $qui['statut'] == '0minirezo' |
|
| 852 | - and !$qui['restreint']; |
|
| 847 | + return |
|
| 848 | + (defined('_ID_WEBMESTRES') ? |
|
| 849 | + in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES)) |
|
| 850 | + : $qui['webmestre'] == 'oui') |
|
| 851 | + and $qui['statut'] == '0minirezo' |
|
| 852 | + and !$qui['restreint']; |
|
| 853 | 853 | } |
| 854 | 854 | |
| 855 | 855 | /** |
@@ -865,9 +865,9 @@ discard block |
||
| 865 | 865 | * @return bool true s'il a le droit, false sinon |
| 866 | 866 | **/ |
| 867 | 867 | function autoriser_configurer_dist($faire, $type, $id, $qui, $opt) { |
| 868 | - return |
|
| 869 | - $qui['statut'] == '0minirezo' |
|
| 870 | - and !$qui['restreint']; |
|
| 868 | + return |
|
| 869 | + $qui['statut'] == '0minirezo' |
|
| 870 | + and !$qui['restreint']; |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | /** |
@@ -883,8 +883,8 @@ discard block |
||
| 883 | 883 | * @return bool true s'il a le droit, false sinon |
| 884 | 884 | **/ |
| 885 | 885 | function autoriser_sauvegarder_dist($faire, $type, $id, $qui, $opt) { |
| 886 | - return |
|
| 887 | - $qui['statut'] == '0minirezo'; |
|
| 886 | + return |
|
| 887 | + $qui['statut'] == '0minirezo'; |
|
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | /** |
@@ -900,8 +900,8 @@ discard block |
||
| 900 | 900 | * @return bool true s'il a le droit, false sinon |
| 901 | 901 | **/ |
| 902 | 902 | function autoriser_detruire_dist($faire, $type, $id, $qui, $opt) { |
| 903 | - return |
|
| 904 | - autoriser('webmestre', null, null, $qui, $opt); |
|
| 903 | + return |
|
| 904 | + autoriser('webmestre', null, null, $qui, $opt); |
|
| 905 | 905 | } |
| 906 | 906 | |
| 907 | 907 | /** |
@@ -918,21 +918,21 @@ discard block |
||
| 918 | 918 | * @return bool true s'il a le droit, false sinon |
| 919 | 919 | **/ |
| 920 | 920 | function autoriser_auteur_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 921 | - // les admins peuvent "previsualiser" une page auteur |
|
| 922 | - if ( |
|
| 923 | - $qui['statut'] == '0minirezo' |
|
| 924 | - and !$qui['restreint'] |
|
| 925 | - ) { |
|
| 926 | - return true; |
|
| 927 | - } |
|
| 928 | - // "Voir en ligne" si l'auteur a un article publie |
|
| 929 | - $n = sql_fetsel( |
|
| 930 | - 'A.id_article', |
|
| 931 | - 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 932 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 933 | - ); |
|
| 921 | + // les admins peuvent "previsualiser" une page auteur |
|
| 922 | + if ( |
|
| 923 | + $qui['statut'] == '0minirezo' |
|
| 924 | + and !$qui['restreint'] |
|
| 925 | + ) { |
|
| 926 | + return true; |
|
| 927 | + } |
|
| 928 | + // "Voir en ligne" si l'auteur a un article publie |
|
| 929 | + $n = sql_fetsel( |
|
| 930 | + 'A.id_article', |
|
| 931 | + 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
|
| 932 | + "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 933 | + ); |
|
| 934 | 934 | |
| 935 | - return $n ? true : false; |
|
| 935 | + return $n ? true : false; |
|
| 936 | 936 | } |
| 937 | 937 | |
| 938 | 938 | |
@@ -960,7 +960,7 @@ discard block |
||
| 960 | 960 | * @return bool true s'il a le droit, false sinon |
| 961 | 961 | **/ |
| 962 | 962 | function autoriser_auteur_creer_dist($faire, $type, $id, $qui, $opt) { |
| 963 | - return ($qui['statut'] == '0minirezo'); |
|
| 963 | + return ($qui['statut'] == '0minirezo'); |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | |
@@ -980,73 +980,73 @@ discard block |
||
| 980 | 980 | **/ |
| 981 | 981 | function autoriser_auteur_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 982 | 982 | |
| 983 | - // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 984 | - // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 985 | - if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 986 | - if ( |
|
| 987 | - $id == $qui['id_auteur'] |
|
| 988 | - && empty($opt['statut']) |
|
| 989 | - && empty($opt['webmestre']) |
|
| 990 | - && empty($opt['restreintes']) |
|
| 991 | - && empty($opt['login']) |
|
| 992 | - ) { |
|
| 993 | - return true; |
|
| 994 | - } |
|
| 995 | - return false; |
|
| 996 | - } |
|
| 997 | - |
|
| 998 | - // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 999 | - // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1000 | - if ($qui['restreint']) { |
|
| 1001 | - if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1002 | - return false; |
|
| 1003 | - } elseif ( |
|
| 1004 | - (isset($opt['statut']) and ($opt['statut'] == '0minirezo')) |
|
| 1005 | - or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1006 | - ) { |
|
| 1007 | - return false; |
|
| 1008 | - } else { |
|
| 1009 | - if ($id == $qui['id_auteur']) { |
|
| 1010 | - if (isset($opt['statut']) and $opt['statut']) { |
|
| 1011 | - return false; |
|
| 1012 | - } else { |
|
| 1013 | - return true; |
|
| 1014 | - } |
|
| 1015 | - } else { |
|
| 1016 | - if ($id_auteur = intval($id)) { |
|
| 1017 | - $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1018 | - if ($t and $t['statut'] != '0minirezo') { |
|
| 1019 | - return true; |
|
| 1020 | - } else { |
|
| 1021 | - return false; |
|
| 1022 | - } |
|
| 1023 | - } // id = 0 => creation |
|
| 1024 | - else { |
|
| 1025 | - return true; |
|
| 1026 | - } |
|
| 1027 | - } |
|
| 1028 | - } |
|
| 1029 | - } |
|
| 1030 | - |
|
| 1031 | - // Un admin complet fait ce qu'il veut |
|
| 1032 | - // sauf se degrader |
|
| 1033 | - if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1034 | - return false; |
|
| 1035 | - } elseif ( |
|
| 1036 | - isset($opt['webmestre']) |
|
| 1037 | - and $opt['webmestre'] |
|
| 1038 | - and (defined('_ID_WEBMESTRES') |
|
| 1039 | - or !autoriser('webmestre')) |
|
| 1040 | - ) { |
|
| 1041 | - // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1042 | - // ou si les webmestres sont fixes par constante (securite) |
|
| 1043 | - return false; |
|
| 1044 | - } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1045 | - elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) { |
|
| 1046 | - return false; |
|
| 1047 | - } else { |
|
| 1048 | - return true; |
|
| 1049 | - } |
|
| 983 | + // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login |
|
| 984 | + // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca |
|
| 985 | + if (!in_array($qui['statut'], ['0minirezo'])) { |
|
| 986 | + if ( |
|
| 987 | + $id == $qui['id_auteur'] |
|
| 988 | + && empty($opt['statut']) |
|
| 989 | + && empty($opt['webmestre']) |
|
| 990 | + && empty($opt['restreintes']) |
|
| 991 | + && empty($opt['login']) |
|
| 992 | + ) { |
|
| 993 | + return true; |
|
| 994 | + } |
|
| 995 | + return false; |
|
| 996 | + } |
|
| 997 | + |
|
| 998 | + // Un admin restreint peut modifier/creer un auteur non-admin mais il |
|
| 999 | + // n'a le droit ni de le promouvoir admin, ni de changer les rubriques |
|
| 1000 | + if ($qui['restreint']) { |
|
| 1001 | + if (isset($opt['webmestre']) and $opt['webmestre']) { |
|
| 1002 | + return false; |
|
| 1003 | + } elseif ( |
|
| 1004 | + (isset($opt['statut']) and ($opt['statut'] == '0minirezo')) |
|
| 1005 | + or (isset($opt['restreintes']) and $opt['restreintes']) |
|
| 1006 | + ) { |
|
| 1007 | + return false; |
|
| 1008 | + } else { |
|
| 1009 | + if ($id == $qui['id_auteur']) { |
|
| 1010 | + if (isset($opt['statut']) and $opt['statut']) { |
|
| 1011 | + return false; |
|
| 1012 | + } else { |
|
| 1013 | + return true; |
|
| 1014 | + } |
|
| 1015 | + } else { |
|
| 1016 | + if ($id_auteur = intval($id)) { |
|
| 1017 | + $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur"); |
|
| 1018 | + if ($t and $t['statut'] != '0minirezo') { |
|
| 1019 | + return true; |
|
| 1020 | + } else { |
|
| 1021 | + return false; |
|
| 1022 | + } |
|
| 1023 | + } // id = 0 => creation |
|
| 1024 | + else { |
|
| 1025 | + return true; |
|
| 1026 | + } |
|
| 1027 | + } |
|
| 1028 | + } |
|
| 1029 | + } |
|
| 1030 | + |
|
| 1031 | + // Un admin complet fait ce qu'il veut |
|
| 1032 | + // sauf se degrader |
|
| 1033 | + if ($id == $qui['id_auteur'] && (isset($opt['statut']) and $opt['statut'])) { |
|
| 1034 | + return false; |
|
| 1035 | + } elseif ( |
|
| 1036 | + isset($opt['webmestre']) |
|
| 1037 | + and $opt['webmestre'] |
|
| 1038 | + and (defined('_ID_WEBMESTRES') |
|
| 1039 | + or !autoriser('webmestre')) |
|
| 1040 | + ) { |
|
| 1041 | + // et toucher au statut webmestre si il ne l'est pas lui meme |
|
| 1042 | + // ou si les webmestres sont fixes par constante (securite) |
|
| 1043 | + return false; |
|
| 1044 | + } // et modifier un webmestre si il ne l'est pas lui meme |
|
| 1045 | + elseif (intval($id) and autoriser('webmestre', '', 0, $id) and !autoriser('webmestre')) { |
|
| 1046 | + return false; |
|
| 1047 | + } else { |
|
| 1048 | + return true; |
|
| 1049 | + } |
|
| 1050 | 1050 | } |
| 1051 | 1051 | |
| 1052 | 1052 | |
@@ -1063,7 +1063,7 @@ discard block |
||
| 1063 | 1063 | * @return bool true s'il a le droit, false sinon |
| 1064 | 1064 | **/ |
| 1065 | 1065 | function autoriser_associerauteurs_dist($faire, $type, $id, $qui, $opt) { |
| 1066 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1066 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1067 | 1067 | } |
| 1068 | 1068 | |
| 1069 | 1069 | |
@@ -1080,7 +1080,7 @@ discard block |
||
| 1080 | 1080 | * @return bool true s'il a le droit, false sinon |
| 1081 | 1081 | **/ |
| 1082 | 1082 | function autoriser_chargerftp_dist($faire, $type, $id, $qui, $opt) { |
| 1083 | - return $qui['statut'] == '0minirezo'; |
|
| 1083 | + return $qui['statut'] == '0minirezo'; |
|
| 1084 | 1084 | } |
| 1085 | 1085 | |
| 1086 | 1086 | /** |
@@ -1096,7 +1096,7 @@ discard block |
||
| 1096 | 1096 | * @return bool true s'il a le droit, false sinon |
| 1097 | 1097 | **/ |
| 1098 | 1098 | function autoriser_debug_dist($faire, $type, $id, $qui, $opt) { |
| 1099 | - return $qui['statut'] == '0minirezo'; |
|
| 1099 | + return $qui['statut'] == '0minirezo'; |
|
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | 1102 | /** |
@@ -1113,54 +1113,54 @@ discard block |
||
| 1113 | 1113 | * @return array Liste des rubriques |
| 1114 | 1114 | **/ |
| 1115 | 1115 | function liste_rubriques_auteur($id_auteur, $raz = false) { |
| 1116 | - static $restreint = []; |
|
| 1117 | - |
|
| 1118 | - if (!$id_auteur = intval($id_auteur)) { |
|
| 1119 | - return []; |
|
| 1120 | - } |
|
| 1121 | - if ($raz) { |
|
| 1122 | - unset($restreint[$id_auteur]); |
|
| 1123 | - } elseif (isset($restreint[$id_auteur])) { |
|
| 1124 | - return $restreint[$id_auteur]; |
|
| 1125 | - } |
|
| 1126 | - |
|
| 1127 | - $rubriques = []; |
|
| 1128 | - if ( |
|
| 1129 | - (!isset($GLOBALS['meta']['version_installee']) |
|
| 1130 | - or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1131 | - and $r = sql_allfetsel( |
|
| 1132 | - 'id_objet', |
|
| 1133 | - 'spip_auteurs_liens', |
|
| 1134 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1135 | - ) |
|
| 1136 | - and count($r) |
|
| 1137 | - ) { |
|
| 1138 | - $r = array_column($r, 'id_objet'); |
|
| 1139 | - |
|
| 1140 | - // recuperer toute la branche, au format chaine enumeration |
|
| 1141 | - include_spip('inc/rubriques'); |
|
| 1142 | - $r = calcul_branche_in($r); |
|
| 1143 | - $r = explode(',', $r); |
|
| 1144 | - |
|
| 1145 | - // passer les rubriques en index, elimine les doublons |
|
| 1146 | - $r = array_flip($r); |
|
| 1147 | - // recuperer les index seuls |
|
| 1148 | - $r = array_keys($r); |
|
| 1149 | - // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1150 | - // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1151 | - $rubriques = array_combine($r, $r); |
|
| 1152 | - } |
|
| 1153 | - |
|
| 1154 | - // Affecter l'auteur session le cas echeant |
|
| 1155 | - if ( |
|
| 1156 | - isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1157 | - and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1158 | - ) { |
|
| 1159 | - $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1160 | - } |
|
| 1161 | - |
|
| 1162 | - |
|
| 1163 | - return $restreint[$id_auteur] = $rubriques; |
|
| 1116 | + static $restreint = []; |
|
| 1117 | + |
|
| 1118 | + if (!$id_auteur = intval($id_auteur)) { |
|
| 1119 | + return []; |
|
| 1120 | + } |
|
| 1121 | + if ($raz) { |
|
| 1122 | + unset($restreint[$id_auteur]); |
|
| 1123 | + } elseif (isset($restreint[$id_auteur])) { |
|
| 1124 | + return $restreint[$id_auteur]; |
|
| 1125 | + } |
|
| 1126 | + |
|
| 1127 | + $rubriques = []; |
|
| 1128 | + if ( |
|
| 1129 | + (!isset($GLOBALS['meta']['version_installee']) |
|
| 1130 | + or $GLOBALS['meta']['version_installee'] > 16428) |
|
| 1131 | + and $r = sql_allfetsel( |
|
| 1132 | + 'id_objet', |
|
| 1133 | + 'spip_auteurs_liens', |
|
| 1134 | + 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1135 | + ) |
|
| 1136 | + and count($r) |
|
| 1137 | + ) { |
|
| 1138 | + $r = array_column($r, 'id_objet'); |
|
| 1139 | + |
|
| 1140 | + // recuperer toute la branche, au format chaine enumeration |
|
| 1141 | + include_spip('inc/rubriques'); |
|
| 1142 | + $r = calcul_branche_in($r); |
|
| 1143 | + $r = explode(',', $r); |
|
| 1144 | + |
|
| 1145 | + // passer les rubriques en index, elimine les doublons |
|
| 1146 | + $r = array_flip($r); |
|
| 1147 | + // recuperer les index seuls |
|
| 1148 | + $r = array_keys($r); |
|
| 1149 | + // combiner pour avoir un tableau id_rubrique=>id_rubrique |
|
| 1150 | + // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent) |
|
| 1151 | + $rubriques = array_combine($r, $r); |
|
| 1152 | + } |
|
| 1153 | + |
|
| 1154 | + // Affecter l'auteur session le cas echeant |
|
| 1155 | + if ( |
|
| 1156 | + isset($GLOBALS['visiteur_session']['id_auteur']) |
|
| 1157 | + and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur |
|
| 1158 | + ) { |
|
| 1159 | + $GLOBALS['visiteur_session']['restreint'] = $rubriques; |
|
| 1160 | + } |
|
| 1161 | + |
|
| 1162 | + |
|
| 1163 | + return $restreint[$id_auteur] = $rubriques; |
|
| 1164 | 1164 | } |
| 1165 | 1165 | |
| 1166 | 1166 | /** |
@@ -1176,7 +1176,7 @@ discard block |
||
| 1176 | 1176 | * @return bool true s'il a le droit, false sinon |
| 1177 | 1177 | **/ |
| 1178 | 1178 | function autoriser_rubrique_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 1179 | - return autoriser('previsualiser'); |
|
| 1179 | + return autoriser('previsualiser'); |
|
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | 1182 | /** |
@@ -1192,7 +1192,7 @@ discard block |
||
| 1192 | 1192 | * @return bool true s'il a le droit, false sinon |
| 1193 | 1193 | **/ |
| 1194 | 1194 | function autoriser_rubrique_iconifier_dist($faire, $type, $id, $qui, $opt) { |
| 1195 | - return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1195 | + return autoriser('publierdans', 'rubrique', $id, $qui, $opt); |
|
| 1196 | 1196 | } |
| 1197 | 1197 | |
| 1198 | 1198 | /** |
@@ -1208,8 +1208,8 @@ discard block |
||
| 1208 | 1208 | * @return bool true s'il a le droit, false sinon |
| 1209 | 1209 | **/ |
| 1210 | 1210 | function autoriser_auteur_iconifier_dist($faire, $type, $id, $qui, $opt) { |
| 1211 | - return (($id == $qui['id_auteur']) or |
|
| 1212 | - (($qui['statut'] == '0minirezo') and !$qui['restreint'])); |
|
| 1211 | + return (($id == $qui['id_auteur']) or |
|
| 1212 | + (($qui['statut'] == '0minirezo') and !$qui['restreint'])); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | /** |
@@ -1225,8 +1225,8 @@ discard block |
||
| 1225 | 1225 | * @return bool true s'il a le droit, false sinon |
| 1226 | 1226 | **/ |
| 1227 | 1227 | function autoriser_iconifier_dist($faire, $type, $id, $qui, $opt) { |
| 1228 | - // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1229 | - return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1228 | + // par defaut, on a le droit d'iconifier si on a le droit de modifier |
|
| 1229 | + return autoriser('modifier', $type, $id, $qui, $opt); |
|
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | 1232 | |
@@ -1244,7 +1244,7 @@ discard block |
||
| 1244 | 1244 | * @return bool true |
| 1245 | 1245 | **/ |
| 1246 | 1246 | function autoriser_ok_dist($faire, $type, $id, $qui, $opt) { |
| 1247 | - return true; |
|
| 1247 | + return true; |
|
| 1248 | 1248 | } |
| 1249 | 1249 | |
| 1250 | 1250 | /** |
@@ -1261,7 +1261,7 @@ discard block |
||
| 1261 | 1261 | * @return bool false |
| 1262 | 1262 | **/ |
| 1263 | 1263 | function autoriser_niet_dist($faire, $type, $id, $qui, $opt) { |
| 1264 | - return false; |
|
| 1264 | + return false; |
|
| 1265 | 1265 | } |
| 1266 | 1266 | |
| 1267 | 1267 | /** |
@@ -1277,11 +1277,11 @@ discard block |
||
| 1277 | 1277 | * @return bool false |
| 1278 | 1278 | **/ |
| 1279 | 1279 | function autoriser_base_reparer_dist($faire, $type, $id, $qui, $opt) { |
| 1280 | - if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1281 | - return false; |
|
| 1282 | - } |
|
| 1280 | + if (!autoriser('detruire') or _request('reinstall')) { |
|
| 1281 | + return false; |
|
| 1282 | + } |
|
| 1283 | 1283 | |
| 1284 | - return true; |
|
| 1284 | + return true; |
|
| 1285 | 1285 | } |
| 1286 | 1286 | |
| 1287 | 1287 | /** |
@@ -1297,7 +1297,7 @@ discard block |
||
| 1297 | 1297 | * @return bool true s'il a le droit, false sinon |
| 1298 | 1298 | **/ |
| 1299 | 1299 | function autoriser_infosperso_dist($faire, $type, $id, $qui, $opt) { |
| 1300 | - return true; |
|
| 1300 | + return true; |
|
| 1301 | 1301 | } |
| 1302 | 1302 | |
| 1303 | 1303 | /** |
@@ -1313,7 +1313,7 @@ discard block |
||
| 1313 | 1313 | * @return bool true s'il a le droit, false sinon |
| 1314 | 1314 | **/ |
| 1315 | 1315 | function autoriser_langage_configurer_dist($faire, $type, $id, $qui, $opt) { |
| 1316 | - return true; |
|
| 1316 | + return true; |
|
| 1317 | 1317 | } |
| 1318 | 1318 | |
| 1319 | 1319 | /** |
@@ -1329,7 +1329,7 @@ discard block |
||
| 1329 | 1329 | * @return bool true s'il a le droit, false sinon |
| 1330 | 1330 | **/ |
| 1331 | 1331 | function autoriser_configurerlangage_dist($faire, $type, $id, $qui, $opt) { |
| 1332 | - return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1332 | + return autoriser('configurer', '_langage', $id, $qui, $opt); |
|
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | 1335 | /** |
@@ -1345,7 +1345,7 @@ discard block |
||
| 1345 | 1345 | * @return bool true s'il a le droit, false sinon |
| 1346 | 1346 | **/ |
| 1347 | 1347 | function autoriser_preferences_configurer_dist($faire, $type, $id, $qui, $opt) { |
| 1348 | - return true; |
|
| 1348 | + return true; |
|
| 1349 | 1349 | } |
| 1350 | 1350 | |
| 1351 | 1351 | /** |
@@ -1361,7 +1361,7 @@ discard block |
||
| 1361 | 1361 | * @return bool true s'il a le droit, false sinon |
| 1362 | 1362 | **/ |
| 1363 | 1363 | function autoriser_configurerpreferences_dist($faire, $type, $id, $qui, $opt) { |
| 1364 | - return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1364 | + return autoriser('configurer', '_preferences', $id, $qui, $opt); |
|
| 1365 | 1365 | } |
| 1366 | 1366 | |
| 1367 | 1367 | /** |
@@ -1377,8 +1377,8 @@ discard block |
||
| 1377 | 1377 | * @return bool true s'il a le droit, false sinon |
| 1378 | 1378 | **/ |
| 1379 | 1379 | function autoriser_menudeveloppement_menugrandeentree_dist($faire, $type, $id, $qui, $opt) { |
| 1380 | - return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1381 | - and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] == 'oui'); |
|
| 1380 | + return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) |
|
| 1381 | + and $GLOBALS['visiteur_session']['prefs']['activer_menudev'] == 'oui'); |
|
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | /** |
@@ -1395,7 +1395,7 @@ discard block |
||
| 1395 | 1395 | * @return bool true s'il a le droit, false sinon |
| 1396 | 1396 | **/ |
| 1397 | 1397 | function autoriser_menugrandeentree_dist($faire, $type, $id, $qui, $opt) { |
| 1398 | - return true; |
|
| 1398 | + return true; |
|
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | /** |
@@ -1411,7 +1411,7 @@ discard block |
||
| 1411 | 1411 | * @return bool true s'il a le droit, false sinon |
| 1412 | 1412 | **/ |
| 1413 | 1413 | function autoriser_auteurs_voir_dist($faire, $type, $id, $qui, $opt) { |
| 1414 | - return true; |
|
| 1414 | + return true; |
|
| 1415 | 1415 | } |
| 1416 | 1416 | |
| 1417 | 1417 | /** |
@@ -1427,7 +1427,7 @@ discard block |
||
| 1427 | 1427 | * @return bool true s'il a le droit, false sinon |
| 1428 | 1428 | **/ |
| 1429 | 1429 | function autoriser_auteurs_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1430 | - return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1430 | + return autoriser('voir', '_auteurs', $id, $qui, $opt); |
|
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | /** |
@@ -1443,7 +1443,7 @@ discard block |
||
| 1443 | 1443 | * @return bool true s'il a le droit, false sinon |
| 1444 | 1444 | **/ |
| 1445 | 1445 | function autoriser_articles_voir_dist($faire, $type, $id, $qui, $opt) { |
| 1446 | - return true; |
|
| 1446 | + return true; |
|
| 1447 | 1447 | } |
| 1448 | 1448 | |
| 1449 | 1449 | /** |
@@ -1459,7 +1459,7 @@ discard block |
||
| 1459 | 1459 | * @return bool true s'il a le droit, false sinon |
| 1460 | 1460 | **/ |
| 1461 | 1461 | function autoriser_articles_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1462 | - return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1462 | + return autoriser('voir', '_articles', $id, $qui, $opt); |
|
| 1463 | 1463 | } |
| 1464 | 1464 | |
| 1465 | 1465 | /** |
@@ -1475,7 +1475,7 @@ discard block |
||
| 1475 | 1475 | * @return bool true s'il a le droit, false sinon |
| 1476 | 1476 | **/ |
| 1477 | 1477 | function autoriser_rubriques_voir_dist($faire, $type, $id, $qui, $opt) { |
| 1478 | - return true; |
|
| 1478 | + return true; |
|
| 1479 | 1479 | } |
| 1480 | 1480 | |
| 1481 | 1481 | /** |
@@ -1491,7 +1491,7 @@ discard block |
||
| 1491 | 1491 | * @return bool true s'il a le droit, false sinon |
| 1492 | 1492 | **/ |
| 1493 | 1493 | function autoriser_rubriques_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1494 | - return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1494 | + return autoriser('voir', '_rubriques', $id, $qui, $opt); |
|
| 1495 | 1495 | } |
| 1496 | 1496 | |
| 1497 | 1497 | /** |
@@ -1507,7 +1507,7 @@ discard block |
||
| 1507 | 1507 | * @return bool true s'il a le droit, false sinon |
| 1508 | 1508 | **/ |
| 1509 | 1509 | function autoriser_articlecreer_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1510 | - return verifier_table_non_vide(); |
|
| 1510 | + return verifier_table_non_vide(); |
|
| 1511 | 1511 | } |
| 1512 | 1512 | |
| 1513 | 1513 | |
@@ -1526,7 +1526,7 @@ discard block |
||
| 1526 | 1526 | * @return bool true s'il a le droit, false sinon |
| 1527 | 1527 | **/ |
| 1528 | 1528 | function autoriser_auteurcreer_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1529 | - return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1529 | + return autoriser('creer', 'auteur', $id, $qui, $opt); |
|
| 1530 | 1530 | } |
| 1531 | 1531 | |
| 1532 | 1532 | /** |
@@ -1542,13 +1542,13 @@ discard block |
||
| 1542 | 1542 | * @return bool true s'il a le droit, false sinon |
| 1543 | 1543 | **/ |
| 1544 | 1544 | function autoriser_visiteurs_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1545 | - include_spip('base/abstract_sql'); |
|
| 1546 | - return |
|
| 1547 | - $qui['statut'] == '0minirezo' and !$qui['restreint'] |
|
| 1548 | - and ( |
|
| 1549 | - $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1550 | - or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1551 | - ); |
|
| 1545 | + include_spip('base/abstract_sql'); |
|
| 1546 | + return |
|
| 1547 | + $qui['statut'] == '0minirezo' and !$qui['restreint'] |
|
| 1548 | + and ( |
|
| 1549 | + $GLOBALS['meta']['accepter_visiteurs'] != 'non' |
|
| 1550 | + or sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0 |
|
| 1551 | + ); |
|
| 1552 | 1552 | } |
| 1553 | 1553 | |
| 1554 | 1554 | /** |
@@ -1564,7 +1564,7 @@ discard block |
||
| 1564 | 1564 | * @return bool true s'il a le droit, false sinon |
| 1565 | 1565 | **/ |
| 1566 | 1566 | function autoriser_suiviedito_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1567 | - return $qui['statut'] == '0minirezo'; |
|
| 1567 | + return $qui['statut'] == '0minirezo'; |
|
| 1568 | 1568 | } |
| 1569 | 1569 | |
| 1570 | 1570 | /** |
@@ -1580,7 +1580,7 @@ discard block |
||
| 1580 | 1580 | * @return bool true s'il a le droit, false sinon |
| 1581 | 1581 | **/ |
| 1582 | 1582 | function autoriser_synchro_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1583 | - return $qui['statut'] == '0minirezo'; |
|
| 1583 | + return $qui['statut'] == '0minirezo'; |
|
| 1584 | 1584 | } |
| 1585 | 1585 | |
| 1586 | 1586 | /** |
@@ -1596,7 +1596,7 @@ discard block |
||
| 1596 | 1596 | * @return bool true s'il a le droit, false sinon |
| 1597 | 1597 | **/ |
| 1598 | 1598 | function autoriser_configurerinteractions_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1599 | - return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1599 | + return autoriser('configurer', '_interactions', $id, $qui, $opt); |
|
| 1600 | 1600 | } |
| 1601 | 1601 | |
| 1602 | 1602 | /** |
@@ -1612,7 +1612,7 @@ discard block |
||
| 1612 | 1612 | * @return bool true s'il a le droit, false sinon |
| 1613 | 1613 | **/ |
| 1614 | 1614 | function autoriser_configurerlangue_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1615 | - return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1615 | + return autoriser('configurer', '_langue', $id, $qui, $opt); |
|
| 1616 | 1616 | } |
| 1617 | 1617 | |
| 1618 | 1618 | /** |
@@ -1628,7 +1628,7 @@ discard block |
||
| 1628 | 1628 | * @return bool true s'il a le droit, false sinon |
| 1629 | 1629 | **/ |
| 1630 | 1630 | function autoriser_configurermultilinguisme_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1631 | - return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1631 | + return autoriser('configurer', '_multilinguisme', $id, $qui, $opt); |
|
| 1632 | 1632 | } |
| 1633 | 1633 | |
| 1634 | 1634 | /** |
@@ -1644,7 +1644,7 @@ discard block |
||
| 1644 | 1644 | * @return bool true s'il a le droit, false sinon |
| 1645 | 1645 | **/ |
| 1646 | 1646 | function autoriser_configurercontenu_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1647 | - return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1647 | + return autoriser('configurer', '_contenu', $id, $qui, $opt); |
|
| 1648 | 1648 | } |
| 1649 | 1649 | |
| 1650 | 1650 | /** |
@@ -1660,7 +1660,7 @@ discard block |
||
| 1660 | 1660 | * @return bool true s'il a le droit, false sinon |
| 1661 | 1661 | **/ |
| 1662 | 1662 | function autoriser_configureravancees_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1663 | - return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1663 | + return autoriser('configurer', '_avancees', $id, $qui, $opt); |
|
| 1664 | 1664 | } |
| 1665 | 1665 | |
| 1666 | 1666 | /** |
@@ -1676,7 +1676,7 @@ discard block |
||
| 1676 | 1676 | * @return bool true s'il a le droit, false sinon |
| 1677 | 1677 | **/ |
| 1678 | 1678 | function autoriser_adminplugin_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1679 | - return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1679 | + return autoriser('configurer', '_plugins', $id, $qui, $opt); |
|
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | 1682 | /** |
@@ -1692,7 +1692,7 @@ discard block |
||
| 1692 | 1692 | * @return bool true s'il a le droit, false sinon |
| 1693 | 1693 | **/ |
| 1694 | 1694 | function autoriser_admintech_menu_dist($faire, $type, $id, $qui, $opt) { |
| 1695 | - return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1695 | + return autoriser('detruire', $type, $id, $qui, $opt); |
|
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | 1698 | /** |
@@ -1708,7 +1708,7 @@ discard block |
||
| 1708 | 1708 | * @return bool true s'il a le droit, false sinon |
| 1709 | 1709 | **/ |
| 1710 | 1710 | function autoriser_queue_purger_dist($faire, $type, $id, $qui, $opt) { |
| 1711 | - return autoriser('webmestre'); |
|
| 1711 | + return autoriser('webmestre'); |
|
| 1712 | 1712 | } |
| 1713 | 1713 | |
| 1714 | 1714 | |
@@ -1726,11 +1726,11 @@ discard block |
||
| 1726 | 1726 | * @return bool true s'il a le droit, false sinon |
| 1727 | 1727 | **/ |
| 1728 | 1728 | function autoriser_echafauder_dist($faire, $type, $id, $qui, $opt) { |
| 1729 | - if (test_espace_prive()) { |
|
| 1730 | - return intval($qui['id_auteur']) ? true : false; |
|
| 1731 | - } else { |
|
| 1732 | - return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1733 | - } |
|
| 1729 | + if (test_espace_prive()) { |
|
| 1730 | + return intval($qui['id_auteur']) ? true : false; |
|
| 1731 | + } else { |
|
| 1732 | + return autoriser('webmestre', '', $id, $qui, $opt); |
|
| 1733 | + } |
|
| 1734 | 1734 | } |
| 1735 | 1735 | |
| 1736 | 1736 | |
@@ -1745,27 +1745,27 @@ discard block |
||
| 1745 | 1745 | * Identifiants d'auteurs |
| 1746 | 1746 | */ |
| 1747 | 1747 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1748 | - $objet = objet_type($objet); |
|
| 1749 | - $where = [ |
|
| 1750 | - 'objet=' . sql_quote($objet), |
|
| 1751 | - 'id_objet=' . intval($id_objet) |
|
| 1752 | - ]; |
|
| 1753 | - if (!empty($cond)) { |
|
| 1754 | - if (is_array($cond)) { |
|
| 1755 | - $where = array_merge($where, $cond); |
|
| 1756 | - } else { |
|
| 1757 | - $where[] = $cond; |
|
| 1758 | - } |
|
| 1759 | - } |
|
| 1760 | - $auteurs = sql_allfetsel( |
|
| 1761 | - 'id_auteur', |
|
| 1762 | - 'spip_auteurs_liens', |
|
| 1763 | - $where |
|
| 1764 | - ); |
|
| 1765 | - if (is_array($auteurs)) { |
|
| 1766 | - return array_column($auteurs, 'id_auteur'); |
|
| 1767 | - } |
|
| 1768 | - return []; |
|
| 1748 | + $objet = objet_type($objet); |
|
| 1749 | + $where = [ |
|
| 1750 | + 'objet=' . sql_quote($objet), |
|
| 1751 | + 'id_objet=' . intval($id_objet) |
|
| 1752 | + ]; |
|
| 1753 | + if (!empty($cond)) { |
|
| 1754 | + if (is_array($cond)) { |
|
| 1755 | + $where = array_merge($where, $cond); |
|
| 1756 | + } else { |
|
| 1757 | + $where[] = $cond; |
|
| 1758 | + } |
|
| 1759 | + } |
|
| 1760 | + $auteurs = sql_allfetsel( |
|
| 1761 | + 'id_auteur', |
|
| 1762 | + 'spip_auteurs_liens', |
|
| 1763 | + $where |
|
| 1764 | + ); |
|
| 1765 | + if (is_array($auteurs)) { |
|
| 1766 | + return array_column($auteurs, 'id_auteur'); |
|
| 1767 | + } |
|
| 1768 | + return []; |
|
| 1769 | 1769 | } |
| 1770 | 1770 | |
| 1771 | 1771 | /** |
@@ -1780,11 +1780,11 @@ discard block |
||
| 1780 | 1780 | * - false : serveur SQL indisponible |
| 1781 | 1781 | */ |
| 1782 | 1782 | function auteurs_article($id_article, $cond = '') { |
| 1783 | - return sql_allfetsel( |
|
| 1784 | - 'id_auteur', |
|
| 1785 | - 'spip_auteurs_liens', |
|
| 1786 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1787 | - ); |
|
| 1783 | + return sql_allfetsel( |
|
| 1784 | + 'id_auteur', |
|
| 1785 | + 'spip_auteurs_liens', |
|
| 1786 | + "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1787 | + ); |
|
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | 1790 | |
@@ -1798,7 +1798,7 @@ discard block |
||
| 1798 | 1798 | */ |
| 1799 | 1799 | function acces_restreint_rubrique($id_rubrique) { |
| 1800 | 1800 | |
| 1801 | - return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1801 | + return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique])); |
|
| 1802 | 1802 | } |
| 1803 | 1803 | |
| 1804 | 1804 | |
@@ -1811,12 +1811,12 @@ discard block |
||
| 1811 | 1811 | * @return bool true si un parent existe |
| 1812 | 1812 | */ |
| 1813 | 1813 | function verifier_table_non_vide($table = 'spip_rubriques') { |
| 1814 | - static $done = []; |
|
| 1815 | - if (!isset($done[$table])) { |
|
| 1816 | - $done[$table] = sql_countsel($table) > 0; |
|
| 1817 | - } |
|
| 1814 | + static $done = []; |
|
| 1815 | + if (!isset($done[$table])) { |
|
| 1816 | + $done[$table] = sql_countsel($table) > 0; |
|
| 1817 | + } |
|
| 1818 | 1818 | |
| 1819 | - return $done[$table]; |
|
| 1819 | + return $done[$table]; |
|
| 1820 | 1820 | } |
| 1821 | 1821 | |
| 1822 | 1822 | /** |
@@ -1841,15 +1841,15 @@ discard block |
||
| 1841 | 1841 | */ |
| 1842 | 1842 | function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt) { |
| 1843 | 1843 | |
| 1844 | - $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 1845 | - switch ($s) { |
|
| 1846 | - case 'info_redacteurs': |
|
| 1847 | - return ($GLOBALS['meta']['accepter_inscriptions'] == 'oui'); |
|
| 1848 | - case 'info_visiteurs': |
|
| 1849 | - return ($GLOBALS['meta']['accepter_visiteurs'] == 'oui' or $GLOBALS['meta']['forums_publics'] == 'abo'); |
|
| 1850 | - } |
|
| 1844 | + $s = array_search($quoi, $GLOBALS['liste_des_statuts']); |
|
| 1845 | + switch ($s) { |
|
| 1846 | + case 'info_redacteurs': |
|
| 1847 | + return ($GLOBALS['meta']['accepter_inscriptions'] == 'oui'); |
|
| 1848 | + case 'info_visiteurs': |
|
| 1849 | + return ($GLOBALS['meta']['accepter_visiteurs'] == 'oui' or $GLOBALS['meta']['forums_publics'] == 'abo'); |
|
| 1850 | + } |
|
| 1851 | 1851 | |
| 1852 | - return false; |
|
| 1852 | + return false; |
|
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | 1855 | /** |
@@ -1865,7 +1865,7 @@ discard block |
||
| 1865 | 1865 | * @return bool false |
| 1866 | 1866 | **/ |
| 1867 | 1867 | function autoriser_inscription_relancer_dist($faire, $type, $id, $qui, $opt) { |
| 1868 | - return $qui['statut'] == '0minirezo' and !$qui['restreint']; |
|
| 1868 | + return $qui['statut'] == '0minirezo' and !$qui['restreint']; |
|
| 1869 | 1869 | } |
| 1870 | 1870 | |
| 1871 | 1871 | /** |
@@ -1881,5 +1881,5 @@ discard block |
||
| 1881 | 1881 | * @return bool true s'il a le droit, false sinon |
| 1882 | 1882 | **/ |
| 1883 | 1883 | function autoriser_phpinfos_dist($faire, $type, $id, $qui, $opt) { |
| 1884 | - return autoriser('webmestre'); |
|
| 1884 | + return autoriser('webmestre'); |
|
| 1885 | 1885 | } |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | // mais apres la fonction autoriser() |
| 115 | 115 | if ($f = find_in_path('mes_fonctions.php')) { |
| 116 | 116 | global $dossier_squelettes; |
| 117 | - include_once(_ROOT_CWD . $f); |
|
| 117 | + include_once(_ROOT_CWD.$f); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : []; |
| 149 | 149 | $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui); |
| 150 | 150 | } elseif (is_numeric($qui)) { |
| 151 | - $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui); |
|
| 151 | + $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.$qui); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // Admins restreints, on construit ici (pas generique mais...) |
@@ -158,8 +158,8 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | spip_log( |
| 161 | - "autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ') ?', |
|
| 162 | - 'autoriser' . _LOG_DEBUG |
|
| 161 | + "autoriser $faire $type $id (".(isset($qui['nom']) ? $qui['nom'] : '').') ?', |
|
| 162 | + 'autoriser'._LOG_DEBUG |
|
| 163 | 163 | ); |
| 164 | 164 | |
| 165 | 165 | // passer par objet_type pour avoir les alias |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | (isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier')) |
| 172 | 172 | or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier')) |
| 173 | 173 | ) { |
| 174 | - spip_log("autoriser ($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG); |
|
| 174 | + spip_log("autoriser ($faire, $type, $id, ".(isset($qui['nom']) ? $qui['nom'] : '').') : OK Exception', 'autoriser'._LOG_DEBUG); |
|
| 175 | 175 | return true; |
| 176 | 176 | } |
| 177 | 177 | |
@@ -180,18 +180,18 @@ discard block |
||
| 180 | 180 | // autoriser_faire[_dist], autoriser_defaut[_dist] |
| 181 | 181 | $fonctions = $type |
| 182 | 182 | ? [ |
| 183 | - 'autoriser_' . $type . '_' . $faire, |
|
| 184 | - 'autoriser_' . $type . '_' . $faire . '_dist', |
|
| 185 | - 'autoriser_' . $type, |
|
| 186 | - 'autoriser_' . $type . '_dist', |
|
| 187 | - 'autoriser_' . $faire, |
|
| 188 | - 'autoriser_' . $faire . '_dist', |
|
| 183 | + 'autoriser_'.$type.'_'.$faire, |
|
| 184 | + 'autoriser_'.$type.'_'.$faire.'_dist', |
|
| 185 | + 'autoriser_'.$type, |
|
| 186 | + 'autoriser_'.$type.'_dist', |
|
| 187 | + 'autoriser_'.$faire, |
|
| 188 | + 'autoriser_'.$faire.'_dist', |
|
| 189 | 189 | 'autoriser_defaut', |
| 190 | 190 | 'autoriser_defaut_dist' |
| 191 | 191 | ] |
| 192 | 192 | : [ |
| 193 | - 'autoriser_' . $faire, |
|
| 194 | - 'autoriser_' . $faire . '_dist', |
|
| 193 | + 'autoriser_'.$faire, |
|
| 194 | + 'autoriser_'.$faire.'_dist', |
|
| 195 | 195 | 'autoriser_defaut', |
| 196 | 196 | 'autoriser_defaut_dist' |
| 197 | 197 | ]; |
@@ -204,8 +204,8 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | spip_log( |
| 207 | - "$f($faire, $type, $id, " . (isset($qui['nom']) ? $qui['nom'] : '') . ') : ' . ($a ? 'OK' : 'niet'), |
|
| 208 | - 'autoriser' . _LOG_DEBUG |
|
| 207 | + "$f($faire, $type, $id, ".(isset($qui['nom']) ? $qui['nom'] : '').') : '.($a ? 'OK' : 'niet'), |
|
| 208 | + 'autoriser'._LOG_DEBUG |
|
| 209 | 209 | ); |
| 210 | 210 | |
| 211 | 211 | return $a; |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | function autoriser_previsualiser_dist($faire, $type, $id, $qui, $opt) { |
| 334 | 334 | |
| 335 | 335 | // Le visiteur a-t-il un statut prevu par la config ? |
| 336 | - if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) { |
|
| 336 | + if (strpos($GLOBALS['meta']['preview'], ','.$qui['statut'].',') !== false) { |
|
| 337 | 337 | return test_previsualiser_objet_champ($type, $id, $qui, $opt); |
| 338 | 338 | } |
| 339 | 339 | |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | } // pas de champ passe a la demande => NIET |
| 391 | 391 | $previsu = explode(',', $c['previsu']); |
| 392 | 392 | // regarder si ce statut est autorise pour l'auteur |
| 393 | - if (in_array($opt[$champ] . '/auteur', $previsu)) { |
|
| 393 | + if (in_array($opt[$champ].'/auteur', $previsu)) { |
|
| 394 | 394 | // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement, |
| 395 | 395 | // sinon l’auteur en session |
| 396 | 396 | include_spip('inc/securiser_action'); |
@@ -404,12 +404,12 @@ discard block |
||
| 404 | 404 | |
| 405 | 405 | if (!$id_auteur) { |
| 406 | 406 | return false; |
| 407 | - } elseif (autoriser('previsualiser' . $opt[$champ], $type, '', $id_auteur)) { |
|
| 407 | + } elseif (autoriser('previsualiser'.$opt[$champ], $type, '', $id_auteur)) { |
|
| 408 | 408 | // dans ce cas (admin en general), pas de filtrage sur ce statut |
| 409 | 409 | } elseif ( |
| 410 | 410 | !sql_countsel( |
| 411 | 411 | 'spip_auteurs_liens', |
| 412 | - 'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id) |
|
| 412 | + 'id_auteur='.intval($id_auteur).' AND objet='.sql_quote($type).' AND id_objet='.intval($id) |
|
| 413 | 413 | ) |
| 414 | 414 | ) { |
| 415 | 415 | return false; |
@@ -452,16 +452,16 @@ discard block |
||
| 452 | 452 | // multilinguisme par secteur et objet rattaché à une rubrique |
| 453 | 453 | $primary = id_table_objet($type); |
| 454 | 454 | if ($table != 'spip_rubriques') { |
| 455 | - $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id)); |
|
| 455 | + $id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=".intval($id)); |
|
| 456 | 456 | } else { |
| 457 | 457 | $id_rubrique = $id; |
| 458 | 458 | } |
| 459 | - $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique)); |
|
| 459 | + $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique)); |
|
| 460 | 460 | if (!$id_secteur > 0) { |
| 461 | 461 | $id_secteur = $id_rubrique; |
| 462 | 462 | } |
| 463 | - $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur)); |
|
| 464 | - $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id)); |
|
| 463 | + $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_secteur)); |
|
| 464 | + $langue_objet = sql_getfetsel('lang', "$table", "$primary=".intval($id)); |
|
| 465 | 465 | if ($langue_secteur != $langue_objet) { |
| 466 | 466 | // configuration incohérente, on laisse l'utilisateur corriger la situation |
| 467 | 467 | return true; |
@@ -469,7 +469,7 @@ discard block |
||
| 469 | 469 | if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques |
| 470 | 470 | return false; |
| 471 | 471 | } else { |
| 472 | - $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id)); |
|
| 472 | + $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.intval($id)); |
|
| 473 | 473 | if ($id_parent != 0) { |
| 474 | 474 | // sous-rubriques : pas de choix de langue |
| 475 | 475 | return false; |
@@ -517,7 +517,7 @@ discard block |
||
| 517 | 517 | |
| 518 | 518 | if (!isset($opt['statut'])) { |
| 519 | 519 | if (isset($desc['field']['statut'])) { |
| 520 | - $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id)); |
|
| 520 | + $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type).'='.intval($id)); |
|
| 521 | 521 | } else { |
| 522 | 522 | $statut = 'publie'; |
| 523 | 523 | } // pas de statut => publie |
@@ -677,11 +677,11 @@ discard block |
||
| 677 | 677 | return false; |
| 678 | 678 | } |
| 679 | 679 | |
| 680 | - if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) { |
|
| 680 | + if (sql_countsel('spip_rubriques', 'id_parent='.intval($id))) { |
|
| 681 | 681 | return false; |
| 682 | 682 | } |
| 683 | 683 | |
| 684 | - if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) { |
|
| 684 | + if (sql_countsel('spip_articles', 'id_rubrique='.intval($id)." AND (statut<>'poubelle')")) { |
|
| 685 | 685 | return false; |
| 686 | 686 | } |
| 687 | 687 | |
@@ -713,7 +713,7 @@ discard block |
||
| 713 | 713 | * @return bool true s'il a le droit, false sinon |
| 714 | 714 | **/ |
| 715 | 715 | function autoriser_article_modifier_dist($faire, $type, $id, $qui, $opt) { |
| 716 | - $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id)); |
|
| 716 | + $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article='.sql_quote($id)); |
|
| 717 | 717 | |
| 718 | 718 | return |
| 719 | 719 | $r |
@@ -724,7 +724,7 @@ discard block |
||
| 724 | 724 | (!isset($opt['statut']) or $opt['statut'] !== 'publie') |
| 725 | 725 | and in_array($qui['statut'], ['0minirezo', '1comite']) |
| 726 | 726 | and in_array($r['statut'], ['prop', 'prepa', 'poubelle']) |
| 727 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']) |
|
| 727 | + and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur']) |
|
| 728 | 728 | ) |
| 729 | 729 | ); |
| 730 | 730 | } |
@@ -778,7 +778,7 @@ discard block |
||
| 778 | 778 | if (!$id) { |
| 779 | 779 | return false; |
| 780 | 780 | } |
| 781 | - $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id)); |
|
| 781 | + $statut = sql_getfetsel('statut', 'spip_articles', 'id_article='.intval($id)); |
|
| 782 | 782 | } |
| 783 | 783 | |
| 784 | 784 | return |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | or |
| 790 | 790 | ($id |
| 791 | 791 | and $qui['id_auteur'] |
| 792 | - and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])); |
|
| 792 | + and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur'])); |
|
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 | |
@@ -808,8 +808,8 @@ discard block |
||
| 808 | 808 | function autoriser_voir_dist($faire, $type, $id, $qui, $opt) { |
| 809 | 809 | # securite, mais on aurait pas du arriver ici ! |
| 810 | 810 | if ( |
| 811 | - function_exists($f = 'autoriser_' . $type . '_voir') |
|
| 812 | - or function_exists($f = 'autoriser_' . $type . '_voir_dist') |
|
| 811 | + function_exists($f = 'autoriser_'.$type.'_voir') |
|
| 812 | + or function_exists($f = 'autoriser_'.$type.'_voir_dist') |
|
| 813 | 813 | ) { |
| 814 | 814 | return $f($faire, $type, $id, $qui, $opt); |
| 815 | 815 | } |
@@ -929,7 +929,7 @@ discard block |
||
| 929 | 929 | $n = sql_fetsel( |
| 930 | 930 | 'A.id_article', |
| 931 | 931 | 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', |
| 932 | - "A.statut='publie' AND L.id_auteur=" . sql_quote($id) |
|
| 932 | + "A.statut='publie' AND L.id_auteur=".sql_quote($id) |
|
| 933 | 933 | ); |
| 934 | 934 | |
| 935 | 935 | return $n ? true : false; |
@@ -1131,7 +1131,7 @@ discard block |
||
| 1131 | 1131 | and $r = sql_allfetsel( |
| 1132 | 1132 | 'id_objet', |
| 1133 | 1133 | 'spip_auteurs_liens', |
| 1134 | - 'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0" |
|
| 1134 | + 'id_auteur='.intval($id_auteur)." AND objet='rubrique' AND id_objet!=0" |
|
| 1135 | 1135 | ) |
| 1136 | 1136 | and count($r) |
| 1137 | 1137 | ) { |
@@ -1747,8 +1747,8 @@ discard block |
||
| 1747 | 1747 | function auteurs_objet($objet, $id_objet, $cond = '') { |
| 1748 | 1748 | $objet = objet_type($objet); |
| 1749 | 1749 | $where = [ |
| 1750 | - 'objet=' . sql_quote($objet), |
|
| 1751 | - 'id_objet=' . intval($id_objet) |
|
| 1750 | + 'objet='.sql_quote($objet), |
|
| 1751 | + 'id_objet='.intval($id_objet) |
|
| 1752 | 1752 | ]; |
| 1753 | 1753 | if (!empty($cond)) { |
| 1754 | 1754 | if (is_array($cond)) { |
@@ -1783,7 +1783,7 @@ discard block |
||
| 1783 | 1783 | return sql_allfetsel( |
| 1784 | 1784 | 'id_auteur', |
| 1785 | 1785 | 'spip_auteurs_liens', |
| 1786 | - "objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '') |
|
| 1786 | + "objet='article' AND id_objet=".intval($id_article).($cond ? " AND $cond" : '') |
|
| 1787 | 1787 | ); |
| 1788 | 1788 | } |
| 1789 | 1789 | |
@@ -238,8 +238,7 @@ discard block |
||
| 238 | 238 | if ($id === '*') { |
| 239 | 239 | unset($GLOBALS['autoriser_exception'][$faire][$type]); |
| 240 | 240 | unset($autorisation[$faire][$type]); |
| 241 | - } |
|
| 242 | - else { |
|
| 241 | + } else { |
|
| 243 | 242 | unset($GLOBALS['autoriser_exception'][$faire][$type][$id]); |
| 244 | 243 | unset($autorisation[$faire][$type][$id]); |
| 245 | 244 | } |
@@ -598,8 +597,7 @@ discard block |
||
| 598 | 597 | function autoriser_rubrique_creer_dist($faire, $type, $id, $qui, $opt) { |
| 599 | 598 | if (!empty($opt['id_parent'])) { |
| 600 | 599 | return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui); |
| 601 | - } |
|
| 602 | - else { |
|
| 600 | + } else { |
|
| 603 | 601 | return autoriser('defaut', null, null, $qui, $opt); |
| 604 | 602 | } |
| 605 | 603 | } |
@@ -745,8 +743,7 @@ discard block |
||
| 745 | 743 | if (!empty($opt['id_parent'])) { |
| 746 | 744 | // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi |
| 747 | 745 | return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui); |
| 748 | - } |
|
| 749 | - else { |
|
| 746 | + } else { |
|
| 750 | 747 | return (sql_countsel('spip_rubriques') > 0 and in_array($qui['statut'], ['0minirezo', '1comite'])); |
| 751 | 748 | } |
| 752 | 749 | } |