Completed
Push — spip-3.0 ( cd2822...016705 )
by cam
08:31
created
ecrire/action/desinstaller_plugin.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -15,25 +15,25 @@
 block discarded – undo
15 15
 // http://doc.spip.org/@action_desinstaller_plugin_dist
16 16
 function action_desinstaller_plugin_dist() {
17 17
 
18
-	$securiser_action = charger_fonction('securiser_action', 'inc');
19
-	$arg = $securiser_action();
20
-	list($dir_plugins,$plugin) = explode("::",$arg);
21
-	$dir_type = "_DIR_PLUGINS";
22
-	if (defined('_DIR_PLUGINS_SUPPL') AND $dir_plugins==_DIR_PLUGINS_SUPPL)
23
-		$dir_type = "_DIR_PLUGINS_SUPPL";
24
-	$installer_plugins = charger_fonction('installer', 'plugins');
25
-	$infos = $installer_plugins($plugin, 'uninstall',$dir_type);
26
-	if ($infos AND !$infos['install_test'][0]) {
27
-		include_spip('inc/plugin');
28
-		ecrire_plugin_actifs(array($plugin),false,'enleve');
29
-		$erreur = '';
30
-	} else 	$erreur = 'erreur_plugin_desinstalation_echouee';
31
-	if ($redirect = _request('redirect')){
32
-		include_spip('inc/headers');
33
-		if ($erreur)
34
-			$redirect = parametre_url($redirect, 'erreur',$erreur);
35
-		$redirect = str_replace('&','&',$redirect);
36
-		redirige_par_entete($redirect);
37
-	}
18
+    $securiser_action = charger_fonction('securiser_action', 'inc');
19
+    $arg = $securiser_action();
20
+    list($dir_plugins,$plugin) = explode("::",$arg);
21
+    $dir_type = "_DIR_PLUGINS";
22
+    if (defined('_DIR_PLUGINS_SUPPL') AND $dir_plugins==_DIR_PLUGINS_SUPPL)
23
+        $dir_type = "_DIR_PLUGINS_SUPPL";
24
+    $installer_plugins = charger_fonction('installer', 'plugins');
25
+    $infos = $installer_plugins($plugin, 'uninstall',$dir_type);
26
+    if ($infos AND !$infos['install_test'][0]) {
27
+        include_spip('inc/plugin');
28
+        ecrire_plugin_actifs(array($plugin),false,'enleve');
29
+        $erreur = '';
30
+    } else 	$erreur = 'erreur_plugin_desinstalation_echouee';
31
+    if ($redirect = _request('redirect')){
32
+        include_spip('inc/headers');
33
+        if ($erreur)
34
+            $redirect = parametre_url($redirect, 'erreur',$erreur);
35
+        $redirect = str_replace('&','&',$redirect);
36
+        redirige_par_entete($redirect);
37
+    }
38 38
 }
39 39
 ?>
Please login to merge, or discard this patch.
ecrire/action/instituer_langue_rubrique.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -15,32 +15,32 @@
 block discarded – undo
15 15
 // http://doc.spip.org/@action_instituer_langue_rubrique_dist
16 16
 function action_instituer_langue_rubrique_dist() {
17 17
 
18
-	$securiser_action = charger_fonction('securiser_action', 'inc');
19
-	$arg = $securiser_action();
20
-	$changer_lang = _request('changer_lang');
18
+    $securiser_action = charger_fonction('securiser_action', 'inc');
19
+    $arg = $securiser_action();
20
+    $changer_lang = _request('changer_lang');
21 21
 
22
-	list($id_rubrique, $id_parent) = preg_split('/\W/', $arg);
22
+    list($id_rubrique, $id_parent) = preg_split('/\W/', $arg);
23 23
 
24
-	if ($changer_lang
25
-	AND $id_rubrique>0
26
-	AND $GLOBALS['meta']['multi_rubriques'] == 'oui'
27
-	AND ($GLOBALS['meta']['multi_secteurs'] == 'non' OR $id_parent == 0)) {
28
-		if ($changer_lang != "herit")
29
-			sql_updateq('spip_rubriques', array('lang'=>$changer_lang, 'langue_choisie'=>'oui'), "id_rubrique=$id_rubrique");
30
-		else {
31
-			if ($id_parent == 0)
32
-				$langue_parent = $GLOBALS['meta']['langue_site'];
33
-			else {
34
-				$langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=$id_parent");
35
-			}
36
-			sql_updateq('spip_rubriques', array('lang'=>$langue_parent, 'langue_choisie'=>'non'), "id_rubrique=$id_rubrique");
37
-		}
38
-		include_spip('inc/rubriques');
39
-		calculer_langues_rubriques();
24
+    if ($changer_lang
25
+    AND $id_rubrique>0
26
+    AND $GLOBALS['meta']['multi_rubriques'] == 'oui'
27
+    AND ($GLOBALS['meta']['multi_secteurs'] == 'non' OR $id_parent == 0)) {
28
+        if ($changer_lang != "herit")
29
+            sql_updateq('spip_rubriques', array('lang'=>$changer_lang, 'langue_choisie'=>'oui'), "id_rubrique=$id_rubrique");
30
+        else {
31
+            if ($id_parent == 0)
32
+                $langue_parent = $GLOBALS['meta']['langue_site'];
33
+            else {
34
+                $langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=$id_parent");
35
+            }
36
+            sql_updateq('spip_rubriques', array('lang'=>$langue_parent, 'langue_choisie'=>'non'), "id_rubrique=$id_rubrique");
37
+        }
38
+        include_spip('inc/rubriques');
39
+        calculer_langues_rubriques();
40 40
 
41
-		// invalider les caches marques de cette rubrique
42
-		include_spip('inc/invalideur');
43
-		suivre_invalideur("id='rubrique/$id_rubrique'");
44
-	}
41
+        // invalider les caches marques de cette rubrique
42
+        include_spip('inc/invalideur');
43
+        suivre_invalideur("id='rubrique/$id_rubrique'");
44
+    }
45 45
 }
46 46
 ?>
Please login to merge, or discard this patch.
ecrire/action/editer_rubrique.php 1 patch
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -36,31 +36,31 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function action_editer_rubrique_dist($arg=null) {
38 38
 
39
-	if (is_null($arg)){
40
-		$securiser_action = charger_fonction('securiser_action', 'inc');
41
-		$arg = $securiser_action();
42
-	}
43
-
44
-	if (!$id_rubrique = intval($arg)) {
45
-		if ($arg != 'oui') {
46
-			include_spip('inc/headers');
47
-			redirige_url_ecrire();
48
-		}
49
-		$id_rubrique = rubrique_inserer(_request('id_parent'));
50
-	}
51
-
52
-	$err = rubrique_modifier($id_rubrique);
53
-
54
-	if (_request('redirect')) {
55
-		$redirect = parametre_url(
56
-			urldecode(_request('redirect')),
57
-			'id_rubrique', $id_rubrique, '&');
39
+    if (is_null($arg)){
40
+        $securiser_action = charger_fonction('securiser_action', 'inc');
41
+        $arg = $securiser_action();
42
+    }
43
+
44
+    if (!$id_rubrique = intval($arg)) {
45
+        if ($arg != 'oui') {
46
+            include_spip('inc/headers');
47
+            redirige_url_ecrire();
48
+        }
49
+        $id_rubrique = rubrique_inserer(_request('id_parent'));
50
+    }
51
+
52
+    $err = rubrique_modifier($id_rubrique);
53
+
54
+    if (_request('redirect')) {
55
+        $redirect = parametre_url(
56
+            urldecode(_request('redirect')),
57
+            'id_rubrique', $id_rubrique, '&');
58 58
 	
59
-		include_spip('inc/headers');
60
-		redirige_par_entete($redirect);
61
-	}
59
+        include_spip('inc/headers');
60
+        redirige_par_entete($redirect);
61
+    }
62 62
 
63
-	return array($id_rubrique,$err);
63
+    return array($id_rubrique,$err);
64 64
 }
