@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | */ |
| 30 | 30 | |
| 31 | 31 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 32 | - return; |
|
| 32 | + return; |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // charger la gestion les rôles sur les objets |
@@ -47,22 +47,22 @@ discard block |
||
| 47 | 47 | * - array(clé primaire, nom de la table de lien) si associable |
| 48 | 48 | */ |
| 49 | 49 | function objet_associable($objet) { |
| 50 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 51 | - $table_sql = table_objet_sql($objet); |
|
| 52 | - |
|
| 53 | - $l = ''; |
|
| 54 | - if ( |
|
| 55 | - $primary = id_table_objet($objet) |
|
| 56 | - and $trouver_table($l = $table_sql . '_liens', '', true, ['log_missing' => false]) |
|
| 57 | - and !preg_match(',[^\w],', $primary) |
|
| 58 | - and !preg_match(',[^\w],', $l) |
|
| 59 | - ) { |
|
| 60 | - return [$primary, $l]; |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l"); |
|
| 64 | - |
|
| 65 | - return false; |
|
| 50 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 51 | + $table_sql = table_objet_sql($objet); |
|
| 52 | + |
|
| 53 | + $l = ''; |
|
| 54 | + if ( |
|
| 55 | + $primary = id_table_objet($objet) |
|
| 56 | + and $trouver_table($l = $table_sql . '_liens', '', true, ['log_missing' => false]) |
|
| 57 | + and !preg_match(',[^\w],', $primary) |
|
| 58 | + and !preg_match(',[^\w],', $l) |
|
| 59 | + ) { |
|
| 60 | + return [$primary, $l]; |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l"); |
|
| 64 | + |
|
| 65 | + return false; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | /** |
@@ -88,13 +88,13 @@ discard block |
||
| 88 | 88 | * @return bool|int |
| 89 | 89 | */ |
| 90 | 90 | function objet_associer($objets_source, $objets_lies, $qualif = null) { |
| 91 | - $modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies, $qualif); |
|
| 91 | + $modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies, $qualif); |
|
| 92 | 92 | |
| 93 | - if ($qualif) { |
|
| 94 | - objet_qualifier_liens($objets_source, $objets_lies, $qualif); |
|
| 95 | - } |
|
| 93 | + if ($qualif) { |
|
| 94 | + objet_qualifier_liens($objets_source, $objets_lies, $qualif); |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - return $modifs; // pas d'erreur |
|
| 97 | + return $modifs; // pas d'erreur |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | * @return bool|int |
| 129 | 129 | */ |
| 130 | 130 | function objet_dissocier($objets_source, $objets_lies, $cond = null) { |
| 131 | - return objet_traiter_liaisons('lien_delete', $objets_source, $objets_lies, $cond); |
|
| 131 | + return objet_traiter_liaisons('lien_delete', $objets_source, $objets_lies, $cond); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
@@ -153,7 +153,7 @@ discard block |
||
| 153 | 153 | * @return bool|int |
| 154 | 154 | */ |
| 155 | 155 | function objet_qualifier_liens($objets_source, $objets_lies, $qualif) { |
| 156 | - return objet_traiter_liaisons('lien_set', $objets_source, $objets_lies, $qualif); |
|
| 156 | + return objet_traiter_liaisons('lien_set', $objets_source, $objets_lies, $qualif); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | * Liste des trouvailles |
| 189 | 189 | */ |
| 190 | 190 | function objet_trouver_liens($objets_source, $objets_lies, $cond = null) { |
| 191 | - return objet_traiter_liaisons('lien_find', $objets_source, $objets_lies, $cond); |
|
| 191 | + return objet_traiter_liaisons('lien_find', $objets_source, $objets_lies, $cond); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | |
@@ -212,8 +212,8 @@ discard block |
||
| 212 | 212 | * @return int |
| 213 | 213 | */ |
| 214 | 214 | function objet_optimiser_liens($objets_source, $objets_lies) { |
| 215 | - spip_log('objet_optimiser_liens : ' . json_encode($objets_source, JSON_THROW_ON_ERROR) . ', ' . json_encode($objets_lies, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG); |
|
| 216 | - return objet_traiter_liaisons('lien_optimise', $objets_source, $objets_lies); |
|
| 215 | + spip_log('objet_optimiser_liens : ' . json_encode($objets_source, JSON_THROW_ON_ERROR) . ', ' . json_encode($objets_lies, JSON_THROW_ON_ERROR), 'genie' . _LOG_DEBUG); |
|
| 216 | + return objet_traiter_liaisons('lien_optimise', $objets_source, $objets_lies); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | |
@@ -233,37 +233,37 @@ discard block |
||
| 233 | 233 | * Nombre de liens copiés |
| 234 | 234 | */ |
| 235 | 235 | function objet_dupliquer_liens($objet, $id_source, $id_cible, $types = null, $exclure_types = null) { |
| 236 | - include_spip('base/objets'); |
|
| 237 | - $tables = lister_tables_objets_sql(); |
|
| 238 | - $n = 0; |
|
| 239 | - foreach ($tables as $table_sql => $infos) { |
|
| 240 | - if ( |
|
| 241 | - (is_null($types) or in_array($infos['type'], $types)) |
|
| 242 | - and (is_null($exclure_types) or !in_array($infos['type'], $exclure_types)) |
|
| 243 | - ) { |
|
| 244 | - if (objet_associable($infos['type'])) { |
|
| 245 | - $liens = (($infos['type'] == $objet) ? |
|
| 246 | - objet_trouver_liens([$objet => $id_source], '*') |
|
| 247 | - : |
|
| 248 | - objet_trouver_liens([$infos['type'] => '*'], [$objet => $id_source])); |
|
| 249 | - foreach ($liens as $lien) { |
|
| 250 | - $n++; |
|
| 251 | - if ($infos['type'] == $objet) { |
|
| 252 | - if ( |
|
| 253 | - (is_null($types) or in_array($lien['objet'], $types)) |
|
| 254 | - and (is_null($exclure_types) or !in_array($lien['objet'], $exclure_types)) |
|
| 255 | - ) { |
|
| 256 | - objet_associer([$objet => $id_cible], [$lien['objet'] => $lien[$lien['objet']]], $lien); |
|
| 257 | - } |
|
| 258 | - } else { |
|
| 259 | - objet_associer([$infos['type'] => $lien[$infos['type']]], [$objet => $id_cible], $lien); |
|
| 260 | - } |
|
| 261 | - } |
|
| 262 | - } |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - |
|
| 266 | - return $n; |
|
| 236 | + include_spip('base/objets'); |
|
| 237 | + $tables = lister_tables_objets_sql(); |
|
| 238 | + $n = 0; |
|
| 239 | + foreach ($tables as $table_sql => $infos) { |
|
| 240 | + if ( |
|
| 241 | + (is_null($types) or in_array($infos['type'], $types)) |
|
| 242 | + and (is_null($exclure_types) or !in_array($infos['type'], $exclure_types)) |
|
| 243 | + ) { |
|
| 244 | + if (objet_associable($infos['type'])) { |
|
| 245 | + $liens = (($infos['type'] == $objet) ? |
|
| 246 | + objet_trouver_liens([$objet => $id_source], '*') |
|
| 247 | + : |
|
| 248 | + objet_trouver_liens([$infos['type'] => '*'], [$objet => $id_source])); |
|
| 249 | + foreach ($liens as $lien) { |
|
| 250 | + $n++; |
|
| 251 | + if ($infos['type'] == $objet) { |
|
| 252 | + if ( |
|
| 253 | + (is_null($types) or in_array($lien['objet'], $types)) |
|
| 254 | + and (is_null($exclure_types) or !in_array($lien['objet'], $exclure_types)) |
|
| 255 | + ) { |
|
| 256 | + objet_associer([$objet => $id_cible], [$lien['objet'] => $lien[$lien['objet']]], $lien); |
|
| 257 | + } |
|
| 258 | + } else { |
|
| 259 | + objet_associer([$infos['type'] => $lien[$infos['type']]], [$objet => $id_cible], $lien); |
|
| 260 | + } |
|
| 261 | + } |
|
| 262 | + } |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + |
|
| 266 | + return $n; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
@@ -305,38 +305,38 @@ discard block |
||
| 305 | 305 | * @return bool|int|array |
| 306 | 306 | */ |
| 307 | 307 | function objet_traiter_liaisons($operation, $objets_source, $objets_lies, $set = null) { |
| 308 | - // accepter une syntaxe minimale pour supprimer tous les liens |
|
| 309 | - if ($objets_lies == '*') { |
|
| 310 | - $objets_lies = ['*' => '*']; |
|
| 311 | - } |
|
| 312 | - $modifs = 0; // compter le nombre de modifications |
|
| 313 | - $echec = null; |
|
| 314 | - foreach ($objets_source as $objet => $ids) { |
|
| 315 | - if ($a = objet_associable($objet)) { |
|
| 316 | - [$primary, $l] = $a; |
|
| 317 | - if (!is_array($ids)) { |
|
| 318 | - $ids = [$ids]; |
|
| 319 | - } elseif (reset($ids) == 'NOT') { |
|
| 320 | - // si on demande un array('NOT',...) => recuperer la liste d'ids correspondants |
|
| 321 | - $where = lien_where($primary, $ids, '*', '*'); |
|
| 322 | - $ids = sql_allfetsel($primary, $l, $where); |
|
| 323 | - $ids = array_map('reset', $ids); |
|
| 324 | - } |
|
| 325 | - foreach ($ids as $id) { |
|
| 326 | - $res = $operation($objet, $primary, $l, $id, $objets_lies, $set); |
|
| 327 | - if ($res === false) { |
|
| 328 | - spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id", _LOG_ERREUR); |
|
| 329 | - $echec = true; |
|
| 330 | - } else { |
|
| 331 | - $modifs = ($modifs ? (is_array($res) ? array_merge($modifs, $res) : $modifs + $res) : $res); |
|
| 332 | - } |
|
| 333 | - } |
|
| 334 | - } else { |
|
| 335 | - $echec = true; |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - return ($echec ? false : $modifs); // pas d'erreur |
|
| 308 | + // accepter une syntaxe minimale pour supprimer tous les liens |
|
| 309 | + if ($objets_lies == '*') { |
|
| 310 | + $objets_lies = ['*' => '*']; |
|
| 311 | + } |
|
| 312 | + $modifs = 0; // compter le nombre de modifications |
|
| 313 | + $echec = null; |
|
| 314 | + foreach ($objets_source as $objet => $ids) { |
|
| 315 | + if ($a = objet_associable($objet)) { |
|
| 316 | + [$primary, $l] = $a; |
|
| 317 | + if (!is_array($ids)) { |
|
| 318 | + $ids = [$ids]; |
|
| 319 | + } elseif (reset($ids) == 'NOT') { |
|
| 320 | + // si on demande un array('NOT',...) => recuperer la liste d'ids correspondants |
|
| 321 | + $where = lien_where($primary, $ids, '*', '*'); |
|
| 322 | + $ids = sql_allfetsel($primary, $l, $where); |
|
| 323 | + $ids = array_map('reset', $ids); |
|
| 324 | + } |
|
| 325 | + foreach ($ids as $id) { |
|
| 326 | + $res = $operation($objet, $primary, $l, $id, $objets_lies, $set); |
|
| 327 | + if ($res === false) { |
|
| 328 | + spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id", _LOG_ERREUR); |
|
| 329 | + $echec = true; |
|
| 330 | + } else { |
|
| 331 | + $modifs = ($modifs ? (is_array($res) ? array_merge($modifs, $res) : $modifs + $res) : $res); |
|
| 332 | + } |
|
| 333 | + } |
|
| 334 | + } else { |
|
| 335 | + $echec = true; |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + return ($echec ? false : $modifs); // pas d'erreur |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | |
@@ -365,117 +365,117 @@ discard block |
||
| 365 | 365 | * Nombre d'insertions faites, false si échec. |
| 366 | 366 | */ |
| 367 | 367 | function lien_insert($objet_source, $primary, $table_lien, $id, $objets, $qualif) { |
| 368 | - $ins = 0; |
|
| 369 | - $echec = null; |
|
| 370 | - if (is_null($qualif)) { |
|
| 371 | - $qualif = []; |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - foreach ($objets as $objet => $id_objets) { |
|
| 375 | - if (!is_array($id_objets)) { |
|
| 376 | - $id_objets = [$id_objets]; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - // role, colonne, where par défaut |
|
| 380 | - [$role, $colonne_role, $cond] = |
|
| 381 | - roles_trouver_dans_qualif($objet_source, $objet, $qualif); |
|
| 382 | - |
|
| 383 | - foreach ($id_objets as $id_objet) { |
|
| 384 | - $objet = (($objet == '*') ? $objet : objet_type($objet)); # securite |
|
| 385 | - |
|
| 386 | - $insertions = [ |
|
| 387 | - 'id_objet' => $id_objet, |
|
| 388 | - 'objet' => $objet, |
|
| 389 | - $primary => $id |
|
| 390 | - ]; |
|
| 391 | - // rôle en plus s'il est défini |
|
| 392 | - if ($role) { |
|
| 393 | - $insertions += [ |
|
| 394 | - $colonne_role => $role |
|
| 395 | - ]; |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - if (lien_triables($table_lien)) { |
|
| 399 | - if (isset($qualif['rang_lien'])) { |
|
| 400 | - $rang = $qualif['rang_lien']; |
|
| 401 | - } |
|
| 402 | - else { |
|
| 403 | - $where = lien_where($primary, $id, $objet, $id_objet); |
|
| 404 | - // si il y a deja un lien pour ce couple (avec un autre role?) on reprend le meme rang si non nul |
|
| 405 | - if (!$rang = intval(sql_getfetsel('rang_lien', $table_lien, $where))) { |
|
| 406 | - $where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet); |
|
| 407 | - $rang = intval(sql_getfetsel('max(rang_lien)', $table_lien, $where)); |
|
| 408 | - // si aucun lien n'a de rang, on en introduit pas, on garde zero |
|
| 409 | - if ($rang > 0) { |
|
| 410 | - $rang = intval($rang) + 1; |
|
| 411 | - } |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - $insertions['rang_lien'] = $rang; |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - $args = [ |
|
| 418 | - 'table_lien' => $table_lien, |
|
| 419 | - 'objet_source' => $objet_source, |
|
| 420 | - 'id_objet_source' => $id, |
|
| 421 | - 'objet' => $objet, |
|
| 422 | - 'id_objet' => $id_objet, |
|
| 423 | - 'role' => $role, |
|
| 424 | - 'colonne_role' => $colonne_role, |
|
| 425 | - 'action' => 'insert', |
|
| 426 | - ]; |
|
| 427 | - |
|
| 428 | - // Envoyer aux plugins |
|
| 429 | - $insertions = pipeline( |
|
| 430 | - 'pre_edition_lien', |
|
| 431 | - [ |
|
| 432 | - 'args' => $args, |
|
| 433 | - 'data' => $insertions |
|
| 434 | - ] |
|
| 435 | - ); |
|
| 436 | - $args['id_objet'] = $insertions['id_objet']; |
|
| 437 | - |
|
| 438 | - $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 439 | - |
|
| 440 | - if ( |
|
| 441 | - ($id_objet = intval($insertions['id_objet']) or in_array($objet, ['site', 'rubrique'])) |
|
| 442 | - and !sql_getfetsel($primary, $table_lien, $where) |
|
| 443 | - ) { |
|
| 444 | - if (lien_triables($table_lien) and isset($insertions['rang_lien']) and intval($insertions['rang_lien'])) { |
|
| 445 | - $where_meme_lien = lien_where($primary, $id, $objet, $id_objet); |
|
| 446 | - $where_meme_lien = implode(' AND ', $where_meme_lien); |
|
| 447 | - // on decale les liens de rang_lien>=la valeur inseree pour faire la place |
|
| 448 | - // sauf sur le meme lien avec un role eventuellement different |
|
| 449 | - $w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . intval($insertions['rang_lien']), "NOT($where_meme_lien)"]); |
|
| 450 | - sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w); |
|
| 451 | - } |
|
| 452 | - |
|
| 453 | - $e = sql_insertq($table_lien, $insertions); |
|
| 454 | - if ($e !== false) { |
|
| 455 | - $ins++; |
|
| 456 | - lien_propage_date_modif($objet, $id_objet); |
|
| 457 | - lien_propage_date_modif($objet_source, $id); |
|
| 458 | - // Envoyer aux plugins |
|
| 459 | - pipeline( |
|
| 460 | - 'post_edition_lien', |
|
| 461 | - [ |
|
| 462 | - 'args' => $args, |
|
| 463 | - 'data' => $insertions |
|
| 464 | - ] |
|
| 465 | - ); |
|
| 466 | - } else { |
|
| 467 | - $echec = true; |
|
| 468 | - } |
|
| 469 | - } |
|
| 470 | - } |
|
| 471 | - } |
|
| 472 | - // si on a fait des insertions, on reordonne les liens concernes |
|
| 473 | - // pas la peine si $qualif['rang_lien'] etait fournie, on va passer dans lien_set a suivre et donc finir le recomptage |
|
| 474 | - if ($ins > 0 and empty($qualif['rang_lien'])) { |
|
| 475 | - lien_ordonner($objet_source, $primary, $table_lien, $id, $objets); |
|
| 476 | - } |
|
| 477 | - |
|
| 478 | - return ($echec ? false : $ins); |
|
| 368 | + $ins = 0; |
|
| 369 | + $echec = null; |
|
| 370 | + if (is_null($qualif)) { |
|
| 371 | + $qualif = []; |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + foreach ($objets as $objet => $id_objets) { |
|
| 375 | + if (!is_array($id_objets)) { |
|
| 376 | + $id_objets = [$id_objets]; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + // role, colonne, where par défaut |
|
| 380 | + [$role, $colonne_role, $cond] = |
|
| 381 | + roles_trouver_dans_qualif($objet_source, $objet, $qualif); |
|
| 382 | + |
|
| 383 | + foreach ($id_objets as $id_objet) { |
|
| 384 | + $objet = (($objet == '*') ? $objet : objet_type($objet)); # securite |
|
| 385 | + |
|
| 386 | + $insertions = [ |
|
| 387 | + 'id_objet' => $id_objet, |
|
| 388 | + 'objet' => $objet, |
|
| 389 | + $primary => $id |
|
| 390 | + ]; |
|
| 391 | + // rôle en plus s'il est défini |
|
| 392 | + if ($role) { |
|
| 393 | + $insertions += [ |
|
| 394 | + $colonne_role => $role |
|
| 395 | + ]; |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + if (lien_triables($table_lien)) { |
|
| 399 | + if (isset($qualif['rang_lien'])) { |
|
| 400 | + $rang = $qualif['rang_lien']; |
|
| 401 | + } |
|
| 402 | + else { |
|
| 403 | + $where = lien_where($primary, $id, $objet, $id_objet); |
|
| 404 | + // si il y a deja un lien pour ce couple (avec un autre role?) on reprend le meme rang si non nul |
|
| 405 | + if (!$rang = intval(sql_getfetsel('rang_lien', $table_lien, $where))) { |
|
| 406 | + $where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet); |
|
| 407 | + $rang = intval(sql_getfetsel('max(rang_lien)', $table_lien, $where)); |
|
| 408 | + // si aucun lien n'a de rang, on en introduit pas, on garde zero |
|
| 409 | + if ($rang > 0) { |
|
| 410 | + $rang = intval($rang) + 1; |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + $insertions['rang_lien'] = $rang; |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + $args = [ |
|
| 418 | + 'table_lien' => $table_lien, |
|
| 419 | + 'objet_source' => $objet_source, |
|
| 420 | + 'id_objet_source' => $id, |
|
| 421 | + 'objet' => $objet, |
|
| 422 | + 'id_objet' => $id_objet, |
|
| 423 | + 'role' => $role, |
|
| 424 | + 'colonne_role' => $colonne_role, |
|
| 425 | + 'action' => 'insert', |
|
| 426 | + ]; |
|
| 427 | + |
|
| 428 | + // Envoyer aux plugins |
|
| 429 | + $insertions = pipeline( |
|
| 430 | + 'pre_edition_lien', |
|
| 431 | + [ |
|
| 432 | + 'args' => $args, |
|
| 433 | + 'data' => $insertions |
|
| 434 | + ] |
|
| 435 | + ); |
|
| 436 | + $args['id_objet'] = $insertions['id_objet']; |
|
| 437 | + |
|
| 438 | + $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 439 | + |
|
| 440 | + if ( |
|
| 441 | + ($id_objet = intval($insertions['id_objet']) or in_array($objet, ['site', 'rubrique'])) |
|
| 442 | + and !sql_getfetsel($primary, $table_lien, $where) |
|
| 443 | + ) { |
|
| 444 | + if (lien_triables($table_lien) and isset($insertions['rang_lien']) and intval($insertions['rang_lien'])) { |
|
| 445 | + $where_meme_lien = lien_where($primary, $id, $objet, $id_objet); |
|
| 446 | + $where_meme_lien = implode(' AND ', $where_meme_lien); |
|
| 447 | + // on decale les liens de rang_lien>=la valeur inseree pour faire la place |
|
| 448 | + // sauf sur le meme lien avec un role eventuellement different |
|
| 449 | + $w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . intval($insertions['rang_lien']), "NOT($where_meme_lien)"]); |
|
| 450 | + sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w); |
|
| 451 | + } |
|
| 452 | + |
|
| 453 | + $e = sql_insertq($table_lien, $insertions); |
|
| 454 | + if ($e !== false) { |
|
| 455 | + $ins++; |
|
| 456 | + lien_propage_date_modif($objet, $id_objet); |
|
| 457 | + lien_propage_date_modif($objet_source, $id); |
|
| 458 | + // Envoyer aux plugins |
|
| 459 | + pipeline( |
|
| 460 | + 'post_edition_lien', |
|
| 461 | + [ |
|
| 462 | + 'args' => $args, |
|
| 463 | + 'data' => $insertions |
|
| 464 | + ] |
|
| 465 | + ); |
|
| 466 | + } else { |
|
| 467 | + $echec = true; |
|
| 468 | + } |
|
| 469 | + } |
|
| 470 | + } |
|
| 471 | + } |
|
| 472 | + // si on a fait des insertions, on reordonne les liens concernes |
|
| 473 | + // pas la peine si $qualif['rang_lien'] etait fournie, on va passer dans lien_set a suivre et donc finir le recomptage |
|
| 474 | + if ($ins > 0 and empty($qualif['rang_lien'])) { |
|
| 475 | + lien_ordonner($objet_source, $primary, $table_lien, $id, $objets); |
|
| 476 | + } |
|
| 477 | + |
|
| 478 | + return ($echec ? false : $ins); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | |
@@ -488,47 +488,47 @@ discard block |
||
| 488 | 488 | * @param array|string $objets |
| 489 | 489 | */ |
| 490 | 490 | function lien_ordonner($objet_source, $primary, $table_lien, $id, $objets) { |
| 491 | - if (!lien_triables($table_lien)) { |
|
| 492 | - return; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - $deja_reordonne = []; |
|
| 496 | - |
|
| 497 | - foreach ($objets as $objet => $id_objets) { |
|
| 498 | - if (!is_array($id_objets)) { |
|
| 499 | - $id_objets = [$id_objets]; |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - foreach ($id_objets as $id_objet) { |
|
| 503 | - if (empty($deja_reordonne[$id][$objet][$id_objet])) { |
|
| 504 | - $objet = (($objet == '*') ? $objet : objet_type($objet)); # securite |
|
| 505 | - |
|
| 506 | - $where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet); |
|
| 507 | - $liens = sql_allfetsel("$primary, id_objet, objet, rang_lien", $table_lien, $where, '', 'rang_lien'); |
|
| 508 | - |
|
| 509 | - $rangs = array_column($liens, 'rang_lien'); |
|
| 510 | - if (count($rangs) and (max($rangs) > 0 or min($rangs) < 0)) { |
|
| 511 | - $rang = 1; |
|
| 512 | - foreach ($liens as $lien) { |
|
| 513 | - if (empty($deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']])) { |
|
| 514 | - $where = lien_where($primary, $lien[$primary], $lien['objet'], $lien['id_objet'], ['rang_lien!=' . intval($rang)]); |
|
| 515 | - sql_updateq($table_lien, ['rang_lien' => $rang], $where); |
|
| 516 | - |
|
| 517 | - if (empty($deja_reordonne[$lien[$primary]])) { |
|
| 518 | - $deja_reordonne[$lien[$primary]] = []; |
|
| 519 | - } |
|
| 520 | - if (empty($deja_reordonne[$lien[$primary]][$lien['objet']])) { |
|
| 521 | - $deja_reordonne[$lien[$primary]][$lien['objet']] = []; |
|
| 522 | - } |
|
| 523 | - $deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']] = $rang; |
|
| 524 | - |
|
| 525 | - $rang++; |
|
| 526 | - } |
|
| 527 | - } |
|
| 528 | - } |
|
| 529 | - } |
|
| 530 | - } |
|
| 531 | - } |
|
| 491 | + if (!lien_triables($table_lien)) { |
|
| 492 | + return; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + $deja_reordonne = []; |
|
| 496 | + |
|
| 497 | + foreach ($objets as $objet => $id_objets) { |
|
| 498 | + if (!is_array($id_objets)) { |
|
| 499 | + $id_objets = [$id_objets]; |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + foreach ($id_objets as $id_objet) { |
|
| 503 | + if (empty($deja_reordonne[$id][$objet][$id_objet])) { |
|
| 504 | + $objet = (($objet == '*') ? $objet : objet_type($objet)); # securite |
|
| 505 | + |
|
| 506 | + $where = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet); |
|
| 507 | + $liens = sql_allfetsel("$primary, id_objet, objet, rang_lien", $table_lien, $where, '', 'rang_lien'); |
|
| 508 | + |
|
| 509 | + $rangs = array_column($liens, 'rang_lien'); |
|
| 510 | + if (count($rangs) and (max($rangs) > 0 or min($rangs) < 0)) { |
|
| 511 | + $rang = 1; |
|
| 512 | + foreach ($liens as $lien) { |
|
| 513 | + if (empty($deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']])) { |
|
| 514 | + $where = lien_where($primary, $lien[$primary], $lien['objet'], $lien['id_objet'], ['rang_lien!=' . intval($rang)]); |
|
| 515 | + sql_updateq($table_lien, ['rang_lien' => $rang], $where); |
|
| 516 | + |
|
| 517 | + if (empty($deja_reordonne[$lien[$primary]])) { |
|
| 518 | + $deja_reordonne[$lien[$primary]] = []; |
|
| 519 | + } |
|
| 520 | + if (empty($deja_reordonne[$lien[$primary]][$lien['objet']])) { |
|
| 521 | + $deja_reordonne[$lien[$primary]][$lien['objet']] = []; |
|
| 522 | + } |
|
| 523 | + $deja_reordonne[$lien[$primary]][$lien['objet']][$lien['id_objet']] = $rang; |
|
| 524 | + |
|
| 525 | + $rang++; |
|
| 526 | + } |
|
| 527 | + } |
|
| 528 | + } |
|
| 529 | + } |
|
| 530 | + } |
|
| 531 | + } |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | |
@@ -539,18 +539,18 @@ discard block |
||
| 539 | 539 | * @return mixed |
| 540 | 540 | */ |
| 541 | 541 | function lien_triables($table_lien) { |
| 542 | - static $triables = []; |
|
| 543 | - if (!isset($triables[$table_lien])) { |
|
| 544 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 545 | - $desc = $trouver_table($table_lien); |
|
| 546 | - if ($desc and isset($desc['field']['rang_lien'])) { |
|
| 547 | - $triables[$table_lien] = true; |
|
| 548 | - } |
|
| 549 | - else { |
|
| 550 | - $triables[$table_lien] = false; |
|
| 551 | - } |
|
| 552 | - } |
|
| 553 | - return $triables[$table_lien]; |
|
| 542 | + static $triables = []; |
|
| 543 | + if (!isset($triables[$table_lien])) { |
|
| 544 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 545 | + $desc = $trouver_table($table_lien); |
|
| 546 | + if ($desc and isset($desc['field']['rang_lien'])) { |
|
| 547 | + $triables[$table_lien] = true; |
|
| 548 | + } |
|
| 549 | + else { |
|
| 550 | + $triables[$table_lien] = false; |
|
| 551 | + } |
|
| 552 | + } |
|
| 553 | + return $triables[$table_lien]; |
|
| 554 | 554 | } |
| 555 | 555 | |
| 556 | 556 | |
@@ -566,52 +566,52 @@ discard block |
||
| 566 | 566 | * @return array Liste des conditions |
| 567 | 567 | */ |
| 568 | 568 | function lien_where($primary, $id_source, $objet, $id_objet, $cond = []) { |
| 569 | - if ( |
|
| 570 | - (!is_array($id_source) and !strlen($id_source)) |
|
| 571 | - or !strlen($objet) |
|
| 572 | - or (!is_array($id_objet) and !strlen($id_objet)) |
|
| 573 | - ) { |
|
| 574 | - return ['0=1']; |
|
| 575 | - } // securite |
|
| 576 | - |
|
| 577 | - $not = ''; |
|
| 578 | - if (is_array($id_source) and reset($id_source) == 'NOT') { |
|
| 579 | - $not = array_shift($id_source); |
|
| 580 | - $id_source = reset($id_source); |
|
| 581 | - } |
|
| 582 | - |
|
| 583 | - $where = $cond; |
|
| 584 | - |
|
| 585 | - if ($id_source !== '*') { |
|
| 586 | - $where[] = (is_array($id_source) ? sql_in( |
|
| 587 | - addslashes($primary), |
|
| 588 | - array_map('intval', $id_source), |
|
| 589 | - $not |
|
| 590 | - ) : addslashes($primary) . ($not ? '<>' : '=') . intval($id_source)); |
|
| 591 | - } elseif ($not) { |
|
| 592 | - $where[] = '0=1'; |
|
| 593 | - } // idiot mais quand meme |
|
| 594 | - |
|
| 595 | - $not = ''; |
|
| 596 | - if (is_array($id_objet) and reset($id_objet) == 'NOT') { |
|
| 597 | - $not = array_shift($id_objet); |
|
| 598 | - $id_objet = reset($id_objet); |
|
| 599 | - } |
|
| 600 | - |
|
| 601 | - if ($objet !== '*') { |
|
| 602 | - $where[] = 'objet=' . sql_quote($objet); |
|
| 603 | - } |
|
| 604 | - if ($id_objet !== '*') { |
|
| 605 | - $where[] = (is_array($id_objet) ? sql_in( |
|
| 606 | - 'id_objet', |
|
| 607 | - array_map('intval', $id_objet), |
|
| 608 | - $not |
|
| 609 | - ) : 'id_objet' . ($not ? '<>' : '=') . intval($id_objet)); |
|
| 610 | - } elseif ($not) { |
|
| 611 | - $where[] = '0=1'; |
|
| 612 | - } // idiot mais quand meme |
|
| 613 | - |
|
| 614 | - return $where; |
|
| 569 | + if ( |
|
| 570 | + (!is_array($id_source) and !strlen($id_source)) |
|
| 571 | + or !strlen($objet) |
|
| 572 | + or (!is_array($id_objet) and !strlen($id_objet)) |
|
| 573 | + ) { |
|
| 574 | + return ['0=1']; |
|
| 575 | + } // securite |
|
| 576 | + |
|
| 577 | + $not = ''; |
|
| 578 | + if (is_array($id_source) and reset($id_source) == 'NOT') { |
|
| 579 | + $not = array_shift($id_source); |
|
| 580 | + $id_source = reset($id_source); |
|
| 581 | + } |
|
| 582 | + |
|
| 583 | + $where = $cond; |
|
| 584 | + |
|
| 585 | + if ($id_source !== '*') { |
|
| 586 | + $where[] = (is_array($id_source) ? sql_in( |
|
| 587 | + addslashes($primary), |
|
| 588 | + array_map('intval', $id_source), |
|
| 589 | + $not |
|
| 590 | + ) : addslashes($primary) . ($not ? '<>' : '=') . intval($id_source)); |
|
| 591 | + } elseif ($not) { |
|
| 592 | + $where[] = '0=1'; |
|
| 593 | + } // idiot mais quand meme |
|
| 594 | + |
|
| 595 | + $not = ''; |
|
| 596 | + if (is_array($id_objet) and reset($id_objet) == 'NOT') { |
|
| 597 | + $not = array_shift($id_objet); |
|
| 598 | + $id_objet = reset($id_objet); |
|
| 599 | + } |
|
| 600 | + |
|
| 601 | + if ($objet !== '*') { |
|
| 602 | + $where[] = 'objet=' . sql_quote($objet); |
|
| 603 | + } |
|
| 604 | + if ($id_objet !== '*') { |
|
| 605 | + $where[] = (is_array($id_objet) ? sql_in( |
|
| 606 | + 'id_objet', |
|
| 607 | + array_map('intval', $id_objet), |
|
| 608 | + $not |
|
| 609 | + ) : 'id_objet' . ($not ? '<>' : '=') . intval($id_objet)); |
|
| 610 | + } elseif ($not) { |
|
| 611 | + $where[] = '0=1'; |
|
| 612 | + } // idiot mais quand meme |
|
| 613 | + |
|
| 614 | + return $where; |
|
| 615 | 615 | } |
| 616 | 616 | |
| 617 | 617 | /** |
@@ -626,13 +626,13 @@ discard block |
||
| 626 | 626 | */ |
| 627 | 627 | function lien_rang_where($table_lien, $primary, $id_source, $objet, $id_objet, $cond = []) { |
| 628 | 628 | |
| 629 | - // si on veut compter les rangs autrement que le core ne le fait par defaut, fournir le where adhoc |
|
| 630 | - if (function_exists($f = 'lien_rang_where_' . $table_lien)) { |
|
| 631 | - return $f($primary, $id_source, $objet, $id_objet, $cond); |
|
| 632 | - } |
|
| 629 | + // si on veut compter les rangs autrement que le core ne le fait par defaut, fournir le where adhoc |
|
| 630 | + if (function_exists($f = 'lien_rang_where_' . $table_lien)) { |
|
| 631 | + return $f($primary, $id_source, $objet, $id_objet, $cond); |
|
| 632 | + } |
|
| 633 | 633 | |
| 634 | - // par defaut c'est un rang compté pour tous les id_source d'un couple objet-id_objet |
|
| 635 | - return lien_where($primary, '*', $objet, $id_objet, $cond); |
|
| 634 | + // par defaut c'est un rang compté pour tous les id_source d'un couple objet-id_objet |
|
| 635 | + return lien_where($primary, '*', $objet, $id_objet, $cond); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | /** |
@@ -663,90 +663,90 @@ discard block |
||
| 663 | 663 | */ |
| 664 | 664 | function lien_delete($objet_source, $primary, $table_lien, $id, $objets, $cond = null) { |
| 665 | 665 | |
| 666 | - $retire = []; |
|
| 667 | - $dels = 0; |
|
| 668 | - $echec = false; |
|
| 669 | - if (is_null($cond)) { |
|
| 670 | - $cond = []; |
|
| 671 | - } |
|
| 672 | - |
|
| 673 | - foreach ($objets as $objet => $id_objets) { |
|
| 674 | - $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 675 | - if (!is_array($id_objets) or reset($id_objets) == 'NOT') { |
|
| 676 | - $id_objets = [$id_objets]; |
|
| 677 | - } |
|
| 678 | - foreach ($id_objets as $id_objet) { |
|
| 679 | - [$cond, $colonne_role, $role] = roles_creer_condition_role($objet_source, $objet, $cond); |
|
| 680 | - // id_objet peut valoir '*' |
|
| 681 | - $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 682 | - |
|
| 683 | - // lire les liens existants pour propager la date de modif |
|
| 684 | - $select = "$primary,id_objet,objet"; |
|
| 685 | - if ($colonne_role) { |
|
| 686 | - $select .= ",$colonne_role"; |
|
| 687 | - } |
|
| 688 | - $liens = sql_allfetsel($select, $table_lien, $where); |
|
| 689 | - |
|
| 690 | - // iterer sur les liens pour permettre aux plugins de gerer |
|
| 691 | - foreach ($liens as $l) { |
|
| 692 | - $args = [ |
|
| 693 | - 'table_lien' => $table_lien, |
|
| 694 | - 'objet_source' => $objet_source, |
|
| 695 | - 'id_objet_source' => $l[$primary], |
|
| 696 | - 'objet' => $l['objet'], |
|
| 697 | - 'id_objet' => $l['id_objet'], |
|
| 698 | - 'colonne_role' => $colonne_role, |
|
| 699 | - 'role' => ($colonne_role ? $l[$colonne_role] : ''), |
|
| 700 | - 'action' => 'delete', |
|
| 701 | - ]; |
|
| 702 | - |
|
| 703 | - // Envoyer aux plugins |
|
| 704 | - $l = pipeline( |
|
| 705 | - 'pre_edition_lien', |
|
| 706 | - [ |
|
| 707 | - 'args' => $args, |
|
| 708 | - 'data' => $l |
|
| 709 | - ] |
|
| 710 | - ); |
|
| 711 | - $args['id_objet'] = $id_o = $l['id_objet']; |
|
| 712 | - |
|
| 713 | - if ($id_o = intval($l['id_objet']) or in_array($l['objet'], ['site', 'rubrique'])) { |
|
| 714 | - $where = lien_where($primary, $l[$primary], $l['objet'], $id_o, $cond); |
|
| 715 | - $e = sql_delete($table_lien, $where); |
|
| 716 | - if ($e !== false) { |
|
| 717 | - $dels += $e; |
|
| 718 | - lien_propage_date_modif($l['objet'], $id_o); |
|
| 719 | - lien_propage_date_modif($objet_source, $l[$primary]); |
|
| 720 | - } else { |
|
| 721 | - $echec = true; |
|
| 722 | - } |
|
| 723 | - $retire[] = [ |
|
| 724 | - 'source' => [$objet_source => $l[$primary]], |
|
| 725 | - 'lien' => [$l['objet'] => $id_o], |
|
| 726 | - 'type' => $l['objet'], |
|
| 727 | - 'role' => ($colonne_role ? $l[$colonne_role] : ''), |
|
| 728 | - 'id' => $id_o |
|
| 729 | - ]; |
|
| 730 | - // Envoyer aux plugins |
|
| 731 | - pipeline( |
|
| 732 | - 'post_edition_lien', |
|
| 733 | - [ |
|
| 734 | - 'args' => $args, |
|
| 735 | - 'data' => $l |
|
| 736 | - ] |
|
| 737 | - ); |
|
| 738 | - } |
|
| 739 | - } |
|
| 740 | - } |
|
| 741 | - } |
|
| 742 | - // si on a supprime des liens, on reordonne les liens concernes |
|
| 743 | - if ($dels) { |
|
| 744 | - lien_ordonner($objet_source, $primary, $table_lien, $id, $objets); |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - pipeline('trig_supprimer_objets_lies', $retire); |
|
| 748 | - |
|
| 749 | - return ($echec ? false : $dels); |
|
| 666 | + $retire = []; |
|
| 667 | + $dels = 0; |
|
| 668 | + $echec = false; |
|
| 669 | + if (is_null($cond)) { |
|
| 670 | + $cond = []; |
|
| 671 | + } |
|
| 672 | + |
|
| 673 | + foreach ($objets as $objet => $id_objets) { |
|
| 674 | + $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 675 | + if (!is_array($id_objets) or reset($id_objets) == 'NOT') { |
|
| 676 | + $id_objets = [$id_objets]; |
|
| 677 | + } |
|
| 678 | + foreach ($id_objets as $id_objet) { |
|
| 679 | + [$cond, $colonne_role, $role] = roles_creer_condition_role($objet_source, $objet, $cond); |
|
| 680 | + // id_objet peut valoir '*' |
|
| 681 | + $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 682 | + |
|
| 683 | + // lire les liens existants pour propager la date de modif |
|
| 684 | + $select = "$primary,id_objet,objet"; |
|
| 685 | + if ($colonne_role) { |
|
| 686 | + $select .= ",$colonne_role"; |
|
| 687 | + } |
|
| 688 | + $liens = sql_allfetsel($select, $table_lien, $where); |
|
| 689 | + |
|
| 690 | + // iterer sur les liens pour permettre aux plugins de gerer |
|
| 691 | + foreach ($liens as $l) { |
|
| 692 | + $args = [ |
|
| 693 | + 'table_lien' => $table_lien, |
|
| 694 | + 'objet_source' => $objet_source, |
|
| 695 | + 'id_objet_source' => $l[$primary], |
|
| 696 | + 'objet' => $l['objet'], |
|
| 697 | + 'id_objet' => $l['id_objet'], |
|
| 698 | + 'colonne_role' => $colonne_role, |
|
| 699 | + 'role' => ($colonne_role ? $l[$colonne_role] : ''), |
|
| 700 | + 'action' => 'delete', |
|
| 701 | + ]; |
|
| 702 | + |
|
| 703 | + // Envoyer aux plugins |
|
| 704 | + $l = pipeline( |
|
| 705 | + 'pre_edition_lien', |
|
| 706 | + [ |
|
| 707 | + 'args' => $args, |
|
| 708 | + 'data' => $l |
|
| 709 | + ] |
|
| 710 | + ); |
|
| 711 | + $args['id_objet'] = $id_o = $l['id_objet']; |
|
| 712 | + |
|
| 713 | + if ($id_o = intval($l['id_objet']) or in_array($l['objet'], ['site', 'rubrique'])) { |
|
| 714 | + $where = lien_where($primary, $l[$primary], $l['objet'], $id_o, $cond); |
|
| 715 | + $e = sql_delete($table_lien, $where); |
|
| 716 | + if ($e !== false) { |
|
| 717 | + $dels += $e; |
|
| 718 | + lien_propage_date_modif($l['objet'], $id_o); |
|
| 719 | + lien_propage_date_modif($objet_source, $l[$primary]); |
|
| 720 | + } else { |
|
| 721 | + $echec = true; |
|
| 722 | + } |
|
| 723 | + $retire[] = [ |
|
| 724 | + 'source' => [$objet_source => $l[$primary]], |
|
| 725 | + 'lien' => [$l['objet'] => $id_o], |
|
| 726 | + 'type' => $l['objet'], |
|
| 727 | + 'role' => ($colonne_role ? $l[$colonne_role] : ''), |
|
| 728 | + 'id' => $id_o |
|
| 729 | + ]; |
|
| 730 | + // Envoyer aux plugins |
|
| 731 | + pipeline( |
|
| 732 | + 'post_edition_lien', |
|
| 733 | + [ |
|
| 734 | + 'args' => $args, |
|
| 735 | + 'data' => $l |
|
| 736 | + ] |
|
| 737 | + ); |
|
| 738 | + } |
|
| 739 | + } |
|
| 740 | + } |
|
| 741 | + } |
|
| 742 | + // si on a supprime des liens, on reordonne les liens concernes |
|
| 743 | + if ($dels) { |
|
| 744 | + lien_ordonner($objet_source, $primary, $table_lien, $id, $objets); |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + pipeline('trig_supprimer_objets_lies', $retire); |
|
| 748 | + |
|
| 749 | + return ($echec ? false : $dels); |
|
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | |
@@ -769,67 +769,67 @@ discard block |
||
| 769 | 769 | * @return bool|int |
| 770 | 770 | */ |
| 771 | 771 | function lien_optimise($objet_source, $primary, $table_lien, $id, $objets) { |
| 772 | - include_spip('genie/optimiser'); |
|
| 773 | - $echec = false; |
|
| 774 | - $dels = 0; |
|
| 775 | - foreach ($objets as $objet => $id_objets) { |
|
| 776 | - $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 777 | - if (!is_array($id_objets) or reset($id_objets) == 'NOT') { |
|
| 778 | - $id_objets = [$id_objets]; |
|
| 779 | - } |
|
| 780 | - foreach ($id_objets as $id_objet) { |
|
| 781 | - $where = lien_where($primary, $id, $objet, $id_objet); |
|
| 782 | - # les liens vers un objet inexistant |
|
| 783 | - $r = sql_select('DISTINCT objet', $table_lien, $where); |
|
| 784 | - while ($t = sql_fetch($r)) { |
|
| 785 | - $type = $t['objet']; |
|
| 786 | - $spip_table_objet = table_objet_sql($type); |
|
| 787 | - $id_table_objet = id_table_objet($type); |
|
| 788 | - $res = sql_select( |
|
| 789 | - "L.$primary AS id,L.id_objet", |
|
| 790 | - // la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes |
|
| 791 | - // du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN |
|
| 792 | - // il faut les eliminier en repetant la condition dans le where L.objet='xxx' |
|
| 793 | - "$table_lien AS L |
|
| 772 | + include_spip('genie/optimiser'); |
|
| 773 | + $echec = false; |
|
| 774 | + $dels = 0; |
|
| 775 | + foreach ($objets as $objet => $id_objets) { |
|
| 776 | + $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 777 | + if (!is_array($id_objets) or reset($id_objets) == 'NOT') { |
|
| 778 | + $id_objets = [$id_objets]; |
|
| 779 | + } |
|
| 780 | + foreach ($id_objets as $id_objet) { |
|
| 781 | + $where = lien_where($primary, $id, $objet, $id_objet); |
|
| 782 | + # les liens vers un objet inexistant |
|
| 783 | + $r = sql_select('DISTINCT objet', $table_lien, $where); |
|
| 784 | + while ($t = sql_fetch($r)) { |
|
| 785 | + $type = $t['objet']; |
|
| 786 | + $spip_table_objet = table_objet_sql($type); |
|
| 787 | + $id_table_objet = id_table_objet($type); |
|
| 788 | + $res = sql_select( |
|
| 789 | + "L.$primary AS id,L.id_objet", |
|
| 790 | + // la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes |
|
| 791 | + // du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN |
|
| 792 | + // il faut les eliminier en repetant la condition dans le where L.objet='xxx' |
|
| 793 | + "$table_lien AS L |
|
| 794 | 794 | LEFT JOIN $spip_table_objet AS O |
| 795 | 795 | ON (O.$id_table_objet=L.id_objet AND L.objet=" . sql_quote($type) . ')', |
| 796 | - 'L.objet=' . sql_quote($type) . " AND O.$id_table_objet IS NULL" |
|
| 797 | - ); |
|
| 798 | - // sur une cle primaire composee, pas d'autres solutions que de virer un a un |
|
| 799 | - while ($row = sql_fetch($res)) { |
|
| 800 | - if ($primary === 'id_document' and in_array($type, ['site', 'rubrique']) and !intval($row['id_objet'])) { |
|
| 801 | - continue; // gaffe, c'est le logo du site ou des rubriques! |
|
| 802 | - } |
|
| 803 | - $e = sql_delete( |
|
| 804 | - $table_lien, |
|
| 805 | - ["$primary=" . $row['id'], 'id_objet=' . $row['id_objet'], 'objet=' . sql_quote($type)] |
|
| 806 | - ); |
|
| 807 | - if ($e != false) { |
|
| 808 | - $dels += $e; |
|
| 809 | - spip_log( |
|
| 810 | - 'lien_optimise: Entree ' . $row['id'] . '/' . $row['id_objet'] . "/$type supprimee dans la table $table_lien", |
|
| 811 | - 'genie' . _LOG_INFO_IMPORTANTE |
|
| 812 | - ); |
|
| 813 | - } |
|
| 814 | - } |
|
| 815 | - } |
|
| 816 | - |
|
| 817 | - # les liens depuis un objet inexistant |
|
| 818 | - $table_source = table_objet_sql($objet_source); |
|
| 819 | - // filtrer selon $id, $objet, $id_objet eventuellement fournis |
|
| 820 | - // (en general '*' pour chaque) |
|
| 821 | - $where = lien_where("L.$primary", $id, $objet, $id_objet); |
|
| 822 | - $where[] = "O.$primary IS NULL"; |
|
| 823 | - $res = sql_select( |
|
| 824 | - "L.$primary AS id", |
|
| 825 | - "$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary", |
|
| 826 | - $where |
|
| 827 | - ); |
|
| 828 | - $dels += optimiser_sansref($table_lien, $primary, $res); |
|
| 829 | - } |
|
| 830 | - } |
|
| 831 | - |
|
| 832 | - return ($echec ? false : $dels); |
|
| 796 | + 'L.objet=' . sql_quote($type) . " AND O.$id_table_objet IS NULL" |
|
| 797 | + ); |
|
| 798 | + // sur une cle primaire composee, pas d'autres solutions que de virer un a un |
|
| 799 | + while ($row = sql_fetch($res)) { |
|
| 800 | + if ($primary === 'id_document' and in_array($type, ['site', 'rubrique']) and !intval($row['id_objet'])) { |
|
| 801 | + continue; // gaffe, c'est le logo du site ou des rubriques! |
|
| 802 | + } |
|
| 803 | + $e = sql_delete( |
|
| 804 | + $table_lien, |
|
| 805 | + ["$primary=" . $row['id'], 'id_objet=' . $row['id_objet'], 'objet=' . sql_quote($type)] |
|
| 806 | + ); |
|
| 807 | + if ($e != false) { |
|
| 808 | + $dels += $e; |
|
| 809 | + spip_log( |
|
| 810 | + 'lien_optimise: Entree ' . $row['id'] . '/' . $row['id_objet'] . "/$type supprimee dans la table $table_lien", |
|
| 811 | + 'genie' . _LOG_INFO_IMPORTANTE |
|
| 812 | + ); |
|
| 813 | + } |
|
| 814 | + } |
|
| 815 | + } |
|
| 816 | + |
|
| 817 | + # les liens depuis un objet inexistant |
|
| 818 | + $table_source = table_objet_sql($objet_source); |
|
| 819 | + // filtrer selon $id, $objet, $id_objet eventuellement fournis |
|
| 820 | + // (en general '*' pour chaque) |
|
| 821 | + $where = lien_where("L.$primary", $id, $objet, $id_objet); |
|
| 822 | + $where[] = "O.$primary IS NULL"; |
|
| 823 | + $res = sql_select( |
|
| 824 | + "L.$primary AS id", |
|
| 825 | + "$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary", |
|
| 826 | + $where |
|
| 827 | + ); |
|
| 828 | + $dels += optimiser_sansref($table_lien, $primary, $res); |
|
| 829 | + } |
|
| 830 | + } |
|
| 831 | + |
|
| 832 | + return ($echec ? false : $dels); |
|
| 833 | 833 | } |
| 834 | 834 | |
| 835 | 835 | |
@@ -861,92 +861,92 @@ discard block |
||
| 861 | 861 | * Nombre de modifications faites, false si échec. |
| 862 | 862 | */ |
| 863 | 863 | function lien_set($objet_source, $primary, $table_lien, $id, $objets, $qualif) { |
| 864 | - $echec = null; |
|
| 865 | - $ok = 0; |
|
| 866 | - $reordonner = false; |
|
| 867 | - if (!$qualif) { |
|
| 868 | - return false; |
|
| 869 | - } |
|
| 870 | - // nettoyer qualif qui peut venir directement d'un objet_trouver_lien : |
|
| 871 | - unset($qualif[$primary]); |
|
| 872 | - unset($qualif[$objet_source]); |
|
| 873 | - if (isset($qualif['objet'])) { |
|
| 874 | - unset($qualif[$qualif['objet']]); |
|
| 875 | - } |
|
| 876 | - unset($qualif['objet']); |
|
| 877 | - unset($qualif['id_objet']); |
|
| 878 | - foreach ($objets as $objet => $id_objets) { |
|
| 879 | - // role, colonne, where par défaut |
|
| 880 | - [$role, $colonne_role, $cond] = |
|
| 881 | - roles_trouver_dans_qualif($objet_source, $objet, $qualif); |
|
| 882 | - |
|
| 883 | - $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 884 | - if (!is_array($id_objets) or reset($id_objets) == 'NOT') { |
|
| 885 | - $id_objets = [$id_objets]; |
|
| 886 | - } |
|
| 887 | - foreach ($id_objets as $id_objet) { |
|
| 888 | - $args = [ |
|
| 889 | - 'table_lien' => $table_lien, |
|
| 890 | - 'objet_source' => $objet_source, |
|
| 891 | - 'id_objet_source' => $id, |
|
| 892 | - 'objet' => $objet, |
|
| 893 | - 'id_objet' => $id_objet, |
|
| 894 | - 'role' => $role, |
|
| 895 | - 'colonne_role' => $colonne_role, |
|
| 896 | - 'action' => 'modifier', |
|
| 897 | - ]; |
|
| 898 | - |
|
| 899 | - // Envoyer aux plugins |
|
| 900 | - $qualif = pipeline( |
|
| 901 | - 'pre_edition_lien', |
|
| 902 | - [ |
|
| 903 | - 'args' => $args, |
|
| 904 | - 'data' => $qualif, |
|
| 905 | - ] |
|
| 906 | - ); |
|
| 907 | - $args['id_objet'] = $id_objet; |
|
| 908 | - |
|
| 909 | - if (lien_triables($table_lien) and isset($qualif['rang_lien'])) { |
|
| 910 | - if (intval($qualif['rang_lien'])) { |
|
| 911 | - // on decale les liens de rang_lien>=la valeur inseree pour faire la place |
|
| 912 | - // sauf sur le meme lien avec un role eventuellement different |
|
| 913 | - $where_meme_lien = lien_where($primary, $id, $objet, $id_objet); |
|
| 914 | - $where_meme_lien = implode(' AND ', $where_meme_lien); |
|
| 915 | - $w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . intval($qualif['rang_lien']), "NOT($where_meme_lien)"]); |
|
| 916 | - sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w); |
|
| 917 | - } |
|
| 918 | - // tous les liens de même rôle recoivent le rang indiqué aussi |
|
| 919 | - if (roles_colonne($objet_source, $objet)) { |
|
| 920 | - $w = lien_where($primary, $id, $objet, $id_objet); |
|
| 921 | - sql_updateq($table_lien, ['rang_lien' => intval($qualif['rang_lien'])], $w); |
|
| 922 | - } |
|
| 923 | - $reordonner = true; |
|
| 924 | - } |
|
| 925 | - |
|
| 926 | - $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 927 | - $e = sql_updateq($table_lien, $qualif, $where); |
|
| 928 | - |
|
| 929 | - if ($e === false) { |
|
| 930 | - $echec = true; |
|
| 931 | - } else { |
|
| 932 | - // Envoyer aux plugins |
|
| 933 | - pipeline( |
|
| 934 | - 'post_edition_lien', |
|
| 935 | - [ |
|
| 936 | - 'args' => $args, |
|
| 937 | - 'data' => $qualif |
|
| 938 | - ] |
|
| 939 | - ); |
|
| 940 | - $ok++; |
|
| 941 | - } |
|
| 942 | - } |
|
| 943 | - } |
|
| 944 | - // si on a fait des modif de rang, on reordonne les liens concernes |
|
| 945 | - if ($reordonner) { |
|
| 946 | - lien_ordonner($objet_source, $primary, $table_lien, $id, $objets); |
|
| 947 | - } |
|
| 948 | - |
|
| 949 | - return ($echec ? false : $ok); |
|
| 864 | + $echec = null; |
|
| 865 | + $ok = 0; |
|
| 866 | + $reordonner = false; |
|
| 867 | + if (!$qualif) { |
|
| 868 | + return false; |
|
| 869 | + } |
|
| 870 | + // nettoyer qualif qui peut venir directement d'un objet_trouver_lien : |
|
| 871 | + unset($qualif[$primary]); |
|
| 872 | + unset($qualif[$objet_source]); |
|
| 873 | + if (isset($qualif['objet'])) { |
|
| 874 | + unset($qualif[$qualif['objet']]); |
|
| 875 | + } |
|
| 876 | + unset($qualif['objet']); |
|
| 877 | + unset($qualif['id_objet']); |
|
| 878 | + foreach ($objets as $objet => $id_objets) { |
|
| 879 | + // role, colonne, where par défaut |
|
| 880 | + [$role, $colonne_role, $cond] = |
|
| 881 | + roles_trouver_dans_qualif($objet_source, $objet, $qualif); |
|
| 882 | + |
|
| 883 | + $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 884 | + if (!is_array($id_objets) or reset($id_objets) == 'NOT') { |
|
| 885 | + $id_objets = [$id_objets]; |
|
| 886 | + } |
|
| 887 | + foreach ($id_objets as $id_objet) { |
|
| 888 | + $args = [ |
|
| 889 | + 'table_lien' => $table_lien, |
|
| 890 | + 'objet_source' => $objet_source, |
|
| 891 | + 'id_objet_source' => $id, |
|
| 892 | + 'objet' => $objet, |
|
| 893 | + 'id_objet' => $id_objet, |
|
| 894 | + 'role' => $role, |
|
| 895 | + 'colonne_role' => $colonne_role, |
|
| 896 | + 'action' => 'modifier', |
|
| 897 | + ]; |
|
| 898 | + |
|
| 899 | + // Envoyer aux plugins |
|
| 900 | + $qualif = pipeline( |
|
| 901 | + 'pre_edition_lien', |
|
| 902 | + [ |
|
| 903 | + 'args' => $args, |
|
| 904 | + 'data' => $qualif, |
|
| 905 | + ] |
|
| 906 | + ); |
|
| 907 | + $args['id_objet'] = $id_objet; |
|
| 908 | + |
|
| 909 | + if (lien_triables($table_lien) and isset($qualif['rang_lien'])) { |
|
| 910 | + if (intval($qualif['rang_lien'])) { |
|
| 911 | + // on decale les liens de rang_lien>=la valeur inseree pour faire la place |
|
| 912 | + // sauf sur le meme lien avec un role eventuellement different |
|
| 913 | + $where_meme_lien = lien_where($primary, $id, $objet, $id_objet); |
|
| 914 | + $where_meme_lien = implode(' AND ', $where_meme_lien); |
|
| 915 | + $w = lien_rang_where($table_lien, $primary, $id, $objet, $id_objet, ['rang_lien>=' . intval($qualif['rang_lien']), "NOT($where_meme_lien)"]); |
|
| 916 | + sql_update($table_lien, ['rang_lien' => 'rang_lien+1'], $w); |
|
| 917 | + } |
|
| 918 | + // tous les liens de même rôle recoivent le rang indiqué aussi |
|
| 919 | + if (roles_colonne($objet_source, $objet)) { |
|
| 920 | + $w = lien_where($primary, $id, $objet, $id_objet); |
|
| 921 | + sql_updateq($table_lien, ['rang_lien' => intval($qualif['rang_lien'])], $w); |
|
| 922 | + } |
|
| 923 | + $reordonner = true; |
|
| 924 | + } |
|
| 925 | + |
|
| 926 | + $where = lien_where($primary, $id, $objet, $id_objet, $cond); |
|
| 927 | + $e = sql_updateq($table_lien, $qualif, $where); |
|
| 928 | + |
|
| 929 | + if ($e === false) { |
|
| 930 | + $echec = true; |
|
| 931 | + } else { |
|
| 932 | + // Envoyer aux plugins |
|
| 933 | + pipeline( |
|
| 934 | + 'post_edition_lien', |
|
| 935 | + [ |
|
| 936 | + 'args' => $args, |
|
| 937 | + 'data' => $qualif |
|
| 938 | + ] |
|
| 939 | + ); |
|
| 940 | + $ok++; |
|
| 941 | + } |
|
| 942 | + } |
|
| 943 | + } |
|
| 944 | + // si on a fait des modif de rang, on reordonne les liens concernes |
|
| 945 | + if ($reordonner) { |
|
| 946 | + lien_ordonner($objet_source, $primary, $table_lien, $id, $objets); |
|
| 947 | + } |
|
| 948 | + |
|
| 949 | + return ($echec ? false : $ok); |
|
| 950 | 950 | } |
| 951 | 951 | |
| 952 | 952 | /** |
@@ -976,23 +976,23 @@ discard block |
||
| 976 | 976 | * @return array |
| 977 | 977 | */ |
| 978 | 978 | function lien_find($objet_source, $primary, $table_lien, $id, $objets, $cond = null) { |
| 979 | - $trouve = []; |
|
| 980 | - foreach ($objets as $objet => $id_objets) { |
|
| 981 | - $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 982 | - // gerer les roles s'il y en a dans $cond |
|
| 983 | - [$cond] = roles_creer_condition_role($objet_source, $objet, $cond, true); |
|
| 984 | - // lien_where prend en charge les $id_objets sous forme int ou array |
|
| 985 | - $where = lien_where($primary, $id, $objet, $id_objets, $cond); |
|
| 986 | - $liens = sql_allfetsel('*', $table_lien, $where); |
|
| 987 | - // ajouter les entrees objet_source et objet cible par convenance |
|
| 988 | - foreach ($liens as $l) { |
|
| 989 | - $l[$objet_source] = $l[$primary]; |
|
| 990 | - $l[$l['objet']] = $l['id_objet']; |
|
| 991 | - $trouve[] = $l; |
|
| 992 | - } |
|
| 993 | - } |
|
| 994 | - |
|
| 995 | - return $trouve; |
|
| 979 | + $trouve = []; |
|
| 980 | + foreach ($objets as $objet => $id_objets) { |
|
| 981 | + $objet = ($objet == '*') ? $objet : objet_type($objet); # securite |
|
| 982 | + // gerer les roles s'il y en a dans $cond |
|
| 983 | + [$cond] = roles_creer_condition_role($objet_source, $objet, $cond, true); |
|
| 984 | + // lien_where prend en charge les $id_objets sous forme int ou array |
|
| 985 | + $where = lien_where($primary, $id, $objet, $id_objets, $cond); |
|
| 986 | + $liens = sql_allfetsel('*', $table_lien, $where); |
|
| 987 | + // ajouter les entrees objet_source et objet cible par convenance |
|
| 988 | + foreach ($liens as $l) { |
|
| 989 | + $l[$objet_source] = $l[$primary]; |
|
| 990 | + $l[$l['objet']] = $l['id_objet']; |
|
| 991 | + $trouve[] = $l; |
|
| 992 | + } |
|
| 993 | + } |
|
| 994 | + |
|
| 995 | + return $trouve; |
|
| 996 | 996 | } |
| 997 | 997 | |
| 998 | 998 | /** |
@@ -1003,26 +1003,26 @@ discard block |
||
| 1003 | 1003 | * @param array|int $ids |
| 1004 | 1004 | */ |
| 1005 | 1005 | function lien_propage_date_modif($objet, $ids) { |
| 1006 | - static $done = []; |
|
| 1007 | - $hash = md5($objet . serialize($ids)); |
|
| 1008 | - |
|
| 1009 | - // sql_updateq, peut être un rien lent. |
|
| 1010 | - // On évite de l'appeler 2 fois sur les mêmes choses |
|
| 1011 | - if (isset($done[$hash])) { |
|
| 1012 | - return; |
|
| 1013 | - } |
|
| 1014 | - |
|
| 1015 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1016 | - |
|
| 1017 | - $table = table_objet_sql($objet); |
|
| 1018 | - if ( |
|
| 1019 | - $desc = $trouver_table($table) |
|
| 1020 | - and isset($desc['field']['date_modif']) |
|
| 1021 | - ) { |
|
| 1022 | - $primary = id_table_objet($objet); |
|
| 1023 | - $where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=" . intval($ids)); |
|
| 1024 | - sql_updateq($table, ['date_modif' => date('Y-m-d H:i:s')], $where); |
|
| 1025 | - } |
|
| 1026 | - |
|
| 1027 | - $done[$hash] = true; |
|
| 1006 | + static $done = []; |
|
| 1007 | + $hash = md5($objet . serialize($ids)); |
|
| 1008 | + |
|
| 1009 | + // sql_updateq, peut être un rien lent. |
|
| 1010 | + // On évite de l'appeler 2 fois sur les mêmes choses |
|
| 1011 | + if (isset($done[$hash])) { |
|
| 1012 | + return; |
|
| 1013 | + } |
|
| 1014 | + |
|
| 1015 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 1016 | + |
|
| 1017 | + $table = table_objet_sql($objet); |
|
| 1018 | + if ( |
|
| 1019 | + $desc = $trouver_table($table) |
|
| 1020 | + and isset($desc['field']['date_modif']) |
|
| 1021 | + ) { |
|
| 1022 | + $primary = id_table_objet($objet); |
|
| 1023 | + $where = (is_array($ids) ? sql_in($primary, array_map('intval', $ids)) : "$primary=" . intval($ids)); |
|
| 1024 | + sql_updateq($table, ['date_modif' => date('Y-m-d H:i:s')], $where); |
|
| 1025 | + } |
|
| 1026 | + |
|
| 1027 | + $done[$hash] = true; |
|
| 1028 | 1028 | } |
@@ -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 | /** |
@@ -25,41 +25,41 @@ discard block |
||
| 25 | 25 | **/ |
| 26 | 26 | function action_instituer_langue_rubrique_dist() { |
| 27 | 27 | |
| 28 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | - $arg = $securiser_action(); |
|
| 30 | - $changer_lang = _request('changer_lang'); |
|
| 28 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | + $arg = $securiser_action(); |
|
| 30 | + $changer_lang = _request('changer_lang'); |
|
| 31 | 31 | |
| 32 | - [$id_rubrique, $id_parent] = preg_split('/\W/', $arg); |
|
| 32 | + [$id_rubrique, $id_parent] = preg_split('/\W/', $arg); |
|
| 33 | 33 | |
| 34 | - if ( |
|
| 35 | - $changer_lang |
|
| 36 | - and $id_rubrique > 0 |
|
| 37 | - and $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 38 | - and ($GLOBALS['meta']['multi_secteurs'] == 'non' or $id_parent == 0) |
|
| 39 | - ) { |
|
| 40 | - if ($changer_lang != 'herit') { |
|
| 41 | - sql_updateq( |
|
| 42 | - 'spip_rubriques', |
|
| 43 | - ['lang' => $changer_lang, 'langue_choisie' => 'oui'], |
|
| 44 | - "id_rubrique=$id_rubrique" |
|
| 45 | - ); |
|
| 46 | - } else { |
|
| 47 | - if ($id_parent == 0) { |
|
| 48 | - $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 49 | - } else { |
|
| 50 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', "id_rubrique=$id_parent"); |
|
| 51 | - } |
|
| 52 | - sql_updateq( |
|
| 53 | - 'spip_rubriques', |
|
| 54 | - ['lang' => $langue_parent, 'langue_choisie' => 'non'], |
|
| 55 | - "id_rubrique=$id_rubrique" |
|
| 56 | - ); |
|
| 57 | - } |
|
| 58 | - include_spip('inc/rubriques'); |
|
| 59 | - calculer_langues_rubriques(); |
|
| 34 | + if ( |
|
| 35 | + $changer_lang |
|
| 36 | + and $id_rubrique > 0 |
|
| 37 | + and $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 38 | + and ($GLOBALS['meta']['multi_secteurs'] == 'non' or $id_parent == 0) |
|
| 39 | + ) { |
|
| 40 | + if ($changer_lang != 'herit') { |
|
| 41 | + sql_updateq( |
|
| 42 | + 'spip_rubriques', |
|
| 43 | + ['lang' => $changer_lang, 'langue_choisie' => 'oui'], |
|
| 44 | + "id_rubrique=$id_rubrique" |
|
| 45 | + ); |
|
| 46 | + } else { |
|
| 47 | + if ($id_parent == 0) { |
|
| 48 | + $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 49 | + } else { |
|
| 50 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', "id_rubrique=$id_parent"); |
|
| 51 | + } |
|
| 52 | + sql_updateq( |
|
| 53 | + 'spip_rubriques', |
|
| 54 | + ['lang' => $langue_parent, 'langue_choisie' => 'non'], |
|
| 55 | + "id_rubrique=$id_rubrique" |
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | + include_spip('inc/rubriques'); |
|
| 59 | + calculer_langues_rubriques(); |
|
| 60 | 60 | |
| 61 | - // invalider les caches marques de cette rubrique |
|
| 62 | - include_spip('inc/invalideur'); |
|
| 63 | - suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 64 | - } |
|
| 61 | + // invalider les caches marques de cette rubrique |
|
| 62 | + include_spip('inc/invalideur'); |
|
| 63 | + suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -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 | |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | * @return void |
| 36 | 36 | */ |
| 37 | 37 | function action_supprimer_lien_dist($arg = null) { |
| 38 | - if (is_null($arg)) { |
|
| 39 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 40 | - $arg = $securiser_action(); |
|
| 41 | - } |
|
| 38 | + if (is_null($arg)) { |
|
| 39 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 40 | + $arg = $securiser_action(); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - $arg = explode('-', $arg); |
|
| 44 | - [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 43 | + $arg = explode('-', $arg); |
|
| 44 | + [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 45 | 45 | |
| 46 | - include_spip('action/editer_liens'); |
|
| 47 | - objet_dissocier([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 46 | + include_spip('action/editer_liens'); |
|
| 47 | + objet_dissocier([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 48 | 48 | } |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | include_spip('inc/headers'); |
| 24 | 24 | |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | * Sortie du buffer |
| 36 | 36 | **/ |
| 37 | 37 | function action_tester_taille_error_handler($output) { |
| 38 | - // on est ici, donc echec lors de la creation de l'image |
|
| 39 | - if (!empty($GLOBALS['redirect'])) { |
|
| 40 | - return redirige_formulaire($GLOBALS['redirect']); |
|
| 41 | - } |
|
| 38 | + // on est ici, donc echec lors de la creation de l'image |
|
| 39 | + if (!empty($GLOBALS['redirect'])) { |
|
| 40 | + return redirige_formulaire($GLOBALS['redirect']); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - return $output; |
|
| 43 | + return $output; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | |
@@ -58,77 +58,77 @@ discard block |
||
| 58 | 58 | **/ |
| 59 | 59 | function action_tester_taille_dist() { |
| 60 | 60 | |
| 61 | - if (!autoriser('configurer')) { |
|
| 62 | - return; |
|
| 63 | - } |
|
| 64 | - |
|
| 65 | - $taille = _request('arg'); |
|
| 66 | - $taille = explode('-', $taille); |
|
| 67 | - |
|
| 68 | - $GLOBALS['taille_max'] = end($taille); |
|
| 69 | - $GLOBALS['taille_min'] = 0; |
|
| 70 | - if (count($taille) > 1) { |
|
| 71 | - $GLOBALS['taille_min'] = reset($taille); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - // si l'intervalle est assez petit, on garde la valeur min |
|
| 75 | - if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) { |
|
| 76 | - $t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']); |
|
| 77 | - if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) { |
|
| 78 | - $t = $t * 0.9; // marge de securite |
|
| 79 | - echo round($t / 1_000_000, 3) . ' Mpx'; |
|
| 80 | - } else { |
|
| 81 | - // c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue" |
|
| 82 | - $t = 0; |
|
| 83 | - echo '∞'; |
|
| 84 | - } |
|
| 85 | - ecrire_meta('max_taille_vignettes', $t, 'non'); |
|
| 86 | - die(); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2); |
|
| 90 | - |
|
| 91 | - include_spip('inc/filtres'); |
|
| 92 | - // des inclusions representatives d'un hit prive et/ou public pour la conso memoire |
|
| 93 | - include_spip('public/assembler'); |
|
| 94 | - include_spip('public/balises'); |
|
| 95 | - include_spip('public/boucles'); |
|
| 96 | - include_spip('public/cacher'); |
|
| 97 | - include_spip('public/compiler'); |
|
| 98 | - include_spip('public/composer'); |
|
| 99 | - include_spip('public/criteres'); |
|
| 100 | - include_spip('public/interfaces'); |
|
| 101 | - include_spip('public/parametrer'); |
|
| 102 | - include_spip('public/phraser_html'); |
|
| 103 | - include_spip('public/references'); |
|
| 104 | - |
|
| 105 | - include_spip('inc/presentation'); |
|
| 106 | - include_spip('inc/charsets'); |
|
| 107 | - include_spip('inc/documents'); |
|
| 108 | - include_spip('inc/header'); |
|
| 109 | - propre('<doc1>'); // charger propre avec le trairement d'un modele |
|
| 110 | - |
|
| 111 | - $i = _request('i') + 1; |
|
| 112 | - $image_source = chemin_image('test.png'); |
|
| 113 | - $GLOBALS['redirect'] = generer_url_action( |
|
| 114 | - 'tester_taille', |
|
| 115 | - "i=$i&arg=" . $GLOBALS['taille_min'] . '-' . $GLOBALS['taille_test'] |
|
| 116 | - ); |
|
| 117 | - |
|
| 118 | - ob_start('action_tester_taille_error_handler'); |
|
| 119 | - filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 120 | - $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 121 | - |
|
| 122 | - // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee |
|
| 123 | - // si $GLOBALS['taille_min']==0 (car on est au premier coup) |
|
| 124 | - if ($GLOBALS['taille_min'] == 0) { |
|
| 125 | - $taille = $GLOBALS['taille_max']; |
|
| 126 | - filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 127 | - $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 128 | - } |
|
| 129 | - ob_end_clean(); |
|
| 130 | - |
|
| 131 | - |
|
| 132 | - // on est ici, donc pas de plantage |
|
| 133 | - echo redirige_formulaire($GLOBALS['redirect']); |
|
| 61 | + if (!autoriser('configurer')) { |
|
| 62 | + return; |
|
| 63 | + } |
|
| 64 | + |
|
| 65 | + $taille = _request('arg'); |
|
| 66 | + $taille = explode('-', $taille); |
|
| 67 | + |
|
| 68 | + $GLOBALS['taille_max'] = end($taille); |
|
| 69 | + $GLOBALS['taille_min'] = 0; |
|
| 70 | + if (count($taille) > 1) { |
|
| 71 | + $GLOBALS['taille_min'] = reset($taille); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + // si l'intervalle est assez petit, on garde la valeur min |
|
| 75 | + if ($GLOBALS['taille_max'] * $GLOBALS['taille_max'] - $GLOBALS['taille_min'] * $GLOBALS['taille_min'] < 50000) { |
|
| 76 | + $t = ($GLOBALS['taille_min'] * $GLOBALS['taille_min']); |
|
| 77 | + if ($GLOBALS['taille_min'] !== $GLOBALS['taille_max']) { |
|
| 78 | + $t = $t * 0.9; // marge de securite |
|
| 79 | + echo round($t / 1_000_000, 3) . ' Mpx'; |
|
| 80 | + } else { |
|
| 81 | + // c'est un cas "on a reussi la borne max initiale, donc on a pas de limite connue" |
|
| 82 | + $t = 0; |
|
| 83 | + echo '∞'; |
|
| 84 | + } |
|
| 85 | + ecrire_meta('max_taille_vignettes', $t, 'non'); |
|
| 86 | + die(); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $taille = $GLOBALS['taille_test'] = round(($GLOBALS['taille_max'] + $GLOBALS['taille_min']) / 2); |
|
| 90 | + |
|
| 91 | + include_spip('inc/filtres'); |
|
| 92 | + // des inclusions representatives d'un hit prive et/ou public pour la conso memoire |
|
| 93 | + include_spip('public/assembler'); |
|
| 94 | + include_spip('public/balises'); |
|
| 95 | + include_spip('public/boucles'); |
|
| 96 | + include_spip('public/cacher'); |
|
| 97 | + include_spip('public/compiler'); |
|
| 98 | + include_spip('public/composer'); |
|
| 99 | + include_spip('public/criteres'); |
|
| 100 | + include_spip('public/interfaces'); |
|
| 101 | + include_spip('public/parametrer'); |
|
| 102 | + include_spip('public/phraser_html'); |
|
| 103 | + include_spip('public/references'); |
|
| 104 | + |
|
| 105 | + include_spip('inc/presentation'); |
|
| 106 | + include_spip('inc/charsets'); |
|
| 107 | + include_spip('inc/documents'); |
|
| 108 | + include_spip('inc/header'); |
|
| 109 | + propre('<doc1>'); // charger propre avec le trairement d'un modele |
|
| 110 | + |
|
| 111 | + $i = _request('i') + 1; |
|
| 112 | + $image_source = chemin_image('test.png'); |
|
| 113 | + $GLOBALS['redirect'] = generer_url_action( |
|
| 114 | + 'tester_taille', |
|
| 115 | + "i=$i&arg=" . $GLOBALS['taille_min'] . '-' . $GLOBALS['taille_test'] |
|
| 116 | + ); |
|
| 117 | + |
|
| 118 | + ob_start('action_tester_taille_error_handler'); |
|
| 119 | + filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 120 | + $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 121 | + |
|
| 122 | + // si la valeur intermediaire a reussi, on teste la valeur maxi qui est peut etre sous estimee |
|
| 123 | + // si $GLOBALS['taille_min']==0 (car on est au premier coup) |
|
| 124 | + if ($GLOBALS['taille_min'] == 0) { |
|
| 125 | + $taille = $GLOBALS['taille_max']; |
|
| 126 | + filtrer('image_recadre', $image_source, $taille, $taille); |
|
| 127 | + $GLOBALS['redirect'] = generer_url_action('tester_taille', "i=$i&arg=$taille-" . $GLOBALS['taille_max']); |
|
| 128 | + } |
|
| 129 | + ob_end_clean(); |
|
| 130 | + |
|
| 131 | + |
|
| 132 | + // on est ici, donc pas de plantage |
|
| 133 | + echo redirige_formulaire($GLOBALS['redirect']); |
|
| 134 | 134 | } |
@@ -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 | /** |
@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | 36 | function action_ajouter_lien_dist($arg = null) { |
| 37 | - if (is_null($arg)) { |
|
| 38 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 39 | - $arg = $securiser_action(); |
|
| 40 | - } |
|
| 37 | + if (is_null($arg)) { |
|
| 38 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 39 | + $arg = $securiser_action(); |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $arg = explode('-', $arg); |
|
| 43 | - [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 42 | + $arg = explode('-', $arg); |
|
| 43 | + [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 44 | 44 | |
| 45 | - include_spip('action/editer_liens'); |
|
| 46 | - objet_associer([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 45 | + include_spip('action/editer_liens'); |
|
| 46 | + objet_associer([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 47 | 47 | } |
@@ -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 | /** |
@@ -31,17 +31,17 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | function action_debloquer_edition_dist() { |
| 33 | 33 | |
| 34 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | - $arg = $securiser_action(); |
|
| 34 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 35 | + $arg = $securiser_action(); |
|
| 36 | 36 | |
| 37 | - if ($arg) { |
|
| 38 | - include_spip('inc/drapeau_edition'); |
|
| 39 | - if ($arg == 'tous') { |
|
| 40 | - debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 41 | - } else { |
|
| 42 | - $arg = explode('-', $arg); |
|
| 43 | - [$objet, $id_objet] = $arg; |
|
| 44 | - debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 45 | - } |
|
| 46 | - } |
|
| 37 | + if ($arg) { |
|
| 38 | + include_spip('inc/drapeau_edition'); |
|
| 39 | + if ($arg == 'tous') { |
|
| 40 | + debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 41 | + } else { |
|
| 42 | + $arg = explode('-', $arg); |
|
| 43 | + [$objet, $id_objet] = $arg; |
|
| 44 | + debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -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 | include_spip('inc/actions'); |
@@ -33,93 +33,93 @@ discard block |
||
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | 35 | function action_cookie_dist($set_cookie_admin = null, $change_session = null) { |
| 36 | - $redirect_echec = $redirect = null; |
|
| 37 | - $test_echec_cookie = null; |
|
| 38 | - $url = ''; |
|
| 39 | - if (is_null($set_cookie_admin)) { |
|
| 40 | - $set_cookie_admin = _request('cookie_admin'); |
|
| 41 | - $change_session = _request('change_session'); |
|
| 42 | - $test_echec_cookie = _request('test_echec_cookie'); |
|
| 36 | + $redirect_echec = $redirect = null; |
|
| 37 | + $test_echec_cookie = null; |
|
| 38 | + $url = ''; |
|
| 39 | + if (is_null($set_cookie_admin)) { |
|
| 40 | + $set_cookie_admin = _request('cookie_admin'); |
|
| 41 | + $change_session = _request('change_session'); |
|
| 42 | + $test_echec_cookie = _request('test_echec_cookie'); |
|
| 43 | 43 | |
| 44 | - // La cible de notre operation de connexion |
|
| 45 | - $url = securiser_redirect_action(_request('url')); |
|
| 46 | - $redirect = $url ?: generer_url_ecrire('accueil'); |
|
| 47 | - $redirect_echec = _request('url_echec'); |
|
| 48 | - if (!isset($redirect_echec)) { |
|
| 49 | - if (strpos($redirect, (string) _DIR_RESTREINT_ABS) !== false) { |
|
| 50 | - $redirect_echec = generer_url_public('login', '', true); |
|
| 51 | - } else { |
|
| 52 | - $redirect_echec = $redirect; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - } |
|
| 44 | + // La cible de notre operation de connexion |
|
| 45 | + $url = securiser_redirect_action(_request('url')); |
|
| 46 | + $redirect = $url ?: generer_url_ecrire('accueil'); |
|
| 47 | + $redirect_echec = _request('url_echec'); |
|
| 48 | + if (!isset($redirect_echec)) { |
|
| 49 | + if (strpos($redirect, (string) _DIR_RESTREINT_ABS) !== false) { |
|
| 50 | + $redirect_echec = generer_url_public('login', '', true); |
|
| 51 | + } else { |
|
| 52 | + $redirect_echec = $redirect; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | 57 | |
| 58 | - // rejoue le cookie pour renouveler spip_session |
|
| 59 | - if ($change_session == 'oui') { |
|
| 60 | - $session = charger_fonction('session', 'inc'); |
|
| 61 | - $session(true); |
|
| 62 | - spip_log('statut 204 pour ' . $_SERVER['REQUEST_URI']); |
|
| 63 | - http_response_code(204); // No Content |
|
| 64 | - return; |
|
| 65 | - } |
|
| 58 | + // rejoue le cookie pour renouveler spip_session |
|
| 59 | + if ($change_session == 'oui') { |
|
| 60 | + $session = charger_fonction('session', 'inc'); |
|
| 61 | + $session(true); |
|
| 62 | + spip_log('statut 204 pour ' . $_SERVER['REQUEST_URI']); |
|
| 63 | + http_response_code(204); // No Content |
|
| 64 | + return; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - // tentative de connexion en auth_http |
|
| 68 | - if (_request('essai_auth_http') and !$GLOBALS['ignore_auth_http']) { |
|
| 69 | - include_spip('inc/auth'); |
|
| 70 | - if ( |
|
| 71 | - @$_SERVER['PHP_AUTH_USER'] |
|
| 72 | - and @$_SERVER['PHP_AUTH_PW'] |
|
| 73 | - and $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) |
|
| 74 | - ) { |
|
| 75 | - auth_loger($auteur); |
|
| 76 | - redirige_par_entete(parametre_url($redirect, 't', time(), '&')); |
|
| 77 | - } else { |
|
| 78 | - ask_php_auth( |
|
| 79 | - _T('info_connexion_refusee'), |
|
| 80 | - _T('login_login_pass_incorrect'), |
|
| 81 | - _T('login_retour_site'), |
|
| 82 | - 'url=' . rawurlencode($redirect), |
|
| 83 | - _T('login_nouvelle_tentative'), |
|
| 84 | - (strpos($url, (string) _DIR_RESTREINT_ABS) !== false) |
|
| 85 | - ); |
|
| 86 | - } |
|
| 87 | - } else { |
|
| 88 | - // en cas de login sur bonjour=oui, on tente de poser un cookie |
|
| 89 | - // puis de passer au login qui diagnostiquera l'echec de cookie |
|
| 90 | - // le cas echeant. |
|
| 91 | - if ($test_echec_cookie == 'oui') { |
|
| 92 | - spip_setcookie('spip_session', 'test_echec_cookie'); |
|
| 93 | - if ($redirect) { |
|
| 94 | - $redirect = parametre_url( |
|
| 95 | - parametre_url($redirect_echec, 'var_echec_cookie', 'oui', '&'), |
|
| 96 | - 'url', |
|
| 97 | - rawurlencode($redirect), |
|
| 98 | - '&' |
|
| 99 | - ); |
|
| 100 | - } |
|
| 101 | - } else { |
|
| 102 | - $cook = $_COOKIE['spip_admin'] ?? ''; |
|
| 103 | - // Suppression cookie d'admin ? |
|
| 104 | - if ($set_cookie_admin == 'non') { |
|
| 105 | - if ($cook) { |
|
| 106 | - spip_setcookie('spip_admin', $cook, [ |
|
| 107 | - 'expires' => time() - 3600 * 24 |
|
| 108 | - ]); |
|
| 109 | - } |
|
| 110 | - } // Ajout de cookie d'admin |
|
| 111 | - else { |
|
| 112 | - if ($set_cookie_admin and _DUREE_COOKIE_ADMIN) { |
|
| 113 | - spip_setcookie('spip_admin', $set_cookie_admin, [ |
|
| 114 | - 'expires' => time() + max(_DUREE_COOKIE_ADMIN, 2 * _RENOUVELLE_ALEA) |
|
| 115 | - ]); |
|
| 116 | - } |
|
| 117 | - } |
|
| 118 | - } |
|
| 119 | - } |
|
| 67 | + // tentative de connexion en auth_http |
|
| 68 | + if (_request('essai_auth_http') and !$GLOBALS['ignore_auth_http']) { |
|
| 69 | + include_spip('inc/auth'); |
|
| 70 | + if ( |
|
| 71 | + @$_SERVER['PHP_AUTH_USER'] |
|
| 72 | + and @$_SERVER['PHP_AUTH_PW'] |
|
| 73 | + and $auteur = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']) |
|
| 74 | + ) { |
|
| 75 | + auth_loger($auteur); |
|
| 76 | + redirige_par_entete(parametre_url($redirect, 't', time(), '&')); |
|
| 77 | + } else { |
|
| 78 | + ask_php_auth( |
|
| 79 | + _T('info_connexion_refusee'), |
|
| 80 | + _T('login_login_pass_incorrect'), |
|
| 81 | + _T('login_retour_site'), |
|
| 82 | + 'url=' . rawurlencode($redirect), |
|
| 83 | + _T('login_nouvelle_tentative'), |
|
| 84 | + (strpos($url, (string) _DIR_RESTREINT_ABS) !== false) |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | + } else { |
|
| 88 | + // en cas de login sur bonjour=oui, on tente de poser un cookie |
|
| 89 | + // puis de passer au login qui diagnostiquera l'echec de cookie |
|
| 90 | + // le cas echeant. |
|
| 91 | + if ($test_echec_cookie == 'oui') { |
|
| 92 | + spip_setcookie('spip_session', 'test_echec_cookie'); |
|
| 93 | + if ($redirect) { |
|
| 94 | + $redirect = parametre_url( |
|
| 95 | + parametre_url($redirect_echec, 'var_echec_cookie', 'oui', '&'), |
|
| 96 | + 'url', |
|
| 97 | + rawurlencode($redirect), |
|
| 98 | + '&' |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | + } else { |
|
| 102 | + $cook = $_COOKIE['spip_admin'] ?? ''; |
|
| 103 | + // Suppression cookie d'admin ? |
|
| 104 | + if ($set_cookie_admin == 'non') { |
|
| 105 | + if ($cook) { |
|
| 106 | + spip_setcookie('spip_admin', $cook, [ |
|
| 107 | + 'expires' => time() - 3600 * 24 |
|
| 108 | + ]); |
|
| 109 | + } |
|
| 110 | + } // Ajout de cookie d'admin |
|
| 111 | + else { |
|
| 112 | + if ($set_cookie_admin and _DUREE_COOKIE_ADMIN) { |
|
| 113 | + spip_setcookie('spip_admin', $set_cookie_admin, [ |
|
| 114 | + 'expires' => time() + max(_DUREE_COOKIE_ADMIN, 2 * _RENOUVELLE_ALEA) |
|
| 115 | + ]); |
|
| 116 | + } |
|
| 117 | + } |
|
| 118 | + } |
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - // Redirection finale |
|
| 122 | - if ($redirect) { |
|
| 123 | - redirige_par_entete($redirect, true); |
|
| 124 | - } |
|
| 121 | + // Redirection finale |
|
| 122 | + if ($redirect) { |
|
| 123 | + redirige_par_entete($redirect, true); |
|
| 124 | + } |
|
| 125 | 125 | } |
@@ -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 | /** |
@@ -30,155 +30,155 @@ discard block |
||
| 30 | 30 | * redirige sur l'image ainsi créée (sinon sur une image d'echec). |
| 31 | 31 | **/ |
| 32 | 32 | function action_tester_dist() { |
| 33 | - $arg = _request('arg'); |
|
| 34 | - |
|
| 35 | - $gd_formats = []; |
|
| 36 | - $gd_formats_read_gif = ''; |
|
| 37 | - // verifier les formats acceptes par GD |
|
| 38 | - if ($arg == 'gd1') { |
|
| 39 | - // Si GD est installe et php >= 4.0.2 |
|
| 40 | - if (function_exists('imagetypes')) { |
|
| 41 | - if (imagetypes() & IMG_GIF) { |
|
| 42 | - $gd_formats[] = 'gif'; |
|
| 43 | - } else { |
|
| 44 | - # Attention GD sait lire le gif mais pas forcement l'ecrire |
|
| 45 | - if (function_exists('ImageCreateFromGIF')) { |
|
| 46 | - $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK . 'test.gif'); |
|
| 47 | - if ($srcImage) { |
|
| 48 | - $gd_formats_read_gif = ',gif'; |
|
| 49 | - ImageDestroy($srcImage); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - if (imagetypes() & IMG_JPG) { |
|
| 55 | - $gd_formats[] = 'jpg'; |
|
| 56 | - } |
|
| 57 | - if (imagetypes() & IMG_PNG) { |
|
| 58 | - $gd_formats[] = 'png'; |
|
| 59 | - } |
|
| 60 | - if (imagetypes() & IMG_WEBP) { |
|
| 61 | - $gd_formats[] = 'webp'; |
|
| 62 | - } |
|
| 63 | - } else { |
|
| 64 | - # ancienne methode de detection des formats, qui en plus |
|
| 65 | - # est bugguee car elle teste les formats en lecture |
|
| 66 | - # alors que la valeur deduite sert a identifier |
|
| 67 | - # les formats disponibles en ecriture... (cf. inc_logos) |
|
| 68 | - |
|
| 69 | - if (function_exists('ImageCreateFromJPEG')) { |
|
| 70 | - $srcImage = @ImageCreateFromJPEG(_ROOT_IMG_PACK . 'test.jpg'); |
|
| 71 | - if ($srcImage) { |
|
| 72 | - $gd_formats[] = 'jpg'; |
|
| 73 | - ImageDestroy($srcImage); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - if (function_exists('ImageCreateFromGIF')) { |
|
| 77 | - $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK . 'test.gif'); |
|
| 78 | - if ($srcImage) { |
|
| 79 | - $gd_formats[] = 'gif'; |
|
| 80 | - ImageDestroy($srcImage); |
|
| 81 | - } |
|
| 82 | - } |
|
| 83 | - if (function_exists('ImageCreateFromPNG')) { |
|
| 84 | - $srcImage = @ImageCreateFromPNG(_ROOT_IMG_PACK . 'test.png'); |
|
| 85 | - if ($srcImage) { |
|
| 86 | - $gd_formats[] = 'png'; |
|
| 87 | - ImageDestroy($srcImage); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - if (function_exists('ImageCreateFromWEBP')) { |
|
| 91 | - $srcImage = @ImageCreateFromWEBP(_ROOT_IMG_PACK . 'test.webp'); |
|
| 92 | - if ($srcImage) { |
|
| 93 | - $gd_formats[] = 'webp'; |
|
| 94 | - ImageDestroy($srcImage); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - if (! empty($gd_formats)) { |
|
| 100 | - $gd_formats = join(',', $gd_formats); |
|
| 101 | - } |
|
| 102 | - ecrire_meta('gd_formats_read', $gd_formats . $gd_formats_read_gif); |
|
| 103 | - ecrire_meta('gd_formats', $gd_formats); |
|
| 104 | - } // verifier les formats netpbm |
|
| 105 | - else { |
|
| 106 | - if ($arg == 'netpbm') { |
|
| 107 | - if (!defined('_PNMSCALE_COMMAND')) { |
|
| 108 | - define('_PNMSCALE_COMMAND', 'pnmscale'); |
|
| 109 | - } // Securite : mes_options.php peut preciser le chemin absolu |
|
| 110 | - if (_PNMSCALE_COMMAND == '') { |
|
| 111 | - return; |
|
| 112 | - } |
|
| 113 | - $netpbm_formats = []; |
|
| 114 | - |
|
| 115 | - $jpegtopnm_command = str_replace( |
|
| 116 | - 'pnmscale', |
|
| 117 | - 'jpegtopnm', |
|
| 118 | - _PNMSCALE_COMMAND |
|
| 119 | - ); |
|
| 120 | - $pnmtojpeg_command = str_replace( |
|
| 121 | - 'pnmscale', |
|
| 122 | - 'pnmtojpeg', |
|
| 123 | - _PNMSCALE_COMMAND |
|
| 124 | - ); |
|
| 125 | - |
|
| 126 | - $vignette = _ROOT_IMG_PACK . 'test.jpg'; |
|
| 127 | - $dest = _DIR_VAR . 'test-jpg.jpg'; |
|
| 128 | - $commande = "$jpegtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 129 | - spip_log($commande); |
|
| 130 | - exec($commande); |
|
| 131 | - if ($taille = @getimagesize($dest)) { |
|
| 132 | - if ($taille[1] == 10) { |
|
| 133 | - $netpbm_formats[] = 'jpg'; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - $giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND); |
|
| 137 | - $pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND); |
|
| 138 | - $vignette = _ROOT_IMG_PACK . 'test.gif'; |
|
| 139 | - $dest = _DIR_VAR . 'test-gif.jpg'; |
|
| 140 | - $commande = "$giftopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 141 | - spip_log($commande); |
|
| 142 | - exec($commande); |
|
| 143 | - if ($taille = @getimagesize($dest)) { |
|
| 144 | - if ($taille[1] == 10) { |
|
| 145 | - $netpbm_formats[] = 'gif'; |
|
| 146 | - } |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - $pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND); |
|
| 150 | - $vignette = _ROOT_IMG_PACK . 'test.png'; |
|
| 151 | - $dest = _DIR_VAR . 'test-gif.jpg'; |
|
| 152 | - $commande = "$pngtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 153 | - spip_log($commande); |
|
| 154 | - exec($commande); |
|
| 155 | - if ($taille = @getimagesize($dest)) { |
|
| 156 | - if ($taille[1] == 10) { |
|
| 157 | - $netpbm_formats[] = 'png'; |
|
| 158 | - } |
|
| 159 | - } |
|
| 160 | - |
|
| 161 | - ecrire_meta('netpbm_formats', join(',', $netpbm_formats ?: [])); |
|
| 162 | - } |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - // et maintenant envoyer la vignette de tests |
|
| 166 | - if (in_array($arg, ['gd1', 'gd2', 'imagick', 'convert', 'netpbm'])) { |
|
| 167 | - include_spip('inc/filtres'); |
|
| 168 | - include_spip('inc/filtres_images_mini'); |
|
| 169 | - $taille_preview = 150; |
|
| 170 | - $image = _image_valeurs_trans(_DIR_IMG_PACK . 'test_image.jpg', "reduire-$taille_preview-$taille_preview", 'jpg'); |
|
| 171 | - |
|
| 172 | - $image['fichier_dest'] = _DIR_VAR . "test_$arg"; |
|
| 173 | - |
|
| 174 | - if ( |
|
| 175 | - $preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true) |
|
| 176 | - and ($preview['width'] * $preview['height'] > 0) |
|
| 177 | - ) { |
|
| 178 | - redirige_par_entete($preview['fichier']); |
|
| 179 | - } |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - # image echec |
|
| 183 | - redirige_par_entete(chemin_image('echec-reducteur-xx.svg')); |
|
| 33 | + $arg = _request('arg'); |
|
| 34 | + |
|
| 35 | + $gd_formats = []; |
|
| 36 | + $gd_formats_read_gif = ''; |
|
| 37 | + // verifier les formats acceptes par GD |
|
| 38 | + if ($arg == 'gd1') { |
|
| 39 | + // Si GD est installe et php >= 4.0.2 |
|
| 40 | + if (function_exists('imagetypes')) { |
|
| 41 | + if (imagetypes() & IMG_GIF) { |
|
| 42 | + $gd_formats[] = 'gif'; |
|
| 43 | + } else { |
|
| 44 | + # Attention GD sait lire le gif mais pas forcement l'ecrire |
|
| 45 | + if (function_exists('ImageCreateFromGIF')) { |
|
| 46 | + $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK . 'test.gif'); |
|
| 47 | + if ($srcImage) { |
|
| 48 | + $gd_formats_read_gif = ',gif'; |
|
| 49 | + ImageDestroy($srcImage); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + if (imagetypes() & IMG_JPG) { |
|
| 55 | + $gd_formats[] = 'jpg'; |
|
| 56 | + } |
|
| 57 | + if (imagetypes() & IMG_PNG) { |
|
| 58 | + $gd_formats[] = 'png'; |
|
| 59 | + } |
|
| 60 | + if (imagetypes() & IMG_WEBP) { |
|
| 61 | + $gd_formats[] = 'webp'; |
|
| 62 | + } |
|
| 63 | + } else { |
|
| 64 | + # ancienne methode de detection des formats, qui en plus |
|
| 65 | + # est bugguee car elle teste les formats en lecture |
|
| 66 | + # alors que la valeur deduite sert a identifier |
|
| 67 | + # les formats disponibles en ecriture... (cf. inc_logos) |
|
| 68 | + |
|
| 69 | + if (function_exists('ImageCreateFromJPEG')) { |
|
| 70 | + $srcImage = @ImageCreateFromJPEG(_ROOT_IMG_PACK . 'test.jpg'); |
|
| 71 | + if ($srcImage) { |
|
| 72 | + $gd_formats[] = 'jpg'; |
|
| 73 | + ImageDestroy($srcImage); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + if (function_exists('ImageCreateFromGIF')) { |
|
| 77 | + $srcImage = @ImageCreateFromGIF(_ROOT_IMG_PACK . 'test.gif'); |
|
| 78 | + if ($srcImage) { |
|
| 79 | + $gd_formats[] = 'gif'; |
|
| 80 | + ImageDestroy($srcImage); |
|
| 81 | + } |
|
| 82 | + } |
|
| 83 | + if (function_exists('ImageCreateFromPNG')) { |
|
| 84 | + $srcImage = @ImageCreateFromPNG(_ROOT_IMG_PACK . 'test.png'); |
|
| 85 | + if ($srcImage) { |
|
| 86 | + $gd_formats[] = 'png'; |
|
| 87 | + ImageDestroy($srcImage); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + if (function_exists('ImageCreateFromWEBP')) { |
|
| 91 | + $srcImage = @ImageCreateFromWEBP(_ROOT_IMG_PACK . 'test.webp'); |
|
| 92 | + if ($srcImage) { |
|
| 93 | + $gd_formats[] = 'webp'; |
|
| 94 | + ImageDestroy($srcImage); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + if (! empty($gd_formats)) { |
|
| 100 | + $gd_formats = join(',', $gd_formats); |
|
| 101 | + } |
|
| 102 | + ecrire_meta('gd_formats_read', $gd_formats . $gd_formats_read_gif); |
|
| 103 | + ecrire_meta('gd_formats', $gd_formats); |
|
| 104 | + } // verifier les formats netpbm |
|
| 105 | + else { |
|
| 106 | + if ($arg == 'netpbm') { |
|
| 107 | + if (!defined('_PNMSCALE_COMMAND')) { |
|
| 108 | + define('_PNMSCALE_COMMAND', 'pnmscale'); |
|
| 109 | + } // Securite : mes_options.php peut preciser le chemin absolu |
|
| 110 | + if (_PNMSCALE_COMMAND == '') { |
|
| 111 | + return; |
|
| 112 | + } |
|
| 113 | + $netpbm_formats = []; |
|
| 114 | + |
|
| 115 | + $jpegtopnm_command = str_replace( |
|
| 116 | + 'pnmscale', |
|
| 117 | + 'jpegtopnm', |
|
| 118 | + _PNMSCALE_COMMAND |
|
| 119 | + ); |
|
| 120 | + $pnmtojpeg_command = str_replace( |
|
| 121 | + 'pnmscale', |
|
| 122 | + 'pnmtojpeg', |
|
| 123 | + _PNMSCALE_COMMAND |
|
| 124 | + ); |
|
| 125 | + |
|
| 126 | + $vignette = _ROOT_IMG_PACK . 'test.jpg'; |
|
| 127 | + $dest = _DIR_VAR . 'test-jpg.jpg'; |
|
| 128 | + $commande = "$jpegtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 129 | + spip_log($commande); |
|
| 130 | + exec($commande); |
|
| 131 | + if ($taille = @getimagesize($dest)) { |
|
| 132 | + if ($taille[1] == 10) { |
|
| 133 | + $netpbm_formats[] = 'jpg'; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + $giftopnm_command = str_replace('pnmscale', 'giftopnm', _PNMSCALE_COMMAND); |
|
| 137 | + $pnmtojpeg_command = str_replace('pnmscale', 'pnmtojpeg', _PNMSCALE_COMMAND); |
|
| 138 | + $vignette = _ROOT_IMG_PACK . 'test.gif'; |
|
| 139 | + $dest = _DIR_VAR . 'test-gif.jpg'; |
|
| 140 | + $commande = "$giftopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 141 | + spip_log($commande); |
|
| 142 | + exec($commande); |
|
| 143 | + if ($taille = @getimagesize($dest)) { |
|
| 144 | + if ($taille[1] == 10) { |
|
| 145 | + $netpbm_formats[] = 'gif'; |
|
| 146 | + } |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + $pngtopnm_command = str_replace('pnmscale', 'pngtopnm', _PNMSCALE_COMMAND); |
|
| 150 | + $vignette = _ROOT_IMG_PACK . 'test.png'; |
|
| 151 | + $dest = _DIR_VAR . 'test-gif.jpg'; |
|
| 152 | + $commande = "$pngtopnm_command $vignette | " . _PNMSCALE_COMMAND . " -width 10 | $pnmtojpeg_command > $dest"; |
|
| 153 | + spip_log($commande); |
|
| 154 | + exec($commande); |
|
| 155 | + if ($taille = @getimagesize($dest)) { |
|
| 156 | + if ($taille[1] == 10) { |
|
| 157 | + $netpbm_formats[] = 'png'; |
|
| 158 | + } |
|
| 159 | + } |
|
| 160 | + |
|
| 161 | + ecrire_meta('netpbm_formats', join(',', $netpbm_formats ?: [])); |
|
| 162 | + } |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + // et maintenant envoyer la vignette de tests |
|
| 166 | + if (in_array($arg, ['gd1', 'gd2', 'imagick', 'convert', 'netpbm'])) { |
|
| 167 | + include_spip('inc/filtres'); |
|
| 168 | + include_spip('inc/filtres_images_mini'); |
|
| 169 | + $taille_preview = 150; |
|
| 170 | + $image = _image_valeurs_trans(_DIR_IMG_PACK . 'test_image.jpg', "reduire-$taille_preview-$taille_preview", 'jpg'); |
|
| 171 | + |
|
| 172 | + $image['fichier_dest'] = _DIR_VAR . "test_$arg"; |
|
| 173 | + |
|
| 174 | + if ( |
|
| 175 | + $preview = _image_creer_vignette($image, $taille_preview, $taille_preview, $arg, true) |
|
| 176 | + and ($preview['width'] * $preview['height'] > 0) |
|
| 177 | + ) { |
|
| 178 | + redirige_par_entete($preview['fichier']); |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + # image echec |
|
| 183 | + redirige_par_entete(chemin_image('echec-reducteur-xx.svg')); |
|
| 184 | 184 | } |
@@ -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 | /** |
@@ -32,28 +32,28 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function action_desinstaller_plugin_dist() { |
| 34 | 34 | |
| 35 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 36 | - $arg = $securiser_action(); |
|
| 37 | - [$dir_plugins, $plugin] = explode('::', $arg); |
|
| 38 | - $dir_type = '_DIR_PLUGINS'; |
|
| 39 | - if (defined('_DIR_PLUGINS_SUPPL') and $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 40 | - $dir_type = '_DIR_PLUGINS_SUPPL'; |
|
| 41 | - } |
|
| 42 | - $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 43 | - $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 44 | - if ($infos and !$infos['install_test'][0]) { |
|
| 45 | - include_spip('inc/plugin'); |
|
| 46 | - ecrire_plugin_actifs([$plugin], false, 'enleve'); |
|
| 47 | - $erreur = ''; |
|
| 48 | - } else { |
|
| 49 | - $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 50 | - } |
|
| 51 | - if ($redirect = _request('redirect')) { |
|
| 52 | - include_spip('inc/headers'); |
|
| 53 | - if ($erreur) { |
|
| 54 | - $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 55 | - } |
|
| 56 | - $redirect = str_replace('&', '&', $redirect); |
|
| 57 | - redirige_par_entete($redirect); |
|
| 58 | - } |
|
| 35 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 36 | + $arg = $securiser_action(); |
|
| 37 | + [$dir_plugins, $plugin] = explode('::', $arg); |
|
| 38 | + $dir_type = '_DIR_PLUGINS'; |
|
| 39 | + if (defined('_DIR_PLUGINS_SUPPL') and $dir_plugins == _DIR_PLUGINS_SUPPL) { |
|
| 40 | + $dir_type = '_DIR_PLUGINS_SUPPL'; |
|
| 41 | + } |
|
| 42 | + $installer_plugins = charger_fonction('installer', 'plugins'); |
|
| 43 | + $infos = $installer_plugins($plugin, 'uninstall', $dir_type); |
|
| 44 | + if ($infos and !$infos['install_test'][0]) { |
|
| 45 | + include_spip('inc/plugin'); |
|
| 46 | + ecrire_plugin_actifs([$plugin], false, 'enleve'); |
|
| 47 | + $erreur = ''; |
|
| 48 | + } else { |
|
| 49 | + $erreur = 'erreur_plugin_desinstalation_echouee'; |
|
| 50 | + } |
|
| 51 | + if ($redirect = _request('redirect')) { |
|
| 52 | + include_spip('inc/headers'); |
|
| 53 | + if ($erreur) { |
|
| 54 | + $redirect = parametre_url($redirect, 'erreur', $erreur); |
|
| 55 | + } |
|
| 56 | + $redirect = str_replace('&', '&', $redirect); |
|
| 57 | + redirige_par_entete($redirect); |
|
| 58 | + } |
|
| 59 | 59 | } |