Completed
Push — master ( c667cf...a3cb85 )
by cam
01:06
created
ecrire/balise/formulaire_admin.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  *     Pile complétée du code compilé
43 43
  **/
44 44
 function balise_FORMULAIRE_ADMIN($p) {
45
-	return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []);
45
+    return calculer_balise_dynamique($p, 'FORMULAIRE_ADMIN', []);
46 46
 }
47 47
 
48 48
 /**
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
  *   - chaîne vide sinon.
60 60
  */
61 61
 function balise_FORMULAIRE_ADMIN_stat($args, $context_compil) {
62
-	return $args;
62
+    return $args;
63 63
 }
64 64
 
65 65
 
@@ -84,66 +84,66 @@  discard block
 block discarded – undo
84 84
  **/
85 85
 function balise_FORMULAIRE_ADMIN_dyn($float = '', $debug = '') {
86 86
 
87
-	static $dejafait = false;
87
+    static $dejafait = false;
88 88
 
89
-	if (empty($_COOKIE['spip_admin'])) {
90
-		return '';
91
-	}
89
+    if (empty($_COOKIE['spip_admin'])) {
90
+        return '';
91
+    }
92 92
 
93
-	if (!is_array($debug)) {
94
-		if ($dejafait) {
95
-			return '';
96
-		}
97
-	} else {
98
-		if ($dejafait) {
99
-			if (empty($debug['sourcefile'])) {
100
-				return '';
101
-			}
102
-			foreach ($debug['sourcefile'] as $k => $v) {
103
-				if (strpos($v, 'administration.') !== false) {
104
-					if (isset($debug['resultat'][$k . 'tout'])) {
105
-						return $debug['resultat'][$k . 'tout'];
106
-					}
107
-				}
108
-			}
93
+    if (!is_array($debug)) {
94
+        if ($dejafait) {
95
+            return '';
96
+        }
97
+    } else {
98
+        if ($dejafait) {
99
+            if (empty($debug['sourcefile'])) {
100
+                return '';
101
+            }
102
+            foreach ($debug['sourcefile'] as $k => $v) {
103
+                if (strpos($v, 'administration.') !== false) {
104
+                    if (isset($debug['resultat'][$k . 'tout'])) {
105
+                        return $debug['resultat'][$k . 'tout'];
106
+                    }
107
+                }
108
+            }
109 109
 
110
-			return '';
111
-		}
112
-	}
110
+            return '';
111
+        }
112
+    }
113 113
 
114
-	include_spip('inc/autoriser');
115
-	include_spip('base/abstract_sql');
114
+    include_spip('inc/autoriser');
115
+    include_spip('base/abstract_sql');
116 116
 
117 117
 
118
-	$dejafait = true;
118
+    $dejafait = true;
119 119
 
120
-	// Preparer le #ENV des boutons
120
+    // Preparer le #ENV des boutons
121 121
 
122
-	$env = admin_objet();
122
+    $env = admin_objet();
123 123
 
124
-	// Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
125
-	if (!$env) {
126
-		$env['ecrire'] = _DIR_RESTREINT_ABS;
127
-	}
124
+    // Pas de "modifier ce..." ? -> donner "acces a l'espace prive"
125
+    if (!$env) {
126
+        $env['ecrire'] = _DIR_RESTREINT_ABS;
127
+    }
128 128
 
129
-	$env['divclass'] = $float;
130
-	$env['lang'] = admin_lang();
131
-	$env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
132
-	$env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug());
133
-	$env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider();
134
-	$env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : '');
129
+    $env['divclass'] = $float;
130
+    $env['lang'] = admin_lang();
131
+    $env['calcul'] = (_request('var_mode') ? 'recalcul' : 'calcul');
132
+    $env['debug'] = ((defined('_VAR_PREVIEW') and _VAR_PREVIEW) ? '' : admin_debug());
133
+    $env['analyser'] = (!$env['debug'] and !$GLOBALS['xhtml']) ? '' : admin_valider();
134
+    $env['inclure'] = ((defined('_VAR_INCLURE') and _VAR_INCLURE) ? 'inclure' : '');
135 135
 
136
-	if (empty($GLOBALS['use_cache'])) {
137
-		$env['use_cache'] = ' *';
138
-	}
136
+    if (empty($GLOBALS['use_cache'])) {
137
+        $env['use_cache'] = ' *';
138
+    }
139 139
 
140
-	if (isset($debug['validation'])) {
141
-		$env['xhtml_error'] = $debug['validation'];
142
-	}
140
+    if (isset($debug['validation'])) {
141
+        $env['xhtml_error'] = $debug['validation'];
142
+    }
143 143
 
144
-	$env['_pipelines']['formulaire_admin'] = [];
144
+    $env['_pipelines']['formulaire_admin'] = [];
145 145
 
146
-	return ['formulaires/administration', 0, $env];
146
+    return ['formulaires/administration', 0, $env];
147 147
 }
148 148
 
149 149
 
@@ -161,47 +161,47 @@  discard block
 block discarded – undo
161 161
  *     Tableau de l'environnement calculé
162 162
  **/
163 163
 function admin_objet() {
164
-	include_spip('inc/urls');
165
-	$env = [];
166
-
167
-	$trouver_table = charger_fonction('trouver_table', 'base');
168
-	$objets = urls_liste_objets(false);
169
-	$objets = array_diff($objets, ['rubrique']);
170
-	$objets = array_reverse($objets);
171
-	array_unshift($objets, 'rubrique');
172
-	foreach ($objets as $obj) {
173
-		$type = $obj;
174
-		if (
175
-			$type == objet_type($type, false)
176
-			and $_id_type = id_table_objet($type)
177
-			and isset($GLOBALS['contexte'][$_id_type])
178
-			and $id = $GLOBALS['contexte'][$_id_type]
179
-			and !is_array($id)
180
-			and $id = intval($id)
181
-			and $desc = $trouver_table(table_objet_sql($type))
182
-		) {
183
-			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
184
-			if ($id) {
185
-				$env[$_id_type] = $id;
186
-				$env['objet'] = $type;
187
-				$env['id_objet'] = $id;
188
-				$env['voir_' . $obj] =
189
-					str_replace('&', '&', generer_objet_url($id, $obj, '', '', false));
190
-				if (
191
-					isset($desc['field']['id_rubrique'])
192
-					and $type != 'rubrique'
193
-				) {
194
-					unset($env['id_rubrique']);
195
-					unset($env['voir_rubrique']);
196
-					if (admin_preview($type, $id, $desc)) {
197
-						$env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
198
-					}
199
-				}
200
-			}
201
-		}
202
-	}
203
-
204
-	return $env;
164
+    include_spip('inc/urls');
165
+    $env = [];
166
+
167
+    $trouver_table = charger_fonction('trouver_table', 'base');
168
+    $objets = urls_liste_objets(false);
169
+    $objets = array_diff($objets, ['rubrique']);
170
+    $objets = array_reverse($objets);
171
+    array_unshift($objets, 'rubrique');
172
+    foreach ($objets as $obj) {
173
+        $type = $obj;
174
+        if (
175
+            $type == objet_type($type, false)
176
+            and $_id_type = id_table_objet($type)
177
+            and isset($GLOBALS['contexte'][$_id_type])
178
+            and $id = $GLOBALS['contexte'][$_id_type]
179
+            and !is_array($id)
180
+            and $id = intval($id)
181
+            and $desc = $trouver_table(table_objet_sql($type))
182
+        ) {
183
+            $id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
184
+            if ($id) {
185
+                $env[$_id_type] = $id;
186
+                $env['objet'] = $type;
187
+                $env['id_objet'] = $id;
188
+                $env['voir_' . $obj] =
189
+                    str_replace('&', '&', generer_objet_url($id, $obj, '', '', false));
190
+                if (
191
+                    isset($desc['field']['id_rubrique'])
192
+                    and $type != 'rubrique'
193
+                ) {
194
+                    unset($env['id_rubrique']);
195
+                    unset($env['voir_rubrique']);
196
+                    if (admin_preview($type, $id, $desc)) {
197
+                        $env['preview'] = parametre_url(self(), 'var_mode', 'preview', '&');
198
+                    }
199
+                }
200
+            }
201
+        }
202
+    }
203
+
204
+    return $env;
205 205
 }
206 206
 
207 207
 
@@ -219,30 +219,30 @@  discard block
 block discarded – undo
219 219
  *     - Tableau d'un élément sinon.
220 220
  **/
221 221
 function admin_preview($type, $id, $desc = null) {
222
-	if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) {
223
-		return '';
224
-	}
225
-
226
-	if (!$desc) {
227
-		$trouver_table = charger_fonction('trouver_table', 'base');
228
-		$desc = $trouver_table(table_objet_sql($type));
229
-	}
230
-	if (!$desc or !isset($desc['field']['statut'])) {
231
-		return '';
232
-	}
233
-
234
-	include_spip('inc/autoriser');
235
-	if (!autoriser('previsualiser')) {
236
-		return '';
237
-	}
238
-
239
-	$notpub = sql_in('statut', ['prop', 'prive']);
240
-
241
-	if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
-		$notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
243
-	}
244
-
245
-	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
222
+    if (defined('_VAR_PREVIEW') and _VAR_PREVIEW) {
223
+        return '';
224
+    }
225
+
226
+    if (!$desc) {
227
+        $trouver_table = charger_fonction('trouver_table', 'base');
228
+        $desc = $trouver_table(table_objet_sql($type));
229
+    }
230
+    if (!$desc or !isset($desc['field']['statut'])) {
231
+        return '';
232
+    }
233
+
234
+    include_spip('inc/autoriser');
235
+    if (!autoriser('previsualiser')) {
236
+        return '';
237
+    }
238
+
239
+    $notpub = sql_in('statut', ['prop', 'prive']);
240
+
241
+    if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
+        $notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
243
+    }
244
+
245
+    return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
246 246
 }
247 247
 
248 248
 
@@ -253,25 +253,25 @@  discard block
 block discarded – undo
253 253
  *     Code de langue
254 254
  **/
255 255
 function admin_lang() {
256
-	$alang = '';
257
-	if (!empty($_COOKIE['spip_admin'])) {
258
-		$email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
-		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
260
-		if (!$alang) {
261
-			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
262
-		}
263
-	}
264
-	if (!$alang) {
265
-		return '';
266
-	}
267
-
268
-	$l = lang_select($alang);
269
-	$alang = $GLOBALS['spip_lang'];
270
-	if ($l) {
271
-		lang_select();
272
-	}
273
-
274
-	return $alang;
256
+    $alang = '';
257
+    if (!empty($_COOKIE['spip_admin'])) {
258
+        $email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
+        $alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
260
+        if (!$alang) {
261
+            $alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
262
+        }
263
+    }
264
+    if (!$alang) {
265
+        return '';
266
+    }
267
+
268
+    $l = lang_select($alang);
269
+    $alang = $GLOBALS['spip_lang'];
270
+    if ($l) {
271
+        lang_select();
272
+    }
273
+
274
+    return $alang;
275 275
 }
276 276
 
277 277
 /**
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
  **/
282 282
 function admin_valider() {
283 283
 
284
-	return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285
-		(parametre_url(self(), 'var_mode', 'debug', '&')
286
-			. '&var_mode_affiche=validation') :
287
-		('http://validator.w3.org/check?uri='
288
-			. rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
284
+    return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285
+        (parametre_url(self(), 'var_mode', 'debug', '&')
286
+            . '&var_mode_affiche=validation') :
287
+        ('http://validator.w3.org/check?uri='
288
+            . rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
289 289
 }
290 290
 
291 291
 /**
@@ -294,14 +294,14 @@  discard block
 block discarded – undo
294 294
  * @return string
295 295
  **/
296 296
 function admin_debug() {
297
-	return ((
298
-			(isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug'])
299
-			or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug'])
300
-			or (
301
-				defined('_VAR_MODE') and _VAR_MODE == 'debug'
302
-				and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug']
303
-			)
304
-		) and autoriser('debug')
305
-	)
306
-		? parametre_url(self(), 'var_mode', 'debug', '&') : '';
297
+    return ((
298
+            (isset($GLOBALS['forcer_debug']) and $GLOBALS['forcer_debug'])
299
+            or (isset($GLOBALS['bouton_admin_debug']) and $GLOBALS['bouton_admin_debug'])
300
+            or (
301
+                defined('_VAR_MODE') and _VAR_MODE == 'debug'
302
+                and isset($_COOKIE['spip_debug']) and $_COOKIE['spip_debug']
303
+            )
304
+        ) and autoriser('debug')
305
+    )
306
+        ? parametre_url(self(), 'var_mode', 'debug', '&') : '';
307 307
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -11 removed lines patch added patch discarded remove patch
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 			}
102 102
 			foreach ($debug['sourcefile'] as $k => $v) {
103 103
 				if (strpos($v, 'administration.') !== false) {
104
-					if (isset($debug['resultat'][$k . 'tout'])) {
105
-						return $debug['resultat'][$k . 'tout'];
104
+					if (isset($debug['resultat'][$k.'tout'])) {
105
+						return $debug['resultat'][$k.'tout'];
106 106
 					}
107 107
 				}
108 108
 			}
@@ -180,12 +180,12 @@  discard block
 block discarded – undo
180 180
 			and $id = intval($id)
181 181
 			and $desc = $trouver_table(table_objet_sql($type))
182 182
 		) {
183
-			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=" . intval($id));
183
+			$id = sql_getfetsel($_id_type, table_objet_sql($type), "$_id_type=".intval($id));
184 184
 			if ($id) {
185 185
 				$env[$_id_type] = $id;
186 186
 				$env['objet'] = $type;
187 187
 				$env['id_objet'] = $id;
188
-				$env['voir_' . $obj] =
188
+				$env['voir_'.$obj] =
189 189
 					str_replace('&', '&', generer_objet_url($id, $obj, '', '', false));
190 190
 				if (
191 191
 					isset($desc['field']['id_rubrique'])
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	$notpub = sql_in('statut', ['prop', 'prive']);
240 240
 
241 241
 	if ($type == 'article' and $GLOBALS['meta']['post_dates'] != 'oui') {
242
-		$notpub .= " OR (statut='publie' AND date>" . sql_quote(date('Y-m-d H:i:s')) . ')';
242
+		$notpub .= " OR (statut='publie' AND date>".sql_quote(date('Y-m-d H:i:s')).')';
243 243
 	}
244 244
 
245
-	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type) . '=' . $id . " AND ($notpub)");
245
+	return sql_fetsel('1', table_objet_sql($type), id_table_objet($type).'='.$id." AND ($notpub)");
246 246
 }
247 247
 
248 248
 
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	$alang = '';
257 257
 	if (!empty($_COOKIE['spip_admin'])) {
258 258
 		$email_or_login = preg_replace(',^@,', '', $_COOKIE['spip_admin']);
259
-		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email=' . sql_quote($email_or_login));
259
+		$alang = sql_getfetsel('lang', 'spip_auteurs', 'email='.sql_quote($email_or_login));
260 260
 		if (!$alang) {
261
-			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login=' . sql_quote($email_or_login));
261
+			$alang = sql_getfetsel('lang', 'spip_auteurs', 'login='.sql_quote($email_or_login));
262 262
 		}
263 263
 	}
264 264
 	if (!$alang) {
@@ -283,9 +283,8 @@  discard block
 block discarded – undo
283 283
 
284 284
 	return ((!isset($GLOBALS['xhtml']) or $GLOBALS['xhtml'] !== 'true') ?
285 285
 		(parametre_url(self(), 'var_mode', 'debug', '&')
286
-			. '&var_mode_affiche=validation') :
287
-		('http://validator.w3.org/check?uri='
288
-			. rawurlencode('http://' . $_SERVER['HTTP_HOST'] . nettoyer_uri())));
286
+			. '&var_mode_affiche=validation') : ('http://validator.w3.org/check?uri='
287
+			. rawurlencode('http://'.$_SERVER['HTTP_HOST'].nettoyer_uri())));
289 288
 }
290 289
 
291 290
 /**
Please login to merge, or discard this patch.
ecrire/balise/info_.php 2 patches
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -40,29 +40,29 @@  discard block
 block discarded – undo
40 40
  *     Pile complétée par le code à générer
41 41
  */
42 42
 function balise_INFO__dist($p) {
43
-	$info = $p->nom_champ;
44
-	$type_objet = interprete_argument_balise(1, $p);
45
-	$id_objet = interprete_argument_balise(2, $p);
46
-	if ($info === 'INFO_' or !$type_objet or !$id_objet) {
47
-		$msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']);
48
-		erreur_squelette($msg, $p);
49
-		$p->interdire_scripts = true;
43
+    $info = $p->nom_champ;
44
+    $type_objet = interprete_argument_balise(1, $p);
45
+    $id_objet = interprete_argument_balise(2, $p);
46
+    if ($info === 'INFO_' or !$type_objet or !$id_objet) {
47
+        $msg = _T('zbug_balise_sans_argument', ['balise' => ' INFO_']);
48
+        erreur_squelette($msg, $p);
49
+        $p->interdire_scripts = true;
50 50
 
51
-		return $p;
52
-	} else {
53
-		// Récupérer tous les params à la suite de objet et id_objet
54
-		$_params = '[';
55
-		$nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus
56
-		for ($i = 3; $i < $nb_params; $i++) {
57
-			$_params .= interprete_argument_balise($i, $p) . ',';
58
-		}
59
-		$_params .= ']';
51
+        return $p;
52
+    } else {
53
+        // Récupérer tous les params à la suite de objet et id_objet
54
+        $_params = '[';
55
+        $nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus
56
+        for ($i = 3; $i < $nb_params; $i++) {
57
+            $_params .= interprete_argument_balise($i, $p) . ',';
58
+        }
59
+        $_params .= ']';
60 60
 
61
-		$info_sql = strtolower(substr($info, 5));
62
-		$code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)";
63
-		$p->code = champ_sql($info, $p, $code);
64
-		$p->interdire_scripts = true;
61
+        $info_sql = strtolower(substr($info, 5));
62
+        $code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)";
63
+        $p->code = champ_sql($info, $p, $code);
64
+        $p->interdire_scripts = true;
65 65
 
66
-		return $p;
67
-	}
66
+        return $p;
67
+    }
68 68
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,12 +54,12 @@
 block discarded – undo