65 65
 
66 66
 
@@ -74,34 +74,34 @@  discard block
 block discarded – undo
74 74
  *     Identifiant de la rubrique crée
75 75
  */
76 76
 function rubrique_inserer($id_parent) {
77
-	$champs = array(
78
-		'titre' => _T('item_nouvelle_rubrique'),
79
-		'id_parent' => intval($id_parent),
80
-		'statut' => 'new');
77
+    $champs = array(
78
+        'titre' => _T('item_nouvelle_rubrique'),
79
+        'id_parent' => intval($id_parent),
80
+        'statut' => 'new');
81 81
 	
82
-	// Envoyer aux plugins
83
-	$champs = pipeline('pre_insertion',
84
-		array(
85
-			'args' => array(
86
-				'table' => 'spip_rubriques',
87
-			),
88
-			'data' => $champs
89
-		)
90
-	);
82
+    // Envoyer aux plugins
83
+    $champs = pipeline('pre_insertion',
84
+        array(
85
+            'args' => array(
86
+                'table' => 'spip_rubriques',
87
+            ),
88
+            'data' => $champs
89
+        )
90
+    );
91 91
 	
92
-	$id_rubrique = sql_insertq("spip_rubriques", $champs);
93
-	pipeline('post_insertion',
94
-		array(
95
-			'args' => array(
96
-				'table' => 'spip_rubriques',
97
-				'id_objet' => $id_rubrique
98
-			),
99
-			'data' => $champs
100
-		)
101
-	);
102
-	propager_les_secteurs();
103
-	calculer_langues_rubriques();
104
-	return $id_rubrique;
92
+    $id_rubrique = sql_insertq("spip_rubriques", $champs);
93
+    pipeline('post_insertion',
94
+        array(
95
+            'args' => array(
96
+                'table' => 'spip_rubriques',
97
+                'id_objet' => $id_rubrique
98
+            ),
99
+            'data' => $champs
100
+        )
101
+    );
102
+    propager_les_secteurs();
103
+    calculer_langues_rubriques();
104
+    return $id_rubrique;
105 105
 }
106 106
 
107 107
 /**
@@ -117,39 +117,39 @@  discard block
 block discarded – undo
117 117
  *     - chaîne : Texte d'un message d'erreur
118 118
  */
119 119
 function rubrique_modifier($id_rubrique, $set=null) {
120
-	include_spip('inc/autoriser');
121
-	include_spip('inc/filtres');
122
-
123
-	include_spip('inc/modifier');
124
-	$c = collecter_requests(
125
-		// white list
126
-		objet_info('rubrique','champs_editables'),
127
-		// black list
128
-		array('id_parent', 'confirme_deplace'),
129
-		// donnees eventuellement fournies
130
-		$set
131
-	);
132
-
133
-	if ($err = objet_modifier_champs('rubrique', $id_rubrique,
134
-		array(
135
-			'data' => $set,
136
-			'nonvide' => array('titre' => _T('titre_nouvelle_rubrique')." "._T('info_numero_abbreviation').$id_rubrique)
137
-		),
138
-		$c))
139
-		return $err;
140
-
141
-	$c = collecter_requests(array('id_parent', 'confirme_deplace'),array(),$set);
142
-	// Deplacer la rubrique
143
-	if (isset($c['id_parent'])) {
144
-		$err = rubrique_instituer($id_rubrique, $c);
145
-	}
146
-
147
-	// invalider les caches marques de cette rubrique
148
-	include_spip('inc/invalideur');
149
-	suivre_invalideur("id='rubrique/$id_rubrique'");
150
-	// et celui de menu_rubriques 
151
-	effacer_meta("date_calcul_rubriques");
152
-	return $err;
120
+    include_spip('inc/autoriser');
121
+    include_spip('inc/filtres');
122
+
123
+    include_spip('inc/modifier');
124
+    $c = collecter_requests(
125
+        // white list
126
+        objet_info('rubrique','champs_editables'),
127
+        // black list
128
+        array('id_parent', 'confirme_deplace'),
129
+        // donnees eventuellement fournies
130
+        $set
131
+    );
132
+
133
+    if ($err = objet_modifier_champs('rubrique', $id_rubrique,
134
+        array(
135
+            'data' => $set,
136
+            'nonvide' => array('titre' => _T('titre_nouvelle_rubrique')." "._T('info_numero_abbreviation').$id_rubrique)
137
+        ),
138
+        $c))
139
+        return $err;
140
+
141
+    $c = collecter_requests(array('id_parent', 'confirme_deplace'),array(),$set);
142
+    // Deplacer la rubrique
143
+    if (isset($c['id_parent'])) {
144
+        $err = rubrique_instituer($id_rubrique, $c);
145
+    }
146
+
147
+    // invalider les caches marques de cette rubrique
148
+    include_spip('inc/invalideur');
149
+    suivre_invalideur("id='rubrique/$id_rubrique'");
150
+    // et celui de menu_rubriques 
151
+    effacer_meta("date_calcul_rubriques");
152
+    return $err;
153 153
 }
154 154
 
155 155
 /**
@@ -173,17 +173,17 @@  discard block
 block discarded – undo
173 173
  */
174 174
 function editer_rubrique_breves($id_rubrique, $id_parent, $c=array())
175 175
 {
176
-	if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique"))
177
-		return true;
176
+    if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique"))
177
+        return true;
178 178
 
179
-	if ($c['confirme_deplace'] != 'oui')
180
-		return false;
179
+    if ($c['confirme_deplace'] != 'oui')
180
+        return false;
181 181
 
182
-	if ($id_secteur = sql_getfetsel("id_secteur",
183
-	"spip_rubriques", "id_rubrique=$id_parent"))
184
-		sql_updateq("spip_breves", array("id_rubrique" => $id_secteur), "id_rubrique=$id_rubrique");
182
+    if ($id_secteur = sql_getfetsel("id_secteur",
183
+    "spip_rubriques", "id_rubrique=$id_parent"))
184
+        sql_updateq("spip_breves", array("id_rubrique" => $id_secteur), "id_rubrique=$id_rubrique");
185 185
 
186
-	return true;
186
+    return true;
187 187
 }
188 188
 
189 189
 
@@ -204,78 +204,78 @@  discard block
 block discarded – undo
204 204
  *     Chaîne : Texte du message d'erreur
205 205
  */
