@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -24,41 +24,41 @@ discard block |
||
| 24 | 24 | **/ |
| 25 | 25 | function action_instituer_langue_rubrique_dist() { |
| 26 | 26 | |
| 27 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 28 | - $arg = $securiser_action(); |
|
| 29 | - $changer_lang = _request('changer_lang'); |
|
| 27 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 28 | + $arg = $securiser_action(); |
|
| 29 | + $changer_lang = _request('changer_lang'); |
|
| 30 | 30 | |
| 31 | - [$id_rubrique, $id_parent] = preg_split('/\W/', (string) $arg); |
|
| 31 | + [$id_rubrique, $id_parent] = preg_split('/\W/', (string) $arg); |
|
| 32 | 32 | |
| 33 | - if ( |
|
| 34 | - $changer_lang |
|
| 35 | - && $id_rubrique > 0 |
|
| 36 | - && $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 37 | - && ($GLOBALS['meta']['multi_secteurs'] == 'non' || $id_parent == 0) |
|
| 38 | - ) { |
|
| 39 | - if ($changer_lang != 'herit') { |
|
| 40 | - sql_updateq( |
|
| 41 | - 'spip_rubriques', |
|
| 42 | - ['lang' => $changer_lang, 'langue_choisie' => 'oui'], |
|
| 43 | - "id_rubrique=$id_rubrique" |
|
| 44 | - ); |
|
| 45 | - } else { |
|
| 46 | - if ($id_parent == 0) { |
|
| 47 | - $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 48 | - } else { |
|
| 49 | - $langue_parent = sql_getfetsel('lang', 'spip_rubriques', "id_rubrique=$id_parent"); |
|
| 50 | - } |
|
| 51 | - sql_updateq( |
|
| 52 | - 'spip_rubriques', |
|
| 53 | - ['lang' => $langue_parent, 'langue_choisie' => 'non'], |
|
| 54 | - "id_rubrique=$id_rubrique" |
|
| 55 | - ); |
|
| 56 | - } |
|
| 57 | - include_spip('inc/rubriques'); |
|
| 58 | - calculer_langues_rubriques(); |
|
| 33 | + if ( |
|
| 34 | + $changer_lang |
|
| 35 | + && $id_rubrique > 0 |
|
| 36 | + && $GLOBALS['meta']['multi_rubriques'] == 'oui' |
|
| 37 | + && ($GLOBALS['meta']['multi_secteurs'] == 'non' || $id_parent == 0) |
|
| 38 | + ) { |
|
| 39 | + if ($changer_lang != 'herit') { |
|
| 40 | + sql_updateq( |
|
| 41 | + 'spip_rubriques', |
|
| 42 | + ['lang' => $changer_lang, 'langue_choisie' => 'oui'], |
|
| 43 | + "id_rubrique=$id_rubrique" |
|
| 44 | + ); |
|
| 45 | + } else { |
|
| 46 | + if ($id_parent == 0) { |
|
| 47 | + $langue_parent = $GLOBALS['meta']['langue_site']; |
|
| 48 | + } else { |
|
| 49 | + $langue_parent = sql_getfetsel('lang', 'spip_rubriques', "id_rubrique=$id_parent"); |
|
| 50 | + } |
|
| 51 | + sql_updateq( |
|
| 52 | + 'spip_rubriques', |
|
| 53 | + ['lang' => $langue_parent, 'langue_choisie' => 'non'], |
|
| 54 | + "id_rubrique=$id_rubrique" |
|
| 55 | + ); |
|
| 56 | + } |
|
| 57 | + include_spip('inc/rubriques'); |
|
| 58 | + calculer_langues_rubriques(); |
|
| 59 | 59 | |
| 60 | - // invalider les caches marques de cette rubrique |
|
| 61 | - include_spip('inc/invalideur'); |
|
| 62 | - suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 63 | - } |
|
| 60 | + // invalider les caches marques de cette rubrique |
|
| 61 | + include_spip('inc/invalideur'); |
|
| 62 | + suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 63 | + } |
|
| 64 | 64 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -25,15 +25,15 @@ discard block |
||
| 25 | 25 | * @return void |
| 26 | 26 | */ |
| 27 | 27 | function action_forcer_job_dist() { |
| 28 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | - $id_job = $securiser_action(); |
|
| 28 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 29 | + $id_job = $securiser_action(); |
|
| 30 | 30 | |
| 31 | - if ( |
|
| 32 | - ($id_job = (int) $id_job) |
|
| 33 | - && autoriser('forcer', 'job', $id_job) |
|
| 34 | - ) { |
|
| 35 | - include_spip('inc/queue'); |
|
| 36 | - include_spip('inc/genie'); |
|
| 37 | - queue_schedule([$id_job]); |
|
| 38 | - } |
|
| 31 | + if ( |
|
| 32 | + ($id_job = (int) $id_job) |
|
| 33 | + && autoriser('forcer', 'job', $id_job) |
|
| 34 | + ) { |
|
| 35 | + include_spip('inc/queue'); |
|
| 36 | + include_spip('inc/genie'); |
|
| 37 | + queue_schedule([$id_job]); |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | * @return void |
| 35 | 35 | */ |
| 36 | 36 | function action_supprimer_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('-', (string) $arg); |
|
| 43 | - [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 42 | + $arg = explode('-', (string) $arg); |
|
| 43 | + [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 44 | 44 | |
| 45 | - include_spip('action/editer_liens'); |
|
| 46 | - objet_dissocier([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 45 | + include_spip('action/editer_liens'); |
|
| 46 | + objet_dissocier([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 47 | 47 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('inc/actions'); |
@@ -28,23 +28,23 @@ discard block |
||
| 28 | 28 | * @return void |
| 29 | 29 | */ |
| 30 | 30 | function action_etre_webmestre_dist() { |
| 31 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 32 | - $time = $securiser_action(); |
|
| 31 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 32 | + $time = $securiser_action(); |
|
| 33 | 33 | |
| 34 | - if ( |
|
| 35 | - time() - $time < 15 * 60 |
|
| 36 | - && $GLOBALS['visiteur_session']['statut'] == '0minirezo' |
|
| 37 | - && $GLOBALS['visiteur_session']['webmestre'] !== 'oui' |
|
| 38 | - ) { |
|
| 39 | - $action = _T('info_admin_etre_webmestre'); |
|
| 40 | - $admin = charger_fonction('admin', 'inc'); |
|
| 41 | - // lance la verif par ftp et l'appel |
|
| 42 | - // a base_etre_webmestre_dist quand c'est OK |
|
| 43 | - if ($r = $admin('etre_webmestre', $action)) { |
|
| 44 | - echo $r; |
|
| 45 | - exit; |
|
| 46 | - } |
|
| 47 | - } |
|
| 34 | + if ( |
|
| 35 | + time() - $time < 15 * 60 |
|
| 36 | + && $GLOBALS['visiteur_session']['statut'] == '0minirezo' |
|
| 37 | + && $GLOBALS['visiteur_session']['webmestre'] !== 'oui' |
|
| 38 | + ) { |
|
| 39 | + $action = _T('info_admin_etre_webmestre'); |
|
| 40 | + $admin = charger_fonction('admin', 'inc'); |
|
| 41 | + // lance la verif par ftp et l'appel |
|
| 42 | + // a base_etre_webmestre_dist quand c'est OK |
|
| 43 | + if ($r = $admin('etre_webmestre', $action)) { |
|
| 44 | + echo $r; |
|
| 45 | + exit; |
|
| 46 | + } |
|
| 47 | + } |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | /** |
@@ -53,8 +53,8 @@ discard block |
||
| 53 | 53 | * @return void |
| 54 | 54 | */ |
| 55 | 55 | function base_etre_webmestre_dist() { |
| 56 | - if ($GLOBALS['visiteur_session']['statut'] == '0minirezo' && $GLOBALS['visiteur_session']['webmestre'] !== 'oui') { |
|
| 57 | - include_spip('action/editer_auteur'); |
|
| 58 | - auteur_instituer($GLOBALS['visiteur_session']['id_auteur'], ['webmestre' => 'oui'], true); |
|
| 59 | - } |
|
| 56 | + if ($GLOBALS['visiteur_session']['statut'] == '0minirezo' && $GLOBALS['visiteur_session']['webmestre'] !== 'oui') { |
|
| 57 | + include_spip('action/editer_auteur'); |
|
| 58 | + auteur_instituer($GLOBALS['visiteur_session']['id_auteur'], ['webmestre' => 'oui'], true); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $champs['source'] = $source ?: 'spip'; |
| 92 | 92 | |
| 93 | 93 | $champs['login'] = ''; |
| 94 | - $champs['statut'] = '5poubelle'; // inutilisable tant qu'il n'a pas ete renseigne et institue |
|
| 94 | + $champs['statut'] = '5poubelle'; // inutilisable tant qu'il n'a pas ete renseigne et institue |
|
| 95 | 95 | $champs['webmestre'] = 'non'; |
| 96 | 96 | if (empty($champs['imessage'])) { |
| 97 | 97 | $champs['imessage'] = 'oui'; |
@@ -331,7 +331,7 @@ discard block |
||
| 331 | 331 | $champs['pass'] = $c['pass']; |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | - $statut = $statut_ancien = sql_getfetsel('statut', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 334 | + $statut = $statut_ancien = sql_getfetsel('statut', 'spip_auteurs', 'id_auteur='.(int) $id_auteur); |
|
| 335 | 335 | |
| 336 | 336 | if ( |
| 337 | 337 | isset($c['statut']) && autoriser('modifier', 'auteur', $id_auteur, null, ['statut' => $c['statut']]) |
@@ -390,7 +390,7 @@ discard block |
||
| 390 | 390 | // commencer par traiter les cas particuliers des logins et pass |
| 391 | 391 | // avant les autres ecritures en base |
| 392 | 392 | if (isset($champs['login']) || isset($champs['pass'])) { |
| 393 | - $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 393 | + $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur='.(int) $id_auteur); |
|
| 394 | 394 | include_spip('inc/auth'); |
| 395 | 395 | if ( |
| 396 | 396 | isset($champs['login']) |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | $erreurs[] = 'ecrire:impossible_modifier_login_auteur'; |
| 401 | 401 | } |
| 402 | 402 | if (isset($champs['pass']) && strlen((string) $champs['pass'])) { |
| 403 | - $champs['login'] = sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 403 | + $champs['login'] = sql_getfetsel('login', 'spip_auteurs', 'id_auteur='.(int) $id_auteur); |
|
| 404 | 404 | if (!auth_modifier_pass($auth_methode, $champs['login'], $champs['pass'], $id_auteur)) { |
| 405 | 405 | $erreurs[] = 'ecrire:impossible_modifier_pass_auteur'; |
| 406 | 406 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | if (!(is_countable($champs) ? count($champs) : 0)) { |
| 414 | 414 | return implode(' ', array_map('_T', $erreurs)); |
| 415 | 415 | } |
| 416 | - sql_updateq('spip_auteurs', $champs, 'id_auteur=' . $id_auteur); |
|
| 416 | + sql_updateq('spip_auteurs', $champs, 'id_auteur='.$id_auteur); |
|
| 417 | 417 | |
| 418 | 418 | // .. mettre a jour les fichiers .htpasswd et .htpasswd-admin |
| 419 | 419 | if ($flag_ecrire_acces || isset($champs['statut'])) { |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -36,40 +36,40 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | function action_editer_auteur_dist($arg = null) { |
| 38 | 38 | |
| 39 | - if (is_null($arg)) { |
|
| 40 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 41 | - $arg = $securiser_action(); |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - // si id_auteur n'est pas un nombre, c'est une creation |
|
| 46 | - if ( |
|
| 47 | - !($id_auteur = (int) $arg) |
|
| 48 | - && ($id_auteur = auteur_inserer()) > 0 |
|
| 49 | - ) { |
|
| 50 | - # cf. GROS HACK |
|
| 51 | - # recuperer l'eventuel logo charge avant la creation |
|
| 52 | - # ils ont un id = 0-id_auteur de la session |
|
| 53 | - $id_hack = 0 - $GLOBALS['visiteur_session']['id_auteur']; |
|
| 54 | - $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 55 | - foreach (['on', 'off'] as $type) { |
|
| 56 | - if (($logo = $chercher_logo($id_hack, 'id_auteur', $type)) && ($logo = reset($logo))) { |
|
| 57 | - rename($logo, str_replace($id_hack, $id_auteur, (string) $logo)); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - // Enregistre l'envoi dans la BD |
|
| 63 | - $err = ''; |
|
| 64 | - if ($id_auteur > 0) { |
|
| 65 | - $err = auteur_modifier($id_auteur); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - if ($err) { |
|
| 69 | - spip_logger()->error("echec editeur auteur: $err"); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return [$id_auteur, $err]; |
|
| 39 | + if (is_null($arg)) { |
|
| 40 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 41 | + $arg = $securiser_action(); |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + // si id_auteur n'est pas un nombre, c'est une creation |
|
| 46 | + if ( |
|
| 47 | + !($id_auteur = (int) $arg) |
|
| 48 | + && ($id_auteur = auteur_inserer()) > 0 |
|
| 49 | + ) { |
|
| 50 | + # cf. GROS HACK |
|
| 51 | + # recuperer l'eventuel logo charge avant la creation |
|
| 52 | + # ils ont un id = 0-id_auteur de la session |
|
| 53 | + $id_hack = 0 - $GLOBALS['visiteur_session']['id_auteur']; |
|
| 54 | + $chercher_logo = charger_fonction('chercher_logo', 'inc'); |
|
| 55 | + foreach (['on', 'off'] as $type) { |
|
| 56 | + if (($logo = $chercher_logo($id_hack, 'id_auteur', $type)) && ($logo = reset($logo))) { |
|
| 57 | + rename($logo, str_replace($id_hack, $id_auteur, (string) $logo)); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + // Enregistre l'envoi dans la BD |
|
| 63 | + $err = ''; |
|
| 64 | + if ($id_auteur > 0) { |
|
| 65 | + $err = auteur_modifier($id_auteur); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + if ($err) { |
|
| 69 | + spip_logger()->error("echec editeur auteur: $err"); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return [$id_auteur, $err]; |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -86,64 +86,64 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | function auteur_inserer($source = null, $set = null) { |
| 88 | 88 | |
| 89 | - // Ce qu'on va demander comme modifications |
|
| 90 | - $champs = []; |
|
| 91 | - $champs['source'] = $source ?: 'spip'; |
|
| 92 | - |
|
| 93 | - $champs['login'] = ''; |
|
| 94 | - $champs['statut'] = '5poubelle'; // inutilisable tant qu'il n'a pas ete renseigne et institue |
|
| 95 | - $champs['webmestre'] = 'non'; |
|
| 96 | - if (empty($champs['imessage'])) { |
|
| 97 | - $champs['imessage'] = 'oui'; |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - if ($set) { |
|
| 101 | - $champs = array_merge($champs, $set); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - // Envoyer aux plugins |
|
| 105 | - $champs = pipeline( |
|
| 106 | - 'pre_insertion', |
|
| 107 | - [ |
|
| 108 | - 'args' => [ |
|
| 109 | - 'table' => 'spip_auteurs', |
|
| 110 | - ], |
|
| 111 | - 'data' => $champs |
|
| 112 | - ] |
|
| 113 | - ); |
|
| 114 | - $id_auteur = sql_insertq('spip_auteurs', $champs); |
|
| 115 | - pipeline( |
|
| 116 | - 'post_insertion', |
|
| 117 | - [ |
|
| 118 | - 'args' => [ |
|
| 119 | - 'table' => 'spip_auteurs', |
|
| 120 | - 'id_objet' => $id_auteur |
|
| 121 | - ], |
|
| 122 | - 'data' => $champs |
|
| 123 | - ] |
|
| 124 | - ); |
|
| 125 | - |
|
| 126 | - // Appeler une notification |
|
| 127 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 128 | - $notifications( |
|
| 129 | - 'auteur_inserer', |
|
| 130 | - $id_auteur, |
|
| 131 | - [ |
|
| 132 | - 'champs' => $champs, |
|
| 133 | - ] |
|
| 134 | - ); |
|
| 135 | - $notifications( |
|
| 136 | - 'objet_inserer', |
|
| 137 | - $id_auteur, |
|
| 138 | - [ |
|
| 139 | - 'objet' => 'auteur', |
|
| 140 | - 'id_objet' => $id_auteur, |
|
| 141 | - 'champs' => $champs, |
|
| 142 | - ] |
|
| 143 | - ); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - return $id_auteur; |
|
| 89 | + // Ce qu'on va demander comme modifications |
|
| 90 | + $champs = []; |
|
| 91 | + $champs['source'] = $source ?: 'spip'; |
|
| 92 | + |
|
| 93 | + $champs['login'] = ''; |
|
| 94 | + $champs['statut'] = '5poubelle'; // inutilisable tant qu'il n'a pas ete renseigne et institue |
|
| 95 | + $champs['webmestre'] = 'non'; |
|
| 96 | + if (empty($champs['imessage'])) { |
|
| 97 | + $champs['imessage'] = 'oui'; |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + if ($set) { |
|
| 101 | + $champs = array_merge($champs, $set); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + // Envoyer aux plugins |
|
| 105 | + $champs = pipeline( |
|
| 106 | + 'pre_insertion', |
|
| 107 | + [ |
|
| 108 | + 'args' => [ |
|
| 109 | + 'table' => 'spip_auteurs', |
|
| 110 | + ], |
|
| 111 | + 'data' => $champs |
|
| 112 | + ] |
|
| 113 | + ); |
|
| 114 | + $id_auteur = sql_insertq('spip_auteurs', $champs); |
|
| 115 | + pipeline( |
|
| 116 | + 'post_insertion', |
|
| 117 | + [ |
|
| 118 | + 'args' => [ |
|
| 119 | + 'table' => 'spip_auteurs', |
|
| 120 | + 'id_objet' => $id_auteur |
|
| 121 | + ], |
|
| 122 | + 'data' => $champs |
|
| 123 | + ] |
|
| 124 | + ); |
|
| 125 | + |
|
| 126 | + // Appeler une notification |
|
| 127 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 128 | + $notifications( |
|
| 129 | + 'auteur_inserer', |
|
| 130 | + $id_auteur, |
|
| 131 | + [ |
|
| 132 | + 'champs' => $champs, |
|
| 133 | + ] |
|
| 134 | + ); |
|
| 135 | + $notifications( |
|
| 136 | + 'objet_inserer', |
|
| 137 | + $id_auteur, |
|
| 138 | + [ |
|
| 139 | + 'objet' => 'auteur', |
|
| 140 | + 'id_objet' => $id_auteur, |
|
| 141 | + 'champs' => $champs, |
|
| 142 | + ] |
|
| 143 | + ); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + return $id_auteur; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | |
@@ -168,70 +168,70 @@ discard block |
||
| 168 | 168 | */ |
| 169 | 169 | function auteur_modifier($id_auteur, $set = null, $force_update = false) { |
| 170 | 170 | |
| 171 | - include_spip('inc/modifier'); |
|
| 172 | - include_spip('inc/filtres'); |
|
| 173 | - $c = collecter_requests( |
|
| 174 | - // include list |
|
| 175 | - objet_info('auteur', 'champs_editables'), |
|
| 176 | - // exclude list |
|
| 177 | - $force_update ? [] : ['webmestre', 'pass', 'login'], |
|
| 178 | - // donnees eventuellement fournies |
|
| 179 | - $set |
|
| 180 | - ); |
|
| 181 | - |
|
| 182 | - if ( |
|
| 183 | - $err = objet_modifier_champs( |
|
| 184 | - 'auteur', |
|
| 185 | - $id_auteur, |
|
| 186 | - [ |
|
| 187 | - 'data' => $set, |
|
| 188 | - 'nonvide' => ['nom' => _T('ecrire:item_nouvel_auteur')] |
|
| 189 | - ], |
|
| 190 | - $c |
|
| 191 | - ) |
|
| 192 | - ) { |
|
| 193 | - return $err; |
|
| 194 | - } |
|
| 195 | - $session = $c; |
|
| 196 | - |
|
| 197 | - $err = ''; |
|
| 198 | - if (!$force_update) { |
|
| 199 | - // Modification de statut, changement de rubrique ? |
|
| 200 | - $c = collecter_requests( |
|
| 201 | - // include list |
|
| 202 | - [ |
|
| 203 | - 'statut', |
|
| 204 | - 'new_login', |
|
| 205 | - 'new_pass', |
|
| 206 | - 'login', |
|
| 207 | - 'pass', |
|
| 208 | - 'webmestre', |
|
| 209 | - 'restreintes', |
|
| 210 | - 'id_parent' |
|
| 211 | - ], |
|
| 212 | - // exclude list |
|
| 213 | - [], |
|
| 214 | - // donnees eventuellement fournies |
|
| 215 | - $set |
|
| 216 | - ); |
|
| 217 | - if (isset($c['new_login']) && !isset($c['login'])) { |
|
| 218 | - $c['login'] = $c['new_login']; |
|
| 219 | - } |
|
| 220 | - if (isset($c['new_pass']) && !isset($c['pass'])) { |
|
| 221 | - $c['pass'] = $c['new_pass']; |
|
| 222 | - } |
|
| 223 | - $err = auteur_instituer($id_auteur, $c); |
|
| 224 | - $session = array_merge($session, $c); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - // .. mettre a jour les sessions de cet auteur |
|
| 228 | - include_spip('inc/session'); |
|
| 229 | - $session['id_auteur'] = $id_auteur; |
|
| 230 | - unset($session['new_login']); |
|
| 231 | - unset($session['new_pass']); |
|
| 232 | - actualiser_sessions($session); |
|
| 233 | - |
|
| 234 | - return $err; |
|
| 171 | + include_spip('inc/modifier'); |
|
| 172 | + include_spip('inc/filtres'); |
|
| 173 | + $c = collecter_requests( |
|
| 174 | + // include list |
|
| 175 | + objet_info('auteur', 'champs_editables'), |
|
| 176 | + // exclude list |
|
| 177 | + $force_update ? [] : ['webmestre', 'pass', 'login'], |
|
| 178 | + // donnees eventuellement fournies |
|
| 179 | + $set |
|
| 180 | + ); |
|
| 181 | + |
|
| 182 | + if ( |
|
| 183 | + $err = objet_modifier_champs( |
|
| 184 | + 'auteur', |
|
| 185 | + $id_auteur, |
|
| 186 | + [ |
|
| 187 | + 'data' => $set, |
|
| 188 | + 'nonvide' => ['nom' => _T('ecrire:item_nouvel_auteur')] |
|
| 189 | + ], |
|
| 190 | + $c |
|
| 191 | + ) |
|
| 192 | + ) { |
|
| 193 | + return $err; |
|
| 194 | + } |
|
| 195 | + $session = $c; |
|
| 196 | + |
|
| 197 | + $err = ''; |
|
| 198 | + if (!$force_update) { |
|
| 199 | + // Modification de statut, changement de rubrique ? |
|
| 200 | + $c = collecter_requests( |
|
| 201 | + // include list |
|
| 202 | + [ |
|
| 203 | + 'statut', |
|
| 204 | + 'new_login', |
|
| 205 | + 'new_pass', |
|
| 206 | + 'login', |
|
| 207 | + 'pass', |
|
| 208 | + 'webmestre', |
|
| 209 | + 'restreintes', |
|
| 210 | + 'id_parent' |
|
| 211 | + ], |
|
| 212 | + // exclude list |
|
| 213 | + [], |
|
| 214 | + // donnees eventuellement fournies |
|
| 215 | + $set |
|
| 216 | + ); |
|
| 217 | + if (isset($c['new_login']) && !isset($c['login'])) { |
|
| 218 | + $c['login'] = $c['new_login']; |
|
| 219 | + } |
|
| 220 | + if (isset($c['new_pass']) && !isset($c['pass'])) { |
|
| 221 | + $c['pass'] = $c['new_pass']; |
|
| 222 | + } |
|
| 223 | + $err = auteur_instituer($id_auteur, $c); |
|
| 224 | + $session = array_merge($session, $c); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + // .. mettre a jour les sessions de cet auteur |
|
| 228 | + include_spip('inc/session'); |
|
| 229 | + $session['id_auteur'] = $id_auteur; |
|
| 230 | + unset($session['new_login']); |
|
| 231 | + unset($session['new_pass']); |
|
| 232 | + actualiser_sessions($session); |
|
| 233 | + |
|
| 234 | + return $err; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -252,9 +252,9 @@ discard block |
||
| 252 | 252 | * @return string |
| 253 | 253 | */ |
| 254 | 254 | function auteur_associer($id_auteur, $objets, $qualif = null) { |
| 255 | - include_spip('action/editer_liens'); |
|
| 255 | + include_spip('action/editer_liens'); |
|
| 256 | 256 | |
| 257 | - return objet_associer(['auteur' => $id_auteur], $objets, $qualif); |
|
| 257 | + return objet_associer(['auteur' => $id_auteur], $objets, $qualif); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | /** |
@@ -273,9 +273,9 @@ discard block |
||
| 273 | 273 | * @return string |
| 274 | 274 | */ |
| 275 | 275 | function auteur_dissocier($id_auteur, $objets) { |
| 276 | - include_spip('action/editer_liens'); |
|
| 276 | + include_spip('action/editer_liens'); |
|
| 277 | 277 | |
| 278 | - return objet_dissocier(['auteur' => $id_auteur], $objets); |
|
| 278 | + return objet_dissocier(['auteur' => $id_auteur], $objets); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -296,9 +296,9 @@ discard block |
||
| 296 | 296 | * @return bool|int |
| 297 | 297 | */ |
| 298 | 298 | function auteur_qualifier($id_auteur, $objets, $qualif) { |
| 299 | - include_spip('action/editer_liens'); |
|
| 299 | + include_spip('action/editer_liens'); |
|
| 300 | 300 | |
| 301 | - return objet_qualifier_liens(['auteur' => $id_auteur], $objets, $qualif); |
|
| 301 | + return objet_qualifier_liens(['auteur' => $id_auteur], $objets, $qualif); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | |
@@ -317,164 +317,164 @@ discard block |
||
| 317 | 317 | * @return bool|string |
| 318 | 318 | */ |
| 319 | 319 | function auteur_instituer($id_auteur, $c, $force_webmestre = false) { |
| 320 | - if (!$id_auteur = (int) $id_auteur) { |
|
| 321 | - return false; |
|
| 322 | - } |
|
| 323 | - $erreurs = []; // contiendra les differentes erreurs a traduire par _T() |
|
| 324 | - $champs = []; |
|
| 325 | - |
|
| 326 | - // les memoriser pour les faire passer dans le pipeline pre_edition |
|
| 327 | - if (isset($c['login']) && strlen((string) $c['login'])) { |
|
| 328 | - $champs['login'] = $c['login']; |
|
| 329 | - } |
|
| 330 | - if (isset($c['pass']) && strlen((string) $c['pass'])) { |
|
| 331 | - $champs['pass'] = $c['pass']; |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - $statut = $statut_ancien = sql_getfetsel('statut', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 335 | - |
|
| 336 | - if ( |
|
| 337 | - isset($c['statut']) && autoriser('modifier', 'auteur', $id_auteur, null, ['statut' => $c['statut']]) |
|
| 338 | - ) { |
|
| 339 | - $statut = $champs['statut'] = $c['statut']; |
|
| 340 | - } |
|
| 341 | - |
|
| 342 | - // Restreindre avant de declarer l'auteur |
|
| 343 | - // (section critique sur les droits) |
|
| 344 | - if (isset($c['id_parent']) && $c['id_parent']) { |
|
| 345 | - if (is_array($c['restreintes'])) { |
|
| 346 | - $c['restreintes'][] = $c['id_parent']; |
|
| 347 | - } else { |
|
| 348 | - $c['restreintes'] = [$c['id_parent']]; |
|
| 349 | - } |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - if ( |
|
| 353 | - isset($c['webmestre']) |
|
| 354 | - && ($force_webmestre || autoriser('modifier', 'auteur', $id_auteur, null, ['webmestre' => '?'])) |
|
| 355 | - ) { |
|
| 356 | - $champs['webmestre'] = $c['webmestre'] == 'oui' ? 'oui' : 'non'; |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - // si statut change et n'est pas 0minirezo, on force webmestre a non |
|
| 360 | - if (isset($c['statut']) && $c['statut'] !== '0minirezo') { |
|
| 361 | - $champs['webmestre'] = $c['webmestre'] = 'non'; |
|
| 362 | - } |
|
| 363 | - |
|
| 364 | - // Envoyer aux plugins |
|
| 365 | - $champs = pipeline( |
|
| 366 | - 'pre_edition', |
|
| 367 | - [ |
|
| 368 | - 'args' => [ |
|
| 369 | - 'table' => 'spip_auteurs', |
|
| 370 | - 'table_objet' => 'auteurs', |
|
| 371 | - 'spip_table_objet' => 'spip_auteurs', |
|
| 372 | - 'objet' => 'auteur', |
|
| 373 | - 'id_objet' => $id_auteur, |
|
| 374 | - 'action' => 'instituer', |
|
| 375 | - 'statut_ancien' => $statut_ancien, |
|
| 376 | - ], |
|
| 377 | - 'data' => $champs |
|
| 378 | - ] |
|
| 379 | - ); |
|
| 380 | - |
|
| 381 | - if ( |
|
| 382 | - isset($c['restreintes']) && is_array($c['restreintes']) |
|
| 383 | - && autoriser('modifier', 'auteur', $id_auteur, null, ['restreint' => $c['restreintes']]) |
|
| 384 | - ) { |
|
| 385 | - $rubriques = array_map('intval', $c['restreintes']); |
|
| 386 | - $rubriques = array_unique($rubriques); |
|
| 387 | - $rubriques = array_diff($rubriques, [0]); |
|
| 388 | - auteur_dissocier($id_auteur, ['rubrique' => '*']); |
|
| 389 | - auteur_associer($id_auteur, ['rubrique' => $rubriques]); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - $flag_ecrire_acces = false; |
|
| 393 | - // commencer par traiter les cas particuliers des logins et pass |
|
| 394 | - // avant les autres ecritures en base |
|
| 395 | - if (isset($champs['login']) || isset($champs['pass'])) { |
|
| 396 | - $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 397 | - include_spip('inc/auth'); |
|
| 398 | - if ( |
|
| 399 | - isset($champs['login']) |
|
| 400 | - && strlen((string) $champs['login']) |
|
| 401 | - && !auth_modifier_login($auth_methode, $champs['login'], $id_auteur) |
|
| 402 | - ) { |
|
| 403 | - $erreurs[] = 'ecrire:impossible_modifier_login_auteur'; |
|
| 404 | - } |
|
| 405 | - if (isset($champs['pass']) && strlen((string) $champs['pass'])) { |
|
| 406 | - $champs['login'] = sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 407 | - if (!auth_modifier_pass($auth_methode, $champs['login'], $champs['pass'], $id_auteur)) { |
|
| 408 | - $erreurs[] = 'ecrire:impossible_modifier_pass_auteur'; |
|
| 409 | - } |
|
| 410 | - } |
|
| 411 | - unset($champs['login']); |
|
| 412 | - unset($champs['pass']); |
|
| 413 | - $flag_ecrire_acces = true; |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 417 | - return implode(' ', array_map('_T', $erreurs)); |
|
| 418 | - } |
|
| 419 | - sql_updateq('spip_auteurs', $champs, 'id_auteur=' . $id_auteur); |
|
| 420 | - |
|
| 421 | - // .. mettre a jour les fichiers .htpasswd et .htpasswd-admin |
|
| 422 | - if ($flag_ecrire_acces || isset($champs['statut'])) { |
|
| 423 | - include_spip('inc/acces'); |
|
| 424 | - ecrire_acces(); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - // Invalider les caches |
|
| 428 | - include_spip('inc/invalideur'); |
|
| 429 | - suivre_invalideur("id='auteur/$id_auteur'"); |
|
| 430 | - |
|
| 431 | - // Pipeline |
|
| 432 | - pipeline( |
|
| 433 | - 'post_edition', |
|
| 434 | - [ |
|
| 435 | - 'args' => [ |
|
| 436 | - 'table' => 'spip_auteurs', |
|
| 437 | - 'table_objet' => 'auteurs', |
|
| 438 | - 'spip_table_objet' => 'spip_auteurs', |
|
| 439 | - 'objet' => 'auteur', |
|
| 440 | - 'id_objet' => $id_auteur, |
|
| 441 | - 'action' => 'instituer', |
|
| 442 | - 'statut_ancien' => $statut_ancien, |
|
| 443 | - ], |
|
| 444 | - 'data' => $champs |
|
| 445 | - ] |
|
| 446 | - ); |
|
| 447 | - |
|
| 448 | - // Notifications |
|
| 449 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 450 | - $notifications( |
|
| 451 | - 'auteur_instituer', |
|
| 452 | - $id_auteur, |
|
| 453 | - [ |
|
| 454 | - 'statut' => $statut, |
|
| 455 | - 'statut_ancien' => $statut_ancien, |
|
| 456 | - 'champs' => $champs, |
|
| 457 | - ] |
|
| 458 | - ); |
|
| 459 | - $notifications( |
|
| 460 | - 'objet_instituer', |
|
| 461 | - $id_auteur, |
|
| 462 | - [ |
|
| 463 | - 'objet' => 'auteur', |
|
| 464 | - 'id_objet' => $id_auteur, |
|
| 465 | - 'statut' => $statut, |
|
| 466 | - 'statut_ancien' => $statut_ancien, |
|
| 467 | - 'champs' => $champs, |
|
| 468 | - ] |
|
| 469 | - ); |
|
| 470 | - |
|
| 471 | - // Rétro-compat |
|
| 472 | - $notifications( |
|
| 473 | - 'instituerauteur', |
|
| 474 | - $id_auteur, |
|
| 475 | - ['statut' => $statut, 'statut_ancien' => $statut_ancien] |
|
| 476 | - ); |
|
| 477 | - } |
|
| 478 | - |
|
| 479 | - return implode(' ', array_map('_T', $erreurs)); |
|
| 320 | + if (!$id_auteur = (int) $id_auteur) { |
|
| 321 | + return false; |
|
| 322 | + } |
|
| 323 | + $erreurs = []; // contiendra les differentes erreurs a traduire par _T() |
|
| 324 | + $champs = []; |
|
| 325 | + |
|
| 326 | + // les memoriser pour les faire passer dans le pipeline pre_edition |
|
| 327 | + if (isset($c['login']) && strlen((string) $c['login'])) { |
|
| 328 | + $champs['login'] = $c['login']; |
|
| 329 | + } |
|
| 330 | + if (isset($c['pass']) && strlen((string) $c['pass'])) { |
|
| 331 | + $champs['pass'] = $c['pass']; |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + $statut = $statut_ancien = sql_getfetsel('statut', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 335 | + |
|
| 336 | + if ( |
|
| 337 | + isset($c['statut']) && autoriser('modifier', 'auteur', $id_auteur, null, ['statut' => $c['statut']]) |
|
| 338 | + ) { |
|
| 339 | + $statut = $champs['statut'] = $c['statut']; |
|
| 340 | + } |
|
| 341 | + |
|
| 342 | + // Restreindre avant de declarer l'auteur |
|
| 343 | + // (section critique sur les droits) |
|
| 344 | + if (isset($c['id_parent']) && $c['id_parent']) { |
|
| 345 | + if (is_array($c['restreintes'])) { |
|
| 346 | + $c['restreintes'][] = $c['id_parent']; |
|
| 347 | + } else { |
|
| 348 | + $c['restreintes'] = [$c['id_parent']]; |
|
| 349 | + } |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + if ( |
|
| 353 | + isset($c['webmestre']) |
|
| 354 | + && ($force_webmestre || autoriser('modifier', 'auteur', $id_auteur, null, ['webmestre' => '?'])) |
|
| 355 | + ) { |
|
| 356 | + $champs['webmestre'] = $c['webmestre'] == 'oui' ? 'oui' : 'non'; |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + // si statut change et n'est pas 0minirezo, on force webmestre a non |
|
| 360 | + if (isset($c['statut']) && $c['statut'] !== '0minirezo') { |
|
| 361 | + $champs['webmestre'] = $c['webmestre'] = 'non'; |
|
| 362 | + } |
|
| 363 | + |
|
| 364 | + // Envoyer aux plugins |
|
| 365 | + $champs = pipeline( |
|
| 366 | + 'pre_edition', |
|
| 367 | + [ |
|
| 368 | + 'args' => [ |
|
| 369 | + 'table' => 'spip_auteurs', |
|
| 370 | + 'table_objet' => 'auteurs', |
|
| 371 | + 'spip_table_objet' => 'spip_auteurs', |
|
| 372 | + 'objet' => 'auteur', |
|
| 373 | + 'id_objet' => $id_auteur, |
|
| 374 | + 'action' => 'instituer', |
|
| 375 | + 'statut_ancien' => $statut_ancien, |
|
| 376 | + ], |
|
| 377 | + 'data' => $champs |
|
| 378 | + ] |
|
| 379 | + ); |
|
| 380 | + |
|
| 381 | + if ( |
|
| 382 | + isset($c['restreintes']) && is_array($c['restreintes']) |
|
| 383 | + && autoriser('modifier', 'auteur', $id_auteur, null, ['restreint' => $c['restreintes']]) |
|
| 384 | + ) { |
|
| 385 | + $rubriques = array_map('intval', $c['restreintes']); |
|
| 386 | + $rubriques = array_unique($rubriques); |
|
| 387 | + $rubriques = array_diff($rubriques, [0]); |
|
| 388 | + auteur_dissocier($id_auteur, ['rubrique' => '*']); |
|
| 389 | + auteur_associer($id_auteur, ['rubrique' => $rubriques]); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + $flag_ecrire_acces = false; |
|
| 393 | + // commencer par traiter les cas particuliers des logins et pass |
|
| 394 | + // avant les autres ecritures en base |
|
| 395 | + if (isset($champs['login']) || isset($champs['pass'])) { |
|
| 396 | + $auth_methode = sql_getfetsel('source', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 397 | + include_spip('inc/auth'); |
|
| 398 | + if ( |
|
| 399 | + isset($champs['login']) |
|
| 400 | + && strlen((string) $champs['login']) |
|
| 401 | + && !auth_modifier_login($auth_methode, $champs['login'], $id_auteur) |
|
| 402 | + ) { |
|
| 403 | + $erreurs[] = 'ecrire:impossible_modifier_login_auteur'; |
|
| 404 | + } |
|
| 405 | + if (isset($champs['pass']) && strlen((string) $champs['pass'])) { |
|
| 406 | + $champs['login'] = sql_getfetsel('login', 'spip_auteurs', 'id_auteur=' . (int) $id_auteur); |
|
| 407 | + if (!auth_modifier_pass($auth_methode, $champs['login'], $champs['pass'], $id_auteur)) { |
|
| 408 | + $erreurs[] = 'ecrire:impossible_modifier_pass_auteur'; |
|
| 409 | + } |
|
| 410 | + } |
|
| 411 | + unset($champs['login']); |
|
| 412 | + unset($champs['pass']); |
|
| 413 | + $flag_ecrire_acces = true; |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 417 | + return implode(' ', array_map('_T', $erreurs)); |
|
| 418 | + } |
|
| 419 | + sql_updateq('spip_auteurs', $champs, 'id_auteur=' . $id_auteur); |
|
| 420 | + |
|
| 421 | + // .. mettre a jour les fichiers .htpasswd et .htpasswd-admin |
|
| 422 | + if ($flag_ecrire_acces || isset($champs['statut'])) { |
|
| 423 | + include_spip('inc/acces'); |
|
| 424 | + ecrire_acces(); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + // Invalider les caches |
|
| 428 | + include_spip('inc/invalideur'); |
|
| 429 | + suivre_invalideur("id='auteur/$id_auteur'"); |
|
| 430 | + |
|
| 431 | + // Pipeline |
|
| 432 | + pipeline( |
|
| 433 | + 'post_edition', |
|
| 434 | + [ |
|
| 435 | + 'args' => [ |
|
| 436 | + 'table' => 'spip_auteurs', |
|
| 437 | + 'table_objet' => 'auteurs', |
|
| 438 | + 'spip_table_objet' => 'spip_auteurs', |
|
| 439 | + 'objet' => 'auteur', |
|
| 440 | + 'id_objet' => $id_auteur, |
|
| 441 | + 'action' => 'instituer', |
|
| 442 | + 'statut_ancien' => $statut_ancien, |
|
| 443 | + ], |
|
| 444 | + 'data' => $champs |
|
| 445 | + ] |
|
| 446 | + ); |
|
| 447 | + |
|
| 448 | + // Notifications |
|
| 449 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 450 | + $notifications( |
|
| 451 | + 'auteur_instituer', |
|
| 452 | + $id_auteur, |
|
| 453 | + [ |
|
| 454 | + 'statut' => $statut, |
|
| 455 | + 'statut_ancien' => $statut_ancien, |
|
| 456 | + 'champs' => $champs, |
|
| 457 | + ] |
|
| 458 | + ); |
|
| 459 | + $notifications( |
|
| 460 | + 'objet_instituer', |
|
| 461 | + $id_auteur, |
|
| 462 | + [ |
|
| 463 | + 'objet' => 'auteur', |
|
| 464 | + 'id_objet' => $id_auteur, |
|
| 465 | + 'statut' => $statut, |
|
| 466 | + 'statut_ancien' => $statut_ancien, |
|
| 467 | + 'champs' => $champs, |
|
| 468 | + ] |
|
| 469 | + ); |
|
| 470 | + |
|
| 471 | + // Rétro-compat |
|
| 472 | + $notifications( |
|
| 473 | + 'instituerauteur', |
|
| 474 | + $id_auteur, |
|
| 475 | + ['statut' => $statut, 'statut_ancien' => $statut_ancien] |
|
| 476 | + ); |
|
| 477 | + } |
|
| 478 | + |
|
| 479 | + return implode(' ', array_map('_T', $erreurs)); |
|
| 480 | 480 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | * @return void |
| 34 | 34 | */ |
| 35 | 35 | function action_ajouter_lien_dist($arg = null) { |
| 36 | - if (is_null($arg)) { |
|
| 37 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 38 | - $arg = $securiser_action(); |
|
| 39 | - } |
|
| 36 | + if (is_null($arg)) { |
|
| 37 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 38 | + $arg = $securiser_action(); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $arg = explode('-', (string) $arg); |
|
| 42 | - [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 41 | + $arg = explode('-', (string) $arg); |
|
| 42 | + [$objet_source, $ids, $objet_lie, $idl] = $arg; |
|
| 43 | 43 | |
| 44 | - include_spip('action/editer_liens'); |
|
| 45 | - objet_associer([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 44 | + include_spip('action/editer_liens'); |
|
| 45 | + objet_associer([$objet_source => $ids], [$objet_lie => $idl]); |
|
| 46 | 46 | } |
@@ -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,53 +35,53 @@ discard block |
||
| 35 | 35 | * ``` |
| 36 | 36 | **/ |
| 37 | 37 | function action_redirect_dist() { |
| 38 | - $type = _request('type'); |
|
| 39 | - $id = (int) _request('id'); |
|
| 40 | - $page = false; |
|
| 38 | + $type = _request('type'); |
|
| 39 | + $id = (int) _request('id'); |
|
| 40 | + $page = false; |
|
| 41 | 41 | |
| 42 | - // verifier le type ou page transmis |
|
| 43 | - if (!preg_match('/^\w+$/', (string) $type)) { |
|
| 44 | - $page = _request('page'); |
|
| 45 | - if (!preg_match('/^\w+$/', (string) $page)) { |
|
| 46 | - return; |
|
| 47 | - } |
|
| 48 | - } |
|
| 42 | + // verifier le type ou page transmis |
|
| 43 | + if (!preg_match('/^\w+$/', (string) $type)) { |
|
| 44 | + $page = _request('page'); |
|
| 45 | + if (!preg_match('/^\w+$/', (string) $page)) { |
|
| 46 | + return; |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - $var_mode = _request('var_mode'); |
|
| 51 | - // forcer la mise a jour de l'url de cet objet ! |
|
| 52 | - if ($var_mode && !defined('_VAR_URLS')) { |
|
| 53 | - define('_VAR_URLS', true); |
|
| 54 | - } |
|
| 50 | + $var_mode = _request('var_mode'); |
|
| 51 | + // forcer la mise a jour de l'url de cet objet ! |
|
| 52 | + if ($var_mode && !defined('_VAR_URLS')) { |
|
| 53 | + define('_VAR_URLS', true); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - $url = $page |
|
| 57 | - ? generer_url_public($page, '', true) |
|
| 58 | - : calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 56 | + $url = $page |
|
| 57 | + ? generer_url_public($page, '', true) |
|
| 58 | + : calculer_url_redirect_entite($type, $id, $var_mode); |
|
| 59 | 59 | |
| 60 | - $status = '302'; |
|
| 61 | - if ($url) { |
|
| 62 | - if ($var_mode) { |
|
| 63 | - $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 64 | - } |
|
| 60 | + $status = '302'; |
|
| 61 | + if ($url) { |
|
| 62 | + if ($var_mode) { |
|
| 63 | + $url = parametre_url($url, 'var_mode', $var_mode, '&'); |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - if ( |
|
| 67 | - $var_mode == 'preview' |
|
| 68 | - && defined('_PREVIEW_TOKEN') |
|
| 69 | - && _PREVIEW_TOKEN |
|
| 70 | - && autoriser('previsualiser') |
|
| 71 | - ) { |
|
| 72 | - include_spip('inc/securiser_action'); |
|
| 73 | - $token = calculer_token_previsu($url); |
|
| 74 | - $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 75 | - } |
|
| 66 | + if ( |
|
| 67 | + $var_mode == 'preview' |
|
| 68 | + && defined('_PREVIEW_TOKEN') |
|
| 69 | + && _PREVIEW_TOKEN |
|
| 70 | + && autoriser('previsualiser') |
|
| 71 | + ) { |
|
| 72 | + include_spip('inc/securiser_action'); |
|
| 73 | + $token = calculer_token_previsu($url); |
|
| 74 | + $url = parametre_url($url, 'var_previewtoken', $token); |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - if (_request('status') && _request('status') == '301') { |
|
| 78 | - $status = '301'; |
|
| 79 | - } |
|
| 80 | - } else { |
|
| 81 | - $url = generer_url_public('404', '', true); |
|
| 82 | - } |
|
| 77 | + if (_request('status') && _request('status') == '301') { |
|
| 78 | + $status = '301'; |
|
| 79 | + } |
|
| 80 | + } else { |
|
| 81 | + $url = generer_url_public('404', '', true); |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - redirige_par_entete(str_replace('&', '&', (string) $url), '', $status); |
|
| 84 | + redirige_par_entete(str_replace('&', '&', (string) $url), '', $status); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
@@ -96,35 +96,35 @@ discard block |
||
| 96 | 96 | * @return string|null |
| 97 | 97 | */ |
| 98 | 98 | function calculer_url_redirect_entite($type, $id, $var_mode) { |
| 99 | - $desc = null; |
|
| 100 | - $publie = null; |
|
| 101 | - $url = null; |
|
| 102 | - // invalider le cache à chaque modif en bdd |
|
| 103 | - $date = 0; |
|
| 104 | - if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 105 | - $date = $GLOBALS['meta']['derniere_modif']; |
|
| 106 | - } |
|
| 107 | - $key = "url-$date-$type-$id"; |
|
| 99 | + $desc = null; |
|
| 100 | + $publie = null; |
|
| 101 | + $url = null; |
|
| 102 | + // invalider le cache à chaque modif en bdd |
|
| 103 | + $date = 0; |
|
| 104 | + if (isset($GLOBALS['meta']['derniere_modif'])) { |
|
| 105 | + $date = $GLOBALS['meta']['derniere_modif']; |
|
| 106 | + } |
|
| 107 | + $key = "url-$date-$type-$id"; |
|
| 108 | 108 | |
| 109 | - // Obtenir l’url et si elle est publié du cache memoization |
|
| 110 | - if (function_exists('cache_get') && ($desc = cache_get($key))) { |
|
| 111 | - [$url, $publie] = $desc; |
|
| 112 | - } |
|
| 113 | - // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 114 | - if (empty($desc) || $var_mode) { |
|
| 115 | - $publie = objet_test_si_publie($type, $id); |
|
| 116 | - $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 117 | - if (function_exists('cache_set')) { |
|
| 118 | - cache_set($key, [$url, $publie], 3600); |
|
| 119 | - } |
|
| 120 | - } |
|
| 109 | + // Obtenir l’url et si elle est publié du cache memoization |
|
| 110 | + if (function_exists('cache_get') && ($desc = cache_get($key))) { |
|
| 111 | + [$url, $publie] = $desc; |
|
| 112 | + } |
|
| 113 | + // Si on ne l’a pas trouvé, ou si var mode, on calcule l’url et son état publie |
|
| 114 | + if (empty($desc) || $var_mode) { |
|
| 115 | + $publie = objet_test_si_publie($type, $id); |
|
| 116 | + $url = generer_objet_url_absolue($id, $type, '', '', true); |
|
| 117 | + if (function_exists('cache_set')) { |
|
| 118 | + cache_set($key, [$url, $publie], 3600); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 123 | - if ($publie) { |
|
| 124 | - return $url; |
|
| 125 | - } elseif (defined('_VAR_PREVIEW') && _VAR_PREVIEW && autoriser('voir', $type, $id)) { |
|
| 126 | - return $url; |
|
| 127 | - } |
|
| 122 | + // On valide l’url si elle est publiee ; sinon si preview on teste l’autorisation |
|
| 123 | + if ($publie) { |
|
| 124 | + return $url; |
|
| 125 | + } elseif (defined('_VAR_PREVIEW') && _VAR_PREVIEW && autoriser('voir', $type, $id)) { |
|
| 126 | + return $url; |
|
| 127 | + } |
|
| 128 | 128 | |
| 129 | - return; |
|
| 129 | + return; |
|
| 130 | 130 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -27,23 +27,23 @@ discard block |
||
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | 29 | function action_confirmer_email_dist() { |
| 30 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 31 | - $arg = $securiser_action(); |
|
| 30 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 31 | + $arg = $securiser_action(); |
|
| 32 | 32 | |
| 33 | - include_spip('inc/filtres'); |
|
| 34 | - if ($GLOBALS['visiteur_session']['id_auteur'] && email_valide($arg)) { |
|
| 35 | - include_spip('action/editer_auteur'); |
|
| 36 | - auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], ['email' => $arg]); |
|
| 37 | - } |
|
| 38 | - // verifier avant de rediriger pour invalider le message de confirmation |
|
| 39 | - // si ca n'a pas marche |
|
| 40 | - if ( |
|
| 41 | - ($redirect = _request('redirect')) && !$arg == sql_getfetsel( |
|
| 42 | - 'email', |
|
| 43 | - 'spip_auteurs', |
|
| 44 | - 'id_auteur=' . (int) $GLOBALS['visiteur_session'] |
|
| 45 | - ) |
|
| 46 | - ) { |
|
| 47 | - $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif', ''); |
|
| 48 | - } |
|
| 33 | + include_spip('inc/filtres'); |
|
| 34 | + if ($GLOBALS['visiteur_session']['id_auteur'] && email_valide($arg)) { |
|
| 35 | + include_spip('action/editer_auteur'); |
|
| 36 | + auteur_modifier($GLOBALS['visiteur_session']['id_auteur'], ['email' => $arg]); |
|
| 37 | + } |
|
| 38 | + // verifier avant de rediriger pour invalider le message de confirmation |
|
| 39 | + // si ca n'a pas marche |
|
| 40 | + if ( |
|
| 41 | + ($redirect = _request('redirect')) && !$arg == sql_getfetsel( |
|
| 42 | + 'email', |
|
| 43 | + 'spip_auteurs', |
|
| 44 | + 'id_auteur=' . (int) $GLOBALS['visiteur_session'] |
|
| 45 | + ) |
|
| 46 | + ) { |
|
| 47 | + $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif', ''); |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | ($redirect = _request('redirect')) && !$arg == sql_getfetsel( |
| 42 | 42 | 'email', |
| 43 | 43 | 'spip_auteurs', |
| 44 | - 'id_auteur=' . (int) $GLOBALS['visiteur_session'] |
|
| 44 | + 'id_auteur='.(int) $GLOBALS['visiteur_session'] |
|
| 45 | 45 | ) |
| 46 | 46 | ) { |
| 47 | 47 | $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif', ''); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
@@ -30,17 +30,17 @@ discard block |
||
| 30 | 30 | */ |
| 31 | 31 | function action_debloquer_edition_dist() { |
| 32 | 32 | |
| 33 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 34 | - $arg = $securiser_action(); |
|
| 33 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 34 | + $arg = $securiser_action(); |
|
| 35 | 35 | |
| 36 | - if ($arg) { |
|
| 37 | - include_spip('inc/drapeau_edition'); |
|
| 38 | - if ($arg == 'tous') { |
|
| 39 | - debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 40 | - } else { |
|
| 41 | - $arg = explode('-', (string) $arg); |
|
| 42 | - [$objet, $id_objet] = $arg; |
|
| 43 | - debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 44 | - } |
|
| 45 | - } |
|
| 36 | + if ($arg) { |
|
| 37 | + include_spip('inc/drapeau_edition'); |
|
| 38 | + if ($arg == 'tous') { |
|
| 39 | + debloquer_tous($GLOBALS['visiteur_session']['id_auteur']); |
|
| 40 | + } else { |
|
| 41 | + $arg = explode('-', (string) $arg); |
|
| 42 | + [$objet, $id_objet] = $arg; |
|
| 43 | + debloquer_edition($GLOBALS['visiteur_session']['id_auteur'], $id_objet, $objet); |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | 46 | } |