Completed
Push — master ( ab9620...37f24f )
by cam
09:07 queued 05:07
created
ecrire/inc/urls.php 1 patch
Indentation   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  **/
19 19
 
20 20
 if (!defined('_ECRIRE_INC_VERSION')) {
21
-	return;
21
+    return;
22 22
 }
23 23
 include_spip('base/objets');
24 24
 
@@ -58,114 +58,114 @@  discard block
 block discarded – undo
58 58
  *
59 59
  */
60 60
 function urls_decoder_url($url, $fond = '', $contexte = array(), $assembler = false) {
61
-	static $current_base = null;
61
+    static $current_base = null;
62 62
 
63
-	// les anciennes fonctions modifient directement les globales
64
-	// on les sauve avant l'appel, et on les retablit apres !
65
-	$save = array(
66
-		isset($GLOBALS['fond']) ? $GLOBALS['fond'] : null,
67
-		isset($GLOBALS['contexte']) ? $GLOBALS['contexte'] : null,
68
-		isset($_SERVER['REDIRECT_url_propre']) ? $_SERVER['REDIRECT_url_propre'] : null,
69
-		isset($_ENV['url_propre']) ? $_ENV['url_propre'] : null,
70
-		$GLOBALS['profondeur_url']
71
-	);
63
+    // les anciennes fonctions modifient directement les globales
64
+    // on les sauve avant l'appel, et on les retablit apres !
65
+    $save = array(
66
+        isset($GLOBALS['fond']) ? $GLOBALS['fond'] : null,
67
+        isset($GLOBALS['contexte']) ? $GLOBALS['contexte'] : null,
68
+        isset($_SERVER['REDIRECT_url_propre']) ? $_SERVER['REDIRECT_url_propre'] : null,
69
+        isset($_ENV['url_propre']) ? $_ENV['url_propre'] : null,
70
+        $GLOBALS['profondeur_url']
71
+    );
72 72
 
73
-	if (is_null($current_base)) {
74
-		include_spip('inc/filtres_mini');
75
-		// le decodage des urls se fait toujours par rapport au site public
76
-		$current_base = url_absolue(_DIR_RACINE ? _DIR_RACINE : './');
77
-	}
78
-	if (strncmp($url, $current_base, strlen($current_base)) == 0) {
79
-		$url = substr($url, strlen($current_base));
80
-	}
73
+    if (is_null($current_base)) {
74
+        include_spip('inc/filtres_mini');
75
+        // le decodage des urls se fait toujours par rapport au site public
76
+        $current_base = url_absolue(_DIR_RACINE ? _DIR_RACINE : './');
77
+    }
78
+    if (strncmp($url, $current_base, strlen($current_base)) == 0) {
79
+        $url = substr($url, strlen($current_base));
80
+    }
81 81
 
82
-	// si on est en train d'assembler la page principale,
83
-	// recuperer l'url depuis les globales url propres si fournies
84
-	// sinon extraire la bonne portion d'url
85
-	if ($assembler) {
86
-		if (isset($_SERVER['REDIRECT_url_propre'])) {
87
-			$url = $_SERVER['REDIRECT_url_propre'];
88
-		} elseif (isset($_ENV['url_propre'])) {
89
-			$url = $_ENV['url_propre'];
90
-		} else {
91
-			$qs = explode("?", $url);
92
-			// ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee
93
-			$url = ltrim($qs[0], '/');
94
-			$url = explode('/', $url);
95
-			while (count($url) > $GLOBALS['profondeur_url'] + 1) {
96
-				array_shift($url);
97
-			}
98
-			$qs[0] = implode('/', $url);
99
-			$url = implode("?", $qs);
100
-		}
101
-	}
82
+    // si on est en train d'assembler la page principale,
83
+    // recuperer l'url depuis les globales url propres si fournies
84
+    // sinon extraire la bonne portion d'url
85
+    if ($assembler) {
86
+        if (isset($_SERVER['REDIRECT_url_propre'])) {
87
+            $url = $_SERVER['REDIRECT_url_propre'];
88
+        } elseif (isset($_ENV['url_propre'])) {
89
+            $url = $_ENV['url_propre'];
90
+        } else {
91
+            $qs = explode("?", $url);
92
+            // ne prendre que le segment d'url qui correspond, en fonction de la profondeur calculee
93
+            $url = ltrim($qs[0], '/');
94
+            $url = explode('/', $url);
95
+            while (count($url) > $GLOBALS['profondeur_url'] + 1) {
96
+                array_shift($url);
97
+            }
98
+            $qs[0] = implode('/', $url);
99
+            $url = implode("?", $qs);
100
+        }
101
+    }
102 102
 
103
-	unset($_SERVER['REDIRECT_url_propre']);
104
-	unset($_ENV['url_propre']);
105
-	include_spip('inc/filtres_mini');
106
-	if (strpos($url, "://") === false) {
107
-		$GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/');
108
-	} else {
109
-		$GLOBALS['profondeur_url'] = max(0, substr_count($url, "/") - substr_count($current_base, "/"));
110
-	}
103
+    unset($_SERVER['REDIRECT_url_propre']);
104
+    unset($_ENV['url_propre']);
105
+    include_spip('inc/filtres_mini');
106
+    if (strpos($url, "://") === false) {
107
+        $GLOBALS['profondeur_url'] = substr_count(ltrim(resolve_path("/$url"), '/'), '/');
108
+    } else {
109
+        $GLOBALS['profondeur_url'] = max(0, substr_count($url, "/") - substr_count($current_base, "/"));
110
+    }
111 111
 
112
-	$url_redirect = "";
113
-	$renommer = generer_url_entite('', '', '', '', true);
114
-	if (!$renommer and !function_exists('recuperer_parametres_url')) {
115
-		$renommer = charger_fonction('page', 'urls');
116
-	} // fallback pour decoder l'url
117
-	if ($renommer) {
118
-		$a = $renommer($url, $fond, $contexte);
119
-		if (is_array($a)) {
120
-			list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null);
121
-			if ($url_redirect == $url) {
122
-				$url_redirect = "";
123
-			} // securite pour eviter une redirection infinie
124
-			if ($assembler and strlen($url_redirect)) {
125
-				spip_log("Redirige $url vers $url_redirect");
126
-				include_spip('inc/headers');
127
-				redirige_par_entete($url_redirect, '', 301);
128
-			}
129
-			if (isset($nfond)) {
130
-				$fond = $nfond;
131
-			} else {
132
-				if ($fond == ''
133
-					or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */
134
-				) {
135
-					$fond = $type;
136
-				}
137
-			}
138
-			if (isset($ncontexte)) {
139
-				$contexte = $ncontexte;
140
-			}
141
-			if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
142
-				$contexte['type'] = $type;
143
-			}
144
-			if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
145
-				$contexte['type-page'] = $type;
146
-			}
147
-		}
148
-	} // compatibilite <= 1.9.2
149
-	elseif (function_exists('recuperer_parametres_url')) {
150
-		$GLOBALS['fond'] = $fond;
151
-		$GLOBALS['contexte'] = $contexte;
152
-		recuperer_parametres_url($fond, nettoyer_uri());
153
-		// fond est en principe modifiee directement
154
-		$contexte = $GLOBALS['contexte'];
155
-	}
112
+    $url_redirect = "";
113
+    $renommer = generer_url_entite('', '', '', '', true);
114
+    if (!$renommer and !function_exists('recuperer_parametres_url')) {
115
+        $renommer = charger_fonction('page', 'urls');
116
+    } // fallback pour decoder l'url
117
+    if ($renommer) {
118
+        $a = $renommer($url, $fond, $contexte);
119
+        if (is_array($a)) {
120
+            list($ncontexte, $type, $url_redirect, $nfond) = array_pad($a, 4, null);
121
+            if ($url_redirect == $url) {
122
+                $url_redirect = "";
123
+            } // securite pour eviter une redirection infinie
124
+            if ($assembler and strlen($url_redirect)) {
125
+                spip_log("Redirige $url vers $url_redirect");
126
+                include_spip('inc/headers');
127
+                redirige_par_entete($url_redirect, '', 301);
128
+            }
129
+            if (isset($nfond)) {
130
+                $fond = $nfond;
131
+            } else {
132
+                if ($fond == ''
133
+                    or $fond == 'type_urls' /* compat avec htaccess 2.0.0 */
134
+                ) {
135
+                    $fond = $type;
136
+                }
137
+            }
138
+            if (isset($ncontexte)) {
139
+                $contexte = $ncontexte;
140
+            }
141
+            if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
142
+                $contexte['type'] = $type;
143
+            }
144
+            if (defined('_DEFINIR_CONTEXTE_TYPE_PAGE') and _DEFINIR_CONTEXTE_TYPE_PAGE) {
145
+                $contexte['type-page'] = $type;
146
+            }
147
+        }
148
+    } // compatibilite <= 1.9.2
149
+    elseif (function_exists('recuperer_parametres_url')) {
150
+        $GLOBALS['fond'] = $fond;
151
+        $GLOBALS['contexte'] = $contexte;
152
+        recuperer_parametres_url($fond, nettoyer_uri());
153
+        // fond est en principe modifiee directement
154
+        $contexte = $GLOBALS['contexte'];
155
+    }
156 156
 
157
-	// retablir les globales
158
-	list($GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']) = $save;
157
+    // retablir les globales
158
+    list($GLOBALS['fond'], $GLOBALS['contexte'], $_SERVER['REDIRECT_url_propre'], $_ENV['url_propre'], $GLOBALS['profondeur_url']) = $save;
159 159
 
160
-	// vider les globales url propres qui ne doivent plus etre utilisees en cas
161
-	// d'inversion url => objet
162
-	// maintenir pour compat ?
163
-	#if ($assembler) {
164
-	#	unset($_SERVER['REDIRECT_url_propre']);
165
-	#	unset($_ENV['url_propre']);
166
-	#}
160
+    // vider les globales url propres qui ne doivent plus etre utilisees en cas
161
+    // d'inversion url => objet
162
+    // maintenir pour compat ?
163
+    #if ($assembler) {
164
+    #	unset($_SERVER['REDIRECT_url_propre']);
165
+    #	unset($_ENV['url_propre']);
166
+    #}
167 167
 
168
-	return array($fond, $contexte, $url_redirect);
168
+    return array($fond, $contexte, $url_redirect);
169 169
 }
170 170
 
171 171
 
@@ -179,24 +179,24 @@  discard block
 block discarded – undo
179 179
  * @return string|array
180 180
  */