206 206
 function rubrique_instituer($id_rubrique, $c) {
207
-	// traitement de la rubrique parente
208
-	// interdiction de deplacer vers ou a partir d'une rubrique
209
-	// qu'on n'administre pas.
210
-
211
-	if (NULL !== ($id_parent = $c['id_parent'])) {
212
-		$id_parent = intval($id_parent);
213
-		$filles = calcul_branche_in($id_rubrique);
214
-		if (strpos(",$id_parent,", ",$filles,") !== false)
215
-			spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent");
216
-		else {
217
-			$s = sql_fetsel("id_parent, statut", "spip_rubriques", "id_rubrique=$id_rubrique");
218
-			$old_parent = $s['id_parent'];
219
-
220
-			if (!($id_parent != $old_parent
221
-			AND autoriser('publierdans', 'rubrique', $id_parent)
222
-			AND autoriser('creerrubriquedans', 'rubrique', $id_parent)
223
-			AND autoriser('publierdans', 'rubrique', $old_parent)
224
-			      )) {
225
-				if ($s['statut'] != 'new') {
226
-					spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' '.  $GLOBALS['visiteur_session']['statut']);
227
-				}
228
-			}
229
-			elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) {
230
-
231
-				$champs = array('id_parent' => $id_parent);
232
-				$statut_ancien = $s['statut'];
233
-
234
-				// Envoyer aux plugins
235
-				$champs = pipeline('pre_edition',
236
-					array(
237
-						'args' => array(
238
-							'table' => 'spip_rubriques',
239
-							'id_objet' => $id_rubrique,
240
-							'action'=>'instituer',
241
-							'statut_ancien' => $statut_ancien,
242
-						),
243
-						'data' => $champs
244
-					)
245
-				);
246
-
247
-				if (!count($champs)) return '';
248
-
249
-				sql_updateq('spip_rubriques', $champs, "id_rubrique=$id_rubrique");
250
-
251
-				propager_les_secteurs();
252
-
253
-				// Deplacement d'une rubrique publiee ==> chgt general de leur statut
254
-				if ($statut_ancien == 'publie')
255
-					calculer_rubriques_if($old_parent, array('id_rubrique' => $id_parent), $statut_ancien);
256
-				// Creation ou deplacement d'une rubrique non publiee
257
-				// invalider le cache de leur menu
258
-				elseif (!$statut_ancien || $old_parent!=$id_parent)
259
-					effacer_meta("date_calcul_rubriques");
260
-
261
-				calculer_langues_rubriques();
262
-
263
-				// Pipeline
264
-				pipeline('post_edition',
265
-					array(
266
-						'args' => array(
267
-							'table' => 'spip_rubriques',
268
-							'id_objet' => $id_rubrique,
269
-							'action'=>'instituer',
270
-							'statut_ancien' => $statut_ancien,
271
-						),
272
-						'data' => $champs
273
-					)
274
-				);
275
-			}
276
-		}
277
-	}
278
-	return ''; // pas d'erreur
207
+    // traitement de la rubrique parente
208
+    // interdiction de deplacer vers ou a partir d'une rubrique
209
+    // qu'on n'administre pas.
210
+
211
+    if (NULL !== ($id_parent = $c['id_parent'])) {
212
+        $id_parent = intval($id_parent);
213
+        $filles = calcul_branche_in($id_rubrique);
214
+        if (strpos(",$id_parent,", ",$filles,") !== false)
215
+            spip_log("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent");
216
+        else {
217
+            $s = sql_fetsel("id_parent, statut", "spip_rubriques", "id_rubrique=$id_rubrique");
218
+            $old_parent = $s['id_parent'];
219
+
220
+            if (!($id_parent != $old_parent
221
+            AND autoriser('publierdans', 'rubrique', $id_parent)
222
+            AND autoriser('creerrubriquedans', 'rubrique', $id_parent)
223
+            AND autoriser('publierdans', 'rubrique', $old_parent)
224
+                    )) {
225
+                if ($s['statut'] != 'new') {
226
+                    spip_log("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' '.  $GLOBALS['visiteur_session']['statut']);
227
+                }
228
+            }
229
+            elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) {
230
+
231
+                $champs = array('id_parent' => $id_parent);
232
+                $statut_ancien = $s['statut'];
233
+
234
+                // Envoyer aux plugins
235
+                $champs = pipeline('pre_edition',
236
+                    array(
237
+                        'args' => array(
238
+                            'table' => 'spip_rubriques',
239
+                            'id_objet' => $id_rubrique,
240
+                            'action'=>'instituer',
241
+                            'statut_ancien' => $statut_ancien,
242
+                        ),
243
+                        'data' => $champs
244
+                    )
245
+                );
246
+
247
+                if (!count($champs)) return '';
248
+
249
+                sql_updateq('spip_rubriques', $champs, "id_rubrique=$id_rubrique");
250
+
251
+                propager_les_secteurs();
252
+
253
+                // Deplacement d'une rubrique publiee ==> chgt general de leur statut
254
+                if ($statut_ancien == 'publie')
255
+                    calculer_rubriques_if($old_parent, array('id_rubrique' => $id_parent), $statut_ancien);
256
+                // Creation ou deplacement d'une rubrique non publiee
257
+                // invalider le cache de leur menu
258
+                elseif (!$statut_ancien || $old_parent!=$id_parent)
259
+                    effacer_meta("date_calcul_rubriques");
260
+
261
+                calculer_langues_rubriques();
262
+
263
+                // Pipeline
264
+                pipeline('post_edition',
265
+                    array(
266
+                        'args' => array(
267
+                            'table' => 'spip_rubriques',
268
+                            'id_objet' => $id_rubrique,
269
+                            'action'=>'instituer',
270
+                            'statut_ancien' => $statut_ancien,
271
+                        ),
272
+                        'data' => $champs
273
+                    )
274
+                );
275
+            }
276
+        }
277
+    }
278
+    return ''; // pas d'erreur
279 279
 }
280 280
 
281 281
 /**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
  *     Identifiant de la rubrique crée
293 293
 **/
294 294
 function insert_rubrique($id_parent) {
295
-	return rubrique_inserer($id_parent);
295
+    return rubrique_inserer($id_parent);
296 296
 }
297 297
 
298 298
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
  *     - chaîne : Texte d'un message d'erreur
314 314
 **/
315 315
 function revisions_rubriques($id_rubrique, $set=null) {
316
-	return rubrique_modifier($id_rubrique,$set);
316
+    return rubrique_modifier($id_rubrique,$set);
317 317
 }
318 318
 
319 319
 /**
@@ -332,5 +332,5 @@  discard block
 block discarded – undo
332 332
  *     Chaîne : Texte du message d'erreur
333 333
 **/
334 334
 function instituer_rubrique($id_rubrique, $c) {
335
-	return rubrique_instituer($id_rubrique, $c);
335
+    return rubrique_instituer($id_rubrique, $c);
336 336
 }
Please login to merge, or discard this patch.
ecrire/action/confirmer_inscription.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -17,49 +17,49 @@
 block discarded – undo
17 17
  * @return void
18 18
  */