54 54
 		$_params = '[';
55 55
 		$nb_params = is_countable($p->param[0]) ? count($p->param[0]) : 0; // 1ère valeur vide donc 1 en plus
56 56
 		for ($i = 3; $i < $nb_params; $i++) {
57
-			$_params .= interprete_argument_balise($i, $p) . ',';
57
+			$_params .= interprete_argument_balise($i, $p).',';
58 58
 		}
59 59
 		$_params .= ']';
60 60
 
61 61
 		$info_sql = strtolower(substr($info, 5));
62
-		$code = "generer_objet_info($id_objet, $type_objet, '$info_sql', " . ($p->etoile ? _q($p->etoile) : "''") . ", $_params)";
62
+		$code = "generer_objet_info($id_objet, $type_objet, '$info_sql', ".($p->etoile ? _q($p->etoile) : "''").", $_params)";
63 63
 		$p->code = champ_sql($info, $p, $code);
64 64
 		$p->interdire_scripts = true;
65 65
 
Please login to merge, or discard this patch.
ecrire/urls/page.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 # attention toutefois seuls '' et '=' figurent dans les modes de compatibilite
24 24
 define('_separateur_urls_page', '');
25 25
 # on peut indiquer '' si on a installe le .htaccess
26
-define('_debut_urls_page', get_spip_script('./') . '?');
26
+define('_debut_urls_page', get_spip_script('./').'?');
27 27
 #######
28 28
 
29 29
 
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 		}
47 47
 	}
48 48
 
49
-	$url = \_debut_urls_page . $objet . \_separateur_urls_page
50
-		. $id . \_terminaison_urls_page;
49
+	$url = \_debut_urls_page.$objet.\_separateur_urls_page
50
+		. $id.\_terminaison_urls_page;
51 51
 
52 52
 	if ($args) {
53 53
 		$args = strpos($url, '?') ? "&$args" : "?$args";
54 54
 	}
55 55
 
56
-	return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
56
+	return _DIR_RACINE.$url.$args.($ancre ? "#$ancre" : '');
57 57
 }
58 58
 
59 59
 /**
Please login to merge, or discard this patch.
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 defined('URLS_PAGE_EXEMPLE') || define('URLS_PAGE_EXEMPLE', 'spip.php?article12');
@@ -37,23 +37,23 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function urls_page_generer_url_objet_dist(int $id, string $objet, string $args = '', string $ancre = ''): string {
39 39
 
40
-	if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) {
41
-		$url = $generer_url_externe($id, $args, $ancre);
42
-		// une url === null indique "je ne traite pas cette url, appliquez le calcul standard"
43
-		// une url vide est une url vide, ne rien faire de plus
44
-		if (!is_null($url)) {
45
-			return $url;
46
-		}
47
-	}
40
+    if ($generer_url_externe = charger_fonction_url($objet, 'defaut')) {
41
+        $url = $generer_url_externe($id, $args, $ancre);
42
+        // une url === null indique "je ne traite pas cette url, appliquez le calcul standard"
43
+        // une url vide est une url vide, ne rien faire de plus
44
+        if (!is_null($url)) {
45
+            return $url;
46
+        }
47
+    }
48 48
 
49
-	$url = \_debut_urls_page . $objet . \_separateur_urls_page
50
-		. $id . \_terminaison_urls_page;
49
+    $url = \_debut_urls_page . $objet . \_separateur_urls_page
50
+        . $id . \_terminaison_urls_page;
51 51
 
52
-	if ($args) {
53
-		$args = strpos($url, '?') ? "&$args" : "?$args";
54
-	}
52
+    if ($args) {
53
+        $args = strpos($url, '?') ? "&$args" : "?$args";
54
+    }
55 55
 
56
-	return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
56
+    return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : '');
57 57
 }
58 58
 
59 59
 /**
@@ -69,27 +69,27 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function urls_page_decoder_url_dist(string $url, string $entite, array $contexte = []): array {
71 71
 
72
-	// traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23
73
-	if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') {
74
-		return [[], '404'];
75
-	}
72
+    // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23
73
+    if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') {
74
+        return [[], '404'];
75
+    }
76 76
 
77
-	include_spip('inc/urls');
78
-	$r = nettoyer_url_page($url, $contexte);
79
-	if ($r) {
80
-		array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici
81
-		return $r;
82
-	}
77
+    include_spip('inc/urls');
78
+    $r = nettoyer_url_page($url, $contexte);
79
+    if ($r) {
80
+        array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici
81
+        return $r;
82
+    }
83 83
 
84
-	/*
84
+    /*
85 85
 	 * Le bloc qui suit sert a faciliter les transitions depuis
86 86
 	 * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html'
87 87
 	 * Il est inutile de le recopier si vous personnalisez vos URLs
88 88
 	 * et votre .htaccess
89 89
 	 */
90
-	// Si on est revenu en mode html, mais c'est une ancienne url_propre
91
-	// on ne redirige pas, on assume le nouveau contexte (si possible)
92
-	$url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? '';
93
-	return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte);
94
-	/* Fin du bloc compatibilite url-propres */
90
+    // Si on est revenu en mode html, mais c'est une ancienne url_propre
91
+    // on ne redirige pas, on assume le nouveau contexte (si possible)
92
+    $url_propre = $url ?? $_SERVER['REDIRECT_url_propre'] ?? $_ENV['url_propre'] ?? '';
93
+    return urls_transition_retrouver_anciennes_url_propres($url_propre, $entite, $contexte);
94
+    /* Fin du bloc compatibilite url-propres */
95 95
 }
Please login to merge, or discard this patch.
ecrire/action/menu_rubriques.php 2 patches
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/autoriser');
@@ -35,42 +35,42 @@  discard block
 block discarded – undo
35 35
  **/
36 36
 function action_menu_rubriques_dist() {
37 37
 
38
-	// si pas acces a ecrire, pas acces au menu
39
-	// on renvoi un 401 qui fait echouer la requete ajax silencieusement
40
-	if (!autoriser('ecrire')) {
41
-		$retour =
42
-		'<ul class="deroulant__sous-menu" data-profondeur="1">' .
43
-			'<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' .
44
-				'<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' .
45
-					'<span class="libelle">' . _T('public:lien_connecter') . '</span>' .
46
-				'</a>' .
47
-			'</li>' .
48
-		'</ul>';
49
-		include_spip('inc/actions');
50
-		ajax_retour($retour);
51
-		exit;
52
-	}
53
-
54
-	if ($date = intval(_request('date'))) {
55
-		header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT');
56
-	}
57
-
58
-	$r = gen_liste_rubriques();
59
-	if (
60
-		!$r
61
-		and isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
62
-		and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
63
-	) {
64
-		include_spip('inc/headers');
65
-		header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
66
-		http_response_code(304);
67
-		exit;
68
-	} else {
69
-		include_spip('inc/actions');
70
-		$ret = menu_rubriques();
71
-		ajax_retour($ret);
72
-		exit;
73
-	}
38
+    // si pas acces a ecrire, pas acces au menu
39
+    // on renvoi un 401 qui fait echouer la requete ajax silencieusement
40
+    if (!autoriser('ecrire')) {
41
+        $retour =
42
+        '<ul class="deroulant__sous-menu" data-profondeur="1">' .
43
+            '<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' .
44
+                '<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' .
45
+                    '<span class="libelle">' . _T('public:lien_connecter') . '</span>' .
46
+                '</a>' .
47
+            '</li>' .
48
+        '</ul>';
49
+        include_spip('inc/actions');
50
+        ajax_retour($retour);
51
+        exit;
52
+    }
53
+
54
+    if ($date = intval(_request('date'))) {
55
+        header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT');
56
+    }
57
+
58
+    $r = gen_liste_rubriques();
59
+    if (
60
+        !$r
61
+        and isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
62
+        and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
63
+    ) {
64
+        include_spip('inc/headers');
65
+        header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
66
+        http_response_code(304);
67
+        exit;
68
+    } else {
69
+        include_spip('inc/actions');
70
+        $ret = menu_rubriques();
71
+        ajax_retour($ret);
72
+        exit;
73
+    }
74 74
 }
75 75
 
76 76
 /**
@@ -84,44 +84,44 @@  discard block
 block discarded – undo
84 84
  *     Code HTML présentant la liste des rubriques
85 85
  **/
86 86
 function menu_rubriques($complet = true) {
87
-	$ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">'
88
-		. '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">'
89
-		. '<span class="libelle">' . _T('info_tout_site') . '</span>'
90
-		. '</a>'
91
-		. '</li>';
92
-
93
-	if (!$complet) {
94
-		return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
95
-	}
96
-
97
-	if (!isset($GLOBALS['db_art_cache'])) {
98
-		gen_liste_rubriques();
99
-	}
100
-	$arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
101
-
102
-	$total_lignes = $i = sizeof($arr_low);
103
-
104
-	if ($i > 0) {
105
-		$nb_col = min(8, ceil($total_lignes / 30));
106
-		if ($nb_col <= 1) {
107
-			$nb_col = ceil($total_lignes / 10);
108
-		}
109
-		foreach ($arr_low as $id_rubrique => $titre_rubrique) {
110
-			if (autoriser('voir', 'rubrique', $id_rubrique)) {
111
-				$ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
112
-				$i++;
113
-			}
114
-		}
115
-
116
-		$class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
117
-		$ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">"
118
-			. $ret
119
-			. "\n</ul>\n";
120
-	} else {
121
-		$ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
122
-	}
123
-
124
-	return $ret;
87
+    $ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">'
88
+        . '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">'
89
+        . '<span class="libelle">' . _T('info_tout_site') . '</span>'
90
+        . '</a>'
91
+        . '</li>';
92
+
93
+    if (!$complet) {
94
+        return "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
95
+    }
96
+
97
+    if (!isset($GLOBALS['db_art_cache'])) {
98
+        gen_liste_rubriques();
99
+    }
100
+    $arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
101
+
102
+    $total_lignes = $i = sizeof($arr_low);
103
+
104
+    if ($i > 0) {
105
+        $nb_col = min(8, ceil($total_lignes / 30));
106
+        if ($nb_col <= 1) {
107
+            $nb_col = ceil($total_lignes / 10);
108
+        }
109
+        foreach ($arr_low as $id_rubrique => $titre_rubrique) {
110
+            if (autoriser('voir', 'rubrique', $id_rubrique)) {
111
+                $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
112
+                $i++;
113
+            }
114
+        }
115
+
116
+        $class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
117
+        $ret = "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"1\">"
118
+            . $ret
119
+            . "\n</ul>\n";
120
+    } else {
121
+        $ret = "<ul class=\"deroulant__sous-menu\" data-profondeur=\"1\">$ret\n</ul>\n";
122
+    }
123
+
124
+    return $ret;
125 125
 }
126 126
 
127 127
 /**
@@ -142,48 +142,48 @@  discard block
 block discarded – undo
142 142
  *     Code HTML présentant la liste des rubriques
143 143
  **/
144 144
 function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal, $profondeur = 1) {
145
-	static $zmax = 6;
146
-	$profondeur_next = $profondeur + 1;
147
-
148
-	$nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">"
149
-		. '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>'
150
-		. "</a>\n";
151
-
152
-	// Limiter volontairement le nombre de sous-menus
153
-	if (!(--$zmax)) {
154
-		$zmax++;
155
-
156
-		return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
157
-	}
158
-
159
-	$arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
160
-	$i = sizeof($arr_rub);
161
-	if (!$i) {
162
-		$zmax++;
163
-
164
-		return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
165
-	}
166
-
167
-
168
-	$nb_col = 1;
169
-	if ($nb_rub = count($arr_rub)) {
170
-		$nb_col = min(10, max(1, ceil($nb_rub / 10)));
171
-	}
172
-	$class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
173
-	$ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">"
174
-	 . $nav
175
-	 . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">";
176
-	foreach ($arr_rub as $id_rub => $titre_rub) {
177
-		if (autoriser('voir', 'rubrique', $id_rub)) {
178
-			$titre = supprimer_numero(typo($titre_rub));
179
-			$ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next);
180
-			$i++;
181
-		}
182
-	}
183
-	$ret .= "</ul></li>\n";
184
-	$zmax++;
185
-
186
-	return $ret;
145
+    static $zmax = 6;
146
+    $profondeur_next = $profondeur + 1;
147
+
148
+    $nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">"
149
+        . '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>'
150
+        . "</a>\n";
151
+
152
+    // Limiter volontairement le nombre de sous-menus
153
+    if (!(--$zmax)) {
154
+        $zmax++;
155
+
156
+        return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
157
+    }
158
+
159
+    $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
160
+    $i = sizeof($arr_rub);
161
+    if (!$i) {
162
+        $zmax++;
163
+
164
+        return "\n<li class=\"deroulant__item\" data-profondeur=\"$profondeur\">$nav</li>";
165
+    }
166
+
167
+
168
+    $nb_col = 1;
169
+    if ($nb_rub = count($arr_rub)) {
170
+        $nb_col = min(10, max(1, ceil($nb_rub / 10)));
171
+    }
172
+    $class_cols = ($nb_col > 1 ? "cols-$nb_col" : '');
173
+    $ret = "<li class=\"deroulant__item deroulant__item_parent\" data-profondeur=\"$profondeur\">"
174
+        . $nav
175
+        . "<ul class=\"deroulant__sous-menu $class_cols\" data-profondeur=\"$profondeur_next\">";
176
+    foreach ($arr_rub as $id_rub => $titre_rub) {
177
+        if (autoriser('voir', 'rubrique', $id_rub)) {
178
+            $titre = supprimer_numero(typo($titre_rub));
179
+            $ret .= bandeau_rubrique($id_rub, $titre, $zdecal + $i, $profondeur_next);
180
+            $i++;
181
+        }
182
+    }
183
+    $ret .= "</ul></li>\n";
184
+    $zmax++;
185
+
186
+    return $ret;
187 187
 }
188 188
 
189 189
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
  *     Liste des rubriques enfants de la rubrique (et leur titre)
202 202
  **/
203 203
 function extraire_article($id_p, $t) {
204
-	return array_key_exists($id_p, $t) ? $t[$id_p] : [];
204
+    return array_key_exists($id_p, $t) ? $t[$id_p] : [];
205 205
 }
206 206
 
207 207
 /**
@@ -217,42 +217,42 @@  discard block
 block discarded – undo
217 217
  **/
218 218
 function gen_liste_rubriques() {
219 219
 
220
-	$cache = null;
221
-	include_spip('inc/config');
222
-	// ici, un petit fichier cache ne fait pas de mal
223
-	$last = lire_config('date_calcul_rubriques', 0);
224
-	if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
225
-		[$date, $GLOBALS['db_art_cache']] = @unserialize($cache);
226
-		if ($date == $last) {
227
-			return false;
228
-		} // c'etait en cache :-)
229
-	}
230
-	// se restreindre aux rubriques utilisees recemment +secteurs
231
-
232
-	$where = sql_in_select(
233
-		'id_rubrique',
234
-		'id_rubrique',
235
-		'spip_rubriques',
236
-		'',
237
-		'',
238
-		'id_parent=0 DESC, date DESC',
239
-		_CACHE_RUBRIQUES_MAX
240
-	);
241
-
242
-	// puis refaire la requete pour avoir l'ordre alphabetique
243
-
244
-	$res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre');
245
-
246
-	// il ne faut pas filtrer le autoriser voir ici
247
-	// car on met le resultat en cache, commun a tout le monde
248
-	$GLOBALS['db_art_cache'] = [];
249
-	while ($r = sql_fetch($res)) {
250
-		$t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
251
-		$GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
252
-	}
253
-
254
-	$t = [$last ?: time(), $GLOBALS['db_art_cache']];
255
-	ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
256
-
257
-	return true;
220
+    $cache = null;
221
+    include_spip('inc/config');
222
+    // ici, un petit fichier cache ne fait pas de mal
223
+    $last = lire_config('date_calcul_rubriques', 0);
224
+    if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
225
+        [$date, $GLOBALS['db_art_cache']] = @unserialize($cache);
226
+        if ($date == $last) {
227
+            return false;
228
+        } // c'etait en cache :-)
229
+    }
230
+    // se restreindre aux rubriques utilisees recemment +secteurs
231
+
232
+    $where = sql_in_select(
233
+        'id_rubrique',
234
+        'id_rubrique',
235
+        'spip_rubriques',
236
+        '',
237
+        '',
238
+        'id_parent=0 DESC, date DESC',
239
+        _CACHE_RUBRIQUES_MAX
240
+    );
241
+
242
+    // puis refaire la requete pour avoir l'ordre alphabetique
243
+
244
+    $res = sql_select('id_rubrique, titre, id_parent', 'spip_rubriques', $where, '', 'id_parent, 0+titre, titre');
245
+
246
+    // il ne faut pas filtrer le autoriser voir ici
247
+    // car on met le resultat en cache, commun a tout le monde
248
+    $GLOBALS['db_art_cache'] = [];
249
+    while ($r = sql_fetch($res)) {
250
+        $t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
251
+        $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
252
+    }
253
+
254
+    $t = [$last ?: time(), $GLOBALS['db_art_cache']];
255
+    ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
256
+
257
+    return true;
258 258
 }
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 	// on renvoi un 401 qui fait echouer la requete ajax silencieusement
40 40
 	if (!autoriser('ecrire')) {
41 41
 		$retour =
42
-		'<ul class="deroulant__sous-menu" data-profondeur="1">' .
43
-			'<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">' .
44
-				'<a class="deroulant__lien" href="' . generer_url_ecrire('accueil') . '" data-profondeur="1">' .
45
-					'<span class="libelle">' . _T('public:lien_connecter') . '</span>' .
46
-				'</a>' .
47
-			'</li>' .
42
+		'<ul class="deroulant__sous-menu" data-profondeur="1">'.
43
+			'<li class="deroulant__item deroulant__item_plan plan_site" data-profondeur="1">'.
44
+				'<a class="deroulant__lien" href="'.generer_url_ecrire('accueil').'" data-profondeur="1">'.
45
+					'<span class="libelle">'._T('public:lien_connecter').'</span>'.
46
+				'</a>'.
47
+			'</li>'.
48 48
 		'</ul>';
49 49
 		include_spip('inc/actions');
50 50
 		ajax_retour($retour);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	}