181 181
 function urls_liste_objets($preg = true) {
182
-	static $url_objets = null;
183
-	if (is_null($url_objets)) {
184
-		$url_objets = array();
185
-		// recuperer les tables_objets_sql declarees
186
-		$tables_objets = lister_tables_objets_sql();
187
-		foreach ($tables_objets as $t => $infos) {
188
-			if ($infos['page']) {
189
-				$url_objets[] = $infos['type'];
190
-				$url_objets = array_merge($url_objets, $infos['type_surnoms']);
191
-			}
192
-		}
193
-		$url_objets = pipeline('declarer_url_objets', $url_objets);
194
-	}
195
-	if (!$preg) {
196
-		return $url_objets;
197
-	}
182
+    static $url_objets = null;
183
+    if (is_null($url_objets)) {
184
+        $url_objets = array();
185
+        // recuperer les tables_objets_sql declarees
186
+        $tables_objets = lister_tables_objets_sql();
187
+        foreach ($tables_objets as $t => $infos) {
188
+            if ($infos['page']) {
189
+                $url_objets[] = $infos['type'];
190
+                $url_objets = array_merge($url_objets, $infos['type_surnoms']);
191
+            }
192
+        }
193
+        $url_objets = pipeline('declarer_url_objets', $url_objets);
194
+    }
195
+    if (!$preg) {
196
+        return $url_objets;
197
+    }
198 198
 
199
-	return implode('|', array_map('preg_quote', $url_objets));
199
+    return implode('|', array_map('preg_quote', $url_objets));
200 200
 }
201 201
 
202 202
 /**
@@ -210,25 +210,25 @@  discard block
 block discarded – undo
210 210
  * @return array
211 211
  */
212 212
 function nettoyer_url_page($url, $contexte = array()) {
213
-	$url_objets = urls_liste_objets();
214
-	$raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,';
215
-	$raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,';
216
-	$raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,';
213
+    $url_objets = urls_liste_objets();
214
+    $raccourci_url_page_html = ',^(?:[^?]*/)?(' . $url_objets . ')([0-9]+)(?:\.html)?([?&].*)?$,';
215
+    $raccourci_url_page_id = ',^(?:[^?]*/)?(' . $url_objets . ')\.php3?[?]id_\1=([0-9]+)([?&].*)?$,';
216
+    $raccourci_url_page_spip = ',^(?:[^?]*/)?(?:spip[.]php)?[?](' . $url_objets . ')([0-9]+)=?(&.*)?$,';
217 217
 
218
-	if (preg_match($raccourci_url_page_html, $url, $regs)
219
-		or preg_match($raccourci_url_page_id, $url, $regs)
220
-		or preg_match($raccourci_url_page_spip, $url, $regs)
221
-	) {
222
-		$regs = array_pad($regs, 4, null);
223
-		$type = objet_type($regs[1]);
224
-		$_id = id_table_objet($type);
225
-		$contexte[$_id] = $regs[2];
226
-		$suite = $regs[3];
218
+    if (preg_match($raccourci_url_page_html, $url, $regs)
219
+        or preg_match($raccourci_url_page_id, $url, $regs)
220
+        or preg_match($raccourci_url_page_spip, $url, $regs)
221
+    ) {
222
+        $regs = array_pad($regs, 4, null);
223
+        $type = objet_type($regs[1]);
224
+        $_id = id_table_objet($type);
225
+        $contexte[$_id] = $regs[2];
226
+        $suite = $regs[3];
227 227
 
228
-		return array($contexte, $type, null, $type, $suite);
229
-	}
228
+        return array($contexte, $type, null, $type, $suite);
229
+    }
230 230
 
231
-	return array();
231
+    return array();
232 232
 }
233 233
 
234 234
 /**
@@ -247,32 +247,32 @@  discard block
 block discarded – undo
247 247
  *
248 248
  */
249 249
 function generer_url_ecrire_objet($objet, $id, $args = '', $ancre = '', $public = null, $connect = '') {
250
-	static $furls = array();
251
-	if (!isset($furls[$objet])) {
252
-		if (function_exists($f = 'generer_url_ecrire_' . $objet)
253
-			// ou definie par un plugin
254
-			or $f = charger_fonction($f, 'urls', true)
255
-		) {
256
-			$furls[$objet] = $f;
257
-		} else {
258
-			$furls[$objet] = '';
259
-		}
260
-	}
261
-	if ($furls[$objet]) {
262
-		return $furls[$objet]($id, $args, $ancre, $public, $connect);
263
-	}
264
-	// si pas de flag public fourni
265
-	// le calculer en fonction de la declaration de statut
266
-	if (is_null($public) and !$connect) {
267
-		$public = objet_test_si_publie($objet, $id, $connect);
268
-	}
269
-	if ($public or $connect) {
270
-		return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect);
271
-	}
272
-	$a = id_table_objet($objet) . "=" . intval($id);
273
-	if (!function_exists('objet_info')) {
274
-		include_spip('inc/filtres');
275
-	}
250
+    static $furls = array();
251
+    if (!isset($furls[$objet])) {
252
+        if (function_exists($f = 'generer_url_ecrire_' . $objet)
253
+            // ou definie par un plugin
254
+            or $f = charger_fonction($f, 'urls', true)
255
+        ) {
256
+            $furls[$objet] = $f;
257
+        } else {
258
+            $furls[$objet] = '';
259
+        }
260
+    }
261
+    if ($furls[$objet]) {
262
+        return $furls[$objet]($id, $args, $ancre, $public, $connect);
263
+    }
264
+    // si pas de flag public fourni
265
+    // le calculer en fonction de la declaration de statut
266
+    if (is_null($public) and !$connect) {
267
+        $public = objet_test_si_publie($objet, $id, $connect);
268
+    }
269
+    if ($public or $connect) {
270
+        return generer_url_entite_absolue($id, $objet, $args, $ancre, $connect);
271
+    }
272
+    $a = id_table_objet($objet) . "=" . intval($id);
273
+    if (!function_exists('objet_info')) {
274
+        include_spip('inc/filtres');
275
+    }
276 276
 
277
-	return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : '');
277
+    return generer_url_ecrire(objet_info($objet, 'url_voir'), $a . ($args ? "&$args" : '')) . ($ancre ? "#$ancre" : '');
278 278
 }
Please login to merge, or discard this patch.
ecrire/inc/drapeau_edition.php 1 patch
Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
  * @package SPIP\Core\Drapeaux\Edition
31 31
  **/
32 32
 if (!defined('_ECRIRE_INC_VERSION')) {
33
-	return;
33
+    return;
34 34
 }
35 35
 
36 36
 
@@ -45,46 +45,46 @@  discard block
 block discarded – undo
45 45
  *     `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()`
46 46
  **/
47 47
 function lire_tableau_edition() {
48
-	$edition = @unserialize($GLOBALS['meta']['drapeau_edition']);
49
-	if (!$edition) {
50
-		return array();
51
-	}
52
-	$changed = false;
48
+    $edition = @unserialize($GLOBALS['meta']['drapeau_edition']);
49
+    if (!$edition) {
50
+        return array();
51
+    }
52
+    $changed = false;
53 53
 
54
-	$bon_pour_le_service = time() - 3600;
55
-	// parcourir le tableau et virer les vieux
56
-	foreach ($edition as $objet => $data) {
57
-		if (!is_array($data)) {
58
-			unset($edition[$objet]);
59
-		} // vieille version
60
-		else {
61
-			foreach ($data as $id => $tab) {
62
-				if (!is_array($tab)) {
63
-					unset($edition[$objet][$tab]);
64
-				} // vieille version
65
-				else {
66
-					foreach ($tab as $n => $duo) {
67
-						if (current($duo) < $bon_pour_le_service) {
68
-							unset($edition[$objet][$id][$n]);
69
-							$changed = true;
70
-						}
71
-					}
72
-				}
73
-				if (!$edition[$objet][$id]) {
74
-					unset($edition[$objet][$id]);
75
-				}
76
-			}
77
-		}
78
-		if (!$edition[$objet]) {
79
-			unset($edition[$objet]);
80
-		}
81
-	}
54
+    $bon_pour_le_service = time() - 3600;
55
+    // parcourir le tableau et virer les vieux
56
+    foreach ($edition as $objet => $data) {
57
+        if (!is_array($data)) {
58
+            unset($edition[$objet]);
59
+        } // vieille version
60
+        else {
61
+            foreach ($data as $id => $tab) {
62
+                if (!is_array($tab)) {
63
+                    unset($edition[$objet][$tab]);
64
+                } // vieille version
65
+                else {
66
+                    foreach ($tab as $n => $duo) {
67
+                        if (current($duo) < $bon_pour_le_service) {
68
+                            unset($edition[$objet][$id][$n]);
69
+                            $changed = true;
70
+                        }
71
+                    }
72
+                }
73
+                if (!$edition[$objet][$id]) {
74
+                    unset($edition[$objet][$id]);
75
+                }
76
+            }
77
+        }
78
+        if (!$edition[$objet]) {
79
+            unset($edition[$objet]);
80
+        }
81
+    }
82 82
 
83
-	if ($changed) {
84
-		ecrire_tableau_edition($edition);
85
-	}
83
+    if ($changed) {
84
+        ecrire_tableau_edition($edition);
85
+    }
86 86
 
87
-	return $edition;
87
+    return $edition;
88 88
 }
89 89
 
90 90
 /**
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
  *     `[ type d'objet ][id_objet][id_auteur][nom de l'auteur] = time()`
98 98
  **/
99 99
 function ecrire_tableau_edition($edition) {
100
-	ecrire_meta('drapeau_edition', serialize($edition));
100
+    ecrire_meta('drapeau_edition', serialize($edition));
101 101
 }
102 102
 
103 103
 /**
@@ -117,24 +117,24 @@  discard block
 block discarded – undo
117 117
  *     Type d'objet édité
118 118
  */
119 119
 function signale_edition($id, $auteur, $type = 'article') {
120
-	include_spip('base/objets');
121
-	include_spip('inc/filtres');
122
-	if (objet_info($type, 'editable') !== 'oui') {
123
-		return;
124
-	}
120
+    include_spip('base/objets');
121
+    include_spip('inc/filtres');
122
+    if (objet_info($type, 'editable') !== 'oui') {
123
+        return;
124
+    }
125 125
 
126
-	$edition = lire_tableau_edition();
127
-	if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) {
128
-		$nom = $auteur['nom'];
129
-	} else {
130
-		$nom = $id_a = $GLOBALS['ip'];
131
-	}
126
+    $edition = lire_tableau_edition();
127
+    if (isset($auteur['id_auteur']) and $id_a = $auteur['id_auteur']) {
128
+        $nom = $auteur['nom'];
129
+    } else {
130
+        $nom = $id_a = $GLOBALS['ip'];
131
+    }
132 132
 
