Completed
Push — spip-3.0 ( 484b62...e817f1 )
by cam
34:33
created
ecrire/inc/modifier.php 1 patch
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -37,28 +37,28 @@  discard block
 block discarded – undo
37 37
  *     Tableau des champs et valeurs collectées 
38 38
  */
39 39
 function collecter_requests($white_list, $black_list, $set=null, $tous=false){
40
-	$c = $set;
41
-	if (!$c){
42
-		$c = array();
43
-		foreach($white_list as $champ) {
44
-			// on ne collecte que les champs reellement envoyes par defaut.
45
-			// le cas d'un envoi de valeur NULL peut du coup poser probleme.
46
-			$val = _request($champ);
47
-			if ($tous OR $val !== NULL) {
48
-				$c[$champ] = $val;
49
-			}
50
-		}
51
-		// on ajoute toujours la lang en saisie possible
52
-		// meme si pas prevu au depart pour l'objet concerne
53
-		if ($l = _request('changer_lang')){
54
-			$c['lang'] = $l;
55
-		}
56
-	}
57
-	foreach($black_list as $champ) {
58
-		unset($c[$champ]);
59
-	}
40
+    $c = $set;
41
+    if (!$c){
42
+        $c = array();
43
+        foreach($white_list as $champ) {
44
+            // on ne collecte que les champs reellement envoyes par defaut.
45
+            // le cas d'un envoi de valeur NULL peut du coup poser probleme.
46
+            $val = _request($champ);
47
+            if ($tous OR $val !== NULL) {
48
+                $c[$champ] = $val;
49
+            }
50
+        }
51
+        // on ajoute toujours la lang en saisie possible
52
+        // meme si pas prevu au depart pour l'objet concerne
53
+        if ($l = _request('changer_lang')){
54
+            $c['lang'] = $l;
55
+        }
56
+    }
57
+    foreach($black_list as $champ) {
58
+        unset($c[$champ]);
59
+    }
60 60
 	
61
-	return $c;
61
+    return $c;
62 62
 }
63 63
 
64 64
 /**
@@ -95,183 +95,183 @@  discard block
 block discarded – undo
95 95
  *     - chaîne : Texte d'un message d'erreur
96 96
  */
97 97
 function objet_modifier_champs($objet, $id_objet, $options, $c=null, $serveur='') {
98
-	if (!$id_objet = intval($id_objet)) {
99
-		spip_log('Erreur $id_objet non defini', 'warn');
100
-		return _T('erreur_technique_enregistrement_impossible');
101
-	}
98
+    if (!$id_objet = intval($id_objet)) {
99
+        spip_log('Erreur $id_objet non defini', 'warn');
100
+        return _T('erreur_technique_enregistrement_impossible');
101
+    }
102 102
 
103
-	include_spip('inc/filtres');
103
+    include_spip('inc/filtres');
104 104
 
105
-	$table_objet = table_objet($objet,$serveur);
106
-	$spip_table_objet = table_objet_sql($objet,$serveur);
107
-	$id_table_objet = id_table_objet($objet,$serveur);
108
-	$trouver_table = charger_fonction('trouver_table', 'base');
109
-	$desc = $trouver_table($spip_table_objet, $serveur);
105
+    $table_objet = table_objet($objet,$serveur);
106
+    $spip_table_objet = table_objet_sql($objet,$serveur);
107
+    $id_table_objet = id_table_objet($objet,$serveur);
108
+    $trouver_table = charger_fonction('trouver_table', 'base');
109
+    $desc = $trouver_table($spip_table_objet, $serveur);
110 110
 
111
-	// Appels incomplets (sans $c)
112
-	if (!is_array($c)) {
113
-		spip_log('erreur appel objet_modifier_champs('.$objet.'), manque $c');
114
-		return _T('erreur_technique_enregistrement_impossible');
115
-	}
111
+    // Appels incomplets (sans $c)
112
+    if (!is_array($c)) {
113
+        spip_log('erreur appel objet_modifier_champs('.$objet.'), manque $c');
114
+        return _T('erreur_technique_enregistrement_impossible');
115
+    }
116 116
 
117
-	// Securite : certaines variables ne sont jamais acceptees ici
118
-	// car elles ne relevent pas de autoriser(xxx, modifier) ;
119
-	// il faut passer par instituer_XX()
120
-	// TODO: faut-il passer ces variables interdites
121
-	// dans un fichier de description separe ?
122
-	unset($c['statut']);
123
-	unset($c['id_parent']);
124
-	unset($c['id_rubrique']);
125
-	unset($c['id_secteur']);
117
+    // Securite : certaines variables ne sont jamais acceptees ici
118
+    // car elles ne relevent pas de autoriser(xxx, modifier) ;
119
+    // il faut passer par instituer_XX()
120
+    // TODO: faut-il passer ces variables interdites
121
+    // dans un fichier de description separe ?
122
+    unset($c['statut']);
123
+    unset($c['id_parent']);
124
+    unset($c['id_rubrique']);
125
+    unset($c['id_secteur']);
126 126
 
127
-	// Gerer les champs non vides
128
-	if (isset($options['nonvide']) AND is_array($options['nonvide'])) {
129
-		foreach ($options['nonvide'] as $champ => $sinon) {
130
-			if ($c[$champ] === '') {
131
-				$c[$champ] = $sinon;
132
-			}
133
-		}
134
-	}
127
+    // Gerer les champs non vides
128
+    if (isset($options['nonvide']) AND is_array($options['nonvide'])) {
129
+        foreach ($options['nonvide'] as $champ => $sinon) {
130
+            if ($c[$champ] === '') {
131
+                $c[$champ] = $sinon;
132
+            }
133
+        }
134
+    }
135 135
 
136 136
 
137
-	// N'accepter que les champs qui existent
138
-	// TODO: ici aussi on peut valider les contenus
139
-	// en fonction du type
140
-	$champs = array();
141
-	foreach($desc['field'] as $champ => $ignore)
142
-		if (isset($c[$champ]))
143
-			$champs[$champ] = $c[$champ];
137
+    // N'accepter que les champs qui existent
138
+    // TODO: ici aussi on peut valider les contenus
139
+    // en fonction du type
140
+    $champs = array();
141
+    foreach($desc['field'] as $champ => $ignore)
142
+        if (isset($c[$champ]))
143
+            $champs[$champ] = $c[$champ];
144 144
 
145
-	// Nettoyer les valeurs
146
-	$champs = array_map('corriger_caracteres', $champs);
145
+    // Nettoyer les valeurs
146
+    $champs = array_map('corriger_caracteres', $champs);
147 147
 
148
-	// Envoyer aux plugins
149
-	$champs = pipeline('pre_edition',
150
-		array(
151
-			'args' => array(
152
-				'table' => $spip_table_objet, // compatibilite
153
-				'table_objet' => $table_objet,
154
-				'spip_table_objet' => $spip_table_objet,
155
-				'type' =>$objet,
156
-				'id_objet' => $id_objet,
157
-				'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] c'est quoi ?
158
-				'serveur' => $serveur,
159
-				'action' => isset($options['action']) ? $options['action'] : 'modifier'
160
-			),
161
-			'data' => $champs
162
-		)
163
-	);
148
+    // Envoyer aux plugins
149
+    $champs = pipeline('pre_edition',
150
+        array(
151
+            'args' => array(
152
+                'table' => $spip_table_objet, // compatibilite
153
+                'table_objet' => $table_objet,
154
+                'spip_table_objet' => $spip_table_objet,
155
+                'type' =>$objet,
156
+                'id_objet' => $id_objet,
157
+                'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] c'est quoi ?
158
+                'serveur' => $serveur,
159
+                'action' => isset($options['action']) ? $options['action'] : 'modifier'
160
+            ),
161
+            'data' => $champs
162
+        )
163
+    );
164 164
 
165
-	if (!$champs) return false;
165
+    if (!$champs) return false;
166 166
 
167 167
 
168
-	// marquer le fait que l'objet est travaille par toto a telle date
169
-	if ($GLOBALS['meta']['articles_modif'] != 'non') {
170
-		include_spip('inc/drapeau_edition');
171
-		signale_edition ($id_objet, $GLOBALS['visiteur_session'], $objet);
172
-	}
168
+    // marquer le fait que l'objet est travaille par toto a telle date
169
+    if ($GLOBALS['meta']['articles_modif'] != 'non') {
170
+        include_spip('inc/drapeau_edition');
171
+        signale_edition ($id_objet, $GLOBALS['visiteur_session'], $objet);
172
+    }
173 173
 
174
-	// Verifier si les mises a jour sont pertinentes, datees, en conflit etc
175
-	include_spip('inc/editer');
176
-	if (!isset($options['data']) OR is_null($options['data'])){
177
-		$options['data'] = &$_POST;
178
-	}
179
-	$conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur);
180
-	// cas hypothetique : normalement inc/editer verifie en amont le conflit edition
181
-	// et gere l'interface
182
-	// ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme
183
-	if ($conflits)
184
-		return _T('titre_conflit_edition');
174
+    // Verifier si les mises a jour sont pertinentes, datees, en conflit etc
175
+    include_spip('inc/editer');
176
+    if (!isset($options['data']) OR is_null($options['data'])){
177
+        $options['data'] = &$_POST;
178
+    }
179
+    $conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur);
180
+    // cas hypothetique : normalement inc/editer verifie en amont le conflit edition
181
+    // et gere l'interface
182
+    // ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme
183
+    if ($conflits)
184
+        return _T('titre_conflit_edition');
185 185
 
186
-	if ($champs) {
187
-		// cas particulier de la langue : passer par instituer_langue_objet
188
-		if (isset($champs['lang'])){
189
-			if ($changer_lang=$champs['lang']){
190
-				$id_rubrique = 0;
191
-				if ($desc['field']['id_rubrique']){
192
-					$parent = ($objet=='rubrique')?'id_parent':'id_rubrique';
193
-					$id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=".intval($id_objet));
194
-				}
195
-				$instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action');
196
-				$champs['lang'] = $instituer_langue_objet($objet, $id_objet, $id_rubrique, $changer_lang, $serveur);
197
-			}
198
-			// on laisse 'lang' dans $champs,
199
-			// ca permet de passer dans le pipeline post_edition et de journaliser
200
-			// et ca ne gene pas qu'on refasse un sql_updateq dessus apres l'avoir
201
-			// deja pris en compte
202
-		}
186
+    if ($champs) {
187
+        // cas particulier de la langue : passer par instituer_langue_objet
188
+        if (isset($champs['lang'])){
189
+            if ($changer_lang=$champs['lang']){
190
+                $id_rubrique = 0;
191
+                if ($desc['field']['id_rubrique']){
192
+                    $parent = ($objet=='rubrique')?'id_parent':'id_rubrique';
193
+                    $id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=".intval($id_objet));
194
+                }
195
+                $instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action');
196
+                $champs['lang'] = $instituer_langue_objet($objet, $id_objet, $id_rubrique, $changer_lang, $serveur);
197
+            }
198
+            // on laisse 'lang' dans $champs,
199
+            // ca permet de passer dans le pipeline post_edition et de journaliser
200
+            // et ca ne gene pas qu'on refasse un sql_updateq dessus apres l'avoir
201
+            // deja pris en compte
202
+        }
203 203
 
204
-		// la modif peut avoir lieu
204
+        // la modif peut avoir lieu
205 205
 
206
-		// faut-il ajouter date_modif ?
207
-		if (isset($options['date_modif']) AND $options['date_modif']
208
-		AND !isset($champs[$options['date_modif']]))
209
-			$champs[$options['date_modif']] = date('Y-m-d H:i:s');
206
+        // faut-il ajouter date_modif ?
207
+        if (isset($options['date_modif']) AND $options['date_modif']
208
+        AND !isset($champs[$options['date_modif']]))
209
+            $champs[$options['date_modif']] = date('Y-m-d H:i:s');
210 210
 
211
-		// allez on commit la modif
212
-		sql_updateq($spip_table_objet, $champs, "$id_table_objet=".intval($id_objet), $serveur);
211
+        // allez on commit la modif
212
+        sql_updateq($spip_table_objet, $champs, "$id_table_objet=".intval($id_objet), $serveur);
213 213
 
214
-		// on verifie si elle est bien passee
215
-		$moof = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=".intval($id_objet), array(), array(), '', array(), $serveur);
216
-		// si difference entre les champs, reperer les champs mal enregistres
217
-		if ($moof != $champs) {
218
-			$liste = array();
219
-			foreach($moof as $k=>$v)
220
-				if ($v !== $champs[$k]
221
-					// ne pas alerter si le champ est numerique est que les valeurs sont equivalentes
222
-					AND (!is_numeric($v) OR intval($v)!=intval($champs[$k]))
223
-					) {
224
-					$liste[] = $k;
225
-					$conflits[$k]['post'] = $champs[$k];
226
-					$conflits[$k]['save'] = $v;
227
-				}
228
-			// si un champ n'a pas ete correctement enregistre, loger et retourner une erreur
229
-			// c'est un cas exceptionnel
230
-			if (count($liste)){
231
-				spip_log("Erreur enregistrement en base $objet/$id_objet champs :".var_export($conflits,true),'modifier.'._LOG_CRITIQUE);
232
-				return _T('erreur_technique_enregistrement_champs',array('champs'=>"<i>'".implode("'</i>,<i>'",$liste)."'</i>"));
233
-			}
234
-		}
214
+        // on verifie si elle est bien passee
215
+        $moof = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=".intval($id_objet), array(), array(), '', array(), $serveur);
216
+        // si difference entre les champs, reperer les champs mal enregistres
217
+        if ($moof != $champs) {
218
+            $liste = array();
219
+            foreach($moof as $k=>$v)
220
+                if ($v !== $champs[$k]
221
+                    // ne pas alerter si le champ est numerique est que les valeurs sont equivalentes
222
+                    AND (!is_numeric($v) OR intval($v)!=intval($champs[$k]))
223
+                    ) {
224
+                    $liste[] = $k;
225
+                    $conflits[$k]['post'] = $champs[$k];
226
+                    $conflits[$k]['save'] = $v;
227
+                }
228
+            // si un champ n'a pas ete correctement enregistre, loger et retourner une erreur
229
+            // c'est un cas exceptionnel
230
+            if (count($liste)){
231
+                spip_log("Erreur enregistrement en base $objet/$id_objet champs :".var_export($conflits,true),'modifier.'._LOG_CRITIQUE);
232
+                return _T('erreur_technique_enregistrement_champs',array('champs'=>"<i>'".implode("'</i>,<i>'",$liste)."'</i>"));
233
+            }
234
+        }
235 235
 
236
-		// Invalider les caches
237
-		if (isset($options['invalideur']) and $options['invalideur']) {
238
-			include_spip('inc/invalideur');
239
-			if (is_array($options['invalideur']))
240
-				array_map('suivre_invalideur',$options['invalideur']);
241
-			else
242
-				suivre_invalideur($options['invalideur']);
243
-		}
236
+        // Invalider les caches
237
+        if (isset($options['invalideur']) and $options['invalideur']) {
238
+            include_spip('inc/invalideur');
239
+            if (is_array($options['invalideur']))
240
+                array_map('suivre_invalideur',$options['invalideur']);
241
+            else
242
+                suivre_invalideur($options['invalideur']);
243
+        }
244 244
 
245
-		// Notifications, gestion des revisions...
246
-		// en standard, appelle |nouvelle_revision ci-dessous
247
-		pipeline('post_edition',
248
-			array(
249
-				'args' => array(
250
-					'table' => $spip_table_objet,
251
-					'table_objet' => $table_objet,
252
-					'spip_table_objet' => $spip_table_objet,
253
-					'type' =>$objet,
254
-					'id_objet' => $id_objet,
255
-					'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] kesako ?
256
-					'serveur' => $serveur,
257
-					'action' => isset($options['action']) ? $options['action'] : 'modifier'
258
-				),
259
-				'data' => $champs
260
-			)
261
-		);
262
-	}
245
+        // Notifications, gestion des revisions...
246
+        // en standard, appelle |nouvelle_revision ci-dessous
247
+        pipeline('post_edition',
248
+            array(
249
+                'args' => array(
250
+                    'table' => $spip_table_objet,
251
+                    'table_objet' => $table_objet,
252
+                    'spip_table_objet' => $spip_table_objet,
253
+                    'type' =>$objet,
254
+                    'id_objet' => $id_objet,
255
+                    'champs' => isset($options['champs']) ? $options['champs'] : array(), // [doc] kesako ?
256
+                    'serveur' => $serveur,
257
+                    'action' => isset($options['action']) ? $options['action'] : 'modifier'
258
+                ),
259
+                'data' => $champs
260
+            )
261
+        );
262
+    }
263 263
 
