Completed
Push — master ( 457c22...749f05 )
by cam
01:51
created
ecrire/action/editer_article.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	);
107 107
 
108 108
 	// Si l'article est publie, invalider les caches et demander sa reindexation
109
-	$t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id_article));
109
+	$t = sql_getfetsel('statut', 'spip_articles', 'id_article='.intval($id_article));
110 110
 	$invalideur = $indexation = false;
111 111
 	if ($t == 'publie') {
112 112
 		$invalideur = "id='article/$id_article'";
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 			$id_article,
120 120
 			[
121 121
 			'data' => $set,
122
-			'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article],
122
+			'nonvide' => ['titre' => _T('info_nouvel_article').' '._T('info_numero_abbreviation').$id_article],
123 123
 			'invalideur' => $invalideur,
124 124
 			'indexation' => $indexation,
125 125
 			'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 		} elseif (autoriser('modifier', 'article', $id_article) and $s != 'publie') {
310 310
 			$statut = $champs['statut'] = $s;
311 311
 		} else {
312
-			spip_log("editer_article $id_article refus " . join(' ', $c));
312
+			spip_log("editer_article $id_article refus ".join(' ', $c));
313 313
 		}
314 314
 
315 315
 		// En cas de publication, fixer la date a "maintenant"
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 		isset($c['id_parent'])
335 335
 		and $id_parent = $c['id_parent']
336 336
 		and $id_parent != $id_rubrique
337
-		and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . intval($id_parent)))
337
+		and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique='.intval($id_parent)))
338 338
 	) {
339 339
 		$champs['id_rubrique'] = $id_parent;
340 340
 
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 	// Si on deplace l'article
436 436
 	//  changer aussi son secteur et sa langue (si heritee)
437 437
 	if (isset($champs['id_rubrique'])) {
438
-		$row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique']));
438
+		$row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique='.sql_quote($champs['id_rubrique']));
439 439
 
440 440
 		$langue = $row_rub['lang'];
441 441
 		$champs['id_secteur'] = $row_rub['id_secteur'];
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
 			sql_fetsel(
444 444
 				'1',
445 445
 				'spip_articles',
446
-				'id_article=' . intval($id_article) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue)
446
+				'id_article='.intval($id_article)." AND langue_choisie<>'oui' AND lang<>".sql_quote($langue)
447 447
 			)
448 448
 		) {
449 449
 			$champs['lang'] = $langue;
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 		return;
455 455
 	}
456 456
 
457
-	sql_updateq('spip_articles', $champs, 'id_article=' . intval($id_article));
457
+	sql_updateq('spip_articles', $champs, 'id_article='.intval($id_article));
458 458
 
459 459
 	// Changer le statut des rubriques concernees
460 460
 
@@ -475,6 +475,6 @@  discard block
 block discarded – undo
475 475
 		foreach ($plus as $n => $t) {
476 476
 			$plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', $t);
477 477
 		}
478
-		set_request('texte', join('', $plus) . _request('texte'));
478
+		set_request('texte', join('', $plus)._request('texte'));
479 479
 	}
480 480
 }
Please login to merge, or discard this patch.
Indentation   +371 added lines, -371 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
 /**
@@ -39,36 +39,36 @@  discard block
 block discarded – undo
39 39
  *     Liste (identifiant de l'article, texte d'erreur éventuel)
40 40
  */
41 41
 function action_editer_article_dist($arg = null) {
42
-	include_spip('inc/autoriser');
43
-	$err = '';
44
-	if (is_null($arg)) {
45
-		$securiser_action = charger_fonction('securiser_action', 'inc');
46
-		$arg = $securiser_action();
47
-	}
48
-
49
-	// si id_article n'est pas un nombre, c'est une creation
50
-	// mais on verifie qu'on a toutes les donnees qu'il faut.
51
-	if (!$id_article = intval($arg)) {
52
-		$id_parent = _request('id_parent');
53
-		if (!$id_parent) {
54
-			$err = _L("creation interdite d'un article sans rubrique");
55
-		} elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) {
56
-			$err = _T('info_creerdansrubrique_non_autorise');
57
-		} else {
58
-			$id_article = article_inserer($id_parent);
59
-		}
60
-	}
61
-
62
-	// Enregistre l'envoi dans la BD
63
-	if ($id_article > 0) {
64
-		$err = article_modifier($id_article);
65
-	}
66
-
67
-	if ($err) {
68
-		spip_log("echec editeur article: $err", _LOG_ERREUR);
69
-	}
70
-
71
-	return [$id_article, $err];
42
+    include_spip('inc/autoriser');
43
+    $err = '';
44
+    if (is_null($arg)) {
45
+        $securiser_action = charger_fonction('securiser_action', 'inc');
46
+        $arg = $securiser_action();
47
+    }
48
+
49
+    // si id_article n'est pas un nombre, c'est une creation
50
+    // mais on verifie qu'on a toutes les donnees qu'il faut.
51
+    if (!$id_article = intval($arg)) {
52
+        $id_parent = _request('id_parent');
53
+        if (!$id_parent) {
54
+            $err = _L("creation interdite d'un article sans rubrique");
55
+        } elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) {
56
+            $err = _T('info_creerdansrubrique_non_autorise');
57
+        } else {
58
+            $id_article = article_inserer($id_parent);
59
+        }
60
+    }
61
+
62
+    // Enregistre l'envoi dans la BD
63
+    if ($id_article > 0) {
64
+        $err = article_modifier($id_article);
65
+    }
66
+
67
+    if ($err) {
68
+        spip_log("echec editeur article: $err", _LOG_ERREUR);
69
+    }
70
+
71
+    return [$id_article, $err];
72 72
 }
73 73
 
74 74
 /**
@@ -90,50 +90,50 @@  discard block
 block discarded – undo
90 90
  */
91 91
 function article_modifier($id_article, $set = null) {
92 92
 
93
-	// unifier $texte en cas de texte trop long
94
-	trop_longs_articles();
95
-
96
-	include_spip('inc/modifier');
97
-	include_spip('inc/filtres');
98
-	$c = collecter_requests(
99
-		// include list
100
-		objet_info('article', 'champs_editables'),
101
-		// exclude list
102
-		['date', 'statut', 'id_parent'],
103
-		// donnees eventuellement fournies
104
-		$set
105
-	);
106
-
107
-	// Si l'article est publie, invalider les caches et demander sa reindexation
108
-	$t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id_article));
109
-	$invalideur = $indexation = false;
110
-	if ($t == 'publie') {
111
-		$invalideur = "id='article/$id_article'";
112
-		$indexation = true;
113
-	}
114
-
115
-	if (
116
-		$err = objet_modifier_champs(
117
-			'article',
118
-			$id_article,
119
-			[
120
-			'data' => $set,
121
-			'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article],
122
-			'invalideur' => $invalideur,
123
-			'indexation' => $indexation,
124
-			'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif
125
-			],
126
-			$c
127
-		)
128
-	) {
129
-		return $err;
130
-	}
131
-
132
-	// Modification de statut, changement de rubrique ?
133
-	$c = collecter_requests(['date', 'statut', 'id_parent'], [], $set);
134
-	$err = article_instituer($id_article, $c);
135
-
136
-	return $err;
93
+    // unifier $texte en cas de texte trop long
94
+    trop_longs_articles();
95
+
96
+    include_spip('inc/modifier');
97
+    include_spip('inc/filtres');
98
+    $c = collecter_requests(
99
+        // include list
100
+        objet_info('article', 'champs_editables'),
101
+        // exclude list
102
+        ['date', 'statut', 'id_parent'],
103
+        // donnees eventuellement fournies
104
+        $set
105
+    );
106
+
107
+    // Si l'article est publie, invalider les caches et demander sa reindexation
108
+    $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id_article));
109
+    $invalideur = $indexation = false;
110
+    if ($t == 'publie') {
111
+        $invalideur = "id='article/$id_article'";
112
+        $indexation = true;
113
+    }
114
+
115
+    if (
116
+        $err = objet_modifier_champs(
117
+            'article',
118
+            $id_article,
119
+            [
120
+            'data' => $set,
121
+            'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article],
122
+            'invalideur' => $invalideur,
123
+            'indexation' => $indexation,
124
+            'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif
125
+            ],
126
+            $c
127
+        )
128
+    ) {
129
+        return $err;
130
+    }
131
+
132
+    // Modification de statut, changement de rubrique ?
133
+    $c = collecter_requests(['date', 'statut', 'id_parent'], [], $set);
134
+    $err = article_instituer($id_article, $c);
135
+
136
+    return $err;
137 137
 }
138 138
 
139 139
 /**
@@ -169,120 +169,120 @@  discard block
 block discarded – undo
169 169
  */
170 170
 function article_inserer($id_rubrique, $set = null) {
171 171
 
172
-	// Si id_rubrique vaut 0 ou n'est pas definie, creer l'article
173
-	// dans la premiere rubrique racine
174
-	if (!$id_rubrique = intval($id_rubrique)) {
175
-		$row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1');
176
-		$id_rubrique = $row['id_rubrique'];
177
-	} else {
178
-		$row = sql_fetsel('lang, id_secteur', 'spip_rubriques', "id_rubrique=$id_rubrique");
179
-	}
180
-
181
-	// eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue
182
-	// cas de id_rubrique = -1 par exemple avec plugin "pages"
183
-	$id_secteur = $row['id_secteur'] ?? 0;
184
-	$lang_rub = $row['lang'] ?? '';
185
-
186
-	$lang = '';
187
-	$choisie = 'non';
188
-	// La langue a la creation : si les liens de traduction sont autorises
189
-	// dans les rubriques, on essaie avec la langue de l'auteur,
190
-	// ou a defaut celle de la rubrique
191
-	// Sinon c'est la langue de la rubrique qui est choisie + heritee
192
-	if (
193
-		!empty($GLOBALS['meta']['multi_objets']) and in_array(
194
-			'spip_articles',
195
-			explode(',', $GLOBALS['meta']['multi_objets'])
196
-		)
197
-	) {
198
-		lang_select($GLOBALS['visiteur_session']['lang']);
199
-		if (
200
-			in_array(
201
-				$GLOBALS['spip_lang'],
202
-				explode(',', $GLOBALS['meta']['langues_multilingue'])
203
-			)
204
-		) {
205
-			$lang = $GLOBALS['spip_lang'];
206
-			$choisie = 'oui';
207
-		}
208
-	}
209
-
210
-	if (!$lang) {
211
-		$choisie = 'non';
212
-		$lang = $lang_rub ?: $GLOBALS['meta']['langue_site'];
213
-	}
214
-
215
-	$champs = [
216
-		'id_rubrique' => $id_rubrique,
217
-		'id_secteur' => $id_secteur,
218
-		'statut' => 'prepa',
219
-		'date' => date('Y-m-d H:i:s'),
220
-		'lang' => $lang,
221
-		'langue_choisie' => $choisie
222
-	];
223
-
224
-	if ($set) {
225
-		$champs = array_merge($champs, $set);
226
-	}
227
-
228
-	// Envoyer aux plugins
229
-	$champs = pipeline(
230
-		'pre_insertion',
231
-		[
232
-			'args' => [
233
-				'table' => 'spip_articles',
234
-			],
235
-			'data' => $champs
236
-		]
237
-	);
238
-
239
-	$id_article = sql_insertq('spip_articles', $champs);
240
-
241
-	// controler si le serveur n'a pas renvoye une erreur
242
-	if ($id_article > 0) {
243
-		$id_auteur = ((is_null(_request('id_auteur')) and isset($GLOBALS['visiteur_session']['id_auteur'])) ?
244
-			$GLOBALS['visiteur_session']['id_auteur']
245
-			: _request('id_auteur'));
246
-		if ($id_auteur) {
247
-			include_spip('action/editer_auteur');
248
-			auteur_associer($id_auteur, ['article' => $id_article]);
249
-		}
250
-	}
251
-
252
-	pipeline(
253
-		'post_insertion',
254
-		[
255
-			'args' => [
256
-				'table' => 'spip_articles',
257
-				'id_objet' => $id_article
258
-			],
259
-			'data' => $champs
260
-		]
261
-	);
172
+    // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article
173
+    // dans la premiere rubrique racine
174
+    if (!$id_rubrique = intval($id_rubrique)) {
175
+        $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1');
176
+        $id_rubrique = $row['id_rubrique'];
177
+    } else {
178
+        $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', "id_rubrique=$id_rubrique");
179
+    }
180
+
181
+    // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue
182
+    // cas de id_rubrique = -1 par exemple avec plugin "pages"
183
+    $id_secteur = $row['id_secteur'] ?? 0;
184
+    $lang_rub = $row['lang'] ?? '';
185
+
186
+    $lang = '';
187
+    $choisie = 'non';
188
+    // La langue a la creation : si les liens de traduction sont autorises
189
+    // dans les rubriques, on essaie avec la langue de l'auteur,
190
+    // ou a defaut celle de la rubrique
191
+    // Sinon c'est la langue de la rubrique qui est choisie + heritee
192
+    if (
193
+        !empty($GLOBALS['meta']['multi_objets']) and in_array(
194
+            'spip_articles',
195
+            explode(',', $GLOBALS['meta']['multi_objets'])
196
+        )
197
+    ) {
198
+        lang_select($GLOBALS['visiteur_session']['lang']);
199
+        if (
200
+            in_array(
201
+                $GLOBALS['spip_lang'],
202
+                explode(',', $GLOBALS['meta']['langues_multilingue'])
203
+            )
204
+        ) {
205
+            $lang = $GLOBALS['spip_lang'];
206
+            $choisie = 'oui';
207
+        }
208
+    }
209
+
210
+    if (!$lang) {
211
+        $choisie = 'non';
212
+        $lang = $lang_rub ?: $GLOBALS['meta']['langue_site'];
213
+    }
214
+
215
+    $champs = [
216
+        'id_rubrique' => $id_rubrique,
217
+        'id_secteur' => $id_secteur,
218
+        'statut' => 'prepa',
219
+        'date' => date('Y-m-d H:i:s'),
220
+        'lang' => $lang,
221
+        'langue_choisie' => $choisie
222
+    ];
223
+
224
+    if ($set) {
225
+        $champs = array_merge($champs, $set);
226
+    }
227
+
228
+    // Envoyer aux plugins
229
+    $champs = pipeline(
230
+        'pre_insertion',
231
+        [
232
+            'args' => [
233
+                'table' => 'spip_articles',
234
+            ],
235
+            'data' => $champs
236
+        ]
237
+    );
238
+
239
+    $id_article = sql_insertq('spip_articles', $champs);
240
+
241
+    // controler si le serveur n'a pas renvoye une erreur
242
+    if ($id_article > 0) {
243
+        $id_auteur = ((is_null(_request('id_auteur')) and isset($GLOBALS['visiteur_session']['id_auteur'])) ?
244
+            $GLOBALS['visiteur_session']['id_auteur']
245
+            : _request('id_auteur'));
246
+        if ($id_auteur) {
247
+            include_spip('action/editer_auteur');
248
+            auteur_associer($id_auteur, ['article' => $id_article]);
249
+        }
250
+    }
251
+
252
+    pipeline(
253
+        'post_insertion',
254
+        [
255
+            'args' => [
256
+                'table' => 'spip_articles',
257
+                'id_objet' => $id_article
258
+            ],
259
+            'data' => $champs
260
+        ]
261
+    );
262 262
 	
263
-	// Appeler une notification
264
-	if ($notifications = charger_fonction('notifications', 'inc')) {
265
-		$notifications(
266
-			'article_inserer',
267
-			$id_article,
268
-			[
269
-				'id_parent' => $id_rubrique,
270
-				'champs' => $champs,
271
-			]
272
-		);
273
-		$notifications(
274
-			'objet_inserer',
275
-			$id_article,
276
-			[
277
-				'objet' => 'article',
278
-				'id_objet' => $id_article,
279
-				'id_parent' => $id_rubrique,
280
-				'champs' => $champs,
281
-			]
282
-		);
283
-	}
284
-
285
-	return $id_article;
263
+    // Appeler une notification
264
+    if ($notifications = charger_fonction('notifications', 'inc')) {
265
+        $notifications(
266
+            'article_inserer',
267
+            $id_article,
268
+            [
269
+                'id_parent' => $id_rubrique,
270
+                'champs' => $champs,
271
+            ]
272
+        );
273
+        $notifications(
274
+            'objet_inserer',
275
+            $id_article,
276
+            [
277
+                'objet' => 'article',
278
+                'id_objet' => $id_article,
279
+                'id_parent' => $id_rubrique,
280
+                'champs' => $champs,
281
+            ]
282
+        );
283
+    }
284
+
285
+    return $id_article;
286 286
 }
287 287
 
288 288
 
@@ -310,153 +310,153 @@  discard block
 block discarded – undo
310 310
  */