19 19
 function action_confirmer_inscription_dist() {
20
-	$jeton = _request('jeton');
21
-	$email = _request('email');
20
+    $jeton = _request('jeton');
21
+    $email = _request('email');
22 22
 
23
-	include_spip('action/inscrire_auteur');
24
-	if ($auteur = auteur_verifier_jeton($jeton)
25
-	  AND $auteur['email']==$email
26
-	  AND $auteur['statut']=='nouveau'){
23
+    include_spip('action/inscrire_auteur');
24
+    if ($auteur = auteur_verifier_jeton($jeton)
25
+      AND $auteur['email']==$email
26
+      AND $auteur['statut']=='nouveau'){
27 27
 
28
-		// OK c'est un nouvel inscrit qui confirme :
29
-		// on le loge => ca va confirmer son statut et c'est plus sympa
30
-		include_spip('inc/auth');
31
-		auth_loger($auteur);
28
+        // OK c'est un nouvel inscrit qui confirme :
29
+        // on le loge => ca va confirmer son statut et c'est plus sympa
30
+        include_spip('inc/auth');
31
+        auth_loger($auteur);
32 32
 
33
-		// et on efface son jeton
34
-		auteur_effacer_jeton($auteur['id_auteur']);
33
+        // et on efface son jeton
34
+        auteur_effacer_jeton($auteur['id_auteur']);
35 35
 
36
-		// si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur
37
-		// TODO: ne semble pas marcher si inscrit non visiteur, a debug
38
-		if (!_request('redirect')){
39
-			// on passe id_auteur explicite pour forcer une lecture en base de toutes les infos
40
-			if (autoriser('ecrire','','',$auteur['id_auteur'])){
41
-				// poser un cookie admin aussi
42
-				$cookie = charger_fonction('cookie','action');
43
-				$cookie("@".$GLOBALS['visiteur_session']['login']);
44
-				$GLOBALS['redirect'] = _DIR_RESTREINT_ABS;
45
-			}
46
-			else
47
-				$GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
48
-		}
49
-	}
50
-	else {
51
-		// lien perime :
52
-		if ($GLOBALS['visiteur_session']['id_auteur']){
53
-			// on passe id_auteur explicite pour forcer une lecture en base de toutes les infos
54
-			if (autoriser('ecrire','','',$GLOBALS['visiteur_session']['id_auteur']))
55
-				$GLOBALS['redirect'] = _DIR_RESTREINT_ABS;
56
-			else
57
-				$GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
58
-		}
59
-		else
60
-			// rediriger vers la page de login si pas encore loge
61
-			$GLOBALS['redirect'] = parametre_url(generer_url_public('login','',false),'url',_request('redirect'));
62
-	}
36
+        // si pas de redirection demandee, rediriger vers public ou prive selon le statut de l'auteur
37
+        // TODO: ne semble pas marcher si inscrit non visiteur, a debug
38
+        if (!_request('redirect')){
39
+            // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos
40
+            if (autoriser('ecrire','','',$auteur['id_auteur'])){
41
+                // poser un cookie admin aussi
42
+                $cookie = charger_fonction('cookie','action');
43
+                $cookie("@".$GLOBALS['visiteur_session']['login']);
44
+                $GLOBALS['redirect'] = _DIR_RESTREINT_ABS;
45
+            }
46
+            else
47
+                $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
48
+        }
49
+    }
50
+    else {
51
+        // lien perime :
52
+        if ($GLOBALS['visiteur_session']['id_auteur']){
53
+            // on passe id_auteur explicite pour forcer une lecture en base de toutes les infos
54
+            if (autoriser('ecrire','','',$GLOBALS['visiteur_session']['id_auteur']))
55
+                $GLOBALS['redirect'] = _DIR_RESTREINT_ABS;
56
+            else
57
+                $GLOBALS['redirect'] = $GLOBALS['meta']['adresse_site'];
58
+        }
59
+        else
60
+            // rediriger vers la page de login si pas encore loge
61
+            $GLOBALS['redirect'] = parametre_url(generer_url_public('login','',false),'url',_request('redirect'));
62
+    }
63 63
 
64 64
 }
65 65
 
Please login to merge, or discard this patch.
ecrire/action/preferer.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -15,47 +15,47 @@
 block discarded – undo
15 15
 
16 16
 // http://doc.spip.org/@action_preferer_dist
17 17
 function action_preferer_dist() {
18
-	//
19
-	// Preferences de presentation de l'espace prive
20
-	//
21
-	if ($_GET['arg'] !== 'display:4') {
22
-		$securiser_action = charger_fonction('securiser_action', 'inc');
23
-		$arg = $securiser_action();
24
-	} else $arg = $_GET['arg'];
25
-
26
-	if (!preg_match(",^(.+):(.*)$,", $arg, $r))
27
-		spip_log("action_preferer_dist: $arg pas compris");
28
-	else {
29
-	$prefs_mod = false;
30
-
31
-	list(, $op, $val) = $r;
32
-	if ($op == 'couleur') {
33
-		$GLOBALS['visiteur_session']['prefs']['couleur'] = $val;
34
-		$prefs_mod = true;
35
-	}
36
-	elseif ($op == 'display') {
37
-		$GLOBALS['visiteur_session']['prefs']['display'] = $val;
38
-		$prefs_mod = true;
39
-	}
40
-	elseif ($op == 'display_outils') {
41
-		$GLOBALS['visiteur_session']['prefs']['display_outils'] = $val;
42
-		$prefs_mod = true;
43
-	}
44
-
45
-	if ($prefs_mod AND intval($GLOBALS['visiteur_session']['id_auteur']))
46
-		sql_updateq('spip_auteurs', array('prefs' => serialize($GLOBALS['visiteur_session']['prefs'])), "id_auteur=" .intval($GLOBALS['visiteur_session']['id_auteur']));
18
+    //
19
+    // Preferences de presentation de l'espace prive
20
+    //
21
+    if ($_GET['arg'] !== 'display:4') {
22
+        $securiser_action = charger_fonction('securiser_action', 'inc');
23
+        $arg = $securiser_action();
24
+    } else $arg = $_GET['arg'];
25
+
26
+    if (!preg_match(",^(.+):(.*)$,", $arg, $r))
27
+        spip_log("action_preferer_dist: $arg pas compris");
28
+    else {
29
+    $prefs_mod = false;
30
+
31
+    list(, $op, $val) = $r;
32
+    if ($op == 'couleur') {
33
+        $GLOBALS['visiteur_session']['prefs']['couleur'] = $val;
34
+        $prefs_mod = true;
35
+    }
36
+    elseif ($op == 'display') {
37
+        $GLOBALS['visiteur_session']['prefs']['display'] = $val;
38
+        $prefs_mod = true;
39
+    }
40
+    elseif ($op == 'display_outils') {
41
+        $GLOBALS['visiteur_session']['prefs']['display_outils'] = $val;
42
+        $prefs_mod = true;
43
+    }
44
+
45
+    if ($prefs_mod AND intval($GLOBALS['visiteur_session']['id_auteur']))
46
+        sql_updateq('spip_auteurs', array('prefs' => serialize($GLOBALS['visiteur_session']['prefs'])), "id_auteur=" .intval($GLOBALS['visiteur_session']['id_auteur']));
47 47
 	
48
-	if ($op == 'spip_ecran') {
49
-		// Poser un cookie,
50
-		// car ce reglage depend plus du navigateur que de l'utilisateur
51
-		$GLOBALS['spip_ecran'] = $val;
52
-		include_spip('inc/cookie');
53
-		spip_setcookie('spip_ecran', $val, time() + 365 * 24 * 3600);
54
-	}
55
-
56
-	// Si modif des couleurs en ajax, redirect inutile on a change de CSS
57
-	if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') exit;
58
-
59
-	}
48
+    if ($op == 'spip_ecran') {
49
+        // Poser un cookie,
50
+        // car ce reglage depend plus du navigateur que de l'utilisateur
51
+        $GLOBALS['spip_ecran'] = $val;
52
+        include_spip('inc/cookie');
53
+        spip_setcookie('spip_ecran', $val, time() + 365 * 24 * 3600);
54
+    }
55
+
56
+    // Si modif des couleurs en ajax, redirect inutile on a change de CSS
57
+    if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') exit;
58
+
59
+    }
60 60
 }