133
-	if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) {
134
-		$edition[$type][$id] = array();
135
-	}
136
-	$edition[$type][$id][$id_a][$nom] = time();
137
-	ecrire_tableau_edition($edition);
133
+    if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) {
134
+        $edition[$type][$id] = array();
135
+    }
136
+    $edition[$type][$id][$id_a][$nom] = time();
137
+    ecrire_tableau_edition($edition);
138 138
 }
139 139
 
140 140
 /**
@@ -151,9 +151,9 @@  discard block
 block discarded – undo
151 151
  */
152 152
 function qui_edite($id, $type = 'article') {
153 153
 
154
-	$edition = lire_tableau_edition();
154
+    $edition = lire_tableau_edition();
155 155
 
156
-	return empty($edition[$type][$id]) ? array() : $edition[$type][$id];
156
+    return empty($edition[$type][$id]) ? array() : $edition[$type][$id];
157 157
 }
158 158
 
159 159
 /**
@@ -167,22 +167,22 @@  discard block
 block discarded – undo
167 167
  *     Liste de tableaux `['nom_auteur_modif' => x|y|z, 'date_diff' => n]`
168 168
  */
169 169
 function mention_qui_edite($id, $type = 'article') {
170
-	$modif = qui_edite($id, $type);
171
-	unset($modif[$GLOBALS['visiteur_session']['id_auteur']]);
170
+    $modif = qui_edite($id, $type);
171
+    unset($modif[$GLOBALS['visiteur_session']['id_auteur']]);
172 172
 
173
-	if ($modif) {
174
-		$quand = 0;
175
-		foreach ($modif as $duo) {
176
-			$auteurs[] = typo(key($duo));
177
-			$quand = max($quand, current($duo));
178
-		}
173
+    if ($modif) {
174
+        $quand = 0;
175
+        foreach ($modif as $duo) {
176
+            $auteurs[] = typo(key($duo));
177
+            $quand = max($quand, current($duo));
178
+        }
179 179
 
180
-		// format lie a la chaine de langue 'avis_article_modifie'
181
-		return array(
182
-			'nom_auteur_modif' => join(' | ', $auteurs),
183
-			'date_diff' => ceil((time() - $quand) / 60)
184
-		);
185
-	}
180
+        // format lie a la chaine de langue 'avis_article_modifie'
181
+        return array(
182
+            'nom_auteur_modif' => join(' | ', $auteurs),
183
+            'date_diff' => ceil((time() - $quand) / 60)
184
+        );
185
+    }
186 186
 }
187 187
 
188 188
 /**
@@ -196,24 +196,24 @@  discard block
 block discarded – undo
196 196
  *     Liste de tableaux `['objet' => x, 'id_objet' => n]`
197 197
  */
198 198
 function liste_drapeau_edition($id_auteur) {
199
-	$edition = lire_tableau_edition();
200
-	$objets_ouverts = array();
199
+    $edition = lire_tableau_edition();
200
+    $objets_ouverts = array();
201 201
 
202
-	foreach ($edition as $objet => $data) {
203
-		foreach ($data as $id => $auteurs) {
204
-			if (isset($auteurs[$id_auteur])
205
-				and is_array($auteurs[$id_auteur]) // precaution
206
-				and (array_pop($auteurs[$id_auteur]) > time() - 3600)
207
-			) {
208
-				$objets_ouverts[] = array(
209
-					'objet' => $objet,
210
-					'id_objet' => $id,
211
-				);
212
-			}
213
-		}
214
-	}
202
+    foreach ($edition as $objet => $data) {
203
+        foreach ($data as $id => $auteurs) {
204
+            if (isset($auteurs[$id_auteur])
205
+                and is_array($auteurs[$id_auteur]) // precaution
206
+                and (array_pop($auteurs[$id_auteur]) > time() - 3600)
207
+            ) {
208
+                $objets_ouverts[] = array(
209
+                    'objet' => $objet,
210
+                    'id_objet' => $id,
211
+                );
212
+            }
213
+        }
214
+    }
215 215
 
216
-	return $objets_ouverts;
216
+    return $objets_ouverts;
217 217
 }
218 218
 
219 219
 /**
@@ -226,15 +226,15 @@  discard block
 block discarded – undo
226 226
  * @return void
227 227
  */
228 228
 function debloquer_tous($id_auteur) {
229
-	$edition = lire_tableau_edition();
230
-	foreach ($edition as $objet => $data) {
231
-		foreach ($data as $id => $auteurs) {
232
-			if (isset($auteurs[$id_auteur])) {
233
-				unset($edition[$objet][$id][$id_auteur]);
234
-				ecrire_tableau_edition($edition);
235
-			}
236
-		}
237
-	}
229
+    $edition = lire_tableau_edition();
230
+    foreach ($edition as $objet => $data) {
231
+        foreach ($data as $id => $auteurs) {
232
+            if (isset($auteurs[$id_auteur])) {
233
+                unset($edition[$objet][$id][$id_auteur]);
234
+                ecrire_tableau_edition($edition);
235
+            }
236
+        }
237
+    }
238 238
 }
239 239
 
240 240
 /**
@@ -252,18 +252,18 @@  discard block
 block discarded – undo
252 252
  * @return void
253 253
  */
254 254
 function debloquer_edition($id_auteur, $id_objet, $type = 'article') {
255
-	$edition = lire_tableau_edition();
255
+    $edition = lire_tableau_edition();
256 256
 
257
-	foreach ($edition as $objet => $data) {
258
-		if ($objet == $type) {
259
-			foreach ($data as $id => $auteurs) {
260
-				if ($id == $id_objet
261
-					and isset($auteurs[$id_auteur])
262
-				) {
263
-					unset($edition[$objet][$id][$id_auteur]);
264
-					ecrire_tableau_edition($edition);
265
-				}
266
-			}
267
-		}
268
-	}
257
+    foreach ($edition as $objet => $data) {
258
+        if ($objet == $type) {
259
+            foreach ($data as $id => $auteurs) {
260
+                if ($id == $id_objet
261
+                    and isset($auteurs[$id_auteur])
262
+                ) {
263
+                    unset($edition[$objet][$id][$id_auteur]);
264
+                    ecrire_tableau_edition($edition);
265
+                }
266
+            }
267
+        }
268
+    }
269 269
 }
Please login to merge, or discard this patch.
ecrire/inc/boutons.php 1 patch
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -25,51 +25,51 @@  discard block
 block discarded – undo
25 25
  * privée ou dans un de ses sous menus
26 26
  */
27 27
 class Bouton {
28
-	/** @var string L'icone à mettre dans le bouton */
29
-	public $icone;
30
-
31
-	/** @var string Le nom de l'entrée d'i18n associé */
32
-	public $libelle;
33
-
34
-	/** @var null|string L'URL de la page (null => ?exec=nom) */
35
-	public $url = null;
36
-
37
-	/** @var null|string|array Arguments supplementaires de l'URL */
38
-	public $urlArg = null;
39
-
40
-	/** @var null|string URL du javascript */
41
-	public $url2 = null;
42
-
43
-	/** @var null|string Pour ouvrir dans une fenetre a part */
44
-	public $target = null;
45
-
46
-	/** @var null|mixed Sous-barre de boutons / onglets */
47
-	public $sousmenu = null;
48
-
49
-	/**
50
-	 * Définit un bouton
51
-	 *
52
-	 * @param string $icone
53
-	 *    L'icone à mettre dans le bouton
54
-	 * @param string $libelle
55
-	 *    Le nom de l'entrée i18n associé
56
-	 * @param null|string $url
57
-	 *    L'URL de la page
58
-	 * @param null|string|array $urlArg
59
-	 *    Arguments supplémentaires de l'URL
60
-	 * @param null|string $url2
61
-	 *    URL du javascript
62
-	 * @param null|mixed $target
63
-	 *    Pour ouvrir une fenêtre à part
64
-	 */
65
-	public function __construct($icone, $libelle, $url = null, $urlArg = null, $url2 = null, $target = null) {
66
-		$this->icone = $icone;
67
-		$this->libelle = $libelle;
68
-		$this->url = $url;
69
-		$this->urlArg = $urlArg;
70
-		$this->url2 = $url2;
71
-		$this->target = $target;
72
-	}
28
+    /** @var string L'icone à mettre dans le bouton */
29
+    public $icone;
30
+
31
+    /** @var string Le nom de l'entrée d'i18n associé */
32
+    public $libelle;
33
+
34
+    /** @var null|string L'URL de la page (null => ?exec=nom) */
35
+    public $url = null;
36
+
37
+    /** @var null|string|array Arguments supplementaires de l'URL */
38
+    public $urlArg = null;
39
+
40
+    /** @var null|string URL du javascript */
41
+    public $url2 = null;
42
+
43
+    /** @var null|string Pour ouvrir dans une fenetre a part */
44
+    public $target = null;
45
+
46
+    /** @var null|mixed Sous-barre de boutons / onglets */
47
+    public $sousmenu = null;
48
+
49
+    /**
50
+     * Définit un bouton
51
+     *
52
+     * @param string $icone
53
+     *    L'icone à mettre dans le bouton
54
+     * @param string $libelle
55
+     *    Le nom de l'entrée i18n associé
56
+     * @param null|string $url
57
+     *    L'URL de la page
58
+     * @param null|string|array $urlArg
59
+     *    Arguments supplémentaires de l'URL
60
+     * @param null|string $url2
61
+     *    URL du javascript
62
+     * @param null|mixed $target
63
+     *    Pour ouvrir une fenêtre à part
64
+     */
65
+    public function __construct($icone, $libelle, $url = null, $urlArg = null, $url2 = null, $target = null) {
66
+        $this->icone = $icone;
67
+        $this->libelle = $libelle;
68
+        $this->url = $url;
69
+        $this->urlArg = $urlArg;
70
+        $this->url2 = $url2;
71
+        $this->target = $target;
72
+    }
73 73
 }
74 74
 
75 75
 
@@ -86,32 +86,32 @@  discard block
 block discarded – undo
86 86
  */
