Completed
Push — master ( a11830...c9d2a2 )
by cam
01:14
created
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 [];
51
-	}
52
-	$changed = false;
48
+    $edition = @unserialize($GLOBALS['meta']['drapeau_edition']);
49
+    if (!$edition) {
50
+        return [];
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,22 +117,22 @@  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();
126
+    $edition = lire_tableau_edition();
127 127
 	
128
-	$nom = $auteur['nom'] ?? $GLOBALS['ip'];
129
-	$id_a = $auteur['id_auteur'] ?? $GLOBALS['ip'];
128
+    $nom = $auteur['nom'] ?? $GLOBALS['ip'];
129
+    $id_a = $auteur['id_auteur'] ?? $GLOBALS['ip'];
130 130
 
131
-	if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) {
132
-		$edition[$type][$id] = [];
133
-	}
134
-	$edition[$type][$id][$id_a][$nom] = time();
135
-	ecrire_tableau_edition($edition);
131
+    if (!isset($edition[$type][$id]) or !is_array($edition[$type][$id])) {
132
+        $edition[$type][$id] = [];
133
+    }
134
+    $edition[$type][$id][$id_a][$nom] = time();
135
+    ecrire_tableau_edition($edition);
136 136
 }
137 137
 
138 138
 /**
@@ -149,9 +149,9 @@  discard block
 block discarded – undo
149 149
  */
150 150
 function qui_edite($id, $type = 'article') {
151 151
 
152
-	$edition = lire_tableau_edition();
152
+    $edition = lire_tableau_edition();
153 153
 
154
-	return empty($edition[$type][$id]) ? [] : $edition[$type][$id];
154
+    return empty($edition[$type][$id]) ? [] : $edition[$type][$id];
155 155
 }
156 156
 
157 157
 /**
@@ -165,23 +165,23 @@  discard block
 block discarded – undo
165 165
  *     Liste de tableaux `['nom_auteur_modif' => x|y|z, 'date_diff' => n]`
166 166
  */
167 167
 function mention_qui_edite($id, $type = 'article'): array {
168
-	$modif = qui_edite($id, $type);
169
-	unset($modif[$GLOBALS['visiteur_session']['id_auteur']]);
168
+    $modif = qui_edite($id, $type);
169
+    unset($modif[$GLOBALS['visiteur_session']['id_auteur']]);
170 170
 
171
-	if ($modif) {
172
-		$quand = 0;
173
-		foreach ($modif as $duo) {
174
-			$auteurs[] = typo(key($duo));
175
-			$quand = max($quand, current($duo));
176
-		}
171
+    if ($modif) {
172
+        $quand = 0;
173
+        foreach ($modif as $duo) {
174
+            $auteurs[] = typo(key($duo));
175
+            $quand = max($quand, current($duo));
176
+        }
177 177
 
178
-		// format lie a la chaine de langue 'avis_article_modifie'
179
-		return [
180
-			'nom_auteur_modif' => join(' | ', $auteurs),
181
-			'date_diff' => ceil((time() - $quand) / 60)
182
-		];
183
-	}
184
-	return [];
178
+        // format lie a la chaine de langue 'avis_article_modifie'
179
+        return [
180
+            'nom_auteur_modif' => join(' | ', $auteurs),
181
+            'date_diff' => ceil((time() - $quand) / 60)
182
+        ];
183
+    }
184
+    return [];
185 185
 }
186 186
 
187 187
 /**
@@ -195,25 +195,25 @@  discard block
 block discarded – undo
195 195
  *     Liste de tableaux `['objet' => x, 'id_objet' => n]`
196 196
  */
197 197
 function liste_drapeau_edition($id_auteur) {
198
-	$edition = lire_tableau_edition();
199
-	$objets_ouverts = [];
198
+    $edition = lire_tableau_edition();
199
+    $objets_ouverts = [];
200 200
 
201
-	foreach ($edition as $objet => $data) {
202
-		foreach ($data as $id => $auteurs) {
203
-			if (
204
-				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[] = [
209
-					'objet' => $objet,
210
-					'id_objet' => $id,
211
-				];
212
-			}
213
-		}
214
-	}
201
+    foreach ($edition as $objet => $data) {
202
+        foreach ($data as $id => $auteurs) {
203
+            if (
204
+                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[] = [
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,19 +252,19 @@  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 (
261
-					$id == $id_objet
262
-					and isset($auteurs[$id_auteur])
263
-				) {
264
-					unset($edition[$objet][$id][$id_auteur]);
265
-					ecrire_tableau_edition($edition);
266
-				}
267
-			}
268
-		}
269
-	}
257
+    foreach ($edition as $objet => $data) {
258
+        if ($objet == $type) {
259
+            foreach ($data as $id => $auteurs) {
260
+                if (
261
+                    $id == $id_objet
262
+                    and isset($auteurs[$id_auteur])
263
+                ) {
264
+                    unset($edition[$objet][$id][$id_auteur]);
265
+                    ecrire_tableau_edition($edition);
266
+                }
267
+            }
268
+        }
269
+    }
270 270
 }
Please login to merge, or discard this patch.