61 61
 ?>
Please login to merge, or discard this patch.
ecrire/action/reorganiser.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -16,75 +16,75 @@
 block discarded – undo
16 16
 
17 17
 // http://doc.spip.org/@gerer_deplacements
18 18
 function gerer_deplacements($deplacements){
19
-	foreach(explode("\n",$deplacements) as $dep){
20
-		$mouvement=explode(":",$dep);
21
-		list($quoi,$id_quoi) = explode("-",$mouvement[0]);
22
-		list($cible, $id_cible) =explode("-",$mouvement[1]);
23
-		$f = 'reorganiser_' . $quoi . '_' . $cible;
24
-		if (function_exists($f))
25
-			$f(intval($id_quoi), intval($id_cible));
26
-		else spip_log("reorganiser $dep: incompris");
27
-	}
19
+    foreach(explode("\n",$deplacements) as $dep){
20
+        $mouvement=explode(":",$dep);
21
+        list($quoi,$id_quoi) = explode("-",$mouvement[0]);
22
+        list($cible, $id_cible) =explode("-",$mouvement[1]);
23
+        $f = 'reorganiser_' . $quoi . '_' . $cible;
24
+        if (function_exists($f))
25
+            $f(intval($id_quoi), intval($id_cible));
26
+        else spip_log("reorganiser $dep: incompris");
27
+    }
28 28
 }
29 29
 
30 30
 // http://doc.spip.org/@reorganiser_article_rubrique
31 31
 function reorganiser_article_rubrique($id_article, $id_rubrique)
32 32
 {
33
-	if ($id_rubrique
34
-	AND autoriser('modifier','rubrique',$id_rubrique)
35
-	AND autoriser('modifier','article',$id_article)) {
36
-
37
-		include_spip('action/editer_article');
38
-		include_spip('inc/rubriques');
39
-		$s = sql_fetsel("statut, id_rubrique", "spip_articles", "id_article=$id_article");
40
-		editer_article_heritage($id_article,
41
-					$s['id_rubrique'], 
42
-					$s['statut'],
43
-					array('id_rubrique' => $id_rubrique));
44
-	}
33
+    if ($id_rubrique
34
+    AND autoriser('modifier','rubrique',$id_rubrique)
35
+    AND autoriser('modifier','article',$id_article)) {
36
+
37
+        include_spip('action/editer_article');
38
+        include_spip('inc/rubriques');
39
+        $s = sql_fetsel("statut, id_rubrique", "spip_articles", "id_article=$id_article");
40
+        editer_article_heritage($id_article,
41
+                    $s['id_rubrique'], 
42
+                    $s['statut'],
43
+                    array('id_rubrique' => $id_rubrique));
44
+    }
45 45
 }
46 46
 
47 47
 // http://doc.spip.org/@reorganiser_rubrique_rubrique
48 48
 function reorganiser_rubrique_rubrique($id_quoi, $id_cible)
49 49
 {
50
-	if (($id_quoi != $id_cible)
51
-	AND autoriser('modifier','rubrique',$id_cible)
52
-	AND autoriser('modifier','rubrique',$id_quoi)) {
53
-		if (!$id_cible)
54
-			$id_secteur = $id_quoi;
55
-		else {
56
-			$id_secteur = sql_getfetsel("id_secteur", "spip_rubriques", "id_rubrique=$id_cible");
57
-		}
58
-
59
-		$s = sql_fetsel("statut, id_parent, id_secteur", "spip_rubriques", "id_rubrique=".intval($id_quoi));
60
-
61
-		sql_updateq('spip_rubriques', array('id_parent' => $id_cible, 'id_secteur'=>$id_secteur),  "id_rubrique=".intval($id_quoi));
62
-
63
-		include_spip('inc/rubriques');
64
-		// propager les secteurs si besoin
65
-		if ($s['id_secteur']!=$id_secteur)
66
-			propager_les_secteurs();
67
-		// changer le statut de la rubrique source
68
-		if ($s['statut'] == 'publie')
69
-			calculer_rubriques_if($s['id_parent'],
70
-					      array('id_rubrique' => $id_cible),
71
-					      'publie');
72
-	}
50
+    if (($id_quoi != $id_cible)
51
+    AND autoriser('modifier','rubrique',$id_cible)
52
+    AND autoriser('modifier','rubrique',$id_quoi)) {
53
+        if (!$id_cible)
54
+            $id_secteur = $id_quoi;
55
+        else {
56
+            $id_secteur = sql_getfetsel("id_secteur", "spip_rubriques", "id_rubrique=$id_cible");
57
+        }
58
+
59
+        $s = sql_fetsel("statut, id_parent, id_secteur", "spip_rubriques", "id_rubrique=".intval($id_quoi));
60
+
61
+        sql_updateq('spip_rubriques', array('id_parent' => $id_cible, 'id_secteur'=>$id_secteur),  "id_rubrique=".intval($id_quoi));
62
+
63
+        include_spip('inc/rubriques');
64
+        // propager les secteurs si besoin
65
+        if ($s['id_secteur']!=$id_secteur)
66
+            propager_les_secteurs();
67
+        // changer le statut de la rubrique source
68
+        if ($s['statut'] == 'publie')
69
+            calculer_rubriques_if($s['id_parent'],
70
+                            array('id_rubrique' => $id_cible),
71
+                            'publie');
72
+    }
73 73
 }
74 74
 
75 75
 // http://doc.spip.org/@action_reorganiser_dist
76 76
 function action_reorganiser_dist(){
77 77
 
78
-	$securiser_action = charger_fonction('securiser_action', 'inc');
79
-	$securiser_action();
78
+    $securiser_action = charger_fonction('securiser_action', 'inc');
79
+    $securiser_action();
80 80
 
81
-	if (_request('deplacements')!==NULL)
82
-		  gerer_deplacements(_request('deplacements'));
81
+    if (_request('deplacements')!==NULL)
82
+            gerer_deplacements(_request('deplacements'));
83 83
 
84
-	$redirect = _request('redirect');
85
-	if ($redirect==NULL) $redirect="";
84
+    $redirect = _request('redirect');
85
+    if ($redirect==NULL) $redirect="";
86 86
 
87
-	redirige_par_entete(str_replace("&","&",urldecode($redirect)));
87
+    redirige_par_entete(str_replace("&","&",urldecode($redirect)));
88 88
 }
89 89
 
90 90
 
Please login to merge, or discard this patch.
ecrire/action/cookie.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -17,83 +17,83 @@
 block discarded – undo
17 17
 
18 18
 // http://doc.spip.org/@action_cookie_dist