264
-	// journaliser l'affaire
265
-	// message a affiner :-)
266
-	include_spip('inc/filtres_mini');
267
-	$qui = ((isset($GLOBALS['visiteur_session']['nom']) AND $GLOBALS['visiteur_session']['nom'])?$GLOBALS['visiteur_session']['nom']:$GLOBALS['ip']);
268
-	journal(_L($qui.' a &#233;dit&#233; l&#8217;'.$objet.' '.$id_objet.' ('.join('+',array_diff(array_keys($champs), array('date_modif'))).')'), array(
269
-		'faire' => 'modifier',
270
-		'quoi' => $objet,
271
-		'id' => $id_objet
272
-	));
264
+    // journaliser l'affaire
265
+    // message a affiner :-)
266
+    include_spip('inc/filtres_mini');
267
+    $qui = ((isset($GLOBALS['visiteur_session']['nom']) AND $GLOBALS['visiteur_session']['nom'])?$GLOBALS['visiteur_session']['nom']:$GLOBALS['ip']);
268
+    journal(_L($qui.' a &#233;dit&#233; l&#8217;'.$objet.' '.$id_objet.' ('.join('+',array_diff(array_keys($champs), array('date_modif'))).')'), array(
269
+        'faire' => 'modifier',
270
+        'quoi' => $objet,
271
+        'id' => $id_objet
272
+    ));
273 273
 
274
-	return '';
274
+    return '';
275 275
 }
276 276
 
277 277
 /**
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
  *     false sinon (erreur ou aucun champ modifié)
297 297
  */
298 298
 function modifier_contenu($type, $id, $options, $c=null, $serveur='') {
299
-	$res = objet_modifier_champs($type, $id, $options, $c, $serveur);
300
-	return ($res===''?true:false);
299
+    $res = objet_modifier_champs($type, $id, $options, $c, $serveur);
300
+    return ($res===''?true:false);
301 301
 }
302 302
 
303 303
 /**
@@ -318,9 +318,9 @@  discard block
 block discarded – undo
318 318
  * @return mixed|string
319 319
  */
320 320
 function revision_objet($objet,$id_objet,$c=null){
321
-	$objet = objet_type($objet); // securite
322
-	include_spip('action/editer_objet');
323
-	return objet_modifier($objet,$id_objet,$c);
321
+    $objet = objet_type($objet); // securite
322
+    include_spip('action/editer_objet');
323
+    return objet_modifier($objet,$id_objet,$c);
324 324
 }
325 325
 
326 326
 
Please login to merge, or discard this patch.
ecrire/inc/securiser_action.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -34,18 +34,18 @@  discard block
 block discarded – undo
34 34
  */
35 35
 function inc_securiser_action_dist($action='', $arg='', $redirect="", $mode=false, $att='', $public=false)
36 36
 {
37
-	if ($action)
38
-		return securiser_action_auteur($action, $arg, $redirect, $mode, $att, $public);
39
-	else {
40
-		$arg = _request('arg');
41
-		$hash = _request('hash');
42
-		$action = _request('action')?_request('action'):_request('formulaire_action');
43
-		if ($a = verifier_action_auteur("$action-$arg", $hash))
44
-			return $arg;
45
-		include_spip('inc/minipres');
46
-		echo minipres();
47
-		exit;
48
-	}
37
+    if ($action)
38
+        return securiser_action_auteur($action, $arg, $redirect, $mode, $att, $public);
39
+    else {
40
+        $arg = _request('arg');
41
+        $hash = _request('hash');
42
+        $action = _request('action')?_request('action'):_request('formulaire_action');
43
+        if ($a = verifier_action_auteur("$action-$arg", $hash))
44
+            return $arg;
45
+        include_spip('inc/minipres');
46
+        echo minipres();
47
+        exit;
48
+    }
49 49
 }
50 50
 
51 51
 /**
@@ -68,27 +68,27 @@  discard block
 block discarded – undo
68 68
  */
69 69
 function securiser_action_auteur($action, $arg, $redirect="", $mode=false, $att='', $public=false) {
70 70
 
71
-	// mode URL ou array
72
-	if (!is_string($mode)){
73
-		$hash = calculer_action_auteur("$action-$arg",is_numeric($att)?$att:null);
71
+    // mode URL ou array
72
+    if (!is_string($mode)){
73
+        $hash = calculer_action_auteur("$action-$arg",is_numeric($att)?$att:null);
74 74
 
75
-		$r = rawurlencode($redirect);
76
-		if ($mode===-1)
77
-			return array('action'=>$action,'arg'=>$arg,'hash'=>$hash);
78
-		else
79
-			return generer_url_action($action, "arg=$arg&hash=$hash" . (!$r ? '' : "&redirect=$r"), $mode, $public);
80
-	}
75
+        $r = rawurlencode($redirect);
76
+        if ($mode===-1)
77
+            return array('action'=>$action,'arg'=>$arg,'hash'=>$hash);
78
+        else
79
+            return generer_url_action($action, "arg=$arg&hash=$hash" . (!$r ? '' : "&redirect=$r"), $mode, $public);
80
+    }
81 81
 
82
-	// mode formulaire
83
-	$hash = calculer_action_auteur("$action-$arg");
84
-	$att .= " style='margin: 0px; border: 0px'";
85
-	if ($redirect)
86
-		$redirect = "\n\t\t<input name='redirect' type='hidden' value='". str_replace("'", '&#39;', $redirect) ."' />";
87
-	$mode .= $redirect . "
82
+    // mode formulaire
83
+    $hash = calculer_action_auteur("$action-$arg");
84
+    $att .= " style='margin: 0px; border: 0px'";
85
+    if ($redirect)
86
+        $redirect = "\n\t\t<input name='redirect' type='hidden' value='". str_replace("'", '&#39;', $redirect) ."' />";
87
+    $mode .= $redirect . "
88 88
 <input name='hash' type='hidden' value='$hash' />
89 89
 <input name='arg' type='hidden' value='$arg' />";
90 90
 
91
-	return generer_form_action($action, $mode, $att, $public);
91
+    return generer_form_action($action, $mode, $att, $public);
92 92
 }
93 93
 
94 94
 /**
@@ -100,41 +100,41 @@  discard block
 block discarded – undo
100 100
  * @return array
101 101
  */
102 102
 function caracteriser_auteur($id_auteur=null) {
103
-	static $caracterisation = array();
103
+    static $caracterisation = array();
104 104
 
105
-	if (is_null($id_auteur) AND !isset($GLOBALS['visiteur_session']['id_auteur'])) {
106
-	// si l'auteur courant n'est pas connu alors qu'il peut demander une action
107
-	// c'est une connexion par php_auth ou 1 instal, on se rabat sur le cookie.
108
-	// S'il n'avait pas le droit de realiser cette action, le hash sera faux.
109
-		if (isset($_COOKIE['spip_session'])
110
-		AND (preg_match('/^(\d+)/',$_COOKIE['spip_session'],$r))) {
111
-			  return array($r[1], '');
112
-			  // Necessaire aux forums anonymes.
113
-			  // Pour le reste, ca echouera.
114
-		} else return array('0','');
115
-	}
116
-	// Eviter l'acces SQL si le pass est connu de PHP
117
-	if (is_null($id_auteur)){
118
-		$id_auteur = isset($GLOBALS['visiteur_session']['id_auteur'])?$GLOBALS['visiteur_session']['id_auteur']:0;
119
-		if (isset($GLOBALS['visiteur_session']['pass']) AND $GLOBALS['visiteur_session']['pass'])
120
-			return $caracterisation[$id_auteur] = array($id_auteur, $GLOBALS['visiteur_session']['pass']);
121
-	}
105
+    if (is_null($id_auteur) AND !isset($GLOBALS['visiteur_session']['id_auteur'])) {
106
+    // si l'auteur courant n'est pas connu alors qu'il peut demander une action
107
+    // c'est une connexion par php_auth ou 1 instal, on se rabat sur le cookie.
108
+    // S'il n'avait pas le droit de realiser cette action, le hash sera faux.
109
+        if (isset($_COOKIE['spip_session'])
110
+        AND (preg_match('/^(\d+)/',$_COOKIE['spip_session'],$r))) {
111
+                return array($r[1], '');
112
+                // Necessaire aux forums anonymes.
113
+                // Pour le reste, ca echouera.
114
+        } else return array('0','');
115
+    }
116
+    // Eviter l'acces SQL si le pass est connu de PHP
117
+    if (is_null($id_auteur)){
118
+        $id_auteur = isset($GLOBALS['visiteur_session']['id_auteur'])?$GLOBALS['visiteur_session']['id_auteur']:0;
119
+        if (isset($GLOBALS['visiteur_session']['pass']) AND $GLOBALS['visiteur_session']['pass'])
120
+            return $caracterisation[$id_auteur] = array($id_auteur, $GLOBALS['visiteur_session']['pass']);
121
+    }
122 122
 
123
-	if (isset($caracterisation[$id_auteur])) return $caracterisation[$id_auteur];
123
+    if (isset($caracterisation[$id_auteur])) return $caracterisation[$id_auteur];
124 124
 
125
-	if ($id_auteur) {
126
-		include_spip('base/abstract_sql');
127
-		$t = sql_fetsel("id_auteur, pass", "spip_auteurs", "id_auteur=$id_auteur");
128
-		if ($t)
129
-			return $caracterisation[$id_auteur] = array($t['id_auteur'], $t['pass']);
130
-		include_spip('inc/minipres');
131
-		echo minipres();
132
-		exit;
133
-	}
134
-	// Visiteur anonyme, pour ls forums par exemple
135
-	else {
136
-		return array('0','');
137
-	}
125
+    if ($id_auteur) {
126
+        include_spip('base/abstract_sql');
127
+        $t = sql_fetsel("id_auteur, pass", "spip_auteurs", "id_auteur=$id_auteur");
128
+        if ($t)
129
+            return $caracterisation[$id_auteur] = array($t['id_auteur'], $t['pass']);
130
+        include_spip('inc/minipres');
131
+        echo minipres();
132
+        exit;
133
+    }
134
+    // Visiteur anonyme, pour ls forums par exemple
135
+    else {
136
+        return array('0','');
137
+    }
138 138
 }
139 139
 
140 140
 /**
@@ -151,25 +151,25 @@  discard block
 block discarded – undo
151 151
  * @return string
152 152
  */
153 153
 function _action_auteur($action, $id_auteur, $pass, $alea) {
154
-	static $sha = array();
155
-	if (!isset($sha[$id_auteur.$pass.$alea])){
156
-		if (!isset($GLOBALS['meta'][$alea]) AND _request('exec')!=='install') {
157
-			include_spip('base/abstract_sql');
158
-			$GLOBALS['meta'][$alea] = sql_getfetsel('valeur', 'spip_meta', "nom=" . sql_quote($alea));
159
-			if (!($GLOBALS['meta'][$alea])) {
160
-				include_spip('inc/minipres');
161
-				echo minipres();
162
-				spip_log("$alea indisponible");
163
-				exit;
164
-			}
165
-		}
166
-		include_spip('auth/sha256.inc');
167
-		$sha[$id_auteur.$pass.$alea] = _nano_sha256($id_auteur.$pass.@$GLOBALS['meta'][$alea]);
168
-	}
169
-	if (function_exists('sha1'))
170
-		return sha1($action.$sha[$id_auteur.$pass.$alea]);
171
-	else
172
-		return md5($action.$sha[$id_auteur.$pass.$alea]);
154
+    static $sha = array();
155
+    if (!isset($sha[$id_auteur.$pass.$alea])){
156
+        if (!isset($GLOBALS['meta'][$alea]) AND _request('exec')!=='install') {
157
+            include_spip('base/abstract_sql');
158
+            $GLOBALS['meta'][$alea] = sql_getfetsel('valeur', 'spip_meta', "nom=" . sql_quote($alea));
159
+            if (!($GLOBALS['meta'][$alea])) {
160
+                include_spip('inc/minipres');
161
+                echo minipres();
162
+                spip_log("$alea indisponible");
163
+                exit;
164
+            }
165
+        }
166
+        include_spip('auth/sha256.inc');
167
+        $sha[$id_auteur.$pass.$alea] = _nano_sha256($id_auteur.$pass.@$GLOBALS['meta'][$alea]);
168
+    }
169
+    if (function_exists('sha1'))
170
+        return sha1($action.$sha[$id_auteur.$pass.$alea]);
171
+    else
172
+        return md5($action.$sha[$id_auteur.$pass.$alea]);
173 173
 }
174 174
 
175 175
 /**
@@ -181,8 +181,8 @@  discard block
 block discarded – undo
181 181
  * @return string
182 182
  */
183 183
 function calculer_action_auteur($action, $id_auteur=null) {
184
-	list($id_auteur, $pass) = caracteriser_auteur($id_auteur);
185
-	return _action_auteur($action, $id_auteur, $pass, 'alea_ephemere');
184
+    list($id_auteur, $pass) = caracteriser_auteur($id_auteur);
185
+    return _action_auteur($action, $id_auteur, $pass, 'alea_ephemere');
186 186
 }
187 187
 
188 188
 
@@ -196,12 +196,12 @@  discard block
 block discarded – undo
196 196
  * @return bool
197 197
  */
198 198
 function verifier_action_auteur($action, $hash) {
199
-	list($id_auteur, $pass) = caracteriser_auteur();
200
-	if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere'))
201
-		return true;
202
-	if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere_ancien'))
203
-		return true;
204
-	return false;
199
+    list($id_auteur, $pass) = caracteriser_auteur();
200
+    if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere'))
201
+        return true;
202
+    if ($hash == _action_auteur($action, $id_auteur, $pass, 'alea_ephemere_ancien'))
203
+        return true;
204
+    return false;
205 205
 }
206 206
 
207 207
 //
@@ -219,18 +219,18 @@  discard block
 block discarded – undo
219 219
  * @return string
220 220
  */