87 87
 function definir_barre_onglets($script) {
88 88
 
89
-	$onglets = array();
90
-	$liste_onglets = array();
91
-
92
-	// ajouter les onglets issus des plugin via paquet.xml
93
-	if (function_exists('onglets_plugins')) {
94
-		$liste_onglets = onglets_plugins();
95
-	}
96
-
97
-
98
-	foreach ($liste_onglets as $id => $infos) {
99
-		if (($parent = $infos['parent'])
100
-			&& $parent == $script
101
-			&& autoriser('onglet', "_$id")
102
-		) {
103
-			$onglets[$id] = new Bouton(
104
-				isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
105
-				$infos['titre'],  // titre
106
-				(isset($infos['action']) and $infos['action'])
107
-					? generer_url_ecrire($infos['action'],
108
-					(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : '')
109
-					: null
110
-			);
111
-		}
112
-	}
113
-
114
-	return pipeline('ajouter_onglets', array('data' => $onglets, 'args' => $script));
89
+    $onglets = array();
90
+    $liste_onglets = array();
91
+
92
+    // ajouter les onglets issus des plugin via paquet.xml
93
+    if (function_exists('onglets_plugins')) {
94
+        $liste_onglets = onglets_plugins();
95
+    }
96
+
97
+
98
+    foreach ($liste_onglets as $id => $infos) {
99
+        if (($parent = $infos['parent'])
100
+            && $parent == $script
101
+            && autoriser('onglet', "_$id")
102
+        ) {
103
+            $onglets[$id] = new Bouton(
104
+                isset($infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
105
+                $infos['titre'],  // titre
106
+                (isset($infos['action']) and $infos['action'])
107
+                    ? generer_url_ecrire($infos['action'],
108
+                    (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : '')
109
+                    : null
110
+            );
111
+        }
112
+    }
113
+
114
+    return pipeline('ajouter_onglets', array('data' => $onglets, 'args' => $script));
115 115
 }
116 116
 
117 117
 
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
  * @return string
131 131
  */
132 132
 function barre_onglets($rubrique, $ongletCourant, $class = "barre_onglet") {
133
-	include_spip('inc/presentation');
133
+    include_spip('inc/presentation');
134 134
 
135
-	$res = '';
135
+    $res = '';
136 136
 
137
-	foreach (definir_barre_onglets($rubrique) as $exec => $onglet) {
138
-		$url = $onglet->url ? $onglet->url : generer_url_ecrire($exec);
139
-		$res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
140
-	}
137
+    foreach (definir_barre_onglets($rubrique) as $exec => $onglet) {
138
+        $url = $onglet->url ? $onglet->url : generer_url_ecrire($exec);
139
+        $res .= onglet(_T($onglet->libelle), $url, $exec, $ongletCourant, $onglet->icone);
140
+    }
141 141
 
142
-	return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
142
+    return !$res ? '' : (debut_onglet($class) . $res . fin_onglet());
143 143
 }
Please login to merge, or discard this patch.
ecrire/inc/cvt_configurer.php 1 patch
Indentation   +142 added lines, -142 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  */
21 21
 
22 22
 if (!defined('_ECRIRE_INC_VERSION')) {
23
-	return;
23
+    return;
24 24
 }
25 25
 
26 26
 include_spip('inc/config');
@@ -32,31 +32,31 @@  discard block
 block discarded – undo
32 32
  * @return array
33 33
  */
34 34
 function cvtconf_formulaire_charger($flux) {
35
-	if (
36
-		$form = $flux['args']['form']
37
-		and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX
38
-	) {
39
-		// Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé
40
-		include_spip('inc/autoriser');
41
-		if (!autoriser('configurer', '_' . substr($form, 11))) {
42
-			return false;
43
-		}
35
+    if (
36
+        $form = $flux['args']['form']
37
+        and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX
38
+    ) {
39
+        // Pour tous les formulaires CONFIGURER, ayant une fonction charger ou pas, on teste si autorisé
40
+        include_spip('inc/autoriser');
41
+        if (!autoriser('configurer', '_' . substr($form, 11))) {
42
+            return false;
43
+        }
44 44
 
45
-		// S'il n'y a pas de fonction charger(), on génère un contexte automatiquement
46
-		if (!charger_fonction("charger", "formulaires/$form/", true)) {
47
-			$flux['data'] = cvtconf_formulaires_configurer_recense($form);
48
-			$flux['data']['editable'] = true;
49
-			if (_request('var_mode') == 'configurer' and autoriser('webmestre')) {
50
-				if (!_AJAX) {
51
-					var_dump($flux['data']);
52
-				}
53
-				// reinjecter pour la trace au traitement
54
-				$flux['data']['_hidden'] = "<input type='hidden' name='var_mode' value='configurer' />";
55
-			}
56
-		}
57
-	}
45
+        // S'il n'y a pas de fonction charger(), on génère un contexte automatiquement
46
+        if (!charger_fonction("charger", "formulaires/$form/", true)) {
47
+            $flux['data'] = cvtconf_formulaires_configurer_recense($form);
48
+            $flux['data']['editable'] = true;
49
+            if (_request('var_mode') == 'configurer' and autoriser('webmestre')) {
50
+                if (!_AJAX) {
51
+                    var_dump($flux['data']);
52
+                }
53
+                // reinjecter pour la trace au traitement
54
+                $flux['data']['_hidden'] = "<input type='hidden' name='var_mode' value='configurer' />";
55
+            }
56
+        }
57
+    }
58 58
 
59
-	return $flux;
59
+    return $flux;
60 60
 }
61 61
 
62 62
 /**
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
  * @return array
67 67
  */
68 68
 function cvtconf_formulaire_traiter($flux) {
69
-	if ($form = $flux['args']['form']
70
-		and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX
71
-		and !charger_fonction("traiter", "formulaires/$form/", true) // sans fonction traiter()
72
-	) {
73
-		$trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']);
74
-		$flux['data'] = array('message_ok' => _T('config_info_enregistree') . $trace, 'editable' => true);
75
-	}
69
+    if ($form = $flux['args']['form']
70
+        and strncmp($form, 'configurer_', 11) == 0 // un #FORMULAIRE_CONFIGURER_XXX
71
+        and !charger_fonction("traiter", "formulaires/$form/", true) // sans fonction traiter()
72
+    ) {
73
+        $trace = cvtconf_formulaires_configurer_enregistre($form, $flux['args']['args']);
74
+        $flux['data'] = array('message_ok' => _T('config_info_enregistree') . $trace, 'editable' => true);
75
+    }
76 76
 
77
-	return $flux;
77
+    return $flux;
78 78
 }
79 79
 
80 80
 /**
@@ -90,32 +90,32 @@  discard block
 block discarded – undo
90 90
  * @return string
91 91
  */
92 92
 function cvtconf_formulaires_configurer_enregistre($form, $args) {
93
-	$valeurs = array();
94
-	// charger les valeurs
95
-	// ce qui permet de prendre en charge une fonction charger() existante
96
-	// qui prend alors la main sur l'auto detection
97
-	if ($charger_valeurs = charger_fonction("charger", "formulaires/$form/", true)) {
98
-		$valeurs = call_user_func_array($charger_valeurs, $args);
99
-	}
100
-	$valeurs = pipeline(
101
-		'formulaire_charger',
102
-		array(
103
-			'args' => array('form' => $form, 'args' => $args, 'je_suis_poste' => false),
104
-			'data' => $valeurs
105
-		)
106
-	);
107
-	// ne pas stocker editable !
108
-	unset($valeurs['editable']);
93
+    $valeurs = array();
94
+    // charger les valeurs
95
+    // ce qui permet de prendre en charge une fonction charger() existante
96
+    // qui prend alors la main sur l'auto detection
97
+    if ($charger_valeurs = charger_fonction("charger", "formulaires/$form/", true)) {
98
+        $valeurs = call_user_func_array($charger_valeurs, $args);
99
+    }
100
+    $valeurs = pipeline(
101
+        'formulaire_charger',
102
+        array(
103
+            'args' => array('form' => $form, 'args' => $args, 'je_suis_poste' => false),
104
+            'data' => $valeurs
105
+        )
106
+    );
107
+    // ne pas stocker editable !
108
+    unset($valeurs['editable']);
109 109
 
110
-	// recuperer les valeurs postees
111
-	$store = array();
112
-	foreach ($valeurs as $k => $v) {
113
-		if (substr($k, 0, 1) !== '_') {
114
-			$store[$k] = _request($k);
115
-		}
116
-	}
110
+    // recuperer les valeurs postees
111
+    $store = array();
112
+    foreach ($valeurs as $k => $v) {
113
+        if (substr($k, 0, 1) !== '_') {
114
+            $store[$k] = _request($k);
115
+        }
116
+    }
117 117
 
118
-	return cvtconf_configurer_stocker($form, $valeurs, $store);
118
+    return cvtconf_configurer_stocker($form, $valeurs, $store);
119 119
 }
120 120
 
121 121
 /**
@@ -131,31 +131,31 @@  discard block
 block discarded – undo
131 131
  * @return array
132 132
  */
133 133
 function cvtconf_definir_configurer_conteneur($form, $valeurs) {
134
-	// stocker en base
135
-	// par defaut, dans un casier serialize dans spip_meta (idem CFG)
136
-	$casier = substr($form, 11);
137
-	$table = 'meta';
138
-	$prefixe = '';
139
-	$stockage = '';
134
+    // stocker en base
135
+    // par defaut, dans un casier serialize dans spip_meta (idem CFG)
136
+    $casier = substr($form, 11);
137
+    $table = 'meta';
138
+    $prefixe = '';
139
+    $stockage = '';
140 140
 
141
-	if (isset($valeurs['_meta_casier'])) {
142
-		$casier = $valeurs['_meta_casier'];
143
-	}
144
-	if (isset($valeurs['_meta_prefixe'])) {
145
-		$prefixe = $valeurs['_meta_prefixe'];
146
-	}
147
-	if (isset($valeurs['_meta_stockage'])) {
148
-		$stockage = $valeurs['_meta_stockage'] . '::';
149
-	}
141
+    if (isset($valeurs['_meta_casier'])) {
142
+        $casier = $valeurs['_meta_casier'];
143
+    }
144
+    if (isset($valeurs['_meta_prefixe'])) {
145
+        $prefixe = $valeurs['_meta_prefixe'];
146
+    }
147
+    if (isset($valeurs['_meta_stockage'])) {
148
+        $stockage = $valeurs['_meta_stockage'] . '::';
149
+    }
150 150
 
151
-	// si on indique juste une table, il faut vider les autres proprietes
152
-	// car par defaut on utilise ni casier ni prefixe dans ce cas
153
-	if (isset($valeurs['_meta_table'])) {
154
-		$table = $valeurs['_meta_table'];
155
-		$casier = (isset($valeurs['_meta_casier']) ? $valeurs['_meta_casier'] : '');
156
-	}
151
+    // si on indique juste une table, il faut vider les autres proprietes
152
+    // car par defaut on utilise ni casier ni prefixe dans ce cas
153
+    if (isset($valeurs['_meta_table'])) {
154
+        $table = $valeurs['_meta_table'];
155
+        $casier = (isset($valeurs['_meta_casier']) ? $valeurs['_meta_casier'] : '');
156
+    }
157 157
 
158
-	return array($table, $casier, $prefixe, $stockage);
158
+    return array($table, $casier, $prefixe, $stockage);
159 159
 }
160 160
 
161 161
 /**
@@ -166,45 +166,45 @@  discard block
 block discarded – undo
166 166
  * @return array
167 167
  */
168 168
 function cvtconf_formulaires_configurer_recense($form) {
169
-	$valeurs = array('editable' => ' ');
169
+    $valeurs = array('editable' => ' ');
170 170
 
171
-	// sinon cas analyse du squelette
172
-	if ($f = find_in_path($form . '.' . _EXTENSION_SQUELETTES, 'formulaires/')
173
-		and lire_fichier($f, $contenu)
174
-	) {
171
+    // sinon cas analyse du squelette
172
+    if ($f = find_in_path($form . '.' . _EXTENSION_SQUELETTES, 'formulaires/')
173
+        and lire_fichier($f, $contenu)
174
+    ) {
175 175
 
176
-		for ($i = 0; $i < 2; $i++) {
177
-			// a la seconde iteration, evaluer le fond avec les valeurs deja trouvees
178
-			// permet de trouver aussi les name="#GET{truc}"
179
-			if ($i == 1) {
180
-				$contenu = recuperer_fond("formulaires/$form", $valeurs);
181
-			}
176
+        for ($i = 0; $i < 2; $i++) {
177
+            // a la seconde iteration, evaluer le fond avec les valeurs deja trouvees
178
+            // permet de trouver aussi les name="#GET{truc}"
179
+            if ($i == 1) {
180
+                $contenu = recuperer_fond("formulaires/$form", $valeurs);
181
+            }
182 182
 
183
-			$balises = array_merge(extraire_balises($contenu, 'input'),
184
-				extraire_balises($contenu, 'textarea'),
185
-				extraire_balises($contenu, 'select'));
183
+            $balises = array_merge(extraire_balises($contenu, 'input'),
184
+                extraire_balises($contenu, 'textarea'),
185
+                extraire_balises($contenu, 'select'));
186 186
 
187
-			foreach ($balises as $b) {
188
-				if ($n = extraire_attribut($b, 'name')
189
-					and preg_match(",^([\w\-]+)(\[\w*\])?$,", $n, $r)
190
-					and !in_array($n, array('formulaire_action', 'formulaire_action_args'))
191
-					and extraire_attribut($b, 'type') !== 'submit'
192
-				) {
193
-					$valeurs[$r[1]] = '';
194
-					// recuperer les valeurs _meta_xx qui peuvent etre fournies
195
-					// en input hidden dans le squelette
196
-					if (strncmp($r[1], '_meta_', 6) == 0) {
197
-						$valeurs[$r[1]] = extraire_attribut($b, 'value');
198
-					}
199
-				}
200
-			}
201
-		}
202
-	}
187
+            foreach ($balises as $b) {
188
+                if ($n = extraire_attribut($b, 'name')
189
+                    and preg_match(",^([\w\-]+)(\[\w*\])?$,", $n, $r)
190
+                    and !in_array($n, array('formulaire_action', 'formulaire_action_args'))
191
+                    and extraire_attribut($b, 'type') !== 'submit'
192
+                ) {
193
+                    $valeurs[$r[1]] = '';
194
+                    // recuperer les valeurs _meta_xx qui peuvent etre fournies
195
+                    // en input hidden dans le squelette
196
+                    if (strncmp($r[1], '_meta_', 6) == 0) {
197
+                        $valeurs[$r[1]] = extraire_attribut($b, 'value');
198
+                    }
199
+                }
200
+            }
201
+        }
202
+    }
203 203
 
204 204
 
205
-	cvtconf_configurer_lire_meta($form, $valeurs);
205
+    cvtconf_configurer_lire_meta($form, $valeurs);
206 206
 
207
-	return $valeurs;
207
+    return $valeurs;
208 208
 }
209 209
 
210 210
 /**
@@ -216,26 +216,26 @@  discard block
 block discarded – undo
216 216
  * @return string
217 217
  */
218 218
 function cvtconf_configurer_stocker($form, $valeurs, $store) {
219
-	$trace = '';
220
-	list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs);
221
-	// stocker en base
222
-	// par defaut, dans un casier serialize dans spip_meta (idem CFG)
223
-	if (!isset($GLOBALS[$table])) {
224
-		lire_metas($table);
225
-	}
219
+    $trace = '';
220
+    list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs);
221
+    // stocker en base
222
+    // par defaut, dans un casier serialize dans spip_meta (idem CFG)
223
+    if (!isset($GLOBALS[$table])) {
224
+        lire_metas($table);
225
+    }
226 226
 
227
-	$prefixe = ($prefixe ? $prefixe . '_' : '');
228
-	$table = ($table) ? "/$table/" : "";
229
-	$casier = ($casier) ? rtrim($casier, '/') . '/' : ""; // slash final, sinon rien
227
+    $prefixe = ($prefixe ? $prefixe . '_' : '');
228
+    $table = ($table) ? "/$table/" : "";
229
+    $casier = ($casier) ? rtrim($casier, '/') . '/' : ""; // slash final, sinon rien
230 230
 
231
-	foreach ($store as $k => $v) {
232
-		ecrire_config("$stockage$table$prefixe$casier$k", $v);
233
-		if (_request('var_mode') == 'configurer' and autoriser('webmestre')) {
234
-			$trace .= "<br />table $table : " . $prefixe . $k . " = $v;";
235
-		}
236
-	}
231
+    foreach ($store as $k => $v) {
232
+        ecrire_config("$stockage$table$prefixe$casier$k", $v);
233
+        if (_request('var_mode') == 'configurer' and autoriser('webmestre')) {
234
+            $trace .= "<br />table $table : " . $prefixe . $k . " = $v;";
235
+        }
236
+    }
237 237
 
238
-	return $trace;
238
+    return $trace;
239 239
 }
240 240
 
241 241
 /**
@@ -245,21 +245,21 @@  discard block
 block discarded – undo
245 245
  * @param array $valeurs
246 246
  */
247 247
 function cvtconf_configurer_lire_meta($form, &$valeurs) {
248
-	list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs);
248
+    list($table, $casier, $prefixe, $stockage) = cvtconf_definir_configurer_conteneur($form, $valeurs);
249 249
 
250
-	$table = ($table) ? "/$table/" : "";
251
-	$prefixe = ($prefixe ? $prefixe . '_' : '');
252
-	if ($casier) {
253
-		$meta = lire_config("$stockage$table$prefixe$casier");
254
-		$prefixe = '';
255
-	} else {
256
-		$table = rtrim($table, '/');
257
-		$meta = lire_config("$stockage$table");
258
-	}
250
+    $table = ($table) ? "/$table/" : "";
251
+    $prefixe = ($prefixe ? $prefixe . '_' : '');
252
+    if ($casier) {
253
+        $meta = lire_config("$stockage$table$prefixe$casier");
254
+        $prefixe = '';
255
+    } else {
256
+        $table = rtrim($table, '/');
257
+        $meta = lire_config("$stockage$table");
258
+    }
259 259
 
260
-	foreach ($valeurs as $k => $v) {
261
-		if (substr($k, 0, 1) !== '_') {
262
-			$valeurs[$k] = (isset($meta[$prefixe . $k]) ? $meta[$prefixe . $k] : null);
263
-		}
264
-	}
260
+    foreach ($valeurs as $k => $v) {
261
+        if (substr($k, 0, 1) !== '_') {
262
+            $valeurs[$k] = (isset($meta[$prefixe . $k]) ? $meta[$prefixe . $k] : null);
263
+        }
264
+    }
265 265
 }