19 19
 function action_cookie_dist($set_cookie_admin=null, $change_session = null) {
20
-	$redirect_echec = $redirect = null;
21
-	$test_echec_cookie = null;
22
-	$url = "";
23
-	if (is_null($set_cookie_admin)){
24
-		$set_cookie_admin = _request('cookie_admin');
25
-		$change_session = _request('change_session');
26
-		$test_echec_cookie = _request('test_echec_cookie');
20
+    $redirect_echec = $redirect = null;
21
+    $test_echec_cookie = null;
22
+    $url = "";
23
+    if (is_null($set_cookie_admin)){
24
+        $set_cookie_admin = _request('cookie_admin');
25
+        $change_session = _request('change_session');
26
+        $test_echec_cookie = _request('test_echec_cookie');
27 27
 
28
-		// La cible de notre operation de connexion
29
-		$url = securiser_redirect_action(_request('url'));
30
-		$redirect = $url ? $url : generer_url_ecrire('accueil');
31
-		$redirect_echec = _request('url_echec');
32
-		if (!isset($redirect_echec)) {
33
-			if (strpos($redirect,_DIR_RESTREINT_ABS)!==false)
34
-				$redirect_echec = generer_url_public('login','',true);
35
-			else
36
-				$redirect_echec = $redirect;
37
-		}
38
-	}
28
+        // La cible de notre operation de connexion
29
+        $url = securiser_redirect_action(_request('url'));
30
+        $redirect = $url ? $url : generer_url_ecrire('accueil');
31
+        $redirect_echec = _request('url_echec');
32
+        if (!isset($redirect_echec)) {
33
+            if (strpos($redirect,_DIR_RESTREINT_ABS)!==false)
34
+                $redirect_echec = generer_url_public('login','',true);
35
+            else
36
+                $redirect_echec = $redirect;
37
+        }
38
+    }
39 39
 
40 40
 
41
-	// rejoue le cookie pour renouveler spip_session
42
-	if ($change_session == 'oui') {
43
-		$session = charger_fonction('session', 'inc');
44
-		$session(true);
45
-		spip_log("statut 204 pour " . $_SERVER['REQUEST_URI']);
46
-		http_status(204); // No Content
47
-		return;
48
-	}
41
+    // rejoue le cookie pour renouveler spip_session
42
+    if ($change_session == 'oui') {
43
+        $session = charger_fonction('session', 'inc');
44
+        $session(true);
45
+        spip_log("statut 204 pour " . $_SERVER['REQUEST_URI']);
46
+        http_status(204); // No Content
47
+        return;
48
+    }
49 49
 
50
-	// tentative de connexion en auth_http
51
-	if (_request('essai_auth_http') AND !$GLOBALS['ignore_auth_http']) {
52
-		include_spip('inc/auth');
53
-		if (@$_SERVER['PHP_AUTH_USER']
54
-		AND @$_SERVER['PHP_AUTH_PW']
55
-		AND $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])){
56
-			auth_loger($auteur);
57
-			redirige_par_entete(parametre_url($redirect,'t',time(),'&'));
58
-		}
59
-		else {
60
-			ask_php_auth(_T('info_connexion_refusee'),
61
-			     _T('login_login_pass_incorrect'),
62
-			     _T('login_retour_site'),
63
-			     "url=".rawurlencode($redirect),
64
-			     _T('login_nouvelle_tentative'),
65
-			     (strpos($url,_DIR_RESTREINT_ABS)!==false));
66
-		}
67
-	}
68
-	else {
50
+    // tentative de connexion en auth_http
51
+    if (_request('essai_auth_http') AND !$GLOBALS['ignore_auth_http']) {
52
+        include_spip('inc/auth');
53
+        if (@$_SERVER['PHP_AUTH_USER']
54
+        AND @$_SERVER['PHP_AUTH_PW']
55
+        AND $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'])){
56
+            auth_loger($auteur);
57
+            redirige_par_entete(parametre_url($redirect,'t',time(),'&'));
58
+        }
59
+        else {
60
+            ask_php_auth(_T('info_connexion_refusee'),
61
+                    _T('login_login_pass_incorrect'),
62
+                    _T('login_retour_site'),
63
+                    "url=".rawurlencode($redirect),
64
+                    _T('login_nouvelle_tentative'),
65
+                    (strpos($url,_DIR_RESTREINT_ABS)!==false));
66
+        }
67
+    }
68
+    else {
69 69
 		
70
-		// en cas de login sur bonjour=oui, on tente de poser un cookie
71
-		// puis de passer au login qui diagnostiquera l'echec de cookie
72
-		// le cas echeant.
73
-		if ($test_echec_cookie == 'oui') {
74
-			spip_setcookie('spip_session', 'test_echec_cookie');
75
-			if ($redirect)
76
-				$redirect = parametre_url(parametre_url($redirect_echec,'var_echec_cookie','oui','&'),'url',rawurlencode($redirect),'&');
77
-		}
78
-		else {
70
+        // en cas de login sur bonjour=oui, on tente de poser un cookie
71
+        // puis de passer au login qui diagnostiquera l'echec de cookie
72
+        // le cas echeant.
73
+        if ($test_echec_cookie == 'oui') {
74
+            spip_setcookie('spip_session', 'test_echec_cookie');
75
+            if ($redirect)
76
+                $redirect = parametre_url(parametre_url($redirect_echec,'var_echec_cookie','oui','&'),'url',rawurlencode($redirect),'&');
77
+        }
78
+        else {
79 79
 
80
-			$cook = isset($_COOKIE['spip_admin']) ? $_COOKIE['spip_admin'] : '';
81
-			// Suppression cookie d'admin ?
82
-			if ($set_cookie_admin == "non") {
83
-				if ($cook)
84
-					spip_setcookie('spip_admin', $cook, time() - 3600 * 24);
85
-			}
86
-			// Ajout de cookie d'admin
87
-			else if ($set_cookie_admin) {
88
-				spip_setcookie('spip_admin', $set_cookie_admin,
89
-					time() + 14 * 24 * 3600);
90
-			}
91
-		}
92
-	}
80
+            $cook = isset($_COOKIE['spip_admin']) ? $_COOKIE['spip_admin'] : '';
81
+            // Suppression cookie d'admin ?
82
+            if ($set_cookie_admin == "non") {
83
+                if ($cook)
84
+                    spip_setcookie('spip_admin', $cook, time() - 3600 * 24);
85
+            }
86
+            // Ajout de cookie d'admin
87
+            else if ($set_cookie_admin) {
88
+                spip_setcookie('spip_admin', $set_cookie_admin,
89
+                    time() + 14 * 24 * 3600);
90
+            }
91
+        }
92
+    }
93 93
 	
94
-	// Redirection finale
95
-	if ($redirect)
96
-		redirige_par_entete($redirect, true);
94
+    // Redirection finale
95
+    if ($redirect)
96
+        redirige_par_entete($redirect, true);
97 97
 }
98 98
 
99 99
 ?>
Please login to merge, or discard this patch.
ecrire/action/menu_rubriques.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -18,142 +18,142 @@
 block discarded – undo
18 18
 