311 311
 function article_instituer($id_article, $c, $calcul_rub = true) {
312 312
 
313
-	include_spip('inc/autoriser');
314
-	include_spip('inc/rubriques');
315
-	include_spip('inc/modifier');
316
-
317
-	$row = sql_fetsel('statut, date, id_rubrique', 'spip_articles', "id_article=$id_article");
318
-	$id_rubrique = $row['id_rubrique'];
319
-	$statut_ancien = $statut = $row['statut'];
320
-	$date_ancienne = $date = $row['date'];
321
-	$champs = [];
322
-
323
-	$d = $c['date'] ?? null;
324
-	$s = $c['statut'] ?? $statut;
325
-
326
-	// cf autorisations dans inc/instituer_article
327
-	if ($s != $statut or ($d and $d != $date)) {
328
-		if (autoriser('publierdans', 'rubrique', $id_rubrique)) {
329
-			$statut = $champs['statut'] = $s;
330
-		} elseif (autoriser('modifier', 'article', $id_article) and $s != 'publie') {
331
-			$statut = $champs['statut'] = $s;
332
-		} else {
333
-			spip_log("editer_article $id_article refus " . join(' ', $c));
334
-		}
335
-
336
-		// En cas de publication, fixer la date a "maintenant"
337
-		// sauf si $c commande autre chose
338
-		// ou si l'article est deja date dans le futur
339
-		// En cas de proposition d'un article (mais pas depublication), idem
340
-		if (
341
-			$champs['statut'] == 'publie'
342
-			or ($champs['statut'] == 'prop' and ($d or !in_array($statut_ancien, ['publie', 'prop'])))
343
-		) {
344
-			if ($d or strtotime($d = $date) > time()) {
345
-				$champs['date'] = $date = $d;
346
-			} else {
347
-				$champs['date'] = $date = date('Y-m-d H:i:s');
348
-			}
349
-		}
350
-	}
351
-
352
-	// Verifier que la rubrique demandee existe et est differente
353
-	// de la rubrique actuelle
354
-	if (
355
-		isset($c['id_parent'])
356
-		and $id_parent = $c['id_parent']
357
-		and $id_parent != $id_rubrique
358
-		and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . intval($id_parent)))
359
-	) {
360
-		$champs['id_rubrique'] = $id_parent;
361
-
362
-		// si l'article etait publie
363
-		// et que le demandeur n'est pas admin de la rubrique de destination
364
-		// repasser l'article en statut 'propose'.
365
-		if (
366
-			$statut == 'publie'
367
-			and !autoriser('publierdans', 'rubrique', $id_parent)
368
-		) {
369
-			$champs['statut'] = 'prop';
370
-		}
371
-	}
372
-
373
-	// Envoyer aux plugins
374
-	$champs = pipeline(
375
-		'pre_edition',
376
-		[
377
-			'args' => [
378
-				'table' => 'spip_articles',
379
-				'id_objet' => $id_article,
380
-				'action' => 'instituer',
381
-				'statut_ancien' => $statut_ancien,
382
-				'date_ancienne' => $date_ancienne,
383
-			],
384
-			'data' => $champs
385
-		]
386
-	);
387
-
388
-	if (!(is_countable($champs) ? count($champs) : 0)) {
389
-		return '';
390
-	}
391
-
392
-	// Envoyer les modifs.
393
-	editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub);
394
-
395
-	// Invalider les caches
396
-	include_spip('inc/invalideur');
397
-	suivre_invalideur("id='article/$id_article'");
398
-
399
-	if ($date) {
400
-		$t = strtotime($date);
401
-		$p = @$GLOBALS['meta']['date_prochain_postdate'];
402
-		if ($t > time() and (!$p or ($t < $p))) {
403
-			ecrire_meta('date_prochain_postdate', $t);
404
-		}
405
-	}
406
-
407
-	// Pipeline
408
-	pipeline(
409
-		'post_edition',
410
-		[
411
-			'args' => [
412
-				'table' => 'spip_articles',
413
-				'id_objet' => $id_article,
414
-				'action' => 'instituer',
415
-				'statut_ancien' => $statut_ancien,
416
-				'date_ancienne' => $date_ancienne,
417
-			],
418
-			'data' => $champs
419
-		]
420
-	);
421
-
422
-	// Notifications
423
-	if ($notifications = charger_fonction('notifications', 'inc')) {
424
-		$notifications(
425
-			'article_instituer',
426
-			$id_article,
427
-			[
428
-				'statut' => $statut,
429
-				'statut_ancien' => $statut_ancien,
430
-				'date' => $date,
431
-				'date_ancienne' => $date_ancienne,
432
-				'id_parent_ancien' => $id_rubrique,
433
-				'champs' => $champs,
434
-			]
435
-		);
436
-		$notifications(
437
-			'objet_instituer',
438
-			$id_article,
439
-			[
440
-				'objet' => 'article',
441
-				'id_objet' => $id_article,
442
-				'statut' => $statut,
443
-				'statut_ancien' => $statut_ancien,
444
-				'date' => $date,
445
-				'date_ancienne' => $date_ancienne,
446
-				'id_parent_ancien' => $id_rubrique,
447
-				'champs' => $champs,
448
-			]
449
-		);
313
+    include_spip('inc/autoriser');
314
+    include_spip('inc/rubriques');
315
+    include_spip('inc/modifier');
316
+
317
+    $row = sql_fetsel('statut, date, id_rubrique', 'spip_articles', "id_article=$id_article");
318
+    $id_rubrique = $row['id_rubrique'];
319
+    $statut_ancien = $statut = $row['statut'];
320
+    $date_ancienne = $date = $row['date'];
321
+    $champs = [];
322
+
323
+    $d = $c['date'] ?? null;
324
+    $s = $c['statut'] ?? $statut;
325
+
326
+    // cf autorisations dans inc/instituer_article
327
+    if ($s != $statut or ($d and $d != $date)) {
328
+        if (autoriser('publierdans', 'rubrique', $id_rubrique)) {
329
+            $statut = $champs['statut'] = $s;
330
+        } elseif (autoriser('modifier', 'article', $id_article) and $s != 'publie') {
331
+            $statut = $champs['statut'] = $s;
332
+        } else {
333
+            spip_log("editer_article $id_article refus " . join(' ', $c));
334
+        }
335
+
336
+        // En cas de publication, fixer la date a "maintenant"
337
+        // sauf si $c commande autre chose
338
+        // ou si l'article est deja date dans le futur
339
+        // En cas de proposition d'un article (mais pas depublication), idem
340
+        if (
341
+            $champs['statut'] == 'publie'
342
+            or ($champs['statut'] == 'prop' and ($d or !in_array($statut_ancien, ['publie', 'prop'])))
343
+        ) {
344
+            if ($d or strtotime($d = $date) > time()) {
345
+                $champs['date'] = $date = $d;
346
+            } else {
347
+                $champs['date'] = $date = date('Y-m-d H:i:s');
348
+            }
349
+        }
350
+    }
351
+
352
+    // Verifier que la rubrique demandee existe et est differente
353
+    // de la rubrique actuelle
354
+    if (
355
+        isset($c['id_parent'])
356
+        and $id_parent = $c['id_parent']
357
+        and $id_parent != $id_rubrique
358
+        and (sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . intval($id_parent)))
359
+    ) {
360
+        $champs['id_rubrique'] = $id_parent;
361
+
362
+        // si l'article etait publie
363
+        // et que le demandeur n'est pas admin de la rubrique de destination
364
+        // repasser l'article en statut 'propose'.
365
+        if (
366
+            $statut == 'publie'
367
+            and !autoriser('publierdans', 'rubrique', $id_parent)
368
+        ) {
369
+            $champs['statut'] = 'prop';
370
+        }
371
+    }
372
+
373
+    // Envoyer aux plugins
374
+    $champs = pipeline(
375
+        'pre_edition',
376
+        [
377
+            'args' => [
378
+                'table' => 'spip_articles',
379
+                'id_objet' => $id_article,
380
+                'action' => 'instituer',
381
+                'statut_ancien' => $statut_ancien,
382
+                'date_ancienne' => $date_ancienne,
383
+            ],
384
+            'data' => $champs
385
+        ]
386
+    );
387
+
388
+    if (!(is_countable($champs) ? count($champs) : 0)) {
389
+        return '';
390
+    }
391
+
392
+    // Envoyer les modifs.
393
+    editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub);
394
+
395
+    // Invalider les caches
396
+    include_spip('inc/invalideur');
397
+    suivre_invalideur("id='article/$id_article'");
398
+
399
+    if ($date) {
400
+        $t = strtotime($date);
401
+        $p = @$GLOBALS['meta']['date_prochain_postdate'];
402
+        if ($t > time() and (!$p or ($t < $p))) {
403
+            ecrire_meta('date_prochain_postdate', $t);
404
+        }
405
+    }
406
+
407
+    // Pipeline
408
+    pipeline(
409
+        'post_edition',
410
+        [
411
+            'args' => [
412
+                'table' => 'spip_articles',
413
+                'id_objet' => $id_article,
414
+                'action' => 'instituer',
415
+                'statut_ancien' => $statut_ancien,
416
+                'date_ancienne' => $date_ancienne,
417
+            ],
418
+            'data' => $champs
419
+        ]
420
+    );
421
+
422
+    // Notifications
423
+    if ($notifications = charger_fonction('notifications', 'inc')) {
424
+        $notifications(
425
+            'article_instituer',
426
+            $id_article,
427
+            [
428
+                'statut' => $statut,
429
+                'statut_ancien' => $statut_ancien,
430
+                'date' => $date,
431
+                'date_ancienne' => $date_ancienne,
432
+                'id_parent_ancien' => $id_rubrique,
433
+                'champs' => $champs,
434
+            ]
435
+        );
436
+        $notifications(
437
+            'objet_instituer',
438
+            $id_article,
439
+            [
440
+                'objet' => 'article',
441
+                'id_objet' => $id_article,
442
+                'statut' => $statut,
443
+                'statut_ancien' => $statut_ancien,
444
+                'date' => $date,
445
+                'date_ancienne' => $date_ancienne,
446
+                'id_parent_ancien' => $id_rubrique,
447
+                'champs' => $champs,
448
+            ]
449
+        );
450 450
 		
451
-		// Rétro-compat
452
-		$notifications(
453
-			'instituerarticle',
454
-			$id_article,
455
-			['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne]
456
-		);
457
-	}
458
-
459
-	return ''; // pas d'erreur
451
+        // Rétro-compat
452
+        $notifications(
453
+            'instituerarticle',
454
+            $id_article,
455
+            ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne]
456
+        );
457
+    }
458
+
459
+    return ''; // pas d'erreur
460 460
 }
461 461
 
462 462
 /**
@@ -481,37 +481,37 @@  discard block
 block discarded – undo
481 481
  */
482 482
 function editer_article_heritage($id_article, $id_rubrique, $statut, $champs, $cond = true) {
483 483
 
484
-	// Si on deplace l'article
485
-	//  changer aussi son secteur et sa langue (si heritee)
486
-	if (isset($champs['id_rubrique'])) {
487
-		$row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique']));
488
-
489
-		$langue = $row_rub['lang'];
490
-		$champs['id_secteur'] = $row_rub['id_secteur'];
491
-		if (
492
-			sql_fetsel(
493
-				'1',
494
-				'spip_articles',
495
-				'id_article=' . intval($id_article) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue)
496
-			)
497
-		) {
498
-			$champs['lang'] = $langue;
499
-		}
500
-	}
501
-
502
-	if (!$champs) {
503
-		return;
504
-	}
505
-
506
-	sql_updateq('spip_articles', $champs, 'id_article=' . intval($id_article));
507
-
508
-	// Changer le statut des rubriques concernees
509
-
510
-	if ($cond) {
511
-		include_spip('inc/rubriques');
512
-		$postdate = ($GLOBALS['meta']['post_dates'] == 'non' and isset($champs['date']) and (strtotime($champs['date']) < time())) ? $champs['date'] : false;
513
-		calculer_rubriques_if($id_rubrique, $champs, ['statut_ancien' => $statut], $postdate);
514
-	}
484
+    // Si on deplace l'article
485
+    //  changer aussi son secteur et sa langue (si heritee)
486
+    if (isset($champs['id_rubrique'])) {
487
+        $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique']));
488
+
489
+        $langue = $row_rub['lang'];
490
+        $champs['id_secteur'] = $row_rub['id_secteur'];
491
+        if (
492
+            sql_fetsel(
493
+                '1',
494
+                'spip_articles',
495
+                'id_article=' . intval($id_article) . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue)
496
+            )
497
+        ) {
498
+            $champs['lang'] = $langue;
499
+        }
500
+    }
501
+
502
+    if (!$champs) {
503
+        return;
504
+    }
505
+
506
+    sql_updateq('spip_articles', $champs, 'id_article=' . intval($id_article));
507
+
508
+    // Changer le statut des rubriques concernees
509
+
510
+    if ($cond) {
511
+        include_spip('inc/rubriques');
512
+        $postdate = ($GLOBALS['meta']['post_dates'] == 'non' and isset($champs['date']) and (strtotime($champs['date']) < time())) ? $champs['date'] : false;
513
+        calculer_rubriques_if($id_rubrique, $champs, ['statut_ancien' => $statut], $postdate);
514
+    }
515 515
 }
516 516
 
517 517
 /**
@@ -520,10 +520,10 @@  discard block
 block discarded – undo
520 520
  * @return void
521 521
  */
522 522
 function trop_longs_articles() {
523
-	if (is_array($plus = _request('texte_plus'))) {
524
-		foreach ($plus as $n => $t) {
525
-			$plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', $t);
526
-		}
527
-		set_request('texte', join('', $plus) . _request('texte'));
528
-	}
523
+    if (is_array($plus = _request('texte_plus'))) {
524
+        foreach ($plus as $n => $t) {
525
+            $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', $t);
526
+        }
527
+        set_request('texte', join('', $plus) . _request('texte'));
528
+    }
529 529
 }
Please login to merge, or discard this patch.
ecrire/auth/ldap.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	$credentials_ldap = ['ldap_dn' => $dn, 'ldap_password' => $pass];
69 69
 
70 70
 	// Si l'utilisateur figure deja dans la base, y recuperer les infos
71
-	$r = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur);
71
+	$r = sql_fetsel('*', 'spip_auteurs', 'login='.sql_quote($login)." AND source='ldap'", '', '', '', '', $serveur);
72 72
 
73 73
 	if ($r) {
74 74
 		return array_merge($r, $credentials_ldap);
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	if ($r) {
93 93
 		return array_merge(
94 94
 			$credentials_ldap,
95
-			sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($r), '', '', '', '', $serveur)
95
+			sql_fetsel('*', 'spip_auteurs', 'id_auteur='.intval($r), '', '', '', '', $serveur)
96 96
 		);
97 97
 	}