53 53
 
54 54
 	if ($date = intval(_request('date'))) {
55
-		header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $date) . ' GMT');
55
+		header('Last-Modified: '.gmdate('D, d M Y H:i:s', $date).' GMT');
56 56
 	}
57 57
 
58 58
 	$r = gen_liste_rubriques();
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 		and !strstr($_SERVER['SERVER_SOFTWARE'], 'IIS/')
63 63
 	) {
64 64
 		include_spip('inc/headers');
65
-		header('Content-Type: text/html; charset=' . $GLOBALS['meta']['charset']);
65
+		header('Content-Type: text/html; charset='.$GLOBALS['meta']['charset']);
66 66
 		http_response_code(304);
67 67
 		exit;
68 68
 	} else {
@@ -85,8 +85,8 @@  discard block
 block discarded – undo
85 85
  **/
86 86
 function menu_rubriques($complet = true) {
87 87
 	$ret = '<li class="deroulant__item deroulant__item_tout toutsite" data-profondeur="1">'
88
-		. '<a class="deroulant__lien" href="' . generer_url_ecrire('plan') . '" data-profondeur="1">'
89
-		. '<span class="libelle">' . _T('info_tout_site') . '</span>'
88
+		. '<a class="deroulant__lien" href="'.generer_url_ecrire('plan').'" data-profondeur="1">'
89
+		. '<span class="libelle">'._T('info_tout_site').'</span>'
90 90
 		. '</a>'
91 91
 		. '</li>';
92 92
 
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 	static $zmax = 6;
146 146
 	$profondeur_next = $profondeur + 1;
147 147
 
148
-	$nav = '<a class="deroulant__lien" href="' . generer_objet_url($id_rubrique, 'rubrique', '', '', false) . "\" data-profondeur=\"$profondeur\">"
149
-		. '<span class="libelle">' . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)) . '</span>'
148
+	$nav = '<a class="deroulant__lien" href="'.generer_objet_url($id_rubrique, 'rubrique', '', '', false)."\" data-profondeur=\"$profondeur\">"
149
+		. '<span class="libelle">'.supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique)).'</span>'
150 150
 		. "</a>\n";
151 151
 
152 152
 	// Limiter volontairement le nombre de sous-menus
Please login to merge, or discard this patch.
ecrire/action/redirect.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 /**
@@ -36,56 +36,56 @@  discard block
 block discarded – undo
36 36
  *   ```
37 37
  **/
38 38
 function action_redirect_dist() {
39
-	$type = _request('type');
40
-	$id = intval(_request('id'));
41
-	$page = false;
39
+    $type = _request('type');
40
+    $id = intval(_request('id'));
41
+    $page = false;
42 42
 
43
-	// verifier le type ou page transmis
44
-	if (!preg_match('/^\w+$/', $type)) {
45
-		$page = _request('page');
46
-		if (!preg_match('/^\w+$/', $page)) {
47
-			return;
48
-		}
49
-	}
43
+    // verifier le type ou page transmis
44
+    if (!preg_match('/^\w+$/', $type)) {
45
+        $page = _request('page');
46
+        if (!preg_match('/^\w+$/', $page)) {
47
+            return;
48
+        }
49
+    }
50 50
 
51
-	if ($var_mode = _request('var_mode')) {
52
-		// forcer la mise a jour de l'url de cet objet !
53
-		if (!defined('_VAR_URLS')) {
54
-			define('_VAR_URLS', true);
55
-		}
56
-	}
51
+    if ($var_mode = _request('var_mode')) {
52
+        // forcer la mise a jour de l'url de cet objet !
53
+        if (!defined('_VAR_URLS')) {
54
+            define('_VAR_URLS', true);
55
+        }
56
+    }
57 57
 
58
-	if ($page) {
59
-		$url = generer_url_public($page, '', true);
60
-	} else {
61
-		$url = calculer_url_redirect_entite($type, $id, $var_mode);
62
-	}
58
+    if ($page) {
59
+        $url = generer_url_public($page, '', true);
60
+    } else {
61
+        $url = calculer_url_redirect_entite($type, $id, $var_mode);
62
+    }
63 63
 
64
-	$status = '302';
65
-	if ($url) {
66
-		if ($var_mode) {
67
-			$url = parametre_url($url, 'var_mode', $var_mode, '&');
68
-		}
64
+    $status = '302';
65
+    if ($url) {
66
+        if ($var_mode) {
67
+            $url = parametre_url($url, 'var_mode', $var_mode, '&');
68
+        }
69 69
 
70
-		if (
71
-			$var_mode == 'preview'
72
-			and defined('_PREVIEW_TOKEN')
73
-			and _PREVIEW_TOKEN
74
-			and autoriser('previsualiser')
75
-		) {
76
-			include_spip('inc/securiser_action');
77
-			$token = calculer_token_previsu($url);
78
-			$url = parametre_url($url, 'var_previewtoken', $token);
79
-		}
70
+        if (
71
+            $var_mode == 'preview'
72
+            and defined('_PREVIEW_TOKEN')
73
+            and _PREVIEW_TOKEN
74
+            and autoriser('previsualiser')
75
+        ) {
76
+            include_spip('inc/securiser_action');
77
+            $token = calculer_token_previsu($url);
78
+            $url = parametre_url($url, 'var_previewtoken', $token);
79
+        }
80 80
 
81
-		if (_request('status') and _request('status') == '301') {
82
-			$status = '301';
83
-		}
84
-	} else {
85
-		$url = generer_url_public('404', '', true);
86
-	}
81
+        if (_request('status') and _request('status') == '301') {
82
+            $status = '301';
83
+        }
84
+    } else {
85
+        $url = generer_url_public('404', '', true);
86
+    }
87 87
 
88
-	redirige_par_entete(str_replace('&amp;', '&', $url), '', $status);
88
+    redirige_par_entete(str_replace('&amp;', '&', $url), '', $status);
89 89
 }
90 90
 
91 91
 /**
@@ -100,35 +100,35 @@  discard block
 block discarded – undo
100 100
  * @return string|null
101 101
  */
102 102
 function calculer_url_redirect_entite($type, $id, $var_mode) {
103
-	$desc = null;
104
-	$publie = null;
105
-	$url = null;
106
-	// invalider le cache à chaque modif en bdd
107
-	$date = 0;
108
-	if (isset($GLOBALS['meta']['derniere_modif'])) {
109
-		$date = $GLOBALS['meta']['derniere_modif'];
110
-	}
111
-	$key = "url-$date-$type-$id";
103
+    $desc = null;
104
+    $publie = null;
105
+    $url = null;
106
+    // invalider le cache à chaque modif en bdd
107
+    $date = 0;
108
+    if (isset($GLOBALS['meta']['derniere_modif'])) {
109
+        $date = $GLOBALS['meta']['derniere_modif'];
110
+    }
111
+    $key = "url-$date-$type-$id";
112 112
 
113
-	// Obtenir l’url et si elle est publié du cache memoization
114
-	if (function_exists('cache_get') and $desc = cache_get($key)) {
115
-		[$url, $publie] = $desc;
116
-	}
117
-	// Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie
118
-	if (empty($desc) or $var_mode) {
119
-		$publie = objet_test_si_publie($type, $id);
120
-		$url = generer_objet_url_absolue($id, $type, '', '', true);
121
-		if (function_exists('cache_set')) {
122
-			cache_set($key, [$url, $publie], 3600);
123
-		}
124
-	}
113
+    // Obtenir l’url et si elle est publié du cache memoization
114
+    if (function_exists('cache_get') and $desc = cache_get($key)) {
115
+        [$url, $publie] = $desc;
116
+    }
117
+    // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie
118
+    if (empty($desc) or $var_mode) {
119
+        $publie = objet_test_si_publie($type, $id);
120
+        $url = generer_objet_url_absolue($id, $type, '', '', true);
121
+        if (function_exists('cache_set')) {
122
+            cache_set($key, [$url, $publie], 3600);
123
+        }
124
+    }
125 125
 
126
-	// On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation
127
-	if ($publie) {
128
-		return $url;
129
-	} elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) {
130
-		return $url;
131
-	}
126
+    // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation
127
+    if ($publie) {
128
+        return $url;
129
+    } elseif (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id)) {
130
+        return $url;
131
+    }
132 132
 
133
-	return;
133
+    return;
134 134
 }
Please login to merge, or discard this patch.
ecrire/inc/urls.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
 	) {
204 204
 		$r = nettoyer_url_page($url, $contexte);
205 205
 		if ($r) {
206
-			[$contexte, $type, , , $suite] = $r;
206
+			[$contexte, $type,,, $suite] = $r;
207 207
 			$_id = id_table_objet($type);
208 208
 			$id_objet = $contexte[$_id];
209 209
 			$url_propre = generer_objet_url($id_objet, $type);
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
  */
275 275
 function nettoyer_url_page($url, $contexte = []) {
276 276
 	$url_objets = urls_liste_objets();
277
-	$raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,';
278
-	$raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,';
279
-	$raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,';
277
+	$raccourci_url_page_html = ',^(?:[^?]*/)?('.$url_objets.')([0-9]+)(?:\.html)?([?&].*)?$,';
278
+	$raccourci_url_page_id = ',^(?:[^?]*/)?('.$url_objets.')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,';
279
+	$raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?]('.$url_objets.')([0-9]+)=?(&.*)?$,';
280 280
 
281 281
 	if (
282 282
 		preg_match($raccourci_url_page_html, $url, $regs)
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 	$id = intval($id);
315 315
 	if (!isset($furls[$objet])) {
316 316
 		if (
317
-			function_exists($f = 'generer_' . $objet . '_url_ecrire')
317
+			function_exists($f = 'generer_'.$objet.'_url_ecrire')
318 318
 			// ou definie par un plugin
319 319
 			or $f = charger_fonction($f, 'urls', true)
320 320
 			// deprecated
321
-			or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true)
321
+			or function_exists($f = 'generer_url_ecrire_'.$objet) or $f = charger_fonction($f, 'urls', true)
322 322
 		) {
323 323
 			$furls[$objet] = $f;
324 324
 		} else {
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
 	if ($public or $connect) {
337 337
 		return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect);
338 338
 	}
339
-	$a = id_table_objet($objet) . '=' . intval($id);
339
+	$a = id_table_objet($objet).'='.intval($id);
340 340
 	if (!function_exists('objet_info')) {
341 341
 		include_spip('inc/filtres');
342 342
 	}
343 343
 
344
-	return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : '');
344
+	return generer_url_ecrire(objet_info($objet, 'url_voir'), $a.($args ? "&$args" : '')).($ancre ? "#$ancre" : '');
345 345
 }
346 346
 
347 347
 /**
Please login to merge, or discard this patch.
Indentation   +205 added lines, -205 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 include_spip('base/objets');
23 23
 
@@ -57,106 +57,106 @@  discard block
 block discarded – undo
57 57
  *
58 58
  */
59 59
 function urls_decoder_url($url, $fond = '', $contexte = [], $assembler = false) {
60
-	static $current_base = null;
60
+    static $current_base = null;
61 61
 
62
-	// les anciennes fonctions modifient directement les globales
63
-	// on les sauve avant l'appel, et on les retablit apres !
64
-	$save = [
65
-		$GLOBALS['fond'] ?? null,
66
-		$GLOBALS['contexte'] ?? null,
67
-		$_SERVER['REDIRECT_url_propre'] ?? null,
68
-		$_ENV['url_propre'] ?? null,
69
-		$GLOBALS['profondeur_url']
70
-	];
62
+    // les anciennes fonctions modifient directement les globales
63
+    // on les sauve avant l'appel, et on les retablit apres !
64
+    $save = [
65
+        $GLOBALS['fond'] ?? null,
66
+        $GLOBALS['contexte'] ?? null,
67
+        $_SERVER['REDIRECT_url_propre'] ?? null,
68
+        $_ENV['url_propre'] ?? null,
69
+        $GLOBALS['profondeur_url']
70
+    ];
71 71
 
72
-	if (is_null($current_base)) {
73
-		include_spip('inc/filtres_mini');
74
-		// le decodage des urls se fait toujours par rapport au site public
75
-		$current_base = url_absolue(_DIR_RACINE ?: './');
76
-	}
77
-	if (strncmp($url, $current_base, strlen($current_base)) == 0) {
78
-		$url = substr($url, strlen($current_base));
79
-	}
72
+    if (is_null($current_base)) {
73
+        include_spip('inc/filtres_mini');
74
+        // le decodage des urls se fait toujours par rapport au site public
75
+        $current_base = url_absolue(_DIR_RACINE ?: './');
76
+    }
77
+    if (strncmp($url, $current_base, strlen($current_base)) == 0) {
78
+        $url = substr($url, strlen($current_base));
79
+    }
80 80
 
81
-	// si on est en train d'assembler la page principale,
82
-	// recuperer l'url depuis les globales url propres si fournies
83
-	// sinon extraire la bonne portion d'url
84
-	if ($assembler) {
85
-		if (isset($_SERVER['REDIRECT_url_propre'])) {
86
-			$url = $_SERVER['REDIRECT_url_propre'];
87
-		} elseif (isset($_ENV['url_propre'])) {
88
-			$url = $_ENV['url_propre'];
89
-		} else {
90
-			$qs = explode('?', $url);
91
-			// ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee
92
-			$url = ltrim($qs[0], '/');
93
-			$url = explode('/', $url);
94
-			while (count($url) > $GLOBALS['profondeur_url'] + 1) {
95
-				array_shift($url);
96
-			}
97
-			$qs[0] = implode('/', $url);
98
-			$url = implode('?', $qs);
99
-		}
100
-	}
81
+    // si on est en train d'assembler la page principale,
82
+    // recuperer l'url depuis les globales url propres si fournies
83
+    // sinon extraire la bonne portion d'url
84
+    if ($assembler) {
85
+        if (isset($_SERVER['REDIRECT_url_propre'])) {
86
+            $url = $_SERVER['REDIRECT_url_propre'];
87
+        } elseif (isset($_ENV['url_propre'])) {
88
+            $url = $_ENV['url_propre'];
89
+        } else {
90
+            $qs = explode('?', $url);
91
+            // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee
92
+            $url = ltrim($qs[0], '/');
93
+            $url = explode('/', $url);
94
+            while (count($url) > $GLOBALS['profondeur_url'] + 1) {
95
+                array_shift($url);
96
+            }
97
+            $qs[0] = implode('/', $url);
98
+            $url = implode('?', $qs);
99
+        }
100
+    }
101 101
 
102
-	unset($_SERVER['REDIRECT_url_propre']);
103
-	unset($_ENV['url_propre']);
104
-	include_spip('inc/filtres_mini');
105
-	if (strpos($url, '://') === false) {
106
-		$GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/');
107
-	} else {
108
-		$GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/'));
109
-	}
102
+    unset($_SERVER['REDIRECT_url_propre']);
103
+    unset($_ENV['url_propre']);
104
+    include_spip('inc/filtres_mini');
105
+    if (strpos($url, '://') === false) {
106
+        $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/');
107
+    } else {
108
+        $GLOBALS['profondeur_url'] = max(0, substr_count($url, '/') - substr_count($current_base, '/'));
109
+    }
110 110
 
111
-	$url_redirect = '';
112
-	$decoder = charger_fonction_url('decoder');
113
-	if ($decoder) {
114
-		$a = $decoder($url, $fond, $contexte);
115
-		if (is_array($a)) {
116
-			[$ncontexte, $type, $url_redirect, $nfond] = array_pad($a, 4, null);
117
-			$url_redirect ??= '';
118
-			if ($url_redirect === $url) {
119
-				$url_redirect = '';
120
-			} // securite pour eviter une redirection infinie
121
-			if ($assembler and strlen($url_redirect)) {
122
-				spip_log("Redirige $url vers $url_redirect");
123
-				include_spip('inc/headers');
124
-				redirige_par_entete($url_redirect, '', 301);
125
-			}
126
-			if (isset($nfond)) {
127
-				$fond = $nfond;
128
-			} else {
129
-				if (
130
-					$fond == ''
131
-					or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */
132
-				) {
133
-					$fond = $type;
134
-				}
135
-			}
136
-			if (isset($ncontexte)) {
137
-				$contexte = $ncontexte;
138
-			}
139
-			if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
140
-				$contexte['type'] = $type;
141
-			}
142
-			if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
143
-				$contexte['type-page'] = $type;
144
-			}
145
-		}
146
-	}
111
+    $url_redirect = '';
112
+    $decoder = charger_fonction_url('decoder');
113
+    if ($decoder) {
114
+        $a = $decoder($url, $fond, $contexte);
115
+        if (is_array($a)) {
116
+            [$ncontexte, $type, $url_redirect, $nfond] = array_pad($a, 4, null);
117
+            $url_redirect ??= '';
118
+            if ($url_redirect === $url) {
119
+                $url_redirect = '';
120
+            } // securite pour eviter une redirection infinie
121
+            if ($assembler and strlen($url_redirect)) {
122
+                spip_log("Redirige $url vers $url_redirect");
123
+                include_spip('inc/headers');
124
+                redirige_par_entete($url_redirect, '', 301);
125
+            }
126
+            if (isset($nfond)) {
127
+                $fond = $nfond;
128
+            } else {
129
+                if (
130
+                    $fond == ''
131
+                    or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */
132
+                ) {
133
+                    $fond = $type;
134
+                }
135
+            }
136
+            if (isset($ncontexte)) {
137
+                $contexte = $ncontexte;
138
+            }
139
+            if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
140
+                $contexte['type'] = $type;
141
+            }
142
+            if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
143
+                $contexte['type-page'] = $type;
144
+            }
145
+        }
146
+    }
147 147
 
