@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | /** |
@@ -39,28 +39,28 @@ discard block |
||
| 39 | 39 | * Tableau des champs et valeurs collectées |
| 40 | 40 | */ |
| 41 | 41 | function collecter_requests($include_list, $exclude_list = [], $set = null, $tous = false) { |
| 42 | - $c = $set; |
|
| 43 | - if (!$c) { |
|
| 44 | - $c = []; |
|
| 45 | - foreach ($include_list as $champ) { |
|
| 46 | - // on ne collecte que les champs reellement envoyes par defaut. |
|
| 47 | - // le cas d'un envoi de valeur NULL peut du coup poser probleme. |
|
| 48 | - $val = _request($champ); |
|
| 49 | - if ($tous or $val !== null) { |
|
| 50 | - $c[$champ] = $val; |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - // on ajoute toujours la lang en saisie possible |
|
| 54 | - // meme si pas prevu au depart pour l'objet concerne |
|
| 55 | - if ($l = _request('changer_lang')) { |
|
| 56 | - $c['lang'] = $l; |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - foreach ($exclude_list as $champ) { |
|
| 60 | - unset($c[$champ]); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - return $c; |
|
| 42 | + $c = $set; |
|
| 43 | + if (!$c) { |
|
| 44 | + $c = []; |
|
| 45 | + foreach ($include_list as $champ) { |
|
| 46 | + // on ne collecte que les champs reellement envoyes par defaut. |
|
| 47 | + // le cas d'un envoi de valeur NULL peut du coup poser probleme. |
|
| 48 | + $val = _request($champ); |
|
| 49 | + if ($tous or $val !== null) { |
|
| 50 | + $c[$champ] = $val; |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + // on ajoute toujours la lang en saisie possible |
|
| 54 | + // meme si pas prevu au depart pour l'objet concerne |
|
| 55 | + if ($l = _request('changer_lang')) { |
|
| 56 | + $c['lang'] = $l; |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + foreach ($exclude_list as $champ) { |
|
| 60 | + unset($c[$champ]); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + return $c; |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -97,238 +97,238 @@ discard block |
||
| 97 | 97 | * - chaîne : Texte d'un message d'erreur |
| 98 | 98 | */ |
| 99 | 99 | function objet_modifier_champs($objet, $id_objet, $options, $c = null, $serveur = '') { |
| 100 | - if (!$id_objet = intval($id_objet)) { |
|
| 101 | - spip_log('Erreur $id_objet non defini', 'warn'); |
|
| 102 | - |
|
| 103 | - return _T('erreur_technique_enregistrement_impossible'); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - include_spip('inc/filtres'); |
|
| 107 | - |
|
| 108 | - $table_objet = table_objet($objet, $serveur); |
|
| 109 | - $spip_table_objet = table_objet_sql($objet, $serveur); |
|
| 110 | - $id_table_objet = id_table_objet($objet, $serveur); |
|
| 111 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 112 | - $desc = $trouver_table($spip_table_objet, $serveur); |
|
| 113 | - |
|
| 114 | - // Appels incomplets (sans $c) |
|
| 115 | - if (!is_array($c)) { |
|
| 116 | - spip_log('erreur appel objet_modifier_champs(' . $objet . '), manque $c'); |
|
| 117 | - |
|
| 118 | - return _T('erreur_technique_enregistrement_impossible'); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // Securite : certaines variables ne sont jamais acceptees ici |
|
| 122 | - // car elles ne relevent pas de autoriser(xxx, modifier) ; |
|
| 123 | - // il faut passer par instituer_XX() |
|
| 124 | - // TODO: faut-il passer ces variables interdites |
|
| 125 | - // dans un fichier de description separe ? |
|
| 126 | - unset($c['statut']); |
|
| 127 | - unset($c['id_parent']); |
|
| 128 | - unset($c['id_rubrique']); |
|
| 129 | - unset($c['id_secteur']); |
|
| 130 | - |
|
| 131 | - // Gerer les champs non vides |
|
| 132 | - if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 133 | - foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 134 | - if (isset($c[$champ]) and $c[$champ] === '') { |
|
| 135 | - $c[$champ] = $sinon; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - // N'accepter que les champs qui existent |
|
| 141 | - // TODO: ici aussi on peut valider les contenus |
|
| 142 | - // en fonction du type |
|
| 143 | - $champs = array_intersect_key($c, $desc['field']); |
|
| 144 | - |
|
| 145 | - // Nettoyer les valeurs |
|
| 146 | - $champs = array_map('corriger_caracteres', $champs); |
|
| 147 | - |
|
| 148 | - // On récupère l'état avant toute modification |
|
| 149 | - $row = sql_fetsel('*', $spip_table_objet, $id_table_objet . '=' . $id_objet); |
|
| 150 | - |
|
| 151 | - // Envoyer aux plugins |
|
| 152 | - $champs = pipeline( |
|
| 153 | - 'pre_edition', |
|
| 154 | - [ |
|
| 155 | - 'args' => [ |
|
| 156 | - 'table' => $spip_table_objet, // compatibilite |
|
| 157 | - 'table_objet' => $table_objet, |
|
| 158 | - 'spip_table_objet' => $spip_table_objet, |
|
| 159 | - 'desc' => $desc, |
|
| 160 | - 'type' => $objet, |
|
| 161 | - 'id_objet' => $id_objet, |
|
| 162 | - 'data' => $options['data'] ?? null, |
|
| 163 | - 'champs' => $options['champs'] ?? [], // [doc] c'est quoi ? |
|
| 164 | - 'champs_anciens' => $row, // état du contenu avant modif |
|
| 165 | - 'serveur' => $serveur, |
|
| 166 | - 'action' => $options['action'] ?? 'modifier' |
|
| 167 | - ], |
|
| 168 | - 'data' => $champs |
|
| 169 | - ] |
|
| 170 | - ); |
|
| 171 | - |
|
| 172 | - if (!$champs) { |
|
| 173 | - return false; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - // marquer le fait que l'objet est travaille par toto a telle date |
|
| 178 | - include_spip('inc/config'); |
|
| 179 | - if (lire_config('articles_modif', 'non') !== 'non') { |
|
| 180 | - include_spip('inc/drapeau_edition'); |
|
| 181 | - signale_edition($id_objet, $GLOBALS['visiteur_session'], $objet); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 185 | - include_spip('inc/editer'); |
|
| 186 | - if (!isset($options['data']) or is_null($options['data'])) { |
|
| 187 | - $options['data'] = &$_POST; |
|
| 188 | - } |
|
| 189 | - $conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur); |
|
| 190 | - // cas hypothetique : normalement inc/editer verifie en amont le conflit edition |
|
| 191 | - // et gere l'interface |
|
| 192 | - // ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme |
|
| 193 | - if ($conflits) { |
|
| 194 | - return _T('titre_conflit_edition'); |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - if ($champs) { |
|
| 198 | - // cas particulier de la langue : passer par instituer_langue_objet |
|
| 199 | - if (isset($champs['lang'])) { |
|
| 200 | - if ($changer_lang = $champs['lang']) { |
|
| 201 | - $id_rubrique = 0; |
|
| 202 | - if (isset($desc['field']['id_rubrique'])) { |
|
| 203 | - $parent = ($objet == 'rubrique') ? 'id_parent' : 'id_rubrique'; |
|
| 204 | - $id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=" . intval($id_objet)); |
|
| 205 | - } |
|
| 206 | - $instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action'); |
|
| 207 | - $champs['lang'] = $instituer_langue_objet($objet, $id_objet, $id_rubrique, $changer_lang, $serveur); |
|
| 208 | - } |
|
| 209 | - // on laisse 'lang' dans $champs, |
|
| 210 | - // ca permet de passer dans le pipeline post_edition et de journaliser |
|
| 211 | - // et ca ne gene pas qu'on refasse un sql_updateq dessus apres l'avoir |
|
| 212 | - // deja pris en compte |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - // la modif peut avoir lieu |
|
| 216 | - |
|
| 217 | - // faut-il ajouter date_modif ? |
|
| 218 | - if ( |
|
| 219 | - !empty($options['date_modif']) |
|
| 220 | - and !isset($champs[$options['date_modif']]) |
|
| 221 | - ) { |
|
| 222 | - $champs[$options['date_modif']] = date('Y-m-d H:i:s'); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - // allez on commit la modif |
|
| 226 | - sql_updateq($spip_table_objet, $champs, "$id_table_objet=" . intval($id_objet), [], $serveur); |
|
| 227 | - |
|
| 228 | - // on verifie si elle est bien passee |
|
| 229 | - $moof = sql_fetsel( |
|
| 230 | - array_keys($champs), |
|
| 231 | - $spip_table_objet, |
|
| 232 | - "$id_table_objet=" . intval($id_objet), |
|
| 233 | - [], |
|
| 234 | - [], |
|
| 235 | - '', |
|
| 236 | - [], |
|
| 237 | - $serveur |
|
| 238 | - ); |
|
| 239 | - // si difference entre les champs, reperer les champs mal enregistres |
|
| 240 | - if ($moof != $champs) { |
|
| 241 | - $liste = []; |
|
| 242 | - foreach ($moof as $k => $v) { |
|
| 243 | - if ( |
|
| 244 | - $v !== $champs[$k] |
|
| 245 | - // ne pas alerter si le champ est numerique est que les valeurs sont equivalentes |
|
| 246 | - and (!is_numeric($v) or intval($v) !== intval($champs[$k])) |
|
| 247 | - // ne pas alerter si le champ est date, qu'on a envoye une valeur vide et qu'on recupere une date nulle |
|
| 248 | - and (strlen($champs[$k]) or !in_array($v, ['0000-00-00 00:00:00', '0000-00-00'])) |
|
| 249 | - ) { |
|
| 250 | - $liste[] = $k; |
|
| 251 | - $conflits[$k]['post'] = $champs[$k]; |
|
| 252 | - $conflits[$k]['save'] = $v; |
|
| 253 | - |
|
| 254 | - // cas specifique MySQL+emoji : si l'un est la |
|
| 255 | - // conversion utf8_noplanes de l'autre alors c'est OK |
|
| 256 | - if (defined('_MYSQL_NOPLANES') && _MYSQL_NOPLANES) { |
|
| 257 | - include_spip('inc/charsets'); |
|
| 258 | - if ($v == utf8_noplanes($champs[$k])) { |
|
| 259 | - array_pop($liste); |
|
| 260 | - } |
|
| 261 | - } |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - // si un champ n'a pas ete correctement enregistre, loger et retourner une erreur |
|
| 265 | - // c'est un cas exceptionnel |
|
| 266 | - if (count($liste)) { |
|
| 267 | - spip_log( |
|
| 268 | - "Erreur enregistrement en base $objet/$id_objet champs :" . var_export($conflits, true), |
|
| 269 | - 'modifier.' . _LOG_CRITIQUE |
|
| 270 | - ); |
|
| 271 | - |
|
| 272 | - return _T( |
|
| 273 | - 'erreur_technique_enregistrement_champs', |
|
| 274 | - ['champs' => "<i>'" . implode("'</i>,<i>'", $liste) . "'</i>"] |
|
| 275 | - ); |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - // Invalider les caches |
|
| 280 | - if (isset($options['invalideur']) and $options['invalideur']) { |
|
| 281 | - include_spip('inc/invalideur'); |
|
| 282 | - if (is_array($options['invalideur'])) { |
|
| 283 | - array_map('suivre_invalideur', $options['invalideur']); |
|
| 284 | - } else { |
|
| 285 | - suivre_invalideur($options['invalideur']); |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - // Notifications, gestion des revisions... |
|
| 290 | - // en standard, appelle |nouvelle_revision ci-dessous |
|
| 291 | - pipeline( |
|
| 292 | - 'post_edition', |
|
| 293 | - [ |
|
| 294 | - 'args' => [ |
|
| 295 | - 'table' => $spip_table_objet, |
|
| 296 | - 'table_objet' => $table_objet, |
|
| 297 | - 'spip_table_objet' => $spip_table_objet, |
|
| 298 | - 'desc' => $desc, |
|
| 299 | - 'type' => $objet, |
|
| 300 | - 'id_objet' => $id_objet, |
|
| 301 | - 'champs' => $options['champs'] ?? [], // [doc] kesako ? |
|
| 302 | - 'champs_anciens' => $row, // état du contenu avant modif |
|
| 303 | - 'serveur' => $serveur, |
|
| 304 | - 'action' => $options['action'] ?? 'modifier' |
|
| 305 | - ], |
|
| 306 | - 'data' => $champs |
|
| 307 | - ] |
|
| 308 | - ); |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - // journaliser l'affaire |
|
| 312 | - // message a affiner :-) |
|
| 313 | - include_spip('inc/filtres_mini'); |
|
| 314 | - $qui = ''; |
|
| 315 | - if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 316 | - $qui .= ' #id_auteur:' . $GLOBALS['visiteur_session']['id_auteur'] . '#'; |
|
| 317 | - } |
|
| 318 | - if (!empty($GLOBALS['visiteur_session']['nom'])) { |
|
| 319 | - $qui .= ' #nom:' . $GLOBALS['visiteur_session']['nom'] . '#'; |
|
| 320 | - } |
|
| 321 | - if ($qui == '') { |
|
| 322 | - $qui = '#ip:' . $GLOBALS['ip'] . '#'; |
|
| 323 | - } |
|
| 324 | - journal(_L($qui . ' a édité ' . $objet . ' ' . $id_objet . ' (' . join( |
|
| 325 | - '+', |
|
| 326 | - array_diff(array_keys($champs), ['date_modif']) |
|
| 327 | - ) . ')'), [ |
|
| 328 | - 'faire' => 'modifier', |
|
| 329 | - 'quoi' => $objet, |
|
| 330 | - 'id' => $id_objet |
|
| 331 | - ]); |
|
| 332 | - |
|
| 333 | - return ''; |
|
| 100 | + if (!$id_objet = intval($id_objet)) { |
|
| 101 | + spip_log('Erreur $id_objet non defini', 'warn'); |
|
| 102 | + |
|
| 103 | + return _T('erreur_technique_enregistrement_impossible'); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + include_spip('inc/filtres'); |
|
| 107 | + |
|
| 108 | + $table_objet = table_objet($objet, $serveur); |
|
| 109 | + $spip_table_objet = table_objet_sql($objet, $serveur); |
|
| 110 | + $id_table_objet = id_table_objet($objet, $serveur); |
|
| 111 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 112 | + $desc = $trouver_table($spip_table_objet, $serveur); |
|
| 113 | + |
|
| 114 | + // Appels incomplets (sans $c) |
|
| 115 | + if (!is_array($c)) { |
|
| 116 | + spip_log('erreur appel objet_modifier_champs(' . $objet . '), manque $c'); |
|
| 117 | + |
|
| 118 | + return _T('erreur_technique_enregistrement_impossible'); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // Securite : certaines variables ne sont jamais acceptees ici |
|
| 122 | + // car elles ne relevent pas de autoriser(xxx, modifier) ; |
|
| 123 | + // il faut passer par instituer_XX() |
|
| 124 | + // TODO: faut-il passer ces variables interdites |
|
| 125 | + // dans un fichier de description separe ? |
|
| 126 | + unset($c['statut']); |
|
| 127 | + unset($c['id_parent']); |
|
| 128 | + unset($c['id_rubrique']); |
|
| 129 | + unset($c['id_secteur']); |
|
| 130 | + |
|
| 131 | + // Gerer les champs non vides |
|
| 132 | + if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 133 | + foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 134 | + if (isset($c[$champ]) and $c[$champ] === '') { |
|
| 135 | + $c[$champ] = $sinon; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + // N'accepter que les champs qui existent |
|
| 141 | + // TODO: ici aussi on peut valider les contenus |
|
| 142 | + // en fonction du type |
|
| 143 | + $champs = array_intersect_key($c, $desc['field']); |
|
| 144 | + |
|
| 145 | + // Nettoyer les valeurs |
|
| 146 | + $champs = array_map('corriger_caracteres', $champs); |
|
| 147 | + |
|
| 148 | + // On récupère l'état avant toute modification |
|
| 149 | + $row = sql_fetsel('*', $spip_table_objet, $id_table_objet . '=' . $id_objet); |
|
| 150 | + |
|
| 151 | + // Envoyer aux plugins |
|
| 152 | + $champs = pipeline( |
|
| 153 | + 'pre_edition', |
|
| 154 | + [ |
|
| 155 | + 'args' => [ |
|
| 156 | + 'table' => $spip_table_objet, // compatibilite |
|
| 157 | + 'table_objet' => $table_objet, |
|
| 158 | + 'spip_table_objet' => $spip_table_objet, |
|
| 159 | + 'desc' => $desc, |
|
| 160 | + 'type' => $objet, |
|
| 161 | + 'id_objet' => $id_objet, |
|
| 162 | + 'data' => $options['data'] ?? null, |
|
| 163 | + 'champs' => $options['champs'] ?? [], // [doc] c'est quoi ? |
|
| 164 | + 'champs_anciens' => $row, // état du contenu avant modif |
|
| 165 | + 'serveur' => $serveur, |
|
| 166 | + 'action' => $options['action'] ?? 'modifier' |
|
| 167 | + ], |
|
| 168 | + 'data' => $champs |
|
| 169 | + ] |
|
| 170 | + ); |
|
| 171 | + |
|
| 172 | + if (!$champs) { |
|
| 173 | + return false; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + // marquer le fait que l'objet est travaille par toto a telle date |
|
| 178 | + include_spip('inc/config'); |
|
| 179 | + if (lire_config('articles_modif', 'non') !== 'non') { |
|
| 180 | + include_spip('inc/drapeau_edition'); |
|
| 181 | + signale_edition($id_objet, $GLOBALS['visiteur_session'], $objet); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 185 | + include_spip('inc/editer'); |
|
| 186 | + if (!isset($options['data']) or is_null($options['data'])) { |
|
| 187 | + $options['data'] = &$_POST; |
|
| 188 | + } |
|
| 189 | + $conflits = controler_md5($champs, $options['data'], $objet, $id_objet, $serveur); |
|
| 190 | + // cas hypothetique : normalement inc/editer verifie en amont le conflit edition |
|
| 191 | + // et gere l'interface |
|
| 192 | + // ici on ne renvoie donc qu'un messsage d'erreur, au cas ou on y arrive quand meme |
|
| 193 | + if ($conflits) { |
|
| 194 | + return _T('titre_conflit_edition'); |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + if ($champs) { |
|
| 198 | + // cas particulier de la langue : passer par instituer_langue_objet |
|
| 199 | + if (isset($champs['lang'])) { |
|
| 200 | + if ($changer_lang = $champs['lang']) { |
|
| 201 | + $id_rubrique = 0; |
|
| 202 | + if (isset($desc['field']['id_rubrique'])) { |
|
| 203 | + $parent = ($objet == 'rubrique') ? 'id_parent' : 'id_rubrique'; |
|
| 204 | + $id_rubrique = sql_getfetsel($parent, $spip_table_objet, "$id_table_objet=" . intval($id_objet)); |
|
| 205 | + } |
|
| 206 | + $instituer_langue_objet = charger_fonction('instituer_langue_objet', 'action'); |
|
| 207 | + $champs['lang'] = $instituer_langue_objet($objet, $id_objet, $id_rubrique, $changer_lang, $serveur); |
|
| 208 | + } |
|
| 209 | + // on laisse 'lang' dans $champs, |
|
| 210 | + // ca permet de passer dans le pipeline post_edition et de journaliser |
|
| 211 | + // et ca ne gene pas qu'on refasse un sql_updateq dessus apres l'avoir |
|
| 212 | + // deja pris en compte |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + // la modif peut avoir lieu |
|
| 216 | + |
|
| 217 | + // faut-il ajouter date_modif ? |
|
| 218 | + if ( |
|
| 219 | + !empty($options['date_modif']) |
|
| 220 | + and !isset($champs[$options['date_modif']]) |
|
| 221 | + ) { |
|
| 222 | + $champs[$options['date_modif']] = date('Y-m-d H:i:s'); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + // allez on commit la modif |
|
| 226 | + sql_updateq($spip_table_objet, $champs, "$id_table_objet=" . intval($id_objet), [], $serveur); |
|
| 227 | + |
|
| 228 | + // on verifie si elle est bien passee |
|
| 229 | + $moof = sql_fetsel( |
|
| 230 | + array_keys($champs), |
|
| 231 | + $spip_table_objet, |
|
| 232 | + "$id_table_objet=" . intval($id_objet), |
|
| 233 | + [], |
|
| 234 | + [], |
|
| 235 | + '', |
|
| 236 | + [], |
|
| 237 | + $serveur |
|
| 238 | + ); |
|
| 239 | + // si difference entre les champs, reperer les champs mal enregistres |
|
| 240 | + if ($moof != $champs) { |
|
| 241 | + $liste = []; |
|
| 242 | + foreach ($moof as $k => $v) { |
|
| 243 | + if ( |
|
| 244 | + $v !== $champs[$k] |
|
| 245 | + // ne pas alerter si le champ est numerique est que les valeurs sont equivalentes |
|
| 246 | + and (!is_numeric($v) or intval($v) !== intval($champs[$k])) |
|
| 247 | + // ne pas alerter si le champ est date, qu'on a envoye une valeur vide et qu'on recupere une date nulle |
|
| 248 | + and (strlen($champs[$k]) or !in_array($v, ['0000-00-00 00:00:00', '0000-00-00'])) |
|
| 249 | + ) { |
|
| 250 | + $liste[] = $k; |
|
| 251 | + $conflits[$k]['post'] = $champs[$k]; |
|
| 252 | + $conflits[$k]['save'] = $v; |
|
| 253 | + |
|
| 254 | + // cas specifique MySQL+emoji : si l'un est la |
|
| 255 | + // conversion utf8_noplanes de l'autre alors c'est OK |
|
| 256 | + if (defined('_MYSQL_NOPLANES') && _MYSQL_NOPLANES) { |
|
| 257 | + include_spip('inc/charsets'); |
|
| 258 | + if ($v == utf8_noplanes($champs[$k])) { |
|
| 259 | + array_pop($liste); |
|
| 260 | + } |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + // si un champ n'a pas ete correctement enregistre, loger et retourner une erreur |
|
| 265 | + // c'est un cas exceptionnel |
|
| 266 | + if (count($liste)) { |
|
| 267 | + spip_log( |
|
| 268 | + "Erreur enregistrement en base $objet/$id_objet champs :" . var_export($conflits, true), |
|
| 269 | + 'modifier.' . _LOG_CRITIQUE |
|
| 270 | + ); |
|
| 271 | + |
|
| 272 | + return _T( |
|
| 273 | + 'erreur_technique_enregistrement_champs', |
|
| 274 | + ['champs' => "<i>'" . implode("'</i>,<i>'", $liste) . "'</i>"] |
|
| 275 | + ); |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + // Invalider les caches |
|
| 280 | + if (isset($options['invalideur']) and $options['invalideur']) { |
|
| 281 | + include_spip('inc/invalideur'); |
|
| 282 | + if (is_array($options['invalideur'])) { |
|
| 283 | + array_map('suivre_invalideur', $options['invalideur']); |
|
| 284 | + } else { |
|
| 285 | + suivre_invalideur($options['invalideur']); |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + // Notifications, gestion des revisions... |
|
| 290 | + // en standard, appelle |nouvelle_revision ci-dessous |
|
| 291 | + pipeline( |
|
| 292 | + 'post_edition', |
|
| 293 | + [ |
|
| 294 | + 'args' => [ |
|
| 295 | + 'table' => $spip_table_objet, |
|
| 296 | + 'table_objet' => $table_objet, |
|
| 297 | + 'spip_table_objet' => $spip_table_objet, |
|
| 298 | + 'desc' => $desc, |
|
| 299 | + 'type' => $objet, |
|
| 300 | + 'id_objet' => $id_objet, |
|
| 301 | + 'champs' => $options['champs'] ?? [], // [doc] kesako ? |
|
| 302 | + 'champs_anciens' => $row, // état du contenu avant modif |
|
| 303 | + 'serveur' => $serveur, |
|
| 304 | + 'action' => $options['action'] ?? 'modifier' |
|
| 305 | + ], |
|
| 306 | + 'data' => $champs |
|
| 307 | + ] |
|
| 308 | + ); |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + // journaliser l'affaire |
|
| 312 | + // message a affiner :-) |
|
| 313 | + include_spip('inc/filtres_mini'); |
|
| 314 | + $qui = ''; |
|
| 315 | + if (!empty($GLOBALS['visiteur_session']['id_auteur'])) { |
|
| 316 | + $qui .= ' #id_auteur:' . $GLOBALS['visiteur_session']['id_auteur'] . '#'; |
|
| 317 | + } |
|
| 318 | + if (!empty($GLOBALS['visiteur_session']['nom'])) { |
|
| 319 | + $qui .= ' #nom:' . $GLOBALS['visiteur_session']['nom'] . '#'; |
|
| 320 | + } |
|
| 321 | + if ($qui == '') { |
|
| 322 | + $qui = '#ip:' . $GLOBALS['ip'] . '#'; |
|
| 323 | + } |
|
| 324 | + journal(_L($qui . ' a édité ' . $objet . ' ' . $id_objet . ' (' . join( |
|
| 325 | + '+', |
|
| 326 | + array_diff(array_keys($champs), ['date_modif']) |
|
| 327 | + ) . ')'), [ |
|
| 328 | + 'faire' => 'modifier', |
|
| 329 | + 'quoi' => $objet, |
|
| 330 | + 'id' => $id_objet |
|
| 331 | + ]); |
|
| 332 | + |
|
| 333 | + return ''; |
|
| 334 | 334 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Filtres |
| 17 | 17 | */ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/filtres_boites'); |
@@ -41,25 +41,25 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | function parametres_css_prive() { |
| 43 | 43 | |
| 44 | - $args = []; |
|
| 45 | - $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | - $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | - $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | - $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | - // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | - $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 44 | + $args = []; |
|
| 45 | + $args['v'] = $GLOBALS['spip_version_code']; |
|
| 46 | + $args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4); |
|
| 47 | + $args['themes'] = implode(',', lister_themes_prives()); |
|
| 48 | + $args['ltr'] = $GLOBALS['spip_lang_left']; |
|
| 49 | + // un md5 des menus : si un menu change il faut maj la css |
|
| 50 | + $args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : ''); |
|
| 51 | 51 | |
| 52 | - $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 52 | + $c = $GLOBALS['visiteur_session']['prefs']['couleur'] ?? 2; |
|
| 53 | 53 | |
| 54 | - $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | - parse_str($couleurs($c), $c); |
|
| 56 | - $args = array_merge($args, $c); |
|
| 54 | + $couleurs = charger_fonction('couleurs', 'inc'); |
|
| 55 | + parse_str($couleurs($c), $c); |
|
| 56 | + $args = array_merge($args, $c); |
|
| 57 | 57 | |
| 58 | - if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | - $args['var_mode'] = 'recalcul'; |
|
| 60 | - } |
|
| 58 | + if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) { |
|
| 59 | + $args['var_mode'] = 'recalcul'; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - return http_build_query($args); |
|
| 62 | + return http_build_query($args); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | |
@@ -82,91 +82,91 @@ discard block |
||
| 82 | 82 | * @return string |
| 83 | 83 | */ |
| 84 | 84 | function chercher_rubrique( |
| 85 | - $titre, |
|
| 86 | - $id_objet, |
|
| 87 | - $id_parent, |
|
| 88 | - $objet, |
|
| 89 | - $id_secteur, |
|
| 90 | - $restreint, |
|
| 91 | - $actionable = false, |
|
| 92 | - $retour_sans_cadre = false |
|
| 85 | + $titre, |
|
| 86 | + $id_objet, |
|
| 87 | + $id_parent, |
|
| 88 | + $objet, |
|
| 89 | + $id_secteur, |
|
| 90 | + $restreint, |
|
| 91 | + $actionable = false, |
|
| 92 | + $retour_sans_cadre = false |
|
| 93 | 93 | ) { |
| 94 | 94 | |
| 95 | - include_spip('inc/autoriser'); |
|
| 96 | - if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | - return ''; |
|
| 98 | - } |
|
| 99 | - if (!sql_countsel('spip_rubriques')) { |
|
| 100 | - return ''; |
|
| 101 | - } |
|
| 102 | - $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | - $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | - |
|
| 105 | - if ($id_parent == 0) { |
|
| 106 | - $logo = 'racine-24.png'; |
|
| 107 | - } elseif ($id_secteur == $id_parent) { |
|
| 108 | - $logo = 'secteur-24.png'; |
|
| 109 | - } else { |
|
| 110 | - $logo = 'rubrique-24.png'; |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - $confirm = ''; |
|
| 114 | - if ($objet == 'rubrique') { |
|
| 115 | - // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | - // confirmation du deplacement |
|
| 117 | - $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | - |
|
| 119 | - if ($contient_breves > 0) { |
|
| 120 | - $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | - $scb = _T( |
|
| 122 | - 'avis_deplacement_rubrique', |
|
| 123 | - [ |
|
| 124 | - 'contient_breves' => $contient_breves, |
|
| 125 | - 'scb' => $scb |
|
| 126 | - ] |
|
| 127 | - ); |
|
| 128 | - $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | - . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | - . $scb . |
|
| 131 | - "</label></div></div>\n"; |
|
| 132 | - } else { |
|
| 133 | - $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $form .= $confirm; |
|
| 137 | - if ($actionable) { |
|
| 138 | - if (strpos($form, '<select') !== false) { |
|
| 139 | - $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | - . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | - . '</div>'; |
|
| 142 | - } |
|
| 143 | - $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | - if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | - $form = generer_action_auteur( |
|
| 146 | - "editer_$objet", |
|
| 147 | - $id_objet, |
|
| 148 | - self(), |
|
| 149 | - $form, |
|
| 150 | - " method='post' class='submit_plongeur'" |
|
| 151 | - ); |
|
| 152 | - } else { |
|
| 153 | - $form = generer_action_auteur( |
|
| 154 | - 'editer_objet', |
|
| 155 | - "$objet/$id_objet", |
|
| 156 | - self(), |
|
| 157 | - $form, |
|
| 158 | - " method='post' class='submit_plongeur'" |
|
| 159 | - ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - if ($retour_sans_cadre) { |
|
| 164 | - return $form; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - include_spip('inc/presentation'); |
|
| 168 | - |
|
| 169 | - return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 95 | + include_spip('inc/autoriser'); |
|
| 96 | + if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) { |
|
| 97 | + return ''; |
|
| 98 | + } |
|
| 99 | + if (!sql_countsel('spip_rubriques')) { |
|
| 100 | + return ''; |
|
| 101 | + } |
|
| 102 | + $chercher_rubrique = charger_fonction('chercher_rubrique', 'inc'); |
|
| 103 | + $form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0); |
|
| 104 | + |
|
| 105 | + if ($id_parent == 0) { |
|
| 106 | + $logo = 'racine-24.png'; |
|
| 107 | + } elseif ($id_secteur == $id_parent) { |
|
| 108 | + $logo = 'secteur-24.png'; |
|
| 109 | + } else { |
|
| 110 | + $logo = 'rubrique-24.png'; |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + $confirm = ''; |
|
| 114 | + if ($objet == 'rubrique') { |
|
| 115 | + // si c'est une rubrique-secteur contenant des breves, demander la |
|
| 116 | + // confirmation du deplacement |
|
| 117 | + $contient_breves = sql_countsel('spip_breves', 'id_rubrique=' . intval($id_objet)); |
|
| 118 | + |
|
| 119 | + if ($contient_breves > 0) { |
|
| 120 | + $scb = ($contient_breves > 1 ? 's' : ''); |
|
| 121 | + $scb = _T( |
|
| 122 | + 'avis_deplacement_rubrique', |
|
| 123 | + [ |
|
| 124 | + 'contient_breves' => $contient_breves, |
|
| 125 | + 'scb' => $scb |
|
| 126 | + ] |
|
| 127 | + ); |
|
| 128 | + $confirm .= "\n<div class='confirmer_deplacement verdana2'>" |
|
| 129 | + . "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>" |
|
| 130 | + . $scb . |
|
| 131 | + "</label></div></div>\n"; |
|
| 132 | + } else { |
|
| 133 | + $confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n"; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $form .= $confirm; |
|
| 137 | + if ($actionable) { |
|
| 138 | + if (strpos($form, '<select') !== false) { |
|
| 139 | + $form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>" |
|
| 140 | + . '<input class="fondo submit btn" type="submit" value="' . _T('bouton_choisir') . '"/>' |
|
| 141 | + . '</div>'; |
|
| 142 | + } |
|
| 143 | + $form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form; |
|
| 144 | + if ($action = charger_fonction("editer_$objet", 'action', true)) { |
|
| 145 | + $form = generer_action_auteur( |
|
| 146 | + "editer_$objet", |
|
| 147 | + $id_objet, |
|
| 148 | + self(), |
|
| 149 | + $form, |
|
| 150 | + " method='post' class='submit_plongeur'" |
|
| 151 | + ); |
|
| 152 | + } else { |
|
| 153 | + $form = generer_action_auteur( |
|
| 154 | + 'editer_objet', |
|
| 155 | + "$objet/$id_objet", |
|
| 156 | + self(), |
|
| 157 | + $form, |
|
| 158 | + " method='post' class='submit_plongeur'" |
|
| 159 | + ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + if ($retour_sans_cadre) { |
|
| 164 | + return $form; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + include_spip('inc/presentation'); |
|
| 168 | + |
|
| 169 | + return debut_cadre_couleur($logo, true, '', $titre) . $form . fin_cadre_couleur(); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -180,24 +180,24 @@ discard block |
||
| 180 | 180 | * @return bool |
| 181 | 181 | */ |
| 182 | 182 | function avoir_visiteurs($past = false, $accepter = true) { |
| 183 | - if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | - return true; |
|
| 185 | - } |
|
| 186 | - if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | - return true; |
|
| 188 | - } |
|
| 189 | - if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | - return true; |
|
| 191 | - } |
|
| 192 | - if (!$past) { |
|
| 193 | - return false; |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - return sql_countsel( |
|
| 197 | - 'spip_auteurs', |
|
| 198 | - "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 183 | + if ($GLOBALS['meta']['forums_publics'] == 'abo') { |
|
| 184 | + return true; |
|
| 185 | + } |
|
| 186 | + if ($accepter and $GLOBALS['meta']['accepter_visiteurs'] <> 'non') { |
|
| 187 | + return true; |
|
| 188 | + } |
|
| 189 | + if (sql_countsel('spip_articles', "accepter_forum='abo'")) { |
|
| 190 | + return true; |
|
| 191 | + } |
|
| 192 | + if (!$past) { |
|
| 193 | + return false; |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + return sql_countsel( |
|
| 197 | + 'spip_auteurs', |
|
| 198 | + "statut NOT IN ('0minirezo','1comite', '5poubelle') |
|
| 199 | 199 | AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))" |
| 200 | - ); |
|
| 200 | + ); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /** |
@@ -213,18 +213,18 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | */ |
| 215 | 215 | function statuts_articles_visibles($statut_auteur) { |
| 216 | - static $auth = []; |
|
| 217 | - if (!isset($auth[$statut_auteur])) { |
|
| 218 | - $auth[$statut_auteur] = []; |
|
| 219 | - $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | - foreach ($statuts as $s) { |
|
| 221 | - if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | - $auth[$statut_auteur][] = $s; |
|
| 223 | - } |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - return $auth[$statut_auteur]; |
|
| 216 | + static $auth = []; |
|
| 217 | + if (!isset($auth[$statut_auteur])) { |
|
| 218 | + $auth[$statut_auteur] = []; |
|
| 219 | + $statuts = array_column(sql_allfetsel('distinct statut', 'spip_articles'), 'statut'); |
|
| 220 | + foreach ($statuts as $s) { |
|
| 221 | + if (autoriser('voir', 'article', 0, ['statut' => $statut_auteur], ['statut' => $s])) { |
|
| 222 | + $auth[$statut_auteur][] = $s; |
|
| 223 | + } |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + return $auth[$statut_auteur]; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | 230 | /** |
@@ -238,38 +238,38 @@ discard block |
||
| 238 | 238 | * @return string |
| 239 | 239 | */ |
| 240 | 240 | function traduire_statut_auteur($statut, $attente = '') { |
| 241 | - $plus = ''; |
|
| 242 | - if ($statut == 'nouveau') { |
|
| 243 | - if ($attente) { |
|
| 244 | - $statut = $attente; |
|
| 245 | - $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | - } else { |
|
| 247 | - return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - $recom = [ |
|
| 252 | - 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | - 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | - 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | - '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | - ]; |
|
| 257 | - if (isset($recom[$statut])) { |
|
| 258 | - return $recom[$statut] . $plus; |
|
| 259 | - } |
|
| 260 | - |
|
| 261 | - // retrouver directement par le statut sinon |
|
| 262 | - if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | - if (isset($recom[$t])) { |
|
| 264 | - return $recom[$t] . $plus; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - return _T($t) . $plus; |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | - // c'est toujours plus informatif que rien du tout |
|
| 272 | - return $statut; |
|
| 241 | + $plus = ''; |
|
| 242 | + if ($statut == 'nouveau') { |
|
| 243 | + if ($attente) { |
|
| 244 | + $statut = $attente; |
|
| 245 | + $plus = ' (' . _T('info_statut_auteur_a_confirmer') . ')'; |
|
| 246 | + } else { |
|
| 247 | + return _T('info_statut_auteur_a_confirmer'); |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + $recom = [ |
|
| 252 | + 'info_administrateurs' => _T('item_administrateur_2'), |
|
| 253 | + 'info_redacteurs' => _T('intem_redacteur'), |
|
| 254 | + 'info_visiteurs' => _T('item_visiteur'), |
|
| 255 | + '5poubelle' => _T('texte_statut_poubelle'), // bouh |
|
| 256 | + ]; |
|
| 257 | + if (isset($recom[$statut])) { |
|
| 258 | + return $recom[$statut] . $plus; |
|
| 259 | + } |
|
| 260 | + |
|
| 261 | + // retrouver directement par le statut sinon |
|
| 262 | + if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) { |
|
| 263 | + if (isset($recom[$t])) { |
|
| 264 | + return $recom[$t] . $plus; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + return _T($t) . $plus; |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + // si on a pas reussi a le traduire, retournons la chaine telle quelle |
|
| 271 | + // c'est toujours plus informatif que rien du tout |
|
| 272 | + return $statut; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -280,29 +280,29 @@ discard block |
||
| 280 | 280 | * @return string |
| 281 | 281 | */ |
| 282 | 282 | function afficher_qui_edite($id_objet, $objet): string { |
| 283 | - static $qui = []; |
|
| 284 | - if (isset($qui[$objet][$id_objet])) { |
|
| 285 | - return $qui[$objet][$id_objet]; |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - include_spip('inc/config'); |
|
| 289 | - if (lire_config('articles_modif', 'non') === 'non') { |
|
| 290 | - return $qui[$objet][$id_objet] = ''; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - include_spip('inc/drapeau_edition'); |
|
| 294 | - $modif = mention_qui_edite($id_objet, $objet); |
|
| 295 | - if (!$modif) { |
|
| 296 | - return $qui[$objet][$id_objet] = ''; |
|
| 297 | - } |
|
| 298 | - |
|
| 299 | - include_spip('base/objets'); |
|
| 300 | - $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 301 | - if (isset($infos['texte_signale_edition'])) { |
|
| 302 | - return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 303 | - } |
|
| 304 | - |
|
| 305 | - return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 283 | + static $qui = []; |
|
| 284 | + if (isset($qui[$objet][$id_objet])) { |
|
| 285 | + return $qui[$objet][$id_objet]; |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + include_spip('inc/config'); |
|
| 289 | + if (lire_config('articles_modif', 'non') === 'non') { |
|
| 290 | + return $qui[$objet][$id_objet] = ''; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + include_spip('inc/drapeau_edition'); |
|
| 294 | + $modif = mention_qui_edite($id_objet, $objet); |
|
| 295 | + if (!$modif) { |
|
| 296 | + return $qui[$objet][$id_objet] = ''; |
|
| 297 | + } |
|
| 298 | + |
|
| 299 | + include_spip('base/objets'); |
|
| 300 | + $infos = lister_tables_objets_sql(table_objet_sql($objet)); |
|
| 301 | + if (isset($infos['texte_signale_edition'])) { |
|
| 302 | + return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif); |
|
| 303 | + } |
|
| 304 | + |
|
| 305 | + return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif); |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -320,53 +320,53 @@ discard block |
||
| 320 | 320 | * @return array |
| 321 | 321 | */ |
| 322 | 322 | function auteurs_lister_statuts($quoi = 'tous', $en_base = true): array { |
| 323 | - if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 324 | - define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 325 | - } |
|
| 326 | - |
|
| 327 | - switch ($quoi) { |
|
| 328 | - case 'redacteurs': |
|
| 329 | - $statut = AUTEURS_MIN_REDAC; |
|
| 330 | - $statut = explode(',', $statut); |
|
| 331 | - if ($en_base) { |
|
| 332 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 333 | - $retire = array_diff($statut, $check); |
|
| 334 | - $statut = array_diff($statut, $retire); |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - return array_unique($statut); |
|
| 338 | - |
|
| 339 | - case 'visiteurs': |
|
| 340 | - $statut = []; |
|
| 341 | - $exclus = AUTEURS_MIN_REDAC; |
|
| 342 | - $exclus = explode(',', $exclus); |
|
| 343 | - if (!$en_base) { |
|
| 344 | - // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 345 | - $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 346 | - } |
|
| 347 | - $s_complement = array_column( |
|
| 348 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 349 | - 'statut' |
|
| 350 | - ); |
|
| 351 | - |
|
| 352 | - return array_unique(array_merge($statut, $s_complement)); |
|
| 353 | - |
|
| 354 | - default: |
|
| 355 | - case 'tous': |
|
| 356 | - $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 357 | - $s_complement = array_column( |
|
| 358 | - sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 359 | - 'statut' |
|
| 360 | - ); |
|
| 361 | - $statut = array_merge($statut, $s_complement); |
|
| 362 | - if ($en_base) { |
|
| 363 | - $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 364 | - $retire = array_diff($statut, $check); |
|
| 365 | - $statut = array_diff($statut, $retire); |
|
| 366 | - } |
|
| 367 | - |
|
| 368 | - return array_unique($statut); |
|
| 369 | - } |
|
| 323 | + if (!defined('AUTEURS_MIN_REDAC')) { |
|
| 324 | + define('AUTEURS_MIN_REDAC', '0minirezo,1comite,5poubelle'); |
|
| 325 | + } |
|
| 326 | + |
|
| 327 | + switch ($quoi) { |
|
| 328 | + case 'redacteurs': |
|
| 329 | + $statut = AUTEURS_MIN_REDAC; |
|
| 330 | + $statut = explode(',', $statut); |
|
| 331 | + if ($en_base) { |
|
| 332 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 333 | + $retire = array_diff($statut, $check); |
|
| 334 | + $statut = array_diff($statut, $retire); |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + return array_unique($statut); |
|
| 338 | + |
|
| 339 | + case 'visiteurs': |
|
| 340 | + $statut = []; |
|
| 341 | + $exclus = AUTEURS_MIN_REDAC; |
|
| 342 | + $exclus = explode(',', $exclus); |
|
| 343 | + if (!$en_base) { |
|
| 344 | + // prendre aussi les statuts de la table des status qui ne sont pas dans le define |
|
| 345 | + $statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus); |
|
| 346 | + } |
|
| 347 | + $s_complement = array_column( |
|
| 348 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')), |
|
| 349 | + 'statut' |
|
| 350 | + ); |
|
| 351 | + |
|
| 352 | + return array_unique(array_merge($statut, $s_complement)); |
|
| 353 | + |
|
| 354 | + default: |
|
| 355 | + case 'tous': |
|
| 356 | + $statut = array_values($GLOBALS['liste_des_statuts']); |
|
| 357 | + $s_complement = array_column( |
|
| 358 | + sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')), |
|
| 359 | + 'statut' |
|
| 360 | + ); |
|
| 361 | + $statut = array_merge($statut, $s_complement); |
|
| 362 | + if ($en_base) { |
|
| 363 | + $check = array_column(sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)), 'statut'); |
|
| 364 | + $retire = array_diff($statut, $check); |
|
| 365 | + $statut = array_diff($statut, $retire); |
|
| 366 | + } |
|
| 367 | + |
|
| 368 | + return array_unique($statut); |
|
| 369 | + } |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | /** |
@@ -382,28 +382,28 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | function trouver_rubrique_creer_objet($id_rubrique, $objet) { |
| 384 | 384 | |
| 385 | - if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 386 | - $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 387 | - ? '' |
|
| 388 | - : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 389 | - |
|
| 390 | - // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 391 | - if ($objet == 'rubrique') { |
|
| 392 | - $id_rubrique = 0; |
|
| 393 | - } else { |
|
| 394 | - $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 395 | - } |
|
| 396 | - |
|
| 397 | - if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 398 | - // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 399 | - $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 400 | - while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 401 | - $id_rubrique = $row_rub['id_rubrique']; |
|
| 402 | - } |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - return $id_rubrique; |
|
| 385 | + if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) { |
|
| 386 | + $in = !(is_countable($GLOBALS['connect_id_rubrique']) ? count($GLOBALS['connect_id_rubrique']) : 0) |
|
| 387 | + ? '' |
|
| 388 | + : (' AND ' . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique'])); |
|
| 389 | + |
|
| 390 | + // on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement |
|
| 391 | + if ($objet == 'rubrique') { |
|
| 392 | + $id_rubrique = 0; |
|
| 393 | + } else { |
|
| 394 | + $id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', 'id_rubrique DESC', 1); |
|
| 395 | + } |
|
| 396 | + |
|
| 397 | + if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) { |
|
| 398 | + // manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises |
|
| 399 | + $res = sql_select('id_rubrique', 'spip_rubriques', 'id_parent=0'); |
|
| 400 | + while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) { |
|
| 401 | + $id_rubrique = $row_rub['id_rubrique']; |
|
| 402 | + } |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + return $id_rubrique; |
|
| 407 | 407 | } |
| 408 | 408 | |
| 409 | 409 | /** |
@@ -414,12 +414,12 @@ discard block |
||
| 414 | 414 | * @return string |
| 415 | 415 | */ |
| 416 | 416 | function lien_article_virtuel($virtuel) { |
| 417 | - include_spip('inc/lien'); |
|
| 418 | - if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 419 | - return ''; |
|
| 420 | - } |
|
| 417 | + include_spip('inc/lien'); |
|
| 418 | + if (!$virtuel = virtuel_redirige($virtuel)) { |
|
| 419 | + return ''; |
|
| 420 | + } |
|
| 421 | 421 | |
| 422 | - return propre('[->' . $virtuel . ']'); |
|
| 422 | + return propre('[->' . $virtuel . ']'); |
|
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | |
@@ -442,11 +442,11 @@ discard block |
||
| 442 | 442 | * @filtre |
| 443 | 443 | */ |
| 444 | 444 | function bouton_spip_rss($op, $args = [], $lang = '', $title = 'RSS') { |
| 445 | - include_spip('inc/acces'); |
|
| 446 | - $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 445 | + include_spip('inc/acces'); |
|
| 446 | + $clic = http_img_pack('rss-16.png', 'RSS', '', $title); |
|
| 447 | 447 | |
| 448 | - $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 449 | - return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 448 | + $url = generer_url_api_low_sec('transmettre', 'rss', $op, '', http_build_query($args), false, true); |
|
| 449 | + return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>"; |
|
| 450 | 450 | } |
| 451 | 451 | |
| 452 | 452 | |
@@ -458,76 +458,76 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | function alertes_auteur($id_auteur): string { |
| 460 | 460 | |
| 461 | - $alertes = []; |
|
| 462 | - |
|
| 463 | - if ( |
|
| 464 | - isset($GLOBALS['meta']['message_crash_tables']) |
|
| 465 | - and autoriser('detruire', null, null, $id_auteur) |
|
| 466 | - ) { |
|
| 467 | - include_spip('genie/maintenance'); |
|
| 468 | - if ($msg = message_crash_tables()) { |
|
| 469 | - $alertes[] = $msg; |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - if ( |
|
| 474 | - isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 475 | - and $GLOBALS['meta']['message_crash_plugins'] |
|
| 476 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 477 | - and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 478 | - ) { |
|
| 479 | - $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 480 | - $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 484 | - if ( |
|
| 485 | - $a |
|
| 486 | - and is_array($a = unserialize($a)) |
|
| 487 | - and count($a) |
|
| 488 | - ) { |
|
| 489 | - $update = false; |
|
| 490 | - if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 491 | - $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | - unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 493 | - $update = true; |
|
| 494 | - } |
|
| 495 | - if (isset($a[''])) { |
|
| 496 | - $alertes = array_merge($alertes, $a['']); |
|
| 497 | - unset($a['']); |
|
| 498 | - $update = true; |
|
| 499 | - } |
|
| 500 | - if ($update) { |
|
| 501 | - ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 502 | - } |
|
| 503 | - } |
|
| 504 | - |
|
| 505 | - if ( |
|
| 506 | - isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 507 | - and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 508 | - ) { |
|
| 509 | - include_spip('inc/plugin'); |
|
| 510 | - $alertes[] = plugin_donne_erreurs(); |
|
| 511 | - } |
|
| 512 | - |
|
| 513 | - $alertes = pipeline( |
|
| 514 | - 'alertes_auteur', |
|
| 515 | - [ |
|
| 516 | - 'args' => [ |
|
| 517 | - 'id_auteur' => $id_auteur, |
|
| 518 | - 'exec' => _request('exec'), |
|
| 519 | - ], |
|
| 520 | - 'data' => $alertes |
|
| 521 | - ] |
|
| 522 | - ); |
|
| 523 | - |
|
| 524 | - if ($alertes = array_filter($alertes)) { |
|
| 525 | - return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 526 | - join(' | ', $alertes) |
|
| 527 | - . '</div></div>'; |
|
| 528 | - } |
|
| 529 | - |
|
| 530 | - return ''; |
|
| 461 | + $alertes = []; |
|
| 462 | + |
|
| 463 | + if ( |
|
| 464 | + isset($GLOBALS['meta']['message_crash_tables']) |
|
| 465 | + and autoriser('detruire', null, null, $id_auteur) |
|
| 466 | + ) { |
|
| 467 | + include_spip('genie/maintenance'); |
|
| 468 | + if ($msg = message_crash_tables()) { |
|
| 469 | + $alertes[] = $msg; |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + if ( |
|
| 474 | + isset($GLOBALS['meta']['message_crash_plugins']) |
|
| 475 | + and $GLOBALS['meta']['message_crash_plugins'] |
|
| 476 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 477 | + and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins'])) |
|
| 478 | + ) { |
|
| 479 | + $msg = implode(', ', array_map('joli_repertoire', array_keys($msg))); |
|
| 480 | + $alertes[] = _T('plugins_erreur', ['plugins' => $msg]); |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + $a = $GLOBALS['meta']['message_alertes_auteurs'] ?? ''; |
|
| 484 | + if ( |
|
| 485 | + $a |
|
| 486 | + and is_array($a = unserialize($a)) |
|
| 487 | + and count($a) |
|
| 488 | + ) { |
|
| 489 | + $update = false; |
|
| 490 | + if (isset($a[$GLOBALS['visiteur_session']['statut']])) { |
|
| 491 | + $alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]); |
|
| 492 | + unset($a[$GLOBALS['visiteur_session']['statut']]); |
|
| 493 | + $update = true; |
|
| 494 | + } |
|
| 495 | + if (isset($a[''])) { |
|
| 496 | + $alertes = array_merge($alertes, $a['']); |
|
| 497 | + unset($a['']); |
|
| 498 | + $update = true; |
|
| 499 | + } |
|
| 500 | + if ($update) { |
|
| 501 | + ecrire_meta('message_alertes_auteurs', serialize($a)); |
|
| 502 | + } |
|
| 503 | + } |
|
| 504 | + |
|
| 505 | + if ( |
|
| 506 | + isset($GLOBALS['meta']['plugin_erreur_activation']) |
|
| 507 | + and autoriser('configurer', '_plugins', null, $id_auteur) |
|
| 508 | + ) { |
|
| 509 | + include_spip('inc/plugin'); |
|
| 510 | + $alertes[] = plugin_donne_erreurs(); |
|
| 511 | + } |
|
| 512 | + |
|
| 513 | + $alertes = pipeline( |
|
| 514 | + 'alertes_auteur', |
|
| 515 | + [ |
|
| 516 | + 'args' => [ |
|
| 517 | + 'id_auteur' => $id_auteur, |
|
| 518 | + 'exec' => _request('exec'), |
|
| 519 | + ], |
|
| 520 | + 'data' => $alertes |
|
| 521 | + ] |
|
| 522 | + ); |
|
| 523 | + |
|
| 524 | + if ($alertes = array_filter($alertes)) { |
|
| 525 | + return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" . |
|
| 526 | + join(' | ', $alertes) |
|
| 527 | + . '</div></div>'; |
|
| 528 | + } |
|
| 529 | + |
|
| 530 | + return ''; |
|
| 531 | 531 | } |
| 532 | 532 | |
| 533 | 533 | /** |
@@ -537,9 +537,9 @@ discard block |
||
| 537 | 537 | * @return string |
| 538 | 538 | */ |
| 539 | 539 | function filtre_afficher_enfant_rub_dist($id_rubrique) { |
| 540 | - include_spip('inc/presenter_enfants'); |
|
| 540 | + include_spip('inc/presenter_enfants'); |
|
| 541 | 541 | |
| 542 | - return afficher_enfant_rub(intval($id_rubrique)); |
|
| 542 | + return afficher_enfant_rub(intval($id_rubrique)); |
|
| 543 | 543 | } |
| 544 | 544 | |
| 545 | 545 | /** |
@@ -557,15 +557,15 @@ discard block |
||
| 557 | 557 | * @return string |
| 558 | 558 | */ |
| 559 | 559 | function afficher_plus_info($lien, $titre = '+', $titre_lien = '') { |
| 560 | - $titre = attribut_html($titre); |
|
| 561 | - $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 562 | - http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 563 | - |
|
| 564 | - if (!$titre_lien) { |
|
| 565 | - return $icone; |
|
| 566 | - } else { |
|
| 567 | - return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | - } |
|
| 560 | + $titre = attribut_html($titre); |
|
| 561 | + $icone = "\n<a href='$lien' title='$titre' class='plus_info'>" . |
|
| 562 | + http_img_pack('information-16.png', $titre) . '</a>'; |
|
| 563 | + |
|
| 564 | + if (!$titre_lien) { |
|
| 565 | + return $icone; |
|
| 566 | + } else { |
|
| 567 | + return $icone . "\n<a href='$lien'>$titre_lien</a>"; |
|
| 568 | + } |
|
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | |
@@ -584,22 +584,22 @@ discard block |
||
| 584 | 584 | * @return array |
| 585 | 585 | */ |
| 586 | 586 | function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) { |
| 587 | - $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 588 | - if (!(is_countable($res) ? count($res) : 0)) { |
|
| 589 | - return []; |
|
| 590 | - } |
|
| 591 | - $r = reset($res); |
|
| 592 | - if (isset($r['rang_lien'])) { |
|
| 593 | - $l = array_column($res, 'rang_lien', $objet_source); |
|
| 594 | - asort($l); |
|
| 595 | - $l = array_keys($l); |
|
| 596 | - } else { |
|
| 597 | - // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 598 | - // Sinon c'est dans "id_objet" |
|
| 599 | - $l = array_column( |
|
| 600 | - $res, |
|
| 601 | - $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 602 | - ); |
|
| 603 | - } |
|
| 604 | - return $l; |
|
| 587 | + $res = lister_objets_liens($objet_source, $objet, $id_objet, $objet_lien); |
|
| 588 | + if (!(is_countable($res) ? count($res) : 0)) { |
|
| 589 | + return []; |
|
| 590 | + } |
|
| 591 | + $r = reset($res); |
|
| 592 | + if (isset($r['rang_lien'])) { |
|
| 593 | + $l = array_column($res, 'rang_lien', $objet_source); |
|
| 594 | + asort($l); |
|
| 595 | + $l = array_keys($l); |
|
| 596 | + } else { |
|
| 597 | + // Si les liens qu'on cherche sont ceux de la table de lien, l'info est dans la clé de l'objet |
|
| 598 | + // Sinon c'est dans "id_objet" |
|
| 599 | + $l = array_column( |
|
| 600 | + $res, |
|
| 601 | + $objet_source == $objet_lien ? id_table_objet($objet_source) : 'id_objet' |
|
| 602 | + ); |
|
| 603 | + } |
|
| 604 | + return $l; |
|
| 605 | 605 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Affichage |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | * @return string Code HTML |
| 26 | 26 | */ |
| 27 | 27 | function debut_grand_cadre() { |
| 28 | - return "\n<div class = 'table_page'>\n"; |
|
| 28 | + return "\n<div class = 'table_page'>\n"; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | /** |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @return string Code HTML |
| 35 | 35 | */ |
| 36 | 36 | function fin_grand_cadre() { |
| 37 | - return "\n</div>"; |
|
| 37 | + return "\n</div>"; |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | // Debut de la colonne de gauche |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @return string Code HTML |
| 50 | 50 | */ |
| 51 | 51 | function debut_gauche() { |
| 52 | - return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n"; |
|
| 52 | + return "<div id = 'conteneur' class = ''>\n<div id = 'navigation' class = 'lat' role = 'contentinfo'>\n"; |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @return string Code HTML |
| 59 | 59 | */ |
| 60 | 60 | function fin_gauche() { |
| 61 | - return "</div></div><br class = 'nettoyeur' />"; |
|
| 61 | + return "</div></div><br class = 'nettoyeur' />"; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * @return string Code HTML |
| 68 | 68 | */ |
| 69 | 69 | function creer_colonne_droite() { |
| 70 | - static $deja_colonne_droite; |
|
| 71 | - if ($deja_colonne_droite) { |
|
| 72 | - return ''; |
|
| 73 | - } |
|
| 74 | - $deja_colonne_droite = true; |
|
| 70 | + static $deja_colonne_droite; |
|
| 71 | + if ($deja_colonne_droite) { |
|
| 72 | + return ''; |
|
| 73 | + } |
|
| 74 | + $deja_colonne_droite = true; |
|
| 75 | 75 | |
| 76 | - return "\n</div><div id='extra' class='lat' role='complementary'>"; |
|
| 76 | + return "\n</div><div id='extra' class='lat' role='complementary'>"; |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -82,10 +82,10 @@ discard block |
||
| 82 | 82 | * @return string Code HTML |
| 83 | 83 | */ |
| 84 | 84 | function debut_droite() { |
| 85 | - return liste_objets_bloques(_request('exec')) |
|
| 86 | - . creer_colonne_droite() |
|
| 87 | - . '</div>' |
|
| 88 | - . "\n<div id='contenu'>"; |
|
| 85 | + return liste_objets_bloques(_request('exec')) |
|
| 86 | + . creer_colonne_droite() |
|
| 87 | + . '</div>' |
|
| 88 | + . "\n<div id='contenu'>"; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
@@ -107,32 +107,32 @@ discard block |
||
| 107 | 107 | * Code HTML |
| 108 | 108 | **/ |
| 109 | 109 | function liste_objets_bloques($exec, $contexte = [], $auteur = null): string { |
| 110 | - $res = ''; |
|
| 111 | - include_spip('inc/config'); |
|
| 112 | - if (lire_config('articles_modif', 'non') !== 'non') { |
|
| 113 | - include_spip('inc/drapeau_edition'); |
|
| 114 | - if (is_null($auteur)) { |
|
| 115 | - $auteur = $GLOBALS['visiteur_session']; |
|
| 116 | - } |
|
| 117 | - if ( |
|
| 118 | - $en_cours = trouver_objet_exec($exec) |
|
| 119 | - and $en_cours['edition'] |
|
| 120 | - and $type = $en_cours['type'] |
|
| 121 | - and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']]) |
|
| 122 | - or $id = _request($en_cours['id_table_objet'])) |
|
| 123 | - ) { |
|
| 124 | - // marquer le fait que l'objet est ouvert en edition par toto |
|
| 125 | - // a telle date ; une alerte sera donnee aux autres redacteurs |
|
| 126 | - signale_edition($id, $auteur, $type); |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
|
| 130 | - if (count($objets_ouverts)) { |
|
| 131 | - $res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]); |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - return $res; |
|
| 110 | + $res = ''; |
|
| 111 | + include_spip('inc/config'); |
|
| 112 | + if (lire_config('articles_modif', 'non') !== 'non') { |
|
| 113 | + include_spip('inc/drapeau_edition'); |
|
| 114 | + if (is_null($auteur)) { |
|
| 115 | + $auteur = $GLOBALS['visiteur_session']; |
|
| 116 | + } |
|
| 117 | + if ( |
|
| 118 | + $en_cours = trouver_objet_exec($exec) |
|
| 119 | + and $en_cours['edition'] |
|
| 120 | + and $type = $en_cours['type'] |
|
| 121 | + and ((isset($contexte[$en_cours['id_table_objet']]) and $id = $contexte[$en_cours['id_table_objet']]) |
|
| 122 | + or $id = _request($en_cours['id_table_objet'])) |
|
| 123 | + ) { |
|
| 124 | + // marquer le fait que l'objet est ouvert en edition par toto |
|
| 125 | + // a telle date ; une alerte sera donnee aux autres redacteurs |
|
| 126 | + signale_edition($id, $auteur, $type); |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + $objets_ouverts = liste_drapeau_edition($auteur['id_auteur']); |
|
| 130 | + if (count($objets_ouverts)) { |
|
| 131 | + $res .= recuperer_fond('prive/objets/liste/objets-en-edition', [], ['ajax' => true]); |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + return $res; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -146,20 +146,20 @@ discard block |
||
| 146 | 146 | * @return string Code HTML |
| 147 | 147 | **/ |
| 148 | 148 | function fin_page() { |
| 149 | - include_spip('inc/pipelines'); |
|
| 150 | - // avec &var_profile=1 on a le tableau de mesures SQL |
|
| 151 | - $debug = ((_request('exec') !== 'valider_xml') |
|
| 152 | - and ((_request('var_mode') == 'debug') |
|
| 153 | - or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps']) |
|
| 154 | - and isset($_COOKIE['spip_admin']))); |
|
| 155 | - $t = '</div><div id="pied"><div class="largeur">' |
|
| 156 | - . recuperer_fond('prive/squelettes/inclure/pied') |
|
| 157 | - . '</div>' |
|
| 158 | - . '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
|
| 159 | - . ($debug ? erreur_squelette() : '') |
|
| 160 | - . "</body></html>\n"; |
|
| 161 | - |
|
| 162 | - return f_queue($t); |
|
| 149 | + include_spip('inc/pipelines'); |
|
| 150 | + // avec &var_profile=1 on a le tableau de mesures SQL |
|
| 151 | + $debug = ((_request('exec') !== 'valider_xml') |
|
| 152 | + and ((_request('var_mode') == 'debug') |
|
| 153 | + or (isset($GLOBALS['tableau_des_temps']) and $GLOBALS['tableau_des_temps']) |
|
| 154 | + and isset($_COOKIE['spip_admin']))); |
|
| 155 | + $t = '</div><div id="pied"><div class="largeur">' |
|
| 156 | + . recuperer_fond('prive/squelettes/inclure/pied') |
|
| 157 | + . '</div>' |
|
| 158 | + . '</div></div>' // cf. div#page et div.largeur ouvertes dans conmmencer_page() |
|
| 159 | + . ($debug ? erreur_squelette() : '') |
|
| 160 | + . "</body></html>\n"; |
|
| 161 | + |
|
| 162 | + return f_queue($t); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | /** |
@@ -174,22 +174,22 @@ discard block |
||
| 174 | 174 | * @return string Code HTML |
| 175 | 175 | **/ |
| 176 | 176 | function html_tests_js() { |
| 177 | - if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) { |
|
| 178 | - // pour le pied de page (deja defini si on est validation XML) |
|
| 179 | - define( |
|
| 180 | - '_TESTER_NOSCRIPT', |
|
| 181 | - "<noscript>\n<div style='display:none;'><img src='" |
|
| 182 | - . generer_url_ecrire('test_ajax', 'js=-1') |
|
| 183 | - . "' width='1' height='1' alt='' /></div></noscript>\n" |
|
| 184 | - ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - $rejouer = ''; |
|
| 188 | - if (defined('_SESSION_REJOUER')) { |
|
| 189 | - $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER; |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 177 | + if (_SPIP_AJAX and !defined('_TESTER_NOSCRIPT')) { |
|
| 178 | + // pour le pied de page (deja defini si on est validation XML) |
|
| 179 | + define( |
|
| 180 | + '_TESTER_NOSCRIPT', |
|
| 181 | + "<noscript>\n<div style='display:none;'><img src='" |
|
| 182 | + . generer_url_ecrire('test_ajax', 'js=-1') |
|
| 183 | + . "' width='1' height='1' alt='' /></div></noscript>\n" |
|
| 184 | + ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + $rejouer = ''; |
|
| 188 | + if (defined('_SESSION_REJOUER')) { |
|
| 189 | + $rejouer = (_SESSION_REJOUER === true) ? rejouer_session() : _SESSION_REJOUER; |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + return $rejouer . (defined('_TESTER_NOSCRIPT') ? _TESTER_NOSCRIPT : ''); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | /** |
@@ -199,25 +199,25 @@ discard block |
||
| 199 | 199 | **/ |
| 200 | 200 | function info_maj_spip() { |
| 201 | 201 | |
| 202 | - $maj = $GLOBALS['meta']['info_maj_spip'] ?? null; |
|
| 203 | - if (!$maj) { |
|
| 204 | - return ''; |
|
| 205 | - } |
|
| 202 | + $maj = $GLOBALS['meta']['info_maj_spip'] ?? null; |
|
| 203 | + if (!$maj) { |
|
| 204 | + return ''; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - $maj = explode('|', $maj); |
|
| 208 | - // c'est une ancienne notif, on a fait la maj depuis ! |
|
| 209 | - if ($GLOBALS['spip_version_branche'] !== reset($maj)) { |
|
| 210 | - return ''; |
|
| 211 | - } |
|
| 207 | + $maj = explode('|', $maj); |
|
| 208 | + // c'est une ancienne notif, on a fait la maj depuis ! |
|
| 209 | + if ($GLOBALS['spip_version_branche'] !== reset($maj)) { |
|
| 210 | + return ''; |
|
| 211 | + } |
|
| 212 | 212 | |
| 213 | - if (!autoriser('webmestre')) { |
|
| 214 | - return ''; |
|
| 215 | - } |
|
| 213 | + if (!autoriser('webmestre')) { |
|
| 214 | + return ''; |
|
| 215 | + } |
|
| 216 | 216 | |
| 217 | - array_shift($maj); |
|
| 218 | - $maj = implode('|', $maj); |
|
| 217 | + array_shift($maj); |
|
| 218 | + $maj = implode('|', $maj); |
|
| 219 | 219 | |
| 220 | - return "$maj<br />"; |
|
| 220 | + return "$maj<br />"; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -228,47 +228,47 @@ discard block |
||
| 228 | 228 | **/ |
| 229 | 229 | function info_copyright() { |
| 230 | 230 | |
| 231 | - $version = $GLOBALS['spip_version_affichee']; |
|
| 232 | - |
|
| 233 | - // |
|
| 234 | - // Mention, le cas echeant, de la revision SVN courante |
|
| 235 | - // |
|
| 236 | - if ($vcs = version_vcs_courante(_DIR_RACINE, true)) { |
|
| 237 | - if ($vcs['vcs'] === 'GIT') { |
|
| 238 | - $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit']; |
|
| 239 | - } elseif ($vcs['vcs'] === 'SVN') { |
|
| 240 | - $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit']; |
|
| 241 | - } else { |
|
| 242 | - $url = ''; |
|
| 243 | - } |
|
| 244 | - // affichage "GIT [master: abcdef]" |
|
| 245 | - $commit = $vcs['commit_short'] ?? $vcs['commit']; |
|
| 246 | - if ($url) { |
|
| 247 | - $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>"; |
|
| 248 | - } |
|
| 249 | - if ($vcs['branch']) { |
|
| 250 | - $commit = $vcs['branch'] . ': ' . $commit; |
|
| 251 | - } |
|
| 252 | - $version .= " {$vcs['vcs']} [$commit]"; |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - // et la version de l'ecran de securite |
|
| 256 | - $secu = defined('_ECRAN_SECURITE') |
|
| 257 | - ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE]) |
|
| 258 | - : ''; |
|
| 259 | - |
|
| 260 | - return _T( |
|
| 261 | - 'info_copyright', |
|
| 262 | - [ |
|
| 263 | - 'spip' => "<b>SPIP $version</b> ", |
|
| 264 | - 'lien_gpl' => |
|
| 265 | - "<a href='" . generer_url_ecrire( |
|
| 266 | - 'aide', |
|
| 267 | - 'aide=licence&var_lang=' . $GLOBALS['spip_lang'] |
|
| 268 | - ) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>' |
|
| 269 | - ] |
|
| 270 | - ) |
|
| 271 | - . $secu; |
|
| 231 | + $version = $GLOBALS['spip_version_affichee']; |
|
| 232 | + |
|
| 233 | + // |
|
| 234 | + // Mention, le cas echeant, de la revision SVN courante |
|
| 235 | + // |
|
| 236 | + if ($vcs = version_vcs_courante(_DIR_RACINE, true)) { |
|
| 237 | + if ($vcs['vcs'] === 'GIT') { |
|
| 238 | + $url = 'https://git.spip.net/spip/spip/commit/' . $vcs['commit']; |
|
| 239 | + } elseif ($vcs['vcs'] === 'SVN') { |
|
| 240 | + $url = 'https://core.spip.net/projects/spip/repository/revisions/' . $vcs['commit']; |
|
| 241 | + } else { |
|
| 242 | + $url = ''; |
|
| 243 | + } |
|
| 244 | + // affichage "GIT [master: abcdef]" |
|
| 245 | + $commit = $vcs['commit_short'] ?? $vcs['commit']; |
|
| 246 | + if ($url) { |
|
| 247 | + $commit = "<a href=\"$url\" target=\"_blank\" rel=\"noopener noreferrer\">$commit</a>"; |
|
| 248 | + } |
|
| 249 | + if ($vcs['branch']) { |
|
| 250 | + $commit = $vcs['branch'] . ': ' . $commit; |
|
| 251 | + } |
|
| 252 | + $version .= " {$vcs['vcs']} [$commit]"; |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + // et la version de l'ecran de securite |
|
| 256 | + $secu = defined('_ECRAN_SECURITE') |
|
| 257 | + ? '<br />' . _T('ecran_securite', ['version' => _ECRAN_SECURITE]) |
|
| 258 | + : ''; |
|
| 259 | + |
|
| 260 | + return _T( |
|
| 261 | + 'info_copyright', |
|
| 262 | + [ |
|
| 263 | + 'spip' => "<b>SPIP $version</b> ", |
|
| 264 | + 'lien_gpl' => |
|
| 265 | + "<a href='" . generer_url_ecrire( |
|
| 266 | + 'aide', |
|
| 267 | + 'aide=licence&var_lang=' . $GLOBALS['spip_lang'] |
|
| 268 | + ) . "' class=\"aide popin\">" . _T('info_copyright_gpl') . '</a>' |
|
| 269 | + ] |
|
| 270 | + ) |
|
| 271 | + . $secu; |
|
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | /** |
@@ -283,17 +283,17 @@ discard block |
||
| 283 | 283 | * @return string Code HTML |
| 284 | 284 | **/ |
| 285 | 285 | function formulaire_recherche($page, $complement = '') { |
| 286 | - $recherche = _request('recherche'); |
|
| 287 | - $recherche_aff = entites_html($recherche); |
|
| 288 | - if (!strlen($recherche)) { |
|
| 289 | - $recherche_aff = _T('info_rechercher'); |
|
| 290 | - $onfocus = " onfocus=\"this.value='';\""; |
|
| 291 | - } else { |
|
| 292 | - $onfocus = ''; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 296 | - $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />"; |
|
| 297 | - |
|
| 298 | - return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>'; |
|
| 286 | + $recherche = _request('recherche'); |
|
| 287 | + $recherche_aff = entites_html($recherche); |
|
| 288 | + if (!strlen($recherche)) { |
|
| 289 | + $recherche_aff = _T('info_rechercher'); |
|
| 290 | + $onfocus = " onfocus=\"this.value='';\""; |
|
| 291 | + } else { |
|
| 292 | + $onfocus = ''; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + $form = '<input type="text" size="10" value="' . $recherche_aff . '" name="recherche" class="recherche" accesskey="r"' . $onfocus . ' />'; |
|
| 296 | + $form .= "<input type='image' src='" . chemin_image('rechercher-20.png') . "' name='submit' class='submit' alt='" . _T('info_rechercher') . "' />"; |
|
| 297 | + |
|
| 298 | + return "<div class='spip_recherche'>" . generer_form_ecrire($page, $form . $complement, " method='get'") . '</div>'; |
|
| 299 | 299 | } |