19 19
 function action_menu_rubriques_dist() {
20 20
 
21
-	// si pas acces a ecrire, pas acces au menu
22
-	// on renvoi un 401 qui fait echouer la requete ajax silencieusement
23
-	if (!autoriser('ecrire')){
24
-		$retour = "<ul class='cols_1'><li class='toutsite'><a href='".generer_url_ecrire('accueil')."'>"._T('public:lien_connecter')."</a></li></ul>";
25
-		include_spip('inc/actions');
26
-		ajax_retour($retour);
27
-		exit;
28
-	}
29
-
30
-	if ($date = intval(_request('date')))
31
-		header("Last-Modified: ".gmdate("D, d M Y H:i:s", $date)." GMT");
32
-
33
-	$r = gen_liste_rubriques();
34
-	if (!$r
35
-	AND isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
36
-	AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/')) {
37
-		include_spip('inc/headers');
38
-		header('Content-Type: text/html; charset='. $GLOBALS['meta']['charset']);
39
-		http_status(304);
40
-		exit;
41
-	} else {
42
-		include_spip('inc/actions');
43
-		$ret = menu_rubriques();
44
-		ajax_retour($ret);
45
-	}
21
+    // si pas acces a ecrire, pas acces au menu
22
+    // on renvoi un 401 qui fait echouer la requete ajax silencieusement
23
+    if (!autoriser('ecrire')){
24
+        $retour = "<ul class='cols_1'><li class='toutsite'><a href='".generer_url_ecrire('accueil')."'>"._T('public:lien_connecter')."</a></li></ul>";
25
+        include_spip('inc/actions');
26
+        ajax_retour($retour);
27
+        exit;
28
+    }
29
+
30
+    if ($date = intval(_request('date')))
31
+        header("Last-Modified: ".gmdate("D, d M Y H:i:s", $date)." GMT");
32
+
33
+    $r = gen_liste_rubriques();
34
+    if (!$r
35
+    AND isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])
36
+    AND !strstr($_SERVER['SERVER_SOFTWARE'],'IIS/')) {
37
+        include_spip('inc/headers');
38
+        header('Content-Type: text/html; charset='. $GLOBALS['meta']['charset']);
39
+        http_status(304);
40
+        exit;
41
+    } else {
42
+        include_spip('inc/actions');
43
+        $ret = menu_rubriques();
44
+        ajax_retour($ret);
45
+    }
46 46
 }
47 47
 
48 48
 function menu_rubriques($complet = true){
49
-	$ret = "<li class='toutsite'><a href='".generer_url_ecrire('plan')."'>"._T('info_tout_site')."</a></li>";
50
-
51
-	if (!$complet) {
52
-		return "<ul class='cols_1'>$ret\n</ul>\n";
53
-	}
54
-
55
-	if (!isset($GLOBALS['db_art_cache'])){
56
-		gen_liste_rubriques();
57
-	}
58
-	$arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
59
-
60
-	$total_lignes = $i = sizeof($arr_low);
61
-
62
-	if ($i > 0) {
63
-		$nb_col = min(8,ceil($total_lignes / 30));
64
-		if ($nb_col <= 1) $nb_col =  ceil($total_lignes / 10);
65
-		foreach( $arr_low as $id_rubrique => $titre_rubrique) {
66
-			if (autoriser('voir','rubrique',$id_rubrique)){
67
-			  $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
68
-			  $i++;
69
-			}
70
-		}
71
-
72
-		$ret = "<ul class='cols_$nb_col'>"
73
-		  . $ret
74
-		  . "\n</ul>\n";
75
-	}
76
-	else
77
-		$ret = "<ul class='cols_1'>$ret\n</ul>\n";
49
+    $ret = "<li class='toutsite'><a href='".generer_url_ecrire('plan')."'>"._T('info_tout_site')."</a></li>";
50
+
51
+    if (!$complet) {
52
+        return "<ul class='cols_1'>$ret\n</ul>\n";
53
+    }
54
+
55
+    if (!isset($GLOBALS['db_art_cache'])){
56
+        gen_liste_rubriques();
57
+    }
58
+    $arr_low = extraire_article(0, $GLOBALS['db_art_cache']);
59
+
60
+    $total_lignes = $i = sizeof($arr_low);
61
+
62
+    if ($i > 0) {
63
+        $nb_col = min(8,ceil($total_lignes / 30));
64
+        if ($nb_col <= 1) $nb_col =  ceil($total_lignes / 10);
65
+        foreach( $arr_low as $id_rubrique => $titre_rubrique) {
66
+            if (autoriser('voir','rubrique',$id_rubrique)){
67
+                $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i);
68
+                $i++;
69
+            }
70
+        }
71
+
72
+        $ret = "<ul class='cols_$nb_col'>"
73
+            . $ret
74
+            . "\n</ul>\n";
75
+    }
76
+    else
77
+        $ret = "<ul class='cols_1'>$ret\n</ul>\n";
78 78
 	
79
-	return $ret;
79
+    return $ret;
80 80
 }
81 81
 
82 82
 // http://doc.spip.org/@bandeau_rubrique
83 83
 function bandeau_rubrique($id_rubrique, $titre_rubrique, $zdecal) {
84
-	static $zmax = 6;
85
-
86
-	$nav = "<a href='"
87
-	. generer_url_entite($id_rubrique,'rubrique','','',false)
88
-	. "'>"
89
-	. supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique))
90
-	. "</a>\n";
91
-
92
-	// Limiter volontairement le nombre de sous-menus
93
-	if (!(--$zmax)) {
94
-		$zmax++;
95
-		return "\n<li>$nav</li>";
96
-	}
97
-
98
-	$arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
99
-	$i = sizeof($arr_rub);
100
-	if (!$i) {
101
-		$zmax++;
102
-		return "\n<li>$nav</li>";
103
-	}
104
-
105
-
106
-	$nb_col = 1;
107
-	if ($nb_rub = count($arr_rub)) {
108
-		$nb_col = min(10,max(1,ceil($nb_rub / 10)));
109
-	}
110
-	$ret = "<li class='haschild'>$nav<ul class='cols_$nb_col'>";
111
-	foreach( $arr_rub as $id_rub => $titre_rub) {
112
-		if (autoriser('voir','rubrique',$id_rub)){
113
-			$titre = supprimer_numero(typo($titre_rub));
114
-			$ret .= bandeau_rubrique($id_rub, $titre, $zdecal+$i);
115
-			$i++;
116
-		}
117
-	}
118
-	$ret .= "</ul></li>\n";
119
-	$zmax++;
120
-	return $ret;
84
+    static $zmax = 6;
85
+
86
+    $nav = "<a href='"
87
+    . generer_url_entite($id_rubrique,'rubrique','','',false)
88
+    . "'>"
89
+    . supprimer_tags(preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique))
90
+    . "</a>\n";
91
+
92
+    // Limiter volontairement le nombre de sous-menus
93
+    if (!(--$zmax)) {
94
+        $zmax++;
95
+        return "\n<li>$nav</li>";
96
+    }
97
+
98
+    $arr_rub = extraire_article($id_rubrique, $GLOBALS['db_art_cache']);
99
+    $i = sizeof($arr_rub);
100
+    if (!$i) {
101
+        $zmax++;
102
+        return "\n<li>$nav</li>";
103
+    }
104
+
105
+
106
+    $nb_col = 1;
107
+    if ($nb_rub = count($arr_rub)) {
108
+        $nb_col = min(10,max(1,ceil($nb_rub / 10)));
109
+    }
110
+    $ret = "<li class='haschild'>$nav<ul class='cols_$nb_col'>";
111
+    foreach( $arr_rub as $id_rub => $titre_rub) {
112
+        if (autoriser('voir','rubrique',$id_rub)){
113
+            $titre = supprimer_numero(typo($titre_rub));
114
+            $ret .= bandeau_rubrique($id_rub, $titre, $zdecal+$i);
115
+            $i++;
116
+        }
117
+    }
118
+    $ret .= "</ul></li>\n";
119
+    $zmax++;
120
+    return $ret;
121 121
 }