148
-	// retablir les globales
149
-	[$GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']] = $save;
148
+    // retablir les globales
149
+    [$GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']] = $save;
150 150
 
151
-	// vider les globales url propres qui ne doivent plus etre utilisees en cas
152
-	// d'inversion url => objet
153
-	// maintenir pour compat ?
154
-	#if ($assembler) {
155
-	#	unset($_SERVER['REDIRECT_url_propre']);
156
-	#	unset($_ENV['url_propre']);
157
-	#}
151
+    // vider les globales url propres qui ne doivent plus etre utilisees en cas
152
+    // d'inversion url => objet
153
+    // maintenir pour compat ?
154
+    #if ($assembler) {
155
+    #	unset($_SERVER['REDIRECT_url_propre']);
156
+    #	unset($_ENV['url_propre']);
157
+    #}
158 158
 
159
-	return [$fond, $contexte, $url_redirect];
159
+    return [$fond, $contexte, $url_redirect];
160 160
 }
161 161
 
162 162
 /**
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
  * @return array|false|string
170 170
  */
171 171
 function urls_transition_retrouver_anciennes_url_propres(string $url_propre, string $entite, array $contexte = []): array {
172
-	if ($url_propre) {
173
-		if ($GLOBALS['profondeur_url'] <= 0) {
174
-			$urls_anciennes = charger_fonction_url('decoder', 'propres');
175
-		} else {
176
-			$urls_anciennes = charger_fonction_url('decoder', 'arbo');
177
-		}
172
+    if ($url_propre) {
173
+        if ($GLOBALS['profondeur_url'] <= 0) {
174
+            $urls_anciennes = charger_fonction_url('decoder', 'propres');
175
+        } else {
176
+            $urls_anciennes = charger_fonction_url('decoder', 'arbo');
177
+        }
178 178
 
179
-		if ($urls_anciennes) {
180
-			$urls_anciennes = $urls_anciennes($url_propre, $entite, $contexte);
181
-		}
182
-		return $urls_anciennes ?: [];
183
-	}
179
+        if ($urls_anciennes) {
180
+            $urls_anciennes = $urls_anciennes($url_propre, $entite, $contexte);
181
+        }
182
+        return $urls_anciennes ?: [];
183
+    }
184 184
 
185
-	return [];
185
+    return [];
186 186
 }
187 187
 
188 188
 /**
@@ -195,41 +195,41 @@  discard block
 block discarded – undo
195 195
  * @return array|false|string
196 196
  */
197 197
 function urls_transition_retrouver_anciennes_url_html(string $url, string $entite, array $contexte = []): array {
198
-	// Migration depuis anciennes URLs ?
199
-	// traiter les injections domain.tld/spip.php/n/importe/quoi/rubrique23
200
-	if (
201
-		$url
202
-		and $GLOBALS['profondeur_url'] <= 0
203
-	) {
204
-		$r = nettoyer_url_page($url, $contexte);
205
-		if ($r) {
206
-			[$contexte, $type, , , $suite] = $r;
207
-			$_id = id_table_objet($type);
208
-			$id_objet = $contexte[$_id];
209
-			$url_propre = generer_objet_url($id_objet, $type);
210
-			if (
211
-				strlen($url_propre)
212
-				and !strstr($url, (string) $url_propre)
213
-				and (
214
-					objet_test_si_publie($type, $id_objet)
215
-					or (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id_objet))
216
-				)
217
-			) {
218
-				[, $hash] = array_pad(explode('#', $url_propre), 2, '');
219
-				$args = [];
220
-				foreach (array_filter(explode('&', $suite)) as $fragment) {
221
-					if ($fragment != "$_id=$id_objet") {
222
-						$args[] = $fragment;
223
-					}
224
-				}
225
-				$url_redirect = generer_objet_url($id_objet, $type, join('&', array_filter($args)), $hash);
198
+    // Migration depuis anciennes URLs ?
199
+    // traiter les injections domain.tld/spip.php/n/importe/quoi/rubrique23
200
+    if (
201
+        $url
202
+        and $GLOBALS['profondeur_url'] <= 0
203
+    ) {
204
+        $r = nettoyer_url_page($url, $contexte);
205
+        if ($r) {
206
+            [$contexte, $type, , , $suite] = $r;
207
+            $_id = id_table_objet($type);
208
+            $id_objet = $contexte[$_id];
209
+            $url_propre = generer_objet_url($id_objet, $type);
210
+            if (
211
+                strlen($url_propre)
212
+                and !strstr($url, (string) $url_propre)
213
+                and (
214
+                    objet_test_si_publie($type, $id_objet)
215
+                    or (defined('_VAR_PREVIEW') and _VAR_PREVIEW and autoriser('voir', $type, $id_objet))
216
+                )
217
+            ) {
218
+                [, $hash] = array_pad(explode('#', $url_propre), 2, '');
219
+                $args = [];
220
+                foreach (array_filter(explode('&', $suite)) as $fragment) {
221
+                    if ($fragment != "$_id=$id_objet") {
222
+                        $args[] = $fragment;
223
+                    }
224
+                }
225
+                $url_redirect = generer_objet_url($id_objet, $type, join('&', array_filter($args)), $hash);
226 226
 
227
-				return [$contexte, $type, $url_redirect, $type];
228
-			}
229
-		}
230
-	}
231
-	/* Fin compatibilite anciennes urls */
232
-	return [];
227
+                return [$contexte, $type, $url_redirect, $type];
228
+            }
229
+        }
230
+    }
231
+    /* Fin compatibilite anciennes urls */
232
+    return [];
233 233
 }
234 234
 
235 235
 /**
@@ -242,24 +242,24 @@  discard block
 block discarded – undo
242 242
  * @return string|array
243 243
  */
244 244
 function urls_liste_objets($preg = true) {
245
-	static $url_objets = null;
246
-	if (is_null($url_objets)) {
247
-		$url_objets = [];
248
-		// recuperer les tables_objets_sql declarees
249
-		$tables_objets = lister_tables_objets_sql();
250
-		foreach ($tables_objets as $t => $infos) {
251
-			if ($infos['page']) {
252
-				$url_objets[] = $infos['type'];
253
-				$url_objets = array_merge($url_objets, $infos['type_surnoms']);
254
-			}
255
-		}
256
-		$url_objets = pipeline('declarer_url_objets', $url_objets);
257
-	}
258
-	if (!$preg) {
259
-		return $url_objets;
260
-	}
245
+    static $url_objets = null;
246
+    if (is_null($url_objets)) {
247
+        $url_objets = [];
248
+        // recuperer les tables_objets_sql declarees
249
+        $tables_objets = lister_tables_objets_sql();
250
+        foreach ($tables_objets as $t => $infos) {
251
+            if ($infos['page']) {
252
+                $url_objets[] = $infos['type'];
253
+                $url_objets = array_merge($url_objets, $infos['type_surnoms']);
254
+            }
255
+        }
256
+        $url_objets = pipeline('declarer_url_objets', $url_objets);
257
+    }
258
+    if (!$preg) {
259
+        return $url_objets;
260
+    }
261 261
 
262
-	return implode('|', array_map('preg_quote', $url_objets));
262
+    return implode('|', array_map('preg_quote', $url_objets));
263 263
 }
264 264
 
265 265
 /**
@@ -273,26 +273,26 @@  discard block
 block discarded – undo
273 273
  * @return array
274 274
  */
275 275
 function nettoyer_url_page($url, $contexte = []) {
276
-	$url_objets = urls_liste_objets();
277
-	$raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,';
278
-	$raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,';
279
-	$raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,';
276
+    $url_objets = urls_liste_objets();
277
+    $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,';
278
+    $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,';
279
+    $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,';
280 280
 
281
-	if (
282
-		preg_match($raccourci_url_page_html, $url, $regs)
283
-		or preg_match($raccourci_url_page_id, $url, $regs)
284
-		or preg_match($raccourci_url_page_spip, $url, $regs)
285
-	) {
286
-		$regs = array_pad($regs, 4, null);
287
-		$type = objet_type($regs[1]);
288
-		$_id = id_table_objet($type);
289
-		$contexte[$_id] = $regs[2];
290
-		$suite = $regs[3];
281
+    if (
282
+        preg_match($raccourci_url_page_html, $url, $regs)
283
+        or preg_match($raccourci_url_page_id, $url, $regs)
284
+        or preg_match($raccourci_url_page_spip, $url, $regs)
285
+    ) {
286
+        $regs = array_pad($regs, 4, null);
287
+        $type = objet_type($regs[1]);
288
+        $_id = id_table_objet($type);
289
+        $contexte[$_id] = $regs[2];
290
+        $suite = $regs[3];
291 291
 
292
-		return [$contexte, $type, null, $type, $suite];
293
-	}
292
+        return [$contexte, $type, null, $type, $suite];
293
+    }
294 294
 
295
-	return [];
295
+    return [];
296 296
 }
297 297
 
298 298
 /**
@@ -310,38 +310,38 @@  discard block
 block discarded – undo
310 310
  * @return string
311 311
  */
312 312
 function generer_objet_url_ecrire($id, string $objet, string $args = '', string $ancre = '', ?bool $public = null, string $connect = ''): string {
313
-	static $furls = [];
314
-	$id = intval($id);
315
-	if (!isset($furls[$objet])) {
316
-		if (
317
-			function_exists($f = 'generer_' . $objet . '_url_ecrire')
318
-			// ou definie par un plugin
319
-			or $f = charger_fonction($f, 'urls', true)
320
-			// deprecated
321
-			or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true)
322
-		) {
323
-			$furls[$objet] = $f;
324
-		} else {
325
-			$furls[$objet] = '';
326
-		}
327
-	}
328
-	if ($furls[$objet]) {
329
-		return $furls[$objet]($id, $args, $ancre, $public, $connect);
330
-	}
331
-	// si pas de flag public fourni
332
-	// le calculer en fonction de la declaration de statut
333
-	if (is_null($public) and !$connect) {
334
-		$public = objet_test_si_publie($objet, $id, $connect);
335
-	}
336
-	if ($public or $connect) {
337
-		return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect);
338
-	}
339
-	$a = id_table_objet($objet) . '=' . intval($id);
340
-	if (!function_exists('objet_info')) {
341
-		include_spip('inc/filtres');
342
-	}
313
+    static $furls = [];
314
+    $id = intval($id);
315
+    if (!isset($furls[$objet])) {
316
+        if (
317
+            function_exists($f = 'generer_' . $objet . '_url_ecrire')
318
+            // ou definie par un plugin
319
+            or $f = charger_fonction($f, 'urls', true)
320
+            // deprecated
321
+            or function_exists($f = 'generer_url_ecrire_' . $objet) or $f = charger_fonction($f, 'urls', true)
322
+        ) {
323
+            $furls[$objet] = $f;
324
+        } else {
325
+            $furls[$objet] = '';
326
+        }
327
+    }
328
+    if ($furls[$objet]) {
329
+        return $furls[$objet]($id, $args, $ancre, $public, $connect);
330
+    }
331
+    // si pas de flag public fourni
332
+    // le calculer en fonction de la declaration de statut
333
+    if (is_null($public) and !$connect) {
334
+        $public = objet_test_si_publie($objet, $id, $connect);
335
+    }
336
+    if ($public or $connect) {
337
+        return generer_objet_url_absolue($id, $objet, $args, $ancre, $public, '', $connect);
338
+    }
339
+    $a = id_table_objet($objet) . '=' . intval($id);
340
+    if (!function_exists('objet_info')) {
341
+        include_spip('inc/filtres');
342
+    }
343 343
 
344
-	return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : '');
344
+    return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : '');
345 345
 }
346 346
 
347 347
 /**
@@ -349,5 +349,5 @@  discard block
 block discarded – undo
349 349
  * @see generer_objet_url_ecrire
350 350
  */
351 351
 function generer_url_ecrire_objet($objet, $id, $args = '', $ancre = '', $public = null, string $connect = '') {
352
-	return generer_objet_url_ecrire($id, $objet, $args, $ancre, $public, $connect);
352
+    return generer_objet_url_ecrire($id, $objet, $args, $ancre, $public, $connect);
353 353
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_liste.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/charsets');
17 17
 
@@ -27,90 +27,90 @@  discard block
 block discarded – undo
27 27
  * @return string
28 28
  */
29 29
 function plugins_afficher_liste_dist(
30
-	$url_page,
31
-	$liste_plugins,
32
-	$liste_plugins_checked,
33
-	$liste_plugins_actifs,
34
-	$dir_plugins = _DIR_PLUGINS,
35
-	$afficher_un = 'afficher_plugin'
30
+    $url_page,
31
+    $liste_plugins,
32
+    $liste_plugins_checked,
33
+    $liste_plugins_actifs,
34
+    $dir_plugins = _DIR_PLUGINS,
35
+    $afficher_un = 'afficher_plugin'
36 36
 ) {
37
-	$get_infos = charger_fonction('get_infos', 'plugins');
38
-	$ligne_plug = charger_fonction($afficher_un, 'plugins');
37
+    $get_infos = charger_fonction('get_infos', 'plugins');
38
+    $ligne_plug = charger_fonction($afficher_un, 'plugins');
39 39
 
40
-	$all_infos = $get_infos($liste_plugins, false, $dir_plugins);
40
+    $all_infos = $get_infos($liste_plugins, false, $dir_plugins);
41 41
 
42
-	$all_infos = pipeline(
43
-		'filtrer_liste_plugins',
44
-		[
45
-			'args' => [
46
-				'liste_plugins' => $liste_plugins,
47
-				'liste_plugins_checked' => $liste_plugins_checked,
48
-				'liste_plugins_actifs' => $liste_plugins_actifs,
49
-				'dir_plugins' => $dir_plugins
50
-			],
51
-			'data' => $all_infos
52
-		]
53
-	);
42
+    $all_infos = pipeline(
43
+        'filtrer_liste_plugins',
44
+        [
45
+            'args' => [
46
+                'liste_plugins' => $liste_plugins,
47
+                'liste_plugins_checked' => $liste_plugins_checked,
48
+                'liste_plugins_actifs' => $liste_plugins_actifs,
49
+                'dir_plugins' => $dir_plugins
50
+            ],
51
+            'data' => $all_infos
52
+        ]
53
+    );
54 54
 
55
-	$liste_plugins = array_flip($liste_plugins);
56
-	foreach ($liste_plugins as $chemin => $v) {
57
-		// des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
-		if (isset($all_infos[$chemin])) {
59
-			$liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
-		} else {
61
-			unset($liste_plugins[$chemin]);
62
-		}
63
-	}
64
-	asort($liste_plugins);
65
-	$exposed = urldecode(_request('plugin') ?? '');
55
+    $liste_plugins = array_flip($liste_plugins);
56
+    foreach ($liste_plugins as $chemin => $v) {
57
+        // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
+        if (isset($all_infos[$chemin])) {
59
+            $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
+        } else {
61
+            unset($liste_plugins[$chemin]);
62
+        }
63
+    }
64
+    asort($liste_plugins);
65
+    $exposed = urldecode(_request('plugin') ?? '');
66 66
 
67
-	$block_par_lettre = false;//count($liste_plugins)>10;
68
-	$fast_liste_plugins_actifs = [];
69
-	$fast_liste_plugins_checked = [];
70
-	if (is_array($liste_plugins_actifs)) {
71
-		$fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
-	}
73
-	if (is_array($liste_plugins_checked)) {
74
-		$fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
-	}
67
+    $block_par_lettre = false;//count($liste_plugins)>10;
68
+    $fast_liste_plugins_actifs = [];
69
+    $fast_liste_plugins_checked = [];
70
+    if (is_array($liste_plugins_actifs)) {
71
+        $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
+    }
73
+    if (is_array($liste_plugins_checked)) {
74
+        $fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
+    }
76 76
 
77
-	$res = '';
78
-	$block = '';
79
-	$initiale = '';
80
-	$block_actif = false;
81
-	foreach ($liste_plugins as $plug => $nom) {
82
-		if (($i = substr($nom, 0, 1)) !== $initiale) {
83
-			$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
-			$initiale = $i;
85
-			$block = '';
86
-			$block_actif = false;
87
-		}
88
-		// le rep suivant
89
-		$actif = isset($fast_liste_plugins_actifs[$plug]);
90
-		$checked = isset($fast_liste_plugins_checked[$plug]);
91
-		$block_actif = $block_actif | $actif;
92
-		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr(
93
-			$dir_plugins,
94
-			strlen(_DIR_RACINE)
95
-		) . $plug));
96
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
97
-	}
98
-	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
99
-	$class = basename($dir_plugins);
77
+    $res = '';
78
+    $block = '';
79
+    $initiale = '';
80
+    $block_actif = false;
81
+    foreach ($liste_plugins as $plug => $nom) {
82
+        if (($i = substr($nom, 0, 1)) !== $initiale) {
83
+            $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
+            $initiale = $i;
85
+            $block = '';
86
+            $block_actif = false;
87
+        }
88
+        // le rep suivant
89
+        $actif = isset($fast_liste_plugins_actifs[$plug]);
90
+        $checked = isset($fast_liste_plugins_checked[$plug]);
91
+        $block_actif = $block_actif | $actif;
92
+        $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr(
93
+            $dir_plugins,
94
+            strlen(_DIR_RACINE)
95
+        ) . $plug));
96
+        $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
97
+    }
98
+    $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
99
+    $class = basename($dir_plugins);
100 100
 
101
-	return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : '';
101
+    return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : '';
102 102
 }
103 103
 
104 104
 