98 98
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	$connexion = spip_connect($serveur);
122 122
 	if (!is_array($connexion['ldap'])) {
123 123
 		if ($connexion['authentification']['ldap']) {
124
-			$f = _DIR_CONNECT . $connexion['authentification']['ldap'];
124
+			$f = _DIR_CONNECT.$connexion['authentification']['ldap'];
125 125
 			unset($GLOBALS['ldap_link']);
126 126
 			if (is_readable($f)) {
127 127
 				include_once($f);
@@ -334,7 +334,7 @@  discard block
 block discarded – undo
334 334
 	if (!ldap_bind($link, $dn, session_get('ldap_password'))) {
335 335
 		return false;
336 336
 	}
337
-	$encoded_pass = '{MD5}' . base64_encode(pack('H*', md5($new_pass)));
337
+	$encoded_pass = '{MD5}'.base64_encode(pack('H*', md5($new_pass)));
338 338
 	$success = ldap_mod_replace($link, $dn, ['userPassword' => $encoded_pass]);
339 339
 
340 340
 	return $success;
Please login to merge, or discard this patch.
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 // Authentifie via LDAP et retourne la ligne SQL decrivant l'utilisateur si ok
@@ -24,12 +24,12 @@  discard block
 block discarded – undo
24 24
 // Attributs LDAP correspondants a ceux de SPIP, notamment pour le login
25 25
 // ne pas ecraser une definition perso dans mes_options
26 26
 if (!isset($GLOBALS['ldap_attributes']) or !is_array($GLOBALS['ldap_attributes'])) {
27
-	$GLOBALS['ldap_attributes'] = [
28
-		'login' => ['sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'],
29
-		'nom' => 'cn',
30
-		'email' => 'mail',
31
-		'bio' => 'description'
32
-	];
27
+    $GLOBALS['ldap_attributes'] = [
28
+        'login' => ['sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'],
29
+        'nom' => 'cn',
30
+        'email' => 'mail',
31
+        'bio' => 'description'
32
+    ];
33 33
 }
34 34
 
35 35
 /**
@@ -55,50 +55,50 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function auth_ldap_dist($login, #[\SensitiveParameter] $pass, $serveur = '', $phpauth = false) {
57 57
 
58
-	#spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent"));
59
-
60
-	// Utilisateur connu ?
61
-	// si http auth, inutile de reauthentifier: cela
62
-	// ne marchera pas avec auth http autre que basic.
63
-	$checkpass = isset($_SERVER['REMOTE_USER']) ? false : true;
64
-	if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) {
65
-		return [];
66
-	}
67
-	$credentials_ldap = ['ldap_dn' => $dn, 'ldap_password' => $pass];
68
-
69
-	// Si l'utilisateur figure deja dans la base, y recuperer les infos
70
-	$r = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur);
71
-
72
-	if ($r) {
73
-		return array_merge($r, $credentials_ldap);
74
-	}
75
-
76
-	// sinon importer les infos depuis LDAP,
77
-
78
-	if (
79
-		$GLOBALS['meta']['ldap_statut_import']
80
-		and $desc = auth_ldap_retrouver($dn, [], $serveur)
81
-	) {
82
-		// rajouter le statut indique  a l'install
83
-		$desc['statut'] = $GLOBALS['meta']['ldap_statut_import'];
84
-		$desc['login'] = $login;
85
-		$desc['source'] = 'ldap';
86
-		$desc['pass'] = '';
87
-
88
-		$r = sql_insertq('spip_auteurs', $desc, [], $serveur);
89
-	}
90
-
91
-	if ($r) {
92
-		return array_merge(
93
-			$credentials_ldap,
94
-			sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($r), '', '', '', '', $serveur)
95
-		);
96
-	}
97
-
98
-	// sinon echec
99
-	spip_log("Creation de l'auteur '$login' impossible");
100
-
101
-	return [];
58
+    #spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent"));
59
+
60
+    // Utilisateur connu ?
61
+    // si http auth, inutile de reauthentifier: cela
62
+    // ne marchera pas avec auth http autre que basic.
63
+    $checkpass = isset($_SERVER['REMOTE_USER']) ? false : true;
64
+    if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) {
65
+        return [];
66
+    }
67
+    $credentials_ldap = ['ldap_dn' => $dn, 'ldap_password' => $pass];
68
+
69
+    // Si l'utilisateur figure deja dans la base, y recuperer les infos
70
+    $r = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur);
71
+
72
+    if ($r) {
73
+        return array_merge($r, $credentials_ldap);
74
+    }
75
+
76
+    // sinon importer les infos depuis LDAP,
77
+
78
+    if (
79
+        $GLOBALS['meta']['ldap_statut_import']
80
+        and $desc = auth_ldap_retrouver($dn, [], $serveur)
81
+    ) {
82
+        // rajouter le statut indique  a l'install
83
+        $desc['statut'] = $GLOBALS['meta']['ldap_statut_import'];
84
+        $desc['login'] = $login;
85
+        $desc['source'] = 'ldap';
86
+        $desc['pass'] = '';
87
+
88
+        $r = sql_insertq('spip_auteurs', $desc, [], $serveur);
89
+    }
90
+
91
+    if ($r) {
92
+        return array_merge(
93
+            $credentials_ldap,
94
+            sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($r), '', '', '', '', $serveur)
95
+        );
96
+    }
97
+
98
+    // sinon echec
99
+    spip_log("Creation de l'auteur '$login' impossible");
100
+
101
+    return [];
102 102
 }
103 103
 
104 104
 /**
@@ -112,36 +112,36 @@  discard block
 block discarded – undo
112 112
  * @return array
113 113
  */
114 114
 function auth_ldap_connect($serveur = '') {
115
-	include_spip('base/connect_sql');
116
-	static $connexions_ldap = [];
117
-	if (isset($connexions_ldap[$serveur])) {
118
-		return $connexions_ldap[$serveur];
119
-	}
120
-	$connexion = spip_connect($serveur);
121
-	if (!is_array($connexion['ldap'])) {
122
-		if ($connexion['authentification']['ldap']) {
123
-			$f = _DIR_CONNECT . $connexion['authentification']['ldap'];
124
-			unset($GLOBALS['ldap_link']);
125
-			if (is_readable($f)) {
126
-				include_once($f);
127
-			};
128
-			if (isset($GLOBALS['ldap_link'])) {
129
-				$connexion['ldap'] = [
130
-					'link' => $GLOBALS['ldap_link'],
131
-					'base' => $GLOBALS['ldap_base']
132
-				];
133
-			} else {
134
-				spip_log("connection LDAP $serveur mal definie dans $f");
135
-			}
136
-			if (isset($GLOBALS['ldap_champs'])) {
137
-				$connexion['ldap']['attributes'] = $GLOBALS['ldap_champs'];
138
-			}
139
-		} else {
140
-			spip_log("connection LDAP $serveur inconnue");
141
-		}
142
-	}
143
-
144
-	return $connexions_ldap[$serveur] = $connexion['ldap'];
115
+    include_spip('base/connect_sql');
116
+    static $connexions_ldap = [];
117
+    if (isset($connexions_ldap[$serveur])) {
118
+        return $connexions_ldap[$serveur];
119
+    }
120
+    $connexion = spip_connect($serveur);
121
+    if (!is_array($connexion['ldap'])) {
122
+        if ($connexion['authentification']['ldap']) {
123
+            $f = _DIR_CONNECT . $connexion['authentification']['ldap'];
124
+            unset($GLOBALS['ldap_link']);
125
+            if (is_readable($f)) {
126
+                include_once($f);
127
+            };
128
+            if (isset($GLOBALS['ldap_link'])) {
129
+                $connexion['ldap'] = [
130
+                    'link' => $GLOBALS['ldap_link'],
131
+                    'base' => $GLOBALS['ldap_base']
132
+                ];
133
+            } else {
134
+                spip_log("connection LDAP $serveur mal definie dans $f");
135
+            }
136
+            if (isset($GLOBALS['ldap_champs'])) {
137
+                $connexion['ldap']['attributes'] = $GLOBALS['ldap_champs'];
138
+            }
139
+        } else {
140
+            spip_log("connection LDAP $serveur inconnue");
141
+        }
142
+    }
143
+
144
+    return $connexions_ldap[$serveur] = $connexion['ldap'];
145 145
 }
146 146
 
147 147
 /**
@@ -155,52 +155,52 @@  discard block
 block discarded – undo
155 155
  *    Le login trouvé ou chaine vide si non trouvé
156 156
  */
157 157
 function auth_ldap_search($login, #[\SensitiveParameter] $pass, $checkpass = true, $serveur = '') {
158
-	// Securite anti-injection et contre un serveur LDAP laxiste
159
-	$login_search = preg_replace('/[^-@._\s\d\w]/', '', $login);
160
-	if (!strlen($login_search) or ($checkpass and !strlen($pass))) {
161
-		return '';
162
-	}
163
-
164
-	// verifier la connexion
165
-	if (!$ldap = auth_ldap_connect($serveur)) {
166
-		return '';
167
-	}
168
-
169
-	$ldap_link = $ldap['link'] ?? null;
170
-	$ldap_base = $ldap['base'] ?? null;
171
-	$desc = !empty($ldap['attributes']) ? $ldap['attributes'] : $GLOBALS['ldap_attributes'];
172
-
173
-	$logins = is_array($desc['login']) ? $desc['login'] : [$desc['login']];
174
-
175
-	// Tenter une recherche pour essayer de retrouver le DN
176
-	foreach ($logins as $att) {
177
-		$result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", ['dn']);
178
-		$info = @ldap_get_entries($ldap_link, $result);
179
-		// Ne pas accepter les resultats si plus d'une entree
180
-		// (on veut un attribut unique)
181
-
182
-		if (is_array($info) and $info['count'] == 1) {
183
-			$dn = $info[0]['dn'];
184
-			if (!$checkpass) {
185
-				return $dn;
186
-			}
187
-			if (@ldap_bind($ldap_link, $dn, $pass)) {
188
-				return $dn;
189
-			}
190
-		}
191
-	}
192
-
193
-	if ($checkpass and !isset($dn)) {
194
-		// Si echec, essayer de deviner le DN
195
-		foreach ($logins as $att) {
196
-			$dn = "$att=$login_search, $ldap_base";
197
-			if (@ldap_bind($ldap_link, $dn, $pass)) {
198
-				return "$att=$login_search, $ldap_base";
199
-			}
200
-		}
201
-	}
202
-
203
-	return '';
158
+    // Securite anti-injection et contre un serveur LDAP laxiste
159
+    $login_search = preg_replace('/[^-@._\s\d\w]/', '', $login);
160
+    if (!strlen($login_search) or ($checkpass and !strlen($pass))) {
161
+        return '';
162
+    }
163
+
164
+    // verifier la connexion
165
+    if (!$ldap = auth_ldap_connect($serveur)) {
166
+        return '';
167
+    }
168
+
169
+    $ldap_link = $ldap['link'] ?? null;
170
+    $ldap_base = $ldap['base'] ?? null;
171
+    $desc = !empty($ldap['attributes']) ? $ldap['attributes'] : $GLOBALS['ldap_attributes'];
172
+
173
+    $logins = is_array($desc['login']) ? $desc['login'] : [$desc['login']];
174
+
175
+    // Tenter une recherche pour essayer de retrouver le DN
176
+    foreach ($logins as $att) {
177
+        $result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", ['dn']);
178
+        $info = @ldap_get_entries($ldap_link, $result);
179
+        // Ne pas accepter les resultats si plus d'une entree
180
+        // (on veut un attribut unique)
181
+
182
+        if (is_array($info) and $info['count'] == 1) {
183
+            $dn = $info[0]['dn'];
184
+            if (!$checkpass) {
185
+                return $dn;
186
+            }
187
+            if (@ldap_bind($ldap_link, $dn, $pass)) {
188
+                return $dn;
189
+            }
190
+        }
191
+    }
192
+
193
+    if ($checkpass and !isset($dn)) {
194
+        // Si echec, essayer de deviner le DN
195
+        foreach ($logins as $att) {
196
+            $dn = "$att=$login_search, $ldap_base";
197
+            if (@ldap_bind($ldap_link, $dn, $pass)) {
198
+                return "$att=$login_search, $ldap_base";
199
+            }
200
+        }
201
+    }
202
+
203
+    return '';
204 204
 }
205 205
 
206 206
 /**
@@ -212,40 +212,40 @@  discard block
 block discarded – undo
212 212
  * @return array
213 213
  */
214 214
 function auth_ldap_retrouver($dn, $desc = [], $serveur = '') {
215
-	// Lire les infos sur l'utilisateur a partir de son DN depuis LDAP
215
+    // Lire les infos sur l'utilisateur a partir de son DN depuis LDAP
216 216
 
217
-	if (!$ldap = auth_ldap_connect($serveur)) {
218
-		spip_log("ldap $serveur injoignable");
217
+    if (!$ldap = auth_ldap_connect($serveur)) {
218
+        spip_log("ldap $serveur injoignable");
219 219
 
220
-		return [];
221
-	}
220
+        return [];
221
+    }
222 222
 
223
-	$ldap_link = $ldap['link'];
224
-	if (!$desc) {
225
-		$desc = $ldap['attributes'] ?: $GLOBALS['ldap_attributes'];
226
-		unset($desc['login']);
227
-	}
228
-	$result = @ldap_read($ldap_link, $dn, 'objectClass=*', array_values($desc));
223
+    $ldap_link = $ldap['link'];
224
+    if (!$desc) {
225
+        $desc = $ldap['attributes'] ?: $GLOBALS['ldap_attributes'];
226
+        unset($desc['login']);
227
+    }
228
+    $result = @ldap_read($ldap_link, $dn, 'objectClass=*', array_values($desc));
229 229
 
230
-	if (!$result) {
231
-		return [];
232
-	}
230
+    if (!$result) {
231
+        return [];
232
+    }
233 233
 
234
-	// Recuperer les donnees du premier (unique?) compte de l'auteur
235
-	$val = @ldap_get_entries($ldap_link, $result);
236
-	if (!is_array($val) or !is_array($val[0])) {
237
-		return [];
238
-	}
239
-	$val = $val[0];
234
+    // Recuperer les donnees du premier (unique?) compte de l'auteur
235
+    $val = @ldap_get_entries($ldap_link, $result);
236
+    if (!is_array($val) or !is_array($val[0])) {
237
+        return [];
238
+    }
239
+    $val = $val[0];
240 240
 
241
-	// Convertir depuis UTF-8 (jeu de caracteres par defaut)
242
-	include_spip('inc/charsets');
241
+    // Convertir depuis UTF-8 (jeu de caracteres par defaut)
242
+    include_spip('inc/charsets');
243 243
 
244
-	foreach ($desc as $k => $v) {
245
-		$desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8');
246
-	}
244
+    foreach ($desc as $k => $v) {
245
+        $desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8');
246
+    }
247 247
 
248
-	return $desc;
248
+    return $desc;
249 249
 }
250 250
 
251 251
 
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
  * @return string
258 258
  */
259 259
 function auth_ldap_retrouver_login($login, $serveur = '') {
260
-	return auth_ldap_search($login, '', false, $serveur) ? $login : '';
260
+    return auth_ldap_search($login, '', false, $serveur) ? $login : '';
261 261
 }
262 262
 
263 263
 /**
@@ -277,9 +277,9 @@  discard block
 block discarded – undo
277 277
  *   Message d'erreur si login non valide, chaîne vide sinon
278 278
  */
279 279
 function auth_ldap_verifier_pass($login, #[\SensitiveParameter] $new_pass, $id_auteur = 0, $serveur = '') {
280
-	include_spip('auth/spip');
280
+    include_spip('auth/spip');
281 281
 
282
-	return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur);
282
+    return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur);
283 283
 }
284 284
 
285 285
 /**
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
  *   ```
301 301
  */
302 302
 function auth_ldap_autoriser_modifier_pass($serveur = '') {
303
-	return true;
303
+    return true;
304 304
 }
305 305
 
306 306
 /**
@@ -318,23 +318,23 @@  discard block
 block discarded – undo
318 318
  *    Informe du succès ou de l'echec du changement du mot de passe
319 319
  */
320 320
 function auth_ldap_modifier_pass($login, #[\SensitiveParameter] $new_pass, $id_auteur, $serveur = '') {
321
-	if (is_null($new_pass) or auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') {
322
-		return false;
323
-	}
324
-	if (!$ldap = auth_ldap_connect($serveur)) {
325
-		return false;
326
-	}
327
-	$link = $ldap['link'];
328
-	include_spip('inc/session');
329
-	$dn = session_get('ldap_dn');
330
-	if ('' == $dn) {
331
-		return false;
332
-	}
333
-	if (!ldap_bind($link, $dn, session_get('ldap_password'))) {
334
-		return false;
335
-	}
336
-	$encoded_pass = '{MD5}' . base64_encode(pack('H*', md5($new_pass)));
337
-	$success = ldap_mod_replace($link, $dn, ['userPassword' => $encoded_pass]);
338
-
339
-	return $success;
321
+    if (is_null($new_pass) or auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') {
322
+        return false;
323
+    }
324
+    if (!$ldap = auth_ldap_connect($serveur)) {
325
+        return false;
326
+    }
327
+    $link = $ldap['link'];
328
+    include_spip('inc/session');
329
+    $dn = session_get('ldap_dn');
330
+    if ('' == $dn) {
331
+        return false;
332
+    }
333
+    if (!ldap_bind($link, $dn, session_get('ldap_password'))) {
334
+        return false;
335
+    }
336
+    $encoded_pass = '{MD5}' . base64_encode(pack('H*', md5($new_pass)));
337
+    $success = ldap_mod_replace($link, $dn, ['userPassword' => $encoded_pass]);
338
+
339
+    return $success;
340 340
 }
Please login to merge, or discard this patch.
ecrire/public.php 2 patches
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -21,193 +21,193 @@
 block discarded – undo
21 21
 // par souci de compatiilite).
22 22
 
23 23
 if (isset($GLOBALS['_INC_PUBLIC']) and $GLOBALS['_INC_PUBLIC']) {
24
-	echo recuperer_fond($fond, $contexte_inclus, [], _request('connect') ?? '');
24
+    echo recuperer_fond($fond, $contexte_inclus, [], _request('connect') ?? '');
25 25
 } else {
26
-	$GLOBALS['_INC_PUBLIC'] = 1;
27
-	define('_PIPELINE_SUFFIX', test_espace_prive() ? '_prive' : '');
28
-
29
-	// Faut-il initialiser SPIP ? (oui dans le cas general)
30
-	if (!defined('_DIR_RESTREINT_ABS')) {
31
-		if (
32
-			defined('_DIR_RESTREINT')
33
-			and @file_exists(_ROOT_RESTREINT . 'inc_version.php')
34
-		) {
35
-			include_once _ROOT_RESTREINT . 'inc_version.php';
36
-		} else {
37
-			die('inc_version absent ?');
38
-		}
39
-	} // $fond defini dans le fichier d'appel ?
40
-
41
-	else {
42
-		if (isset($fond) and !_request('fond')) {
43
-		} // fond demande dans l'url par page=xxxx ?
44
-		else {
45
-			if (isset($_GET[_SPIP_PAGE])) {
46
-				$fond = (string)$_GET[_SPIP_PAGE];
47
-
48
-				// Securite
49
-				if (
50
-					strstr($fond, '/')
51
-					and !(
52
-						isset($GLOBALS['visiteur_session']) // pour eviter d'evaluer la suite pour les anonymes
53
-						and include_spip('inc/autoriser')
54
-						and autoriser('webmestre'))
55
-				) {
56
-					include_spip('inc/minipres');
57
-					echo minipres();
58
-					exit;
59
-				}
60
-				// l'argument Page a priorite sur l'argument action
61
-				// le cas se presente a cause des RewriteRule d'Apache
62
-				// qui permettent d'ajouter un argument dans la QueryString
63
-				// mais pas d'en retirer un en conservant les autres.
64
-				if (isset($_GET['action']) and $_GET['action'] === $fond) {
65
-					unset($_GET['action']);
66
-				}
67
-				# sinon, fond par defaut
68
-			} else {
69
-				// sinon fond par defaut (cf. assembler.php)
70
-				$fond = pipeline('detecter_fond_par_defaut', '');
71
-			}
72
-		}
73
-	}
74
-
75
-	$tableau_des_temps = [];
76
-
77
-	// Particularites de certains squelettes
78
-	if ($fond == 'login') {
79
-		$forcer_lang = true;
80
-	}
81
-
82
-	if (
83
-		isset($forcer_lang) and $forcer_lang and ($forcer_lang !== 'non')
84
-		and !_request('action')
85
-		and $_SERVER['REQUEST_METHOD'] != 'POST'
86
-	) {
87
-		include_spip('inc/lang');
88
-		verifier_lang_url();
89
-	}
90
-
91
-	$lang = !isset($_GET['lang']) ? '' : lang_select($_GET['lang']);
92
-
93
-	// Charger l'aiguilleur des traitements derogatoires
94
-	// (action en base SQL, formulaires CVT, AJax)
95
-	if (_request('action') or _request('var_ajax') or _request('formulaire_action')) {
96
-		include_spip('public/aiguiller');
97
-		if (
98
-			// cas des appels actions ?action=xxx
99
-			traiter_appels_actions()
100
-			or
101
-			// cas des hits ajax sur les inclusions ajax
102
-			traiter_appels_inclusions_ajax()
103
-			or
104
-			// cas des formulaires charger/verifier/traiter
105
-			traiter_formulaires_dynamiques()
106
-		) {
107
-			// lancer les taches sur affichage final, comme le cron
108
-			// mais sans rien afficher
109
-			$GLOBALS['html'] = false; // ne rien afficher
110
-			pipeline('affichage_final' . _PIPELINE_SUFFIX, '');
111
-			exit; // le hit est fini !
112
-		}
113
-	}
114
-
115
-	// Il y a du texte a produire, charger le metteur en page
116
-	include_spip('public/assembler');
117
-	$page = assembler($fond, _request('connect') ?? '');
118
-
119
-	if (isset($page['status'])) {
120
-		include_spip('inc/headers');
121
-		http_response_code($page['status']);
122
-	}
123
-
124
-	// Content-Type ?
125
-	if (!isset($page['entetes']['Content-Type'])) {
126
-		$charset = $GLOBALS['meta']['charset'] ?? 'utf-8';
127
-		$page['entetes']['Content-Type'] = 'text/html; charset=' . $charset;
128
-		$html = true;
129
-	} else {
130
-		$html = preg_match(',^\s*text/html,', $page['entetes']['Content-Type']);
131
-	}
132
-
133
-	// Tester si on est admin et il y a des choses supplementaires a dire
134
-	// type tableau pour y mettre des choses au besoin.
135
-	$debug = ((_request('var_mode') == 'debug') or $tableau_des_temps) ? [1] : [];
136
-
137
-	// affiche-t-on les boutons d'administration ? voir f_admin()
138
-	$affiche_boutons_admin = ($html and (
139
-			(isset($_COOKIE['spip_admin']) and (!isset($flag_preserver) or !$flag_preserver))
140
-			or ($debug and include_spip('inc/autoriser') and autoriser('debug'))
141
-			or (defined('_VAR_PREVIEW') and _VAR_PREVIEW)
142
-		));
143
-
144
-	if ($affiche_boutons_admin) {
145
-		include_spip('balise/formulaire_admin');
146
-	}
147
-
148
-
149
-	// Execution de la page calculee
150
-
151
-	// traitements sur les entetes avant envoi
152
-	// peut servir pour le plugin de stats
153
-	$page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']);
154
-
155
-
156
-	// eval $page et affecte $res
157
-	include _ROOT_RESTREINT . 'public/evaluer_page.php';
158
-	envoyer_entetes($page['entetes']);
159
-	if ($res === false) {
160
-		include_spip('inc/autoriser');
161
-		$err = _T('zbug_erreur_execution_page');
162
-		if (autoriser('webmestre')) {
163
-			$err .= "\n<hr />\n"
164
-				. highlight_string($page['codephp'], true)
165
-				. "\n<hr />\n";
166
-		}
167
-		$msg = [$err];
168
-		erreur_squelette($msg);
169
-	}
170
-
171
-	//
172
-	// Envoyer le resultat apres post-traitements
173
-	//
174
-	// (c'est ici qu'on fait var_recherche, validation, boutons d'admin,
175
-	// cf. public/assembler.php)
176
-	echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']);
177
-
178
-	if ($lang) {
179
-		lang_select();
180
-	}
181
-	// l'affichage de la page a pu lever des erreurs (inclusion manquante)
182
-	// il faut tester a nouveau
183
-	$debug = ((_request('var_mode') == 'debug') or $tableau_des_temps) ? [1] : [];
184
-
185
-	// Appel au debusqueur en cas d'erreurs ou de demande de trace
186
-	// at last
187
-	if ($debug) {
188
-		// en cas d'erreur, retester l'affichage
189
-		if ($html and ($affiche_boutons_admin or $debug)) {
190
-			$var_mode_affiche = _request('var_mode_affiche');
191
-			$var_mode_objet = _request('var_mode_objet');
192
-			$GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : '');
193
-			echo erreur_squelette(false);
194
-		}
195
-	} else {
196
-		if (
197
-			isset($GLOBALS['meta']['date_prochain_postdate'])
198
-			and $GLOBALS['meta']['date_prochain_postdate'] <= time()
199
-		) {
200
-			include_spip('inc/rubriques');
201
-			calculer_prochain_postdate(true);
202
-		}
203
-
204
-		// Effectuer une tache de fond ?
205
-		// si _DIRECT_CRON_FORCE est present, on force l'appel
206
-		if (defined('_DIRECT_CRON_FORCE')) {
207
-			cron();
208
-		}
209
-
210
-		// sauver le cache chemin si necessaire
211
-		save_path_cache();
212
-	}
26
+    $GLOBALS['_INC_PUBLIC'] = 1;
27
+    define('_PIPELINE_SUFFIX', test_espace_prive() ? '_prive' : '');
28
+
29
+    // Faut-il initialiser SPIP ? (oui dans le cas general)
30
+    if (!defined('_DIR_RESTREINT_ABS')) {
31
+        if (
32
+            defined('_DIR_RESTREINT')
33
+            and @file_exists(_ROOT_RESTREINT . 'inc_version.php')
34
+        ) {
35
+            include_once _ROOT_RESTREINT . 'inc_version.php';
36
+        } else {
37
+            die('inc_version absent ?');
38
+        }
39
+    } // $fond defini dans le fichier d'appel ?
40
+
41
+    else {
42
+        if (isset($fond) and !_request('fond')) {
43
+        } // fond demande dans l'url par page=xxxx ?
44
+        else {
45
+            if (isset($_GET[_SPIP_PAGE])) {
46
+                $fond = (string)$_GET[_SPIP_PAGE];
47
+
48
+                // Securite
49
+                if (
50
+                    strstr($fond, '/')
51
+                    and !(
52
+                        isset($GLOBALS['visiteur_session']) // pour eviter d'evaluer la suite pour les anonymes
53
+                        and include_spip('inc/autoriser')
54
+                        and autoriser('webmestre'))
55
+                ) {
56
+                    include_spip('inc/minipres');
57
+                    echo minipres();
58
+                    exit;
59
+                }
60
+                // l'argument Page a priorite sur l'argument action
61
+                // le cas se presente a cause des RewriteRule d'Apache
62
+                // qui permettent d'ajouter un argument dans la QueryString
63
+                // mais pas d'en retirer un en conservant les autres.
64
+                if (isset($_GET['action']) and $_GET['action'] === $fond) {
65
+                    unset($_GET['action']);
66
+                }
67
+                # sinon, fond par defaut
68
+            } else {
69
+                // sinon fond par defaut (cf. assembler.php)
70
+                $fond = pipeline('detecter_fond_par_defaut', '');
71
+            }
72
+        }
73
+    }
74
+
75
+    $tableau_des_temps = [];
76
+
77
+    // Particularites de certains squelettes
78
+    if ($fond == 'login') {
79
+        $forcer_lang = true;
80
+    }
81
+
82
+    if (
83
+        isset($forcer_lang) and $forcer_lang and ($forcer_lang !== 'non')
84
+        and !_request('action')
85
+        and $_SERVER['REQUEST_METHOD'] != 'POST'
86
+    ) {
87
+        include_spip('inc/lang');
88
+        verifier_lang_url();
89
+    }
90
+
91
+    $lang = !isset($_GET['lang']) ? '' : lang_select($_GET['lang']);
92
+
93
+    // Charger l'aiguilleur des traitements derogatoires
94
+    // (action en base SQL, formulaires CVT, AJax)
95
+    if (_request('action') or _request('var_ajax') or _request('formulaire_action')) {
96
+        include_spip('public/aiguiller');
97
+        if (
98
+            // cas des appels actions ?action=xxx
99
+            traiter_appels_actions()
100
+            or
101
+            // cas des hits ajax sur les inclusions ajax
102
+            traiter_appels_inclusions_ajax()
103
+            or
104
+            // cas des formulaires charger/verifier/traiter
105
+            traiter_formulaires_dynamiques()
106
+        ) {
107
+            // lancer les taches sur affichage final, comme le cron
108
+            // mais sans rien afficher
109
+            $GLOBALS['html'] = false; // ne rien afficher
110
+            pipeline('affichage_final' . _PIPELINE_SUFFIX, '');
111
+            exit; // le hit est fini !
112
+        }
113
+    }
114
+
115
+    // Il y a du texte a produire, charger le metteur en page
116
+    include_spip('public/assembler');
117
+    $page = assembler($fond, _request('connect') ?? '');
118
+
119
+    if (isset($page['status'])) {
120
+        include_spip('inc/headers');
121
+        http_response_code($page['status']);
122
+    }
123
+
124
+    // Content-Type ?
125
+    if (!isset($page['entetes']['Content-Type'])) {
126
+        $charset = $GLOBALS['meta']['charset'] ?? 'utf-8';
127
+        $page['entetes']['Content-Type'] = 'text/html; charset=' . $charset;
128
+        $html = true;
129
+    } else {
130
+        $html = preg_match(',^\s*text/html,', $page['entetes']['Content-Type']);
131
+    }
132
+
133
+    // Tester si on est admin et il y a des choses supplementaires a dire
134
+    // type tableau pour y mettre des choses au besoin.
135
+    $debug = ((_request('var_mode') == 'debug') or $tableau_des_temps) ? [1] : [];
136
+
137
+    // affiche-t-on les boutons d'administration ? voir f_admin()
138
+    $affiche_boutons_admin = ($html and (
139
+            (isset($_COOKIE['spip_admin']) and (!isset($flag_preserver) or !$flag_preserver))
140
+            or ($debug and include_spip('inc/autoriser') and autoriser('debug'))
141
+            or (defined('_VAR_PREVIEW') and _VAR_PREVIEW)
142
+        ));
143
+
144
+    if ($affiche_boutons_admin) {
145
+        include_spip('balise/formulaire_admin');
146
+    }
147
+
148
+
149
+    // Execution de la page calculee
150
+
151
+    // traitements sur les entetes avant envoi
152
+    // peut servir pour le plugin de stats
153
+    $page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']);
154
+
155
+
156
+    // eval $page et affecte $res
157
+    include _ROOT_RESTREINT . 'public/evaluer_page.php';
158
+    envoyer_entetes($page['entetes']);
159
+    if ($res === false) {
160
+        include_spip('inc/autoriser');
161
+        $err = _T('zbug_erreur_execution_page');
162
+        if (autoriser('webmestre')) {
163
+            $err .= "\n<hr />\n"
164
+                . highlight_string($page['codephp'], true)
165
+                . "\n<hr />\n";
166
+        }
167
+        $msg = [$err];
168
+        erreur_squelette($msg);
169
+    }
170
+
171
+    //
172
+    // Envoyer le resultat apres post-traitements
173
+    //
174
+    // (c'est ici qu'on fait var_recherche, validation, boutons d'admin,
175
+    // cf. public/assembler.php)
176
+    echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']);
177
+
178
+    if ($lang) {
179
+        lang_select();
180
+    }
181
+    // l'affichage de la page a pu lever des erreurs (inclusion manquante)
182
+    // il faut tester a nouveau
183
+    $debug = ((_request('var_mode') == 'debug') or $tableau_des_temps) ? [1] : [];
184
+
185
+    // Appel au debusqueur en cas d'erreurs ou de demande de trace
186
+    // at last
187
+    if ($debug) {
188
+        // en cas d'erreur, retester l'affichage
189
+        if ($html and ($affiche_boutons_admin or $debug)) {
190
+            $var_mode_affiche = _request('var_mode_affiche');
191
+            $var_mode_objet = _request('var_mode_objet');
192
+            $GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : '');
193
+            echo erreur_squelette(false);
194
+        }
195
+    } else {
196
+        if (
197
+            isset($GLOBALS['meta']['date_prochain_postdate'])
198
+            and $GLOBALS['meta']['date_prochain_postdate'] <= time()
199
+        ) {
200
+            include_spip('inc/rubriques');
201
+            calculer_prochain_postdate(true);
202
+        }
203
+
204
+        // Effectuer une tache de fond ?
205
+        // si _DIRECT_CRON_FORCE est present, on force l'appel
206
+        if (defined('_DIRECT_CRON_FORCE')) {
207
+            cron();
208
+        }
209
+
210
+        // sauver le cache chemin si necessaire
211
+        save_path_cache();
212
+    }
213 213
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -30,9 +30,9 @@  discard block
 block discarded – undo