Please login to merge, or discard this patch.
ecrire/inc/iconifier.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/actions');
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
  *     - ou tableau d'information sur le squelette.
37 37
  */
38 38
 function inc_iconifier_dist($objet, $id, $script, $visible = false, $flag_modif = true) {
39
-	// compat avec anciens appels
40
-	$objet = objet_type($objet);
39
+    // compat avec anciens appels
40
+    $objet = objet_type($objet);
41 41
 
42
-	return recuperer_fond('prive/objets/editer/logo',
43
-		array('objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif));
42
+    return recuperer_fond('prive/objets/editer/logo',
43
+        array('objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif));
44 44
 }
Please login to merge, or discard this patch.
ecrire/inc/lien_court.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /*
@@ -22,12 +22,12 @@  discard block
 block discarded – undo
22 22
  * http://zoumzamzouilam/truc/chose/machin..."
23 23
  */
24 24
 function inc_lien_court($url) {
25
-	$long_url = defined('_MAX_LONG_URL') ? _MAX_LONG_URL : 40;
26
-	$coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35;
25
+    $long_url = defined('_MAX_LONG_URL') ? _MAX_LONG_URL : 40;
26
+    $coupe_url = defined('_MAX_COUPE_URL') ? _MAX_COUPE_URL : 35;
27 27
 
28
-	if (strlen($url) > $long_url) {
29
-		$url = substr($url, 0, $coupe_url) . '...';
30
-	}
28
+    if (strlen($url) > $long_url) {
29
+        $url = substr($url, 0, $coupe_url) . '...';
30
+    }
31 31
 
32
-	return $url;
32
+    return $url;
33 33
 }
Please login to merge, or discard this patch.
ecrire/inc/log.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -11,103 +11,103 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 function inc_log_dist($message, $logname = null, $logdir = null, $logsuf = null) {
18
-	static $test_repertoire = array();
19
-	static $compteur = array();
20
-	static $debugverb = ''; // pour ne pas le recalculer au reappel
21
-
22
-	if (is_null($logname) or !is_string($logname)) {
23
-		$logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
24
-	}
25
-	if (!isset($compteur[$logname])) {
26
-		$compteur[$logname] = 0;
27
-	}
28
-	if ($logname != 'maj'
29
-		and defined('_MAX_LOG')
30
-		and (
31
-			$compteur[$logname]++ > _MAX_LOG
32
-			or !$GLOBALS['nombre_de_logs']
33
-			or !$GLOBALS['taille_des_logs']
34
-		)
35
-	) {
36
-		return;
37
-	}
38
-
39
-	$logfile = ($logdir === null ? _DIR_LOG : $logdir)
40
-		. ($logname)
41
-		. ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf);
42
-
43
-	if (!isset($test_repertoire[$d = dirname($logfile)])) {
44
-		$test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire
45
-		$test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire(
46
-			$d,
47
-			'',
48
-			false,
49
-			true
50
-		) : false));
51
-	}
52
-
53
-	// si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/
54
-	if (!defined('_DIR_LOG') or !$test_repertoire[$d]) {
55
-		$logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
56
-	}
57
-
58
-	$rotate = 0;
59
-	$pid = '(pid ' . @getmypid() . ')';
60
-
61
-	// accepter spip_log( Array )
62
-	if (!is_string($message)) {
63
-		$message = var_export($message, true);
64
-	}
65
-
66
-	if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) {
67
-		$debug = debug_backtrace();
68
-		$l = $debug[1]['line'];
69
-		$fi = $debug[1]['file'];
70
-		if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) {
71
-			$fi = substr($fi, strlen(_ROOT_RACINE));
72
-		}
73
-		$fu = isset($debug[2]['function']) ? $debug[2]['function'] : '';
74
-		$debugverb = "$fi:L$l:$fu" . '():';
75
-	}
76
-
77
-	$m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' '
78
-		//distinguer les logs prives et publics dans les grep
79
-		. $debugverb
80
-		. (test_espace_prive() ? ':Pri:' : ':Pub:')
81
-		. preg_replace("/\n*$/", "\n", $message);
82
-
83
-
84
-	if (@is_readable($logfile)
85
-		and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024)
86
-	) {
87
-		$rotate = $GLOBALS['nombre_de_logs'];
88
-		$m .= "[-- rotate --]\n";
89
-	}
90
-
91
-	$f = @fopen($logfile, 'ab');
92
-	if ($f) {
93
-		fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '&lt;', $m));
94
-		fclose($f);
95
-	}
96
-
97
-	if ($rotate-- > 0
98
-		and function_exists('spip_unlink')
99
-	) {
100
-		spip_unlink($logfile . '.' . $rotate);
101
-		while ($rotate--) {
102
-			@rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
103
-		}
104
-	}
105
-
106
-	// Dupliquer les erreurs specifiques dans le log general
107
-	if ($logname !== _FILE_LOG
108
-		and defined('_FILE_LOG')
109
-	) {
110
-		inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message);
111
-	}
112
-	$debugverb = '';
18
+    static $test_repertoire = array();
19
+    static $compteur = array();
20
+    static $debugverb = ''; // pour ne pas le recalculer au reappel
21
+
22
+    if (is_null($logname) or !is_string($logname)) {
23
+        $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip';
24
+    }
25
+    if (!isset($compteur[$logname])) {
26
+        $compteur[$logname] = 0;
27
+    }
28
+    if ($logname != 'maj'
29
+        and defined('_MAX_LOG')
30
+        and (
31
+            $compteur[$logname]++ > _MAX_LOG
32
+            or !$GLOBALS['nombre_de_logs']
33
+            or !$GLOBALS['taille_des_logs']
34
+        )
35
+    ) {
36
+        return;
37
+    }
38
+
39
+    $logfile = ($logdir === null ? _DIR_LOG : $logdir)
40
+        . ($logname)
41
+        . ($logsuf === null ? _FILE_LOG_SUFFIX : $logsuf);
42
+
43
+    if (!isset($test_repertoire[$d = dirname($logfile)])) {
44
+        $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire
45
+        $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire(
46
+            $d,
47
+            '',
48
+            false,
49
+            true
50
+        ) : false));
51
+    }
52
+
53
+    // si spip_log() dans mes_options, ou repertoire log/ non present, poser dans tmp/
54
+    if (!defined('_DIR_LOG') or !$test_repertoire[$d]) {
55
+        $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log';
56
+    }
57
+
58
+    $rotate = 0;
59
+    $pid = '(pid ' . @getmypid() . ')';
60
+
61
+    // accepter spip_log( Array )
62
+    if (!is_string($message)) {
63
+        $message = var_export($message, true);
64
+    }
65
+
66
+    if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) {
67
+        $debug = debug_backtrace();
68
+        $l = $debug[1]['line'];
69
+        $fi = $debug[1]['file'];
70
+        if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) {
71
+            $fi = substr($fi, strlen(_ROOT_RACINE));
72
+        }
73
+        $fu = isset($debug[2]['function']) ? $debug[2]['function'] : '';
74
+        $debugverb = "$fi:L$l:$fu" . '():';
75
+    }
76
+
77
+    $m = date('Y-m-d H:i:s') . ' ' . (isset($GLOBALS['ip']) ? $GLOBALS['ip'] : '') . ' ' . $pid . ' '
78
+        //distinguer les logs prives et publics dans les grep
79
+        . $debugverb
80
+        . (test_espace_prive() ? ':Pri:' : ':Pub:')
81
+        . preg_replace("/\n*$/", "\n", $message);
82
+
83
+
84
+    if (@is_readable($logfile)
85
+        and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024)
86
+    ) {
87
+        $rotate = $GLOBALS['nombre_de_logs'];
88
+        $m .= "[-- rotate --]\n";
89
+    }
90
+
91
+    $f = @fopen($logfile, 'ab');
92
+    if ($f) {
93
+        fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '&lt;', $m));
94
+        fclose($f);
95
+    }
96
+
97
+    if ($rotate-- > 0
98
+        and function_exists('spip_unlink')
99
+    ) {
100
+        spip_unlink($logfile . '.' . $rotate);
101
+        while ($rotate--) {
102
+            @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1));
103
+        }
104
+    }
105
+
106
+    // Dupliquer les erreurs specifiques dans le log general
107
+    if ($logname !== _FILE_LOG
108
+        and defined('_FILE_LOG')
109
+    ) {
110
+        inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message);
111
+    }
112
+    $debugverb = '';
113 113
 }