221 221
 function secret_du_site() {
222
-	if (!isset($GLOBALS['meta']['secret_du_site'])){
223
-		include_spip('base/abstract_sql');
224
-		$GLOBALS['meta']['secret_du_site'] = sql_getfetsel('valeur', 'spip_meta', "nom='secret_du_site'");
225
-	}
226
-	if (!isset($GLOBALS['meta']['secret_du_site'])
227
-	  OR (strlen($GLOBALS['meta']['secret_du_site'])<64)) {
228
-		include_spip('inc/acces');
229
-		include_spip('auth/sha256.inc');
230
-		ecrire_meta('secret_du_site', _nano_sha256($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SERVER_SIGNATURE"] . creer_uniqid()), 'non');
231
-		lire_metas(); // au cas ou ecrire_meta() ne fonctionne pas
232
-	}
233
-	return $GLOBALS['meta']['secret_du_site'];
222
+    if (!isset($GLOBALS['meta']['secret_du_site'])){
223
+        include_spip('base/abstract_sql');
224
+        $GLOBALS['meta']['secret_du_site'] = sql_getfetsel('valeur', 'spip_meta', "nom='secret_du_site'");
225
+    }
226
+    if (!isset($GLOBALS['meta']['secret_du_site'])
227
+      OR (strlen($GLOBALS['meta']['secret_du_site'])<64)) {
228
+        include_spip('inc/acces');
229
+        include_spip('auth/sha256.inc');
230
+        ecrire_meta('secret_du_site', _nano_sha256($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SERVER_SIGNATURE"] . creer_uniqid()), 'non');
231
+        lire_metas(); // au cas ou ecrire_meta() ne fonctionne pas
232
+    }
233
+    return $GLOBALS['meta']['secret_du_site'];
234 234
 }
235 235
 
236 236
 /**
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
  * @return string
242 242
  */
243 243
 function calculer_cle_action($action) {
244
-	if (function_exists('sha1'))
245
-		return sha1($action . secret_du_site());
246
-	else
247
-		return md5($action . secret_du_site());
244
+    if (function_exists('sha1'))
245
+        return sha1($action . secret_du_site());
246
+    else
247
+        return md5($action . secret_du_site());
248 248
 }
249 249
 
250 250
 /**
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
  * @return bool
257 257
  */
258 258
 function verifier_cle_action($action, $cle) {
259
-	return ($cle == calculer_cle_action($action));
259
+    return ($cle == calculer_cle_action($action));
260 260
 }
261 261
 
262 262
 ?>
Please login to merge, or discard this patch.
ecrire/inc/layer.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -14,69 +14,69 @@  discard block
 block discarded – undo
14 14
 
15 15
 // http://doc.spip.org/@cadre_depliable
16 16
 function cadre_depliable($icone,$titre,$deplie,$contenu,$ids='',$style_cadre='r'){
17
-	$bouton = bouton_block_depliable($titre,$deplie,$ids);
18
-	return 
19
-		debut_cadre($style_cadre,$icone,'',$bouton, '', '', false)
20
-		. debut_block_depliable($deplie,$ids)
21
-		. "<div class='cadre_padding'>\n"
22
-		. $contenu
23
-		. "</div>\n"
24
-		. fin_block()
25
-		. fin_cadre();
17
+    $bouton = bouton_block_depliable($titre,$deplie,$ids);
18
+    return 
19
+        debut_cadre($style_cadre,$icone,'',$bouton, '', '', false)
20
+        . debut_block_depliable($deplie,$ids)
21
+        . "<div class='cadre_padding'>\n"
22
+        . $contenu
23
+        . "</div>\n"
24
+        . fin_block()
25
+        . fin_cadre();
26 26
 }
27 27
 
28 28
 // http://doc.spip.org/@block_parfois_visible
29 29
 function block_parfois_visible($nom, $invite, $masque, $style='', $visible=false){
30
-	return "\n"
31
-	. bouton_block_depliable($invite,$visible,$nom)
32
-	. debut_block_depliable($visible,$nom)
33
-	. $masque
34
-	. fin_block();
30
+    return "\n"
31
+    . bouton_block_depliable($invite,$visible,$nom)
32
+    . debut_block_depliable($visible,$nom)
33
+    . $masque
34
+    . fin_block();
35 35
 }
36 36
 
37 37
 // http://doc.spip.org/@debut_block_depliable
38 38
 function debut_block_depliable($deplie,$id=""){
39
-	$class=' blocdeplie';
40
-	// si on n'accepte pas js, ne pas fermer
41
-	if (!$deplie)
42
-		$class=" blocreplie";
43
-	return "<div ".($id?"id='$id' ":"")."class='bloc_depliable$class'>";	
39
+    $class=' blocdeplie';
40
+    // si on n'accepte pas js, ne pas fermer
41
+    if (!$deplie)
42
+        $class=" blocreplie";
43
+    return "<div ".($id?"id='$id' ":"")."class='bloc_depliable$class'>";	
44 44
 }
45 45
 // http://doc.spip.org/@fin_block
46 46
 function fin_block() {
47
-	return "<div class='nettoyeur'></div>\n</div>";
47
+    return "<div class='nettoyeur'></div>\n</div>";
48 48
 }
49 49
 // $texte : texte du bouton
50 50
 // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page 
51 51
 // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit)
52 52
 // http://doc.spip.org/@bouton_block_depliable
53 53
 function bouton_block_depliable($texte,$deplie,$ids=""){
54
-	$bouton_id = 'b'.substr(md5($texte.microtime()),0,8);
54
+    $bouton_id = 'b'.substr(md5($texte.microtime()),0,8);
55 55
 
56
-	$class = ($deplie===true)?" deplie":(($deplie==-1)?" impliable":" replie");
57
-	if (strlen($ids)){
58
-		$cible = explode(',',$ids);
59
-		$cible = '#'.implode(",#",$cible);
60
-	}
61
-	else{
62
-		$cible = "#$bouton_id + div.bloc_depliable";
63
-	}
56
+    $class = ($deplie===true)?" deplie":(($deplie==-1)?" impliable":" replie");
57
+    if (strlen($ids)){
58
+        $cible = explode(',',$ids);
59
+        $cible = '#'.implode(",#",$cible);
60
+    }
61
+    else{
62
+        $cible = "#$bouton_id + div.bloc_depliable";
63
+    }
64 64
 
65
-	$b = (strpos($texte,"<h")===false?'h3':'div');
66
-	return "<$b "
67
-	  .($bouton_id?"id='$bouton_id' ":"")
68
-	  ."class='titrem$class'"
69
-	  . (($deplie===-1)
70
-	  	?""
71
-	  	:" onmouseover=\"jQuery(this).depliant('$cible');\""
72
-	  )
73
-	  .">"
74
-	  // une ancre pour rendre accessible au clavier le depliage du sous bloc
75
-	  . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
76
-	  . "$texte</$b>"
77
-	  . http_script( ($deplie==='incertain')
78
-			? "jQuery(document).ready(function(){if (jQuery('$cible').is(':visible')) $('#$bouton_id').addClass('deplie').removeClass('replie');});"
79
-			: '');
65
+    $b = (strpos($texte,"<h")===false?'h3':'div');
66
+    return "<$b "
67
+        .($bouton_id?"id='$bouton_id' ":"")
68
+        ."class='titrem$class'"
69
+        . (($deplie===-1)
70
+          ?""
71
+          :" onmouseover=\"jQuery(this).depliant('$cible');\""
72
+        )
73
+        .">"
74
+        // une ancre pour rendre accessible au clavier le depliage du sous bloc
75
+        . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
76
+        . "$texte</$b>"
77
+        . http_script( ($deplie==='incertain')
78
+            ? "jQuery(document).ready(function(){if (jQuery('$cible').is(':visible')) $('#$bouton_id').addClass('deplie').removeClass('replie');});"
79
+            : '');
80 80
 }
81 81
 
82 82
 //
@@ -85,51 +85,51 @@  discard block
 block discarded – undo
85 85
 // http://doc.spip.org/@verif_butineur
86 86
 function verif_butineur() {
87 87
 
88
-	global $browser_name, $browser_version;
89
-	global $browser_description, $browser_rev, $browser_barre;
90
-	preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match);
91
-	$browser_name = $match[1];
92
-	$browser_version = $match[2];
93
-	$browser_description = $match[3];
94
-	$GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
95
-	$browser_barre = '';
88
+    global $browser_name, $browser_version;
89
+    global $browser_description, $browser_rev, $browser_barre;
90
+    preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match);
91
+    $browser_name = $match[1];
92
+    $browser_version = $match[2];
93
+    $browser_description = $match[3];
94
+    $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
95
+    $browser_barre = '';
96 96
 
97
-	if (!preg_match(",opera,i", $browser_description)&&preg_match(",opera,i", $browser_name)) {
98
-		$browser_name = "Opera";
99
-		$browser_version = $match[2];
100
-		$browser_barre = ($browser_version >= 8.5);
101
-	}
102
-	else if (preg_match(",opera,i", $browser_description)) {
103
-		preg_match(",Opera ([^\ ]*),i", $browser_description, $match);
104
-		$browser_name = "Opera";
105
-		$browser_version = $match[1];
106
-		$browser_barre = ($browser_version >= 8.5);
107
-	}
108
-	else if (preg_match(",msie,i", $browser_description)) {
109
-		preg_match(",MSIE ([^;]*),i", $browser_description, $match);
110
-		$browser_name = "MSIE";
111
-		$browser_version = $match[1];
112
-		$browser_barre = ($browser_version >= 5.5);
113
-	}
114
-	else if (preg_match(",KHTML,i", $browser_description) &&
115
-		preg_match(",Safari/([^;]*),", $browser_description, $match)) {
116
-		$browser_name = "Safari";
117
-		$browser_version = $match[1];
118
-		$browser_barre = ($browser_version >= 5.0);
119
-	}
120
-	else if (preg_match(",mozilla,i", $browser_name) AND $browser_version >= 5) {
121
-		// Numero de version pour Mozilla "authentique"
122
-		if (preg_match(",rv:([0-9]+\.[0-9]+),", $browser_description, $match))
123
-			$browser_rev = doubleval($match[1]);
124
-		// Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.)
125
-		else if (strpos($browser_description, "Gecko") and !strpos($browser_description, "KHTML"))
126
-			$browser_rev = 1.4;
127
-		// Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.)
128
-		else $browser_rev = 1.0;
129
-		$browser_barre = $browser_rev >= 1.3;
130
-	}
97
+    if (!preg_match(",opera,i", $browser_description)&&preg_match(",opera,i", $browser_name)) {
98
+        $browser_name = "Opera";
99
+        $browser_version = $match[2];
100
+        $browser_barre = ($browser_version >= 8.5);
101
+    }
102
+    else if (preg_match(",opera,i", $browser_description)) {
103
+        preg_match(",Opera ([^\ ]*),i", $browser_description, $match);
104
+        $browser_name = "Opera";
105
+        $browser_version = $match[1];
106
+        $browser_barre = ($browser_version >= 8.5);
107
+    }
108
+    else if (preg_match(",msie,i", $browser_description)) {
109
+        preg_match(",MSIE ([^;]*),i", $browser_description, $match);
110
+        $browser_name = "MSIE";
111
+        $browser_version = $match[1];
112
+        $browser_barre = ($browser_version >= 5.5);
113
+    }
114
+    else if (preg_match(",KHTML,i", $browser_description) &&
115
+        preg_match(",Safari/([^;]*),", $browser_description, $match)) {
116
+        $browser_name = "Safari";
117
+        $browser_version = $match[1];
118
+        $browser_barre = ($browser_version >= 5.0);
119
+    }
120
+    else if (preg_match(",mozilla,i", $browser_name) AND $browser_version >= 5) {
121
+        // Numero de version pour Mozilla "authentique"
122
+        if (preg_match(",rv:([0-9]+\.[0-9]+),", $browser_description, $match))
123
+            $browser_rev = doubleval($match[1]);
124
+        // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.)
125
+        else if (strpos($browser_description, "Gecko") and !strpos($browser_description, "KHTML"))
126
+            $browser_rev = 1.4;
127
+        // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.)
128
+        else $browser_rev = 1.0;
129
+        $browser_barre = $browser_rev >= 1.3;
130
+    }
131 131
 
132
-	if (!$browser_name) $browser_name = "Mozilla";
132
+    if (!$browser_name) $browser_name = "Mozilla";
133 133
 }
134 134
 
135 135
 verif_butineur();
Please login to merge, or discard this patch.
ecrire/inc/charger_php_extension.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -16,53 +16,53 @@
 block discarded – undo
16 16
 //
17 17
 // http://doc.spip.org/@inc_charger_php_extension_dist
18 18
 function inc_charger_php_extension_dist($module){
19
-	if (extension_loaded($module)) {
20
-		return true;
21
-	}
19
+    if (extension_loaded($module)) {
20
+        return true;
21
+    }
22 22
 
23
-	// A-t-on le droit de faire un dl() ; si on peut, on memorise la reponse,
24
-	// lourde a calculer, dans les meta
25
-	if (!isset($GLOBALS['meta']['dl_allowed'])) {
26
-		if (!@ini_get('safe_mode') 
27
-		  && @ini_get('enable_dl')
28
-		  && @function_exists('dl')) {
29
-			ob_start();
30
-			phpinfo(INFO_GENERAL); /* Only general info */
31
-			$a = strip_tags(ob_get_contents());
32
-			ob_end_clean();
33
-			if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) {
34
-				if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) {
35
-					$GLOBALS['meta']['dl_allowed'] = true;
36
-				} else {
37
-					$GLOBALS['meta']['dl_allowed'] = false;
38
-				}
39
-			} else {
40
-				$GLOBALS['meta']['dl_allowed'] = true;
41
-			}
42
-		} else {
43
-			$GLOBALS['meta']['dl_allowed'] = false;
44
-		}
23
+    // A-t-on le droit de faire un dl() ; si on peut, on memorise la reponse,
24
+    // lourde a calculer, dans les meta
25
+    if (!isset($GLOBALS['meta']['dl_allowed'])) {
26
+        if (!@ini_get('safe_mode') 
27
+          && @ini_get('enable_dl')
28
+          && @function_exists('dl')) {
29
+            ob_start();
30
+            phpinfo(INFO_GENERAL); /* Only general info */
31
+            $a = strip_tags(ob_get_contents());
32
+            ob_end_clean();
33
+            if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) {
34
+                if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) {
35
+                    $GLOBALS['meta']['dl_allowed'] = true;
36
+                } else {
37
+                    $GLOBALS['meta']['dl_allowed'] = false;
38
+                }
39
+            } else {
40
+                $GLOBALS['meta']['dl_allowed'] = true;
41
+            }
42
+        } else {
43
+            $GLOBALS['meta']['dl_allowed'] = false;
44
+        }
45 45
 
46
-		// Attention, le ecrire_meta() echouera si on le tente ici ;
47
-		// donc on ne fait rien, et on attend qu'un prochain ecrire_meta()
48
-		// se produisant apres cette sequence enregistre sa valeur.
49
-		#include_spip('inc/meta');
50
-		#ecrire_meta('dl_allowed', $GLOBALS['meta']['dl_allowed'], 'non');
51
-	}
46
+        // Attention, le ecrire_meta() echouera si on le tente ici ;
47
+        // donc on ne fait rien, et on attend qu'un prochain ecrire_meta()
48
+        // se produisant apres cette sequence enregistre sa valeur.
49
+        #include_spip('inc/meta');
50
+        #ecrire_meta('dl_allowed', $GLOBALS['meta']['dl_allowed'], 'non');
51
+    }
52 52
 
53
-	if (!$GLOBALS['meta']['dl_allowed']) {
54
-		return false;
55
-	}
53
+    if (!$GLOBALS['meta']['dl_allowed']) {
54
+        return false;
55
+    }
56 56
 
57
-	/* Once we require PHP >= 4.3, we might use PHP_SHLIB_SUFFIX here */
58
-	if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
59
-		$module_file = 'php_' . $module . '.dll';
60
-	} elseif (PHP_OS=='HP-UX') {
61
-		$module_file = $module . '.sl';
62
-	} else {
63
-		$module_file = $module . '.so';
64
-	}
57
+    /* Once we require PHP >= 4.3, we might use PHP_SHLIB_SUFFIX here */
58
+    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
59
+        $module_file = 'php_' . $module . '.dll';
60
+    } elseif (PHP_OS=='HP-UX') {
61
+        $module_file = $module . '.sl';
62
+    } else {
63
+        $module_file = $module . '.so';
64
+    }
65 65
 
66
-	return @dl($module_file);
66
+    return @dl($module_file);
67 67
 }
68 68
 ?>
Please login to merge, or discard this patch.
ecrire/inc/lien.php 1 patch
Indentation   +194 added lines, -194 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 function inc_lien_dist($lien, $texte='', $class='', $title='', $hlang='', $rel='', $connect='', $env=array()) {
24 24
 
25
-	return $lien;
25
+    return $lien;
26 26
 }
27 27
 
28 28
 // Regexp des raccourcis, aussi utilisee pour la fusion de sauvegarde Spip
@@ -34,12 +34,12 @@  discard block
 block discarded – undo
34 34
 // http://doc.spip.org/@expanser_liens
35 35
 function expanser_liens($t, $connect='', $env=array()){
36 36
 
37
-	$t = pipeline('pre_liens', $t);
37
+    $t = pipeline('pre_liens', $t);
38 38
 
39
-	// on passe a traiter_modeles la liste des liens reperes pour lui permettre
40
-	// de remettre le texte d'origine dans les parametres du modele
41
-	$t = traiter_modeles($t, false, false, $connect);
42
-	return $t;
39
+    // on passe a traiter_modeles la liste des liens reperes pour lui permettre
40
+    // de remettre le texte d'origine dans les parametres du modele
41
+    $t = traiter_modeles($t, false, false, $connect);
42
+    return $t;
43 43
 }
44 44
 
45 45
 // Meme analyse mais pour eliminer les liens
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 {
50 50
 
51 51
 
52
-	return $texte;
52
+    return $texte;
53 53
 }
54 54
 
55 55
 
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
 // la langue et la bulle eventuelles
59 59
 // http://doc.spip.org/@traiter_raccourci_lien_atts
60 60
 function traiter_raccourci_lien_atts($texte) {
61
-	$bulle='';
62
-	$hlang='';
63
-	return array(trim($texte), $bulle, $hlang);
61
+    $bulle='';
62
+    $hlang='';
63
+    return array(trim($texte), $bulle, $hlang);
64 64
 }
65 65
 
66 66
 
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
  * @return string
80 80
  */
81 81
 function virtuel_redirige($virtuel, $url=false){
82
-	return $virtuel;
82
+    return $virtuel;
83 83
 }
84 84
 
85 85
 
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 
95 95
 // http://doc.spip.org/@calculer_url
96 96
 function calculer_url ($ref, $texte='', $pour='url', $connect='', $echappe_typo = true) {
97
-	$r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo);
98
-	return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
97
+    $r = traiter_lien_implicite($ref, $texte, $pour, $connect, $echappe_typo);
98
+    return $r ? $r : traiter_lien_explicite($ref, $texte, $pour, $connect, $echappe_typo);
99 99
 }
100 100
 
101 101
 define('_EXTRAIRE_LIEN', ',^\s*(?:' . _PROTOCOLES_STD . '):?/?/?\s*$,iS');
@@ -103,78 +103,78 @@  discard block
 block discarded – undo
103 103
 // http://doc.spip.org/@traiter_lien_explicite
104 104
 function traiter_lien_explicite ($ref, $texte='', $pour='url', $connect='', $echappe_typo = true)
105 105
 {
106
-	if (preg_match(_EXTRAIRE_LIEN, $ref))
107
-		return ($pour != 'tout') ? '' : array('','','','');
108
-
109
-	$lien = entites_html(trim($ref));
110
-
111
-	// Liens explicites
112
-	if (!$texte) {
113
-		$texte = str_replace('"', '', $lien);
114
-		// evite l'affichage de trops longues urls.
115
-		$lien_court = charger_fonction('lien_court', 'inc');
116
-		$texte = $lien_court($texte);
117
-		if ($echappe_typo){
118
-			$texte = "<html>".quote_amp($texte)."</html>";
119
-		}
120
-	}
121
-
122
-	// petites corrections d'URL
123
-	if (preg_match('/^www\.[^@]+$/S',$lien))
124
-		$lien = "http://".$lien;
125
-	else if (strpos($lien, "@") && email_valide($lien)) {
126
-		if (!$texte) $texte = $lien;
127
-		$lien = "mailto:".$lien;
128
-	}
106
+    if (preg_match(_EXTRAIRE_LIEN, $ref))
107
+        return ($pour != 'tout') ? '' : array('','','','');
108
+
109
+    $lien = entites_html(trim($ref));
110
+
111
+    // Liens explicites
112
+    if (!$texte) {
113
+        $texte = str_replace('"', '', $lien);
114
+        // evite l'affichage de trops longues urls.
115
+        $lien_court = charger_fonction('lien_court', 'inc');
116
+        $texte = $lien_court($texte);
117
+        if ($echappe_typo){
118
+            $texte = "<html>".quote_amp($texte)."</html>";
119
+        }
120
+    }
121
+
122
+    // petites corrections d'URL
123
+    if (preg_match('/^www\.[^@]+$/S',$lien))
124
+        $lien = "http://".$lien;
125
+    else if (strpos($lien, "@") && email_valide($lien)) {
126
+        if (!$texte) $texte = $lien;
127
+        $lien = "mailto:".$lien;
128
+    }
129 129
 	
130
-	if ($pour == 'url') return $lien;
130
+    if ($pour == 'url') return $lien;
131 131
 
132
-	if ($pour == 'titre') return $texte;
132
+    if ($pour == 'titre') return $texte;
133 133
 
134
-	return array('url' => $lien, 'titre' => $texte);
134
+    return array('url' => $lien, 'titre' => $texte);
135 135
 }