105 105
 function affiche_block_initiale($initiale, $block, $block_actif) {
106
-	if (strlen($block)) {
107
-		return "<li class='item'>"
108
-		. bouton_block_depliable($initiale, $block_actif ? true : false)
109
-		. debut_block_depliable($block_actif)
110
-		. "<ul>$block</ul>"
111
-		. fin_block()
112
-		. '</li>';
113
-	}
106
+    if (strlen($block)) {
107
+        return "<li class='item'>"
108
+        . bouton_block_depliable($initiale, $block_actif ? true : false)
109
+        . debut_block_depliable($block_actif)
110
+        . "<ul>$block</ul>"
111
+        . fin_block()
112
+        . '</li>';
113
+    }
114 114
 
115
-	return '';
115
+    return '';
116 116
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	asort($liste_plugins);
65 65
 	$exposed = urldecode(_request('plugin') ?? '');
66 66
 
67
-	$block_par_lettre = false;//count($liste_plugins)>10;
67
+	$block_par_lettre = false; //count($liste_plugins)>10;
68 68
 	$fast_liste_plugins_actifs = [];
69 69
 	$fast_liste_plugins_checked = [];
70 70
 	if (is_array($liste_plugins_actifs)) {
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 		$actif = isset($fast_liste_plugins_actifs[$plug]);
90 90
 		$checked = isset($fast_liste_plugins_checked[$plug]);
91 91
 		$block_actif = $block_actif | $actif;
92
-		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr(
92
+		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins.$plug or $exposed == substr(
93 93
 			$dir_plugins,
94 94
 			strlen(_DIR_RACINE)
95
-		) . $plug));
96
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins) . "\n";
95
+		).$plug));
96
+		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, 'item', $dir_plugins)."\n";
97 97
 	}
98 98
 	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
99 99
 	$class = basename($dir_plugins);
Please login to merge, or discard this patch.
prive/formulaires/editer_auteur.php 3 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		unset($erreurs['new_login']);
171 171
 	}
172 172
 
173
-	$auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
173
+	$auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur='.intval($id_auteur));
174 174
 	$auth_methode = ($auth_methode ?: 'spip');
175 175
 	include_spip('inc/auth');
176 176
 
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 			!autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?'])
187 187
 			and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur
188 188
 			and !strlen(trim($email))
189
-			and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)))
189
+			and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($id_auteur)))
190 190
 		) {
191 191
 			$erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email'));
192 192
 		} else {
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 			#Nouvel auteur
202 202
 			if (intval($id_auteur) == 0) {
203 203
 				#Un auteur existe deja avec cette adresse ?
204
-				if (sql_countsel('spip_auteurs', 'email=' . sql_quote($email)) > 0) {
204
+				if (sql_countsel('spip_auteurs', 'email='.sql_quote($email)) > 0) {
205 205
 					$erreurs['email'] = _T('erreur_email_deja_existant');
206 206
 				}
207 207
 			} else {
@@ -209,11 +209,11 @@  discard block
 block discarded – undo
209 209
 				if (
210 210
 					(sql_countsel(
211 211
 						'spip_auteurs',
212
-						'email=' . sql_quote($email)
212
+						'email='.sql_quote($email)
213 213
 					) > 0) and ($id_auteur != ($id_auteur_ancien = sql_getfetsel(
214 214
 						'id_auteur',
215 215
 						'spip_auteurs',
216
-						'email=' . sql_quote($email)
216
+						'email='.sql_quote($email)
217 217
 					)))
218 218
 				) {
219 219
 					$erreurs['email'] = _T('erreur_email_deja_existant');
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	// corriger un cas si frequent : www.example.org sans le http:// qui precede
232 232
 	if ($url = _request('url_site') and !tester_url_absolue($url)) {
233 233
 		if (strpos($url, ':') === false and strncasecmp($url, 'www.', 4) === 0) {
234
-			$url = 'http://' . $url;
234
+			$url = 'http://'.$url;
235 235
 			set_request('url_site', $url);
236 236
 		}
237 237
 	}
@@ -248,11 +248,11 @@  discard block
 block discarded – undo
248 248
 	}
249 249
 	elseif (
250 250
 		($login = _request('new_login')) and
251
-		$login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))
251
+		$login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur='.intval($id_auteur))
252 252
 	) {
253 253
 		// on verifie la meme chose que dans auteurs_edit_config()
254 254
 		if (
255
-			! auth_autoriser_modifier_login($auth_methode)
255
+			!auth_autoriser_modifier_login($auth_methode)
256 256
 			or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['login' => true])
257 257
 			// legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email
258 258
 			or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['email' => true])
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 		if (
360 360
 			$GLOBALS['visiteur_session']['id_auteur'] == $id_auteur
361 361
 			and $email_nouveau !=
362
-				($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)))
362
+				($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($id_auteur)))
363 363
 		) {
364 364
 			$envoyer_mail = charger_fonction('envoyer_mail', 'inc');
365 365
 			$texte = _T(
@@ -393,12 +393,12 @@  discard block
 block discarded – undo
393 393
 		if (isset($erreurs['message_ok'])) {
394 394
 			if (!isset($res['message_ok'])) { $res['message_ok'] = '';
395 395
 			}
396
-			$res['message_ok'] = trim($res['message_ok'] . ' ' . $erreurs['message_ok']);
396
+			$res['message_ok'] = trim($res['message_ok'].' '.$erreurs['message_ok']);
397 397
 		}
398 398
 		if (isset($erreurs['message_erreur']) and $erreurs['message_erreur']) {
399 399
 			if (!isset($res['message_erreur'])) { $res['message_erreur'] = '';
400 400
 			}
401
-			$res['message_erreur'] = trim($res['message_erreur'] . ' ' . $erreurs['message_erreur']);
401
+			$res['message_erreur'] = trim($res['message_erreur'].' '.$erreurs['message_erreur']);
402 402
 		}
403 403
 	}
404 404
 
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 
426 426
 
427 427
 function auteur_reset_password($id_auteur, $erreurs = []) {
428
-	$auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
428
+	$auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.intval($id_auteur));
429 429
 	$config = auteurs_edit_config($auteur);
430 430
 
431 431
 	if ($config['edit_pass']) {
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 		include_spip('action/editer_auteur');
461 461
 		auteur_modifier($id_auteur, $set);
462 462
 
463
-		$row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
463
+		$row = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.intval($id_auteur));
464 464
 		include_spip('inc/filtres');
465 465
 		if (
466 466
 			$notifier
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -245,8 +245,7 @@  discard block
 block discarded – undo
245 245
 	if (_request('login')) {
246 246
 		// on n'est jamais cense poster le name 'login'
247 247
 		$erreurs['login'] = _T('info_non_modifiable');
248
-	}
249
-	elseif (
248
+	} elseif (
250 249
 		($login = _request('new_login')) and
251 250
 		$login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))
252 251
 	) {
@@ -483,8 +482,7 @@  discard block
 block discarded – undo
483 482
 			if (!isset($contexte['lang']) or !$contexte['lang']) {
484 483
 				if (isset($row['lang']) and $row['lang']) {
485 484
 					$contexte['lang'] = $row['lang'];
486
-				}
487
-				else {
485
+				} else {
488 486
 					$contexte['lang'] = $GLOBALS['meta']['langue_site'];
489 487
 				}
490 488
 			}
Please login to merge, or discard this patch.
Indentation   +364 added lines, -364 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  **/
8 8
 
9 9
 if (!defined('_ECRIRE_INC_VERSION')) {
10
-	return;
10
+    return;
11 11
 }
12 12
 
13 13
 include_spip('inc/actions');
@@ -37,21 +37,21 @@  discard block
 block discarded – undo
37 37
  *     Environnement du formulaire
38 38
  **/
39 39
 function formulaires_editer_auteur_charger_dist(
40
-	$id_auteur = 'new',
41
-	$retour = '',
42
-	$associer_objet = '',
43
-	$config_fonc = 'auteurs_edit_config',
44
-	$row = [],
45
-	$hidden = ''
40
+    $id_auteur = 'new',
41
+    $retour = '',
42
+    $associer_objet = '',
43
+    $config_fonc = 'auteurs_edit_config',
44
+    $row = [],
45
+    $hidden = ''
46 46
 ) {
47
-	$valeurs = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden);
48
-	$valeurs['new_login'] = $valeurs['login'];
47
+    $valeurs = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden);
48
+    $valeurs['new_login'] = $valeurs['login'];
49 49
 
50
-	if (!autoriser('modifier', 'auteur', intval($id_auteur))) {
51
-		$valeurs['editable'] = '';
52
-	}
50
+    if (!autoriser('modifier', 'auteur', intval($id_auteur))) {
51
+        $valeurs['editable'] = '';
52
+    }
53 53
 
54
-	return $valeurs;
54
+    return $valeurs;
55 55
 }
56 56
 
57 57
 /**
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
  *     Hash du formulaire
76 76
  */
77 77
 function formulaires_editer_auteur_identifier_dist(
78
-	$id_auteur = 'new',
79
-	$retour = '',
80
-	$associer_objet = '',
81
-	$config_fonc = 'auteurs_edit_config',
82
-	$row = [],
83
-	$hidden = ''
78
+    $id_auteur = 'new',
79
+    $retour = '',
80
+    $associer_objet = '',
81
+    $config_fonc = 'auteurs_edit_config',
82
+    $row = [],
83
+    $hidden = ''
84 84
 ) {
85
-	return serialize([intval($id_auteur), $associer_objet]);
85
+    return serialize([intval($id_auteur), $associer_objet]);
86 86
 }
87 87
 
88 88
 
@@ -96,27 +96,27 @@  discard block
 block discarded – undo
96 96
  */
97 97
 function auteurs_edit_config(array $row): array {
98 98
 
99
-	$config = [];
100
-	$config['lignes'] = 8;
101
-	$config['langue'] = $GLOBALS['spip_lang'];
102
-
103
-	// pour instituer_auteur
104
-	$config['auteur'] = $row;
105
-
106
-	//$config['restreint'] = ($row['statut'] == 'publie');
107
-	$auth_methode = $row['source'];
108
-	include_spip('inc/auth');
109
-	$config['edit_login'] =
110
-		(auth_autoriser_modifier_login($auth_methode)
111
-			and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['login' => true])
112
-			// legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email
113
-			and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['email' => true])
114
-		);
115
-	$config['edit_pass'] =
116
-		(auth_autoriser_modifier_pass($auth_methode)
117
-			and autoriser('modifier', 'auteur', $row['id_auteur']));
118
-
119
-	return $config;
99
+    $config = [];
100
+    $config['lignes'] = 8;
101
+    $config['langue'] = $GLOBALS['spip_lang'];
102
+
103
+    // pour instituer_auteur
104
+    $config['auteur'] = $row;
105
+
106
+    //$config['restreint'] = ($row['statut'] == 'publie');
107
+    $auth_methode = $row['source'];
108
+    include_spip('inc/auth');
109
+    $config['edit_login'] =
110
+        (auth_autoriser_modifier_login($auth_methode)
111
+            and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['login' => true])
112
+            // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email
113
+            and autoriser('modifier', 'auteur', $row['id_auteur'], null, ['email' => true])
114
+        );
115
+    $config['edit_pass'] =
116
+        (auth_autoriser_modifier_pass($auth_methode)
117
+            and autoriser('modifier', 'auteur', $row['id_auteur']));
118
+
119
+    return $config;
120 120
 }
121 121
 
122 122
 /**
@@ -146,143 +146,143 @@  discard block
 block discarded – undo
146 146
  *     Erreurs des saisies
147 147
  **/
148 148
 function formulaires_editer_auteur_verifier_dist(
149
-	$id_auteur = 'new',
150
-	$retour = '',
151
-	$associer_objet = '',
152
-	$config_fonc = 'auteurs_edit_config',
153
-	$row = [],
154
-	$hidden = ''
149
+    $id_auteur = 'new',
150
+    $retour = '',
151
+    $associer_objet = '',
152
+    $config_fonc = 'auteurs_edit_config',
153
+    $row = [],
154
+    $hidden = ''
155 155
 ) {
156
-	// auto-renseigner le nom si il n'existe pas, sans couper
157
-	titre_automatique('nom', ['email', 'login'], 255);
158
-
159
-	$oblis = ['nom'];
160
-	// si on veut renvoyer des identifiants il faut un email et un login
161
-	if (_request('reset_password')) {
162
-		$oblis[] = 'email';
163
-		$oblis[] = 'new_login';
164
-	}
165
-	// mais il reste obligatoire si on a rien trouve
166
-	$erreurs = formulaires_editer_objet_verifier('auteur', $id_auteur, $oblis);
167
-	if (isset($erreurs['new_login'])) {
168
-		$erreurs['login'] = $erreurs['new_login'];
169
-		unset($erreurs['new_login']);
170
-	}
171
-
172
-	$auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
173
-	$auth_methode = ($auth_methode ?: 'spip');
174
-	include_spip('inc/auth');
175
-
176
-	if (!nom_acceptable(_request('nom'))) {
177
-		$erreurs['nom'] = _T('info_nom_pas_conforme');
178
-	}
179
-
180
-	if ($email = _request('email')) {
181
-		include_spip('inc/filtres');
182
-		include_spip('inc/autoriser');
183
-		// un redacteur qui modifie son email n'a pas le droit de le vider si il y en avait un
184
-		if (
185
-			!autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?'])
186
-			and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur
187
-			and !strlen(trim($email))
188
-			and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)))
189
-		) {
190
-			$erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email'));
191
-		} else {
192
-			if (!email_valide($email)) {
193
-				$erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email'));
194
-			}
195
-		}
196
-		# Ne pas autoriser d'avoir deux auteurs avec le même email
197
-		# cette fonctionalité nécessite que la base soit clean à l'activation : pas de
198
-		# doublon sur la requête select email,count(*) from spip_auteurs group by email ;
199
-		if (defined('_INTERDIRE_AUTEUR_MEME_EMAIL')) {
200
-			#Nouvel auteur
201
-			if (intval($id_auteur) == 0) {
202
-				#Un auteur existe deja avec cette adresse ?
203
-				if (sql_countsel('spip_auteurs', 'email=' . sql_quote($email)) > 0) {
204
-					$erreurs['email'] = _T('erreur_email_deja_existant');
205
-				}
206
-			} else {
207
-				#Un auteur existe deja avec cette adresse ? et n'est pas le user courant.
208
-				if (
209
-					(sql_countsel(
210
-						'spip_auteurs',
211
-						'email=' . sql_quote($email)
212
-					) > 0) and ($id_auteur != ($id_auteur_ancien = sql_getfetsel(
213
-						'id_auteur',
214
-						'spip_auteurs',
215
-						'email=' . sql_quote($email)
216
-					)))
217
-				) {
218
-					$erreurs['email'] = _T('erreur_email_deja_existant');
219
-				}
220
-			}
221
-		}
222
-	}
223
-
224
-	// quand c'est un auteur existant on fait le reset password ici
225
-	if (!(is_countable($erreurs) ? count($erreurs) : 0) and _request('reset_password') and intval($id_auteur)) {
226
-		$erreurs = auteur_reset_password($id_auteur, $erreurs);
227
-		return $erreurs;
228
-	}
229
-
230
-	// corriger un cas si frequent : www.example.org sans le http:// qui precede
231
-	if ($url = _request('url_site') and !tester_url_absolue($url)) {
232
-		if (strpos($url, ':') === false and strncasecmp($url, 'www.', 4) === 0) {
233
-			$url = 'http://' . $url;
234
-			set_request('url_site', $url);
235
-		}
236
-	}
237
-	// traiter les liens implicites avant de tester l'url
238
-	include_spip('inc/lien');
239
-	if ($url = calculer_url(_request('url_site')) and !tester_url_absolue($url)) {
240
-		$erreurs['url_site'] = _T('info_url_site_pas_conforme');
241
-	}
242
-
243
-	$erreurs['message_erreur'] = '';
244
-	if (_request('login')) {
245
-		// on n'est jamais cense poster le name 'login'
246
-		$erreurs['login'] = _T('info_non_modifiable');
247
-	}
248
-	elseif (
249
-		($login = _request('new_login')) and
250
-		$login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))
251
-	) {
252
-		// on verifie la meme chose que dans auteurs_edit_config()
253
-		if (
254
-			! auth_autoriser_modifier_login($auth_methode)
255
-			or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['login' => true])
256
-			// legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email
257
-			or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['email' => true])
258
-		) {
259
-			$erreurs['login'] = _T('info_non_modifiable');
260
-		}
261
-	}
262
-
263
-	if (empty($erreurs['login'])) {
264
-		if ($err = auth_verifier_login($auth_methode, _request('new_login'), $id_auteur)) {
265
-			$erreurs['login'] = $err;
266
-			$erreurs['message_erreur'] .= $err;
267
-		} else {
268
-			// pass trop court ou confirmation non identique
269
-			if ($p = _request('new_pass')) {
270
-				if ($p != _request('new_pass2')) {
271
-					$erreurs['new_pass'] = _T('info_passes_identiques');
272
-					$erreurs['message_erreur'] .= _T('info_passes_identiques');
273
-				} elseif ($err = auth_verifier_pass($auth_methode, _request('new_login'), $p, $id_auteur)) {
274
-					$erreurs['new_pass'] = $err;
275
-					$erreurs['message_erreur'] .= $err;
276
-				}
277
-			}
278
-		}
279
-	}
280
-
281
-	if (!$erreurs['message_erreur']) {
282
-		unset($erreurs['message_erreur']);
283
-	}
284
-
285
-	return $erreurs;
156
+    // auto-renseigner le nom si il n'existe pas, sans couper
157
+    titre_automatique('nom', ['email', 'login'], 255);
158
+
159
+    $oblis = ['nom'];
160
+    // si on veut renvoyer des identifiants il faut un email et un login
161
+    if (_request('reset_password')) {
162
+        $oblis[] = 'email';
163
+        $oblis[] = 'new_login';
164
+    }
165
+    // mais il reste obligatoire si on a rien trouve
166
+    $erreurs = formulaires_editer_objet_verifier('auteur', $id_auteur, $oblis);
167
+    if (isset($erreurs['new_login'])) {
168
+        $erreurs['login'] = $erreurs['new_login'];
169
+        unset($erreurs['new_login']);
170
+    }
171
+
172
+    $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
173
+    $auth_methode = ($auth_methode ?: 'spip');
174
+    include_spip('inc/auth');
175
+
176
+    if (!nom_acceptable(_request('nom'))) {
177
+        $erreurs['nom'] = _T('info_nom_pas_conforme');
178
+    }
179
+
180
+    if ($email = _request('email')) {
181
+        include_spip('inc/filtres');
182
+        include_spip('inc/autoriser');
183
+        // un redacteur qui modifie son email n'a pas le droit de le vider si il y en avait un
184
+        if (
185
+            !autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?'])
186
+            and $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur
187
+            and !strlen(trim($email))
188
+            and $email != ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)))
189
+        ) {
190
+            $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email'));
191
+        } else {
192
+            if (!email_valide($email)) {
193
+                $erreurs['email'] = (($id_auteur == $GLOBALS['visiteur_session']['id_auteur']) ? _T('form_email_non_valide') : _T('form_prop_indiquer_email'));
194
+            }
195
+        }
196
+        # Ne pas autoriser d'avoir deux auteurs avec le même email
197
+        # cette fonctionalité nécessite que la base soit clean à l'activation : pas de
198
+        # doublon sur la requête select email,count(*) from spip_auteurs group by email ;
199
+        if (defined('_INTERDIRE_AUTEUR_MEME_EMAIL')) {
200
+            #Nouvel auteur
201
+            if (intval($id_auteur) == 0) {
202
+                #Un auteur existe deja avec cette adresse ?
203
+                if (sql_countsel('spip_auteurs', 'email=' . sql_quote($email)) > 0) {
204
+                    $erreurs['email'] = _T('erreur_email_deja_existant');
205
+                }
206
+            } else {
207
+                #Un auteur existe deja avec cette adresse ? et n'est pas le user courant.
208
+                if (
209
+                    (sql_countsel(
210
+                        'spip_auteurs',
211
+                        'email=' . sql_quote($email)
212
+                    ) > 0) and ($id_auteur != ($id_auteur_ancien = sql_getfetsel(
213
+                        'id_auteur',
214
+                        'spip_auteurs',
215
+                        'email=' . sql_quote($email)
216
+                    )))
217
+                ) {
218
+                    $erreurs['email'] = _T('erreur_email_deja_existant');
219
+                }
220
+            }
221
+        }
222
+    }
223
+
224
+    // quand c'est un auteur existant on fait le reset password ici
225
+    if (!(is_countable($erreurs) ? count($erreurs) : 0) and _request('reset_password') and intval($id_auteur)) {
226
+        $erreurs = auteur_reset_password($id_auteur, $erreurs);
227
+        return $erreurs;
228
+    }
229
+
230
+    // corriger un cas si frequent : www.example.org sans le http:// qui precede
231
+    if ($url = _request('url_site') and !tester_url_absolue($url)) {
232
+        if (strpos($url, ':') === false and strncasecmp($url, 'www.', 4) === 0) {
233
+            $url = 'http://' . $url;
234
+            set_request('url_site', $url);
235
+        }
236
+    }
237
+    // traiter les liens implicites avant de tester l'url
238
+    include_spip('inc/lien');
239
+    if ($url = calculer_url(_request('url_site')) and !tester_url_absolue($url)) {
240
+        $erreurs['url_site'] = _T('info_url_site_pas_conforme');
241
+    }
242
+
243
+    $erreurs['message_erreur'] = '';
244
+    if (_request('login')) {
245
+        // on n'est jamais cense poster le name 'login'
246
+        $erreurs['login'] = _T('info_non_modifiable');
247
+    }
248
+    elseif (
249
+        ($login = _request('new_login')) and
250
+        $login !== sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur))
251
+    ) {
252
+        // on verifie la meme chose que dans auteurs_edit_config()
253
+        if (
254
+            ! auth_autoriser_modifier_login($auth_methode)
255
+            or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['login' => true])
256
+            // legacy : ne pas risquer d'autoriser la modif login si fonction d'autorisation pas mise a jour et ne teste que l'option email
257
+            or !autoriser('modifier', 'auteur', intval($id_auteur), null, ['email' => true])
258
+        ) {
259
+            $erreurs['login'] = _T('info_non_modifiable');
260
+        }
261
+    }
262
+
263
+    if (empty($erreurs['login'])) {
264
+        if ($err = auth_verifier_login($auth_methode, _request('new_login'), $id_auteur)) {
265
+            $erreurs['login'] = $err;
266
+            $erreurs['message_erreur'] .= $err;
267
+        } else {
268
+            // pass trop court ou confirmation non identique
269
+            if ($p = _request('new_pass')) {
270
+                if ($p != _request('new_pass2')) {
271
+                    $erreurs['new_pass'] = _T('info_passes_identiques');
272
+                    $erreurs['message_erreur'] .= _T('info_passes_identiques');
273
+                } elseif ($err = auth_verifier_pass($auth_methode, _request('new_login'), $p, $id_auteur)) {
274
+                    $erreurs['new_pass'] = $err;
275
+                    $erreurs['message_erreur'] .= $err;
276
+                }
277
+            }
278
+        }
279
+    }
280
+
281
+    if (!$erreurs['message_erreur']) {
282
+        unset($erreurs['message_erreur']);
283
+    }
284
+
285
+    return $erreurs;
286 286
 }