Please login to merge, or discard this patch.
ecrire/inc/nfslock.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  **/
8 8
 
9 9
 if (!defined('_ECRIRE_INC_VERSION')) {
10
-	return;
10
+    return;
11 11
 }
12 12
 
13 13
 include_spip('inc/acces');
@@ -101,93 +101,93 @@  discard block
 block discarded – undo
101 101
  * @return int|bool Timestamp du verrou, false si erreur
102 102
  */
103 103
 function spip_nfslock($fichier, $max_age = 0) {
104
-	$tries = 0;
104
+    $tries = 0;
105 105
 
106
-	if (!$max_age) {
107
-		$max_age = _DEFAULT_LOCKTIME;
108
-	}
109
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
106
+    if (!$max_age) {
107
+        $max_age = _DEFAULT_LOCKTIME;
108
+    }
109
+    $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
110 110
 
111 111
 
112
-	/*
112
+    /*
113 113
 	 * 1. create a tmp file with a psuedo random file name. we also make
114 114
 	 *    tpath which is a buffer to store the full pathname of the tmp file.
115 115
 	 */
116 116
 
117
-	$id = creer_uniqid();
118
-	$tpath = _DIR_TMP . "slock.$id";
119
-	$tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ...
120
-	if (!$tmpfd) {  /* open failed */
121
-		@fclose($tmpfd);
122
-		spip_unlink($tpath);
117
+    $id = creer_uniqid();
118
+    $tpath = _DIR_TMP . "slock.$id";
119
+    $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ...
120
+    if (!$tmpfd) {  /* open failed */
121
+        @fclose($tmpfd);
122
+        spip_unlink($tpath);
123 123
 
124
-		return false; //NFSL_SYSF
125
-	}
124
+        return false; //NFSL_SYSF
125
+    }
126 126
 
127
-	/*
127
+    /*
128 128
 	 * 2. make fullpath, a buffer for the full pathname of the lock file.
129 129
 	 *    then start looping trying to lock it
130 130
 	 */
131 131
 
132
-	while ($tries < 10) {
133
-		/*
132
+    while ($tries < 10) {
133
+        /*
134 134
 		 * 3. link tmp file to lock file.  if it goes, we win and we clean
135 135
 		 *    up and return the st_ctime of the lock file.
136 136
 		 */
137 137
 
138
-		if (link($tpath, $lock_file) == 1) {
139
-			spip_unlink($tpath); /* got it! */
140
-			@fclose($tmpfd);
141
-			if (($our_tmp = lstat($lock_file)) == false) {  /* stat failed... shouldn't happen */
142
-				spip_unlink($lock_file);
138
+        if (link($tpath, $lock_file) == 1) {
139
+            spip_unlink($tpath); /* got it! */
140
+            @fclose($tmpfd);
141
+            if (($our_tmp = lstat($lock_file)) == false) {  /* stat failed... shouldn't happen */
142
+                spip_unlink($lock_file);
143 143
 
144
-				return false; // (NFSL_SYSF);
145
-			}
144
+                return false; // (NFSL_SYSF);
145
+            }
146 146
 
147
-			return ($our_tmp['ctime']);
148
-		}
147
+            return ($our_tmp['ctime']);
148
+        }
149 149
 
150
-		/*
150
+        /*
151 151
 		 * 4. the lock failed.  check for a stale lock file, being mindful
152 152
 		 *    of NFS and the fact the time is set from the NFS server.  we
153 153
 		 *    do a write on the tmp file to update its time to the server's
154 154
 		 *    idea of "now."
155 155
 		 */
156 156
 
157
-		$old_stat = lstat($lock_file);
158
-		if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) {
159
-			break;
160
-		} /* something bogus is going on */
157
+        $old_stat = lstat($lock_file);
158
+        if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) {
159
+            break;
160
+        } /* something bogus is going on */
161 161
 
162 162
 
163
-		if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) {
164
-			spip_unlink($lock_file); /* break the stale lock */
165
-			$tries++;
166
-			/* It is CRITICAL that we sleep after breaking
163
+        if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) {
164
+            spip_unlink($lock_file); /* break the stale lock */
165
+            $tries++;
166
+            /* It is CRITICAL that we sleep after breaking
167 167
 			 * the lock. Otherwise, we could race with
168 168
 			 * another process and unlink it's newly-
169 169
 			 * created file.
170 170
 			 */
171
-			sleep(1 + rand(0, 4));
172
-			continue;
173
-		}
171
+            sleep(1 + rand(0, 4));
172
+            continue;
173
+        }
174 174
 
175
-		/*
175
+        /*
176 176
 		 * 5. try again
177 177
 		 */
178 178
 
179
-		$tries++;
180
-		sleep(1 + rand(0, 4));
181
-	}
179
+        $tries++;
180
+        sleep(1 + rand(0, 4));
181
+    }
182 182
 
183
-	/*
183
+    /*
184 184
 	 * 6. give up, failure.
185 185
 	 */
186 186
 
187
-	spip_unlink($tpath);
188
-	@fclose($tmpfd);
187
+    spip_unlink($tpath);
188
+    @fclose($tmpfd);
189 189
 
190
-	return false; //(NFSL_LOCKED);
190
+    return false; //(NFSL_LOCKED);
191 191
 }
192 192
 
193 193
 /**
@@ -231,73 +231,73 @@  discard block
 block discarded – undo
231 231
  * return bool true si déverrouillé, false sinon
232 232
  */