136 136
 
137 137
 function liens_implicite_glose_dist($texte,$id,$type,$args,$ancre,$connect=''){
138
-	if (function_exists($f = 'glossaire_' . $ancre))
139
-		$url = $f($texte, $id);
140
-	else
141
-		$url = glossaire_std($texte);
142
-	return $url;
138
+    if (function_exists($f = 'glossaire_' . $ancre))
139
+        $url = $f($texte, $id);
140
+    else
141
+        $url = glossaire_std($texte);
142
+    return $url;
143 143
 }
144 144
 
145 145
 // http://doc.spip.org/@traiter_lien_implicite
146 146
 function traiter_lien_implicite ($ref, $texte='', $pour='url', $connect='')
147 147
 {
148
-	if (!($match = typer_raccourci($ref))) return false;
149
-	@list($type,,$id,,$args,,$ancre) = $match;
148
+    if (!($match = typer_raccourci($ref))) return false;
149
+    @list($type,,$id,,$args,,$ancre) = $match;
150 150
 # attention dans le cas des sites le lien doit pointer non pas sur
151 151
 # la page locale du site, mais directement sur le site lui-meme
152
-	if ($f = charger_fonction("implicite_$type","liens",true))
153
-		$url = $f($texte,$id,$type,$args,$ancre,$connect);
154
-	if (!$url)
155
-		$url = generer_url_entite($id,$type,$args,$ancre,$connect ? $connect : NULL);
156
-	if (!$url) return false;
157
-	if (is_array($url)) {
158
-		@list($type,$id) = $url;
159
-		$url = generer_url_entite($id,$type,$args,$ancre,$connect ? $connect : NULL);
160
-	}
161
-	if ($pour === 'url') return $url;
162
-	$r = traiter_raccourci_titre($id, $type, $connect);
163
-	if ($r) $r['class'] =  ($type == 'site')?'spip_out':'spip_in';
164
-	if ($texte = trim($texte)) $r['titre'] = $texte;
165
-	if (!@$r['titre']) $r['titre'] =  _T($type) . " $id";
166
-	if ($pour=='titre') return $r['titre'];
167
-	$r['url'] = $url;
168
-
169
-	// dans le cas d'un lien vers un doc, ajouter le type='mime/type'
170
-	if ($type == 'document'
171
-	AND $mime = sql_getfetsel('mime_type', 'spip_types_documents',
172
-			"extension IN (".sql_get_select("extension","spip_documents","id_document=".sql_quote($id)).")",
173
-			'','','','',$connect)
174
-	)
175
-		$r['mime'] = $mime;
176
-
177
-	return $r;
152
+    if ($f = charger_fonction("implicite_$type","liens",true))
153
+        $url = $f($texte,$id,$type,$args,$ancre,$connect);
154
+    if (!$url)
155
+        $url = generer_url_entite($id,$type,$args,$ancre,$connect ? $connect : NULL);
156
+    if (!$url) return false;
157
+    if (is_array($url)) {
158
+        @list($type,$id) = $url;
159
+        $url = generer_url_entite($id,$type,$args,$ancre,$connect ? $connect : NULL);
160
+    }
161
+    if ($pour === 'url') return $url;
162
+    $r = traiter_raccourci_titre($id, $type, $connect);
163
+    if ($r) $r['class'] =  ($type == 'site')?'spip_out':'spip_in';
164
+    if ($texte = trim($texte)) $r['titre'] = $texte;
165
+    if (!@$r['titre']) $r['titre'] =  _T($type) . " $id";
166
+    if ($pour=='titre') return $r['titre'];
167
+    $r['url'] = $url;
168
+
169
+    // dans le cas d'un lien vers un doc, ajouter le type='mime/type'
170
+    if ($type == 'document'
171
+    AND $mime = sql_getfetsel('mime_type', 'spip_types_documents',
172
+            "extension IN (".sql_get_select("extension","spip_documents","id_document=".sql_quote($id)).")",
173
+            '','','','',$connect)
174
+    )
175
+        $r['mime'] = $mime;
176
+
177
+    return $r;
178 178
 }
179 179
 
180 180
 // analyse des raccourcis issus de [TITRE->RACCOURCInnn] et connexes
@@ -183,34 +183,34 @@  discard block
 block discarded – undo
183 183
 
184 184
 // http://doc.spip.org/@typer_raccourci
185 185
 function typer_raccourci ($lien) {
186
-	if (!preg_match(_RACCOURCI_URL, $lien, $match)) return array();
187
-	$f = $match[1];
188
-	// valeur par defaut et alias historiques
189
-	if (!$f) $f = 'article';
190
-	else if ($f == 'art') $f = 'article';
191
-	else if ($f == 'br') $f = 'breve';
192
-	else if ($f == 'rub') $f = 'rubrique';
193
-	else if ($f == 'aut') $f = 'auteur';
194
-	else if ($f == 'doc' OR $f == 'im' OR $f == 'img' OR $f == 'image' OR $f == 'emb')
195
-		$f = 'document';
196
-	else if (preg_match('/^br..?ve$/S', $f)) $f = 'breve'; # accents :(
197
-	$match[0] = $f;
198
-	return $match;
186
+    if (!preg_match(_RACCOURCI_URL, $lien, $match)) return array();
187
+    $f = $match[1];
188
+    // valeur par defaut et alias historiques
189
+    if (!$f) $f = 'article';
190
+    else if ($f == 'art') $f = 'article';
191
+    else if ($f == 'br') $f = 'breve';
192
+    else if ($f == 'rub') $f = 'rubrique';
193
+    else if ($f == 'aut') $f = 'auteur';
194
+    else if ($f == 'doc' OR $f == 'im' OR $f == 'img' OR $f == 'image' OR $f == 'emb')
195
+        $f = 'document';
196
+    else if (preg_match('/^br..?ve$/S', $f)) $f = 'breve'; # accents :(
197
+    $match[0] = $f;
198
+    return $match;
199 199
 }
200 200
 
201 201
 // Retourne le champ textuel associe a une cle primaire, et sa langue
202 202
 function traiter_raccourci_titre($id, $type, $connect=NULL)
203 203
 {
204
-	$trouver_table = charger_fonction('trouver_table', 'base');
205
-	$desc = $trouver_table(table_objet($type));
206
-	if (!($desc AND $s = $desc['titre'])) return array();
207
-	$_id = $desc['key']['PRIMARY KEY'];
208
-	$r = sql_fetsel($s, $desc['table'], "$_id=$id", '','','','',$connect);
209
-	if (!$r) return array();
210
-	$r['titre'] = supprimer_numero($r['titre']);
211
-	if (!$r['titre']) $r['titre'] = $r['surnom'];
212
-	if (!isset($r['lang'])) $r['lang'] = '';
213
-	return $r;
204
+    $trouver_table = charger_fonction('trouver_table', 'base');
205
+    $desc = $trouver_table(table_objet($type));
206
+    if (!($desc AND $s = $desc['titre'])) return array();
207
+    $_id = $desc['key']['PRIMARY KEY'];
208
+    $r = sql_fetsel($s, $desc['table'], "$_id=$id", '','','','',$connect);
209
+    if (!$r) return array();
210
+    $r['titre'] = supprimer_numero($r['titre']);
211
+    if (!$r['titre']) $r['titre'] = $r['surnom'];
212
+    if (!isset($r['lang'])) $r['lang'] = '';
213
+    return $r;
214 214
 }
215 215
 
216 216
 // traite les modeles (dans la fonction typo), en remplacant
@@ -222,107 +222,107 @@  discard block
 block discarded – undo
222 222
 // http://doc.spip.org/@traiter_modeles
223 223
 
224 224
 define('_RACCOURCI_MODELE', 
225
-	 '(<([a-z_-]{3,})' # <modele
226
-	.'\s*([0-9]*)\s*' # id
227
-	.'([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
228
-	.'\s*/?'.'>)' # fin du modele >
229
-	.'\s*(<\/a>)?' # eventuel </a>
230
-       );
225
+        '(<([a-z_-]{3,})' # <modele
226
+    .'\s*([0-9]*)\s*' # id
227
+    .'([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
228
+    .'\s*/?'.'>)' # fin du modele >
229
+    .'\s*(<\/a>)?' # eventuel </a>
230
+        );
231 231
 
232 232
 define('_RACCOURCI_MODELE_DEBUT', '@^' . _RACCOURCI_MODELE .'@isS');
233 233
 
234 234
 // http://doc.spip.org/@traiter_modeles
235 235
 function traiter_modeles($texte, $doublons=false, $echap='', $connect='', $liens = null, $env = array()) {
236
-	// preserver la compatibilite : true = recherche des documents
237
-	if ($doublons===true)
238
-		$doublons = array('documents'=>array('doc','emb','img'));
239
-	// detecter les modeles (rapide)
240
-	if (strpos($texte,"<")!==false AND
241
-	  preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)) {
242
-		include_spip('public/assembler');
243
-		$wrap_embed_html = charger_fonction("wrap_embed_html","inc",true);
244
-		foreach ($matches as $match) {
245
-			// Recuperer l'appel complet (y compris un eventuel lien)
246
-
247
-			$a = strpos($texte,$match[0]);
248
-			preg_match(_RACCOURCI_MODELE_DEBUT,
249
-			substr($texte, $a), $regs);
250
-			$regs[]=""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
251
-			list(,$mod, $type, $id, $params, $fin) = $regs;
252
-			if ($fin AND
253
-			preg_match('/<a\s[^<>]*>\s*$/i',
254
-					substr($texte, 0, $a), $r)) {
255
-				$lien = array(
256
-					'href' => extraire_attribut($r[0],'href'),
257
-					'class' => extraire_attribut($r[0],'class'),
258
-					'mime' => extraire_attribut($r[0],'type'),
259
-					'title' => extraire_attribut($r[0],'title'),
260
-					'hreflang' => extraire_attribut($r[0],'hreflang')
261
-				);
262
-				$n = strlen($r[0]);
263
-				$a -= $n;
264
-				$cherche = $n + strlen($regs[0]);
265
-			} else {
266
-				$lien = false;
267
-				$cherche = strlen($mod);
268
-			}
269
-
270
-			// calculer le modele
271
-			# hack indexation
272
-			if ($doublons)
273
-				$texte .= preg_replace(',[|][^|=]*,s',' ',$params);
274
-			# version normale
275
-			else {
276
-				// si un tableau de liens a ete passe, reinjecter le contenu d'origine
277
-				// dans les parametres, plutot que les liens echappes
278
-				if (!is_null($liens))
279
-					$params = str_replace($liens[0], $liens[1], $params);
280
-				$modele = inclure_modele($type, $id, $params, $lien, $connect, $env);
281
-				// en cas d'echec, 
282
-				// si l'objet demande a une url, 
283
-				// creer un petit encadre vers elle
284
-				if ($modele === false) {
285
-					if (!$lien)
286
-						$lien = traiter_lien_implicite("$type$id", '', 'tout', $connect);
287
-					if ($lien)
288
-						$modele = '<a href="'
289
-						  .$lien['url']
290
-						  .'" class="spip_modele'
291
-						  . '">'
292
-						  .sinon($lien['titre'], _T('ecrire:info_sans_titre'))
293
-						  ."</a>";
294
-					else {
295
-						$modele = "";
296
-						if (test_espace_prive()) {
297
-							$modele = entites_html(substr($texte,$a,$cherche));
298
-							if (!is_null($liens))
299
-								$modele = "<pre>".str_replace($liens[0], $liens[1], $modele)."</pre>";
300
-						}
301
-					}
302
-				}
303
-				// le remplacer dans le texte
304
-				if ($modele !== false) {
305
-					$modele = protege_js_modeles($modele);
306
-					if ($wrap_embed_html){
307
-						$modele = $wrap_embed_html($mod,$modele);
308
-					}
309
-					$rempl = code_echappement($modele, $echap);
310
-					$texte = substr($texte, 0, $a)
311
-						. $rempl
312
-						. substr($texte, $a+$cherche);
313
-				}
314
-			}
315
-
316
-			// hack pour tout l'espace prive
317
-			if (((!_DIR_RESTREINT) OR ($doublons)) AND ($id)){
318
-				foreach($doublons?$doublons:array('documents'=>array('doc','emb','img')) as $quoi=>$modeles)
319
-					if (in_array($type,$modeles))
320
-						$GLOBALS["doublons_{$quoi}_inclus"][] = $id;
321
-			}
322
-		}
323
-	}
324
-
325
-	return $texte;
236
+    // preserver la compatibilite : true = recherche des documents
237
+    if ($doublons===true)
238
+        $doublons = array('documents'=>array('doc','emb','img'));
239
+    // detecter les modeles (rapide)
240
+    if (strpos($texte,"<")!==false AND
241
+      preg_match_all('/<[a-z_-]{3,}\s*[0-9|]+/iS', $texte, $matches, PREG_SET_ORDER)) {
242
+        include_spip('public/assembler');
243
+        $wrap_embed_html = charger_fonction("wrap_embed_html","inc",true);
244
+        foreach ($matches as $match) {
245
+            // Recuperer l'appel complet (y compris un eventuel lien)
246
+
247
+            $a = strpos($texte,$match[0]);
248
+            preg_match(_RACCOURCI_MODELE_DEBUT,
249
+            substr($texte, $a), $regs);
250
+            $regs[]=""; // s'assurer qu'il y a toujours un 5e arg, eventuellement vide
251
+            list(,$mod, $type, $id, $params, $fin) = $regs;
252
+            if ($fin AND
253
+            preg_match('/<a\s[^<>]*>\s*$/i',
254
+                    substr($texte, 0, $a), $r)) {
255
+                $lien = array(
256
+                    'href' => extraire_attribut($r[0],'href'),
257
+                    'class' => extraire_attribut($r[0],'class'),
258
+                    'mime' => extraire_attribut($r[0],'type'),
259
+                    'title' => extraire_attribut($r[0],'title'),
260
+                    'hreflang' => extraire_attribut($r[0],'hreflang')
261
+                );
262
+                $n = strlen($r[0]);
263
+                $a -= $n;
264
+                $cherche = $n + strlen($regs[0]);
265
+            } else {
266
+                $lien = false;
267
+                $cherche = strlen($mod);
268
+            }
269
+
270
+            // calculer le modele
271
+            # hack indexation
272
+            if ($doublons)
273
+                $texte .= preg_replace(',[|][^|=]*,s',' ',$params);
274
+            # version normale
275
+            else {
276
+                // si un tableau de liens a ete passe, reinjecter le contenu d'origine
277
+                // dans les parametres, plutot que les liens echappes
278
+                if (!is_null($liens))
279
+                    $params = str_replace($liens[0], $liens[1], $params);
280
+                $modele = inclure_modele($type, $id, $params, $lien, $connect, $env);
281
+                // en cas d'echec, 
282
+                // si l'objet demande a une url, 
283
+                // creer un petit encadre vers elle
284
+                if ($modele === false) {
285
+                    if (!$lien)
286
+                        $lien = traiter_lien_implicite("$type$id", '', 'tout', $connect);
287
+                    if ($lien)
288
+                        $modele = '<a href="'
289
+                            .$lien['url']
290
+                            .'" class="spip_modele'
291
+                            . '">'
292
+                            .sinon($lien['titre'], _T('ecrire:info_sans_titre'))
293
+                            ."</a>";
294
+                    else {
295
+                        $modele = "";
296
+                        if (test_espace_prive()) {
297
+                            $modele = entites_html(substr($texte,$a,$cherche));
298
+                            if (!is_null($liens))
299
+                                $modele = "<pre>".str_replace($liens[0], $liens[1], $modele)."</pre>";
300
+                        }
301
+                    }
302
+                }
303
+                // le remplacer dans le texte
304
+                if ($modele !== false) {
305
+                    $modele = protege_js_modeles($modele);
306
+                    if ($wrap_embed_html){
307
+                        $modele = $wrap_embed_html($mod,$modele);
308
+                    }
309
+                    $rempl = code_echappement($modele, $echap);
310
+                    $texte = substr($texte, 0, $a)
311
+                        . $rempl
312
+                        . substr($texte, $a+$cherche);
313
+                }
314
+            }
315
+
316
+            // hack pour tout l'espace prive
317
+            if (((!_DIR_RESTREINT) OR ($doublons)) AND ($id)){
318
+                foreach($doublons?$doublons:array('documents'=>array('doc','emb','img')) as $quoi=>$modeles)
319
+                    if (in_array($type,$modeles))
320
+                        $GLOBALS["doublons_{$quoi}_inclus"][] = $id;
321
+            }
322
+        }
323
+    }
324
+
325
+    return $texte;
326 326
 }