287 287
 
288 288
 
@@ -319,149 +319,149 @@  discard block
 block discarded – undo
319 319
  *     Retour des traitements
320 320
  **/
321 321
 function formulaires_editer_auteur_traiter_dist(
322
-	$id_auteur = 'new',
323
-	$retour = '',
324
-	$associer_objet = '',
325
-	$config_fonc = 'auteurs_edit_config',
326
-	$row = [],
327
-	$hidden = ''
322
+    $id_auteur = 'new',
323
+    $retour = '',
324
+    $associer_objet = '',
325
+    $config_fonc = 'auteurs_edit_config',
326
+    $row = [],
327
+    $hidden = ''
328 328
 ) {
329
-	if (_request('saisie_webmestre') or _request('webmestre')) {
330
-		set_request('webmestre', _request('webmestre') ?: 'non');
331
-	}
332
-
333
-	// si il y a des modifs sensibles (statut, mot de passe), on refuse le traitement en ajax
334
-	// le formulaire ne peut être traité depuis une XMLHttpRequest
335
-	$prev = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden);
336
-	if (
337
-		_request('new_pass') // nouveau mot de passe
338
-		or empty($prev['statut']) // creation auteur
339
-		or (_request('email') and $prev['email'] !== _request('email')) // modification email
340
-		or (_request('statut') === '0minirezo' and $prev['statut'] !== '0minirezo') // promotion 0minirezo
341
-		or (_request('statut') and intval(_request('statut')) < intval($prev['statut'])) // promotion de statut
342
-		or (_request('webmestre') and _request('webmestre') !== 'non' and $prev['webmestre'] !== 'oui') // promotion webmestre
343
-	) {
344
-		refuser_traiter_formulaire_ajax();
345
-		// si on arrive là encore en ajax c'est pas OK, on genere une erreur
346
-		if (_AJAX or !empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
347
-			return [
348
-				'message_erreur' => _T('erreur_technique_ajaxform')
349
-			];
350
-		}
351
-	}
352
-
353
-	$id_objet = null;
354
-	$retour = parametre_url($retour, 'email_confirm', '');
355
-
356
-	if ($restreintes = _request('restreintes')) {
357
-		foreach ($restreintes as $k => $v) {
358
-			if (strpos($v, 'rubrique|') === 0) {
359
-				$restreintes[$k] = substr($v, 9);
360
-			}
361
-		}
362
-		set_request('restreintes', $restreintes);
363
-	}
364
-
365
-	set_request(
366
-		'email',
367
-		email_valide(_request('email'))
368
-	); // eviter d'enregistrer les cas qui sont acceptés par email_valide dans le verifier :
369
-	// "[email protected]  " ou encore "Marie Toto <[email protected]>"
370
-
371
-	include_spip('inc/autoriser');
372
-	if (!autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?'])) {
373
-		$email_nouveau = _request('email');
374
-		set_request('email'); // vider la saisie car l'auteur n'a pas le droit de modifier cet email
375
-		// mais si c'est son propre profil on lui envoie un email à l'adresse qu'il a indique
376
-		// pour qu'il confirme qu'il possede bien cette adresse
377
-		// son clic sur l'url du message permettre de confirmer le changement
378
-		// et de revenir sur son profil
379
-		if (
380
-			$GLOBALS['visiteur_session']['id_auteur'] == $id_auteur
381
-			and $email_nouveau !=
382
-				($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)))
383
-		) {
384
-			$envoyer_mail = charger_fonction('envoyer_mail', 'inc');
385
-			$texte = _T(
386
-				'form_auteur_mail_confirmation',
387
-				[
388
-					'url' => generer_action_auteur(
389
-						'confirmer_email',
390
-						$email_nouveau,
391
-						parametre_url($retour, 'email_modif', 'ok')
392
-					)
393
-				]
394
-			);
395
-			$envoyer_mail($email_nouveau, _T('form_auteur_confirmation'), $texte);
396
-			set_request('email_confirm', $email_nouveau);
397
-			if ($email_ancien) {
398
-				$envoyer_mail(
399
-					$email_ancien,
400
-					_T('form_auteur_confirmation'),
401
-					_T('form_auteur_envoi_mail_confirmation', ['email' => $email_nouveau])
402
-				);
403
-			}
404
-			$retour = parametre_url($retour, 'email_confirm', $email_nouveau);
405
-		}
406
-	}
407
-
408
-	$res = formulaires_editer_objet_traiter('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden);
409
-
410
-	if (_request('reset_password') and !intval($id_auteur) and intval($res['id_auteur'])) {
411
-		$erreurs = [];
412
-		$erreurs = auteur_reset_password($res['id_auteur'], $erreurs);
413
-		if (isset($erreurs['message_ok'])) {
414
-			if (!isset($res['message_ok'])) { $res['message_ok'] = '';
415
-			}
416
-			$res['message_ok'] = trim($res['message_ok'] . ' ' . $erreurs['message_ok']);
417
-		}
418
-		if (isset($erreurs['message_erreur']) and $erreurs['message_erreur']) {
419
-			if (!isset($res['message_erreur'])) { $res['message_erreur'] = '';
420
-			}
421
-			$res['message_erreur'] = trim($res['message_erreur'] . ' ' . $erreurs['message_erreur']);
422
-		}
423
-	}
424
-
425
-	// Un lien auteur a prendre en compte ?
426
-	if ($associer_objet and $id_auteur = $res['id_auteur']) {
427
-		$objet = '';
428
-		if (intval($associer_objet)) {
429
-			$objet = 'article';
430
-			$id_objet = intval($associer_objet);
431
-		} elseif (preg_match(',^\w+\|[0-9]+$,', $associer_objet)) {
432
-			[$objet, $id_objet] = explode('|', $associer_objet);
433
-		}
434
-		if ($objet and $id_objet and autoriser('modifier', $objet, $id_objet)) {
435
-			include_spip('action/editer_auteur');
436
-			auteur_associer($id_auteur, [$objet => $id_objet]);
437
-			if (isset($res['redirect'])) {
438
-				$res['redirect'] = parametre_url($res['redirect'], 'id_lien_ajoute', $id_auteur, '&');
439
-			}
440
-		}
441
-	}
442
-
443
-	return $res;
329
+    if (_request('saisie_webmestre') or _request('webmestre')) {
330
+        set_request('webmestre', _request('webmestre') ?: 'non');
331
+    }
332
+
333
+    // si il y a des modifs sensibles (statut, mot de passe), on refuse le traitement en ajax
334
+    // le formulaire ne peut être traité depuis une XMLHttpRequest
335
+    $prev = formulaires_editer_objet_charger('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden);
336
+    if (
337
+        _request('new_pass') // nouveau mot de passe
338
+        or empty($prev['statut']) // creation auteur
339
+        or (_request('email') and $prev['email'] !== _request('email')) // modification email
340
+        or (_request('statut') === '0minirezo' and $prev['statut'] !== '0minirezo') // promotion 0minirezo
341
+        or (_request('statut') and intval(_request('statut')) < intval($prev['statut'])) // promotion de statut
342
+        or (_request('webmestre') and _request('webmestre') !== 'non' and $prev['webmestre'] !== 'oui') // promotion webmestre
343
+    ) {
344
+        refuser_traiter_formulaire_ajax();
345
+        // si on arrive là encore en ajax c'est pas OK, on genere une erreur
346
+        if (_AJAX or !empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
347
+            return [
348
+                'message_erreur' => _T('erreur_technique_ajaxform')
349
+            ];
350
+        }
351
+    }
352
+
353
+    $id_objet = null;
354
+    $retour = parametre_url($retour, 'email_confirm', '');
355
+
356
+    if ($restreintes = _request('restreintes')) {
357
+        foreach ($restreintes as $k => $v) {
358
+            if (strpos($v, 'rubrique|') === 0) {
359
+                $restreintes[$k] = substr($v, 9);
360
+            }
361
+        }
362
+        set_request('restreintes', $restreintes);
363
+    }
364
+
365
+    set_request(
366
+        'email',
367
+        email_valide(_request('email'))
368
+    ); // eviter d'enregistrer les cas qui sont acceptés par email_valide dans le verifier :
369
+    // "[email protected]  " ou encore "Marie Toto <[email protected]>"
370
+
371
+    include_spip('inc/autoriser');
372
+    if (!autoriser('modifier', 'auteur', $id_auteur, null, ['email' => '?'])) {
373
+        $email_nouveau = _request('email');
374
+        set_request('email'); // vider la saisie car l'auteur n'a pas le droit de modifier cet email
375
+        // mais si c'est son propre profil on lui envoie un email à l'adresse qu'il a indique
376
+        // pour qu'il confirme qu'il possede bien cette adresse
377
+        // son clic sur l'url du message permettre de confirmer le changement
378
+        // et de revenir sur son profil
379
+        if (
380
+            $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur
381
+            and $email_nouveau !=
382
+                ($email_ancien = sql_getfetsel('email', 'spip_auteurs', 'id_auteur=' . intval($id_auteur)))
383
+        ) {
384
+            $envoyer_mail = charger_fonction('envoyer_mail', 'inc');
385
+            $texte = _T(
386
+                'form_auteur_mail_confirmation',
387
+                [
388
+                    'url' => generer_action_auteur(
389
+                        'confirmer_email',
390
+                        $email_nouveau,
391
+                        parametre_url($retour, 'email_modif', 'ok')
392
+                    )
393
+                ]
394
+            );
395
+            $envoyer_mail($email_nouveau, _T('form_auteur_confirmation'), $texte);
396
+            set_request('email_confirm', $email_nouveau);
397
+            if ($email_ancien) {
398
+                $envoyer_mail(
399
+                    $email_ancien,
400
+                    _T('form_auteur_confirmation'),
401
+                    _T('form_auteur_envoi_mail_confirmation', ['email' => $email_nouveau])
402
+                );
403
+            }
404
+            $retour = parametre_url($retour, 'email_confirm', $email_nouveau);
405
+        }
406
+    }
407
+
408
+    $res = formulaires_editer_objet_traiter('auteur', $id_auteur, 0, 0, $retour, $config_fonc, $row, $hidden);
409
+
410
+    if (_request('reset_password') and !intval($id_auteur) and intval($res['id_auteur'])) {
411
+        $erreurs = [];
412
+        $erreurs = auteur_reset_password($res['id_auteur'], $erreurs);
413
+        if (isset($erreurs['message_ok'])) {
414
+            if (!isset($res['message_ok'])) { $res['message_ok'] = '';
415
+            }
416
+            $res['message_ok'] = trim($res['message_ok'] . ' ' . $erreurs['message_ok']);
417
+        }
418
+        if (isset($erreurs['message_erreur']) and $erreurs['message_erreur']) {
419
+            if (!isset($res['message_erreur'])) { $res['message_erreur'] = '';
420
+            }
421
+            $res['message_erreur'] = trim($res['message_erreur'] . ' ' . $erreurs['message_erreur']);
422
+        }
423
+    }
424
+
425
+    // Un lien auteur a prendre en compte ?
426
+    if ($associer_objet and $id_auteur = $res['id_auteur']) {
427
+        $objet = '';
428
+        if (intval($associer_objet)) {
429
+            $objet = 'article';
430
+            $id_objet = intval($associer_objet);
431
+        } elseif (preg_match(',^\w+\|[0-9]+$,', $associer_objet)) {
432
+            [$objet, $id_objet] = explode('|', $associer_objet);
433
+        }
434
+        if ($objet and $id_objet and autoriser('modifier', $objet, $id_objet)) {
435
+            include_spip('action/editer_auteur');
436
+            auteur_associer($id_auteur, [$objet => $id_objet]);
437
+            if (isset($res['redirect'])) {
438
+                $res['redirect'] = parametre_url($res['redirect'], 'id_lien_ajoute', $id_auteur, '&');
439
+            }
440
+        }
441
+    }
442
+
443
+    return $res;
444 444
 }
445 445
 
446 446
 
447 447
 function auteur_reset_password($id_auteur, $erreurs = []) {
448
-	$auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
449
-	$config = auteurs_edit_config($auteur);
450
-
451
-	if ($config['edit_pass']) {
452
-		if ($email = auteur_regenerer_identifiants($id_auteur)) {
453
-			$erreurs['message_ok'] = _T('message_nouveaux_identifiants_ok', ['email' => $email]);
454
-			$erreurs['message_erreur'] = '';
455
-		} elseif ($email === false) {
456
-			$erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec_envoi');
457
-		} else {
458
-			$erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec');
459
-		}
460
-	} else {
461
-		$erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec');
462
-	}
463
-
464
-	return $erreurs;
448
+    $auteur = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
449
+    $config = auteurs_edit_config($auteur);
450
+
451
+    if ($config['edit_pass']) {
452
+        if ($email = auteur_regenerer_identifiants($id_auteur)) {
453
+            $erreurs['message_ok'] = _T('message_nouveaux_identifiants_ok', ['email' => $email]);
454
+            $erreurs['message_erreur'] = '';
455
+        } elseif ($email === false) {
456
+            $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec_envoi');
457
+        } else {
458
+            $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec');
459
+        }
460
+    } else {
461
+        $erreurs['message_erreur'] = _T('message_nouveaux_identifiants_echec');
462
+    }
463
+
464
+    return $erreurs;
465 465
 }
466 466
 
467 467
 /**
@@ -472,53 +472,53 @@  discard block
 block discarded – undo
472 472
  * @return string
473 473
  */
474 474
 function auteur_regenerer_identifiants($id_auteur, $notifier = true, $contexte = []) {
475
-	if ($id_auteur) {
476
-		$set = [];
477
-		include_spip('inc/access');
478
-		$set['pass'] = creer_pass_aleatoire(max(_PASS_LONGUEUR_MINI, 16));
479
-
480
-		include_spip('action/editer_auteur');
481
-		auteur_modifier($id_auteur, $set);
482
-
483
-		$row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
484
-		include_spip('inc/filtres');
485
-		if (
486
-			$notifier
487
-			and $row['email']
488
-			and email_valide($row['email'])
489
-			and trouver_fond($fond = 'modeles/mail_nouveaux_identifiants')
490
-		) {
491
-			// envoyer l'email avec login/pass
492
-			$c = [
493
-				'id_auteur' => $id_auteur,
494
-				'nom' => $row['nom'],
495
-				'mode' => $row['statut'],
496
-				'email' => $row['email'],
497
-				'pass' => $set['pass'],
498
-			];
499
-			// on merge avec les champs fournit en appel, qui sont passes au modele de notification donc
500
-			$contexte = array_merge($contexte, $c);
501
-			// si pas de langue explicitement demandee, prendre celle de l'auteur si on la connait, ou a defaut celle du site
502
-			// plutot que celle de l'admin qui vient de cliquer sur le bouton
503
-			if (!isset($contexte['lang']) or !$contexte['lang']) {
504
-				if (isset($row['lang']) and $row['lang']) {
505
-					$contexte['lang'] = $row['lang'];
506
-				}
507
-				else {
508
-					$contexte['lang'] = $GLOBALS['meta']['langue_site'];
509
-				}
510
-			}
511
-			lang_select($contexte['lang']);
512
-			$message = recuperer_fond($fond, $contexte);
513
-			include_spip('inc/notifications');
514
-			notifications_envoyer_mails($row['email'], $message);
515
-			lang_select();
516
-
517
-			return $row['email'];
518
-		}
519
-
520
-		return false;
521
-	}
522
-
523
-	return '';
475
+    if ($id_auteur) {
476
+        $set = [];
477
+        include_spip('inc/access');
478
+        $set['pass'] = creer_pass_aleatoire(max(_PASS_LONGUEUR_MINI, 16));
479
+
480
+        include_spip('action/editer_auteur');
481
+        auteur_modifier($id_auteur, $set);
482
+
483
+        $row = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
484
+        include_spip('inc/filtres');
485
+        if (
486
+            $notifier
487
+            and $row['email']
488
+            and email_valide($row['email'])
489
+            and trouver_fond($fond = 'modeles/mail_nouveaux_identifiants')
490
+        ) {
491
+            // envoyer l'email avec login/pass
492
+            $c = [
493
+                'id_auteur' => $id_auteur,
494
+                'nom' => $row['nom'],
495
+                'mode' => $row['statut'],
496
+                'email' => $row['email'],
497
+                'pass' => $set['pass'],
498
+            ];
499
+            // on merge avec les champs fournit en appel, qui sont passes au modele de notification donc
500
+            $contexte = array_merge($contexte, $c);
501
+            // si pas de langue explicitement demandee, prendre celle de l'auteur si on la connait, ou a defaut celle du site
502
+            // plutot que celle de l'admin qui vient de cliquer sur le bouton
503
+            if (!isset($contexte['lang']) or !$contexte['lang']) {
504
+                if (isset($row['lang']) and $row['lang']) {
505
+                    $contexte['lang'] = $row['lang'];
506
+                }
507
+                else {
508
+                    $contexte['lang'] = $GLOBALS['meta']['langue_site'];
509
+                }
510
+            }
511
+            lang_select($contexte['lang']);
512
+            $message = recuperer_fond($fond, $contexte);
513
+            include_spip('inc/notifications');
514
+            notifications_envoyer_mails($row['email'], $message);
515
+            lang_select();
516
+
517
+            return $row['email'];
518
+        }
519
+
520
+        return false;
521
+    }
522
+
523
+    return '';
524 524
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_ecrire.php 2 patches
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 	if ($objet == 'rubrique') {
115 115
 		// si c'est une rubrique-secteur contenant des breves, demander la
116 116
 		// confirmation du deplacement
117
-		$contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet));
117
+		$contient_breves = sql_countsel('spip_breves', 'id_rubrique='.intval($id_objet));
118 118
 
119 119
 		if ($contient_breves > 0) {
120 120
 			$scb = ($contient_breves > 1 ? 's' : '');
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 			);
128 128
 			$confirm .= "\n<div class='confirmer_deplacement verdana2'>"
129 129
 				. "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>"
130
-				. $scb .
130
+				. $scb.
131 131
 				"</label></div></div>\n";
132 132
 		} else {
133 133
 			$confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n";
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 	$form .= $confirm;
137 137
 	if ($actionable) {
138 138
 		if (strpos($form, '<select') !== false) {
139
-			$form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
140
-				. '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>'
139
+			$form .= "<div style='text-align: ".$GLOBALS['spip_lang_right'].";'>"
140
+				. '<input class="fondo submit btn" type="submit" value="'._T('bouton_choisir').'"/>'
141 141
 				. '</div>';
142 142
 		}
143
-		$form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form;
143
+		$form = "<input type='hidden' name='editer_$objet' value='oui' />\n".$form;
144 144
 		if ($action = charger_fonction("editer_$objet", 'action', true)) {
145 145
 			$form = generer_action_auteur(
146 146
 				"editer_$objet",
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
 	include_spip('inc/presentation');
168 168
 
169
-	return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur();
169
+	return debut_cadre_couleur($logo, true, '', $titre).$form.fin_cadre_couleur();
170 170
 }
171 171
 
172 172
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	if ($statut == 'nouveau') {
243 243
 		if ($attente) {
244 244
 			$statut = $attente;
245
-			$plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')';
245
+			$plus = ' ('._T('info_statut_auteur_a_confirmer').')';
246 246
 		} else {
247 247
 			return _T('info_statut_auteur_a_confirmer');
248 248
 		}
@@ -255,16 +255,16 @@  discard block
 block discarded – undo
255 255
 		'5poubelle' => _T('texte_statut_poubelle'), // bouh
256 256
 	];
257 257
 	if (isset($recom[$statut])) {
258
-		return $recom[$statut] . $plus;
258
+		return $recom[$statut].$plus;
259 259
 	}
260 260
 
261 261
 	// retrouver directement par le statut sinon
262 262
 	if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) {
263 263
 		if (isset($recom[$t])) {
264
-			return $recom[$t] . $plus;
264
+			return $recom[$t].$plus;
265 265
 		}
266 266
 
267
-		return _T($t) . $plus;
267
+		return _T($t).$plus;
268 268
 	}
269 269
 
270 270
 	// si on a pas reussi a le traduire, retournons la chaine telle quelle
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 	if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) {
389 389
 		$in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0)
390 390
 			? ''
391
-			: (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']));
391
+			: (' AND '.sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']));
392 392
 
393 393
 		// on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement
394 394
 		if ($objet == 'rubrique') {
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 		return '';
423 423
 	}
424 424
 
425
-	return propre('[->' . $virtuel . ']');
425
+	return propre('[->'.$virtuel.']');
426 426
 }
427 427
 
428 428
 
@@ -449,7 +449,7 @@  discard block
 block discarded – undo
449 449
 	$clic = http_img_pack('rss-16.png', 'RSS', '', $title);
450 450
 
451 451
 	$url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true);
452
-	return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>";
452
+	return "<a style='float: ".$GLOBALS['spip_lang_right'].";' href='$url'>$clic</a>";
453 453
 }