233 233
 function spip_nfsunlock($fichier, $birth, $max_age = 0, $test = false) {
234
-	$id = creer_uniqid();
235
-	if (!$max_age) {
236
-		$max_age = _DEFAULT_LOCKTIME;
237
-	}
234
+    $id = creer_uniqid();
235
+    if (!$max_age) {
236
+        $max_age = _DEFAULT_LOCKTIME;
237
+    }
238 238
 
239
-	/*
239
+    /*
240 240
 	 * 1. Build a temp file and stat that to get an idea of what the server
241 241
 	 *    thinks the current time is (our_tmp.st_ctime)..
242 242
 	 */
243 243
 
244
-	$tpath = _DIR_TMP . "stime.$id";
245
-	$tmpfd = @fopen($tpath, 'w');
246
-	if ((!$tmpfd)
247
-		or (@fputs($tmpfd, 'zz', 2) != 2)
248
-		or !($our_tmp = fstat($tmpfd))
249
-	) {
250
-		/* The open failed, or we can't write the file, or we can't stat it */
251
-		@fclose($tmpfd);
252
-		spip_unlink($tpath);
244
+    $tpath = _DIR_TMP . "stime.$id";
245
+    $tmpfd = @fopen($tpath, 'w');
246
+    if ((!$tmpfd)
247
+        or (@fputs($tmpfd, 'zz', 2) != 2)
248
+        or !($our_tmp = fstat($tmpfd))
249
+    ) {
250
+        /* The open failed, or we can't write the file, or we can't stat it */
251
+        @fclose($tmpfd);
252
+        spip_unlink($tpath);
253 253
 
254
-		return false; //(NFSL_SYSF);
255
-	}
254
+        return false; //(NFSL_SYSF);
255
+    }
256 256
 
257
-	@fclose($tmpfd);    /* We don't need this once we have our_tmp.st_ctime. */
258
-	spip_unlink($tpath);
257
+    @fclose($tmpfd);    /* We don't need this once we have our_tmp.st_ctime. */
258
+    spip_unlink($tpath);
259 259
 
260
-	/*
260
+    /*
261 261
 	 * 2. make fullpath, a buffer for the full pathname of the lock file
262 262
 	 */
263 263
 
264
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
264
+    $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
265 265
 
266
-	/*
266
+    /*
267 267
 	 * 3. If the ctime hasn't been modified, unlink the file and return. If the
268 268
 	 *    lock has expired, sleep the usual random interval before returning.
269 269
 	 *    If we didn't sleep, there could be a race if the caller immediately
270 270
 	 *    tries to relock the file.
271 271
 	 */
272 272
 
273
-	if (($old_stat = @lstat($lock_file))  /* stat succeeds so file is there */
274
-		&& ($old_stat['ctime'] == $birth)
275
-	) {  /* hasn't been modified since birth */
276
-		if (!$test) {
277
-			spip_unlink($lock_file);
278
-		}      /* so the lock is ours to remove */
279
-		if ($our_tmp['ctime'] >= $birth + $max_age) {  /* the lock has expired */
280
-			if (!$test) {
281
-				return false;
282
-			} //(NFSL_LOST);
283
-			sleep(1 + (random(0, 4)));    /* so sleep a bit */
284
-		}
285
-
286
-		return true;//(NFSL_OK);			/* success */
287
-	}
288
-
289
-	/*
273
+    if (($old_stat = @lstat($lock_file))  /* stat succeeds so file is there */
274
+        && ($old_stat['ctime'] == $birth)
275
+    ) {  /* hasn't been modified since birth */
276
+        if (!$test) {
277
+            spip_unlink($lock_file);
278
+        }      /* so the lock is ours to remove */
279
+        if ($our_tmp['ctime'] >= $birth + $max_age) {  /* the lock has expired */
280
+            if (!$test) {
281
+                return false;
282
+            } //(NFSL_LOST);
283
+            sleep(1 + (random(0, 4)));    /* so sleep a bit */
284
+        }
285
+
286
+        return true;//(NFSL_OK);			/* success */
287
+    }
288
+
289
+    /*
290 290
 	 * 4. Either ctime has been modified, or the entire lock file is missing.
291 291
 	 *    If the lock should still be ours, based on the ctime of the temp
292 292
 	 *    file, return with NFSL_STOLEN. If not, then our lock is expired and
293 293
 	 *    someone else has grabbed the file, so return NFSL_LOST.
294 294
 	 */
295 295
 
296
-	if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */
297
-		return false;
298
-	} //(NFSL_STOLEN);
296
+    if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */
297
+        return false;
298
+    } //(NFSL_STOLEN);
299 299
 
300
-	return false; //(NFSL_LOST);	/* The lock must have expired first. */
300
+    return false; //(NFSL_LOST);	/* The lock must have expired first. */
301 301
 }
302 302
 
303 303
 
@@ -321,5 +321,5 @@  discard block
 block discarded – undo
321 321
  * return bool true si déverrouillé, false sinon
322 322
  */
323 323
 function spip_nfslock_test($fichier, $birth, $max_age = 0) {
324
-	return spip_nfsunlock($fichier, $birth, $max_age, true);
324
+    return spip_nfsunlock($fichier, $birth, $max_age, true);
325 325
 }
Please login to merge, or discard this patch.
ecrire/inc/roles.php 1 patch
Indentation   +184 added lines, -184 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  */
29 29
 
30 30
 if (!defined('_ECRIRE_INC_VERSION')) {
31
-	return;
31
+    return;
32 32
 }
33 33
 
34 34
 
@@ -48,55 +48,55 @@  discard block
 block discarded – undo
48 48
  *     array : description des roles applicables dans 3 index : colonne, titres, roles
49 49
  **/
50 50
 function roles_presents($objet, $objet_destination = '') {
51
-	$desc = lister_tables_objets_sql(table_objet_sql($objet));
52
-
53
-	// pas de liste de roles, on sort
54
-	if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) {
55
-		return false;
56
-	}
57
-
58
-	// on vérifie que la table de liaison existe
59
-	include_spip('action/editer_liens');
60
-	if (!$lien = objet_associable($objet)) {
61
-		return false;
62
-	}
63
-
64
-	// on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role')
65
-	$colonne = isset($desc['roles_colonne']) ? $desc['roles_colonne'] : 'role';
66
-	$trouver_table = charger_fonction('trouver_table', 'base');
67
-	list(, $table_lien) = $lien;
68
-	$desc_lien = $trouver_table($table_lien);
69
-	if (!isset($desc_lien['field'][$colonne])) {
70
-		return false;
71
-	}
72
-
73
-	// sur quoi peuvent s'appliquer nos rôles
74
-	if (!$application = $desc['roles_objets']) {
75
-		return false;
76
-	}
77
-
78
-	// destination presente, on restreint si possible
79
-	if ($objet_destination) {
80
-		$objet_destination = table_objet($objet_destination);
81
-
82
-		// pour l'objet
83
-		if (isset($application[$objet_destination])) {
84
-			$application = $application[$objet_destination];
85
-			// sinon pour tous les objets
86
-		} elseif (isset($application['*'])) {
87
-			$application = $application['*'];
88
-		} // sinon tant pis
89
-		else {
90
-			return false;
91
-		}
92
-	}
93
-
94
-	// tout est ok
95
-	return array(
96
-		'titres' => $titres,
97
-		'roles' => $application,
98
-		'colonne' => $colonne
99
-	);
51
+    $desc = lister_tables_objets_sql(table_objet_sql($objet));
52
+
53
+    // pas de liste de roles, on sort
54
+    if (!isset($desc['roles_titres']) or !($titres = $desc['roles_titres'])) {
55
+        return false;
56
+    }
57
+
58
+    // on vérifie que la table de liaison existe
59
+    include_spip('action/editer_liens');
60
+    if (!$lien = objet_associable($objet)) {
61
+        return false;
62
+    }
63
+
64
+    // on cherche ensuite si la colonne existe bien dans la table de liaison (par défaut 'role')
65
+    $colonne = isset($desc['roles_colonne']) ? $desc['roles_colonne'] : 'role';
66
+    $trouver_table = charger_fonction('trouver_table', 'base');
67
+    list(, $table_lien) = $lien;
68
+    $desc_lien = $trouver_table($table_lien);
69
+    if (!isset($desc_lien['field'][$colonne])) {
70
+        return false;
71
+    }
72
+
73
+    // sur quoi peuvent s'appliquer nos rôles
74
+    if (!$application = $desc['roles_objets']) {
75
+        return false;
76
+    }
77
+
78
+    // destination presente, on restreint si possible
79
+    if ($objet_destination) {
80
+        $objet_destination = table_objet($objet_destination);
81
+
82
+        // pour l'objet
83
+        if (isset($application[$objet_destination])) {
84
+            $application = $application[$objet_destination];
85
+            // sinon pour tous les objets
86
+        } elseif (isset($application['*'])) {
87
+            $application = $application['*'];
88
+        } // sinon tant pis
89
+        else {
90
+            return false;
91
+        }
92
+    }
93
+
94
+    // tout est ok
95
+    return array(
96
+        'titres' => $titres,
97
+        'roles' => $application,
98
+        'colonne' => $colonne
99
+    );
100 100
 }
101 101
 
102 102
 /**
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
  *     Nom de la colonne, sinon vide
111 111
  **/
112 112
 function roles_colonne($objet, $objet_destination) {
113
-	if ($roles = roles_presents($objet, $objet_destination)) {
114
-		return $roles['colonne'];
115
-	}
113
+    if ($roles = roles_presents($objet, $objet_destination)) {
114
+        return $roles['colonne'];
115
+    }
116 116
 
117
-	return '';
117
+    return '';
118 118
 }
119 119
 
120 120
 
@@ -136,23 +136,23 @@  discard block
 block discarded – undo
136 136
  *     Liste ('', '', array()) sinon.
137 137
  **/
138 138
 function roles_trouver_dans_qualif($objet, $objet_destination, $qualif = array()) {
139
-	// si des rôles sont possibles, on les utilise
140
-	$role = $colonne_role = ''; # role défini
141
-	// condition du where par defaut
142
-	$cond = array();
143
-	if ($roles = roles_presents($objet, $objet_destination)) {
144
-		$colonne_role = $roles['colonne'];
145
-		// qu'il n'est pas défini
146
-		if (!isset($qualif[$colonne_role])
147
-			or !($role = $qualif[$colonne_role])
148
-		) {
149
-			$role = $roles['roles']['defaut'];
150
-		}
151
-		// where
152
-		$cond = array("$colonne_role=" . sql_quote($role));
153
-	}
154
-
155
-	return array($role, $colonne_role, $cond);
139
+    // si des rôles sont possibles, on les utilise
140
+    $role = $colonne_role = ''; # role défini
141
+    // condition du where par defaut
142
+    $cond = array();
143
+    if ($roles = roles_presents($objet, $objet_destination)) {
144
+        $colonne_role = $roles['colonne'];
145
+        // qu'il n'est pas défini
146
+        if (!isset($qualif[$colonne_role])
147
+            or !($role = $qualif[$colonne_role])
148
+        ) {
149
+            $role = $roles['roles']['defaut'];
150
+        }
151
+        // where
152
+        $cond = array("$colonne_role=" . sql_quote($role));
153
+    }
154
+
155
+    return array($role, $colonne_role, $cond);
156 156
 }