327 327
 
328 328
 //
@@ -331,19 +331,19 @@  discard block
 block discarded – undo
331 331
 // http://doc.spip.org/@traiter_raccourci_ancre
332 332
 function traiter_raccourci_ancre($letexte)
333 333
 {
334
-	return $letexte;
334
+    return $letexte;
335 335
 }
336 336
 
337 337
 // http://doc.spip.org/@traiter_raccourci_glossaire
338 338
 function traiter_raccourci_glossaire($texte)
339 339
 {
340
-	return $texte;
340
+    return $texte;
341 341
 }
342 342
 
343 343
 // http://doc.spip.org/@glossaire_std
344 344
 function glossaire_std($terme)
345 345
 {
346
-	return  $terme;
346
+    return  $terme;
347 347
 }
348 348
 
349 349
 ?>
Please login to merge, or discard this patch.
ecrire/inc/autoriser.php 1 patch
Indentation   +386 added lines, -386 removed lines patch added patch discarded remove patch
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
 
42 42
 // mes_fonctions peut aussi declarer des autorisations, donc il faut donc le charger
43 43
 if ($f = find_in_path('mes_fonctions.php')) {
44
-	global $dossier_squelettes;
45
-	include_once(_ROOT_CWD . $f);
44
+    global $dossier_squelettes;
45
+    include_once(_ROOT_CWD . $f);
46 46
 }
47 47
 
48 48
 
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
  * @return bool
83 83
  *   true si la personne peut effectuer l'action
84 84
  */
85
-	function autoriser($faire, $type='', $id=0, $qui = NULL, $opt = NULL) {
86
-		// Charger les fonctions d'autorisation supplementaires
87
-		static $pipe;
88
-		if (!isset($pipe)) { $pipe = 1; pipeline('autoriser'); }
89
-
90
-		$args = func_get_args();
91
-		return call_user_func_array('autoriser_dist', $args);
92
-	}
85
+    function autoriser($faire, $type='', $id=0, $qui = NULL, $opt = NULL) {
86
+        // Charger les fonctions d'autorisation supplementaires
87
+        static $pipe;
88
+        if (!isset($pipe)) { $pipe = 1; pipeline('autoriser'); }
89
+
90
+        $args = func_get_args();
91
+        return call_user_func_array('autoriser_dist', $args);
92
+    }
93 93
 }
94 94
 
95 95
 
@@ -117,62 +117,62 @@  discard block
 block discarded – undo
117 117
  */
118 118
 function autoriser_dist($faire, $type='', $id=0, $qui = NULL, $opt = NULL) {
119 119
 
120
-	// Qui ? visiteur_session ?
121
-	// si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge
122
-	if ($qui === NULL OR $qui==='')
123
-	  $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : array('statut' => '', 'id_auteur' =>0, 'webmestre' => 'non');
124
-	elseif (is_numeric($qui)) {
125
-		$qui = sql_fetsel("*", "spip_auteurs", "id_auteur=".$qui);
126
-	}
127
-
128
-	// Admins restreints, on construit ici (pas generique mais...)
129
-	// le tableau de toutes leurs rubriques (y compris les sous-rubriques)
130
-	if (_ADMINS_RESTREINTS AND is_array($qui)) {
131
-		$qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : array();
132
-	}
133
-
134
-	if (_DEBUG_AUTORISER) spip_log("autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ") ?");
135
-
136
-	// passer par objet_type pour avoir les alias
137
-	// et supprimer les _
138
-	$type = str_replace('_','',  strncmp($type,"_",1)==0?$type:objet_type($type,false));
139
-
140
-	// Si une exception a ete decretee plus haut dans le code, l'appliquer
141
-	if (isset($GLOBALS['autoriser_exception'][$faire][$type][$id])
142
-	AND autoriser_exception($faire,$type,$id,'verifier'))
143
-		return true;
144
-
145
-	// Chercher une fonction d'autorisation
146
-	// Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist],
147
-	// autoriser_faire[_dist], autoriser_defaut[_dist]
148
-	$fonctions = $type
149
-		? array (
150
-			'autoriser_'.$type.'_'.$faire,
151
-			'autoriser_'.$type.'_'.$faire.'_dist',
152
-			'autoriser_'.$type,
153
-			'autoriser_'.$type.'_dist',
154
-			'autoriser_'.$faire,
155
-			'autoriser_'.$faire.'_dist',
156
-			'autoriser_defaut',
157
-			'autoriser_defaut_dist'
158
-		)
159
-		: array (
160
-			'autoriser_'.$faire,
161
-			'autoriser_'.$faire.'_dist',
162
-			'autoriser_defaut',
163
-			'autoriser_defaut_dist'
164
-		);
165
-
166
-	foreach ($fonctions as $f) {
167
-		if (function_exists($f)) {
168
-			$a = $f($faire,$type,$id,$qui,$opt);
169
-			break;
170
-		}
171
-	}
172
-
173
-	if (_DEBUG_AUTORISER) spip_log("$f($faire,$type,$id," . (isset($qui['nom']) ? $qui['nom'] : '') . "): ".($a?'OK':'niet'));
174
-
175
-	return $a;
120
+    // Qui ? visiteur_session ?
121
+    // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge
122
+    if ($qui === NULL OR $qui==='')
123
+        $qui = $GLOBALS['visiteur_session'] ? $GLOBALS['visiteur_session'] : array('statut' => '', 'id_auteur' =>0, 'webmestre' => 'non');
124
+    elseif (is_numeric($qui)) {
125
+        $qui = sql_fetsel("*", "spip_auteurs", "id_auteur=".$qui);
126
+    }
127
+
128
+    // Admins restreints, on construit ici (pas generique mais...)
129
+    // le tableau de toutes leurs rubriques (y compris les sous-rubriques)
130
+    if (_ADMINS_RESTREINTS AND is_array($qui)) {
131
+        $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : array();
132
+    }
133
+
134
+    if (_DEBUG_AUTORISER) spip_log("autoriser $faire $type $id (" . (isset($qui['nom']) ? $qui['nom'] : '') . ") ?");
135
+
136
+    // passer par objet_type pour avoir les alias
137
+    // et supprimer les _
138
+    $type = str_replace('_','',  strncmp($type,"_",1)==0?$type:objet_type($type,false));
139
+
140
+    // Si une exception a ete decretee plus haut dans le code, l'appliquer
141
+    if (isset($GLOBALS['autoriser_exception'][$faire][$type][$id])
142
+    AND autoriser_exception($faire,$type,$id,'verifier'))
143
+        return true;
144
+
145
+    // Chercher une fonction d'autorisation
146
+    // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist],
147
+    // autoriser_faire[_dist], autoriser_defaut[_dist]
148
+    $fonctions = $type
149
+        ? array (
150
+            'autoriser_'.$type.'_'.$faire,
151
+            'autoriser_'.$type.'_'.$faire.'_dist',
152
+            'autoriser_'.$type,
153
+            'autoriser_'.$type.'_dist',
154
+            'autoriser_'.$faire,
155
+            'autoriser_'.$faire.'_dist',
156
+            'autoriser_defaut',
157
+            'autoriser_defaut_dist'
158
+        )
159
+        : array (
160
+            'autoriser_'.$faire,
161
+            'autoriser_'.$faire.'_dist',
162
+            'autoriser_defaut',
163
+            'autoriser_defaut_dist'
164
+        );
165
+
166
+    foreach ($fonctions as $f) {
167
+        if (function_exists($f)) {
168
+            $a = $f($faire,$type,$id,$qui,$opt);
169
+            break;
170
+        }
171
+    }
172
+
173
+    if (_DEBUG_AUTORISER) spip_log("$f($faire,$type,$id," . (isset($qui['nom']) ? $qui['nom'] : '') . "): ".($a?'OK':'niet'));
174
+
175
+    return $a;
176 176
 }
177 177
 
178 178
 // une globale pour aller au plus vite dans la fonction generique ci dessus
@@ -190,17 +190,17 @@  discard block
 block discarded – undo
190 190
  * @return bool
191 191
  */
192 192
 function autoriser_exception($faire,$type,$id,$autoriser=true){
193
-	// une static innaccessible par url pour verifier que la globale est positionnee a bon escient
194
-	static $autorisation;
195
-	if ($autoriser==='verifier')
196
-			return isset($autorisation[$faire][$type][$id]);
197
-	if ($autoriser===true)
198
-		$GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true;
199
-	if ($autoriser===false) {
200
-		unset($GLOBALS['autoriser_exception'][$faire][$type][$id]);
201
-		unset($autorisation[$faire][$type][$id]);
202
-	}
203
-	return false;
193
+    // une static innaccessible par url pour verifier que la globale est positionnee a bon escient
194
+    static $autorisation;
195
+    if ($autoriser==='verifier')
196
+            return isset($autorisation[$faire][$type][$id]);
197
+    if ($autoriser===true)
198
+        $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true;
199
+    if ($autoriser===false) {
200
+        unset($GLOBALS['autoriser_exception'][$faire][$type][$id]);
201
+        unset($autorisation[$faire][$type][$id]);
202
+    }
203
+    return false;
204 204
 }
205 205
 
206 206
  
@@ -217,9 +217,9 @@  discard block
 block discarded – undo
217 217
  * @return bool          true s'il a le droit, false sinon
218 218
 **/
219 219
 function autoriser_defaut_dist($faire, $type, $id, $qui, $opt) {
220
-	return
221
-		$qui['statut'] == '0minirezo'
222
-		AND !$qui['restreint'];
220
+    return
221
+        $qui['statut'] == '0minirezo'
222
+        AND !$qui['restreint'];
223 223
 }
224 224
 
225 225
 
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
  * @return bool          true s'il a le droit, false sinon
235 235
 **/
236 236
 function autoriser_ecrire_dist($faire, $type, $id, $qui, $opt) {
237
-	return in_array($qui['statut'], array('0minirezo', '1comite'));
237
+    return in_array($qui['statut'], array('0minirezo', '1comite'));
238 238
 }
239 239
 
240 240
 /**
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
  * @return bool          true s'il a le droit, false sinon
252 252
 **/
253 253
 function autoriser_creer_dist($faire, $type, $id, $qui, $opt) {
254
-	return in_array($qui['statut'], array('0minirezo', '1comite'));
254
+    return in_array($qui['statut'], array('0minirezo', '1comite'));
255 255
 }
256 256
 
257 257
 /**
@@ -265,32 +265,32 @@  discard block
 block discarded – undo
265 265
  * @return bool          true s'il a le droit, false sinon
266 266
 **/
267 267
 function autoriser_previsualiser_dist($faire, $type, $id, $qui, $opt) {
268
-	// si auteur pas autorise, NIET
269
-	if (strpos($GLOBALS['meta']['preview'], ",". $qui['statut'] .",")===false)
270
-		return false;
271
-	// si pas de type et statut fourni, c'est une autorisation generale => OK
272
-	if (!$type)
273
-		return true;
274
-
275
-	include_spip('base/objets');
276
-	$infos = lister_tables_objets_sql(table_objet_sql($type));
277
-	if (isset($infos['statut']))
278
-		foreach($infos['statut'] as $c){
279
-			if (isset($c['publie'])){
280
-				if (!isset($c['previsu'])) return false; // pas de previsu definie => NIET
281
-				$champ = $c['champ'];
282
-				if (!isset($opt[$champ])) return false; // pas de champ passe a la demande => NIET
283
-				$previsu = explode(',',$c['previsu']);
284
-				// regarder si ce statut est autorise pour l'auteur
285
-				if (in_array($opt[$champ]."/auteur",$previsu)){
286
-					if (!sql_countsel("spip_auteurs_liens","id_auteur=".intval($qui['id_auteur'])." AND objet=".sql_quote($type)." AND id_objet=".intval($id)))
287
-						return false;  // pas auteur de cet objet => NIET
288
-				}
289
-				elseif (!in_array($opt[$champ],$previsu)) // le statut n'est pas dans ceux definis par la previsu => NIET
290
-					return false;
291
-			}
292
-		}
293
-	return true;
268
+    // si auteur pas autorise, NIET
269
+    if (strpos($GLOBALS['meta']['preview'], ",". $qui['statut'] .",")===false)
270
+        return false;
271
+    // si pas de type et statut fourni, c'est une autorisation generale => OK
272
+    if (!$type)
273
+        return true;
274
+
275
+    include_spip('base/objets');
276
+    $infos = lister_tables_objets_sql(table_objet_sql($type));
277
+    if (isset($infos['statut']))
278
+        foreach($infos['statut'] as $c){
279
+            if (isset($c['publie'])){
280
+                if (!isset($c['previsu'])) return false; // pas de previsu definie => NIET
281
+                $champ = $c['champ'];
282
+                if (!isset($opt[$champ])) return false; // pas de champ passe a la demande => NIET
283
+                $previsu = explode(',',$c['previsu']);
284
+                // regarder si ce statut est autorise pour l'auteur
285
+                if (in_array($opt[$champ]."/auteur",$previsu)){
286
+                    if (!sql_countsel("spip_auteurs_liens","id_auteur=".intval($qui['id_auteur'])." AND objet=".sql_quote($type)." AND id_objet=".intval($id)))
287
+                        return false;  // pas auteur de cet objet => NIET
288
+                }
289
+                elseif (!in_array($opt[$champ],$previsu)) // le statut n'est pas dans ceux definis par la previsu => NIET
290
+                    return false;
291
+            }
292
+        }
293
+    return true;
294 294
 }
295 295
 
296 296
 /**
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
  * @return bool          true s'il a le droit, false sinon
305 305
 **/
306 306
 function autoriser_changerlangue_dist($faire, $type, $id, $qui, $opt) {
307
-	return autoriser('modifier',$type,$id,$qui,$opt);
307
+    return autoriser('modifier',$type,$id,$qui,$opt);
308 308
 }
309 309
 
310 310
 /**
@@ -318,25 +318,25 @@  discard block
 block discarded – undo
318 318
  * @return bool          true s'il a le droit, false sinon
319 319
 **/
320 320
 function autoriser_dater_dist($faire, $type, $id, $qui, $opt) {
321
-	if (!isset($opt['statut'])){
322
-		$table = table_objet($type);
323
-		$trouver_table = charger_fonction('trouver_table','base');
324
-		$desc = $trouver_table($table);
325
-		if (!$desc)
326
-			return false;
327
-		if (isset($desc['field']['statut'])){
328
-			$statut = sql_getfetsel("statut", $desc['table'], id_table_objet($type)."=".intval($id));
329
-		}
330
-		else
331
-			$statut = 'publie'; // pas de statut => publie
332
-	}
333
-	else
334
-		$statut = $opt['statut'];
335
-
336
-	if ($statut == 'publie'
337
-	 OR ($statut == 'prop' AND $type=='article' AND $GLOBALS['meta']["post_dates"] == "non"))
338
-		return autoriser('modifier', $type, $id);
339
-	return false;
321
+    if (!isset($opt['statut'])){
322
+        $table = table_objet($type);
323
+        $trouver_table = charger_fonction('trouver_table','base');
324
+        $desc = $trouver_table($table);
325
+        if (!$desc)
326
+            return false;
327
+        if (isset($desc['field']['statut'])){
328
+            $statut = sql_getfetsel("statut", $desc['table'], id_table_objet($type)."=".intval($id));
329
+        }
330
+        else
331
+            $statut = 'publie'; // pas de statut => publie
332
+    }
333
+    else
334
+        $statut = $opt['statut'];
335
+
336
+    if ($statut == 'publie'
337
+     OR ($statut == 'prop' AND $type=='article' AND $GLOBALS['meta']["post_dates"] == "non"))
338
+        return autoriser('modifier', $type, $id);
339
+    return false;
340 340
 }
341 341
 
342 342
 /**
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
  * @return bool          true s'il a le droit, false sinon
354 354
 **/
355 355
 function autoriser_instituer_dist($faire, $type, $id, $qui, $opt) {
356
-	return autoriser('modifier',$type,$id,$qui,$opt);
356
+    return autoriser('modifier',$type,$id,$qui,$opt);
357 357
 }
358 358
 
359 359
 /**
@@ -369,31 +369,31 @@  discard block
 block discarded – undo
369 369
  * @return bool          true s'il a le droit, false sinon
370 370
 **/
371 371
 function autoriser_rubrique_publierdans_dist($faire, $type, $id, $qui, $opt) {
372
-	return
373
-		($qui['statut'] == '0minirezo')
374
-		AND (
375
-			!$qui['restreint'] OR !$id
376
-			OR in_array($id, $qui['restreint'])
377
-		);
372
+    return
373
+        ($qui['statut'] == '0minirezo')
374
+        AND (
375
+            !$qui['restreint'] OR !$id
376
+            OR in_array($id, $qui['restreint'])
377
+        );
378 378
 }
