@@ -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 | include_spip('base/abstract_sql'); |
| 23 | 23 | |
@@ -59,56 +59,56 @@ discard block |
||
| 59 | 59 | * Retour des traitements. |
| 60 | 60 | **/ |
| 61 | 61 | function formulaires_editer_objet_traiter( |
| 62 | - $type, |
|
| 63 | - $id = 'new', |
|
| 64 | - $id_parent = 0, |
|
| 65 | - $lier_trad = 0, |
|
| 66 | - $retour = '', |
|
| 67 | - $config_fonc = 'articles_edit_config', |
|
| 68 | - $row = [], |
|
| 69 | - $hidden = '' |
|
| 62 | + $type, |
|
| 63 | + $id = 'new', |
|
| 64 | + $id_parent = 0, |
|
| 65 | + $lier_trad = 0, |
|
| 66 | + $retour = '', |
|
| 67 | + $config_fonc = 'articles_edit_config', |
|
| 68 | + $row = [], |
|
| 69 | + $hidden = '' |
|
| 70 | 70 | ) { |
| 71 | 71 | |
| 72 | - $res = []; |
|
| 73 | - // eviter la redirection forcee par l'action... |
|
| 74 | - set_request('redirect'); |
|
| 75 | - if ($action_editer = charger_fonction("editer_$type", 'action', true)) { |
|
| 76 | - [$id, $err] = $action_editer($id); |
|
| 77 | - } else { |
|
| 78 | - $action_editer = charger_fonction('editer_objet', 'action'); |
|
| 79 | - [$id, $err] = $action_editer($id, $type); |
|
| 80 | - } |
|
| 81 | - $id_table_objet = id_table_objet($type); |
|
| 82 | - $res[$id_table_objet] = $id; |
|
| 83 | - if ($err or !$id) { |
|
| 84 | - $res['message_erreur'] = ($err ?: _T('erreur')); |
|
| 85 | - } else { |
|
| 86 | - // Un lien de trad a prendre en compte |
|
| 87 | - if ($lier_trad) { |
|
| 88 | - // referencer la traduction |
|
| 89 | - $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 90 | - $referencer_traduction($type, $id, $lier_trad); |
|
| 91 | - // actions de recopie de champs / liens sur le nouvel objet créé |
|
| 92 | - $completer_traduction = charger_fonction('completer_traduction', 'inc'); |
|
| 93 | - $err = $completer_traduction($type, $id, $lier_trad); |
|
| 94 | - if ($err) { |
|
| 95 | - $res['message_erreur'] = $err; |
|
| 96 | - return $res; |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - $res['message_ok'] = _T('info_modification_enregistree'); |
|
| 101 | - if ($retour) { |
|
| 102 | - if (strncmp($retour, 'javascript:', 11) == 0) { |
|
| 103 | - $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>'; |
|
| 104 | - $res['editable'] = true; |
|
| 105 | - } else { |
|
| 106 | - $res['redirect'] = parametre_url($retour, $id_table_objet, $id); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - return $res; |
|
| 72 | + $res = []; |
|
| 73 | + // eviter la redirection forcee par l'action... |
|
| 74 | + set_request('redirect'); |
|
| 75 | + if ($action_editer = charger_fonction("editer_$type", 'action', true)) { |
|
| 76 | + [$id, $err] = $action_editer($id); |
|
| 77 | + } else { |
|
| 78 | + $action_editer = charger_fonction('editer_objet', 'action'); |
|
| 79 | + [$id, $err] = $action_editer($id, $type); |
|
| 80 | + } |
|
| 81 | + $id_table_objet = id_table_objet($type); |
|
| 82 | + $res[$id_table_objet] = $id; |
|
| 83 | + if ($err or !$id) { |
|
| 84 | + $res['message_erreur'] = ($err ?: _T('erreur')); |
|
| 85 | + } else { |
|
| 86 | + // Un lien de trad a prendre en compte |
|
| 87 | + if ($lier_trad) { |
|
| 88 | + // referencer la traduction |
|
| 89 | + $referencer_traduction = charger_fonction('referencer_traduction', 'action'); |
|
| 90 | + $referencer_traduction($type, $id, $lier_trad); |
|
| 91 | + // actions de recopie de champs / liens sur le nouvel objet créé |
|
| 92 | + $completer_traduction = charger_fonction('completer_traduction', 'inc'); |
|
| 93 | + $err = $completer_traduction($type, $id, $lier_trad); |
|
| 94 | + if ($err) { |
|
| 95 | + $res['message_erreur'] = $err; |
|
| 96 | + return $res; |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + $res['message_ok'] = _T('info_modification_enregistree'); |
|
| 101 | + if ($retour) { |
|
| 102 | + if (strncmp($retour, 'javascript:', 11) == 0) { |
|
| 103 | + $res['message_ok'] .= '<script type="text/javascript">/*<![CDATA[*/' . substr($retour, 11) . '/*]]>*/</script>'; |
|
| 104 | + $res['editable'] = true; |
|
| 105 | + } else { |
|
| 106 | + $res['redirect'] = parametre_url($retour, $id_table_objet, $id); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + return $res; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | /** |
@@ -132,29 +132,29 @@ discard block |
||
| 132 | 132 | * Tableau des erreurs |
| 133 | 133 | **/ |
| 134 | 134 | function formulaires_editer_objet_verifier($type, $id = 'new', $oblis = []) { |
| 135 | - $erreurs = []; |
|
| 136 | - if (intval($id)) { |
|
| 137 | - $conflits = controler_contenu($type, $id); |
|
| 138 | - if ($conflits and is_countable($conflits) ? count($conflits) : 0) { |
|
| 139 | - foreach ($conflits as $champ => $conflit) { |
|
| 140 | - if (!isset($erreurs[$champ])) { |
|
| 141 | - $erreurs[$champ] = ''; |
|
| 142 | - } |
|
| 143 | - $erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>'; |
|
| 144 | - } |
|
| 145 | - } |
|
| 146 | - } |
|
| 147 | - foreach ($oblis as $obli) { |
|
| 148 | - $value = _request($obli); |
|
| 149 | - if (is_null($value) or !(is_array($value) ? count($value) : strlen($value))) { |
|
| 150 | - if (!isset($erreurs[$obli])) { |
|
| 151 | - $erreurs[$obli] = ''; |
|
| 152 | - } |
|
| 153 | - $erreurs[$obli] .= _T('info_obligatoire'); |
|
| 154 | - } |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - return $erreurs; |
|
| 135 | + $erreurs = []; |
|
| 136 | + if (intval($id)) { |
|
| 137 | + $conflits = controler_contenu($type, $id); |
|
| 138 | + if ($conflits and is_countable($conflits) ? count($conflits) : 0) { |
|
| 139 | + foreach ($conflits as $champ => $conflit) { |
|
| 140 | + if (!isset($erreurs[$champ])) { |
|
| 141 | + $erreurs[$champ] = ''; |
|
| 142 | + } |
|
| 143 | + $erreurs[$champ] .= _T('alerte_modif_info_concourante') . "<br /><textarea readonly='readonly' class='forml'>" . entites_html($conflit['base']) . '</textarea>'; |
|
| 144 | + } |
|
| 145 | + } |
|
| 146 | + } |
|
| 147 | + foreach ($oblis as $obli) { |
|
| 148 | + $value = _request($obli); |
|
| 149 | + if (is_null($value) or !(is_array($value) ? count($value) : strlen($value))) { |
|
| 150 | + if (!isset($erreurs[$obli])) { |
|
| 151 | + $erreurs[$obli] = ''; |
|
| 152 | + } |
|
| 153 | + $erreurs[$obli] .= _T('info_obligatoire'); |
|
| 154 | + } |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + return $erreurs; |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | /** |
@@ -199,154 +199,154 @@ discard block |
||
| 199 | 199 | * Environnement du formulaire. |
| 200 | 200 | **/ |
| 201 | 201 | function formulaires_editer_objet_charger( |
| 202 | - $type, |
|
| 203 | - $id = 'new', |
|
| 204 | - $id_parent = 0, |
|
| 205 | - $lier_trad = 0, |
|
| 206 | - $retour = '', |
|
| 207 | - $config_fonc = 'articles_edit_config', |
|
| 208 | - $row = [], |
|
| 209 | - $hidden = '' |
|
| 202 | + $type, |
|
| 203 | + $id = 'new', |
|
| 204 | + $id_parent = 0, |
|
| 205 | + $lier_trad = 0, |
|
| 206 | + $retour = '', |
|
| 207 | + $config_fonc = 'articles_edit_config', |
|
| 208 | + $row = [], |
|
| 209 | + $hidden = '' |
|
| 210 | 210 | ) { |
| 211 | 211 | |
| 212 | - $table_objet = table_objet($type); |
|
| 213 | - $table_objet_sql = table_objet_sql($type); |
|
| 214 | - $id_table_objet = id_table_objet($type); |
|
| 215 | - if (!is_array($row)) { |
|
| 216 | - $row = []; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - // on accepte pas une fonction de config inconnue si elle vient d'un modele |
|
| 220 | - if ( |
|
| 221 | - $config_fonc |
|
| 222 | - and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
|
| 223 | - and $config_fonc !== $table_objet . '_edit_config' |
|
| 224 | - ) { |
|
| 225 | - if ( |
|
| 226 | - $args = test_formulaire_inclus_par_modele() |
|
| 227 | - and in_array($config_fonc, $args) |
|
| 228 | - ) { |
|
| 229 | - $config_fonc = ''; |
|
| 230 | - } |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - $new = !is_numeric($id); |
|
| 234 | - $lang_default = ''; |
|
| 235 | - // Appel direct dans un squelette |
|
| 236 | - if (!$row) { |
|
| 237 | - if (!$new or $lier_trad) { |
|
| 238 | - if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 239 | - $row = $select($id, $id_parent, $lier_trad); |
|
| 240 | - // si on a une fonction precharger, elle pu faire un reglage de langue |
|
| 241 | - $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
|
| 242 | - } else { |
|
| 243 | - $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 244 | - } |
|
| 245 | - if (!$new) { |
|
| 246 | - $md5 = controles_md5($row ?? []); |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - if (!$row) { |
|
| 250 | - $row = []; |
|
| 251 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 252 | - if ($desc = $trouver_table($table_objet)) { |
|
| 253 | - foreach ($desc['field'] as $k => $v) { |
|
| 254 | - $row[$k] = ''; |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - // Gaffe: sans ceci, on ecrase systematiquement l'article d'origine |
|
| 261 | - // (et donc: pas de lien de traduction) |
|
| 262 | - $id = ($new or $lier_trad) |
|
| 263 | - ? 'oui' |
|
| 264 | - : $row[$id_table_objet]; |
|
| 265 | - $row[$id_table_objet] = $id; |
|
| 266 | - |
|
| 267 | - $contexte = $row; |
|
| 268 | - if (is_numeric($id_parent) && strlen($id_parent) && (!isset($contexte['id_parent']) or $new)) { |
|
| 269 | - if (!isset($contexte['id_parent'])) { |
|
| 270 | - unset($contexte['id_rubrique']); |
|
| 271 | - } |
|
| 272 | - $contexte['id_parent'] = $id_parent; |
|
| 273 | - } elseif (!isset($contexte['id_parent'])) { |
|
| 274 | - // id_rubrique dans id_parent si possible |
|
| 275 | - if (isset($contexte['id_rubrique'])) { |
|
| 276 | - $contexte['id_parent'] = $contexte['id_rubrique']; |
|
| 277 | - unset($contexte['id_rubrique']); |
|
| 278 | - } else { |
|
| 279 | - $contexte['id_parent'] = ''; |
|
| 280 | - } |
|
| 281 | - if ( |
|
| 282 | - !$contexte['id_parent'] |
|
| 283 | - and $preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true) |
|
| 284 | - ) { |
|
| 285 | - $contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row); |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - $config = []; |
|
| 290 | - if ($config_fonc) { |
|
| 291 | - $contexte['config'] = $config = $config_fonc($contexte); |
|
| 292 | - if (!$lang_default) { |
|
| 293 | - $lang_default = $config['langue'] ?? session_get('lang') ; |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - $config = $config + [ |
|
| 297 | - 'lignes' => 0, |
|
| 298 | - 'langue' => '', |
|
| 299 | - ]; |
|
| 300 | - |
|
| 301 | - $att_text = " class='textarea' " |
|
| 302 | - . " rows='" |
|
| 303 | - . ($config['lignes'] + 15) |
|
| 304 | - . "' cols='40'"; |
|
| 305 | - if (isset($contexte['texte'])) { |
|
| 306 | - [$contexte['texte'], $contexte['_texte_trop_long']] = editer_texte_recolle($contexte['texte'], $att_text); |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - // on veut conserver la langue de l'interface ; |
|
| 310 | - // on passe cette donnee sous un autre nom, au cas ou le squelette |
|
| 311 | - // voudrait l'exploiter |
|
| 312 | - if (isset($contexte['lang'])) { |
|
| 313 | - $contexte['langue'] = $contexte['lang']; |
|
| 314 | - unset($contexte['lang']); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 318 | - (!$lier_trad ? '' : |
|
| 319 | - ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 320 | - $lier_trad . |
|
| 321 | - "' />" . |
|
| 322 | - "\n<input type='hidden' name='changer_lang' value='" . |
|
| 323 | - $lang_default . |
|
| 324 | - "' />")) |
|
| 325 | - . $hidden |
|
| 326 | - . ($md5 ?? ''); |
|
| 327 | - |
|
| 328 | - // preciser que le formulaire doit passer dans un pipeline |
|
| 329 | - $contexte['_pipeline'] = ['editer_contenu_objet', ['type' => $type, 'id' => $id]]; |
|
| 330 | - |
|
| 331 | - // preciser que le formulaire doit etre securise auteur/action |
|
| 332 | - // n'est plus utile lorsque l'action accepte l'id en argument direct |
|
| 333 | - // on le garde pour compat |
|
| 334 | - $contexte['_action'] = ["editer_$type", $id]; |
|
| 335 | - |
|
| 336 | - // et in fine placer l'autorisation |
|
| 337 | - include_spip('inc/autoriser'); |
|
| 338 | - if (intval($id)) { |
|
| 339 | - if (!autoriser('modifier', $type, intval($id))) { |
|
| 340 | - $contexte['editable'] = ''; |
|
| 341 | - } |
|
| 342 | - } |
|
| 343 | - else { |
|
| 344 | - if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) { |
|
| 345 | - $contexte['editable'] = ''; |
|
| 346 | - } |
|
| 347 | - } |
|
| 348 | - |
|
| 349 | - return $contexte; |
|
| 212 | + $table_objet = table_objet($type); |
|
| 213 | + $table_objet_sql = table_objet_sql($type); |
|
| 214 | + $id_table_objet = id_table_objet($type); |
|
| 215 | + if (!is_array($row)) { |
|
| 216 | + $row = []; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + // on accepte pas une fonction de config inconnue si elle vient d'un modele |
|
| 220 | + if ( |
|
| 221 | + $config_fonc |
|
| 222 | + and !in_array($config_fonc, ['articles_edit_config', 'rubriques_edit_config', 'auteurs_edit_config']) |
|
| 223 | + and $config_fonc !== $table_objet . '_edit_config' |
|
| 224 | + ) { |
|
| 225 | + if ( |
|
| 226 | + $args = test_formulaire_inclus_par_modele() |
|
| 227 | + and in_array($config_fonc, $args) |
|
| 228 | + ) { |
|
| 229 | + $config_fonc = ''; |
|
| 230 | + } |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + $new = !is_numeric($id); |
|
| 234 | + $lang_default = ''; |
|
| 235 | + // Appel direct dans un squelette |
|
| 236 | + if (!$row) { |
|
| 237 | + if (!$new or $lier_trad) { |
|
| 238 | + if ($select = charger_fonction('precharger_' . $type, 'inc', true)) { |
|
| 239 | + $row = $select($id, $id_parent, $lier_trad); |
|
| 240 | + // si on a une fonction precharger, elle pu faire un reglage de langue |
|
| 241 | + $lang_default = (!empty($row['lang']) ? $row['lang'] : null); |
|
| 242 | + } else { |
|
| 243 | + $row = sql_fetsel('*', $table_objet_sql, $id_table_objet . '=' . intval($id)); |
|
| 244 | + } |
|
| 245 | + if (!$new) { |
|
| 246 | + $md5 = controles_md5($row ?? []); |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + if (!$row) { |
|
| 250 | + $row = []; |
|
| 251 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 252 | + if ($desc = $trouver_table($table_objet)) { |
|
| 253 | + foreach ($desc['field'] as $k => $v) { |
|
| 254 | + $row[$k] = ''; |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + // Gaffe: sans ceci, on ecrase systematiquement l'article d'origine |
|
| 261 | + // (et donc: pas de lien de traduction) |
|
| 262 | + $id = ($new or $lier_trad) |
|
| 263 | + ? 'oui' |
|
| 264 | + : $row[$id_table_objet]; |
|
| 265 | + $row[$id_table_objet] = $id; |
|
| 266 | + |
|
| 267 | + $contexte = $row; |
|
| 268 | + if (is_numeric($id_parent) && strlen($id_parent) && (!isset($contexte['id_parent']) or $new)) { |
|
| 269 | + if (!isset($contexte['id_parent'])) { |
|
| 270 | + unset($contexte['id_rubrique']); |
|
| 271 | + } |
|
| 272 | + $contexte['id_parent'] = $id_parent; |
|
| 273 | + } elseif (!isset($contexte['id_parent'])) { |
|
| 274 | + // id_rubrique dans id_parent si possible |
|
| 275 | + if (isset($contexte['id_rubrique'])) { |
|
| 276 | + $contexte['id_parent'] = $contexte['id_rubrique']; |
|
| 277 | + unset($contexte['id_rubrique']); |
|
| 278 | + } else { |
|
| 279 | + $contexte['id_parent'] = ''; |
|
| 280 | + } |
|
| 281 | + if ( |
|
| 282 | + !$contexte['id_parent'] |
|
| 283 | + and $preselectionner_parent_nouvel_objet = charger_fonction('preselectionner_parent_nouvel_objet', 'inc', true) |
|
| 284 | + ) { |
|
| 285 | + $contexte['id_parent'] = $preselectionner_parent_nouvel_objet($type, $row); |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + $config = []; |
|
| 290 | + if ($config_fonc) { |
|
| 291 | + $contexte['config'] = $config = $config_fonc($contexte); |
|
| 292 | + if (!$lang_default) { |
|
| 293 | + $lang_default = $config['langue'] ?? session_get('lang') ; |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + $config = $config + [ |
|
| 297 | + 'lignes' => 0, |
|
| 298 | + 'langue' => '', |
|
| 299 | + ]; |
|
| 300 | + |
|
| 301 | + $att_text = " class='textarea' " |
|
| 302 | + . " rows='" |
|
| 303 | + . ($config['lignes'] + 15) |
|
| 304 | + . "' cols='40'"; |
|
| 305 | + if (isset($contexte['texte'])) { |
|
| 306 | + [$contexte['texte'], $contexte['_texte_trop_long']] = editer_texte_recolle($contexte['texte'], $att_text); |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + // on veut conserver la langue de l'interface ; |
|
| 310 | + // on passe cette donnee sous un autre nom, au cas ou le squelette |
|
| 311 | + // voudrait l'exploiter |
|
| 312 | + if (isset($contexte['lang'])) { |
|
| 313 | + $contexte['langue'] = $contexte['lang']; |
|
| 314 | + unset($contexte['lang']); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + $contexte['_hidden'] = "<input type='hidden' name='editer_$type' value='oui' />\n" . |
|
| 318 | + (!$lier_trad ? '' : |
|
| 319 | + ("\n<input type='hidden' name='lier_trad' value='" . |
|
| 320 | + $lier_trad . |
|
| 321 | + "' />" . |
|
| 322 | + "\n<input type='hidden' name='changer_lang' value='" . |
|
| 323 | + $lang_default . |
|
| 324 | + "' />")) |
|
| 325 | + . $hidden |
|
| 326 | + . ($md5 ?? ''); |
|
| 327 | + |
|
| 328 | + // preciser que le formulaire doit passer dans un pipeline |
|
| 329 | + $contexte['_pipeline'] = ['editer_contenu_objet', ['type' => $type, 'id' => $id]]; |
|
| 330 | + |
|
| 331 | + // preciser que le formulaire doit etre securise auteur/action |
|
| 332 | + // n'est plus utile lorsque l'action accepte l'id en argument direct |
|
| 333 | + // on le garde pour compat |
|
| 334 | + $contexte['_action'] = ["editer_$type", $id]; |
|
| 335 | + |
|
| 336 | + // et in fine placer l'autorisation |
|
| 337 | + include_spip('inc/autoriser'); |
|
| 338 | + if (intval($id)) { |
|
| 339 | + if (!autoriser('modifier', $type, intval($id))) { |
|
| 340 | + $contexte['editable'] = ''; |
|
| 341 | + } |
|
| 342 | + } |
|
| 343 | + else { |
|
| 344 | + if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) { |
|
| 345 | + $contexte['editable'] = ''; |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | + |
|
| 349 | + return $contexte; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
@@ -357,29 +357,29 @@ discard block |
||
| 357 | 357 | * @return array |
| 358 | 358 | */ |
| 359 | 359 | function coupe_trop_long($texte) { |
| 360 | - $aider = charger_fonction('aider', 'inc'); |
|
| 361 | - if (strlen($texte) > 28 * 1024) { |
|
| 362 | - $texte = str_replace("\r\n", "\n", $texte); |
|
| 363 | - $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 364 | - if ($pos > 0 and $pos < 32 * 1024) { |
|
| 365 | - $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 366 | - $suite = substr($texte, $pos + 2); |
|
| 367 | - } else { |
|
| 368 | - $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 369 | - if (!($pos > 0 and $pos < 32 * 1024)) { |
|
| 370 | - $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 371 | - $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
|
| 372 | - } else { |
|
| 373 | - $decalage = 1; |
|
| 374 | - } |
|
| 375 | - $debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un |
|
| 376 | - $suite = substr($texte, $pos + $decalage); |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - return ([$debut, $suite]); |
|
| 380 | - } else { |
|
| 381 | - return ([$texte, '']); |
|
| 382 | - } |
|
| 360 | + $aider = charger_fonction('aider', 'inc'); |
|
| 361 | + if (strlen($texte) > 28 * 1024) { |
|
| 362 | + $texte = str_replace("\r\n", "\n", $texte); |
|
| 363 | + $pos = strpos($texte, "\n\n", 28 * 1024); // coupe para > 28 ko |
|
| 364 | + if ($pos > 0 and $pos < 32 * 1024) { |
|
| 365 | + $debut = substr($texte, 0, $pos) . "\n\n<!--SPIP-->\n"; |
|
| 366 | + $suite = substr($texte, $pos + 2); |
|
| 367 | + } else { |
|
| 368 | + $pos = strpos($texte, ' ', 28 * 1024); // sinon coupe espace |
|
| 369 | + if (!($pos > 0 and $pos < 32 * 1024)) { |
|
| 370 | + $pos = 28 * 1024; // au pire (pas d'espace trouv'e) |
|
| 371 | + $decalage = 0; // si y'a pas d'espace, il ne faut pas perdre le caract`ere |
|
| 372 | + } else { |
|
| 373 | + $decalage = 1; |
|
| 374 | + } |
|
| 375 | + $debut = substr($texte, 0, $pos + $decalage); // Il faut conserver l'espace s'il y en a un |
|
| 376 | + $suite = substr($texte, $pos + $decalage); |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + return ([$debut, $suite]); |
|
| 380 | + } else { |
|
| 381 | + return ([$texte, '']); |
|
| 382 | + } |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | /** |
@@ -390,25 +390,25 @@ discard block |
||
| 390 | 390 | * @return array |
| 391 | 391 | */ |
| 392 | 392 | function editer_texte_recolle($texte, $att_text) { |
| 393 | - if ( |
|
| 394 | - (strlen($texte) < 29 * 1024) |
|
| 395 | - or (include_spip('inc/layer') and ($GLOBALS['browser_name'] != 'MSIE')) |
|
| 396 | - ) { |
|
| 397 | - return [$texte, '']; |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - include_spip('inc/barre'); |
|
| 401 | - $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 402 | - $nombre = 0; |
|
| 403 | - |
|
| 404 | - while (strlen($texte) > 29 * 1024) { |
|
| 405 | - $nombre++; |
|
| 406 | - [$texte1, $texte] = coupe_trop_long($texte); |
|
| 407 | - $textes_supplement .= '<br />' . |
|
| 408 | - "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - return [$texte, $textes_supplement]; |
|
| 393 | + if ( |
|
| 394 | + (strlen($texte) < 29 * 1024) |
|
| 395 | + or (include_spip('inc/layer') and ($GLOBALS['browser_name'] != 'MSIE')) |
|
| 396 | + ) { |
|
| 397 | + return [$texte, '']; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + include_spip('inc/barre'); |
|
| 401 | + $textes_supplement = "<br /><span style='color: red'>" . _T('info_texte_long') . "</span>\n"; |
|
| 402 | + $nombre = 0; |
|
| 403 | + |
|
| 404 | + while (strlen($texte) > 29 * 1024) { |
|
| 405 | + $nombre++; |
|
| 406 | + [$texte1, $texte] = coupe_trop_long($texte); |
|
| 407 | + $textes_supplement .= '<br />' . |
|
| 408 | + "<textarea id='texte$nombre' name='texte_plus[$nombre]'$att_text>$texte1</textarea>\n"; |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + return [$texte, $textes_supplement]; |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
@@ -419,17 +419,17 @@ discard block |
||
| 419 | 419 | * @param int $longueur |
| 420 | 420 | */ |
| 421 | 421 | function titre_automatique($champ_titre, $champs_contenu, $longueur = null) { |
| 422 | - if (!_request($champ_titre)) { |
|
| 423 | - $titrer_contenu = charger_fonction('titrer_contenu', 'inc'); |
|
| 424 | - if (!is_null($longueur)) { |
|
| 425 | - $t = $titrer_contenu($champs_contenu, null, $longueur); |
|
| 426 | - } else { |
|
| 427 | - $t = $titrer_contenu($champs_contenu); |
|
| 428 | - } |
|
| 429 | - if ($t) { |
|
| 430 | - set_request($champ_titre, $t); |
|
| 431 | - } |
|
| 432 | - } |
|
| 422 | + if (!_request($champ_titre)) { |
|
| 423 | + $titrer_contenu = charger_fonction('titrer_contenu', 'inc'); |
|
| 424 | + if (!is_null($longueur)) { |
|
| 425 | + $t = $titrer_contenu($champs_contenu, null, $longueur); |
|
| 426 | + } else { |
|
| 427 | + $t = $titrer_contenu($champs_contenu); |
|
| 428 | + } |
|
| 429 | + if ($t) { |
|
| 430 | + set_request($champ_titre, $t); |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 | /** |
@@ -449,20 +449,20 @@ discard block |
||
| 449 | 449 | * @return string |
| 450 | 450 | */ |
| 451 | 451 | function inc_titrer_contenu_dist($champs_contenu, $c = null, $longueur = 50) { |
| 452 | - // trouver un champ texte non vide |
|
| 453 | - $t = ''; |
|
| 454 | - foreach ($champs_contenu as $champ) { |
|
| 455 | - if ($t = _request($champ, $c)) { |
|
| 456 | - break; |
|
| 457 | - } |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - if ($t) { |
|
| 461 | - include_spip('inc/texte_mini'); |
|
| 462 | - $t = couper($t, $longueur, '...'); |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - return $t; |
|
| 452 | + // trouver un champ texte non vide |
|
| 453 | + $t = ''; |
|
| 454 | + foreach ($champs_contenu as $champ) { |
|
| 455 | + if ($t = _request($champ, $c)) { |
|
| 456 | + break; |
|
| 457 | + } |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + if ($t) { |
|
| 461 | + include_spip('inc/texte_mini'); |
|
| 462 | + $t = couper($t, $longueur, '...'); |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + return $t; |
|
| 466 | 466 | } |
| 467 | 467 | |
| 468 | 468 | /** |
@@ -484,26 +484,26 @@ discard block |
||
| 484 | 484 | * - array sinon couples ('$prefixe$colonne => md5) |
| 485 | 485 | **/ |
| 486 | 486 | function controles_md5(array $data, string $prefixe = 'ctr_', string $format = 'html') { |
| 487 | - $ctr = []; |
|
| 488 | - foreach ($data as $key => $val) { |
|
| 489 | - $m = md5($val ?? ''); |
|
| 490 | - $k = $prefixe . $key; |
|
| 491 | - |
|
| 492 | - switch ($format) { |
|
| 493 | - case 'html': |
|
| 494 | - $ctr[$k] = "<input type='hidden' value='$m' name='$k' />"; |
|
| 495 | - break; |
|
| 496 | - default: |
|
| 497 | - $ctr[$k] = $m; |
|
| 498 | - break; |
|
| 499 | - } |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - if ($format === 'html') { |
|
| 503 | - return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 504 | - } else { |
|
| 505 | - return $ctr; |
|
| 506 | - } |
|
| 487 | + $ctr = []; |
|
| 488 | + foreach ($data as $key => $val) { |
|
| 489 | + $m = md5($val ?? ''); |
|
| 490 | + $k = $prefixe . $key; |
|
| 491 | + |
|
| 492 | + switch ($format) { |
|
| 493 | + case 'html': |
|
| 494 | + $ctr[$k] = "<input type='hidden' value='$m' name='$k' />"; |
|
| 495 | + break; |
|
| 496 | + default: |
|
| 497 | + $ctr[$k] = $m; |
|
| 498 | + break; |
|
| 499 | + } |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + if ($format === 'html') { |
|
| 503 | + return "\n\n<!-- controles md5 -->\n" . join("\n", $ctr) . "\n\n"; |
|
| 504 | + } else { |
|
| 505 | + return $ctr; |
|
| 506 | + } |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /** |
@@ -542,80 +542,80 @@ discard block |
||
| 542 | 542 | * - post : le contenu posté |
| 543 | 543 | **/ |
| 544 | 544 | function controler_contenu($type, $id, $options = [], $c = false, $serveur = '') { |
| 545 | - include_spip('inc/filtres'); |
|
| 546 | - |
|
| 547 | - $table_objet = table_objet($type); |
|
| 548 | - $spip_table_objet = table_objet_sql($type); |
|
| 549 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 550 | - $desc = $trouver_table($table_objet, $serveur); |
|
| 551 | - |
|
| 552 | - // Appels incomplets (sans $c) |
|
| 553 | - if (!is_array($c)) { |
|
| 554 | - $c = []; |
|
| 555 | - foreach ($desc['field'] as $champ => $ignore) { |
|
| 556 | - if (_request($champ)) { |
|
| 557 | - $c[$champ] = _request($champ); |
|
| 558 | - } |
|
| 559 | - } |
|
| 560 | - } |
|
| 561 | - |
|
| 562 | - // Securite : certaines variables ne sont jamais acceptees ici |
|
| 563 | - // car elles ne relevent pas de autoriser(article, modifier) ; |
|
| 564 | - // il faut passer par instituer_XX() |
|
| 565 | - // TODO: faut-il passer ces variables interdites |
|
| 566 | - // dans un fichier de description separe ? |
|
| 567 | - unset($c['statut']); |
|
| 568 | - unset($c['id_parent']); |
|
| 569 | - unset($c['id_rubrique']); |
|
| 570 | - unset($c['id_secteur']); |
|
| 571 | - |
|
| 572 | - // Gerer les champs non vides |
|
| 573 | - if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 574 | - foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 575 | - if ($c[$champ] === '') { |
|
| 576 | - $c[$champ] = $sinon; |
|
| 577 | - } |
|
| 578 | - } |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - // N'accepter que les champs qui existent |
|
| 582 | - // [TODO] ici aussi on peut valider les contenus en fonction du type |
|
| 583 | - $champs = []; |
|
| 584 | - foreach ($desc['field'] as $champ => $ignore) { |
|
| 585 | - if (isset($c[$champ])) { |
|
| 586 | - $champs[$champ] = $c[$champ]; |
|
| 587 | - } |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - // Nettoyer les valeurs |
|
| 591 | - $champs = array_map('corriger_caracteres', $champs); |
|
| 592 | - |
|
| 593 | - // Envoyer aux plugins |
|
| 594 | - $champs = pipeline( |
|
| 595 | - 'pre_edition', |
|
| 596 | - [ |
|
| 597 | - 'args' => [ |
|
| 598 | - 'table' => $spip_table_objet, // compatibilite |
|
| 599 | - 'table_objet' => $table_objet, |
|
| 600 | - 'spip_table_objet' => $spip_table_objet, |
|
| 601 | - 'type' => $type, |
|
| 602 | - 'id_objet' => $id, |
|
| 603 | - 'champs' => $options['champs'] ?? [], // [doc] c'est quoi ? |
|
| 604 | - 'action' => 'controler', |
|
| 605 | - 'serveur' => $serveur, |
|
| 606 | - ], |
|
| 607 | - 'data' => $champs |
|
| 608 | - ] |
|
| 609 | - ); |
|
| 610 | - |
|
| 611 | - if (!$champs) { |
|
| 612 | - return false; |
|
| 613 | - } |
|
| 614 | - |
|
| 615 | - // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 616 | - $conflits = controler_md5($champs, $_POST, $type, $id, $serveur, $options['prefix'] ?? 'ctr_'); |
|
| 617 | - |
|
| 618 | - return $conflits; |
|
| 545 | + include_spip('inc/filtres'); |
|
| 546 | + |
|
| 547 | + $table_objet = table_objet($type); |
|
| 548 | + $spip_table_objet = table_objet_sql($type); |
|
| 549 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 550 | + $desc = $trouver_table($table_objet, $serveur); |
|
| 551 | + |
|
| 552 | + // Appels incomplets (sans $c) |
|
| 553 | + if (!is_array($c)) { |
|
| 554 | + $c = []; |
|
| 555 | + foreach ($desc['field'] as $champ => $ignore) { |
|
| 556 | + if (_request($champ)) { |
|
| 557 | + $c[$champ] = _request($champ); |
|
| 558 | + } |
|
| 559 | + } |
|
| 560 | + } |
|
| 561 | + |
|
| 562 | + // Securite : certaines variables ne sont jamais acceptees ici |
|
| 563 | + // car elles ne relevent pas de autoriser(article, modifier) ; |
|
| 564 | + // il faut passer par instituer_XX() |
|
| 565 | + // TODO: faut-il passer ces variables interdites |
|
| 566 | + // dans un fichier de description separe ? |
|
| 567 | + unset($c['statut']); |
|
| 568 | + unset($c['id_parent']); |
|
| 569 | + unset($c['id_rubrique']); |
|
| 570 | + unset($c['id_secteur']); |
|
| 571 | + |
|
| 572 | + // Gerer les champs non vides |
|
| 573 | + if (isset($options['nonvide']) and is_array($options['nonvide'])) { |
|
| 574 | + foreach ($options['nonvide'] as $champ => $sinon) { |
|
| 575 | + if ($c[$champ] === '') { |
|
| 576 | + $c[$champ] = $sinon; |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | + } |
|
| 580 | + |
|
| 581 | + // N'accepter que les champs qui existent |
|
| 582 | + // [TODO] ici aussi on peut valider les contenus en fonction du type |
|
| 583 | + $champs = []; |
|
| 584 | + foreach ($desc['field'] as $champ => $ignore) { |
|
| 585 | + if (isset($c[$champ])) { |
|
| 586 | + $champs[$champ] = $c[$champ]; |
|
| 587 | + } |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + // Nettoyer les valeurs |
|
| 591 | + $champs = array_map('corriger_caracteres', $champs); |
|
| 592 | + |
|
| 593 | + // Envoyer aux plugins |
|
| 594 | + $champs = pipeline( |
|
| 595 | + 'pre_edition', |
|
| 596 | + [ |
|
| 597 | + 'args' => [ |
|
| 598 | + 'table' => $spip_table_objet, // compatibilite |
|
| 599 | + 'table_objet' => $table_objet, |
|
| 600 | + 'spip_table_objet' => $spip_table_objet, |
|
| 601 | + 'type' => $type, |
|
| 602 | + 'id_objet' => $id, |
|
| 603 | + 'champs' => $options['champs'] ?? [], // [doc] c'est quoi ? |
|
| 604 | + 'action' => 'controler', |
|
| 605 | + 'serveur' => $serveur, |
|
| 606 | + ], |
|
| 607 | + 'data' => $champs |
|
| 608 | + ] |
|
| 609 | + ); |
|
| 610 | + |
|
| 611 | + if (!$champs) { |
|
| 612 | + return false; |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + // Verifier si les mises a jour sont pertinentes, datees, en conflit etc |
|
| 616 | + $conflits = controler_md5($champs, $_POST, $type, $id, $serveur, $options['prefix'] ?? 'ctr_'); |
|
| 617 | + |
|
| 618 | + return $conflits; |
|
| 619 | 619 | } |
| 620 | 620 | |
| 621 | 621 | |
@@ -645,64 +645,64 @@ discard block |
||
| 645 | 645 | * - post : le contenu posté |
| 646 | 646 | **/ |
| 647 | 647 | function controler_md5(&$champs, $ctr, $type, $id, $serveur, $prefix = 'ctr_') { |
| 648 | - $spip_table_objet = table_objet_sql($type); |
|
| 649 | - $id_table_objet = id_table_objet($type); |
|
| 650 | - |
|
| 651 | - // Controle des MD5 envoyes |
|
| 652 | - // On elimine les donnees non modifiees par le formulaire (mais |
|
| 653 | - // potentiellement modifiees entre temps par un autre utilisateur) |
|
| 654 | - foreach ($champs as $key => $val) { |
|
| 655 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 656 | - if (is_scalar($val) and $m == md5($val)) { |
|
| 657 | - unset($champs[$key]); |
|
| 658 | - } |
|
| 659 | - } |
|
| 660 | - } |
|
| 661 | - if (!$champs) { |
|
| 662 | - return; |
|
| 663 | - } |
|
| 664 | - |
|
| 665 | - // On veut savoir si notre modif va avoir un impact |
|
| 666 | - // par rapport aux donnees contenues dans la base |
|
| 667 | - // (qui peuvent etre differentes de celles ayant servi a calculer le ctr) |
|
| 668 | - $s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 669 | - $intact = true; |
|
| 670 | - foreach ($champs as $ch => $val) { |
|
| 671 | - $intact &= ($s[$ch] == $val); |
|
| 672 | - } |
|
| 673 | - if ($intact) { |
|
| 674 | - return; |
|
| 675 | - } |
|
| 676 | - |
|
| 677 | - // Detection de conflits : |
|
| 678 | - // On verifie si notre modif ne provient pas d'un formulaire |
|
| 679 | - // genere a partir de donnees modifiees dans l'intervalle ; ici |
|
| 680 | - // on compare a ce qui est dans la base, et on bloque en cas |
|
| 681 | - // de conflit. |
|
| 682 | - $ctrh = $ctrq = $conflits = []; |
|
| 683 | - foreach (array_keys($champs) as $key) { |
|
| 684 | - if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 685 | - $ctrh[$key] = $m; |
|
| 686 | - $ctrq[] = $key; |
|
| 687 | - } |
|
| 688 | - } |
|
| 689 | - if ($ctrq) { |
|
| 690 | - $ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 691 | - foreach ($ctrh as $key => $m) { |
|
| 692 | - if ( |
|
| 693 | - $m != md5($ctrq[$key]) |
|
| 694 | - and $champs[$key] !== $ctrq[$key] |
|
| 695 | - ) { |
|
| 696 | - $conflits[$key] = [ |
|
| 697 | - 'base' => $ctrq[$key], |
|
| 698 | - 'post' => $champs[$key] |
|
| 699 | - ]; |
|
| 700 | - unset($champs[$key]); # stocker quand meme les modifs ? |
|
| 701 | - } |
|
| 702 | - } |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - return $conflits; |
|
| 648 | + $spip_table_objet = table_objet_sql($type); |
|
| 649 | + $id_table_objet = id_table_objet($type); |
|
| 650 | + |
|
| 651 | + // Controle des MD5 envoyes |
|
| 652 | + // On elimine les donnees non modifiees par le formulaire (mais |
|
| 653 | + // potentiellement modifiees entre temps par un autre utilisateur) |
|
| 654 | + foreach ($champs as $key => $val) { |
|
| 655 | + if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 656 | + if (is_scalar($val) and $m == md5($val)) { |
|
| 657 | + unset($champs[$key]); |
|
| 658 | + } |
|
| 659 | + } |
|
| 660 | + } |
|
| 661 | + if (!$champs) { |
|
| 662 | + return; |
|
| 663 | + } |
|
| 664 | + |
|
| 665 | + // On veut savoir si notre modif va avoir un impact |
|
| 666 | + // par rapport aux donnees contenues dans la base |
|
| 667 | + // (qui peuvent etre differentes de celles ayant servi a calculer le ctr) |
|
| 668 | + $s = sql_fetsel(array_keys($champs), $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 669 | + $intact = true; |
|
| 670 | + foreach ($champs as $ch => $val) { |
|
| 671 | + $intact &= ($s[$ch] == $val); |
|
| 672 | + } |
|
| 673 | + if ($intact) { |
|
| 674 | + return; |
|
| 675 | + } |
|
| 676 | + |
|
| 677 | + // Detection de conflits : |
|
| 678 | + // On verifie si notre modif ne provient pas d'un formulaire |
|
| 679 | + // genere a partir de donnees modifiees dans l'intervalle ; ici |
|
| 680 | + // on compare a ce qui est dans la base, et on bloque en cas |
|
| 681 | + // de conflit. |
|
| 682 | + $ctrh = $ctrq = $conflits = []; |
|
| 683 | + foreach (array_keys($champs) as $key) { |
|
| 684 | + if (isset($ctr[$prefix . $key]) and $m = $ctr[$prefix . $key]) { |
|
| 685 | + $ctrh[$key] = $m; |
|
| 686 | + $ctrq[] = $key; |
|
| 687 | + } |
|
| 688 | + } |
|
| 689 | + if ($ctrq) { |
|
| 690 | + $ctrq = sql_fetsel($ctrq, $spip_table_objet, "$id_table_objet=$id", $serveur); |
|
| 691 | + foreach ($ctrh as $key => $m) { |
|
| 692 | + if ( |
|
| 693 | + $m != md5($ctrq[$key]) |
|
| 694 | + and $champs[$key] !== $ctrq[$key] |
|
| 695 | + ) { |
|
| 696 | + $conflits[$key] = [ |
|
| 697 | + 'base' => $ctrq[$key], |
|
| 698 | + 'post' => $champs[$key] |
|
| 699 | + ]; |
|
| 700 | + unset($champs[$key]); # stocker quand meme les modifs ? |
|
| 701 | + } |
|
| 702 | + } |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + return $conflits; |
|
| 706 | 706 | } |
| 707 | 707 | |
| 708 | 708 | /** |
@@ -714,9 +714,9 @@ discard block |
||
| 714 | 714 | * @return string |
| 715 | 715 | */ |
| 716 | 716 | function display_conflit_champ($x) { |
| 717 | - if (strstr($x, "\n") or strlen($x) > 80) { |
|
| 718 | - return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 719 | - } else { |
|
| 720 | - return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 721 | - } |
|
| 717 | + if (strstr($x, "\n") or strlen($x) > 80) { |
|
| 718 | + return "<textarea style='width:99%; height:10em;'>" . entites_html($x) . "</textarea>\n"; |
|
| 719 | + } else { |
|
| 720 | + return "<input type='text' size='40' style='width:99%' value=\"" . entites_html($x) . "\" />\n"; |
|
| 721 | + } |
|
| 722 | 722 | } |
@@ -339,8 +339,7 @@ |
||
| 339 | 339 | if (!autoriser('modifier', $type, intval($id))) { |
| 340 | 340 | $contexte['editable'] = ''; |
| 341 | 341 | } |
| 342 | - } |
|
| 343 | - else { |
|
| 342 | + } else { |
|
| 344 | 343 | if (!autoriser('creer', $type, 0, null, ['id_parent' => $id_parent])) { |
| 345 | 344 | $contexte['editable'] = ''; |
| 346 | 345 | } |