454 454
 
455 455
 
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 	);
526 526
 
527 527
 	if ($alertes = array_filter($alertes)) {
528
-		return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" .
528
+		return "<div class='wrap-messages-alertes'><div class='messages-alertes'>".
529 529
 		join(' | ', $alertes)
530 530
 		. '</div></div>';
531 531
 	}
@@ -559,13 +559,13 @@  discard block
 block discarded – undo
559 559
  */
560 560
 function afficher_plus_info($lien, $titre = '+', $titre_lien = '') {
561 561
 	$titre = attribut_html($titre);
562
-	$icone = "\n<a href='$lien' title='$titre' class='plus_info'>" .
563
-		http_img_pack('information-16.png', $titre) . '</a>';
562
+	$icone = "\n<a href='$lien' title='$titre' class='plus_info'>".
563
+		http_img_pack('information-16.png', $titre).'</a>';
564 564
 
565 565
 	if (!$titre_lien) {
566 566
 		return $icone;
567 567
 	} else {
568
-		return $icone . "\n<a href='$lien'>$titre_lien</a>";
568
+		return $icone."\n<a href='$lien'>$titre_lien</a>";
569 569
 	}
570 570
 }
571 571
 
Please login to merge, or discard this patch.
Indentation   +360 added lines, -360 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
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,25 +41,25 @@  discard block
 block discarded – undo
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 = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2;
52
+    $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2;
53 53
 
54
-	$couleurs = charger_fonction('couleurs', 'inc');
55
-	parse_str($couleurs($c), $c);
56
-	$args = array_merge($args, $c);
54
+    $couleurs = charger_fonction('couleurs', 'inc');
55
+    parse_str($couleurs($c), $c);
56
+    $args = array_merge($args, $c);
57 57
 
58
-	if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) {
59
-		$args['var_mode'] = 'recalcul';
60
-	}
58
+    if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) {
59
+        $args['var_mode'] = 'recalcul';
60
+    }
61 61
 
62
-	return http_build_query($args);
62
+    return http_build_query($args);
63 63
 }
64 64
 
65 65
 
@@ -82,91 +82,91 @@  discard block
 block discarded – undo
82 82
  * @return string
83 83
  */
84 84
 function chercher_rubrique(
85
-	$titre,
86
-	$id_objet,
87
-	$id_parent,
88
-	$objet,
89
-	$id_secteur,
90
-	$restreint,
91
-	$actionable = false,
92
-	$retour_sans_cadre = false
85
+    $titre,
86
+    $id_objet,
87
+    $id_parent,
88
+    $objet,
89
+    $id_secteur,
90
+    $restreint,
91
+    $actionable = false,
92
+    $retour_sans_cadre = false
93 93
 ) {
94 94
 
95
-	include_spip('inc/autoriser');
96
-	if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) {
97
-		return '';
98
-	}
99
-	if (!sql_countsel('spip_rubriques')) {
100
-		return '';
101
-	}
102
-	$chercher_rubrique = charger_fonction('chercher_rubrique', 'inc');
103
-	$form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0);
104
-
105
-	if ($id_parent == 0) {
106
-		$logo = 'racine-24.png';
107
-	} elseif ($id_secteur == $id_parent) {
108
-		$logo = 'secteur-24.png';
109
-	} else {
110
-		$logo = 'rubrique-24.png';
111
-	}
112
-
113
-	$confirm = '';
114
-	if ($objet == 'rubrique') {
115
-		// si c'est une rubrique-secteur contenant des breves, demander la
116
-		// confirmation du deplacement
117
-		$contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet));
118
-
119
-		if ($contient_breves > 0) {
120
-			$scb = ($contient_breves > 1 ? 's' : '');
121
-			$scb = _T(
122
-				'avis_deplacement_rubrique',
123
-				[
124
-					'contient_breves' => $contient_breves,
125
-					'scb' => $scb
126
-				]
127
-			);
128
-			$confirm .= "\n<div class='confirmer_deplacement verdana2'>"
129
-				. "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>"
130
-				. $scb .
131
-				"</label></div></div>\n";
132
-		} else {
133
-			$confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n";
134
-		}
135
-	}
136
-	$form .= $confirm;
137
-	if ($actionable) {
138
-		if (strpos($form, '<select') !== false) {
139
-			$form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
140
-				. '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>'
141
-				. '</div>';
142
-		}
143
-		$form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form;
144
-		if ($action = charger_fonction("editer_$objet", 'action', true)) {
145
-			$form = generer_action_auteur(
146
-				"editer_$objet",
147
-				$id_objet,
148
-				self(),
149
-				$form,
150
-				" method='post' class='submit_plongeur'"
151
-			);
152
-		} else {
153
-			$form = generer_action_auteur(
154
-				'editer_objet',
155
-				"$objet/$id_objet",
156
-				self(),
157
-				$form,
158
-				" method='post' class='submit_plongeur'"
159
-			);
160
-		}
161
-	}
162
-
163
-	if ($retour_sans_cadre) {
164
-		return $form;
165
-	}
166
-
167
-	include_spip('inc/presentation');
168
-
169
-	return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur();
95
+    include_spip('inc/autoriser');
96
+    if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) {
97
+        return '';
98
+    }
99
+    if (!sql_countsel('spip_rubriques')) {
100
+        return '';
101
+    }
102
+    $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc');
103
+    $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0);
104
+
105
+    if ($id_parent == 0) {
106
+        $logo = 'racine-24.png';
107
+    } elseif ($id_secteur == $id_parent) {
108
+        $logo = 'secteur-24.png';
109
+    } else {
110
+        $logo = 'rubrique-24.png';
111
+    }
112
+
113
+    $confirm = '';
114
+    if ($objet == 'rubrique') {
115
+        // si c'est une rubrique-secteur contenant des breves, demander la
116
+        // confirmation du deplacement
117
+        $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet));
118
+
119
+        if ($contient_breves > 0) {
120
+            $scb = ($contient_breves > 1 ? 's' : '');
121
+            $scb = _T(
122
+                'avis_deplacement_rubrique',
123
+                [
124
+                    'contient_breves' => $contient_breves,
125
+                    'scb' => $scb
126
+                ]
127
+            );
128
+            $confirm .= "\n<div class='confirmer_deplacement verdana2'>"
129
+                . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>"
130
+                . $scb .
131
+                "</label></div></div>\n";
132
+        } else {
133
+            $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n";
134
+        }
135
+    }
136
+    $form .= $confirm;
137
+    if ($actionable) {
138
+        if (strpos($form, '<select') !== false) {
139
+            $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
140
+                . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>'
141
+                . '</div>';
142
+        }
143
+        $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form;
144
+        if ($action = charger_fonction("editer_$objet", 'action', true)) {
145
+            $form = generer_action_auteur(
146
+                "editer_$objet",
147
+                $id_objet,
148
+                self(),
149
+                $form,
150
+                " method='post' class='submit_plongeur'"
151
+            );
152
+        } else {
153
+            $form = generer_action_auteur(
154
+                'editer_objet',
155
+                "$objet/$id_objet",
156
+                self(),
157
+                $form,
158
+                " method='post' class='submit_plongeur'"
159
+            );
160
+        }
161
+    }
162
+
163
+    if ($retour_sans_cadre) {
164
+        return $form;
165
+    }
166
+
167
+    include_spip('inc/presentation');
168
+
169
+    return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur();
170 170
 }
171 171
 
172 172
 
@@ -180,24 +180,24 @@  discard block
 block discarded – undo
180 180
  * @return bool
181 181
  */
182 182
 function avoir_visiteurs($past = false, $accepter = true) {
183
-	if ($GLOBALS['meta']['forums_publics'] == 'abo') {
184
-		return true;
185
-	}
186
-	if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') {
187
-		return true;
188
-	}
189
-	if (sql_countsel('spip_articles', "accepter_forum='abo'")) {
190
-		return true;
191
-	}
192
-	if (!$past) {
193
-		return false;
194
-	}
195
-
196
-	return sql_countsel(
197
-		'spip_auteurs',
198
-		"statut NOT IN ('0minirezo','1comite', '5poubelle')
183
+    if ($GLOBALS['meta']['forums_publics'] == 'abo') {
184
+        return true;
185
+    }
186
+    if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') {
187
+        return true;
188
+    }
189
+    if (sql_countsel('spip_articles', "accepter_forum='abo'")) {
190
+        return true;
191
+    }
192
+    if (!$past) {
193
+        return false;
194
+    }
195
+
196
+    return sql_countsel(
197
+        'spip_auteurs',
198
+        "statut NOT IN ('0minirezo','1comite', '5poubelle')
199 199
 	                    AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))"
200
-	);
200
+    );
201 201
 }
202 202
 
203 203
 /**
@@ -213,18 +213,18 @@  discard block
 block discarded – undo
213 213
  * @return array
214 214
  */
215 215
 function statuts_articles_visibles($statut_auteur) {
216
-	static $auth = [];
217
-	if (!isset($auth[$statut_auteur])) {
218
-		$auth[$statut_auteur] = [];
219
-		$statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut');
220
-		foreach ($statuts as $s) {
221
-			if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) {
222
-				$auth[$statut_auteur][] = $s;
223
-			}
224
-		}
225
-	}
226
-
227
-	return $auth[$statut_auteur];
216
+    static $auth = [];
217
+    if (!isset($auth[$statut_auteur])) {
218
+        $auth[$statut_auteur] = [];
219
+        $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut');
220
+        foreach ($statuts as $s) {
221
+            if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) {
222
+                $auth[$statut_auteur][] = $s;
223
+            }
224
+        }
225
+    }
226
+
227
+    return $auth[$statut_auteur];
228 228
 }