379 379
 
380
- /**
381
- * Autorisation de créer une rubrique
382
- *
383
- * Il faut être administrateur pour pouvoir publier à la racine
384
- * 
385
- * @param  string $faire Action demandée
386
- * @param  string $type  Type d'objet sur lequel appliquer l'action
387
- * @param  int    $id    Identifiant de l'objet
388
- * @param  array  $qui   Description de l'auteur demandant l'autorisation
389
- * @param  array  $opt   Options de cette autorisation
390
- * @return bool          true s'il a le droit, false sinon
380
+    /**
381
+     * Autorisation de créer une rubrique
382
+     *
383
+     * Il faut être administrateur pour pouvoir publier à la racine
384
+     * 
385
+     * @param  string $faire Action demandée
386
+     * @param  string $type  Type d'objet sur lequel appliquer l'action
387
+     * @param  int    $id    Identifiant de l'objet
388
+     * @param  array  $qui   Description de l'auteur demandant l'autorisation
389
+     * @param  array  $opt   Options de cette autorisation
390
+     * @return bool          true s'il a le droit, false sinon
391 391
 **/
392 392
 function autoriser_rubrique_creer_dist($faire, $type, $id, $qui, $opt) {
393
-	return 
394
-		((!$id AND autoriser('defaut',null,null,$qui, $opt))
395
-		OR $id AND autoriser('creerrubriquedans','rubrique', $id, $qui, $opt)
396
-		);
393
+    return 
394
+        ((!$id AND autoriser('defaut',null,null,$qui, $opt))
395
+        OR $id AND autoriser('creerrubriquedans','rubrique', $id, $qui, $opt)
396
+        );
397 397
 }
398 398
 
399 399
 /**
@@ -409,10 +409,10 @@  discard block
 block discarded – undo
409 409
  * @return bool          true s'il a le droit, false sinon
410 410
 **/
411 411
 function autoriser_rubrique_creerrubriquedans_dist($faire, $type, $id, $qui, $opt) {
412
-	return
413
-		($id OR ($qui['statut'] == '0minirezo' AND !$qui['restreint']))
414
-		AND autoriser('voir','rubrique',$id)
415
-		AND autoriser('publierdans','rubrique',$id);
412
+    return
413
+        ($id OR ($qui['statut'] == '0minirezo' AND !$qui['restreint']))
414
+        AND autoriser('voir','rubrique',$id)
415
+        AND autoriser('publierdans','rubrique',$id);
416 416
 }
417 417
 
418 418
 /**
@@ -428,10 +428,10 @@  discard block
 block discarded – undo
428 428
  * @return bool          true s'il a le droit, false sinon
429 429
 **/
430 430
 function autoriser_rubrique_creerarticledans_dist($faire, $type, $id, $qui, $opt) {
431
-	return
432
-		$id
433
-		AND autoriser('voir','rubrique',$id)
434
-		AND autoriser('creer', 'article');
431
+    return
432
+        $id
433
+        AND autoriser('voir','rubrique',$id)
434
+        AND autoriser('creer', 'article');
435 435
 }
436 436
 
437 437
 
@@ -448,8 +448,8 @@  discard block
 block discarded – undo
448 448
  * @return bool          true s'il a le droit, false sinon
449 449
 **/
450 450
 function autoriser_rubrique_modifier_dist($faire, $type, $id, $qui, $opt) {
451
-	return
452
-		autoriser('publierdans', 'rubrique', $id, $qui, $opt);
451
+    return
452
+        autoriser('publierdans', 'rubrique', $id, $qui, $opt);
453 453
 }
454 454
 
455 455
 /**
@@ -465,21 +465,21 @@  discard block
 block discarded – undo
465 465
  * @return bool          true s'il a le droit, false sinon
466 466
 **/
467 467
 function autoriser_rubrique_supprimer_dist($faire, $type, $id, $qui, $opt) {
468
-	if (!$id = intval($id))
469
-		return false;
468
+    if (!$id = intval($id))
469
+        return false;
470 470
 
471
-	if (sql_countsel('spip_rubriques', "id_parent=".intval($id)))
472
-		return false;
471
+    if (sql_countsel('spip_rubriques', "id_parent=".intval($id)))
472
+        return false;
473 473
 
474
-	if (sql_countsel('spip_articles', "id_rubrique=".intval($id)." AND (statut<>'poubelle')"))
475
-		return false;
474
+    if (sql_countsel('spip_articles', "id_rubrique=".intval($id)." AND (statut<>'poubelle')"))
475
+        return false;
476 476
 
477
-	$compte = pipeline('objet_compte_enfants',array('args'=>array('objet'=>'rubrique','id_objet'=>$id),'data'=>array()));
478
-	foreach($compte as $objet => $n)
479
-		if ($n)
480
-			return false;
477
+    $compte = pipeline('objet_compte_enfants',array('args'=>array('objet'=>'rubrique','id_objet'=>$id),'data'=>array()));
478
+    foreach($compte as $objet => $n)
479
+        if ($n)
480
+            return false;
481 481
 
482
-	return autoriser('modifier','rubrique',$id);
482
+    return autoriser('modifier','rubrique',$id);
483 483
 }
484 484
 
485 485
 
@@ -497,39 +497,39 @@  discard block
 block discarded – undo
497 497
  * @return bool          true s'il a le droit, false sinon
498 498
 **/
499 499
 function autoriser_article_modifier_dist($faire, $type, $id, $qui, $opt) {
500
-	$r = sql_fetsel("id_rubrique,statut", "spip_articles", "id_article=".sql_quote($id));
501
-
502
-	if (!function_exists('auteurs_article'))
503
-		include_spip('inc/auth'); // pour auteurs_article si espace public
504
-
505
-	return
506
-		$r
507
-		AND
508
-		(
509
-			autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt)
510
-			OR (
511
-				(!isset($opt['statut']) OR $opt['statut']!=='publie')
512
-				AND in_array($qui['statut'], array('0minirezo', '1comite'))
513
-				AND in_array($r['statut'], array('prop','prepa', 'poubelle'))
514
-				AND auteurs_article($id, "id_auteur=".$qui['id_auteur'])
515
-			)
516
-		);
500
+    $r = sql_fetsel("id_rubrique,statut", "spip_articles", "id_article=".sql_quote($id));
501
+
502
+    if (!function_exists('auteurs_article'))
503
+        include_spip('inc/auth'); // pour auteurs_article si espace public
504
+
505
+    return
506
+        $r
507
+        AND
508
+        (
509
+            autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt)
510
+            OR (
511
+                (!isset($opt['statut']) OR $opt['statut']!=='publie')
512
+                AND in_array($qui['statut'], array('0minirezo', '1comite'))
513
+                AND in_array($r['statut'], array('prop','prepa', 'poubelle'))
514
+                AND auteurs_article($id, "id_auteur=".$qui['id_auteur'])
515
+            )
516
+        );
517 517
 }
518 518
 
519
- /**
520
- * Autorisation de créer un article
521
- *
522
- * Il faut qu'une rubrique existe et être au moins rédacteur
523
- * 
524
- * @param  string $faire Action demandée
525
- * @param  string $type  Type d'objet sur lequel appliquer l'action
526
- * @param  int    $id    Identifiant de l'objet
527
- * @param  array  $qui   Description de l'auteur demandant l'autorisation
528
- * @param  array  $opt   Options de cette autorisation
529
- * @return bool          true s'il a le droit, false sinon
519
+    /**
520
+     * Autorisation de créer un article
521
+     *
522
+     * Il faut qu'une rubrique existe et être au moins rédacteur
523
+     * 
524
+     * @param  string $faire Action demandée
525
+     * @param  string $type  Type d'objet sur lequel appliquer l'action
526
+     * @param  int    $id    Identifiant de l'objet
527
+     * @param  array  $qui   Description de l'auteur demandant l'autorisation
528
+     * @param  array  $opt   Options de cette autorisation
529
+     * @return bool          true s'il a le droit, false sinon
530 530
 **/
531 531
 function autoriser_article_creer_dist($faire, $type, $id, $qui, $opt) {
532
-	return (sql_countsel('spip_rubriques')>0 AND in_array($qui['statut'], array('0minirezo', '1comite')));
532
+    return (sql_countsel('spip_rubriques')>0 AND in_array($qui['statut'], array('0minirezo', '1comite')));
533 533
 }
534 534
 
535 535
 /**
@@ -549,24 +549,24 @@  discard block
 block discarded – undo
549 549
  * @return bool          true s'il a le droit, false sinon
550 550
  */
551 551
 function autoriser_article_voir_dist($faire, $type, $id, $qui, $opt){
552
-	if ($qui['statut'] == '0minirezo') return true;
553
-	// cas des articles : depend du statut de l'article et de l'auteur
554
-	if (isset($opt['statut']))
555
-		$statut = $opt['statut'];
556
-	else {
557
-		if (!$id) return false;
558
-		$statut = sql_getfetsel("statut", "spip_articles", "id_article=".intval($id));
559
-	}
560
-
561
-	return
562
-		// si on est pas auteur de l'article,
563
-		// seuls les propose et publies sont visibles
564
-		in_array($statut, array('prop', 'publie'))
565
-		// sinon si on est auteur, on a le droit de le voir, evidemment !
566
-		OR
567
-		($id AND $qui['id_auteur']
568
-		     AND (function_exists('auteurs_article') OR include_spip('inc/auth'))
569
-		     AND auteurs_article($id, "id_auteur=".$qui['id_auteur']));
552
+    if ($qui['statut'] == '0minirezo') return true;
553
+    // cas des articles : depend du statut de l'article et de l'auteur
554
+    if (isset($opt['statut']))
555
+        $statut = $opt['statut'];
556
+    else {
557
+        if (!$id) return false;
558
+        $statut = sql_getfetsel("statut", "spip_articles", "id_article=".intval($id));
559
+    }
560
+
561
+    return
562
+        // si on est pas auteur de l'article,
563
+        // seuls les propose et publies sont visibles
564
+        in_array($statut, array('prop', 'publie'))
565
+        // sinon si on est auteur, on a le droit de le voir, evidemment !
566
+        OR
567
+        ($id AND $qui['id_auteur']
568
+             AND (function_exists('auteurs_article') OR include_spip('inc/auth'))
569
+             AND auteurs_article($id, "id_auteur=".$qui['id_auteur']));
570 570
 }
571 571
 
572 572
 
@@ -583,18 +583,18 @@  discard block
 block discarded – undo
583 583
  * @return bool          true s'il a le droit, false sinon
584 584
 **/
585 585
 function autoriser_voir_dist($faire, $type, $id, $qui, $opt) {
586
-	# securite, mais on aurait pas du arriver ici !
587
-	if (function_exists($f='autoriser_'.$type.'_voir') OR function_exists($f='autoriser_'.$type.'_voir_dist')){
588
-		return $f($faire, $type, $id, $qui, $opt);
589
-	}
590
-
591
-	if ($qui['statut'] == '0minirezo') return true;
592
-	// admins et redacteurs peuvent voir un auteur
593
-	if ($type == 'auteur')
594
-		return in_array($qui['statut'], array('0minirezo', '1comite'));
595
-	// sinon par defaut tout est visible
596
-	// sauf cas particuliers traites separemment (ie article)
597
-	return true;
586
+    # securite, mais on aurait pas du arriver ici !
587
+    if (function_exists($f='autoriser_'.$type.'_voir') OR function_exists($f='autoriser_'.$type.'_voir_dist')){
588
+        return $f($faire, $type, $id, $qui, $opt);
589
+    }
590
+
591
+    if ($qui['statut'] == '0minirezo') return true;
592
+    // admins et redacteurs peuvent voir un auteur
593
+    if ($type == 'auteur')
594
+        return in_array($qui['statut'], array('0minirezo', '1comite'));
595
+    // sinon par defaut tout est visible
596
+    // sauf cas particuliers traites separemment (ie article)
597
+    return true;
598 598
 }
599 599
 
600 600
 
@@ -615,13 +615,13 @@  discard block
 block discarded – undo
615 615
  * @return bool          true s'il a le droit, false sinon
616 616
 **/
617 617
 function autoriser_webmestre_dist($faire, $type, $id, $qui, $opt) {
618
-	return
619
-		(defined('_ID_WEBMESTRES')?
620
-			in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES))
621
-			:$qui['webmestre']=='oui')
622
-		AND $qui['statut'] == '0minirezo'
623
-		AND !$qui['restreint']
624
-		;
618
+    return
619
+        (defined('_ID_WEBMESTRES')?
620
+            in_array($qui['id_auteur'], explode(':', _ID_WEBMESTRES))
621
+            :$qui['webmestre']=='oui')
622
+        AND $qui['statut'] == '0minirezo'
623
+        AND !$qui['restreint']
624
+        ;
625 625
 }
626 626
 
627 627
 /**
@@ -637,10 +637,10 @@  discard block
 block discarded – undo
637 637
  * @return bool          true s'il a le droit, false sinon
638 638
 **/
639 639
 function autoriser_configurer_dist($faire, $type, $id, $qui, $opt) {
640
-	return
641
-		$qui['statut'] == '0minirezo'
642
-		AND !$qui['restreint']
643
-		;
640
+    return
641
+        $qui['statut'] == '0minirezo'
642
+        AND !$qui['restreint']
643
+        ;
644 644
 }
645 645
 
646 646
 /**
@@ -656,9 +656,9 @@  discard block
 block discarded – undo
656 656
  * @return bool          true s'il a le droit, false sinon
657 657
 **/
658 658
 function autoriser_sauvegarder_dist($faire, $type, $id, $qui, $opt) {
659
-	return
660
-		$qui['statut'] == '0minirezo'
661
-		;
659
+    return
660
+        $qui['statut'] == '0minirezo'
661
+        ;
662 662
 }
663 663
 
664 664
 /**
@@ -674,8 +674,8 @@  discard block
 block discarded – undo
674 674
  * @return bool          true s'il a le droit, false sinon
675 675
 **/
676 676
 function autoriser_detruire_dist($faire, $type, $id, $qui, $opt) {
677
-	return
678
-		autoriser('webmestre', null, null, $qui, $opt);
677
+    return
678
+        autoriser('webmestre', null, null, $qui, $opt);
679 679
 }
680 680
 
681 681
 /**
@@ -692,12 +692,12 @@  discard block
 block discarded – undo
692 692
  * @return bool          true s'il a le droit, false sinon
693 693
 **/