122 122
 
123 123
 
124 124
 // http://doc.spip.org/@extraire_article
125 125
 function extraire_article($id_p, $t) {
126
-	return array_key_exists($id_p, $t) ?  $t[$id_p]: array();
126
+    return array_key_exists($id_p, $t) ?  $t[$id_p]: array();
127 127
 }
128 128
 
129 129
 // http://doc.spip.org/@gen_liste_rubriques
130 130
 function gen_liste_rubriques() {
131 131
 
132
-	include_spip('inc/config');
133
-	// ici, un petit fichier cache ne fait pas de mal
134
-	$last = lire_config('date_calcul_rubriques', 0);
135
-	if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
136
-		list($date,$GLOBALS['db_art_cache']) = @unserialize($cache);
137
-		if ($date == $last) return false; // c'etait en cache :-)
138
-	}
139
-	// se restreindre aux rubriques utilisees recemment +secteurs
132
+    include_spip('inc/config');
133
+    // ici, un petit fichier cache ne fait pas de mal
134
+    $last = lire_config('date_calcul_rubriques', 0);
135
+    if (lire_fichier(_CACHE_RUBRIQUES, $cache)) {
136
+        list($date,$GLOBALS['db_art_cache']) = @unserialize($cache);
137
+        if ($date == $last) return false; // c'etait en cache :-)
138
+    }
139
+    // se restreindre aux rubriques utilisees recemment +secteurs
140 140
 
141
-	$where = sql_in_select("id_rubrique", "id_rubrique", "spip_rubriques", "", "", "id_parent=0 DESC, date DESC", _CACHE_RUBRIQUES_MAX);
141
+    $where = sql_in_select("id_rubrique", "id_rubrique", "spip_rubriques", "", "", "id_parent=0 DESC, date DESC", _CACHE_RUBRIQUES_MAX);
142 142
 
143
-	// puis refaire la requete pour avoir l'ordre alphabetique
143
+    // puis refaire la requete pour avoir l'ordre alphabetique
144 144
 
145
-	$res = sql_select("id_rubrique, titre, id_parent", "spip_rubriques", $where, '', 'id_parent, 0+titre, titre');
145
+    $res = sql_select("id_rubrique, titre, id_parent", "spip_rubriques", $where, '', 'id_parent, 0+titre, titre');
146 146
 
147
-	// il ne faut pas filtrer le autoriser voir ici
148
-	// car on met le resultat en cache, commun a tout le monde
149
-	$GLOBALS['db_art_cache'] = array();
150
-	while ($r = sql_fetch($res)) {
151
-		$t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
152
-		$GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
153
-	}
147
+    // il ne faut pas filtrer le autoriser voir ici
148
+    // car on met le resultat en cache, commun a tout le monde
149
+    $GLOBALS['db_art_cache'] = array();
150
+    while ($r = sql_fetch($res)) {
151
+        $t = sinon($r['titre'], _T('ecrire:info_sans_titre'));
152
+        $GLOBALS['db_art_cache'][$r['id_parent']][$r['id_rubrique']] = supprimer_numero(typo($t));
153
+    }
154 154
 
155
-	$t = array($last ? $last : time(), $GLOBALS['db_art_cache']);
156
-	ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
157
-	return true;
155
+    $t = array($last ? $last : time(), $GLOBALS['db_art_cache']);
156
+    ecrire_fichier(_CACHE_RUBRIQUES, serialize($t));
157
+    return true;
158 158
 }
159 159
 ?>
Please login to merge, or discard this patch.
ecrire/action/instituer_langue_objet.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -22,42 +22,42 @@
 block discarded – undo
22 22
  * @return string
23 23
  */
24 24
 function action_instituer_langue_objet_dist($objet, $id, $id_rubrique, $changer_lang, $serveur='') {
25
-	if ($changer_lang) {
26
-		$table_objet_sql = table_objet_sql($objet);
27
-		$id_table_objet = id_table_objet($objet);
28
-		$trouver_table = charger_fonction('trouver_table', 'base');
29
-		$desc = $trouver_table($table_objet_sql, $serveur);
25
+    if ($changer_lang) {
26
+        $table_objet_sql = table_objet_sql($objet);
27
+        $id_table_objet = id_table_objet($objet);
28
+        $trouver_table = charger_fonction('trouver_table', 'base');
29
+        $desc = $trouver_table($table_objet_sql, $serveur);
30 30
 		
31
-		$set = array();
32
-		if (isset($desc['field']['langue_choisie'])){
33
-			$set['langue_choisie'] = 'oui';
34
-		}
31
+        $set = array();
32
+        if (isset($desc['field']['langue_choisie'])){
33
+            $set['langue_choisie'] = 'oui';
34
+        }
35 35
 		
36
-		if ($changer_lang != "herit") {
37
-			$set['lang'] = $changer_lang;
38
-			sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id),'',$serveur);
39
-			include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees
40
-			if ($table_objet_sql == 'spip_rubriques') {
41
-				calculer_langues_rubriques();
42
-			}
43
-			$langues = calculer_langues_utilisees($serveur);
44
-			ecrire_meta('langues_utilisees', $langues);
45
-		}
46
-		else {
47
-			$langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=" . intval($id_rubrique));
48
-			if (!$langue_parent)
49
-				$langue_parent = $GLOBALS['meta']['langue_site'];
50
-			$changer_lang = $langue_parent;
51
-			$set['lang'] = $changer_lang;
52
-			if (isset($set['langue_choisie'])){
53
-				$set['langue_choisie'] = 'non';
54
-			}
55
-			sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id),'',$serveur);
56
-			if ($table_objet_sql == 'spip_rubriques') {
57
-				include_spip('inc/rubriques');
58
-				calculer_langues_rubriques();
59
-			}
60
-		}
61
-	}
62
-	return $changer_lang;
36
+        if ($changer_lang != "herit") {
37
+            $set['lang'] = $changer_lang;
38
+            sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id),'',$serveur);
39
+            include_spip('inc/rubriques'); // pour calculer_langues_rubriques et calculer_langues_utilisees
40
+            if ($table_objet_sql == 'spip_rubriques') {
41
+                calculer_langues_rubriques();
42
+            }
43
+            $langues = calculer_langues_utilisees($serveur);
44
+            ecrire_meta('langues_utilisees', $langues);
45
+        }
46
+        else {
47
+            $langue_parent = sql_getfetsel("lang", "spip_rubriques", "id_rubrique=" . intval($id_rubrique));
48
+            if (!$langue_parent)
49
+                $langue_parent = $GLOBALS['meta']['langue_site'];
50
+            $changer_lang = $langue_parent;
51
+            $set['lang'] = $changer_lang;
52
+            if (isset($set['langue_choisie'])){
53
+                $set['langue_choisie'] = 'non';
54
+            }
55
+            sql_updateq($table_objet_sql, $set, "$id_table_objet=" . intval($id),'',$serveur);
56
+            if ($table_objet_sql == 'spip_rubriques') {
57
+                include_spip('inc/rubriques');
58
+                calculer_langues_rubriques();
59
+            }
60
+        }
61
+    }
62
+    return $changer_lang;
63 63
 }
Please login to merge, or discard this patch.