30 30
 	if (!defined('_DIR_RESTREINT_ABS')) {
31 31
 		if (
32 32
 			defined('_DIR_RESTREINT')
33
-			and @file_exists(_ROOT_RESTREINT . 'inc_version.php')
33
+			and @file_exists(_ROOT_RESTREINT.'inc_version.php')
34 34
 		) {
35
-			include_once _ROOT_RESTREINT . 'inc_version.php';
35
+			include_once _ROOT_RESTREINT.'inc_version.php';
36 36
 		} else {
37 37
 			die('inc_version absent ?');
38 38
 		}
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 		} // fond demande dans l'url par page=xxxx ?
44 44
 		else {
45 45
 			if (isset($_GET[_SPIP_PAGE])) {
46
-				$fond = (string)$_GET[_SPIP_PAGE];
46
+				$fond = (string) $_GET[_SPIP_PAGE];
47 47
 
48 48
 				// Securite
49 49
 				if (
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 			// lancer les taches sur affichage final, comme le cron
108 108
 			// mais sans rien afficher
109 109
 			$GLOBALS['html'] = false; // ne rien afficher
110
-			pipeline('affichage_final' . _PIPELINE_SUFFIX, '');
110
+			pipeline('affichage_final'._PIPELINE_SUFFIX, '');
111 111
 			exit; // le hit est fini !
112 112
 		}
113 113
 	}
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	// Content-Type ?
125 125
 	if (!isset($page['entetes']['Content-Type'])) {
126 126
 		$charset = $GLOBALS['meta']['charset'] ?? 'utf-8';
127
-		$page['entetes']['Content-Type'] = 'text/html; charset=' . $charset;
127
+		$page['entetes']['Content-Type'] = 'text/html; charset='.$charset;
128 128
 		$html = true;
129 129
 	} else {
130 130
 		$html = preg_match(',^\s*text/html,', $page['entetes']['Content-Type']);
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
 
151 151
 	// traitements sur les entetes avant envoi
152 152
 	// peut servir pour le plugin de stats
153
-	$page['entetes'] = pipeline('affichage_entetes_final' . _PIPELINE_SUFFIX, $page['entetes']);
153
+	$page['entetes'] = pipeline('affichage_entetes_final'._PIPELINE_SUFFIX, $page['entetes']);
154 154
 
155 155
 
156 156
 	// eval $page et affecte $res
157
-	include _ROOT_RESTREINT . 'public/evaluer_page.php';
157
+	include _ROOT_RESTREINT.'public/evaluer_page.php';
158 158
 	envoyer_entetes($page['entetes']);
159 159
 	if ($res === false) {
160 160
 		include_spip('inc/autoriser');
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 	//
174 174
 	// (c'est ici qu'on fait var_recherche, validation, boutons d'admin,
175 175
 	// cf. public/assembler.php)
176
-	echo pipeline('affichage_final' . _PIPELINE_SUFFIX, $page['texte']);
176
+	echo pipeline('affichage_final'._PIPELINE_SUFFIX, $page['texte']);
177 177
 
178 178
 	if ($lang) {
179 179
 		lang_select();
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		if ($html and ($affiche_boutons_admin or $debug)) {
190 190
 			$var_mode_affiche = _request('var_mode_affiche');
191 191
 			$var_mode_objet = _request('var_mode_objet');
192
-			$GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet . 'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : '');
192
+			$GLOBALS['debug_objets'][$var_mode_affiche][$var_mode_objet.'tout'] = ($var_mode_affiche == 'validation' ? $page['texte'] : '');
193 193
 			echo erreur_squelette(false);
194 194
 		}
195 195
 	} else {
Please login to merge, or discard this patch.
ecrire/plugins/extraire_pipelines.php 1 patch
Indentation   +24 added lines, -24 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
 
@@ -21,28 +21,28 @@  discard block
 block discarded – undo
21 21
  * @param array $arbre
22 22
  */
23 23
 function plugins_extraire_pipelines_dist(&$arbre) {
24
-	$pipes = null;
25
-	$tag = null;
26
-	$pipeline = [];
27
-	if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) {
28
-		foreach ($pipes as $tag => $p) {
29
-			if (!is_array($p[0])) {
30
-				[$tag, $att] = spip_xml_decompose_tag($tag);
31
-				$pipeline[] = $att;
32
-			} else {
33
-				foreach ($p as $pipe) {
34
-					$att = [];
35
-					if (is_array($pipe)) {
36
-						foreach ($pipe as $k => $t) {
37
-							$att[$k] = trim(end($t));
38
-						}
39
-					}
40
-					$pipeline[] = $att;
41
-				}
42
-			}
43
-		}
44
-		unset($arbre[$tag]);
45
-	}
24
+    $pipes = null;
25
+    $tag = null;
26
+    $pipeline = [];
27
+    if (spip_xml_match_nodes(',^pipeline,', $arbre, $pipes)) {
28
+        foreach ($pipes as $tag => $p) {
29
+            if (!is_array($p[0])) {
30
+                [$tag, $att] = spip_xml_decompose_tag($tag);
31
+                $pipeline[] = $att;
32
+            } else {
33
+                foreach ($p as $pipe) {
34
+                    $att = [];
35
+                    if (is_array($pipe)) {
36
+                        foreach ($pipe as $k => $t) {
37
+                            $att[$k] = trim(end($t));
38
+                        }
39
+                    }
40
+                    $pipeline[] = $att;
41
+                }
42
+            }
43
+        }
44
+        unset($arbre[$tag]);
45
+    }
46 46
 
47
-	return $pipeline;
47
+    return $pipeline;
48 48
 }
Please login to merge, or discard this patch.
ecrire/maj/legacy/v30.php 2 patches
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
  * @package SPIP\Core\SQL\Upgrade
19 19
  **/
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 
24 24
 
25 25
 $GLOBALS['maj'][16428] = [
26
-	['maj_liens', 'auteur'], // creer la table liens
27
-	['maj_liens', 'auteur', 'article'],
28
-	['sql_drop_table', 'spip_auteurs_articles'],
29
-	['maj_liens', 'auteur', 'rubrique'],
30
-	['sql_drop_table', 'spip_auteurs_rubriques'],
31
-	['maj_liens', 'auteur', 'message'],
32
-	['sql_drop_table', 'spip_auteurs_messages'],
26
+    ['maj_liens', 'auteur'], // creer la table liens
27
+    ['maj_liens', 'auteur', 'article'],
28
+    ['sql_drop_table', 'spip_auteurs_articles'],
29
+    ['maj_liens', 'auteur', 'rubrique'],
30
+    ['sql_drop_table', 'spip_auteurs_rubriques'],
31
+    ['maj_liens', 'auteur', 'message'],
32
+    ['sql_drop_table', 'spip_auteurs_messages'],
33 33
 ];
34 34
 
35 35
 /**
@@ -55,89 +55,89 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function maj_liens($pivot, $l = '') {
57 57
 
58
-	@define('_LOG_FILTRE_GRAVITE', 8);
59
-
60
-	$exceptions_pluriel = ['forum' => 'forum', 'syndic' => 'syndic'];
61
-
62
-	$pivot = preg_replace(',[^\w],', '', $pivot); // securite
63
-	$pivots = ($exceptions_pluriel[$pivot] ?? $pivot . 's');
64
-	$liens = 'spip_' . $pivots . '_liens';
65
-	$id_pivot = 'id_' . $pivot;
66
-	// Creer spip_auteurs_liens
67
-	global $tables_auxiliaires;
68
-	if (!$l) {
69
-		include_spip('base/auxiliaires');
70
-		include_spip('base/create');
71
-		creer_ou_upgrader_table($liens, $tables_auxiliaires[$liens], false);
72
-	} else {
73
-		// Preparer
74
-		$l = preg_replace(',[^\w],', '', $l); // securite
75
-		$primary = "id_$l";
76
-		$objet = ($l == 'syndic' ? 'site' : $l);
77
-		$ls = ($exceptions_pluriel[$l] ?? $l . 's');
78
-		$ancienne_table = 'spip_' . $pivots . '_' . $ls;
79
-		$pool = 400;
80
-
81
-		$trouver_table = charger_fonction('trouver_table', 'base');
82
-		if (!$desc = $trouver_table($ancienne_table)) {
83
-			return;
84
-		}
85
-
86
-		// securite pour ne pas perdre de donnees
87
-		if (!$trouver_table($liens)) {
88
-			return;
89
-		}
90
-
91
-		$champs = $desc['field'];
92
-		if (isset($champs['maj'])) {
93
-			unset($champs['maj']);
94
-		}
95
-		if (isset($champs[$primary])) {
96
-			unset($champs[$primary]);
97
-		}
98
-
99
-		$champs = array_keys($champs);
100
-		// ne garder que les champs qui existent sur la table destination
101
-		if ($desc_cible = $trouver_table($liens)) {
102
-			$champs = array_intersect($champs, array_keys($desc_cible['field']));
103
-		}
104
-
105
-		$champs[] = "$primary as id_objet";
106
-		$champs[] = "'$objet' as objet";
107
-		$champs = implode(', ', $champs);
108
-
109
-		// Recopier les donnees
110
-		$sub_pool = 100;
111
-		while ($ids = array_map('reset', sql_allfetsel("$primary", $ancienne_table, '', '', '', "0,$sub_pool"))) {
112
-			$insert = [];
113
-			foreach ($ids as $id) {
114
-				$n = sql_countsel($liens, "objet='$objet' AND id_objet=" . intval($id));
115
-				while ($t = sql_allfetsel($champs, $ancienne_table, "$primary=" . intval($id), '', $id_pivot, "$n,$pool")) {
116
-					$n += is_countable($t) ? count($t) : 0;
117
-					// empiler en s'assurant a minima de l'unicite
118
-					while ($r = array_shift($t)) {
119
-						$insert[$r[$id_pivot] . ':' . $r['id_objet']] = $r;
120
-					}
121
-					if (count($insert) >= $sub_pool) {
122
-						maj_liens_insertq_multi_check($liens, $insert, $tables_auxiliaires[$liens]);
123
-						$insert = [];
124
-					}
125
-					// si timeout, sortir, la relance nous ramenera dans cette fonction
126
-					// et on verifiera/repartira de la
127
-					if (time() >= _TIME_OUT) {
128
-						return;
129
-					}
130
-				}
131
-				if (time() >= _TIME_OUT) {
132
-					return;
133
-				}
134
-			}
135
-			if (count($insert)) {
136
-				maj_liens_insertq_multi_check($liens, $insert, $tables_auxiliaires[$liens]);
137
-			}
138
-			sql_delete($ancienne_table, sql_in($primary, $ids));
139
-		}
140
-	}
58
+    @define('_LOG_FILTRE_GRAVITE', 8);
59
+
60
+    $exceptions_pluriel = ['forum' => 'forum', 'syndic' => 'syndic'];
61
+
62
+    $pivot = preg_replace(',[^\w],', '', $pivot); // securite
63
+    $pivots = ($exceptions_pluriel[$pivot] ?? $pivot . 's');
64
+    $liens = 'spip_' . $pivots . '_liens';
65
+    $id_pivot = 'id_' . $pivot;
66
+    // Creer spip_auteurs_liens
67
+    global $tables_auxiliaires;
68
+    if (!$l) {
69
+        include_spip('base/auxiliaires');
70
+        include_spip('base/create');
71
+        creer_ou_upgrader_table($liens, $tables_auxiliaires[$liens], false);
72
+    } else {
73
+        // Preparer
74
+        $l = preg_replace(',[^\w],', '', $l); // securite
75
+        $primary = "id_$l";
76
+        $objet = ($l == 'syndic' ? 'site' : $l);
77
+        $ls = ($exceptions_pluriel[$l] ?? $l . 's');
78
+        $ancienne_table = 'spip_' . $pivots . '_' . $ls;
79
+        $pool = 400;
80
+
81
+        $trouver_table = charger_fonction('trouver_table', 'base');
82
+        if (!$desc = $trouver_table($ancienne_table)) {
83
+            return;
84
+        }
85
+
86
+        // securite pour ne pas perdre de donnees
87
+        if (!$trouver_table($liens)) {
88
+            return;
89
+        }
90
+
91
+        $champs = $desc['field'];
92
+        if (isset($champs['maj'])) {
93
+            unset($champs['maj']);
94
+        }
95
+        if (isset($champs[$primary])) {
96
+            unset($champs[$primary]);
97
+        }
98
+
99
+        $champs = array_keys($champs);
100
+        // ne garder que les champs qui existent sur la table destination
101
+        if ($desc_cible = $trouver_table($liens)) {
102
+            $champs = array_intersect($champs, array_keys($desc_cible['field']));
103
+        }
104
+
105
+        $champs[] = "$primary as id_objet";
106
+        $champs[] = "'$objet' as objet";
107
+        $champs = implode(', ', $champs);
108
+
109
+        // Recopier les donnees
110
+        $sub_pool = 100;
111
+        while ($ids = array_map('reset', sql_allfetsel("$primary", $ancienne_table, '', '', '', "0,$sub_pool"))) {
112
+            $insert = [];
113
+            foreach ($ids as $id) {
114
+                $n = sql_countsel($liens, "objet='$objet' AND id_objet=" . intval($id));
115
+                while ($t = sql_allfetsel($champs, $ancienne_table, "$primary=" . intval($id), '', $id_pivot, "$n,$pool")) {
116
+                    $n += is_countable($t) ? count($t) : 0;
117
+                    // empiler en s'assurant a minima de l'unicite
118
+                    while ($r = array_shift($t)) {
119
+                        $insert[$r[$id_pivot] . ':' . $r['id_objet']] = $r;
120
+                    }
121
+                    if (count($insert) >= $sub_pool) {
122
+                        maj_liens_insertq_multi_check($liens, $insert, $tables_auxiliaires[$liens]);
123
+                        $insert = [];
124
+                    }
125
+                    // si timeout, sortir, la relance nous ramenera dans cette fonction
126
+                    // et on verifiera/repartira de la
127
+                    if (time() >= _TIME_OUT) {
128
+                        return;
129
+                    }
130
+                }
131
+                if (time() >= _TIME_OUT) {
132
+                    return;
133
+                }
134
+            }
135
+            if (count($insert)) {
136
+                maj_liens_insertq_multi_check($liens, $insert, $tables_auxiliaires[$liens]);
137
+            }
138
+            sql_delete($ancienne_table, sql_in($primary, $ids));
139
+        }
140
+    }
141 141
 }
142 142
 
143 143
 /**
@@ -151,86 +151,86 @@  discard block
 block discarded – undo
151 151
  * @return void
152 152
  **/
153 153
 function maj_liens_insertq_multi_check($table, $couples, $desc = []) {
154
-	$n_before = sql_countsel($table);
155
-	sql_insertq_multi($table, $couples, $desc);
156
-	$n_after = sql_countsel($table);
157
-	if (($n_after - $n_before) == count($couples)) {
158
-		return;
159
-	}
160
-	// si ecart, on recommence l'insertion ligne par ligne...
161
-	// moins rapide mais secure : seul le couple en doublon echouera, et non toute la serie
162
-	foreach ($couples as $c) {
163
-		sql_insertq($table, $c, $desc);
164
-	}
154
+    $n_before = sql_countsel($table);
155
+    sql_insertq_multi($table, $couples, $desc);
156
+    $n_after = sql_countsel($table);
157
+    if (($n_after - $n_before) == count($couples)) {
158
+        return;
159
+    }
160
+    // si ecart, on recommence l'insertion ligne par ligne...
161
+    // moins rapide mais secure : seul le couple en doublon echouera, et non toute la serie
162
+    foreach ($couples as $c) {
163
+        sql_insertq($table, $c, $desc);
164
+    }
165 165
 }
166 166
 
167 167
 $GLOBALS['maj'][17311] = [
168
-	[
169
-		'ecrire_meta',
170
-		'multi_objets',
171
-		implode(
172
-			',',
173
-			array_diff(
174
-				[
175
-					(isset($GLOBALS['meta']['multi_rubriques']) and $GLOBALS['meta']['multi_rubriques'] == 'oui')
176
-						? 'spip_rubriques' : '',
177
-					(isset($GLOBALS['meta']['multi_articles']) and $GLOBALS['meta']['multi_articles'] == 'oui')
178
-						? 'spip_articles' : ''
179
-				],
180
-				['']
181
-			)
182
-		)
183
-	],
184
-	[
185
-		'ecrire_meta',
186
-		'gerer_trad_objets',
187
-		implode(
188
-			',',
189
-			array_diff(
190
-				[
191
-					(isset($GLOBALS['meta']['gerer_trad']) and $GLOBALS['meta']['gerer_trad'] == 'oui')
192
-						? 'spip_articles' : ''
193
-				],
194
-				['']
195
-			)
196
-		)
197
-	],
168
+    [
169
+        'ecrire_meta',
170
+        'multi_objets',
171
+        implode(
172
+            ',',
173
+            array_diff(
174
+                [
175
+                    (isset($GLOBALS['meta']['multi_rubriques']) and $GLOBALS['meta']['multi_rubriques'] == 'oui')
176
+                        ? 'spip_rubriques' : '',
177
+                    (isset($GLOBALS['meta']['multi_articles']) and $GLOBALS['meta']['multi_articles'] == 'oui')
178
+                        ? 'spip_articles' : ''
179
+                ],
180
+                ['']
181
+            )
182
+        )
183
+    ],
184
+    [
185
+        'ecrire_meta',
186
+        'gerer_trad_objets',
187
+        implode(
188
+            ',',
189
+            array_diff(
190
+                [
191
+                    (isset($GLOBALS['meta']['gerer_trad']) and $GLOBALS['meta']['gerer_trad'] == 'oui')
192
+                        ? 'spip_articles' : ''
193
+                ],
194
+                ['']
195
+            )
196
+        )
197
+    ],
198 198
 ];
199 199
 $GLOBALS['maj'][17555] = [
200
-	['sql_alter', "TABLE spip_resultats ADD table_objet varchar(30) DEFAULT '' NOT NULL"],
201
-	['sql_alter', "TABLE spip_resultats ADD serveur char(16) DEFAULT '' NOT NULL"],
200
+    ['sql_alter', "TABLE spip_resultats ADD table_objet varchar(30) DEFAULT '' NOT NULL"],
201
+    ['sql_alter', "TABLE spip_resultats ADD serveur char(16) DEFAULT '' NOT NULL"],
202 202
 ];
203 203
 
204 204
 $GLOBALS['maj'][17563] = [
205
-	['sql_alter', "TABLE spip_articles ADD virtuel VARCHAR(255) DEFAULT '' NOT NULL"],
206
-	['sql_update', 'spip_articles', ['virtuel' => 'SUBSTRING(chapo,2)', 'chapo' => "''"], "chapo LIKE '=_%'"],
205
+    ['sql_alter', "TABLE spip_articles ADD virtuel VARCHAR(255) DEFAULT '' NOT NULL"],
206
+    ['sql_update', 'spip_articles', ['virtuel' => 'SUBSTRING(chapo,2)', 'chapo' => "''"], "chapo LIKE '=_%'"],
207 207
 ];
208 208
 
209 209
 $GLOBALS['maj'][17577] = [
210
-	['maj_tables', ['spip_jobs', 'spip_jobs_liens']],
210
+    ['maj_tables', ['spip_jobs', 'spip_jobs_liens']],
211 211
 ];
212 212
 
213 213
 $GLOBALS['maj'][17743] = [
214
-	['sql_update', 'spip_auteurs', ['prefs' => 'bio', 'bio' => "''"], "statut='nouveau' AND bio<>''"],
214
+    ['sql_update', 'spip_auteurs', ['prefs' => 'bio', 'bio' => "''"], "statut='nouveau' AND bio<>''"],
215 215
 ];
216 216
 
217 217
 $GLOBALS['maj'][18219] = [
218
-	['sql_alter', 'TABLE spip_rubriques DROP id_import'],
219
-	['sql_alter', 'TABLE spip_rubriques DROP export'],
218
+    ['sql_alter', 'TABLE spip_rubriques DROP id_import'],
219
+    ['sql_alter', 'TABLE spip_rubriques DROP export'],
220 220
 ];
221 221
 
222 222
 $GLOBALS['maj'][18310] = [
223
-	['sql_alter', "TABLE spip_auteurs_liens CHANGE vu vu VARCHAR(6) DEFAULT 'non' NOT NULL"],
223
+    ['sql_alter', "TABLE spip_auteurs_liens CHANGE vu vu VARCHAR(6) DEFAULT 'non' NOT NULL"],
224 224
 ];
225 225
 
226 226
 $GLOBALS['maj'][18597] = [
227
-	['sql_alter', "TABLE spip_rubriques ADD profondeur smallint(5) DEFAULT '0' NOT NULL"],
228
-	['maj_propager_les_secteurs'],
227
+    ['sql_alter', "TABLE spip_rubriques ADD profondeur smallint(5) DEFAULT '0' NOT NULL"],
228
+    ['maj_propager_les_secteurs'],
229 229
 ];
230 230
 
231 231
 $GLOBALS['maj'][18955] = [
232
-	['sql_alter', 'TABLE spip_auteurs_liens ADD INDEX id_objet (id_objet)'],
233
-	['sql_alter', 'TABLE spip_auteurs_liens ADD INDEX objet (objet)'],
232
+    ['sql_alter', 'TABLE spip_auteurs_liens ADD INDEX id_objet (id_objet)'],
233
+    ['sql_alter', 'TABLE spip_auteurs_liens ADD INDEX objet (objet)'],
234 234
 ];
235 235
 
236 236
 /**
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
  * @uses propager_les_secteurs()
240 240
  **/
241 241
 function maj_propager_les_secteurs() {
242
-	include_spip('inc/rubriques');
243
-	propager_les_secteurs();
242
+    include_spip('inc/rubriques');
243
+    propager_les_secteurs();
244 244
 }
245 245
 
246 246
 /**
@@ -253,87 +253,87 @@  discard block
 block discarded – undo
253 253
 function maj_collation_sqlite() {
254 254
 
255 255
 
256
-	include_spip('base/dump');
257
-	$tables = base_lister_toutes_tables();
258
-
259
-	// rien a faire si base non sqlite
260
-	if (strncmp($GLOBALS['connexions'][0]['type'], 'sqlite', 6) !== 0) {
261
-		return;
262
-	}
263
-
264
-	$trouver_table = charger_fonction('trouver_table', 'base');
265
-	// forcer le vidage de cache
266
-	$trouver_table('');
267
-
268
-	// cas particulier spip_auteurs : retablir le collate binary sur le login
269
-	$desc = $trouver_table('spip_auteurs');
270
-	spip_log('spip_auteurs : ' . var_export($desc['field'], true), 'maj.' . _LOG_INFO_IMPORTANTE);
271
-	if (stripos($desc['field']['login'], 'BINARY') === false) {
272
-		spip_log('Retablir champ login BINARY sur table spip_auteurs', 'maj');
273
-		sql_alter('table spip_auteurs change login login VARCHAR(255) BINARY');
274
-		$trouver_table('');
275
-		$new_desc = $trouver_table('spip_auteurs');
276
-		spip_log('Apres conversion spip_auteurs : ' . var_export($new_desc['field'], true), 'maj.' . _LOG_INFO_IMPORTANTE);
277
-	}
278
-
279
-	foreach ($tables as $table) {
280
-		if (time() >= _TIME_OUT) {
281
-			return;
282
-		}
283
-		if ($desc = $trouver_table($table)) {
284
-			$desc_collate = _sqlite_remplacements_definitions_table($desc['field']);
285
-			if ($d = array_diff($desc['field'], $desc_collate)) {
286
-				spip_log("Table $table COLLATE incorrects", 'maj');
287
-
288
-				// cas particulier spip_urls :
289
-				// supprimer les doublons avant conversion sinon echec (on garde les urls les plus recentes)
290
-				if ($table == 'spip_urls') {
291
-					// par date DESC pour conserver les urls les plus recentes
292
-					$data = sql_allfetsel('*', 'spip_urls', '', '', 'date DESC');
293
-					$urls = [];
294
-					foreach ($data as $d) {
295
-						$key = $d['id_parent'] . '::' . strtolower($d['url']);
296
-						if (!isset($urls[$key])) {
297
-							$urls[$key] = true;
298
-						} else {
299
-							spip_log(
300
-								'Suppression doublon dans spip_urls avant conversion : ' . serialize($d),
301
-								'maj.' . _LOG_INFO_IMPORTANTE
302
-							);
303
-							sql_delete('spip_urls', 'id_parent=' . sql_quote($d['id_parent']) . ' AND url=' . sql_quote($d['url']));
304
-						}
305
-					}
306
-				}
307
-				foreach ($desc['field'] as $field => $type) {
308
-					if ($desc['field'][$field] !== $desc_collate[$field]) {
309
-						spip_log("Conversion COLLATE table $table", 'maj.' . _LOG_INFO_IMPORTANTE);
310
-						sql_alter("table $table change $field $field " . $desc_collate[$field]);
311
-						$trouver_table('');
312
-						$new_desc = $trouver_table($table);
313
-						spip_log(
314
-							"Apres conversion $table : " . var_export($new_desc['field'], true),
315
-							'maj.' . _LOG_INFO_IMPORTANTE
316
-						);
317
-						continue 2; // inutile de continuer pour cette table : un seul alter remet tout a jour en sqlite
318
-					}
319
-				}
320
-			}
321
-		}
322
-	}
323
-
324
-	// forcer le vidage de cache
325
-	$trouver_table('');
256
+    include_spip('base/dump');
257
+    $tables = base_lister_toutes_tables();
258
+
259
+    // rien a faire si base non sqlite
260
+    if (strncmp($GLOBALS['connexions'][0]['type'], 'sqlite', 6) !== 0) {
261
+        return;
262
+    }
263
+
264
+    $trouver_table = charger_fonction('trouver_table', 'base');
265
+    // forcer le vidage de cache
266
+    $trouver_table('');
267
+
268
+    // cas particulier spip_auteurs : retablir le collate binary sur le login
269
+    $desc = $trouver_table('spip_auteurs');
270
+    spip_log('spip_auteurs : ' . var_export($desc['field'], true), 'maj.' . _LOG_INFO_IMPORTANTE);
271
+    if (stripos($desc['field']['login'], 'BINARY') === false) {
272
+        spip_log('Retablir champ login BINARY sur table spip_auteurs', 'maj');
273
+        sql_alter('table spip_auteurs change login login VARCHAR(255) BINARY');
274
+        $trouver_table('');
275
+        $new_desc = $trouver_table('spip_auteurs');
276
+        spip_log('Apres conversion spip_auteurs : ' . var_export($new_desc['field'], true), 'maj.' . _LOG_INFO_IMPORTANTE);
277
+    }
278
+
279
+    foreach ($tables as $table) {
280
+        if (time() >= _TIME_OUT) {
281
+            return;
282
+        }
283
+        if ($desc = $trouver_table($table)) {
284
+            $desc_collate = _sqlite_remplacements_definitions_table($desc['field']);
285
+            if ($d = array_diff($desc['field'], $desc_collate)) {
286
+                spip_log("Table $table COLLATE incorrects", 'maj');
287
+
288
+                // cas particulier spip_urls :
289
+                // supprimer les doublons avant conversion sinon echec (on garde les urls les plus recentes)
290
+                if ($table == 'spip_urls') {
291
+                    // par date DESC pour conserver les urls les plus recentes
292
+                    $data = sql_allfetsel('*', 'spip_urls', '', '', 'date DESC');
293
+                    $urls = [];
294
+                    foreach ($data as $d) {
295
+                        $key = $d['id_parent'] . '::' . strtolower($d['url']);
296
+                        if (!isset($urls[$key])) {
297
+                            $urls[$key] = true;
298
+                        } else {
299
+                            spip_log(
300
+                                'Suppression doublon dans spip_urls avant conversion : ' . serialize($d),
301
+                                'maj.' . _LOG_INFO_IMPORTANTE
302
+                            );
303
+                            sql_delete('spip_urls', 'id_parent=' . sql_quote($d['id_parent']) . ' AND url=' . sql_quote($d['url']));
304
+                        }
305
+                    }
306
+                }
307
+                foreach ($desc['field'] as $field => $type) {
308
+                    if ($desc['field'][$field] !== $desc_collate[$field]) {
309
+                        spip_log("Conversion COLLATE table $table", 'maj.' . _LOG_INFO_IMPORTANTE);
310
+                        sql_alter("table $table change $field $field " . $desc_collate[$field]);
311
+                        $trouver_table('');
312
+                        $new_desc = $trouver_table($table);
313
+                        spip_log(
314
+                            "Apres conversion $table : " . var_export($new_desc['field'], true),
315
+                            'maj.' . _LOG_INFO_IMPORTANTE
316
+                        );
317
+                        continue 2; // inutile de continuer pour cette table : un seul alter remet tout a jour en sqlite
318
+                    }
319
+                }
320
+            }
321
+        }
322
+    }
323
+
324
+    // forcer le vidage de cache
325
+    $trouver_table('');
326 326
 }
327 327
 
328 328
 
329 329
 $GLOBALS['maj'][19236] = [
330
-	['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom='version_installee'"], // version base principale
331
-	['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom LIKE '%_base_version'"],  // version base plugins
332
-	['maj_collation_sqlite'],
330
+    ['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom='version_installee'"], // version base principale
331
+    ['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom LIKE '%_base_version'"],  // version base plugins
332
+    ['maj_collation_sqlite'],
333 333
 ];
334 334
 
335 335
 $GLOBALS['maj'][19268] = [
336
-	['supprimer_toutes_sessions'],
336
+    ['supprimer_toutes_sessions'],
337 337
 ];
338 338
 
339 339
 /**
@@ -342,13 +342,13 @@  discard block
 block discarded – undo
342 342
  * Obligera tous les auteurs à se reconnecter !
343 343
  **/
344 344
 function supprimer_toutes_sessions() {
345
-	spip_log('supprimer sessions auteur');
346
-	if ($dir = opendir(_DIR_SESSIONS)) {
347
-		while (($f = readdir($dir)) !== false) {
348
-			spip_unlink(_DIR_SESSIONS . $f);
349
-			if (time() >= _TIME_OUT) {
350
-				return;
351
-			}
352
-		}
353
-	}
345
+    spip_log('supprimer sessions auteur');
346
+    if ($dir = opendir(_DIR_SESSIONS)) {
347
+        while (($f = readdir($dir)) !== false) {
348
+            spip_unlink(_DIR_SESSIONS . $f);
349
+            if (time() >= _TIME_OUT) {
350
+                return;
351
+            }
352
+        }
353
+    }
354 354
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 	$exceptions_pluriel = ['forum' => 'forum', 'syndic' => 'syndic'];
61 61
 
62 62
 	$pivot = preg_replace(',[^\w],', '', $pivot); // securite
63
-	$pivots = ($exceptions_pluriel[$pivot] ?? $pivot . 's');
64
-	$liens = 'spip_' . $pivots . '_liens';
65
-	$id_pivot = 'id_' . $pivot;
63
+	$pivots = ($exceptions_pluriel[$pivot] ?? $pivot.'s');
64
+	$liens = 'spip_'.$pivots.'_liens';
65
+	$id_pivot = 'id_'.$pivot;
66 66
 	// Creer spip_auteurs_liens
67 67
 	global $tables_auxiliaires;
68 68
 	if (!$l) {
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 		$l = preg_replace(',[^\w],', '', $l); // securite
75 75
 		$primary = "id_$l";
76 76
 		$objet = ($l == 'syndic' ? 'site' : $l);
77
-		$ls = ($exceptions_pluriel[$l] ?? $l . 's');
78
-		$ancienne_table = 'spip_' . $pivots . '_' . $ls;
77
+		$ls = ($exceptions_pluriel[$l] ?? $l.'s');
78
+		$ancienne_table = 'spip_'.$pivots.'_'.$ls;
79 79
 		$pool = 400;
80 80
 
81 81
 		$trouver_table = charger_fonction('trouver_table', 'base');
@@ -111,12 +111,12 @@  discard block
 block discarded – undo
111 111
 		while ($ids = array_map('reset', sql_allfetsel("$primary", $ancienne_table, '', '', '', "0,$sub_pool"))) {
112 112
 			$insert = [];
113 113
 			foreach ($ids as $id) {
114
-				$n = sql_countsel($liens, "objet='$objet' AND id_objet=" . intval($id));
115
-				while ($t = sql_allfetsel($champs, $ancienne_table, "$primary=" . intval($id), '', $id_pivot, "$n,$pool")) {
114
+				$n = sql_countsel($liens, "objet='$objet' AND id_objet=".intval($id));
115
+				while ($t = sql_allfetsel($champs, $ancienne_table, "$primary=".intval($id), '', $id_pivot, "$n,$pool")) {
116 116
 					$n += is_countable($t) ? count($t) : 0;
117 117
 					// empiler en s'assurant a minima de l'unicite
118 118
 					while ($r = array_shift($t)) {
119
-						$insert[$r[$id_pivot] . ':' . $r['id_objet']] = $r;
119
+						$insert[$r[$id_pivot].':'.$r['id_objet']] = $r;
120 120
 					}
121 121
 					if (count($insert) >= $sub_pool) {
122 122
 						maj_liens_insertq_multi_check($liens, $insert, $tables_auxiliaires[$liens]);
@@ -267,13 +267,13 @@  discard block
 block discarded – undo
267 267
 
268 268
 	// cas particulier spip_auteurs : retablir le collate binary sur le login
269 269
 	$desc = $trouver_table('spip_auteurs');
270
-	spip_log('spip_auteurs : ' . var_export($desc['field'], true), 'maj.' . _LOG_INFO_IMPORTANTE);
270
+	spip_log('spip_auteurs : '.var_export($desc['field'], true), 'maj.'._LOG_INFO_IMPORTANTE);
271 271
 	if (stripos($desc['field']['login'], 'BINARY') === false) {
272 272
 		spip_log('Retablir champ login BINARY sur table spip_auteurs', 'maj');
273 273
 		sql_alter('table spip_auteurs change login login VARCHAR(255) BINARY');
274 274
 		$trouver_table('');
275 275
 		$new_desc = $trouver_table('spip_auteurs');
276
-		spip_log('Apres conversion spip_auteurs : ' . var_export($new_desc['field'], true), 'maj.' . _LOG_INFO_IMPORTANTE);
276
+		spip_log('Apres conversion spip_auteurs : '.var_export($new_desc['field'], true), 'maj.'._LOG_INFO_IMPORTANTE);
277 277
 	}
278 278
 
279 279
 	foreach ($tables as $table) {
@@ -292,27 +292,27 @@  discard block
 block discarded – undo
292 292
 					$data = sql_allfetsel('*', 'spip_urls', '', '', 'date DESC');
293 293
 					$urls = [];
294 294
 					foreach ($data as $d) {
295
-						$key = $d['id_parent'] . '::' . strtolower($d['url']);
295
+						$key = $d['id_parent'].'::'.strtolower($d['url']);
296 296
 						if (!isset($urls[$key])) {
297 297
 							$urls[$key] = true;
298 298
 						} else {
299 299
 							spip_log(
300
-								'Suppression doublon dans spip_urls avant conversion : ' . serialize($d),
301
-								'maj.' . _LOG_INFO_IMPORTANTE
300
+								'Suppression doublon dans spip_urls avant conversion : '.serialize($d),
301
+								'maj.'._LOG_INFO_IMPORTANTE
302 302
 							);
303
-							sql_delete('spip_urls', 'id_parent=' . sql_quote($d['id_parent']) . ' AND url=' . sql_quote($d['url']));
303
+							sql_delete('spip_urls', 'id_parent='.sql_quote($d['id_parent']).' AND url='.sql_quote($d['url']));
304 304
 						}
305 305
 					}
306 306
 				}
307 307
 				foreach ($desc['field'] as $field => $type) {
308 308
 					if ($desc['field'][$field] !== $desc_collate[$field]) {
309
-						spip_log("Conversion COLLATE table $table", 'maj.' . _LOG_INFO_IMPORTANTE);
310
-						sql_alter("table $table change $field $field " . $desc_collate[$field]);
309
+						spip_log("Conversion COLLATE table $table", 'maj.'._LOG_INFO_IMPORTANTE);
310
+						sql_alter("table $table change $field $field ".$desc_collate[$field]);
311 311
 						$trouver_table('');
312 312
 						$new_desc = $trouver_table($table);
313 313
 						spip_log(
314
-							"Apres conversion $table : " . var_export($new_desc['field'], true),
315
-							'maj.' . _LOG_INFO_IMPORTANTE
314
+							"Apres conversion $table : ".var_export($new_desc['field'], true),
315
+							'maj.'._LOG_INFO_IMPORTANTE
316 316
 						);
317 317
 						continue 2; // inutile de continuer pour cette table : un seul alter remet tout a jour en sqlite
318 318
 					}
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
 
329 329
 $GLOBALS['maj'][19236] = [
330 330
 	['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom='version_installee'"], // version base principale
331
-	['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom LIKE '%_base_version'"],  // version base plugins
331
+	['sql_updateq', 'spip_meta', ['impt' => 'oui'], "nom LIKE '%_base_version'"], // version base plugins
332 332
 	['maj_collation_sqlite'],
333 333
 ];
334 334
 
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	spip_log('supprimer sessions auteur');
346 346
 	if ($dir = opendir(_DIR_SESSIONS)) {
347 347
 		while (($f = readdir($dir)) !== false) {
348
-			spip_unlink(_DIR_SESSIONS . $f);
348
+			spip_unlink(_DIR_SESSIONS.$f);
349 349
 			if (time() >= _TIME_OUT) {
350 350
 				return;
351 351
 			}
Please login to merge, or discard this patch.
ecrire/action/editer_auteur.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	$champs['source'] = $source ?: 'spip';
94 94
 
95 95
 	$champs['login'] = '';
96
-	$champs['statut'] = '5poubelle';  // inutilisable tant qu'il n'a pas ete renseigne et institue
96
+	$champs['statut'] = '5poubelle'; // inutilisable tant qu'il n'a pas ete renseigne et institue
97 97
 	$champs['webmestre'] = 'non';
98 98
 	if (empty($champs['imessage'])) {
99 99
 		$champs['imessage'] = 'oui';
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 		$champs['pass'] = $c['pass'];
314 314
 	}
315 315
 
316
-	$statut = $statut_ancien = sql_getfetsel('statut', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
316
+	$statut = $statut_ancien = sql_getfetsel('statut', 'spip_auteurs', 'id_auteur='.intval($id_auteur));
317 317
 
318 318
 	if (
319 319
 		isset($c['statut'])
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
 	// commencer par traiter les cas particuliers des logins et pass
374 374
 	// avant les autres ecritures en base
375 375
 	if (isset($champs['login']) or isset($champs['pass'])) {
376
-		$auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
376
+		$auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur='.intval($id_auteur));
377 377
 		include_spip('inc/auth');
378 378
 		if (isset($champs['login']) and strlen($champs['login'])) {
379 379
 			if (!auth_modifier_login($auth_methode, $champs['login'], $id_auteur)) {
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 			}
382 382
 		}
383 383
 		if (isset($champs['pass']) and strlen($champs['pass'])) {
384
-			$champs['login'] = sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
384
+			$champs['login'] = sql_getfetsel('login', 'spip_auteurs', 'id_auteur='.intval($id_auteur));
385 385
 			if (!auth_modifier_pass($auth_methode, $champs['login'], $champs['pass'], $id_auteur)) {
386 386
 				$erreurs[] = 'ecrire:impossible_modifier_pass_auteur';
387 387
 			}
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	if (!(is_countable($champs) ? count($champs) : 0)) {
395 395
 		return implode(' ', array_map('_T', $erreurs));
396 396
 	}
397
-	sql_updateq('spip_auteurs', $champs, 'id_auteur=' . $id_auteur);
397
+	sql_updateq('spip_auteurs', $champs, 'id_auteur='.$id_auteur);
398 398
 
399 399
 	// .. mettre a jour les fichiers .htpasswd et .htpasswd-admin
400 400
 	if (
Please login to merge, or discard this patch.
Indentation   +318 added lines, -318 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
 /**
@@ -37,41 +37,41 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function action_editer_auteur_dist($arg = null) {
39 39
 
40
-	if (is_null($arg)) {
41
-		$securiser_action = charger_fonction('securiser_action', 'inc');
42
-		$arg = $securiser_action();
43
-	}
44
-
45
-
46
-	// si id_auteur n'est pas un nombre, c'est une creation
47
-	if (!$id_auteur = intval($arg)) {
48
-		if (($id_auteur = auteur_inserer()) > 0) {
49
-			# cf. GROS HACK
50
-			# recuperer l'eventuel logo charge avant la creation
51
-			# ils ont un id = 0-id_auteur de la session
52
-			$id_hack = 0 - $GLOBALS['visiteur_session']['id_auteur'];
53
-			$chercher_logo = charger_fonction('chercher_logo', 'inc');
54
-			foreach (['on', 'off'] as $type) {
55
-				if ($logo = $chercher_logo($id_hack, 'id_auteur', $type)) {
56
-					if ($logo = reset($logo)) {
57
-						rename($logo, str_replace($id_hack, $id_auteur, $logo));
58
-					}
59
-				}
60
-			}
61
-		}
62
-	}
63
-
64
-	// Enregistre l'envoi dans la BD
65
-	$err = '';
66
-	if ($id_auteur > 0) {
67
-		$err = auteur_modifier($id_auteur);
68
-	}
69
-
70
-	if ($err) {
71
-		spip_log("echec editeur auteur: $err", _LOG_ERREUR);
72
-	}
73
-
74
-	return [$id_auteur, $err];
40
+    if (is_null($arg)) {
41
+        $securiser_action = charger_fonction('securiser_action', 'inc');
42
+        $arg = $securiser_action();
43
+    }
44
+
45
+
46
+    // si id_auteur n'est pas un nombre, c'est une creation
47
+    if (!$id_auteur = intval($arg)) {
48
+        if (($id_auteur = auteur_inserer()) > 0) {
49
+            # cf. GROS HACK
50
+            # recuperer l'eventuel logo charge avant la creation
51
+            # ils ont un id = 0-id_auteur de la session
52
+            $id_hack = 0 - $GLOBALS['visiteur_session']['id_auteur'];
53
+            $chercher_logo = charger_fonction('chercher_logo', 'inc');
54
+            foreach (['on', 'off'] as $type) {
55
+                if ($logo = $chercher_logo($id_hack, 'id_auteur', $type)) {
56
+                    if ($logo = reset($logo)) {
57
+                        rename($logo, str_replace($id_hack, $id_auteur, $logo));
58
+                    }
59
+                }
60
+            }
61
+        }
62
+    }
63
+
64
+    // Enregistre l'envoi dans la BD
65
+    $err = '';
66
+    if ($id_auteur > 0) {
67
+        $err = auteur_modifier($id_auteur);
68
+    }
69
+
70
+    if ($err) {
71
+        spip_log("echec editeur auteur: $err", _LOG_ERREUR);
72
+    }
73
+
74
+    return [$id_auteur, $err];
75 75
 }
76 76
 
77 77
 /**
@@ -88,64 +88,64 @@  discard block
 block discarded – undo
88 88
  */
89 89
 function auteur_inserer($source = null, $set = null) {
90 90
 
91
-	// Ce qu'on va demander comme modifications
92
-	$champs = [];
93
-	$champs['source'] = $source ?: 'spip';
94
-
95
-	$champs['login'] = '';
96
-	$champs['statut'] = '5poubelle';  // inutilisable tant qu'il n'a pas ete renseigne et institue
97
-	$champs['webmestre'] = 'non';
98
-	if (empty($champs['imessage'])) {
99
-		$champs['imessage'] = 'oui';
100
-	}
101
-
102
-	if ($set) {
103
-		$champs = array_merge($champs, $set);
104
-	}
105
-
106
-	// Envoyer aux plugins
107
-	$champs = pipeline(
108
-		'pre_insertion',
109
-		[
110
-			'args' => [
111
-				'table' => 'spip_auteurs',
112
-			],
113
-			'data' => $champs
114
-		]
115
-	);
116
-	$id_auteur = sql_insertq('spip_auteurs', $champs);
117
-	pipeline(
118
-		'post_insertion',
119
-		[
120
-			'args' => [
121
-				'table' => 'spip_auteurs',
122
-				'id_objet' => $id_auteur
123
-			],
124
-			'data' => $champs
125
-		]
126
-	);
91
+    // Ce qu'on va demander comme modifications
92
+    $champs = [];
93
+    $champs['source'] = $source ?: 'spip';
94
+
95
+    $champs['login'] = '';
96
+    $champs['statut'] = '5poubelle';  // inutilisable tant qu'il n'a pas ete renseigne et institue
97
+    $champs['webmestre'] = 'non';
98
+    if (empty($champs['imessage'])) {
99
+        $champs['imessage'] = 'oui';
100
+    }
101
+
102
+    if ($set) {
103
+        $champs = array_merge($champs, $set);
104
+    }
105
+
106
+    // Envoyer aux plugins
107
+    $champs = pipeline(
108
+        'pre_insertion',
109
+        [
110
+            'args' => [
111
+                'table' => 'spip_auteurs',
112
+            ],
113
+            'data' => $champs
114
+        ]
115
+    );
116
+    $id_auteur = sql_insertq('spip_auteurs', $champs);
117
+    pipeline(
118
+        'post_insertion',
119
+        [
120
+            'args' => [
121
+                'table' => 'spip_auteurs',
122
+                'id_objet' => $id_auteur
123
+            ],
124
+            'data' => $champs
125
+        ]
126
+    );
127 127
 	
128
-	// Appeler une notification
129
-	if ($notifications = charger_fonction('notifications', 'inc')) {
130
-		$notifications(
131
-			'auteur_inserer',
132
-			$id_auteur,
133
-			[
134
-				'champs' => $champs,
135
-			]
136
-		);
137
-		$notifications(
138
-			'objet_inserer',
139
-			$id_auteur,
140
-			[
141
-				'objet' => 'auteur',
142
-				'id_objet' => $id_auteur,
143
-				'champs' => $champs,
144
-			]
145
-		);
146
-	}
147
-
148
-	return $id_auteur;
128
+    // Appeler une notification
129
+    if ($notifications = charger_fonction('notifications', 'inc')) {
130
+        $notifications(
131
+            'auteur_inserer',
132
+            $id_auteur,
133
+            [
134
+                'champs' => $champs,
135
+            ]
136
+        );
137
+        $notifications(
138
+            'objet_inserer',
139
+            $id_auteur,
140
+            [
141
+                'objet' => 'auteur',
142
+                'id_objet' => $id_auteur,
143
+                'champs' => $champs,
144
+            ]
145
+        );
146
+    }
147
+
148
+    return $id_auteur;
149 149
 }
150 150
 
151 151
 
@@ -170,70 +170,70 @@  discard block
 block discarded – undo
170 170
  */
171 171
 function auteur_modifier($id_auteur, $set = null, $force_update = false) {
172 172
 
173
-	include_spip('inc/modifier');
174
-	include_spip('inc/filtres');
175
-	$c = collecter_requests(
176
-		// include list
177
-		objet_info('auteur', 'champs_editables'),
178
-		// exclude list
179
-		$force_update ? [] : ['webmestre', 'pass', 'login'],
180
-		// donnees eventuellement fournies
181
-		$set
182
-	);
183
-
184
-	if (
185
-		$err = objet_modifier_champs(
186
-			'auteur',
187
-			$id_auteur,
188
-			[
189
-			'data' => $set,
190
-			'nonvide' => ['nom' => _T('ecrire:item_nouvel_auteur')]
191
-			],
192
-			$c
193
-		)
194
-	) {
195
-		return $err;
196
-	}
197
-	$session = $c;
198
-
199
-	$err = '';
200
-	if (!$force_update) {
201
-		// Modification de statut, changement de rubrique ?
202
-		$c = collecter_requests(
203
-		// include list
204
-			[
205
-				'statut',
206
-				'new_login',
207
-				'new_pass',
208
-				'login',
209
-				'pass',
210
-				'webmestre',
211
-				'restreintes',
212
-				'id_parent'
213
-			],
214
-			// exclude list
215
-			[],
216
-			// donnees eventuellement fournies
217
-			$set
218
-		);
219
-		if (isset($c['new_login']) and !isset($c['login'])) {
220
-			$c['login'] = $c['new_login'];
221
-		}
222
-		if (isset($c['new_pass']) and !isset($c['pass'])) {
223
-			$c['pass'] = $c['new_pass'];
224
-		}
225
-		$err = auteur_instituer($id_auteur, $c);
226
-		$session = array_merge($session, $c);
227
-	}
228
-
229
-	// .. mettre a jour les sessions de cet auteur
230
-	include_spip('inc/session');
231
-	$session['id_auteur'] = $id_auteur;
232
-	unset($session['new_login']);
233
-	unset($session['new_pass']);
234
-	actualiser_sessions($session);
235
-
236
-	return $err;
173
+    include_spip('inc/modifier');
174
+    include_spip('inc/filtres');
175
+    $c = collecter_requests(
176
+        // include list
177
+        objet_info('auteur', 'champs_editables'),
178
+        // exclude list
179
+        $force_update ? [] : ['webmestre', 'pass', 'login'],
180
+        // donnees eventuellement fournies
181
+        $set
182
+    );
183
+
184
+    if (
185
+        $err = objet_modifier_champs(
186
+            'auteur',
187
+            $id_auteur,
188
+            [
189
+            'data' => $set,
190
+            'nonvide' => ['nom' => _T('ecrire:item_nouvel_auteur')]
191
+            ],
192
+            $c
193
+        )
194
+    ) {
195
+        return $err;
196
+    }
197
+    $session = $c;
198
+
199
+    $err = '';
200
+    if (!$force_update) {
201
+        // Modification de statut, changement de rubrique ?
202
+        $c = collecter_requests(
203
+        // include list
204
+            [
205
+                'statut',
206
+                'new_login',
207
+                'new_pass',
208
+                'login',
209
+                'pass',
210
+                'webmestre',
211
+                'restreintes',
212
+                'id_parent'
213
+            ],
214
+            // exclude list
215
+            [],
216
+            // donnees eventuellement fournies
217
+            $set
218
+        );
219
+        if (isset($c['new_login']) and !isset($c['login'])) {
220
+            $c['login'] = $c['new_login'];
221
+        }
222
+        if (isset($c['new_pass']) and !isset($c['pass'])) {
223
+            $c['pass'] = $c['new_pass'];
224
+        }
225
+        $err = auteur_instituer($id_auteur, $c);
226
+        $session = array_merge($session, $c);
227
+    }
228
+
229
+    // .. mettre a jour les sessions de cet auteur
230
+    include_spip('inc/session');
231
+    $session['id_auteur'] = $id_auteur;
232
+    unset($session['new_login']);
233
+    unset($session['new_pass']);
234
+    actualiser_sessions($session);
235
+
236
+    return $err;
237 237
 }
238 238
 
239 239
 /**
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
  * @return string
255 255
  */
256 256
 function auteur_associer($id_auteur, $objets, $qualif = null) {
257
-	include_spip('action/editer_liens');
257
+    include_spip('action/editer_liens');
258 258
 
259
-	return objet_associer(['auteur' => $id_auteur], $objets, $qualif);
259
+    return objet_associer(['auteur' => $id_auteur], $objets, $qualif);
260 260
 }
261 261
 
262 262
 /**
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
  * @return string
276 276
  */
277 277
 function auteur_dissocier($id_auteur, $objets) {
278
-	include_spip('action/editer_liens');
278
+    include_spip('action/editer_liens');
279 279
 
280
-	return objet_dissocier(['auteur' => $id_auteur], $objets);
280
+    return objet_dissocier(['auteur' => $id_auteur], $objets);
281 281
 }
282 282
 
283 283
 /**
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
  * @return bool|int
299 299
  */
300 300
 function auteur_qualifier($id_auteur, $objets, $qualif) {
301
-	include_spip('action/editer_liens');
301
+    include_spip('action/editer_liens');
302 302
 
303
-	return objet_qualifier_liens(['auteur' => $id_auteur], $objets, $qualif);
303
+    return objet_qualifier_liens(['auteur' => $id_auteur], $objets, $qualif);
304 304
 }
305 305
 
306 306
 
@@ -319,160 +319,160 @@  discard block
 block discarded – undo
319 319
  * @return bool|string
320 320
  */
321 321
 function auteur_instituer($id_auteur, $c, $force_webmestre = false) {
322
-	if (!$id_auteur = intval($id_auteur)) {
323
-		return false;
324
-	}
325
-	$erreurs = []; // contiendra les differentes erreurs a traduire par _T()
326
-	$champs = [];
327
-
328
-	// les memoriser pour les faire passer dans le pipeline pre_edition
329
-	if (isset($c['login']) and strlen($c['login'])) {
330
-		$champs['login'] = $c['login'];
331
-	}
332
-	if (isset($c['pass']) and strlen($c['pass'])) {
333
-		$champs['pass'] = $c['pass'];
334
-	}
335
-
336
-	$statut = $statut_ancien = sql_getfetsel('statut', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
337
-
338
-	if (
339
-		isset($c['statut'])
340
-		and (autoriser('modifier', 'auteur', $id_auteur, null, ['statut' => $c['statut']]))
341
-	) {
342
-		$statut = $champs['statut'] = $c['statut'];
343
-	}
344
-
345
-	// Restreindre avant de declarer l'auteur
346
-	// (section critique sur les droits)
347
-	if (isset($c['id_parent']) and $c['id_parent']) {
348
-		if (is_array($c['restreintes'])) {
349
-			$c['restreintes'][] = $c['id_parent'];
350
-		} else {
351
-			$c['restreintes'] = [$c['id_parent']];
352
-		}
353
-	}
354
-
355
-	if (
356
-		isset($c['webmestre'])
357
-		and ($force_webmestre or autoriser('modifier', 'auteur', $id_auteur, null, ['webmestre' => '?']))
358
-	) {
359
-		$champs['webmestre'] = $c['webmestre'] == 'oui' ? 'oui' : 'non';
360
-	}
361
-
362
-	// si statut change et n'est pas 0minirezo, on force webmestre a non
363
-	if (isset($c['statut']) and $c['statut'] !== '0minirezo') {
364
-		$champs['webmestre'] = $c['webmestre'] = 'non';
365
-	}
366
-
367
-	// Envoyer aux plugins
368
-	$champs = pipeline(
369
-		'pre_edition',
370
-		[
371
-			'args' => [
372
-				'table' => 'spip_auteurs',
373
-				'id_objet' => $id_auteur,
374
-				'action' => 'instituer',
375
-				'statut_ancien' => $statut_ancien,
376
-			],
377
-			'data' => $champs
378
-		]
379
-	);
380
-
381
-	if (
382
-		isset($c['restreintes']) and is_array($c['restreintes'])
383
-		and autoriser('modifier', 'auteur', $id_auteur, null, ['restreint' => $c['restreintes']])
384
-	) {
385
-		$rubriques = array_map('intval', $c['restreintes']);
386
-		$rubriques = array_unique($rubriques);
387
-		$rubriques = array_diff($rubriques, [0]);
388
-		auteur_dissocier($id_auteur, ['rubrique' => '*']);
389
-		auteur_associer($id_auteur, ['rubrique' => $rubriques]);
390
-	}
391
-
392
-	$flag_ecrire_acces = false;
393
-	// commencer par traiter les cas particuliers des logins et pass
394
-	// avant les autres ecritures en base
395
-	if (isset($champs['login']) or isset($champs['pass'])) {
396
-		$auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
397
-		include_spip('inc/auth');
398
-		if (isset($champs['login']) and strlen($champs['login'])) {
399
-			if (!auth_modifier_login($auth_methode, $champs['login'], $id_auteur)) {
400
-				$erreurs[] = 'ecrire:impossible_modifier_login_auteur';
401
-			}
402
-		}
403
-		if (isset($champs['pass']) and strlen($champs['pass'])) {
404
-			$champs['login'] = sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
405
-			if (!auth_modifier_pass($auth_methode, $champs['login'], $champs['pass'], $id_auteur)) {
406
-				$erreurs[] = 'ecrire:impossible_modifier_pass_auteur';
407
-			}
408
-		}
409
-		unset($champs['login']);
410
-		unset($champs['pass']);
411
-		$flag_ecrire_acces = true;
412
-	}
413
-
414
-	if (!(is_countable($champs) ? count($champs) : 0)) {
415
-		return implode(' ', array_map('_T', $erreurs));
416
-	}
417
-	sql_updateq('spip_auteurs', $champs, 'id_auteur=' . $id_auteur);
418
-
419
-	// .. mettre a jour les fichiers .htpasswd et .htpasswd-admin
420
-	if (
421
-		$flag_ecrire_acces
422
-		or isset($champs['statut'])
423
-	) {
424
-		include_spip('inc/acces');
425
-		ecrire_acces();
426
-	}
427
-
428
-	// Invalider les caches
429
-	include_spip('inc/invalideur');
430
-	suivre_invalideur("id='auteur/$id_auteur'");
431
-
432
-	// Pipeline
433
-	pipeline(
434
-		'post_edition',
435
-		[
436
-			'args' => [
437
-				'table' => 'spip_auteurs',
438
-				'id_objet' => $id_auteur,
439
-				'action' => 'instituer',
440
-				'statut_ancien' => $statut_ancien,
441
-			],
442
-			'data' => $champs
443
-		]
444
-	);
445
-
446
-	// Notifications
447
-	if ($notifications = charger_fonction('notifications', 'inc')) {
448
-		$notifications(
449
-			'auteur_instituer',
450
-			$id_auteur,
451
-			[
452
-				'statut' => $statut,
453
-				'statut_ancien' => $statut_ancien,
454
-				'champs' => $champs,
455
-			]
456
-		);
457
-		$notifications(
458
-			'objet_instituer',
459
-			$id_auteur,
460
-			[
461
-				'objet' => 'auteur',
462
-				'id_objet' => $id_auteur,
463
-				'statut' => $statut,
464
-				'statut_ancien' => $statut_ancien,
465
-				'champs' => $champs,
466
-			]
467
-		);
322
+    if (!$id_auteur = intval($id_auteur)) {
323
+        return false;
324
+    }
325
+    $erreurs = []; // contiendra les differentes erreurs a traduire par _T()
326
+    $champs = [];
327
+
328
+    // les memoriser pour les faire passer dans le pipeline pre_edition
329
+    if (isset($c['login']) and strlen($c['login'])) {
330
+        $champs['login'] = $c['login'];
331
+    }
332
+    if (isset($c['pass']) and strlen($c['pass'])) {
333
+        $champs['pass'] = $c['pass'];
334
+    }
335
+
336
+    $statut = $statut_ancien = sql_getfetsel('statut', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
337
+
338
+    if (
339
+        isset($c['statut'])
340
+        and (autoriser('modifier', 'auteur', $id_auteur, null, ['statut' => $c['statut']]))
341
+    ) {
342
+        $statut = $champs['statut'] = $c['statut'];
343
+    }
344
+
345
+    // Restreindre avant de declarer l'auteur
346
+    // (section critique sur les droits)
347
+    if (isset($c['id_parent']) and $c['id_parent']) {
348
+        if (is_array($c['restreintes'])) {
349
+            $c['restreintes'][] = $c['id_parent'];
350
+        } else {
351
+            $c['restreintes'] = [$c['id_parent']];
352
+        }
353
+    }
354
+
355
+    if (
356
+        isset($c['webmestre'])
357
+        and ($force_webmestre or autoriser('modifier', 'auteur', $id_auteur, null, ['webmestre' => '?']))
358
+    ) {
359
+        $champs['webmestre'] = $c['webmestre'] == 'oui' ? 'oui' : 'non';
360
+    }
361
+
362
+    // si statut change et n'est pas 0minirezo, on force webmestre a non
363
+    if (isset($c['statut']) and $c['statut'] !== '0minirezo') {
364
+        $champs['webmestre'] = $c['webmestre'] = 'non';
365
+    }
366
+
367
+    // Envoyer aux plugins
368
+    $champs = pipeline(
369
+        'pre_edition',
370
+        [
371
+            'args' => [
372
+                'table' => 'spip_auteurs',
373
+                'id_objet' => $id_auteur,
374
+                'action' => 'instituer',
375
+                'statut_ancien' => $statut_ancien,
376
+            ],
377
+            'data' => $champs
378
+        ]
379
+    );
380
+
381
+    if (
382
+        isset($c['restreintes']) and is_array($c['restreintes'])
383
+        and autoriser('modifier', 'auteur', $id_auteur, null, ['restreint' => $c['restreintes']])
384
+    ) {
385
+        $rubriques = array_map('intval', $c['restreintes']);
386
+        $rubriques = array_unique($rubriques);
387
+        $rubriques = array_diff($rubriques, [0]);
388
+        auteur_dissocier($id_auteur, ['rubrique' => '*']);
389
+        auteur_associer($id_auteur, ['rubrique' => $rubriques]);
390
+    }
391
+
392
+    $flag_ecrire_acces = false;
393
+    // commencer par traiter les cas particuliers des logins et pass
394
+    // avant les autres ecritures en base
395
+    if (isset($champs['login']) or isset($champs['pass'])) {
396
+        $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
397
+        include_spip('inc/auth');
398
+        if (isset($champs['login']) and strlen($champs['login'])) {
399
+            if (!auth_modifier_login($auth_methode, $champs['login'], $id_auteur)) {
400
+                $erreurs[] = 'ecrire:impossible_modifier_login_auteur';
401
+            }
402
+        }
403
+        if (isset($champs['pass']) and strlen($champs['pass'])) {
404
+            $champs['login'] = sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur));
405
+            if (!auth_modifier_pass($auth_methode, $champs['login'], $champs['pass'], $id_auteur)) {
406
+                $erreurs[] = 'ecrire:impossible_modifier_pass_auteur';
407
+            }
408
+        }
409
+        unset($champs['login']);
410
+        unset($champs['pass']);
411
+        $flag_ecrire_acces = true;
412
+    }
413
+
414
+    if (!(is_countable($champs) ? count($champs) : 0)) {
415
+        return implode(' ', array_map('_T', $erreurs));
416
+    }
417
+    sql_updateq('spip_auteurs', $champs, 'id_auteur=' . $id_auteur);
418
+
419
+    // .. mettre a jour les fichiers .htpasswd et .htpasswd-admin
420
+    if (
421
+        $flag_ecrire_acces
422
+        or isset($champs['statut'])
423
+    ) {
424
+        include_spip('inc/acces');
425
+        ecrire_acces();
426
+    }
427
+
428
+    // Invalider les caches
429
+    include_spip('inc/invalideur');
430
+    suivre_invalideur("id='auteur/$id_auteur'");
431
+
432
+    // Pipeline
433
+    pipeline(
434
+        'post_edition',
435
+        [
436
+            'args' => [
437
+                'table' => 'spip_auteurs',
438
+                'id_objet' => $id_auteur,
439
+                'action' => 'instituer',
440
+                'statut_ancien' => $statut_ancien,
441
+            ],
442
+            'data' => $champs
443
+        ]
444
+    );
445
+
446
+    // Notifications
447
+    if ($notifications = charger_fonction('notifications', 'inc')) {
448
+        $notifications(
449
+            'auteur_instituer',
450
+            $id_auteur,
451
+            [
452
+                'statut' => $statut,
453
+                'statut_ancien' => $statut_ancien,
454
+                'champs' => $champs,
455
+            ]
456
+        );
457
+        $notifications(
458
+            'objet_instituer',
459
+            $id_auteur,
460
+            [
461
+                'objet' => 'auteur',
462
+                'id_objet' => $id_auteur,
463
+                'statut' => $statut,
464
+                'statut_ancien' => $statut_ancien,
465
+                'champs' => $champs,
466
+            ]
467
+        );
468 468
 		
469
-		// Rétro-compat
470
-		$notifications(
471
-			'instituerauteur',
472
-			$id_auteur,
473
-			['statut' => $statut, 'statut_ancien' => $statut_ancien]
474
-		);
475
-	}
476
-
477
-	return implode(' ', array_map('_T', $erreurs));
469
+        // Rétro-compat
470
+        $notifications(
471
+            'instituerauteur',
472
+            $id_auteur,
473
+            ['statut' => $statut, 'statut_ancien' => $statut_ancien]
474
+        );
475
+    }
476
+
477
+    return implode(' ', array_map('_T', $erreurs));
478 478
 }
Please login to merge, or discard this patch.
ecrire/action/instituer_objet.php 1 patch
Indentation   +19 added lines, -19 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
 /**
@@ -29,24 +29,24 @@  discard block
 block discarded – undo
29 29
  */
30 30
 function action_instituer_objet_dist($arg = null) {
31 31
 
32
-	if (is_null($arg)) {
33
-		$securiser_action = charger_fonction('securiser_action', 'inc');
34
-		$arg = $securiser_action();
35
-	}
32
+    if (is_null($arg)) {
33
+        $securiser_action = charger_fonction('securiser_action', 'inc');
34
+        $arg = $securiser_action();
35
+    }
36 36
 
37
-	[$objet, $id_objet, $statut] = preg_split('/\W/', $arg);
38
-	if (!$statut) {
39
-		$statut = _request('statut_nouv');
40
-	} // cas POST
41
-	if (!$statut) {
42
-		return;
43
-	} // impossible mais sait-on jamais
37
+    [$objet, $id_objet, $statut] = preg_split('/\W/', $arg);
38
+    if (!$statut) {
39
+        $statut = _request('statut_nouv');
40
+    } // cas POST
41
+    if (!$statut) {
42
+        return;
43
+    } // impossible mais sait-on jamais
44 44
 
45
-	if (
46
-		$id_objet = intval($id_objet)
47
-		and autoriser('instituer', $objet, $id_objet, '', ['statut' => $statut])
48
-	) {
49
-		include_spip('action/editer_objet');
50
-		objet_modifier($objet, $id_objet, ['statut' => $statut]);
51
-	}
45
+    if (
46
+        $id_objet = intval($id_objet)
47
+        and autoriser('instituer', $objet, $id_objet, '', ['statut' => $statut])
48
+    ) {
49
+        include_spip('action/editer_objet');
50
+        objet_modifier($objet, $id_objet, ['statut' => $statut]);
51
+    }
52 52
 }
Please login to merge, or discard this patch.
ecrire/action/instituer_langue_rubrique.php 1 patch
Indentation   +35 added lines, -35 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
 /**
@@ -25,41 +25,41 @@  discard block
 block discarded – undo
25 25
  **/
26 26
 function action_instituer_langue_rubrique_dist() {
27 27
 
28
-	$securiser_action = charger_fonction('securiser_action', 'inc');
29
-	$arg = $securiser_action();
30
-	$changer_lang = _request('changer_lang');
28
+    $securiser_action = charger_fonction('securiser_action', 'inc');
29
+    $arg = $securiser_action();
30
+    $changer_lang = _request('changer_lang');
31 31
 
32
-	[$id_rubrique, $id_parent] = preg_split('/\W/', $arg);
32
+    [$id_rubrique, $id_parent] = preg_split('/\W/', $arg);
33 33
 
34
-	if (
35
-		$changer_lang
36
-		and $id_rubrique > 0
37
-		and $GLOBALS['meta']['multi_rubriques'] == 'oui'
38
-		and ($GLOBALS['meta']['multi_secteurs'] == 'non' or $id_parent == 0)
39
-	) {
40
-		if ($changer_lang != 'herit') {
41
-			sql_updateq(
42
-				'spip_rubriques',
43
-				['lang' => $changer_lang, 'langue_choisie' => 'oui'],
44
-				"id_rubrique=$id_rubrique"
45
-			);
46
-		} else {
47
-			if ($id_parent == 0) {
48
-				$langue_parent = $GLOBALS['meta']['langue_site'];
49
-			} else {
50
-				$langue_parent = sql_getfetsel('lang', 'spip_rubriques', "id_rubrique=$id_parent");
51
-			}
52
-			sql_updateq(
53
-				'spip_rubriques',
54
-				['lang' => $langue_parent, 'langue_choisie' => 'non'],
55
-				"id_rubrique=$id_rubrique"
56
-			);
57
-		}
58
-		include_spip('inc/rubriques');
59
-		calculer_langues_rubriques();
34
+    if (
35
+        $changer_lang
36
+        and $id_rubrique > 0
37
+        and $GLOBALS['meta']['multi_rubriques'] == 'oui'
38
+        and ($GLOBALS['meta']['multi_secteurs'] == 'non' or $id_parent == 0)
39
+    ) {
40
+        if ($changer_lang != 'herit') {
41
+            sql_updateq(
42
+                'spip_rubriques',
43
+                ['lang' => $changer_lang, 'langue_choisie' => 'oui'],
44
+                "id_rubrique=$id_rubrique"
45
+            );
46
+        } else {
47
+            if ($id_parent == 0) {
48
+                $langue_parent = $GLOBALS['meta']['langue_site'];
49
+            } else {
50
+                $langue_parent = sql_getfetsel('lang', 'spip_rubriques', "id_rubrique=$id_parent");
51
+            }
52
+            sql_updateq(
53
+                'spip_rubriques',
54
+                ['lang' => $langue_parent, 'langue_choisie' => 'non'],
55
+                "id_rubrique=$id_rubrique"
56
+            );
57
+        }
58
+        include_spip('inc/rubriques');
59
+        calculer_langues_rubriques();
60 60
 
61
-		// invalider les caches marques de cette rubrique
62
-		include_spip('inc/invalideur');
63
-		suivre_invalideur("id='rubrique/$id_rubrique'");
64
-	}
61
+        // invalider les caches marques de cette rubrique
62
+        include_spip('inc/invalideur');
63
+        suivre_invalideur("id='rubrique/$id_rubrique'");
64
+    }
65 65
 }
Please login to merge, or discard this patch.
ecrire/action/supprimer_lien.php 1 patch
Indentation   +9 added lines, -9 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
 
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
  * @return void
36 36
  */
37 37
 function action_supprimer_lien_dist($arg = null) {
38
-	if (is_null($arg)) {
39
-		$securiser_action = charger_fonction('securiser_action', 'inc');
40
-		$arg = $securiser_action();
41
-	}
38
+    if (is_null($arg)) {
39
+        $securiser_action = charger_fonction('securiser_action', 'inc');
40
+        $arg = $securiser_action();
41
+    }
42 42
 
43
-	$arg = explode('-', $arg);
44
-	[$objet_source, $ids, $objet_lie, $idl] = $arg;
43
+    $arg = explode('-', $arg);
44
+    [$objet_source, $ids, $objet_lie, $idl] = $arg;
45 45
 
46
-	include_spip('action/editer_liens');
47
-	objet_dissocier([$objet_source => $ids], [$objet_lie => $idl]);
46
+    include_spip('action/editer_liens');
47
+    objet_dissocier([$objet_source => $ids], [$objet_lie => $idl]);
48 48
 }
Please login to merge, or discard this patch.