694 694
 function autoriser_auteur_previsualiser_dist($faire, $type, $id, $qui, $opt) {
695
-	// les admins peuvent "previsualiser" une page auteur
696
-	if ($qui['statut'] == '0minirezo'
697
-		AND !$qui['restreint']) return true;
698
-	// "Voir en ligne" si l'auteur a un article publie
699
-	$n = sql_fetsel('A.id_article', 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', "A.statut='publie' AND L.id_auteur=".sql_quote($id));
700
-	return $n ? true : false;
695
+    // les admins peuvent "previsualiser" une page auteur
696
+    if ($qui['statut'] == '0minirezo'
697
+        AND !$qui['restreint']) return true;
698
+    // "Voir en ligne" si l'auteur a un article publie
699
+    $n = sql_fetsel('A.id_article', 'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)', "A.statut='publie' AND L.id_auteur=".sql_quote($id));
700
+    return $n ? true : false;
701 701
 }
702 702
 
703 703
 /**
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
  * @return bool          true s'il a le droit, false sinon
725 725
 **/
726 726
 function autoriser_auteur_creer_dist($faire, $type, $id, $qui, $opt) {
727
-	return ($qui['statut'] == '0minirezo');
727
+    return ($qui['statut'] == '0minirezo');
728 728
 }
729 729
 
730 730
 
@@ -744,63 +744,63 @@  discard block
 block discarded – undo
744 744
 **/
745 745
 function autoriser_auteur_modifier_dist($faire, $type, $id, $qui, $opt) {
746 746
 
747
-	// Ni admin ni redacteur => non
748
-	if (!in_array($qui['statut'], array('0minirezo', '1comite')))
749
-		return false;
750
-
751
-	// Un redacteur peut modifier ses propres donnees mais ni son login/email
752
-	// ni son statut (qui sont le cas echeant passes comme option)
753
-	if ($qui['statut'] == '1comite') {
754
-		if ($opt['webmestre'])
755
-			return false;
756
-		elseif ($opt['statut'] OR $opt['restreintes'] OR $opt['email'])
757
-			return false;
758
-		elseif ($id == $qui['id_auteur'])
759
-			return true;
760
-		else
761
-			return false;
762
-	}
763
-
764
-	// Un admin restreint peut modifier/creer un auteur non-admin mais il
765
-	// n'a le droit ni de le promouvoir admin, ni de changer les rubriques
766
-	if ($qui['restreint']) {
767
-		if ($opt['webmestre'])
768
-			return false;
769
-		elseif ($opt['statut'] == '0minirezo' OR $opt['restreintes'])
770
-			return false;
771
-		else {
772
-			if ($id == $qui['id_auteur']) {
773
-				if ($opt['statut'])
774
-					return false;
775
-				else
776
-					return true;
777
-			}
778
-			else if ($id_auteur = intval($id)) {
779
-				$t = sql_fetsel("statut", "spip_auteurs", "id_auteur=$id_auteur");
780
-				if ($t AND $t['statut'] != '0minirezo')
781
-					return true;
782
-				else
783
-					return false;
784
-			}
785
-			// id = 0 => creation
786
-			else
787
-				return true;
788
-		}
789
-	}
790
-
791
-	// Un admin complet fait ce qu'elle veut
792
-	// sauf se degrader
793
-	if ($id == $qui['id_auteur'] && $opt['statut'])
794
-		return false;
795
-	// et toucher au statut webmestre si il ne l'est pas lui meme
796
-	// ou si les webmestres sont fixes par constante (securite)
797
-	elseif (isset($opt['webmestre']) AND $opt['webmestre'] AND (defined('_ID_WEBMESTRES') OR !autoriser('webmestre')))
798
-		return false;
799
-	// et modifier un webmestre si il ne l'est pas lui meme
800
-	elseif (intval($id) AND autoriser('webmestre','',0,$id) AND !autoriser('webmestre'))
801
-		return false;
802
-	else
803
-		return true;
747
+    // Ni admin ni redacteur => non
748
+    if (!in_array($qui['statut'], array('0minirezo', '1comite')))
749
+        return false;
750
+
751
+    // Un redacteur peut modifier ses propres donnees mais ni son login/email
752
+    // ni son statut (qui sont le cas echeant passes comme option)
753
+    if ($qui['statut'] == '1comite') {
754
+        if ($opt['webmestre'])
755
+            return false;
756
+        elseif ($opt['statut'] OR $opt['restreintes'] OR $opt['email'])
757
+            return false;
758
+        elseif ($id == $qui['id_auteur'])
759
+            return true;
760
+        else
761
+            return false;
762
+    }
763
+
764
+    // Un admin restreint peut modifier/creer un auteur non-admin mais il
765
+    // n'a le droit ni de le promouvoir admin, ni de changer les rubriques
766
+    if ($qui['restreint']) {
767
+        if ($opt['webmestre'])
768
+            return false;
769
+        elseif ($opt['statut'] == '0minirezo' OR $opt['restreintes'])
770
+            return false;
771
+        else {
772
+            if ($id == $qui['id_auteur']) {
773
+                if ($opt['statut'])
774
+                    return false;
775
+                else
776
+                    return true;
777
+            }
778
+            else if ($id_auteur = intval($id)) {
779
+                $t = sql_fetsel("statut", "spip_auteurs", "id_auteur=$id_auteur");
780
+                if ($t AND $t['statut'] != '0minirezo')
781
+                    return true;
782
+                else
783
+                    return false;
784
+            }
785
+            // id = 0 => creation
786
+            else
787
+                return true;
788
+        }
789
+    }
790
+
791
+    // Un admin complet fait ce qu'elle veut
792
+    // sauf se degrader
793
+    if ($id == $qui['id_auteur'] && $opt['statut'])
794
+        return false;
795
+    // et toucher au statut webmestre si il ne l'est pas lui meme
796
+    // ou si les webmestres sont fixes par constante (securite)
797
+    elseif (isset($opt['webmestre']) AND $opt['webmestre'] AND (defined('_ID_WEBMESTRES') OR !autoriser('webmestre')))
798
+        return false;
799
+    // et modifier un webmestre si il ne l'est pas lui meme
800
+    elseif (intval($id) AND autoriser('webmestre','',0,$id) AND !autoriser('webmestre'))
801
+        return false;
802
+    else
803
+        return true;
804 804
 }
805 805
 
806 806
 
@@ -817,7 +817,7 @@  discard block
 block discarded – undo
817 817
  * @return bool          true s'il a le droit, false sinon
818 818
 **/
819 819
 function autoriser_associerauteurs_dist($faire, $type, $id, $qui, $opt){
820
-	return autoriser('modifier', $type, $id, $qui, $opt);
820
+    return autoriser('modifier', $type, $id, $qui, $opt);
821 821
 }
822 822
 
823 823
 
@@ -834,7 +834,7 @@  discard block
 block discarded – undo
834 834
  * @return bool          true s'il a le droit, false sinon
835 835
 **/
836 836
 function autoriser_chargerftp_dist($faire, $type, $id, $qui, $opt) {
837
-	return $qui['statut'] == '0minirezo';
837
+    return $qui['statut'] == '0minirezo';
838 838
 }
839 839
 
840 840
 /**
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
  * @return bool          true s'il a le droit, false sinon
851 851
 **/
852 852
 function autoriser_debug_dist($faire, $type, $id, $qui, $opt) {
853
-	return $qui['statut'] == '0minirezo';
853
+    return $qui['statut'] == '0minirezo';
854 854
 }
855 855
 
856 856
 /**
@@ -867,40 +867,40 @@  discard block
 block discarded – undo
867 867
  * @return array          Liste des rubriques
868 868
 **/
869 869
 function liste_rubriques_auteur($id_auteur, $raz=false) {
870
-	static $restreint = array();
871
-
872
-	if (!$id_auteur = intval($id_auteur)) return array();
873
-	if ($raz) unset($restreint[$id_auteur]);
874
-	elseif (isset($restreint[$id_auteur])) return $restreint[$id_auteur];
875
-
876
-	$rubriques = array();
877
-	if (
878
-		(!isset($GLOBALS['meta']['version_installee']) OR $GLOBALS['meta']['version_installee']>16428)
879
-	  AND $r = sql_allfetsel('id_objet', 'spip_auteurs_liens', "id_auteur=".intval($id_auteur)." AND objet='rubrique' AND id_objet!=0")
880
-	  AND count($r)) {
881
-		$r = array_map('reset',$r);
882
-
883
-		// recuperer toute la branche, au format chaine enumeration
884
-		include_spip('inc/rubriques');
885
-		$r = calcul_branche_in($r);
886
-		$r = explode(',',$r);
887
-
888
-		// passer les rubriques en index, elimine les doublons
889
-		$r = array_flip($r);
890
-		// recuperer les index seuls
891
-		$r = array_keys($r);
892
-		// combiner pour avoir un tableau id_rubrique=>id_rubrique
893
-		// est-ce vraiment utile ? (on preserve la forme donnee par le code precedent)
894
-		$rubriques = array_combine($r,$r);
895
-	}
896
-
897
-	// Affecter l'auteur session le cas echeant
898
-	if (isset($GLOBALS['visiteur_session']['id_auteur'])
899
-	  AND $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur)
900
-		$GLOBALS['visiteur_session']['restreint'] = $rubriques;
901
-
902
-
903
-	return $restreint[$id_auteur] = $rubriques;
870
+    static $restreint = array();
871
+
872
+    if (!$id_auteur = intval($id_auteur)) return array();
873
+    if ($raz) unset($restreint[$id_auteur]);
874
+    elseif (isset($restreint[$id_auteur])) return $restreint[$id_auteur];
875
+
876
+    $rubriques = array();
877
+    if (
878
+        (!isset($GLOBALS['meta']['version_installee']) OR $GLOBALS['meta']['version_installee']>16428)
879
+      AND $r = sql_allfetsel('id_objet', 'spip_auteurs_liens', "id_auteur=".intval($id_auteur)." AND objet='rubrique' AND id_objet!=0")
880
+      AND count($r)) {
881
+        $r = array_map('reset',$r);
882
+
883
+        // recuperer toute la branche, au format chaine enumeration
884
+        include_spip('inc/rubriques');
885
+        $r = calcul_branche_in($r);
886
+        $r = explode(',',$r);
887
+
888
+        // passer les rubriques en index, elimine les doublons
889
+        $r = array_flip($r);
890
+        // recuperer les index seuls
891
+        $r = array_keys($r);
892
+        // combiner pour avoir un tableau id_rubrique=>id_rubrique
893
+        // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent)
894
+        $rubriques = array_combine($r,$r);
895
+    }
896
+
897
+    // Affecter l'auteur session le cas echeant
898
+    if (isset($GLOBALS['visiteur_session']['id_auteur'])
899
+      AND $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur)
900
+        $GLOBALS['visiteur_session']['restreint'] = $rubriques;
901
+
902
+
903
+    return $restreint[$id_auteur] = $rubriques;
904 904
 }
905 905
 
906 906
 /**
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
  * @return bool          true s'il a le droit, false sinon
917 917
 **/
918 918
 function autoriser_modifierurl_dist($faire, $type, $id, $qui, $opt) {
919
-	return autoriser('modifier', $type, $id, $qui, $opt);
919
+    return autoriser('modifier', $type, $id, $qui, $opt);
920 920
 }
921 921
 
922 922
 /**
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
  * @return bool          true s'il a le droit, false sinon
933 933
 **/
934 934
 function autoriser_rubrique_previsualiser_dist($faire,$type,$id,$qui,$opt){
935
-	return autoriser('previsualiser');
935
+    return autoriser('previsualiser');
936 936
 }
937 937
 
938 938
 /**
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
  * @return bool          true s'il a le droit, false sinon
949 949
 **/
950 950
 function autoriser_rubrique_iconifier_dist($faire,$type,$id,$qui,$opt){
951
-	return autoriser('publierdans', 'rubrique', $id, $qui, $opt);
951
+    return autoriser('publierdans', 'rubrique', $id, $qui, $opt);
952 952
 }
953 953
 
954 954
 /**
@@ -964,8 +964,8 @@  discard block
 block discarded – undo
964 964
  * @return bool          true s'il a le droit, false sinon
965 965
 **/
966 966
 function autoriser_auteur_iconifier_dist($faire,$type,$id,$qui,$opt){
967
- return (($id == $qui['id_auteur']) OR
968
- 		(($qui['statut'] == '0minirezo') AND !$qui['restreint']));
967
+    return (($id == $qui['id_auteur']) OR
968
+         (($qui['statut'] == '0minirezo') AND !$qui['restreint']));
969 969
 }
970 970
 
971 971
 /**
@@ -981,8 +981,8 @@  discard block
 block discarded – undo
981 981
  * @return bool          true s'il a le droit, false sinon
982 982
 **/
983 983
 function autoriser_iconifier_dist($faire,$type,$id,$qui,$opt){
984
-	// par defaut, on a le droit d'iconifier si on a le droit de modifier
985
-	return autoriser('modifier', $type, $id, $qui, $opt);
984
+    // par defaut, on a le droit d'iconifier si on a le droit de modifier
985
+    return autoriser('modifier', $type, $id, $qui, $opt);
986 986
 }
987 987
 
988 988
 
@@ -1029,10 +1029,10 @@  discard block
 block discarded – undo
1029 1029
  * @return bool          false
1030 1030
 **/
1031 1031
 function autoriser_base_reparer_dist($faire, $type, $id, $qui, $opt) {
1032
-	if (!autoriser('detruire') OR _request('reinstall'))
1033
-		return false;
1032
+    if (!autoriser('detruire') OR _request('reinstall'))
1033
+        return false;
1034 1034
 
1035
-	return true;
1035
+    return true;
1036 1036
 }
1037 1037
 
1038 1038
 /**
@@ -1048,7 +1048,7 @@  discard block
 block discarded – undo
1048 1048
  * @return bool          true s'il a le droit, false sinon
1049 1049
 **/
1050 1050
 function autoriser_infosperso_dist($faire,$type,$id,$qui,$opt) {
1051
-	return true;
1051
+    return true;
1052 1052
 }
1053 1053
 
1054 1054
 /**
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
  * @return bool          true s'il a le droit, false sinon
1065 1065
 **/
1066 1066
 function autoriser_langage_configurer_dist($faire,$type,$id,$qui,$opt) {
1067
-	return true;
1067
+    return true;
1068 1068
 }
1069 1069
 
1070 1070
 /**
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
  * @return bool          true s'il a le droit, false sinon
1081 1081
 **/
1082 1082
 function autoriser_configurerlangage_dist($faire,$type,$id,$qui,$opt) {
1083
-	return autoriser('configurer', '_langage', $id, $qui, $opt);
1083
+    return autoriser('configurer', '_langage', $id, $qui, $opt);
1084 1084
 }
1085 1085
 
1086 1086
 /**
@@ -1096,7 +1096,7 @@  discard block
 block discarded – undo
1096 1096
  * @return bool          true s'il a le droit, false sinon
1097 1097
 **/
1098 1098
 function autoriser_preferences_configurer_dist($faire,$type,$id,$qui,$opt) {
1099
-	return true;
1099
+    return true;
1100 1100
 }
1101 1101
 
1102 1102
 /**
@@ -1112,7 +1112,7 @@  discard block
 block discarded – undo
1112 1112
  * @return bool          true s'il a le droit, false sinon
1113 1113
 **/
1114 1114
 function autoriser_configurerpreferences_dist($faire,$type,$id,$qui,$opt) {
1115
-	return autoriser('configurer', '_preferences', $id, $qui, $opt);
1115
+    return autoriser('configurer', '_preferences', $id, $qui, $opt);
1116 1116
 }
1117 1117
 
1118 1118
 /**
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
  * @return bool          true s'il a le droit, false sinon
1171 1171
 **/
1172 1172
 function autoriser_articlecreer_menu_dist($faire, $type, $id, $qui, $opt){
1173
-	return verifier_table_non_vide();
1173
+    return verifier_table_non_vide();
1174 1174
 }
1175 1175
 
1176 1176
 /**
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
  * @return bool          true s'il a le droit, false sinon
1189 1189
 **/
1190 1190
 function autoriser_auteurcreer_menu_dist($faire, $type, $id, $qui, $opt) {
1191
-	return autoriser('creer', 'auteur', $id, $qui, $opt);
1191
+    return autoriser('creer', 'auteur', $id, $qui, $opt);
1192 1192
 }
1193 1193
 
1194 1194
 /**
@@ -1204,7 +1204,7 @@  discard block
 block discarded – undo
1204 1204
  * @return bool          true s'il a le droit, false sinon
1205 1205
 **/
1206 1206
 function autoriser_suiviedito_menu_dist($faire, $type, $id, $qui, $opt){
1207
-	return $qui['statut']=='0minirezo';
1207
+    return $qui['statut']=='0minirezo';
1208 1208
 }
1209 1209
 
1210 1210
 /**
@@ -1220,7 +1220,7 @@  discard block
 block discarded – undo
1220 1220
  * @return bool          true s'il a le droit, false sinon
1221 1221
 **/
1222 1222
 function autoriser_synchro_menu_dist($faire, $type, $id, $qui, $opt){
1223
-	return $qui['statut']=='0minirezo';
1223
+    return $qui['statut']=='0minirezo';
1224 1224
 }
1225 1225
 
1226 1226
 /**
@@ -1236,7 +1236,7 @@  discard block
 block discarded – undo
1236 1236
  * @return bool          true s'il a le droit, false sinon
1237 1237
 **/
1238 1238
 function autoriser_queue_purger_dist($faire, $type, $id, $qui, $opt){
1239
-	return autoriser('webmestre');
1239
+    return autoriser('webmestre');
1240 1240
 }
1241 1241
 
1242 1242
 
@@ -1254,10 +1254,10 @@  discard block
 block discarded – undo
1254 1254
  * @return bool          true s'il a le droit, false sinon
1255 1255
 **/
1256 1256
 function autoriser_echafauder_dist($faire, $type, $id, $qui, $opt){
1257
-	if (test_espace_prive())
1258
-		return intval($qui['id_auteur'])?true:false;
1259
-	else
1260
-		return autoriser('webmestre','',$id,$qui,$opt);
1257
+    if (test_espace_prive())
1258
+        return intval($qui['id_auteur'])?true:false;
1259
+    else
1260
+        return autoriser('webmestre','',$id,$qui,$opt);
1261 1261
 }
1262 1262
 
1263 1263
 
@@ -1274,7 +1274,7 @@  discard block
 block discarded – undo
1274 1274
  */
1275 1275
 function auteurs_article($id_article, $cond='')
1276 1276
 {
1277
-	return sql_allfetsel("id_auteur", "spip_auteurs_liens", "objet='article' AND id_objet=$id_article". ($cond ? " AND $cond" : ''));
1277
+    return sql_allfetsel("id_auteur", "spip_auteurs_liens", "objet='article' AND id_objet=$id_article". ($cond ? " AND $cond" : ''));
1278 1278
 }
1279 1279
 
1280 1280
 
@@ -1287,9 +1287,9 @@  discard block
 block discarded – undo
1287 1287
  * @return bool             true si administrateur de cette rubrique, false sinon.
1288 1288
  */
1289 1289
 function acces_restreint_rubrique($id_rubrique) {
1290
-	global $connect_id_rubrique;
1290
+    global $connect_id_rubrique;
1291 1291
 
1292
-	return (isset($connect_id_rubrique[$id_rubrique]));
1292
+    return (isset($connect_id_rubrique[$id_rubrique]));
1293 1293
 }
1294 1294
 
1295 1295
 
@@ -1302,10 +1302,10 @@  discard block
 block discarded – undo
1302 1302
  * @return bool             true si un parent existe
1303 1303
  */
1304 1304
 function verifier_table_non_vide($table='spip_rubriques') {
1305
-	static $done = array();
1306
-	if (!isset($done[$table]))
1307
-		 $done[$table] = sql_countsel($table)>0;
1308
-	return $done[$table];
1305
+    static $done = array();
1306
+    if (!isset($done[$table]))
1307
+            $done[$table] = sql_countsel($table)>0;
1308
+    return $done[$table];
1309 1309
 }
1310 1310
 
1311 1311
 /**
@@ -1326,17 +1326,17 @@  discard block
 block discarded – undo
1326 1326
  */
1327 1327
 function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt){
1328 1328
 
1329
-	$s = array_search($quoi, $GLOBALS['liste_des_statuts']);
1330
-	switch ($s) {
1329
+    $s = array_search($quoi, $GLOBALS['liste_des_statuts']);
1330
+    switch ($s) {
1331 1331
 
1332
-		case 'info_redacteurs' :
1333
-		  return ($GLOBALS['meta']['accepter_inscriptions'] == 'oui');
1332
+        case 'info_redacteurs' :
1333
+          return ($GLOBALS['meta']['accepter_inscriptions'] == 'oui');
1334 1334
 
1335
-		case 'info_visiteurs' :
1336
-		  return ($GLOBALS['meta']['accepter_visiteurs'] == 'oui' OR $GLOBALS['meta']['forums_publics'] == 'abo');
1335
+        case 'info_visiteurs' :
1336
+          return ($GLOBALS['meta']['accepter_visiteurs'] == 'oui' OR $GLOBALS['meta']['forums_publics'] == 'abo');
1337 1337
 
1338
-	}
1338
+    }
1339 1339
 
1340
-	return false;
1340
+    return false;
1341 1341
 }