229 229
 
230 230
 /**
@@ -238,38 +238,38 @@  discard block
 block discarded – undo
238 238
  * @return string
239 239
  */
240 240
 function traduire_statut_auteur($statut, $attente = '') {
241
-	$plus = '';
242
-	if ($statut == 'nouveau') {
243
-		if ($attente) {
244
-			$statut = $attente;
245
-			$plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')';
246
-		} else {
247
-			return _T('info_statut_auteur_a_confirmer');
248
-		}
249
-	}
250
-
251
-	$recom = [
252
-		'info_administrateurs' => _T('item_administrateur_2'),
253
-		'info_redacteurs' => _T('intem_redacteur'),
254
-		'info_visiteurs' => _T('item_visiteur'),
255
-		'5poubelle' => _T('texte_statut_poubelle'), // bouh
256
-	];
257
-	if (isset($recom[$statut])) {
258
-		return $recom[$statut] . $plus;
259
-	}
260
-
261
-	// retrouver directement par le statut sinon
262
-	if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) {
263
-		if (isset($recom[$t])) {
264
-			return $recom[$t] . $plus;
265
-		}
266
-
267
-		return _T($t) . $plus;
268
-	}
269
-
270
-	// si on a pas reussi a le traduire, retournons la chaine telle quelle
271
-	// c'est toujours plus informatif que rien du tout
272
-	return $statut;
241
+    $plus = '';
242
+    if ($statut == 'nouveau') {
243
+        if ($attente) {
244
+            $statut = $attente;
245
+            $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')';
246
+        } else {
247
+            return _T('info_statut_auteur_a_confirmer');
248
+        }
249
+    }
250
+
251
+    $recom = [
252
+        'info_administrateurs' => _T('item_administrateur_2'),
253
+        'info_redacteurs' => _T('intem_redacteur'),
254
+        'info_visiteurs' => _T('item_visiteur'),
255
+        '5poubelle' => _T('texte_statut_poubelle'), // bouh
256
+    ];
257
+    if (isset($recom[$statut])) {
258
+        return $recom[$statut] . $plus;
259
+    }
260
+
261
+    // retrouver directement par le statut sinon
262
+    if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) {
263
+        if (isset($recom[$t])) {
264
+            return $recom[$t] . $plus;
265
+        }
266
+
267
+        return _T($t) . $plus;
268
+    }
269
+
270
+    // si on a pas reussi a le traduire, retournons la chaine telle quelle
271
+    // c'est toujours plus informatif que rien du tout
272
+    return $statut;
273 273
 }
274 274
 
275 275
 /**
@@ -280,29 +280,29 @@  discard block
 block discarded – undo
280 280
  * @return string
281 281
  */
282 282
 function afficher_qui_edite($id_objet, $objet): string {
283
-	static $qui = [];
284
-	if (isset($qui[$objet][$id_objet])) {
285
-		return $qui[$objet][$id_objet];
286
-	}
287
-
288
-	include_spip('inc/config');
289
-	if (lire_config('articles_modif', 'non') === 'non') {
290
-		return $qui[$objet][$id_objet] = '';
291
-	}
292
-
293
-	include_spip('inc/drapeau_edition');
294
-	$modif = mention_qui_edite($id_objet, $objet);
295
-	if (!$modif) {
296
-		return $qui[$objet][$id_objet] = '';
297
-	}
298
-
299
-	include_spip('base/objets');
300
-	$infos = lister_tables_objets_sql(table_objet_sql($objet));
301
-	if (isset($infos['texte_signale_edition'])) {
302
-		return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif);
303
-	}
304
-
305
-	return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif);
283
+    static $qui = [];
284
+    if (isset($qui[$objet][$id_objet])) {
285
+        return $qui[$objet][$id_objet];
286
+    }
287
+
288
+    include_spip('inc/config');
289
+    if (lire_config('articles_modif', 'non') === 'non') {
290
+        return $qui[$objet][$id_objet] = '';
291
+    }
292
+
293
+    include_spip('inc/drapeau_edition');
294
+    $modif = mention_qui_edite($id_objet, $objet);
295
+    if (!$modif) {
296
+        return $qui[$objet][$id_objet] = '';
297
+    }
298
+
299
+    include_spip('base/objets');
300
+    $infos = lister_tables_objets_sql(table_objet_sql($objet));
301
+    if (isset($infos['texte_signale_edition'])) {
302
+        return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif);
303
+    }
304
+
305
+    return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif);
306 306
 }
307 307
 
308 308
 /**
@@ -320,53 +320,53 @@  discard block
 block discarded – undo
320 320
  * @return array
321 321
  */
322 322
 function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array {
323
-	if (!defined('AUTEURS_MIN_REDAC')) {
324
-		define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle');
325
-	}
326
-
327
-	switch ($quoi) {
328
-		case 'redacteurs':
329
-			$statut = AUTEURS_MIN_REDAC;
330
-			$statut = explode(',', $statut);
331
-			if ($en_base) {
332
-				$check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
333
-				$retire = array_diff($statut, $check);
334
-				$statut = array_diff($statut, $retire);
335
-			}
336
-
337
-			return array_unique($statut);
338
-
339
-		case 'visiteurs':
340
-			$statut = [];
341
-			$exclus = AUTEURS_MIN_REDAC;
342
-			$exclus = explode(',', $exclus);
343
-			if (!$en_base) {
344
-				// prendre aussi les statuts de la table des status qui ne sont pas dans le define
345
-				$statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus);
346
-			}
347
-			$s_complement = array_column(
348
-				sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')),
349
-				'statut'
350
-			);
351
-
352
-			return array_unique(array_merge($statut, $s_complement));
353
-
354
-		default:
355
-		case 'tous':
356
-			$statut = array_values($GLOBALS['liste_des_statuts']);
357
-			$s_complement = array_column(
358
-				sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')),
359
-				'statut'
360
-			);
361
-			$statut = array_merge($statut, $s_complement);
362
-			if ($en_base) {
363
-				$check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
364
-				$retire = array_diff($statut, $check);
365
-				$statut = array_diff($statut, $retire);
366
-			}
367
-
368
-			return array_unique($statut);
369
-	}
323
+    if (!defined('AUTEURS_MIN_REDAC')) {
324
+        define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle');
325
+    }
326
+
327
+    switch ($quoi) {
328
+        case 'redacteurs':
329
+            $statut = AUTEURS_MIN_REDAC;
330
+            $statut = explode(',', $statut);
331
+            if ($en_base) {
332
+                $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
333
+                $retire = array_diff($statut, $check);
334
+                $statut = array_diff($statut, $retire);
335
+            }
336
+
337
+            return array_unique($statut);
338
+
339
+        case 'visiteurs':
340
+            $statut = [];
341
+            $exclus = AUTEURS_MIN_REDAC;
342
+            $exclus = explode(',', $exclus);
343
+            if (!$en_base) {
344
+                // prendre aussi les statuts de la table des status qui ne sont pas dans le define
345
+                $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus);
346
+            }
347
+            $s_complement = array_column(
348
+                sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')),
349
+                'statut'
350
+            );
351
+
352
+            return array_unique(array_merge($statut, $s_complement));
353
+
354
+        default:
355
+        case 'tous':
356
+            $statut = array_values($GLOBALS['liste_des_statuts']);
357
+            $s_complement = array_column(
358
+                sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')),
359
+                'statut'
360
+            );
361
+            $statut = array_merge($statut, $s_complement);
362
+            if ($en_base) {
363
+                $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut');
364
+                $retire = array_diff($statut, $check);
365
+                $statut = array_diff($statut, $retire);
366
+            }
367
+
368
+            return array_unique($statut);
369
+    }
370 370
 }
371 371
 
372 372
 /**
@@ -382,28 +382,28 @@  discard block
 block discarded – undo
382 382
  */
383 383
 function trouver_rubrique_creer_objet($id_rubrique, $objet) {
384 384
 
385
-	if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) {
386
-		$in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0)
387
-			? ''
388
-			: (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']));
389
-
390
-		// on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement
391
-		if ($objet == 'rubrique') {
392
-			$id_rubrique = 0;
393
-		} else {
394
-			$id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1);
395
-		}
396
-
397
-		if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) {
398
-			// manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
399
-			$res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
400
-			while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) {
401
-				$id_rubrique = $row_rub['id_rubrique'];
402
-			}
403
-		}
404
-	}
405
-
406
-	return $id_rubrique;
385
+    if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) {
386
+        $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0)
387
+            ? ''
388
+            : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']));
389
+
390
+        // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement
391
+        if ($objet == 'rubrique') {
392
+            $id_rubrique = 0;
393
+        } else {
394
+            $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1);
395
+        }
396
+
397
+        if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) {
398
+            // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
399
+            $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0');
400
+            while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) {
401
+                $id_rubrique = $row_rub['id_rubrique'];
402
+            }
403
+        }
404
+    }
405
+
406
+    return $id_rubrique;
407 407
 }
408 408
 
409 409
 /**
@@ -414,12 +414,12 @@  discard block
 block discarded – undo
414 414
  * @return string
415 415
  */
416 416
 function lien_article_virtuel($virtuel) {
417
-	include_spip('inc/lien');
418
-	if (!$virtuel = virtuel_redirige($virtuel)) {
419
-		return '';
420
-	}
417
+    include_spip('inc/lien');
418
+    if (!$virtuel = virtuel_redirige($virtuel)) {
419
+        return '';
420
+    }
421 421
 
422
-	return propre('[->' . $virtuel . ']');
422
+    return propre('[->' . $virtuel . ']');
423 423
 }
424 424
 
425 425
 
@@ -442,11 +442,11 @@  discard block
 block discarded – undo
442 442
  * @filtre
443 443
  */
444 444
 function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') {
445
-	include_spip('inc/acces');
446
-	$clic = http_img_pack('rss-16.png', 'RSS', '', $title);
445
+    include_spip('inc/acces');
446
+    $clic = http_img_pack('rss-16.png', 'RSS', '', $title);
447 447
 
448
-	$url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true);
449
-	return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>";
448
+    $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true);
449
+    return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>";
450 450
 }
451 451
 
452 452
 
@@ -458,76 +458,76 @@  discard block
 block discarded – undo
458 458
  */
459 459
 function alertes_auteur($id_auteur): string {
460 460
 
461
-	$alertes = [];
462
-
463
-	if (
464
-		isset($GLOBALS['meta']['message_crash_tables'])
465
-		and autoriser('detruire', null, null, $id_auteur)
466
-	) {
467
-		include_spip('genie/maintenance');
468
-		if ($msg = message_crash_tables()) {
469
-			$alertes[] = $msg;
470
-		}
471
-	}
472
-
473
-	if (
474
-		isset($GLOBALS['meta']['message_crash_plugins'])
475
-		and $GLOBALS['meta']['message_crash_plugins']
476
-		and autoriser('configurer', '_plugins', null, $id_auteur)
477
-		and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins']))
478
-	) {
479
-		$msg = implode(', ', array_map('joli_repertoire', array_keys($msg)));
480
-		$alertes[] = _T('plugins_erreur', ['plugins' => $msg]);
481
-	}
482
-
483
-	$a = $GLOBALS['meta']['message_alertes_auteurs'] ?? '';
484
-	if (
485
-		$a
486
-		and is_array($a = unserialize($a))
487
-		and count($a)
488
-	) {
489
-		$update = false;
490
-		if (isset($a[$GLOBALS['visiteur_session']['statut']])) {
491
-			$alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]);
492
-			unset($a[$GLOBALS['visiteur_session']['statut']]);
493
-			$update = true;
494
-		}
495
-		if (isset($a[''])) {
496
-			$alertes = array_merge($alertes, $a['']);
497
-			unset($a['']);
498
-			$update = true;
499
-		}
500
-		if ($update) {
501
-			ecrire_meta('message_alertes_auteurs', serialize($a));
502
-		}
503
-	}
504
-
505
-	if (
506
-		isset($GLOBALS['meta']['plugin_erreur_activation'])
507
-		and autoriser('configurer', '_plugins', null, $id_auteur)
508
-	) {
509
-		include_spip('inc/plugin');
510
-		$alertes[] = plugin_donne_erreurs();
511
-	}
512
-
513
-	$alertes = pipeline(
514
-		'alertes_auteur',
515
-		[
516
-			'args' => [
517
-				'id_auteur' => $id_auteur,
518
-				'exec' => _request('exec'),
519
-			],
520
-			'data' => $alertes
521
-		]
522
-	);
523
-
524
-	if ($alertes = array_filter($alertes)) {
525
-		return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" .
526
-		join(' | ', $alertes)
527
-		. '</div></div>';
528
-	}
529
-
530
-	return '';
461
+    $alertes = [];
462
+
463
+    if (
464
+        isset($GLOBALS['meta']['message_crash_tables'])
465
+        and autoriser('detruire', null, null, $id_auteur)
466
+    ) {
467
+        include_spip('genie/maintenance');
468
+        if ($msg = message_crash_tables()) {
469
+            $alertes[] = $msg;
470
+        }
471
+    }
472
+
473
+    if (
474
+        isset($GLOBALS['meta']['message_crash_plugins'])
475
+        and $GLOBALS['meta']['message_crash_plugins']
476
+        and autoriser('configurer', '_plugins', null, $id_auteur)
477
+        and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins']))
478
+    ) {
479
+        $msg = implode(', ', array_map('joli_repertoire', array_keys($msg)));
480
+        $alertes[] = _T('plugins_erreur', ['plugins' => $msg]);
481
+    }
482
+
483
+    $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? '';
484
+    if (
485
+        $a
486
+        and is_array($a = unserialize($a))
487
+        and count($a)
488
+    ) {
489
+        $update = false;
490
+        if (isset($a[$GLOBALS['visiteur_session']['statut']])) {
491
+            $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]);
492
+            unset($a[$GLOBALS['visiteur_session']['statut']]);
493
+            $update = true;
494
+        }
495
+        if (isset($a[''])) {
496
+            $alertes = array_merge($alertes, $a['']);
497
+            unset($a['']);
498
+            $update = true;
499
+        }
500
+        if ($update) {
501
+            ecrire_meta('message_alertes_auteurs', serialize($a));
502
+        }
503
+    }
504
+
505
+    if (
506
+        isset($GLOBALS['meta']['plugin_erreur_activation'])
507
+        and autoriser('configurer', '_plugins', null, $id_auteur)
508
+    ) {
509
+        include_spip('inc/plugin');
510
+        $alertes[] = plugin_donne_erreurs();
511
+    }
512
+
513
+    $alertes = pipeline(
514
+        'alertes_auteur',
515
+        [
516
+            'args' => [
517
+                'id_auteur' => $id_auteur,
518
+                'exec' => _request('exec'),
519
+            ],
520
+            'data' => $alertes
521
+        ]
522
+    );
523
+
524
+    if ($alertes = array_filter($alertes)) {
525
+        return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" .
526
+        join(' | ', $alertes)
527
+        . '</div></div>';
528
+    }
529
+
530
+    return '';
531 531
 }
532 532
 
533 533
 /**
@@ -537,9 +537,9 @@  discard block
 block discarded – undo
537 537
  * @return string
538 538
  */
539 539
 function filtre_afficher_enfant_rub_dist($id_rubrique) {
540
-	include_spip('inc/presenter_enfants');
540
+    include_spip('inc/presenter_enfants');
541 541
 
542
-	return afficher_enfant_rub(intval($id_rubrique));
542
+    return afficher_enfant_rub(intval($id_rubrique));
543 543
 }
544 544
 
545 545
 /**
@@ -557,15 +557,15 @@  discard block
 block discarded – undo
557 557
  * @return string
558 558
  */
559 559
 function afficher_plus_info($lien, $titre = '+', $titre_lien = '') {
560
-	$titre = attribut_html($titre);
561
-	$icone = "\n<a href='$lien' title='$titre' class='plus_info'>" .
562
-		http_img_pack('information-16.png', $titre) . '</a>';
563
-
564
-	if (!$titre_lien) {
565
-		return $icone;
566
-	} else {
567
-		return $icone . "\n<a href='$lien'>$titre_lien</a>";
568
-	}
560
+    $titre = attribut_html($titre);
561
+    $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" .
562
+        http_img_pack('information-16.png', $titre) . '</a>';
563
+
564
+    if (!$titre_lien) {
565
+        return $icone;
566
+    } else {
567
+        return $icone . "\n<a href='$lien'>$titre_lien</a>";
568
+    }
569 569
 }
570 570
 
571 571
 
@@ -584,22 +584,22 @@  discard block
 block discarded – undo
584 584
  * @return array
585 585
  */
586 586
 function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) {
587
-	$res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien);
588
-	if (!(is_countable($res) ? count($res) : 0)) {
589
-		return [];
590
-	}
591
-	$r = reset($res);
592
-	if (isset($r['rang_lien'])) {
593
-		$l = array_column($res, 'rang_lien', $objet_source);
594
-		asort($l);
595
-		$l = array_keys($l);
596
-	} else {
597
-		// Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet
598
-		// Sinon c'est dans "id_objet"
599
-		$l = array_column(
600
-			$res,
601
-			$objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet'
602
-		);
603
-	}
604
-	return $l;
587
+    $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien);
588
+    if (!(is_countable($res) ? count($res) : 0)) {
589
+        return [];
590
+    }
591
+    $r = reset($res);
592
+    if (isset($r['rang_lien'])) {
593
+        $l = array_column($res, 'rang_lien', $objet_source);
594
+        asort($l);
595
+        $l = array_keys($l);
596
+    } else {
597
+        // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet
598
+        // Sinon c'est dans "id_objet"
599
+        $l = array_column(
600
+            $res,
601
+            $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet'
602
+        );
603
+    }
604
+    return $l;
605 605
 }
Please login to merge, or discard this patch.