157 157
 
158 158
 /**
@@ -174,21 +174,21 @@  discard block
 block discarded – undo
174 174
  *     Liste (Tableau de conditions where complété du role, Colonne du role, role utilisé)
175 175
  **/
176 176
 function roles_creer_condition_role($objet_source, $objet, $cond, $tous_si_absent = false) {
177
-	// role par défaut, colonne
178
-	list($role_defaut, $colonne_role) = roles_trouver_dans_qualif($objet_source, $objet);
177
+    // role par défaut, colonne
178
+    list($role_defaut, $colonne_role) = roles_trouver_dans_qualif($objet_source, $objet);
179 179
 
180
-	// chercher d'eventuels rôles transmis
181
-	$role = (isset($cond['role']) ? $cond['role'] : ($tous_si_absent ? '*' : $role_defaut));
182
-	unset($cond['role']); // cette condition est particuliere...
180
+    // chercher d'eventuels rôles transmis
181
+    $role = (isset($cond['role']) ? $cond['role'] : ($tous_si_absent ? '*' : $role_defaut));
182
+    unset($cond['role']); // cette condition est particuliere...
183 183
 
184
-	if ($colonne_role) {
185
-		// on ajoute la condition du role aux autres conditions.
186
-		if ($role != '*') {
187
-			$cond[] = "$colonne_role=" . sql_quote($role);
188
-		}
189
-	}
184
+    if ($colonne_role) {
185
+        // on ajoute la condition du role aux autres conditions.
186
+        if ($role != '*') {
187
+            $cond[] = "$colonne_role=" . sql_quote($role);
188
+        }
189
+    }
190 190
 
191
-	return array($cond, $colonne_role, $role);
191
+    return array($cond, $colonne_role, $role);
192 192
 }
193 193
 
194 194
 /**
@@ -210,28 +210,28 @@  discard block
 block discarded – undo
210 210
  */
211 211
 function roles_complets($objet_source, $objet, $id_objet, $objet_lien) {
212 212
 
213
-	$presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
214
-	// pas de roles sur ces objets => la liste par defaut, comme sans role
215
-	if ($presents === false) {
216
-		return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien);
217
-	}
218
-
219
-	// types de roles possibles
220
-	$roles_possibles = $presents['roles']['roles']['choix'];
221
-	// couples id / roles
222
-	$ids = $presents['ids'];
223
-
224
-	// pour chaque groupe, on fait le diff entre tous les roles possibles
225
-	// et les roles attribués à l'élément : s'il en reste, c'est que l'élément
226
-	// n'est pas complet
227
-	$complets = array();
228
-	foreach ($ids as $id => $roles_presents) {
229
-		if (!array_diff($roles_possibles, $roles_presents)) {
230
-			$complets[] = $id;
231
-		}
232
-	}
233
-
234
-	return $complets;
213
+    $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
214
+    // pas de roles sur ces objets => la liste par defaut, comme sans role
215
+    if ($presents === false) {
216
+        return lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien);
217
+    }
218
+
219
+    // types de roles possibles
220
+    $roles_possibles = $presents['roles']['roles']['choix'];
221
+    // couples id / roles
222
+    $ids = $presents['ids'];
223
+
224
+    // pour chaque groupe, on fait le diff entre tous les roles possibles
225
+    // et les roles attribués à l'élément : s'il en reste, c'est que l'élément
226
+    // n'est pas complet
227
+    $complets = array();
228
+    foreach ($ids as $id => $roles_presents) {
229
+        if (!array_diff($roles_possibles, $roles_presents)) {
230
+            $complets[] = $id;
231
+        }
232
+    }
233
+
234
+    return $complets;
235 235
 }
236 236
 
237 237
 
@@ -248,17 +248,17 @@  discard block
 block discarded – undo
248 248
  */
249 249
 function roles_presents_sur_id($id_objet_source, $objet_source, $objet, $id_objet, $objet_lien) {
250 250
 
251
-	$presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
252
-	// pas de roles sur ces objets => la liste par defaut, comme sans role
253
-	if ($presents === false) {
254
-		return array();
255
-	}
251
+    $presents = roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien);
252
+    // pas de roles sur ces objets => la liste par defaut, comme sans role
253
+    if ($presents === false) {
254
+        return array();
255
+    }
256 256
 
257
-	if (!isset($presents['ids'][$id_objet_source])) {
258
-		return array();
259
-	}
257
+    if (!isset($presents['ids'][$id_objet_source])) {
258
+        return array();
259
+    }
260 260
 
261
-	return $presents['ids'][$id_objet_source];
261
+    return $presents['ids'][$id_objet_source];
262 262
 }
263 263
 
264 264
 
@@ -286,47 +286,47 @@  discard block
 block discarded – undo
286 286
  *     - False si pas de role déclarés
287 287
  */
288 288
 function roles_presents_liaisons($objet_source, $objet, $id_objet, $objet_lien) {
289
-	static $done = array();
290
-
291
-	// stocker le résultat
292
-	$hash = "$objet_source-$objet-$id_objet-$objet_lien";
293
-	if (isset($done[$hash])) {
294
-		return $done[$hash];
295
-	}
296
-
297
-	// pas de roles sur ces objets, on sort
298
-	$roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
299
-	if (!$roles) {
300
-		return $done[$hash] = false;
301
-	}
302
-
303
-	// inspiré de lister_objets_lies()
304
-	if ($objet_lien == $objet) {
305
-		$res = objet_trouver_liens(array($objet => $id_objet), array($objet_source => '*'));
306
-	} else {
307
-		$res = objet_trouver_liens(array($objet_source => '*'), array($objet => $id_objet));
308
-	}
309
-
310
-	// types de roles possibles
311
-	$roles_possibles = $roles['roles']['choix'];
312
-	// colonne du role
313
-	$colonne = $roles['colonne'];
314
-
315
-	// on recupere par id, et role existant
316
-	$ids = array();
317
-	while ($row = array_shift($res)) {
318
-		$id = $row[$objet_source];
319
-		if (!isset($ids[$id])) {
320
-			$ids[$id] = array();
321
-		}
322
-		// tableau des roles présents
323
-		$ids[$id][] = $row[$colonne];
324
-	}
325
-
326
-	return $done[$hash] = array(
327
-		'roles' => $roles,
328
-		'ids' => $ids
329
-	);
289
+    static $done = array();
290
+
291
+    // stocker le résultat
292
+    $hash = "$objet_source-$objet-$id_objet-$objet_lien";
293
+    if (isset($done[$hash])) {
294
+        return $done[$hash];
295
+    }
296
+
297
+    // pas de roles sur ces objets, on sort
298
+    $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
299
+    if (!$roles) {
300
+        return $done[$hash] = false;
301
+    }
302
+
303
+    // inspiré de lister_objets_lies()
304
+    if ($objet_lien == $objet) {
305
+        $res = objet_trouver_liens(array($objet => $id_objet), array($objet_source => '*'));
306
+    } else {
307
+        $res = objet_trouver_liens(array($objet_source => '*'), array($objet => $id_objet));
308
+    }
309
+
310
+    // types de roles possibles
311
+    $roles_possibles = $roles['roles']['choix'];
312
+    // colonne du role
313
+    $colonne = $roles['colonne'];
314
+
315
+    // on recupere par id, et role existant
316
+    $ids = array();
317
+    while ($row = array_shift($res)) {
318
+        $id = $row[$objet_source];
319
+        if (!isset($ids[$id])) {
320
+            $ids[$id] = array();
321
+        }
322
+        // tableau des roles présents
323
+        $ids[$id][] = $row[$colonne];
324
+    }
325
+
326
+    return $done[$hash] = array(
327
+        'roles' => $roles,
328
+        'ids' => $ids
329
+    );
330 330
 }
331 331
 
332 332
 
@@ -344,33 +344,33 @@  discard block
 block discarded – undo
344 344
  *     - false si pas de role déclarés
345 345
  */
346 346
 function roles_connus_en_base($objet_source, $objet, $objet_lien) {
347
-	static $done = array();
348
-
349
-	// stocker le résultat
350
-	$hash = "$objet_source-$objet-$objet_lien";
351
-	if (isset($done[$hash])) {
352
-		return $done[$hash];
353
-	}
354
-
355
-	if (!$lien = objet_associable($objet_lien)) {
356
-		return $done[$hash] = false;
357
-	}
358
-
359
-	// pas de roles sur ces objets, on sort
360
-	$roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
361
-	if (!$roles) {
362
-		return $done[$hash] = false;
363
-	}
364
-
365
-	list($primary, $l) = $lien;
366
-	$colone_role = $roles['colonne'];
367
-
368
-	$all = sql_allfetsel(
369
-		"DISTINCT $colone_role",
370
-		$l,
371
-		'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
372
-	);
373
-	$done[$hash] = array_map('reset', $all);
374
-
375
-	return $done[$hash];
347
+    static $done = array();
348
+
349
+    // stocker le résultat
350
+    $hash = "$objet_source-$objet-$objet_lien";
351
+    if (isset($done[$hash])) {
352
+        return $done[$hash];
353
+    }
354
+
355
+    if (!$lien = objet_associable($objet_lien)) {
356
+        return $done[$hash] = false;
357
+    }
358
+
359
+    // pas de roles sur ces objets, on sort
360
+    $roles = roles_presents($objet_lien, ($objet_lien == $objet) ? $objet_source : $objet);
361
+    if (!$roles) {
362
+        return $done[$hash] = false;
363
+    }
364
+
365
+    list($primary, $l) = $lien;
366
+    $colone_role = $roles['colonne'];
367
+
368
+    $all = sql_allfetsel(
369
+        "DISTINCT $colone_role",
370
+        $l,
371
+        'objet=' . sql_quote(($objet_source == $objet_lien) ? $objet : $objet_source)
372
+    );
373
+    $done[$hash] = array_map('reset', $all);
374
+
375
+    return $done[$hash];
376 376
 }
Please login to merge, or discard this patch.