1342 1342
 ?>
Please login to merge, or discard this patch.
ecrire/inc/selectionner.php 1 patch
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -21,106 +21,106 @@
 block discarded – undo
21 21
 // http://doc.spip.org/@inc_selectionner_dist
22 22
 function inc_selectionner_dist ($sel, $idom="", $exclus=0, $aff_racine=false, $recur=true, $do='aff') {
23 23
 
24
-	if ($recur) $recur = mini_hier($sel); else $sel = 0;
25
-
26
-	if ($aff_racine) {
27
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
28
-		$idom3 = $idom . "_selection";
29
-
30
-		$onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
31
-
32
-		$ondbClick = strtr(str_replace("'", "&#8217;",
33
-				str_replace('"', "&#34;",
34
-					textebrut(_T('info_racine_site')))),
35
-				"\n\r", "  ");
36
-
37
-		$js_func = $do . '_selection_titre';
38
-		$ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
39
-
40
-		$aff_racine = "<div class='petite-racine item'>"
41
-		. "<a href='#'"
42
-			. "onclick=\""
43
-			. $onClick
44
-			. "\"\nondbclick=\""
45
-			. $ondbClick
46
-			. $onClick
47
-		. "\">"
48
-		. _T("info_racine_site")
49
-		. "</a></div>";
50
-	}
51
-
52
-	$url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
53
-
54
-	$plonger = charger_fonction('plonger', 'inc');
55
-	$plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
56
-
57
-	// url completee par la fonction JS onkeypress_rechercher
58
-	$url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
59
-	return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
24
+    if ($recur) $recur = mini_hier($sel); else $sel = 0;
25
+
26
+    if ($aff_racine) {
27
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
28
+        $idom3 = $idom . "_selection";
29
+
30
+        $onClick = "jQuery(this).parent().addClass('on');jQuery('#choix_parent_principal .on').removeClass('on'); aff_selection(0, '$idom3', '$info', event);return false;";
31
+
32
+        $ondbClick = strtr(str_replace("'", "&#8217;",
33
+                str_replace('"', "&#34;",
34
+                    textebrut(_T('info_racine_site')))),
35
+                "\n\r", "  ");
36
+
37
+        $js_func = $do . '_selection_titre';
38
+        $ondbClick = "$js_func('$ondbClick',0,'selection_rubrique','id_parent');";
39
+
40
+        $aff_racine = "<div class='petite-racine item'>"
41
+        . "<a href='#'"
42
+            . "onclick=\""
43
+            . $onClick
44
+            . "\"\nondbclick=\""
45
+            . $ondbClick
46
+            . $onClick
47
+        . "\">"
48
+        . _T("info_racine_site")
49
+        . "</a></div>";
50
+    }
51
+
52
+    $url_init = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclus&id=0&col=1&do=$do");
53
+
54
+    $plonger = charger_fonction('plonger', 'inc');
55
+    $plonger_r = $plonger($sel, $idom, $recur, 1, $exclus, $do);
56
+
57
+    // url completee par la fonction JS onkeypress_rechercher
58
+    $url = generer_url_ecrire('rechercher', "exclus=$exclus&rac=$idom&do=$do&type=");
59
+    return construire_selectionner_hierarchie($idom, $plonger_r, $aff_racine, $url, 'id_parent', $url_init);
60 60
 }
61 61
 
62 62
 // http://doc.spip.org/@construire_selectionner_hierarchie
63 63
 function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init='')
64 64
 {
65
-	global $spip_lang_right;
66
-
67
-	$idom1 = $idom . "_champ_recherche";
68
-	$idom2 = $idom . "_principal";
69
-	$idom3 = $idom . "_selection";
70
-	$idom4 = $idom . "_col_1";
71
-	$idom5 = 'img_' . $idom4;
72
-	$idom6 = $idom."_fonc";
73
-
74
-	return "<div id='$idom'>"
75
-	. "<a id='$idom6' style='visibility: hidden;'"
76
-	. ($url_init ?  "\nhref='$url_init'" : '')
77
-	. "></a>"
78
-	. "<div class='recherche_rapide_parent'>"
79
-	. http_img_pack("searching.gif", "*", "style='visibility: hidden;float:$spip_lang_right' id='$idom5'")
80
-	. ""
81
-	. "<input style='width: 100px;float:$spip_lang_right;' type='search' id='$idom1'"
82
-	  // eliminer Return car il provoque la soumission (balise unique)
83
-	  // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
84
-	  // resultats retournes par la recherche
85
-	. "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3){return false;}\""
86
-	  // lancer la recherche apres le filtrage ci-dessus
87
-	. "\nonkeyup=\"return onkey_rechercher(this.value,"
88
-	  // la destination de la recherche
89
-	. "'$idom4'"
65
+    global $spip_lang_right;
66
+
67
+    $idom1 = $idom . "_champ_recherche";
68
+    $idom2 = $idom . "_principal";
69
+    $idom3 = $idom . "_selection";
70
+    $idom4 = $idom . "_col_1";
71
+    $idom5 = 'img_' . $idom4;
72
+    $idom6 = $idom."_fonc";
73
+
74
+    return "<div id='$idom'>"
75
+    . "<a id='$idom6' style='visibility: hidden;'"
76
+    . ($url_init ?  "\nhref='$url_init'" : '')
77
+    . "></a>"
78
+    . "<div class='recherche_rapide_parent'>"
79
+    . http_img_pack("searching.gif", "*", "style='visibility: hidden;float:$spip_lang_right' id='$idom5'")
80
+    . ""
81
+    . "<input style='width: 100px;float:$spip_lang_right;' type='search' id='$idom1'"
82
+        // eliminer Return car il provoque la soumission (balise unique)
83
+        // ce serait encore mieux de ne le faire que s'il y a encore plusieurs
84
+        // resultats retournes par la recherche
85
+    . "\nonkeypress=\"k=event.keyCode;if (k==13 || k==3){return false;}\""
86
+        // lancer la recherche apres le filtrage ci-dessus
87
+    . "\nonkeyup=\"return onkey_rechercher(this.value,"
88
+        // la destination de la recherche
89
+    . "'$idom4'"
90 90
 #	. "this.parentNode.parentNode.parentNode.parentNode.nextSibling.firstChild.id"
91
-	. ",'"
92
-	  // l'url effectuant la recherche
93
-	. $url
94
-	. "',"	
95
-	  // le noeud contenant un gif anime 
96
-	  // . "'idom5'"
97
-	. "this.parentNode.previousSibling.firstChild"
98
-	. ",'"
99
-	  // la valeur de l'attribut Name a remplir
100
-	.  $name
101
-	. "','"
102
-	  // noeud invisible memorisant l'URL initiale (pour re-initialisation)
103
-	. $idom6
104
-	. "')\"" 
105
-	. " />"
106
-	. "\n</div>"
107
-	. ($racine?"<div>$racine</div>":"")
108
-	. "<div id='"
109
-	.  $idom2
110
-	.  "'><div id='$idom4'"
111
-	. " class=''>"
112
-	. $liste
113
-	. "</div></div>\n<div id='$idom3'></div></div>\n";
91
+    . ",'"
92
+        // l'url effectuant la recherche
93
+    . $url
94
+    . "',"	
95
+        // le noeud contenant un gif anime 
96
+        // . "'idom5'"
97
+    . "this.parentNode.previousSibling.firstChild"
98
+    . ",'"
99
+        // la valeur de l'attribut Name a remplir
100
+    .  $name
101
+    . "','"
102
+        // noeud invisible memorisant l'URL initiale (pour re-initialisation)
103
+    . $idom6
104
+    . "')\"" 
105
+    . " />"
106
+    . "\n</div>"
107
+    . ($racine?"<div>$racine</div>":"")
108
+    . "<div id='"
109
+    .  $idom2
110
+    .  "'><div id='$idom4'"
111
+    . " class=''>"
112
+    . $liste
113
+    . "</div></div>\n<div id='$idom3'></div></div>\n";
114 114
 }
115 115
 
116 116
 // http://doc.spip.org/@mini_hier
117 117
 function mini_hier ($id_rubrique) {
118 118
 	
119
-	$liste = $id_rubrique;
120
-	$id_rubrique = intval($id_rubrique);
121
-	while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique))
122
-		$liste = $id_rubrique . ",$liste";
123
-	return explode(',',"0,$liste");
119
+    $liste = $id_rubrique;
120
+    $id_rubrique = intval($id_rubrique);
121
+    while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique))
122
+        $liste = $id_rubrique . ",$liste";
123
+    return explode(',',"0,$liste");
124 124
 }
125 125
 
126 126
 ?>
Please login to merge, or discard this patch.
ecrire/inc/boutons.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -18,24 +18,24 @@  discard block
 block discarded – undo
18 18
  */
19 19
 // http://doc.spip.org/@Bouton
20 20
 class Bouton {
21
-  var $icone;         /* l'icone a mettre dans le bouton */
22
-  var $libelle;       /* le nom de l'entree d'i18n associe */
23
-  var $url= null;     /* l'url de la page (null => ?exec=nom) */
24
-  var $urlArg= null;  /* arguments supplementaires de l'url */
25
-  var $url2= null;    /* url jscript */
26
-  var $target= null;  /* pour ouvrir dans une fenetre a part */
27
-  var $sousmenu= null;/* sous barre de boutons / onglets */
21
+    var $icone;         /* l'icone a mettre dans le bouton */
22
+    var $libelle;       /* le nom de l'entree d'i18n associe */
23
+    var $url= null;     /* l'url de la page (null => ?exec=nom) */
24
+    var $urlArg= null;  /* arguments supplementaires de l'url */
25
+    var $url2= null;    /* url jscript */
26
+    var $target= null;  /* pour ouvrir dans une fenetre a part */
27
+    var $sousmenu= null;/* sous barre de boutons / onglets */
28 28
 
29 29
 // http://doc.spip.org/@Bouton
30
-  function Bouton($icone, $libelle, $url=null, $urlArg=null,
31
-				  $url2=null, $target=null) {
32
-	$this->icone  = $icone;
33
-	$this->libelle= $libelle;
34
-	$this->url    = $url;
35
-	$this->urlArg = $urlArg;
36
-	$this->url2   = $url2;
37
-	$this->target = $target;
38
-  }
30
+    function Bouton($icone, $libelle, $url=null, $urlArg=null,
31
+                    $url2=null, $target=null) {
32
+    $this->icone  = $icone;
33
+    $this->libelle= $libelle;
34
+    $this->url    = $url;
35
+    $this->urlArg = $urlArg;
36
+    $this->url2   = $url2;
37
+    $this->target = $target;
38
+    }
39 39
 }
40 40
 
41 41
 
@@ -46,44 +46,44 @@  discard block
 block discarded – undo
46 46
 // http://doc.spip.org/@definir_barre_onglets
47 47
 function definir_barre_onglets($script) {
48 48
 
49
-	$onglets=array();
50
-	$liste_onglets = array();
51
-
52
-	// ajouter les onglets issus des plugin via plugin.xml
53
-	if (function_exists('onglets_plugins'))
54
-		$liste_onglets = onglets_plugins();
55
-
56
-
57
-	foreach($liste_onglets as $id => $infos){
58
-		if (($parent = $infos['parent'])
59
-			&& $parent == $script
60
-			&& autoriser('onglet',"_$id")) {
61
-				$onglets[$id] = new Bouton(
62
-					find_in_theme($infos['icone']),  // icone
63
-					$infos['titre'],	// titre
64
-					(isset($infos['action']) and $infos['action'])
65
-						? generer_url_ecrire($infos['action'],(isset($infos['parametres']) AND $infos['parametres'])?$infos['parametres']:'')
66
-						: null
67
-					);
68
-		}
69
-	}
70
-
71
-	return pipeline('ajouter_onglets', array('data'=>$onglets,'args'=>$script));
49
+    $onglets=array();
50
+    $liste_onglets = array();
51
+
52
+    // ajouter les onglets issus des plugin via plugin.xml
53
+    if (function_exists('onglets_plugins'))
54
+        $liste_onglets = onglets_plugins();
55
+
56
+
57
+    foreach($liste_onglets as $id => $infos){
58
+        if (($parent = $infos['parent'])
59
+            && $parent == $script
60
+            && autoriser('onglet',"_$id")) {
61
+                $onglets[$id] = new Bouton(
62
+                    find_in_theme($infos['icone']),  // icone
63
+                    $infos['titre'],	// titre
64
+                    (isset($infos['action']) and $infos['action'])
65
+                        ? generer_url_ecrire($infos['action'],(isset($infos['parametres']) AND $infos['parametres'])?$infos['parametres']:'')
66
+                        : null
67
+                    );
68
+        }
69
+    }
70
+
71
+    return pipeline('ajouter_onglets', array('data'=>$onglets,'args'=>$script));
72 72
 }
73 73
 
74 74
 
75 75
 // http://doc.spip.org/@barre_onglets
76 76
 function barre_onglets($rubrique, $ongletCourant, $class="barre_onglet"){
77
-	include_spip('inc/presentation');
77
+    include_spip('inc/presentation');
78 78
 
79
-	$res = '';
79
+    $res = '';
80 80
 
81
-	foreach(definir_barre_onglets($rubrique) as $exec => $onglet) {
82
-		$url= $onglet->url ? $onglet->url : generer_url_ecrire($exec);
83
-		$res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
84
-	}
81
+    foreach(definir_barre_onglets($rubrique) as $exec => $onglet) {
82
+        $url= $onglet->url ? $onglet->url : generer_url_ecrire($exec);
83
+        $res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
84
+    }
85 85
 
86
-	return  !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
86
+    return  !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
87 87
 }
88 88
 
89 89
 
Please login to merge, or discard this patch.
ecrire/balise/info_.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,22 +19,22 @@
 block discarded – undo
19 19
  * 
20 20
  */
21 21
 function balise_INFO__dist($p){
22
-	$info = $p->nom_champ;
23
-	$type_objet = interprete_argument_balise(1,$p);
24
-	$id_objet = interprete_argument_balise(2,$p);
25
-	if ($info === 'INFO_' or !$type_objet or !$id_objet) {
26
-		$msg = _T('zbug_balise_sans_argument', array('balise' => ' INFO_'));
27
-		erreur_squelette($msg, $p);
28
-		$p->interdire_scripts = true;
29
-		return $p;
30
-	}
31
-	else {
32
-		$info_sql = strtolower(substr($info,5));
33
-		$code = "generer_info_entite($id_objet, $type_objet, '$info_sql'".($p->etoile?","._q($p->etoile):"").")";
34
-		$p->code = champ_sql($info, $p, $code);
35
-		$p->interdire_scripts = true;
36
-		return $p;
37
-	}
22
+    $info = $p->nom_champ;
23
+    $type_objet = interprete_argument_balise(1,$p);
24
+    $id_objet = interprete_argument_balise(2,$p);
25
+    if ($info === 'INFO_' or !$type_objet or !$id_objet) {
26
+        $msg = _T('zbug_balise_sans_argument', array('balise' => ' INFO_'));
27
+        erreur_squelette($msg, $p);
28
+        $p->interdire_scripts = true;
29
+        return $p;
30
+    }
31
+    else {
32
+        $info_sql = strtolower(substr($info,5));
33
+        $code = "generer_info_entite($id_objet, $type_objet, '$info_sql'".($p->etoile?","._q($p->etoile):"").")";
34
+        $p->code = champ_sql($info, $p, $code);
35
+        $p->interdire_scripts = true;
36
+        return $p;
37
+    }
38 38
 }
39 39
 
40 40
 ?>
Please login to merge, or discard this patch.