@@ -16,92 +16,92 @@ |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | function action_api_transmettre_dist($arg = null) { |
| 24 | 24 | |
| 25 | - // Obtenir l'argument 'id_auteur/cle/format/fond' |
|
| 26 | - if (is_null($arg)) { |
|
| 27 | - $arg = _request('arg'); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - $args = explode('/', (string) $arg); |
|
| 31 | - |
|
| 32 | - if (count($args) !== 4) { |
|
| 33 | - action_api_transmettre_fail($arg); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - [$id_auteur, $cle, $format, $fond] = $args; |
|
| 37 | - $id_auteur = (int) $id_auteur; |
|
| 38 | - |
|
| 39 | - if (preg_match(',[^\w\\.-],', $format)) { |
|
| 40 | - action_api_transmettre_fail("format $format ??"); |
|
| 41 | - } |
|
| 42 | - if (preg_match(',[^\w\\.-],', $fond)) { |
|
| 43 | - action_api_transmettre_fail("fond $fond ??"); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - // verifier la cle |
|
| 47 | - //[(#ENV{id,0}|securiser_acces{#ENV{cle}, voirstats, #ENV{op}, #ENV{args}}|?{1,0})] |
|
| 48 | - //[(#ENV{id,0}|securiser_acces{#ENV{cle}, voirstats, #ENV{op}, #ENV{args}}|?{1,0})] |
|
| 49 | - |
|
| 50 | - $qs = $_SERVER['QUERY_STRING']; |
|
| 51 | - // retirer action et arg de la qs |
|
| 52 | - $contexte = []; |
|
| 53 | - parse_str((string) $qs, $contexte); |
|
| 54 | - foreach (array_keys($contexte) as $k) { |
|
| 55 | - if (in_array($k, ['action', 'arg', 'var_mode'])) { |
|
| 56 | - unset($contexte[$k]); |
|
| 57 | - } |
|
| 58 | - } |
|
| 59 | - $qs = http_build_query($contexte); |
|
| 60 | - include_spip('inc/acces'); |
|
| 61 | - if (!securiser_acces_low_sec((int) $id_auteur, $cle, "transmettre/$format", $fond, $qs)) { |
|
| 62 | - // si le autoriser low_sec n'est pas bon, on peut valider l'appel si l'auteur est identifie |
|
| 63 | - include_spip('inc/autoriser'); |
|
| 64 | - $autoriser_type = preg_replace(',\W+,', '', "_{$format}{$fond}"); |
|
| 65 | - if ( |
|
| 66 | - !$id_auteur |
|
| 67 | - || empty($GLOBALS['visiteur_session']['id_auteur']) |
|
| 68 | - || $GLOBALS['visiteur_session']['id_auteur'] != $id_auteur |
|
| 69 | - || !autoriser('transmettre', $autoriser_type, $id_auteur) |
|
| 70 | - ) { |
|
| 71 | - action_api_transmettre_fail("auth QS $qs ??"); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - $contexte['id_auteur'] = $id_auteur; |
|
| 76 | - |
|
| 77 | - $fond = "transmettre/$format/$fond"; |
|
| 78 | - |
|
| 79 | - if (!trouver_fond($fond)) { |
|
| 80 | - $fond = "prive/$fond"; |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - if (!trouver_fond($fond)) { |
|
| 84 | - action_api_transmettre_fail("fond $fond ??"); |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - $res = recuperer_fond($fond, $contexte, ['raw' => true]); |
|
| 88 | - if (!empty($res['entetes'])) { |
|
| 89 | - foreach ($res['entetes'] as $h => $v) { |
|
| 90 | - header("$h: $v"); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - $res = ltrim((string) $res['texte']); |
|
| 95 | - if (empty($res)) { |
|
| 96 | - spip_logger('transmettre')->notice("$arg $qs resultat vide"); |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - echo $res; |
|
| 100 | - exit(); |
|
| 25 | + // Obtenir l'argument 'id_auteur/cle/format/fond' |
|
| 26 | + if (is_null($arg)) { |
|
| 27 | + $arg = _request('arg'); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + $args = explode('/', (string) $arg); |
|
| 31 | + |
|
| 32 | + if (count($args) !== 4) { |
|
| 33 | + action_api_transmettre_fail($arg); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + [$id_auteur, $cle, $format, $fond] = $args; |
|
| 37 | + $id_auteur = (int) $id_auteur; |
|
| 38 | + |
|
| 39 | + if (preg_match(',[^\w\\.-],', $format)) { |
|
| 40 | + action_api_transmettre_fail("format $format ??"); |
|
| 41 | + } |
|
| 42 | + if (preg_match(',[^\w\\.-],', $fond)) { |
|
| 43 | + action_api_transmettre_fail("fond $fond ??"); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + // verifier la cle |
|
| 47 | + //[(#ENV{id,0}|securiser_acces{#ENV{cle}, voirstats, #ENV{op}, #ENV{args}}|?{1,0})] |
|
| 48 | + //[(#ENV{id,0}|securiser_acces{#ENV{cle}, voirstats, #ENV{op}, #ENV{args}}|?{1,0})] |
|
| 49 | + |
|
| 50 | + $qs = $_SERVER['QUERY_STRING']; |
|
| 51 | + // retirer action et arg de la qs |
|
| 52 | + $contexte = []; |
|
| 53 | + parse_str((string) $qs, $contexte); |
|
| 54 | + foreach (array_keys($contexte) as $k) { |
|
| 55 | + if (in_array($k, ['action', 'arg', 'var_mode'])) { |
|
| 56 | + unset($contexte[$k]); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | + $qs = http_build_query($contexte); |
|
| 60 | + include_spip('inc/acces'); |
|
| 61 | + if (!securiser_acces_low_sec((int) $id_auteur, $cle, "transmettre/$format", $fond, $qs)) { |
|
| 62 | + // si le autoriser low_sec n'est pas bon, on peut valider l'appel si l'auteur est identifie |
|
| 63 | + include_spip('inc/autoriser'); |
|
| 64 | + $autoriser_type = preg_replace(',\W+,', '', "_{$format}{$fond}"); |
|
| 65 | + if ( |
|
| 66 | + !$id_auteur |
|
| 67 | + || empty($GLOBALS['visiteur_session']['id_auteur']) |
|
| 68 | + || $GLOBALS['visiteur_session']['id_auteur'] != $id_auteur |
|
| 69 | + || !autoriser('transmettre', $autoriser_type, $id_auteur) |
|
| 70 | + ) { |
|
| 71 | + action_api_transmettre_fail("auth QS $qs ??"); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + $contexte['id_auteur'] = $id_auteur; |
|
| 76 | + |
|
| 77 | + $fond = "transmettre/$format/$fond"; |
|
| 78 | + |
|
| 79 | + if (!trouver_fond($fond)) { |
|
| 80 | + $fond = "prive/$fond"; |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + if (!trouver_fond($fond)) { |
|
| 84 | + action_api_transmettre_fail("fond $fond ??"); |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + $res = recuperer_fond($fond, $contexte, ['raw' => true]); |
|
| 88 | + if (!empty($res['entetes'])) { |
|
| 89 | + foreach ($res['entetes'] as $h => $v) { |
|
| 90 | + header("$h: $v"); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + $res = ltrim((string) $res['texte']); |
|
| 95 | + if (empty($res)) { |
|
| 96 | + spip_logger('transmettre')->notice("$arg $qs resultat vide"); |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + echo $res; |
|
| 100 | + exit(); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | function action_api_transmettre_fail($arg): never { |
| 104 | - include_spip('inc/minipres'); |
|
| 105 | - echo minipres(_T('info_acces_interdit'), $arg); |
|
| 106 | - exit; |
|
| 104 | + include_spip('inc/minipres'); |
|
| 105 | + echo minipres(_T('info_acces_interdit'), $arg); |
|
| 106 | + exit; |
|
| 107 | 107 | } |
@@ -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 | /** |
@@ -40,54 +40,54 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | function action_referencer_traduction_dist($objet, $id_objet, $id_trad) { |
| 42 | 42 | |
| 43 | - // ne rien faire si id_trad est ambigu |
|
| 44 | - if (!is_numeric($id_trad)) { |
|
| 45 | - return false; |
|
| 46 | - } |
|
| 43 | + // ne rien faire si id_trad est ambigu |
|
| 44 | + if (!is_numeric($id_trad)) { |
|
| 45 | + return false; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - $table_objet_sql = table_objet_sql($objet); |
|
| 49 | - $id_table_objet = id_table_objet($objet); |
|
| 48 | + $table_objet_sql = table_objet_sql($objet); |
|
| 49 | + $id_table_objet = id_table_objet($objet); |
|
| 50 | 50 | |
| 51 | - // on a fourni un id_trad : affectation ou modification du groupe de trad |
|
| 52 | - if ($id_trad) { |
|
| 53 | - // selectionner l'objet cible, qui doit etre different de nous-meme, |
|
| 54 | - // et quitter s'il n'existe pas |
|
| 55 | - $id_lier = sql_getfetsel( |
|
| 56 | - 'id_trad', |
|
| 57 | - $table_objet_sql, |
|
| 58 | - "$id_table_objet=" . (int) $id_trad . " AND NOT($id_table_objet=" . (int) $id_objet . ')' |
|
| 59 | - ); |
|
| 60 | - if ($id_lier === null) { |
|
| 61 | - spip_logger()->info("echec lien de trad vers objet $objet/$id_objet incorrect ($id_trad)"); |
|
| 51 | + // on a fourni un id_trad : affectation ou modification du groupe de trad |
|
| 52 | + if ($id_trad) { |
|
| 53 | + // selectionner l'objet cible, qui doit etre different de nous-meme, |
|
| 54 | + // et quitter s'il n'existe pas |
|
| 55 | + $id_lier = sql_getfetsel( |
|
| 56 | + 'id_trad', |
|
| 57 | + $table_objet_sql, |
|
| 58 | + "$id_table_objet=" . (int) $id_trad . " AND NOT($id_table_objet=" . (int) $id_objet . ')' |
|
| 59 | + ); |
|
| 60 | + if ($id_lier === null) { |
|
| 61 | + spip_logger()->info("echec lien de trad vers objet $objet/$id_objet incorrect ($id_trad)"); |
|
| 62 | 62 | |
| 63 | - return false; |
|
| 64 | - } |
|
| 63 | + return false; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - // $id_lier est le numero du groupe de traduction |
|
| 67 | - // Si l'objet vise n'est pas deja traduit, son identifiant devient |
|
| 68 | - // le nouvel id_trad de ce nouveau groupe et on l'affecte aux deux |
|
| 69 | - // objets |
|
| 70 | - if ($id_lier == 0) { |
|
| 71 | - sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "$id_table_objet IN ($id_trad, $id_objet)"); |
|
| 72 | - } // si id_lier = id_objet alors on veut changer la reference de tout le groupe de trad |
|
| 73 | - elseif ($id_lier == $id_objet) { |
|
| 74 | - sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "id_trad = $id_lier"); |
|
| 75 | - } // sinon ajouter notre objet dans le groupe |
|
| 76 | - else { |
|
| 77 | - sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=" . (int) $id_objet); |
|
| 78 | - } |
|
| 79 | - } // on a fourni un id_trad nul : sortir id_objet du groupe de trad |
|
| 80 | - else { |
|
| 81 | - $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=" . (int) $id_objet); |
|
| 82 | - // supprimer le lien de traduction |
|
| 83 | - sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=" . (int) $id_objet); |
|
| 66 | + // $id_lier est le numero du groupe de traduction |
|
| 67 | + // Si l'objet vise n'est pas deja traduit, son identifiant devient |
|
| 68 | + // le nouvel id_trad de ce nouveau groupe et on l'affecte aux deux |
|
| 69 | + // objets |
|
| 70 | + if ($id_lier == 0) { |
|
| 71 | + sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "$id_table_objet IN ($id_trad, $id_objet)"); |
|
| 72 | + } // si id_lier = id_objet alors on veut changer la reference de tout le groupe de trad |
|
| 73 | + elseif ($id_lier == $id_objet) { |
|
| 74 | + sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "id_trad = $id_lier"); |
|
| 75 | + } // sinon ajouter notre objet dans le groupe |
|
| 76 | + else { |
|
| 77 | + sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=" . (int) $id_objet); |
|
| 78 | + } |
|
| 79 | + } // on a fourni un id_trad nul : sortir id_objet du groupe de trad |
|
| 80 | + else { |
|
| 81 | + $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=" . (int) $id_objet); |
|
| 82 | + // supprimer le lien de traduction |
|
| 83 | + sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=" . (int) $id_objet); |
|
| 84 | 84 | |
| 85 | - // Verifier si l'ancien groupe ne comporte plus qu'un seul objet. Alors mettre a zero. |
|
| 86 | - $cpt = sql_countsel($table_objet_sql, 'id_trad=' . (int) $old_id_trad); |
|
| 87 | - if ($cpt == 1) { |
|
| 88 | - sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad=' . (int) $old_id_trad); |
|
| 89 | - } |
|
| 90 | - } |
|
| 85 | + // Verifier si l'ancien groupe ne comporte plus qu'un seul objet. Alors mettre a zero. |
|
| 86 | + $cpt = sql_countsel($table_objet_sql, 'id_trad=' . (int) $old_id_trad); |
|
| 87 | + if ($cpt == 1) { |
|
| 88 | + sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad=' . (int) $old_id_trad); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - return true; |
|
| 92 | + return true; |
|
| 93 | 93 | } |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $id_lier = sql_getfetsel( |
| 56 | 56 | 'id_trad', |
| 57 | 57 | $table_objet_sql, |
| 58 | - "$id_table_objet=" . (int) $id_trad . " AND NOT($id_table_objet=" . (int) $id_objet . ')' |
|
| 58 | + "$id_table_objet=".(int) $id_trad." AND NOT($id_table_objet=".(int) $id_objet.')' |
|
| 59 | 59 | ); |
| 60 | 60 | if ($id_lier === null) { |
| 61 | 61 | spip_logger()->info("echec lien de trad vers objet $objet/$id_objet incorrect ($id_trad)"); |
@@ -74,18 +74,18 @@ discard block |
||
| 74 | 74 | sql_updateq($table_objet_sql, ['id_trad' => $id_trad], "id_trad = $id_lier"); |
| 75 | 75 | } // sinon ajouter notre objet dans le groupe |
| 76 | 76 | else { |
| 77 | - sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=" . (int) $id_objet); |
|
| 77 | + sql_updateq($table_objet_sql, ['id_trad' => $id_lier], "$id_table_objet=".(int) $id_objet); |
|
| 78 | 78 | } |
| 79 | 79 | } // on a fourni un id_trad nul : sortir id_objet du groupe de trad |
| 80 | 80 | else { |
| 81 | - $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=" . (int) $id_objet); |
|
| 81 | + $old_id_trad = sql_getfetsel('id_trad', $table_objet_sql, "$id_table_objet=".(int) $id_objet); |
|
| 82 | 82 | // supprimer le lien de traduction |
| 83 | - sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=" . (int) $id_objet); |
|
| 83 | + sql_updateq($table_objet_sql, ['id_trad' => 0], "$id_table_objet=".(int) $id_objet); |
|
| 84 | 84 | |
| 85 | 85 | // Verifier si l'ancien groupe ne comporte plus qu'un seul objet. Alors mettre a zero. |
| 86 | - $cpt = sql_countsel($table_objet_sql, 'id_trad=' . (int) $old_id_trad); |
|
| 86 | + $cpt = sql_countsel($table_objet_sql, 'id_trad='.(int) $old_id_trad); |
|
| 87 | 87 | if ($cpt == 1) { |
| 88 | - sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad=' . (int) $old_id_trad); |
|
| 88 | + sql_updateq($table_objet_sql, ['id_trad' => 0], 'id_trad='.(int) $old_id_trad); |
|
| 89 | 89 | } |
| 90 | 90 | } |
| 91 | 91 | |
@@ -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 | /** |
@@ -31,16 +31,16 @@ discard block |
||
| 31 | 31 | * Envoyer en réponse : json contenant toutes les variables publiques de la session |
| 32 | 32 | **/ |
| 33 | 33 | function action_session_dist() { |
| 34 | - if ( |
|
| 35 | - ($var = _request('var')) |
|
| 36 | - && preg_match(',^[a-z_0-9-]+$,i', (string) $var) |
|
| 37 | - && $_SERVER['REQUEST_METHOD'] == 'POST' |
|
| 38 | - ) { |
|
| 39 | - include_spip('inc/session'); |
|
| 40 | - session_set('session_' . $var, $val = _request('val')); |
|
| 41 | - #spip_logger('autosave')->info("autosave:$var:$val"); |
|
| 42 | - } |
|
| 34 | + if ( |
|
| 35 | + ($var = _request('var')) |
|
| 36 | + && preg_match(',^[a-z_0-9-]+$,i', (string) $var) |
|
| 37 | + && $_SERVER['REQUEST_METHOD'] == 'POST' |
|
| 38 | + ) { |
|
| 39 | + include_spip('inc/session'); |
|
| 40 | + session_set('session_' . $var, $val = _request('val')); |
|
| 41 | + #spip_logger('autosave')->info("autosave:$var:$val"); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - # TODO: mode lecture de session ; n'afficher que ce qu'il faut |
|
| 45 | - #echo json_encode($GLOBALS['visiteur_session']); |
|
| 44 | + # TODO: mode lecture de session ; n'afficher que ce qu'il faut |
|
| 45 | + #echo json_encode($GLOBALS['visiteur_session']); |
|
| 46 | 46 | } |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | && $_SERVER['REQUEST_METHOD'] == 'POST' |
| 38 | 38 | ) { |
| 39 | 39 | include_spip('inc/session'); |
| 40 | - session_set('session_' . $var, $val = _request('val')); |
|
| 40 | + session_set('session_'.$var, $val = _request('val')); |
|
| 41 | 41 | #spip_logger('autosave')->info("autosave:$var:$val"); |
| 42 | 42 | } |
| 43 | 43 | |
@@ -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 | /** |
@@ -32,36 +32,36 @@ discard block |
||
| 32 | 32 | */ |
| 33 | 33 | function action_editer_objet_dist($id = null, $objet = null, $set = null) { |
| 34 | 34 | |
| 35 | - // appel direct depuis une url avec arg = "objet/id" |
|
| 36 | - if (is_null($id) || is_null($objet)) { |
|
| 37 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 38 | - $arg = $securiser_action(); |
|
| 39 | - [$objet, $id] = array_pad(explode('/', (string) $arg, 2), 2, null); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - // appel incorrect ou depuis une url erronnée interdit |
|
| 43 | - if (is_null($id) || is_null($objet)) { |
|
| 44 | - include_spip('inc/minipres'); |
|
| 45 | - echo minipres(_T('info_acces_interdit')); |
|
| 46 | - die(); |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - // si id n'est pas un nombre, c'est une creation |
|
| 50 | - // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 51 | - if (!$id = (int) $id) { |
|
| 52 | - // on ne sait pas si un parent existe mais on essaye |
|
| 53 | - $id_parent = _request('id_parent'); |
|
| 54 | - $id = objet_inserer($objet, $id_parent); |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - if (!($id = (int) $id) > 0) { |
|
| 58 | - return [$id, _L('echec enregistrement en base')]; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - // Enregistre l'envoi dans la BD |
|
| 62 | - $err = objet_modifier($objet, $id, $set); |
|
| 63 | - |
|
| 64 | - return [$id, $err]; |
|
| 35 | + // appel direct depuis une url avec arg = "objet/id" |
|
| 36 | + if (is_null($id) || is_null($objet)) { |
|
| 37 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 38 | + $arg = $securiser_action(); |
|
| 39 | + [$objet, $id] = array_pad(explode('/', (string) $arg, 2), 2, null); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + // appel incorrect ou depuis une url erronnée interdit |
|
| 43 | + if (is_null($id) || is_null($objet)) { |
|
| 44 | + include_spip('inc/minipres'); |
|
| 45 | + echo minipres(_T('info_acces_interdit')); |
|
| 46 | + die(); |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + // si id n'est pas un nombre, c'est une creation |
|
| 50 | + // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 51 | + if (!$id = (int) $id) { |
|
| 52 | + // on ne sait pas si un parent existe mais on essaye |
|
| 53 | + $id_parent = _request('id_parent'); |
|
| 54 | + $id = objet_inserer($objet, $id_parent); |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + if (!($id = (int) $id) > 0) { |
|
| 58 | + return [$id, _L('echec enregistrement en base')]; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + // Enregistre l'envoi dans la BD |
|
| 62 | + $err = objet_modifier($objet, $id, $set); |
|
| 63 | + |
|
| 64 | + return [$id, $err]; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -90,83 +90,83 @@ discard block |
||
| 90 | 90 | * - En cas d'erreur : (string) message d'erreur |
| 91 | 91 | */ |
| 92 | 92 | function objet_modifier($objet, $id, $set = null) { |
| 93 | - if (($t = objet_type($objet)) !== $objet) { |
|
| 94 | - spip_logger('editer')->notice("objet_modifier: appel avec type $objet invalide au lieu de $t"); |
|
| 95 | - $objet = $t; |
|
| 96 | - } |
|
| 97 | - if ( |
|
| 98 | - include_spip('action/editer_' . $objet) && function_exists($modifier = $objet . '_modifier') |
|
| 99 | - ) { |
|
| 100 | - return $modifier($id, $set); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - $table_sql = table_objet_sql($objet); |
|
| 104 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 105 | - $desc = $trouver_table($table_sql); |
|
| 106 | - if (!$desc || !isset($desc['field'])) { |
|
| 107 | - spip_logger('editer')->error("Objet $objet inconnu dans objet_modifier"); |
|
| 108 | - |
|
| 109 | - return _L("Erreur objet $objet inconnu"); |
|
| 110 | - } |
|
| 111 | - include_spip('inc/modifier'); |
|
| 112 | - |
|
| 113 | - $champ_date = ''; |
|
| 114 | - if (isset($desc['date']) && $desc['date']) { |
|
| 115 | - $champ_date = $desc['date']; |
|
| 116 | - } elseif (isset($desc['field']['date'])) { |
|
| 117 | - $champ_date = 'date'; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - $include_list = array_keys($desc['field']); |
|
| 121 | - // on ne traite pas la cle primaire par defaut, notamment car |
|
| 122 | - // sur une creation, id_x vaut 'oui', et serait enregistre en id_x=0 dans la base |
|
| 123 | - $include_list = array_diff($include_list, [$desc['key']['PRIMARY KEY']]); |
|
| 124 | - |
|
| 125 | - if (isset($desc['champs_editables']) && is_array($desc['champs_editables'])) { |
|
| 126 | - $include_list = $desc['champs_editables']; |
|
| 127 | - } |
|
| 128 | - $c = collecter_requests( |
|
| 129 | - // include list |
|
| 130 | - $include_list, |
|
| 131 | - // exclude list |
|
| 132 | - [$champ_date, 'statut', 'id_parent', 'id_secteur'], |
|
| 133 | - // donnees eventuellement fournies |
|
| 134 | - $set |
|
| 135 | - ); |
|
| 136 | - |
|
| 137 | - // Si l'objet est publie, invalider les caches et demander sa reindexation |
|
| 138 | - if (objet_test_si_publie($objet, $id)) { |
|
| 139 | - $invalideur = "id='$objet/$id'"; |
|
| 140 | - $indexation = true; |
|
| 141 | - } else { |
|
| 142 | - $invalideur = ''; |
|
| 143 | - $indexation = false; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - if ( |
|
| 147 | - $err = objet_modifier_champs( |
|
| 148 | - $objet, |
|
| 149 | - $id, |
|
| 150 | - [ |
|
| 151 | - 'data' => $set, |
|
| 152 | - 'nonvide' => '', |
|
| 153 | - 'invalideur' => $invalideur, |
|
| 154 | - 'indexation' => $indexation, |
|
| 155 | - // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 156 | - 'date_modif' => (isset($desc['field']['date_modif']) ? 'date_modif' : '') |
|
| 157 | - ], |
|
| 158 | - $c |
|
| 159 | - ) |
|
| 160 | - ) { |
|
| 161 | - return $err; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - // Modification de statut, changement de rubrique ? |
|
| 165 | - // FIXME: Ici lorsqu'un $set est passé, la fonction collecter_requests() retourne tout |
|
| 166 | - // le tableau $set hors liste d’exclusion, mais du coup on a possiblement des champs en trop. |
|
| 167 | - $c = collecter_requests([$champ_date, 'statut', 'id_parent'], [], $set); |
|
| 168 | - |
|
| 169 | - return objet_instituer($objet, $id, $c); |
|
| 93 | + if (($t = objet_type($objet)) !== $objet) { |
|
| 94 | + spip_logger('editer')->notice("objet_modifier: appel avec type $objet invalide au lieu de $t"); |
|
| 95 | + $objet = $t; |
|
| 96 | + } |
|
| 97 | + if ( |
|
| 98 | + include_spip('action/editer_' . $objet) && function_exists($modifier = $objet . '_modifier') |
|
| 99 | + ) { |
|
| 100 | + return $modifier($id, $set); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + $table_sql = table_objet_sql($objet); |
|
| 104 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 105 | + $desc = $trouver_table($table_sql); |
|
| 106 | + if (!$desc || !isset($desc['field'])) { |
|
| 107 | + spip_logger('editer')->error("Objet $objet inconnu dans objet_modifier"); |
|
| 108 | + |
|
| 109 | + return _L("Erreur objet $objet inconnu"); |
|
| 110 | + } |
|
| 111 | + include_spip('inc/modifier'); |
|
| 112 | + |
|
| 113 | + $champ_date = ''; |
|
| 114 | + if (isset($desc['date']) && $desc['date']) { |
|
| 115 | + $champ_date = $desc['date']; |
|
| 116 | + } elseif (isset($desc['field']['date'])) { |
|
| 117 | + $champ_date = 'date'; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + $include_list = array_keys($desc['field']); |
|
| 121 | + // on ne traite pas la cle primaire par defaut, notamment car |
|
| 122 | + // sur une creation, id_x vaut 'oui', et serait enregistre en id_x=0 dans la base |
|
| 123 | + $include_list = array_diff($include_list, [$desc['key']['PRIMARY KEY']]); |
|
| 124 | + |
|
| 125 | + if (isset($desc['champs_editables']) && is_array($desc['champs_editables'])) { |
|
| 126 | + $include_list = $desc['champs_editables']; |
|
| 127 | + } |
|
| 128 | + $c = collecter_requests( |
|
| 129 | + // include list |
|
| 130 | + $include_list, |
|
| 131 | + // exclude list |
|
| 132 | + [$champ_date, 'statut', 'id_parent', 'id_secteur'], |
|
| 133 | + // donnees eventuellement fournies |
|
| 134 | + $set |
|
| 135 | + ); |
|
| 136 | + |
|
| 137 | + // Si l'objet est publie, invalider les caches et demander sa reindexation |
|
| 138 | + if (objet_test_si_publie($objet, $id)) { |
|
| 139 | + $invalideur = "id='$objet/$id'"; |
|
| 140 | + $indexation = true; |
|
| 141 | + } else { |
|
| 142 | + $invalideur = ''; |
|
| 143 | + $indexation = false; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + if ( |
|
| 147 | + $err = objet_modifier_champs( |
|
| 148 | + $objet, |
|
| 149 | + $id, |
|
| 150 | + [ |
|
| 151 | + 'data' => $set, |
|
| 152 | + 'nonvide' => '', |
|
| 153 | + 'invalideur' => $invalideur, |
|
| 154 | + 'indexation' => $indexation, |
|
| 155 | + // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 156 | + 'date_modif' => (isset($desc['field']['date_modif']) ? 'date_modif' : '') |
|
| 157 | + ], |
|
| 158 | + $c |
|
| 159 | + ) |
|
| 160 | + ) { |
|
| 161 | + return $err; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + // Modification de statut, changement de rubrique ? |
|
| 165 | + // FIXME: Ici lorsqu'un $set est passé, la fonction collecter_requests() retourne tout |
|
| 166 | + // le tableau $set hors liste d’exclusion, mais du coup on a possiblement des champs en trop. |
|
| 167 | + $c = collecter_requests([$champ_date, 'statut', 'id_parent'], [], $set); |
|
| 168 | + |
|
| 169 | + return objet_instituer($objet, $id, $c); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
@@ -197,154 +197,154 @@ discard block |
||
| 197 | 197 | * - (int) 0 si le type d'objet n'existe pas ou que la table est mal déclarée |
| 198 | 198 | */ |
| 199 | 199 | function objet_inserer($objet, $id_parent = null, $set = null) { |
| 200 | - $d = null; |
|
| 201 | - if (($t = objet_type($objet)) !== $objet) { |
|
| 202 | - spip_logger('editer')->notice("objet_inserer: appel avec type $objet invalide au lieu de $t"); |
|
| 203 | - $objet = $t; |
|
| 204 | - } |
|
| 205 | - if ( |
|
| 206 | - include_spip('action/editer_' . $objet) |
|
| 207 | - && function_exists($inserer = $objet . '_inserer') |
|
| 208 | - ) { |
|
| 209 | - return $inserer($id_parent, $set); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - $table_sql = table_objet_sql($objet); |
|
| 213 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 214 | - $desc = $trouver_table($table_sql); |
|
| 215 | - if (!$desc || !isset($desc['field'])) { |
|
| 216 | - return 0; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - $lang_rub = ''; |
|
| 220 | - $champs = []; |
|
| 221 | - if (isset($desc['field']['id_rubrique'])) { |
|
| 222 | - // Si id_rubrique vaut 0 ou n'est pas definie, creer l'objet |
|
| 223 | - // dans la premiere rubrique racine |
|
| 224 | - if (!$id_rubrique = (int) $id_parent) { |
|
| 225 | - $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 226 | - $id_rubrique = $row['id_rubrique']; |
|
| 227 | - } else { |
|
| 228 | - $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - $champs['id_rubrique'] = $id_rubrique; |
|
| 232 | - if (isset($desc['field']['id_secteur'])) { |
|
| 233 | - $champs['id_secteur'] = $row['id_secteur']; |
|
| 234 | - } |
|
| 235 | - $lang_rub = $row['lang']; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - // La langue a la creation : si les liens de traduction sont autorises |
|
| 239 | - // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 240 | - // ou a defaut celle de la rubrique |
|
| 241 | - // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 242 | - if ( |
|
| 243 | - isset($desc['field']['lang']) && !empty($GLOBALS['meta']['multi_objets']) && in_array( |
|
| 244 | - $table_sql, |
|
| 245 | - explode(',', (string) $GLOBALS['meta']['multi_objets']) |
|
| 246 | - ) |
|
| 247 | - ) { |
|
| 248 | - lang_select($GLOBALS['visiteur_session']['lang'] ?? ''); |
|
| 249 | - if ( |
|
| 250 | - in_array( |
|
| 251 | - $GLOBALS['spip_lang'], |
|
| 252 | - explode(',', (string) $GLOBALS['meta']['langues_multilingue']) |
|
| 253 | - ) |
|
| 254 | - ) { |
|
| 255 | - $champs['lang'] = $GLOBALS['spip_lang']; |
|
| 256 | - if (isset($desc['field']['langue_choisie'])) { |
|
| 257 | - $champs['langue_choisie'] = 'oui'; |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - } elseif (isset($desc['field']['lang']) && isset($desc['field']['langue_choisie'])) { |
|
| 261 | - $champs['lang'] = ($lang_rub ?: $GLOBALS['meta']['langue_site']); |
|
| 262 | - $champs['langue_choisie'] = 'non'; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - if (isset($desc['field']['statut'])) { |
|
| 266 | - if (isset($desc['statut_textes_instituer'])) { |
|
| 267 | - $cles_statut = array_keys($desc['statut_textes_instituer']); |
|
| 268 | - $champs['statut'] = reset($cles_statut); |
|
| 269 | - } else { |
|
| 270 | - $champs['statut'] = 'prepa'; |
|
| 271 | - } |
|
| 272 | - } |
|
| 273 | - |
|
| 274 | - |
|
| 275 | - if (isset($desc['date']) && ($d = $desc['date']) || isset($desc['field'][$d = 'date'])) { |
|
| 276 | - $champs[$d] = date('Y-m-d H:i:s'); |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - if ($set) { |
|
| 280 | - $champs = array_merge($champs, $set); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - // Envoyer aux plugins |
|
| 284 | - $champs = pipeline( |
|
| 285 | - 'pre_insertion', |
|
| 286 | - [ |
|
| 287 | - 'args' => [ |
|
| 288 | - 'table' => $table_sql, |
|
| 289 | - 'id_parent' => $id_parent, |
|
| 290 | - ], |
|
| 291 | - 'data' => $champs |
|
| 292 | - ] |
|
| 293 | - ); |
|
| 294 | - |
|
| 295 | - $id = sql_insertq($table_sql, $champs); |
|
| 296 | - |
|
| 297 | - if ($id) { |
|
| 298 | - // controler si le serveur n'a pas renvoye une erreur |
|
| 299 | - // et associer l'auteur sinon |
|
| 300 | - // si la table n'a pas deja un champ id_auteur |
|
| 301 | - // et si le form n'a pas poste un id_auteur (meme vide, ce qui sert a annuler cette auto association) |
|
| 302 | - if ($id > 0 && !isset($desc['field']['id_auteur'])) { |
|
| 303 | - $id_auteur = ((is_null(_request('id_auteur')) && isset($GLOBALS['visiteur_session']['id_auteur'])) |
|
| 304 | - ? $GLOBALS['visiteur_session']['id_auteur'] |
|
| 305 | - : _request('id_auteur')); |
|
| 306 | - if ($id_auteur) { |
|
| 307 | - include_spip('action/editer_auteur'); |
|
| 308 | - auteur_associer($id_auteur, [$objet => $id]); |
|
| 309 | - } |
|
| 310 | - } |
|
| 311 | - |
|
| 312 | - pipeline( |
|
| 313 | - 'post_insertion', |
|
| 314 | - [ |
|
| 315 | - 'args' => [ |
|
| 316 | - 'table' => $table_sql, |
|
| 317 | - 'id_parent' => $id_parent, |
|
| 318 | - 'id_objet' => $id, |
|
| 319 | - ], |
|
| 320 | - 'data' => $champs |
|
| 321 | - ] |
|
| 322 | - ); |
|
| 323 | - } |
|
| 324 | - |
|
| 325 | - // Appeler une notification |
|
| 326 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 327 | - $notifications( |
|
| 328 | - "{$objet}_inserer", |
|
| 329 | - $id, |
|
| 330 | - [ |
|
| 331 | - 'id_parent' => $id_parent, |
|
| 332 | - 'champs' => $champs, |
|
| 333 | - ] |
|
| 334 | - ); |
|
| 335 | - $notifications( |
|
| 336 | - 'objet_inserer', |
|
| 337 | - $id, |
|
| 338 | - [ |
|
| 339 | - 'objet' => $objet, |
|
| 340 | - 'id_objet' => $id, |
|
| 341 | - 'id_parent' => $id_parent, |
|
| 342 | - 'champs' => $champs, |
|
| 343 | - ] |
|
| 344 | - ); |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - return $id; |
|
| 200 | + $d = null; |
|
| 201 | + if (($t = objet_type($objet)) !== $objet) { |
|
| 202 | + spip_logger('editer')->notice("objet_inserer: appel avec type $objet invalide au lieu de $t"); |
|
| 203 | + $objet = $t; |
|
| 204 | + } |
|
| 205 | + if ( |
|
| 206 | + include_spip('action/editer_' . $objet) |
|
| 207 | + && function_exists($inserer = $objet . '_inserer') |
|
| 208 | + ) { |
|
| 209 | + return $inserer($id_parent, $set); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + $table_sql = table_objet_sql($objet); |
|
| 213 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 214 | + $desc = $trouver_table($table_sql); |
|
| 215 | + if (!$desc || !isset($desc['field'])) { |
|
| 216 | + return 0; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + $lang_rub = ''; |
|
| 220 | + $champs = []; |
|
| 221 | + if (isset($desc['field']['id_rubrique'])) { |
|
| 222 | + // Si id_rubrique vaut 0 ou n'est pas definie, creer l'objet |
|
| 223 | + // dans la premiere rubrique racine |
|
| 224 | + if (!$id_rubrique = (int) $id_parent) { |
|
| 225 | + $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 226 | + $id_rubrique = $row['id_rubrique']; |
|
| 227 | + } else { |
|
| 228 | + $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + $champs['id_rubrique'] = $id_rubrique; |
|
| 232 | + if (isset($desc['field']['id_secteur'])) { |
|
| 233 | + $champs['id_secteur'] = $row['id_secteur']; |
|
| 234 | + } |
|
| 235 | + $lang_rub = $row['lang']; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + // La langue a la creation : si les liens de traduction sont autorises |
|
| 239 | + // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 240 | + // ou a defaut celle de la rubrique |
|
| 241 | + // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 242 | + if ( |
|
| 243 | + isset($desc['field']['lang']) && !empty($GLOBALS['meta']['multi_objets']) && in_array( |
|
| 244 | + $table_sql, |
|
| 245 | + explode(',', (string) $GLOBALS['meta']['multi_objets']) |
|
| 246 | + ) |
|
| 247 | + ) { |
|
| 248 | + lang_select($GLOBALS['visiteur_session']['lang'] ?? ''); |
|
| 249 | + if ( |
|
| 250 | + in_array( |
|
| 251 | + $GLOBALS['spip_lang'], |
|
| 252 | + explode(',', (string) $GLOBALS['meta']['langues_multilingue']) |
|
| 253 | + ) |
|
| 254 | + ) { |
|
| 255 | + $champs['lang'] = $GLOBALS['spip_lang']; |
|
| 256 | + if (isset($desc['field']['langue_choisie'])) { |
|
| 257 | + $champs['langue_choisie'] = 'oui'; |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + } elseif (isset($desc['field']['lang']) && isset($desc['field']['langue_choisie'])) { |
|
| 261 | + $champs['lang'] = ($lang_rub ?: $GLOBALS['meta']['langue_site']); |
|
| 262 | + $champs['langue_choisie'] = 'non'; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + if (isset($desc['field']['statut'])) { |
|
| 266 | + if (isset($desc['statut_textes_instituer'])) { |
|
| 267 | + $cles_statut = array_keys($desc['statut_textes_instituer']); |
|
| 268 | + $champs['statut'] = reset($cles_statut); |
|
| 269 | + } else { |
|
| 270 | + $champs['statut'] = 'prepa'; |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + |
|
| 274 | + |
|
| 275 | + if (isset($desc['date']) && ($d = $desc['date']) || isset($desc['field'][$d = 'date'])) { |
|
| 276 | + $champs[$d] = date('Y-m-d H:i:s'); |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + if ($set) { |
|
| 280 | + $champs = array_merge($champs, $set); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + // Envoyer aux plugins |
|
| 284 | + $champs = pipeline( |
|
| 285 | + 'pre_insertion', |
|
| 286 | + [ |
|
| 287 | + 'args' => [ |
|
| 288 | + 'table' => $table_sql, |
|
| 289 | + 'id_parent' => $id_parent, |
|
| 290 | + ], |
|
| 291 | + 'data' => $champs |
|
| 292 | + ] |
|
| 293 | + ); |
|
| 294 | + |
|
| 295 | + $id = sql_insertq($table_sql, $champs); |
|
| 296 | + |
|
| 297 | + if ($id) { |
|
| 298 | + // controler si le serveur n'a pas renvoye une erreur |
|
| 299 | + // et associer l'auteur sinon |
|
| 300 | + // si la table n'a pas deja un champ id_auteur |
|
| 301 | + // et si le form n'a pas poste un id_auteur (meme vide, ce qui sert a annuler cette auto association) |
|
| 302 | + if ($id > 0 && !isset($desc['field']['id_auteur'])) { |
|
| 303 | + $id_auteur = ((is_null(_request('id_auteur')) && isset($GLOBALS['visiteur_session']['id_auteur'])) |
|
| 304 | + ? $GLOBALS['visiteur_session']['id_auteur'] |
|
| 305 | + : _request('id_auteur')); |
|
| 306 | + if ($id_auteur) { |
|
| 307 | + include_spip('action/editer_auteur'); |
|
| 308 | + auteur_associer($id_auteur, [$objet => $id]); |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | + |
|
| 312 | + pipeline( |
|
| 313 | + 'post_insertion', |
|
| 314 | + [ |
|
| 315 | + 'args' => [ |
|
| 316 | + 'table' => $table_sql, |
|
| 317 | + 'id_parent' => $id_parent, |
|
| 318 | + 'id_objet' => $id, |
|
| 319 | + ], |
|
| 320 | + 'data' => $champs |
|
| 321 | + ] |
|
| 322 | + ); |
|
| 323 | + } |
|
| 324 | + |
|
| 325 | + // Appeler une notification |
|
| 326 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 327 | + $notifications( |
|
| 328 | + "{$objet}_inserer", |
|
| 329 | + $id, |
|
| 330 | + [ |
|
| 331 | + 'id_parent' => $id_parent, |
|
| 332 | + 'champs' => $champs, |
|
| 333 | + ] |
|
| 334 | + ); |
|
| 335 | + $notifications( |
|
| 336 | + 'objet_inserer', |
|
| 337 | + $id, |
|
| 338 | + [ |
|
| 339 | + 'objet' => $objet, |
|
| 340 | + 'id_objet' => $id, |
|
| 341 | + 'id_parent' => $id_parent, |
|
| 342 | + 'champs' => $champs, |
|
| 343 | + ] |
|
| 344 | + ); |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + return $id; |
|
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
@@ -361,139 +361,139 @@ discard block |
||
| 361 | 361 | * @return string |
| 362 | 362 | */ |
| 363 | 363 | function objet_instituer($objet, $id, $c, $calcul_rub = true) { |
| 364 | - if (($t = objet_type($objet)) !== $objet) { |
|
| 365 | - spip_logger('editer')->notice("objet_instituer: appel avec type $objet invalide au lieu de $t"); |
|
| 366 | - $objet = $t; |
|
| 367 | - } |
|
| 368 | - if ( |
|
| 369 | - include_spip('action/editer_' . $objet) && function_exists($instituer = $objet . '_instituer') |
|
| 370 | - ) { |
|
| 371 | - return $instituer($id, $c, $calcul_rub); |
|
| 372 | - } |
|
| 373 | - |
|
| 374 | - $table_sql = table_objet_sql($objet); |
|
| 375 | - $table_objet = table_objet($objet); |
|
| 376 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 377 | - $desc = $trouver_table($table_sql); |
|
| 378 | - if (!$desc || !isset($desc['field'])) { |
|
| 379 | - return _L("Impossible d'instituer $objet : non connu en base"); |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - include_spip('inc/autoriser'); |
|
| 383 | - include_spip('inc/rubriques'); |
|
| 384 | - include_spip('inc/modifier'); |
|
| 385 | - |
|
| 386 | - $sel = []; |
|
| 387 | - $sel[] = (isset($desc['field']['statut']) ? 'statut' : "'' as statut"); |
|
| 388 | - |
|
| 389 | - $champ_date = ''; |
|
| 390 | - if (isset($desc['date']) && $desc['date']) { |
|
| 391 | - $champ_date = $desc['date']; |
|
| 392 | - } elseif (isset($desc['field']['date'])) { |
|
| 393 | - $champ_date = 'date'; |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - $sel[] = ($champ_date ? "$champ_date as date" : "'' as date"); |
|
| 397 | - $sel[] = (isset($desc['field']['id_rubrique']) ? 'id_rubrique' : '0 as id_rubrique'); |
|
| 398 | - |
|
| 399 | - $row = sql_fetsel($sel, $table_sql, id_table_objet($objet) . '=' . (int) $id); |
|
| 400 | - |
|
| 401 | - $id_rubrique = $row['id_rubrique']; |
|
| 402 | - $statut_ancien = $statut = $row['statut']; |
|
| 403 | - $date_ancienne = $date = $row['date']; |
|
| 404 | - $champs = []; |
|
| 405 | - |
|
| 406 | - $d = ($date && isset($c[$champ_date])) ? $c[$champ_date] : null; |
|
| 407 | - $s = (isset($desc['field']['statut']) && isset($c['statut'])) ? $c['statut'] : $statut; |
|
| 408 | - |
|
| 409 | - // cf autorisations dans inc/instituer_objet |
|
| 410 | - if ($s != $statut || $d && $d != $date) { |
|
| 411 | - if ( |
|
| 412 | - $id_rubrique ? |
|
| 413 | - autoriser('publierdans', 'rubrique', $id_rubrique) |
|
| 414 | - : |
|
| 415 | - autoriser('instituer', $objet, $id, null, ['statut' => $s]) |
|
| 416 | - ) { |
|
| 417 | - $statut = $champs['statut'] = $s; |
|
| 418 | - } else { |
|
| 419 | - if ($s != 'publie' && autoriser('modifier', $objet, $id)) { |
|
| 420 | - $statut = $champs['statut'] = $s; |
|
| 421 | - } else { |
|
| 422 | - spip_logger('editer')->notice("editer_objet $objet #$id refus " . json_encode($c, JSON_THROW_ON_ERROR)); |
|
| 423 | - } |
|
| 424 | - } |
|
| 425 | - |
|
| 426 | - // En cas de publication, fixer la date a "maintenant" |
|
| 427 | - // sauf si $c commande autre chose |
|
| 428 | - // ou si l'objet est deja date dans le futur |
|
| 429 | - // En cas de proposition d'un objet (mais pas depublication), idem |
|
| 430 | - if ( |
|
| 431 | - $champ_date |
|
| 432 | - && ( |
|
| 433 | - $champs['statut'] == 'publie' |
|
| 434 | - || $champs['statut'] == 'prop' && !in_array($statut_ancien, ['publie', 'prop']) |
|
| 435 | - || $d |
|
| 436 | - ) |
|
| 437 | - ) { |
|
| 438 | - $date = ($d || strtotime((string) ($d = $date)) > time()) ? $d : date('Y-m-d H:i:s'); |
|
| 439 | - $champs[$champ_date] = $date; |
|
| 440 | - } |
|
| 441 | - } |
|
| 442 | - |
|
| 443 | - // Verifier que la rubrique demandee existe et est differente |
|
| 444 | - // de la rubrique actuelle |
|
| 445 | - if ( |
|
| 446 | - $id_rubrique |
|
| 447 | - && isset($c['id_parent']) |
|
| 448 | - && ($id_parent = $c['id_parent']) |
|
| 449 | - && $id_parent != $id_rubrique |
|
| 450 | - && sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . (int) $id_parent) |
|
| 451 | - ) { |
|
| 452 | - $champs['id_rubrique'] = $id_parent; |
|
| 453 | - |
|
| 454 | - // si l'objet etait publie |
|
| 455 | - // et que le demandeur n'est pas admin de la rubrique |
|
| 456 | - // repasser l'objet en statut 'propose'. |
|
| 457 | - if ( |
|
| 458 | - $statut == 'publie' |
|
| 459 | - && !autoriser('publierdans', 'rubrique', $id_rubrique) |
|
| 460 | - ) { |
|
| 461 | - $champs['statut'] = 'prop'; |
|
| 462 | - } |
|
| 463 | - } |
|
| 464 | - |
|
| 465 | - |
|
| 466 | - // Envoyer aux plugins |
|
| 467 | - $champs = pipeline( |
|
| 468 | - 'pre_edition', |
|
| 469 | - [ |
|
| 470 | - 'args' => [ |
|
| 471 | - 'table' => $table_sql, |
|
| 472 | - 'table_objet' => $table_objet, |
|
| 473 | - 'spip_table_objet' => $table_sql, |
|
| 474 | - 'objet' => $objet, |
|
| 475 | - 'id_objet' => $id, |
|
| 476 | - 'action' => 'instituer', |
|
| 477 | - 'statut_ancien' => $statut_ancien, |
|
| 478 | - 'date_ancienne' => $date_ancienne, |
|
| 479 | - 'id_parent_ancien' => $id_rubrique, |
|
| 480 | - ], |
|
| 481 | - 'data' => $champs |
|
| 482 | - ] |
|
| 483 | - ); |
|
| 484 | - |
|
| 485 | - if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 486 | - return ''; |
|
| 487 | - } |
|
| 488 | - |
|
| 489 | - // Envoyer les modifs. |
|
| 490 | - objet_editer_heritage($objet, $id, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 491 | - |
|
| 492 | - // Invalider les caches |
|
| 493 | - include_spip('inc/invalideur'); |
|
| 494 | - suivre_invalideur("id='$objet/$id'"); |
|
| 495 | - |
|
| 496 | - /* |
|
| 364 | + if (($t = objet_type($objet)) !== $objet) { |
|
| 365 | + spip_logger('editer')->notice("objet_instituer: appel avec type $objet invalide au lieu de $t"); |
|
| 366 | + $objet = $t; |
|
| 367 | + } |
|
| 368 | + if ( |
|
| 369 | + include_spip('action/editer_' . $objet) && function_exists($instituer = $objet . '_instituer') |
|
| 370 | + ) { |
|
| 371 | + return $instituer($id, $c, $calcul_rub); |
|
| 372 | + } |
|
| 373 | + |
|
| 374 | + $table_sql = table_objet_sql($objet); |
|
| 375 | + $table_objet = table_objet($objet); |
|
| 376 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 377 | + $desc = $trouver_table($table_sql); |
|
| 378 | + if (!$desc || !isset($desc['field'])) { |
|
| 379 | + return _L("Impossible d'instituer $objet : non connu en base"); |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + include_spip('inc/autoriser'); |
|
| 383 | + include_spip('inc/rubriques'); |
|
| 384 | + include_spip('inc/modifier'); |
|
| 385 | + |
|
| 386 | + $sel = []; |
|
| 387 | + $sel[] = (isset($desc['field']['statut']) ? 'statut' : "'' as statut"); |
|
| 388 | + |
|
| 389 | + $champ_date = ''; |
|
| 390 | + if (isset($desc['date']) && $desc['date']) { |
|
| 391 | + $champ_date = $desc['date']; |
|
| 392 | + } elseif (isset($desc['field']['date'])) { |
|
| 393 | + $champ_date = 'date'; |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + $sel[] = ($champ_date ? "$champ_date as date" : "'' as date"); |
|
| 397 | + $sel[] = (isset($desc['field']['id_rubrique']) ? 'id_rubrique' : '0 as id_rubrique'); |
|
| 398 | + |
|
| 399 | + $row = sql_fetsel($sel, $table_sql, id_table_objet($objet) . '=' . (int) $id); |
|
| 400 | + |
|
| 401 | + $id_rubrique = $row['id_rubrique']; |
|
| 402 | + $statut_ancien = $statut = $row['statut']; |
|
| 403 | + $date_ancienne = $date = $row['date']; |
|
| 404 | + $champs = []; |
|
| 405 | + |
|
| 406 | + $d = ($date && isset($c[$champ_date])) ? $c[$champ_date] : null; |
|
| 407 | + $s = (isset($desc['field']['statut']) && isset($c['statut'])) ? $c['statut'] : $statut; |
|
| 408 | + |
|
| 409 | + // cf autorisations dans inc/instituer_objet |
|
| 410 | + if ($s != $statut || $d && $d != $date) { |
|
| 411 | + if ( |
|
| 412 | + $id_rubrique ? |
|
| 413 | + autoriser('publierdans', 'rubrique', $id_rubrique) |
|
| 414 | + : |
|
| 415 | + autoriser('instituer', $objet, $id, null, ['statut' => $s]) |
|
| 416 | + ) { |
|
| 417 | + $statut = $champs['statut'] = $s; |
|
| 418 | + } else { |
|
| 419 | + if ($s != 'publie' && autoriser('modifier', $objet, $id)) { |
|
| 420 | + $statut = $champs['statut'] = $s; |
|
| 421 | + } else { |
|
| 422 | + spip_logger('editer')->notice("editer_objet $objet #$id refus " . json_encode($c, JSON_THROW_ON_ERROR)); |
|
| 423 | + } |
|
| 424 | + } |
|
| 425 | + |
|
| 426 | + // En cas de publication, fixer la date a "maintenant" |
|
| 427 | + // sauf si $c commande autre chose |
|
| 428 | + // ou si l'objet est deja date dans le futur |
|
| 429 | + // En cas de proposition d'un objet (mais pas depublication), idem |
|
| 430 | + if ( |
|
| 431 | + $champ_date |
|
| 432 | + && ( |
|
| 433 | + $champs['statut'] == 'publie' |
|
| 434 | + || $champs['statut'] == 'prop' && !in_array($statut_ancien, ['publie', 'prop']) |
|
| 435 | + || $d |
|
| 436 | + ) |
|
| 437 | + ) { |
|
| 438 | + $date = ($d || strtotime((string) ($d = $date)) > time()) ? $d : date('Y-m-d H:i:s'); |
|
| 439 | + $champs[$champ_date] = $date; |
|
| 440 | + } |
|
| 441 | + } |
|
| 442 | + |
|
| 443 | + // Verifier que la rubrique demandee existe et est differente |
|
| 444 | + // de la rubrique actuelle |
|
| 445 | + if ( |
|
| 446 | + $id_rubrique |
|
| 447 | + && isset($c['id_parent']) |
|
| 448 | + && ($id_parent = $c['id_parent']) |
|
| 449 | + && $id_parent != $id_rubrique |
|
| 450 | + && sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . (int) $id_parent) |
|
| 451 | + ) { |
|
| 452 | + $champs['id_rubrique'] = $id_parent; |
|
| 453 | + |
|
| 454 | + // si l'objet etait publie |
|
| 455 | + // et que le demandeur n'est pas admin de la rubrique |
|
| 456 | + // repasser l'objet en statut 'propose'. |
|
| 457 | + if ( |
|
| 458 | + $statut == 'publie' |
|
| 459 | + && !autoriser('publierdans', 'rubrique', $id_rubrique) |
|
| 460 | + ) { |
|
| 461 | + $champs['statut'] = 'prop'; |
|
| 462 | + } |
|
| 463 | + } |
|
| 464 | + |
|
| 465 | + |
|
| 466 | + // Envoyer aux plugins |
|
| 467 | + $champs = pipeline( |
|
| 468 | + 'pre_edition', |
|
| 469 | + [ |
|
| 470 | + 'args' => [ |
|
| 471 | + 'table' => $table_sql, |
|
| 472 | + 'table_objet' => $table_objet, |
|
| 473 | + 'spip_table_objet' => $table_sql, |
|
| 474 | + 'objet' => $objet, |
|
| 475 | + 'id_objet' => $id, |
|
| 476 | + 'action' => 'instituer', |
|
| 477 | + 'statut_ancien' => $statut_ancien, |
|
| 478 | + 'date_ancienne' => $date_ancienne, |
|
| 479 | + 'id_parent_ancien' => $id_rubrique, |
|
| 480 | + ], |
|
| 481 | + 'data' => $champs |
|
| 482 | + ] |
|
| 483 | + ); |
|
| 484 | + |
|
| 485 | + if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 486 | + return ''; |
|
| 487 | + } |
|
| 488 | + |
|
| 489 | + // Envoyer les modifs. |
|
| 490 | + objet_editer_heritage($objet, $id, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 491 | + |
|
| 492 | + // Invalider les caches |
|
| 493 | + include_spip('inc/invalideur'); |
|
| 494 | + suivre_invalideur("id='$objet/$id'"); |
|
| 495 | + |
|
| 496 | + /* |
|
| 497 | 497 | if ($date) { |
| 498 | 498 | $t = strtotime($date); |
| 499 | 499 | $p = @$GLOBALS['meta']['date_prochain_postdate']; |
@@ -502,63 +502,63 @@ discard block |
||
| 502 | 502 | } |
| 503 | 503 | }*/ |
| 504 | 504 | |
| 505 | - // Pipeline |
|
| 506 | - pipeline( |
|
| 507 | - 'post_edition', |
|
| 508 | - [ |
|
| 509 | - 'args' => [ |
|
| 510 | - 'table' => $table_sql, |
|
| 511 | - 'table_objet' => $table_objet, |
|
| 512 | - 'spip_table_objet' => $table_sql, |
|
| 513 | - 'objet' => $objet, |
|
| 514 | - 'id_objet' => $id, |
|
| 515 | - 'action' => 'instituer', |
|
| 516 | - 'statut_ancien' => $statut_ancien, |
|
| 517 | - 'date_ancienne' => $date_ancienne, |
|
| 518 | - 'id_parent_ancien' => $id_rubrique, |
|
| 519 | - ], |
|
| 520 | - 'data' => $champs |
|
| 521 | - ] |
|
| 522 | - ); |
|
| 523 | - |
|
| 524 | - // Notifications |
|
| 525 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 526 | - $notifications( |
|
| 527 | - "{$objet}_instituer", |
|
| 528 | - $id, |
|
| 529 | - [ |
|
| 530 | - 'statut' => $statut, |
|
| 531 | - 'statut_ancien' => $statut_ancien, |
|
| 532 | - 'date' => $date, |
|
| 533 | - 'date_ancienne' => $date_ancienne, |
|
| 534 | - 'id_parent_ancien' => $id_rubrique, |
|
| 535 | - 'champs' => $champs, |
|
| 536 | - ] |
|
| 537 | - ); |
|
| 538 | - $notifications( |
|
| 539 | - 'objet_instituer', |
|
| 540 | - $id, |
|
| 541 | - [ |
|
| 542 | - 'objet' => $objet, |
|
| 543 | - 'id_objet' => $id, |
|
| 544 | - 'statut' => $statut, |
|
| 545 | - 'statut_ancien' => $statut_ancien, |
|
| 546 | - 'date' => $date, |
|
| 547 | - 'date_ancienne' => $date_ancienne, |
|
| 548 | - 'id_parent_ancien' => $id_rubrique, |
|
| 549 | - 'champs' => $champs, |
|
| 550 | - ] |
|
| 551 | - ); |
|
| 552 | - |
|
| 553 | - // Rétro-compat |
|
| 554 | - $notifications( |
|
| 555 | - "instituer$objet", |
|
| 556 | - $id, |
|
| 557 | - ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 558 | - ); |
|
| 559 | - } |
|
| 560 | - |
|
| 561 | - return ''; // pas d'erreur |
|
| 505 | + // Pipeline |
|
| 506 | + pipeline( |
|
| 507 | + 'post_edition', |
|
| 508 | + [ |
|
| 509 | + 'args' => [ |
|
| 510 | + 'table' => $table_sql, |
|
| 511 | + 'table_objet' => $table_objet, |
|
| 512 | + 'spip_table_objet' => $table_sql, |
|
| 513 | + 'objet' => $objet, |
|
| 514 | + 'id_objet' => $id, |
|
| 515 | + 'action' => 'instituer', |
|
| 516 | + 'statut_ancien' => $statut_ancien, |
|
| 517 | + 'date_ancienne' => $date_ancienne, |
|
| 518 | + 'id_parent_ancien' => $id_rubrique, |
|
| 519 | + ], |
|
| 520 | + 'data' => $champs |
|
| 521 | + ] |
|
| 522 | + ); |
|
| 523 | + |
|
| 524 | + // Notifications |
|
| 525 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 526 | + $notifications( |
|
| 527 | + "{$objet}_instituer", |
|
| 528 | + $id, |
|
| 529 | + [ |
|
| 530 | + 'statut' => $statut, |
|
| 531 | + 'statut_ancien' => $statut_ancien, |
|
| 532 | + 'date' => $date, |
|
| 533 | + 'date_ancienne' => $date_ancienne, |
|
| 534 | + 'id_parent_ancien' => $id_rubrique, |
|
| 535 | + 'champs' => $champs, |
|
| 536 | + ] |
|
| 537 | + ); |
|
| 538 | + $notifications( |
|
| 539 | + 'objet_instituer', |
|
| 540 | + $id, |
|
| 541 | + [ |
|
| 542 | + 'objet' => $objet, |
|
| 543 | + 'id_objet' => $id, |
|
| 544 | + 'statut' => $statut, |
|
| 545 | + 'statut_ancien' => $statut_ancien, |
|
| 546 | + 'date' => $date, |
|
| 547 | + 'date_ancienne' => $date_ancienne, |
|
| 548 | + 'id_parent_ancien' => $id_rubrique, |
|
| 549 | + 'champs' => $champs, |
|
| 550 | + ] |
|
| 551 | + ); |
|
| 552 | + |
|
| 553 | + // Rétro-compat |
|
| 554 | + $notifications( |
|
| 555 | + "instituer$objet", |
|
| 556 | + $id, |
|
| 557 | + ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 558 | + ); |
|
| 559 | + } |
|
| 560 | + |
|
| 561 | + return ''; // pas d'erreur |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | /** |
@@ -573,51 +573,51 @@ discard block |
||
| 573 | 573 | * @return void |
| 574 | 574 | */ |
| 575 | 575 | function objet_editer_heritage($objet, $id, $id_rubrique, $statut, $champs, $cond = true) { |
| 576 | - $table_sql = table_objet_sql($objet); |
|
| 577 | - $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 578 | - $desc = $trouver_table($table_sql); |
|
| 579 | - |
|
| 580 | - // Si on deplace l'objet |
|
| 581 | - // changer aussi son secteur et sa langue (si heritee) |
|
| 582 | - if (isset($champs['id_rubrique'])) { |
|
| 583 | - $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 584 | - $langue = $row_rub['lang']; |
|
| 585 | - |
|
| 586 | - if (isset($desc['field']['id_secteur'])) { |
|
| 587 | - $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 588 | - } |
|
| 589 | - |
|
| 590 | - if ( |
|
| 591 | - isset($desc['field']['lang']) |
|
| 592 | - && isset($desc['field']['langue_choisie']) |
|
| 593 | - && sql_fetsel( |
|
| 594 | - '1', |
|
| 595 | - $table_sql, |
|
| 596 | - id_table_objet($objet) . '=' . (int) $id . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 597 | - ) |
|
| 598 | - ) { |
|
| 599 | - $champs['lang'] = $langue; |
|
| 600 | - } |
|
| 601 | - } |
|
| 602 | - |
|
| 603 | - if (!$champs) { |
|
| 604 | - return; |
|
| 605 | - } |
|
| 606 | - sql_updateq($table_sql, $champs, id_table_objet($objet) . '=' . (int) $id); |
|
| 607 | - |
|
| 608 | - // Changer le statut des rubriques concernees |
|
| 609 | - if ($cond) { |
|
| 610 | - include_spip('inc/rubriques'); |
|
| 611 | - //$postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false; |
|
| 612 | - $postdate = false; |
|
| 613 | - // On rajoute les infos de l'objet |
|
| 614 | - $infos = [ |
|
| 615 | - 'objet' => $objet, |
|
| 616 | - 'id_objet' => $id, |
|
| 617 | - 'statut_ancien' => $statut, |
|
| 618 | - ]; |
|
| 619 | - calculer_rubriques_if($id_rubrique, $champs, $infos, $postdate); |
|
| 620 | - } |
|
| 576 | + $table_sql = table_objet_sql($objet); |
|
| 577 | + $trouver_table = charger_fonction('trouver_table', 'base'); |
|
| 578 | + $desc = $trouver_table($table_sql); |
|
| 579 | + |
|
| 580 | + // Si on deplace l'objet |
|
| 581 | + // changer aussi son secteur et sa langue (si heritee) |
|
| 582 | + if (isset($champs['id_rubrique'])) { |
|
| 583 | + $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 584 | + $langue = $row_rub['lang']; |
|
| 585 | + |
|
| 586 | + if (isset($desc['field']['id_secteur'])) { |
|
| 587 | + $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 588 | + } |
|
| 589 | + |
|
| 590 | + if ( |
|
| 591 | + isset($desc['field']['lang']) |
|
| 592 | + && isset($desc['field']['langue_choisie']) |
|
| 593 | + && sql_fetsel( |
|
| 594 | + '1', |
|
| 595 | + $table_sql, |
|
| 596 | + id_table_objet($objet) . '=' . (int) $id . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 597 | + ) |
|
| 598 | + ) { |
|
| 599 | + $champs['lang'] = $langue; |
|
| 600 | + } |
|
| 601 | + } |
|
| 602 | + |
|
| 603 | + if (!$champs) { |
|
| 604 | + return; |
|
| 605 | + } |
|
| 606 | + sql_updateq($table_sql, $champs, id_table_objet($objet) . '=' . (int) $id); |
|
| 607 | + |
|
| 608 | + // Changer le statut des rubriques concernees |
|
| 609 | + if ($cond) { |
|
| 610 | + include_spip('inc/rubriques'); |
|
| 611 | + //$postdate = ($GLOBALS['meta']["post_dates"] == "non" AND isset($champs['date']) AND (strtotime($champs['date']) < time()))?$champs['date']:false; |
|
| 612 | + $postdate = false; |
|
| 613 | + // On rajoute les infos de l'objet |
|
| 614 | + $infos = [ |
|
| 615 | + 'objet' => $objet, |
|
| 616 | + 'id_objet' => $id, |
|
| 617 | + 'statut_ancien' => $statut, |
|
| 618 | + ]; |
|
| 619 | + calculer_rubriques_if($id_rubrique, $champs, $infos, $postdate); |
|
| 620 | + } |
|
| 621 | 621 | } |
| 622 | 622 | |
| 623 | 623 | |
@@ -646,71 +646,71 @@ discard block |
||
| 646 | 646 | * string|int : valeur du champ demande pour l'objet demande |
| 647 | 647 | */ |
| 648 | 648 | function objet_lire($objet, $valeur_id, $options = []) { |
| 649 | - if (($t = objet_type($objet)) !== $objet) { |
|
| 650 | - spip_logger('editer')->notice("objet_lire: appel avec type $objet invalide au lieu de $t"); |
|
| 651 | - $objet = $t; |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - // tableau du cache des descriptions et des id d'objet (au sens id_xxx). |
|
| 655 | - // Les tableaux sont toujours indexés par le trio [objet][cle][valeur_cle] |
|
| 656 | - static $descriptions = []; |
|
| 657 | - |
|
| 658 | - // On détermine le nom du champ id de la table. |
|
| 659 | - include_spip('base/objets'); |
|
| 660 | - $primary = id_table_objet($objet); |
|
| 661 | - |
|
| 662 | - // On détermine l'id à utiliser. |
|
| 663 | - $champ_id = (empty($options['champ_id']) ? $primary : $options['champ_id']); |
|
| 664 | - |
|
| 665 | - // Si l'objet n'a pas encore été stocké, il faut récupérer sa description complète. |
|
| 666 | - if ( |
|
| 667 | - !isset($descriptions[$objet][$champ_id][$valeur_id]) |
|
| 668 | - || isset($options['force']) && $options['force'] |
|
| 669 | - ) { |
|
| 670 | - // Il est possible pour un type d'objet de fournir une fonction de lecture de tous les champs d'un objet. |
|
| 671 | - if ( |
|
| 672 | - include_spip('action/editer_' . $objet) |
|
| 673 | - && function_exists($lire = "{$objet}_lire_champs") |
|
| 674 | - ) { |
|
| 675 | - $valeurs = $lire($objet, $valeur_id, $champ_id); |
|
| 676 | - } else { |
|
| 677 | - // On récupère la table SQL à partir du type d'objet. |
|
| 678 | - $table = table_objet_sql($objet); |
|
| 679 | - |
|
| 680 | - // La condition est appliquée sur le champ désigné par l'utilisateur. |
|
| 681 | - $where = [ |
|
| 682 | - $champ_id . '=' . sql_quote($valeur_id) |
|
| 683 | - ]; |
|
| 684 | - |
|
| 685 | - // Acquisition de tous les champs de l'objet : si l'accès SQL retourne une erreur on renvoie un tableau vide. |
|
| 686 | - $valeurs = sql_fetsel('*', $table, $where); |
|
| 687 | - } |
|
| 688 | - |
|
| 689 | - if (!$valeurs) { |
|
| 690 | - $valeurs = false; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - $descriptions[$objet][$champ_id][$valeur_id] = $valeurs; |
|
| 694 | - |
|
| 695 | - if ($champ_id !== $primary && isset($valeurs[$primary])) { |
|
| 696 | - $descriptions[$objet][$primary][$valeurs[$primary]] = $valeurs; |
|
| 697 | - $descriptions[$objet][$champ_id][$valeur_id] = &$descriptions[$objet][$primary][$valeurs[$primary]]; |
|
| 698 | - } |
|
| 699 | - } |
|
| 700 | - |
|
| 701 | - $retour = $descriptions[$objet][$champ_id][$valeur_id]; |
|
| 702 | - |
|
| 703 | - // On ne retourne maintenant que les champs demandés. |
|
| 704 | - // - on détermine les informations à renvoyer. |
|
| 705 | - if ($retour && !empty($options['champs'])) { |
|
| 706 | - $champs = $options['champs']; |
|
| 707 | - // Extraction des seules informations demandées. |
|
| 708 | - // -- si on demande une information unique on renvoie la valeur simple, sinon on renvoie un tableau. |
|
| 709 | - // -- si une information n'est pas un champ valide elle n'est pas renvoyée sans renvoyer d'erreur. |
|
| 710 | - $retour = is_array($champs) |
|
| 711 | - ? array_intersect_key($retour, array_flip($champs)) |
|
| 712 | - : $retour[$champs] ?? false; |
|
| 713 | - } |
|
| 714 | - |
|
| 715 | - return $retour; |
|
| 649 | + if (($t = objet_type($objet)) !== $objet) { |
|
| 650 | + spip_logger('editer')->notice("objet_lire: appel avec type $objet invalide au lieu de $t"); |
|
| 651 | + $objet = $t; |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + // tableau du cache des descriptions et des id d'objet (au sens id_xxx). |
|
| 655 | + // Les tableaux sont toujours indexés par le trio [objet][cle][valeur_cle] |
|
| 656 | + static $descriptions = []; |
|
| 657 | + |
|
| 658 | + // On détermine le nom du champ id de la table. |
|
| 659 | + include_spip('base/objets'); |
|
| 660 | + $primary = id_table_objet($objet); |
|
| 661 | + |
|
| 662 | + // On détermine l'id à utiliser. |
|
| 663 | + $champ_id = (empty($options['champ_id']) ? $primary : $options['champ_id']); |
|
| 664 | + |
|
| 665 | + // Si l'objet n'a pas encore été stocké, il faut récupérer sa description complète. |
|
| 666 | + if ( |
|
| 667 | + !isset($descriptions[$objet][$champ_id][$valeur_id]) |
|
| 668 | + || isset($options['force']) && $options['force'] |
|
| 669 | + ) { |
|
| 670 | + // Il est possible pour un type d'objet de fournir une fonction de lecture de tous les champs d'un objet. |
|
| 671 | + if ( |
|
| 672 | + include_spip('action/editer_' . $objet) |
|
| 673 | + && function_exists($lire = "{$objet}_lire_champs") |
|
| 674 | + ) { |
|
| 675 | + $valeurs = $lire($objet, $valeur_id, $champ_id); |
|
| 676 | + } else { |
|
| 677 | + // On récupère la table SQL à partir du type d'objet. |
|
| 678 | + $table = table_objet_sql($objet); |
|
| 679 | + |
|
| 680 | + // La condition est appliquée sur le champ désigné par l'utilisateur. |
|
| 681 | + $where = [ |
|
| 682 | + $champ_id . '=' . sql_quote($valeur_id) |
|
| 683 | + ]; |
|
| 684 | + |
|
| 685 | + // Acquisition de tous les champs de l'objet : si l'accès SQL retourne une erreur on renvoie un tableau vide. |
|
| 686 | + $valeurs = sql_fetsel('*', $table, $where); |
|
| 687 | + } |
|
| 688 | + |
|
| 689 | + if (!$valeurs) { |
|
| 690 | + $valeurs = false; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + $descriptions[$objet][$champ_id][$valeur_id] = $valeurs; |
|
| 694 | + |
|
| 695 | + if ($champ_id !== $primary && isset($valeurs[$primary])) { |
|
| 696 | + $descriptions[$objet][$primary][$valeurs[$primary]] = $valeurs; |
|
| 697 | + $descriptions[$objet][$champ_id][$valeur_id] = &$descriptions[$objet][$primary][$valeurs[$primary]]; |
|
| 698 | + } |
|
| 699 | + } |
|
| 700 | + |
|
| 701 | + $retour = $descriptions[$objet][$champ_id][$valeur_id]; |
|
| 702 | + |
|
| 703 | + // On ne retourne maintenant que les champs demandés. |
|
| 704 | + // - on détermine les informations à renvoyer. |
|
| 705 | + if ($retour && !empty($options['champs'])) { |
|
| 706 | + $champs = $options['champs']; |
|
| 707 | + // Extraction des seules informations demandées. |
|
| 708 | + // -- si on demande une information unique on renvoie la valeur simple, sinon on renvoie un tableau. |
|
| 709 | + // -- si une information n'est pas un champ valide elle n'est pas renvoyée sans renvoyer d'erreur. |
|
| 710 | + $retour = is_array($champs) |
|
| 711 | + ? array_intersect_key($retour, array_flip($champs)) |
|
| 712 | + : $retour[$champs] ?? false; |
|
| 713 | + } |
|
| 714 | + |
|
| 715 | + return $retour; |
|
| 716 | 716 | } |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | $objet = $t; |
| 96 | 96 | } |
| 97 | 97 | if ( |
| 98 | - include_spip('action/editer_' . $objet) && function_exists($modifier = $objet . '_modifier') |
|
| 98 | + include_spip('action/editer_'.$objet) && function_exists($modifier = $objet.'_modifier') |
|
| 99 | 99 | ) { |
| 100 | 100 | return $modifier($id, $set); |
| 101 | 101 | } |
@@ -203,8 +203,8 @@ discard block |
||
| 203 | 203 | $objet = $t; |
| 204 | 204 | } |
| 205 | 205 | if ( |
| 206 | - include_spip('action/editer_' . $objet) |
|
| 207 | - && function_exists($inserer = $objet . '_inserer') |
|
| 206 | + include_spip('action/editer_'.$objet) |
|
| 207 | + && function_exists($inserer = $objet.'_inserer') |
|
| 208 | 208 | ) { |
| 209 | 209 | return $inserer($id_parent, $set); |
| 210 | 210 | } |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
| 226 | 226 | $id_rubrique = $row['id_rubrique']; |
| 227 | 227 | } else { |
| 228 | - $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique); |
|
| 228 | + $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', 'id_rubrique='.(int) $id_rubrique); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | $champs['id_rubrique'] = $id_rubrique; |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | $objet = $t; |
| 367 | 367 | } |
| 368 | 368 | if ( |
| 369 | - include_spip('action/editer_' . $objet) && function_exists($instituer = $objet . '_instituer') |
|
| 369 | + include_spip('action/editer_'.$objet) && function_exists($instituer = $objet.'_instituer') |
|
| 370 | 370 | ) { |
| 371 | 371 | return $instituer($id, $c, $calcul_rub); |
| 372 | 372 | } |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | $sel[] = ($champ_date ? "$champ_date as date" : "'' as date"); |
| 397 | 397 | $sel[] = (isset($desc['field']['id_rubrique']) ? 'id_rubrique' : '0 as id_rubrique'); |
| 398 | 398 | |
| 399 | - $row = sql_fetsel($sel, $table_sql, id_table_objet($objet) . '=' . (int) $id); |
|
| 399 | + $row = sql_fetsel($sel, $table_sql, id_table_objet($objet).'='.(int) $id); |
|
| 400 | 400 | |
| 401 | 401 | $id_rubrique = $row['id_rubrique']; |
| 402 | 402 | $statut_ancien = $statut = $row['statut']; |
@@ -419,7 +419,7 @@ discard block |
||
| 419 | 419 | if ($s != 'publie' && autoriser('modifier', $objet, $id)) { |
| 420 | 420 | $statut = $champs['statut'] = $s; |
| 421 | 421 | } else { |
| 422 | - spip_logger('editer')->notice("editer_objet $objet #$id refus " . json_encode($c, JSON_THROW_ON_ERROR)); |
|
| 422 | + spip_logger('editer')->notice("editer_objet $objet #$id refus ".json_encode($c, JSON_THROW_ON_ERROR)); |
|
| 423 | 423 | } |
| 424 | 424 | } |
| 425 | 425 | |
@@ -447,7 +447,7 @@ discard block |
||
| 447 | 447 | && isset($c['id_parent']) |
| 448 | 448 | && ($id_parent = $c['id_parent']) |
| 449 | 449 | && $id_parent != $id_rubrique |
| 450 | - && sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . (int) $id_parent) |
|
| 450 | + && sql_fetsel('1', 'spip_rubriques', 'id_rubrique='.(int) $id_parent) |
|
| 451 | 451 | ) { |
| 452 | 452 | $champs['id_rubrique'] = $id_parent; |
| 453 | 453 | |
@@ -580,7 +580,7 @@ discard block |
||
| 580 | 580 | // Si on deplace l'objet |
| 581 | 581 | // changer aussi son secteur et sa langue (si heritee) |
| 582 | 582 | if (isset($champs['id_rubrique'])) { |
| 583 | - $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 583 | + $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique='.sql_quote($champs['id_rubrique'])); |
|
| 584 | 584 | $langue = $row_rub['lang']; |
| 585 | 585 | |
| 586 | 586 | if (isset($desc['field']['id_secteur'])) { |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | && sql_fetsel( |
| 594 | 594 | '1', |
| 595 | 595 | $table_sql, |
| 596 | - id_table_objet($objet) . '=' . (int) $id . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 596 | + id_table_objet($objet).'='.(int) $id." AND langue_choisie<>'oui' AND lang<>".sql_quote($langue) |
|
| 597 | 597 | ) |
| 598 | 598 | ) { |
| 599 | 599 | $champs['lang'] = $langue; |
@@ -603,7 +603,7 @@ discard block |
||
| 603 | 603 | if (!$champs) { |
| 604 | 604 | return; |
| 605 | 605 | } |
| 606 | - sql_updateq($table_sql, $champs, id_table_objet($objet) . '=' . (int) $id); |
|
| 606 | + sql_updateq($table_sql, $champs, id_table_objet($objet).'='.(int) $id); |
|
| 607 | 607 | |
| 608 | 608 | // Changer le statut des rubriques concernees |
| 609 | 609 | if ($cond) { |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | ) { |
| 670 | 670 | // Il est possible pour un type d'objet de fournir une fonction de lecture de tous les champs d'un objet. |
| 671 | 671 | if ( |
| 672 | - include_spip('action/editer_' . $objet) |
|
| 672 | + include_spip('action/editer_'.$objet) |
|
| 673 | 673 | && function_exists($lire = "{$objet}_lire_champs") |
| 674 | 674 | ) { |
| 675 | 675 | $valeurs = $lire($objet, $valeur_id, $champ_id); |
@@ -679,7 +679,7 @@ discard block |
||
| 679 | 679 | |
| 680 | 680 | // La condition est appliquée sur le champ désigné par l'utilisateur. |
| 681 | 681 | $where = [ |
| 682 | - $champ_id . '=' . sql_quote($valeur_id) |
|
| 682 | + $champ_id.'='.sql_quote($valeur_id) |
|
| 683 | 683 | ]; |
| 684 | 684 | |
| 685 | 685 | // Acquisition de tous les champs de l'objet : si l'accès SQL retourne une erreur on renvoie un tableau vide. |
@@ -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,25 +24,25 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | function action_auth_dist() { |
| 26 | 26 | |
| 27 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 28 | - $arg = $securiser_action(); |
|
| 29 | - |
|
| 30 | - if (!preg_match(',^(\w+)[/](.+)$,', (string) $arg, $r)) { |
|
| 31 | - spip_logger()->info("action_auth_dist $arg pas compris"); |
|
| 32 | - } else { |
|
| 33 | - $auth_methode = $r[1]; |
|
| 34 | - $login = $r[2]; |
|
| 35 | - include_spip('inc/auth'); |
|
| 36 | - $res = auth_terminer_identifier_login($auth_methode, $login); |
|
| 37 | - |
|
| 38 | - if (is_string($res)) { // Erreur |
|
| 39 | - $redirect = _request('redirect'); |
|
| 40 | - $redirect = parametre_url($redirect, 'var_erreur', $res, '&'); |
|
| 41 | - include_spip('inc/headers'); |
|
| 42 | - redirige_par_entete($redirect); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - // sinon on loge l'auteur identifie, et on finit (redirection automatique) |
|
| 46 | - auth_loger($res); |
|
| 47 | - } |
|
| 27 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 28 | + $arg = $securiser_action(); |
|
| 29 | + |
|
| 30 | + if (!preg_match(',^(\w+)[/](.+)$,', (string) $arg, $r)) { |
|
| 31 | + spip_logger()->info("action_auth_dist $arg pas compris"); |
|
| 32 | + } else { |
|
| 33 | + $auth_methode = $r[1]; |
|
| 34 | + $login = $r[2]; |
|
| 35 | + include_spip('inc/auth'); |
|
| 36 | + $res = auth_terminer_identifier_login($auth_methode, $login); |
|
| 37 | + |
|
| 38 | + if (is_string($res)) { // Erreur |
|
| 39 | + $redirect = _request('redirect'); |
|
| 40 | + $redirect = parametre_url($redirect, 'var_erreur', $res, '&'); |
|
| 41 | + include_spip('inc/headers'); |
|
| 42 | + redirige_par_entete($redirect); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + // sinon on loge l'auteur identifie, et on finit (redirection automatique) |
|
| 46 | + auth_loger($res); |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -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 | /** |
@@ -38,36 +38,36 @@ discard block |
||
| 38 | 38 | * Liste (identifiant de l'article, texte d'erreur éventuel) |
| 39 | 39 | */ |
| 40 | 40 | function action_editer_article_dist($arg = null) { |
| 41 | - include_spip('inc/autoriser'); |
|
| 42 | - $err = ''; |
|
| 43 | - if (is_null($arg)) { |
|
| 44 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 45 | - $arg = $securiser_action(); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - // si id_article n'est pas un nombre, c'est une creation |
|
| 49 | - // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 50 | - if (!$id_article = (int) $arg) { |
|
| 51 | - $id_parent = _request('id_parent'); |
|
| 52 | - if (!$id_parent) { |
|
| 53 | - $err = _L("creation interdite d'un article sans rubrique"); |
|
| 54 | - } elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) { |
|
| 55 | - $err = _T('info_creerdansrubrique_non_autorise'); |
|
| 56 | - } else { |
|
| 57 | - $id_article = article_inserer($id_parent); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - // Enregistre l'envoi dans la BD |
|
| 62 | - if ($id_article > 0) { |
|
| 63 | - $err = article_modifier($id_article); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if ($err) { |
|
| 67 | - spip_logger()->error("echec editeur article: $err"); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - return [$id_article, $err]; |
|
| 41 | + include_spip('inc/autoriser'); |
|
| 42 | + $err = ''; |
|
| 43 | + if (is_null($arg)) { |
|
| 44 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 45 | + $arg = $securiser_action(); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + // si id_article n'est pas un nombre, c'est une creation |
|
| 49 | + // mais on verifie qu'on a toutes les donnees qu'il faut. |
|
| 50 | + if (!$id_article = (int) $arg) { |
|
| 51 | + $id_parent = _request('id_parent'); |
|
| 52 | + if (!$id_parent) { |
|
| 53 | + $err = _L("creation interdite d'un article sans rubrique"); |
|
| 54 | + } elseif (!autoriser('creerarticledans', 'rubrique', $id_parent)) { |
|
| 55 | + $err = _T('info_creerdansrubrique_non_autorise'); |
|
| 56 | + } else { |
|
| 57 | + $id_article = article_inserer($id_parent); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + // Enregistre l'envoi dans la BD |
|
| 62 | + if ($id_article > 0) { |
|
| 63 | + $err = article_modifier($id_article); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if ($err) { |
|
| 67 | + spip_logger()->error("echec editeur article: $err"); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + return [$id_article, $err]; |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | /** |
@@ -89,49 +89,49 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | function article_modifier($id_article, $set = null) { |
| 91 | 91 | |
| 92 | - // unifier $texte en cas de texte trop long |
|
| 93 | - trop_longs_articles(); |
|
| 94 | - |
|
| 95 | - include_spip('inc/modifier'); |
|
| 96 | - include_spip('inc/filtres'); |
|
| 97 | - $c = collecter_requests( |
|
| 98 | - // include list |
|
| 99 | - objet_info('article', 'champs_editables'), |
|
| 100 | - // exclude list |
|
| 101 | - ['date', 'statut', 'id_parent'], |
|
| 102 | - // donnees eventuellement fournies |
|
| 103 | - $set |
|
| 104 | - ); |
|
| 105 | - |
|
| 106 | - // Si l'article est publie, invalider les caches et demander sa reindexation |
|
| 107 | - $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . (int) $id_article); |
|
| 108 | - $invalideur = $indexation = false; |
|
| 109 | - if ($t == 'publie') { |
|
| 110 | - $invalideur = "id='article/$id_article'"; |
|
| 111 | - $indexation = true; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - if ( |
|
| 115 | - $err = objet_modifier_champs( |
|
| 116 | - 'article', |
|
| 117 | - $id_article, |
|
| 118 | - [ |
|
| 119 | - 'data' => $set, |
|
| 120 | - 'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article], |
|
| 121 | - 'invalideur' => $invalideur, |
|
| 122 | - 'indexation' => $indexation, |
|
| 123 | - 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 124 | - ], |
|
| 125 | - $c |
|
| 126 | - ) |
|
| 127 | - ) { |
|
| 128 | - return $err; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - // Modification de statut, changement de rubrique ? |
|
| 132 | - $c = collecter_requests(['date', 'statut', 'id_parent'], [], $set); |
|
| 133 | - |
|
| 134 | - return article_instituer($id_article, $c); |
|
| 92 | + // unifier $texte en cas de texte trop long |
|
| 93 | + trop_longs_articles(); |
|
| 94 | + |
|
| 95 | + include_spip('inc/modifier'); |
|
| 96 | + include_spip('inc/filtres'); |
|
| 97 | + $c = collecter_requests( |
|
| 98 | + // include list |
|
| 99 | + objet_info('article', 'champs_editables'), |
|
| 100 | + // exclude list |
|
| 101 | + ['date', 'statut', 'id_parent'], |
|
| 102 | + // donnees eventuellement fournies |
|
| 103 | + $set |
|
| 104 | + ); |
|
| 105 | + |
|
| 106 | + // Si l'article est publie, invalider les caches et demander sa reindexation |
|
| 107 | + $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . (int) $id_article); |
|
| 108 | + $invalideur = $indexation = false; |
|
| 109 | + if ($t == 'publie') { |
|
| 110 | + $invalideur = "id='article/$id_article'"; |
|
| 111 | + $indexation = true; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + if ( |
|
| 115 | + $err = objet_modifier_champs( |
|
| 116 | + 'article', |
|
| 117 | + $id_article, |
|
| 118 | + [ |
|
| 119 | + 'data' => $set, |
|
| 120 | + 'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article], |
|
| 121 | + 'invalideur' => $invalideur, |
|
| 122 | + 'indexation' => $indexation, |
|
| 123 | + 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
|
| 124 | + ], |
|
| 125 | + $c |
|
| 126 | + ) |
|
| 127 | + ) { |
|
| 128 | + return $err; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + // Modification de statut, changement de rubrique ? |
|
| 132 | + $c = collecter_requests(['date', 'statut', 'id_parent'], [], $set); |
|
| 133 | + |
|
| 134 | + return article_instituer($id_article, $c); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -167,120 +167,120 @@ discard block |
||
| 167 | 167 | */ |
| 168 | 168 | function article_inserer($id_rubrique, $set = null) { |
| 169 | 169 | |
| 170 | - // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
|
| 171 | - // dans la premiere rubrique racine |
|
| 172 | - if (!$id_rubrique = (int) $id_rubrique) { |
|
| 173 | - $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 174 | - $id_rubrique = $row['id_rubrique']; |
|
| 175 | - } else { |
|
| 176 | - $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
|
| 180 | - // cas de id_rubrique = -1 par exemple avec plugin "pages" |
|
| 181 | - $id_secteur = $row['id_secteur'] ?? 0; |
|
| 182 | - $lang_rub = $row['lang'] ?? ''; |
|
| 183 | - |
|
| 184 | - $lang = ''; |
|
| 185 | - $choisie = 'non'; |
|
| 186 | - // La langue a la creation : si les liens de traduction sont autorises |
|
| 187 | - // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 188 | - // ou a defaut celle de la rubrique |
|
| 189 | - // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 190 | - if ( |
|
| 191 | - !empty($GLOBALS['meta']['multi_objets']) && in_array( |
|
| 192 | - 'spip_articles', |
|
| 193 | - explode(',', (string) $GLOBALS['meta']['multi_objets']) |
|
| 194 | - ) |
|
| 195 | - ) { |
|
| 196 | - lang_select($GLOBALS['visiteur_session']['lang'] ?? ''); |
|
| 197 | - if ( |
|
| 198 | - in_array( |
|
| 199 | - $GLOBALS['spip_lang'], |
|
| 200 | - explode(',', (string) $GLOBALS['meta']['langues_multilingue']) |
|
| 201 | - ) |
|
| 202 | - ) { |
|
| 203 | - $lang = $GLOBALS['spip_lang']; |
|
| 204 | - $choisie = 'oui'; |
|
| 205 | - } |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - if (!$lang) { |
|
| 209 | - $choisie = 'non'; |
|
| 210 | - $lang = $lang_rub ?: $GLOBALS['meta']['langue_site']; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - $champs = [ |
|
| 214 | - 'id_rubrique' => $id_rubrique, |
|
| 215 | - 'id_secteur' => $id_secteur, |
|
| 216 | - 'statut' => 'prepa', |
|
| 217 | - 'date' => date('Y-m-d H:i:s'), |
|
| 218 | - 'lang' => $lang, |
|
| 219 | - 'langue_choisie' => $choisie |
|
| 220 | - ]; |
|
| 221 | - |
|
| 222 | - if ($set) { |
|
| 223 | - $champs = array_merge($champs, $set); |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - // Envoyer aux plugins |
|
| 227 | - $champs = pipeline( |
|
| 228 | - 'pre_insertion', |
|
| 229 | - [ |
|
| 230 | - 'args' => [ |
|
| 231 | - 'table' => 'spip_articles', |
|
| 232 | - ], |
|
| 233 | - 'data' => $champs |
|
| 234 | - ] |
|
| 235 | - ); |
|
| 236 | - |
|
| 237 | - $id_article = sql_insertq('spip_articles', $champs); |
|
| 238 | - |
|
| 239 | - // controler si le serveur n'a pas renvoye une erreur |
|
| 240 | - if ($id_article > 0) { |
|
| 241 | - $id_auteur = ((is_null(_request('id_auteur')) && isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 242 | - $GLOBALS['visiteur_session']['id_auteur'] |
|
| 243 | - : _request('id_auteur')); |
|
| 244 | - if ($id_auteur) { |
|
| 245 | - include_spip('action/editer_auteur'); |
|
| 246 | - auteur_associer($id_auteur, ['article' => $id_article]); |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - pipeline( |
|
| 251 | - 'post_insertion', |
|
| 252 | - [ |
|
| 253 | - 'args' => [ |
|
| 254 | - 'table' => 'spip_articles', |
|
| 255 | - 'id_objet' => $id_article |
|
| 256 | - ], |
|
| 257 | - 'data' => $champs |
|
| 258 | - ] |
|
| 259 | - ); |
|
| 260 | - |
|
| 261 | - // Appeler une notification |
|
| 262 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 263 | - $notifications( |
|
| 264 | - 'article_inserer', |
|
| 265 | - $id_article, |
|
| 266 | - [ |
|
| 267 | - 'id_parent' => $id_rubrique, |
|
| 268 | - 'champs' => $champs, |
|
| 269 | - ] |
|
| 270 | - ); |
|
| 271 | - $notifications( |
|
| 272 | - 'objet_inserer', |
|
| 273 | - $id_article, |
|
| 274 | - [ |
|
| 275 | - 'objet' => 'article', |
|
| 276 | - 'id_objet' => $id_article, |
|
| 277 | - 'id_parent' => $id_rubrique, |
|
| 278 | - 'champs' => $champs, |
|
| 279 | - ] |
|
| 280 | - ); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - return $id_article; |
|
| 170 | + // Si id_rubrique vaut 0 ou n'est pas definie, creer l'article |
|
| 171 | + // dans la premiere rubrique racine |
|
| 172 | + if (!$id_rubrique = (int) $id_rubrique) { |
|
| 173 | + $row = sql_fetsel('id_rubrique, id_secteur, lang', 'spip_rubriques', 'id_parent=0', '', '0+titre,titre', '1'); |
|
| 174 | + $id_rubrique = $row['id_rubrique']; |
|
| 175 | + } else { |
|
| 176 | + $row = sql_fetsel('lang, id_secteur', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + // eviter $id_secteur = NULL (erreur sqlite) si la requete precedente echoue |
|
| 180 | + // cas de id_rubrique = -1 par exemple avec plugin "pages" |
|
| 181 | + $id_secteur = $row['id_secteur'] ?? 0; |
|
| 182 | + $lang_rub = $row['lang'] ?? ''; |
|
| 183 | + |
|
| 184 | + $lang = ''; |
|
| 185 | + $choisie = 'non'; |
|
| 186 | + // La langue a la creation : si les liens de traduction sont autorises |
|
| 187 | + // dans les rubriques, on essaie avec la langue de l'auteur, |
|
| 188 | + // ou a defaut celle de la rubrique |
|
| 189 | + // Sinon c'est la langue de la rubrique qui est choisie + heritee |
|
| 190 | + if ( |
|
| 191 | + !empty($GLOBALS['meta']['multi_objets']) && in_array( |
|
| 192 | + 'spip_articles', |
|
| 193 | + explode(',', (string) $GLOBALS['meta']['multi_objets']) |
|
| 194 | + ) |
|
| 195 | + ) { |
|
| 196 | + lang_select($GLOBALS['visiteur_session']['lang'] ?? ''); |
|
| 197 | + if ( |
|
| 198 | + in_array( |
|
| 199 | + $GLOBALS['spip_lang'], |
|
| 200 | + explode(',', (string) $GLOBALS['meta']['langues_multilingue']) |
|
| 201 | + ) |
|
| 202 | + ) { |
|
| 203 | + $lang = $GLOBALS['spip_lang']; |
|
| 204 | + $choisie = 'oui'; |
|
| 205 | + } |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + if (!$lang) { |
|
| 209 | + $choisie = 'non'; |
|
| 210 | + $lang = $lang_rub ?: $GLOBALS['meta']['langue_site']; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + $champs = [ |
|
| 214 | + 'id_rubrique' => $id_rubrique, |
|
| 215 | + 'id_secteur' => $id_secteur, |
|
| 216 | + 'statut' => 'prepa', |
|
| 217 | + 'date' => date('Y-m-d H:i:s'), |
|
| 218 | + 'lang' => $lang, |
|
| 219 | + 'langue_choisie' => $choisie |
|
| 220 | + ]; |
|
| 221 | + |
|
| 222 | + if ($set) { |
|
| 223 | + $champs = array_merge($champs, $set); |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + // Envoyer aux plugins |
|
| 227 | + $champs = pipeline( |
|
| 228 | + 'pre_insertion', |
|
| 229 | + [ |
|
| 230 | + 'args' => [ |
|
| 231 | + 'table' => 'spip_articles', |
|
| 232 | + ], |
|
| 233 | + 'data' => $champs |
|
| 234 | + ] |
|
| 235 | + ); |
|
| 236 | + |
|
| 237 | + $id_article = sql_insertq('spip_articles', $champs); |
|
| 238 | + |
|
| 239 | + // controler si le serveur n'a pas renvoye une erreur |
|
| 240 | + if ($id_article > 0) { |
|
| 241 | + $id_auteur = ((is_null(_request('id_auteur')) && isset($GLOBALS['visiteur_session']['id_auteur'])) ? |
|
| 242 | + $GLOBALS['visiteur_session']['id_auteur'] |
|
| 243 | + : _request('id_auteur')); |
|
| 244 | + if ($id_auteur) { |
|
| 245 | + include_spip('action/editer_auteur'); |
|
| 246 | + auteur_associer($id_auteur, ['article' => $id_article]); |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + pipeline( |
|
| 251 | + 'post_insertion', |
|
| 252 | + [ |
|
| 253 | + 'args' => [ |
|
| 254 | + 'table' => 'spip_articles', |
|
| 255 | + 'id_objet' => $id_article |
|
| 256 | + ], |
|
| 257 | + 'data' => $champs |
|
| 258 | + ] |
|
| 259 | + ); |
|
| 260 | + |
|
| 261 | + // Appeler une notification |
|
| 262 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 263 | + $notifications( |
|
| 264 | + 'article_inserer', |
|
| 265 | + $id_article, |
|
| 266 | + [ |
|
| 267 | + 'id_parent' => $id_rubrique, |
|
| 268 | + 'champs' => $champs, |
|
| 269 | + ] |
|
| 270 | + ); |
|
| 271 | + $notifications( |
|
| 272 | + 'objet_inserer', |
|
| 273 | + $id_article, |
|
| 274 | + [ |
|
| 275 | + 'objet' => 'article', |
|
| 276 | + 'id_objet' => $id_article, |
|
| 277 | + 'id_parent' => $id_rubrique, |
|
| 278 | + 'champs' => $champs, |
|
| 279 | + ] |
|
| 280 | + ); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + return $id_article; |
|
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | |
@@ -308,157 +308,157 @@ discard block |
||
| 308 | 308 | */ |
| 309 | 309 | function article_instituer($id_article, $c, $calcul_rub = true) { |
| 310 | 310 | |
| 311 | - include_spip('inc/autoriser'); |
|
| 312 | - include_spip('inc/rubriques'); |
|
| 313 | - include_spip('inc/modifier'); |
|
| 314 | - |
|
| 315 | - $row = sql_fetsel('statut, date, id_rubrique', 'spip_articles', "id_article=$id_article"); |
|
| 316 | - $id_rubrique = $row['id_rubrique']; |
|
| 317 | - $statut_ancien = $statut = $row['statut']; |
|
| 318 | - $date_ancienne = $date = $row['date']; |
|
| 319 | - $champs = []; |
|
| 320 | - |
|
| 321 | - $d = $c['date'] ?? null; |
|
| 322 | - $s = $c['statut'] ?? $statut; |
|
| 323 | - |
|
| 324 | - // cf autorisations dans inc/instituer_article |
|
| 325 | - if ($s != $statut || $d && $d != $date) { |
|
| 326 | - if (autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 327 | - $statut = $champs['statut'] = $s; |
|
| 328 | - } elseif (autoriser('modifier', 'article', $id_article) && $s != 'publie') { |
|
| 329 | - $statut = $champs['statut'] = $s; |
|
| 330 | - } else { |
|
| 331 | - spip_logger()->info("editer_article $id_article refus " . implode(' ', $c)); |
|
| 332 | - } |
|
| 333 | - |
|
| 334 | - // En cas de publication, fixer la date a "maintenant" |
|
| 335 | - // sauf si $c commande autre chose |
|
| 336 | - // ou si l'article est deja date dans le futur |
|
| 337 | - // En cas de proposition d'un article (mais pas depublication), idem |
|
| 338 | - if ( |
|
| 339 | - $champs['statut'] == 'publie' |
|
| 340 | - || $champs['statut'] == 'prop' && ($d || !in_array($statut_ancien, ['publie', 'prop'])) |
|
| 341 | - ) { |
|
| 342 | - $champs['date'] = $d || strtotime((string) ($d = $date)) > time() |
|
| 343 | - ? $date = $d |
|
| 344 | - : ($date = date('Y-m-d H:i:s')); |
|
| 345 | - } |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - // Verifier que la rubrique demandee existe et est differente |
|
| 349 | - // de la rubrique actuelle |
|
| 350 | - if ( |
|
| 351 | - isset($c['id_parent']) |
|
| 352 | - && ($id_parent = $c['id_parent']) |
|
| 353 | - && $id_parent != $id_rubrique |
|
| 354 | - && sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . (int) $id_parent) |
|
| 355 | - ) { |
|
| 356 | - $champs['id_rubrique'] = $id_parent; |
|
| 357 | - |
|
| 358 | - // si l'article etait publie |
|
| 359 | - // et que le demandeur n'est pas admin de la rubrique de destination |
|
| 360 | - // repasser l'article en statut 'propose'. |
|
| 361 | - if ( |
|
| 362 | - $statut == 'publie' |
|
| 363 | - && !autoriser('publierdans', 'rubrique', $id_parent) |
|
| 364 | - ) { |
|
| 365 | - $champs['statut'] = 'prop'; |
|
| 366 | - } |
|
| 367 | - } |
|
| 368 | - |
|
| 369 | - // Envoyer aux plugins |
|
| 370 | - $champs = pipeline( |
|
| 371 | - 'pre_edition', |
|
| 372 | - [ |
|
| 373 | - 'args' => [ |
|
| 374 | - 'table' => 'spip_articles', |
|
| 375 | - 'table_objet' => 'articles', |
|
| 376 | - 'spip_table_objet' => 'spip_articles', |
|
| 377 | - 'objet' => 'article', |
|
| 378 | - 'id_objet' => $id_article, |
|
| 379 | - 'action' => 'instituer', |
|
| 380 | - 'statut_ancien' => $statut_ancien, |
|
| 381 | - 'date_ancienne' => $date_ancienne, |
|
| 382 | - ], |
|
| 383 | - 'data' => $champs |
|
| 384 | - ] |
|
| 385 | - ); |
|
| 386 | - |
|
| 387 | - if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 388 | - return ''; |
|
| 389 | - } |
|
| 390 | - |
|
| 391 | - // Envoyer les modifs. |
|
| 392 | - editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 393 | - |
|
| 394 | - // Invalider les caches |
|
| 395 | - include_spip('inc/invalideur'); |
|
| 396 | - suivre_invalideur("id='article/$id_article'"); |
|
| 397 | - |
|
| 398 | - if ($date) { |
|
| 399 | - $t = strtotime((string) $date); |
|
| 400 | - $p = @$GLOBALS['meta']['date_prochain_postdate']; |
|
| 401 | - if ($t > time() && (!$p || $t < $p)) { |
|
| 402 | - ecrire_meta('date_prochain_postdate', $t); |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - // Pipeline |
|
| 407 | - pipeline( |
|
| 408 | - 'post_edition', |
|
| 409 | - [ |
|
| 410 | - 'args' => [ |
|
| 411 | - 'table' => 'spip_articles', |
|
| 412 | - 'table_objet' => 'articles', |
|
| 413 | - 'spip_table_objet' => 'spip_articles', |
|
| 414 | - 'objet' => 'article', |
|
| 415 | - 'id_objet' => $id_article, |
|
| 416 | - 'action' => 'instituer', |
|
| 417 | - 'statut_ancien' => $statut_ancien, |
|
| 418 | - 'date_ancienne' => $date_ancienne, |
|
| 419 | - ], |
|
| 420 | - 'data' => $champs |
|
| 421 | - ] |
|
| 422 | - ); |
|
| 423 | - |
|
| 424 | - // Notifications |
|
| 425 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 426 | - $notifications( |
|
| 427 | - 'article_instituer', |
|
| 428 | - $id_article, |
|
| 429 | - [ |
|
| 430 | - 'statut' => $statut, |
|
| 431 | - 'statut_ancien' => $statut_ancien, |
|
| 432 | - 'date' => $date, |
|
| 433 | - 'date_ancienne' => $date_ancienne, |
|
| 434 | - 'id_parent_ancien' => $id_rubrique, |
|
| 435 | - 'champs' => $champs, |
|
| 436 | - ] |
|
| 437 | - ); |
|
| 438 | - $notifications( |
|
| 439 | - 'objet_instituer', |
|
| 440 | - $id_article, |
|
| 441 | - [ |
|
| 442 | - 'objet' => 'article', |
|
| 443 | - 'id_objet' => $id_article, |
|
| 444 | - 'statut' => $statut, |
|
| 445 | - 'statut_ancien' => $statut_ancien, |
|
| 446 | - 'date' => $date, |
|
| 447 | - 'date_ancienne' => $date_ancienne, |
|
| 448 | - 'id_parent_ancien' => $id_rubrique, |
|
| 449 | - 'champs' => $champs, |
|
| 450 | - ] |
|
| 451 | - ); |
|
| 452 | - |
|
| 453 | - // Rétro-compat |
|
| 454 | - $notifications( |
|
| 455 | - 'instituerarticle', |
|
| 456 | - $id_article, |
|
| 457 | - ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 458 | - ); |
|
| 459 | - } |
|
| 460 | - |
|
| 461 | - return ''; // pas d'erreur |
|
| 311 | + include_spip('inc/autoriser'); |
|
| 312 | + include_spip('inc/rubriques'); |
|
| 313 | + include_spip('inc/modifier'); |
|
| 314 | + |
|
| 315 | + $row = sql_fetsel('statut, date, id_rubrique', 'spip_articles', "id_article=$id_article"); |
|
| 316 | + $id_rubrique = $row['id_rubrique']; |
|
| 317 | + $statut_ancien = $statut = $row['statut']; |
|
| 318 | + $date_ancienne = $date = $row['date']; |
|
| 319 | + $champs = []; |
|
| 320 | + |
|
| 321 | + $d = $c['date'] ?? null; |
|
| 322 | + $s = $c['statut'] ?? $statut; |
|
| 323 | + |
|
| 324 | + // cf autorisations dans inc/instituer_article |
|
| 325 | + if ($s != $statut || $d && $d != $date) { |
|
| 326 | + if (autoriser('publierdans', 'rubrique', $id_rubrique)) { |
|
| 327 | + $statut = $champs['statut'] = $s; |
|
| 328 | + } elseif (autoriser('modifier', 'article', $id_article) && $s != 'publie') { |
|
| 329 | + $statut = $champs['statut'] = $s; |
|
| 330 | + } else { |
|
| 331 | + spip_logger()->info("editer_article $id_article refus " . implode(' ', $c)); |
|
| 332 | + } |
|
| 333 | + |
|
| 334 | + // En cas de publication, fixer la date a "maintenant" |
|
| 335 | + // sauf si $c commande autre chose |
|
| 336 | + // ou si l'article est deja date dans le futur |
|
| 337 | + // En cas de proposition d'un article (mais pas depublication), idem |
|
| 338 | + if ( |
|
| 339 | + $champs['statut'] == 'publie' |
|
| 340 | + || $champs['statut'] == 'prop' && ($d || !in_array($statut_ancien, ['publie', 'prop'])) |
|
| 341 | + ) { |
|
| 342 | + $champs['date'] = $d || strtotime((string) ($d = $date)) > time() |
|
| 343 | + ? $date = $d |
|
| 344 | + : ($date = date('Y-m-d H:i:s')); |
|
| 345 | + } |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + // Verifier que la rubrique demandee existe et est differente |
|
| 349 | + // de la rubrique actuelle |
|
| 350 | + if ( |
|
| 351 | + isset($c['id_parent']) |
|
| 352 | + && ($id_parent = $c['id_parent']) |
|
| 353 | + && $id_parent != $id_rubrique |
|
| 354 | + && sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . (int) $id_parent) |
|
| 355 | + ) { |
|
| 356 | + $champs['id_rubrique'] = $id_parent; |
|
| 357 | + |
|
| 358 | + // si l'article etait publie |
|
| 359 | + // et que le demandeur n'est pas admin de la rubrique de destination |
|
| 360 | + // repasser l'article en statut 'propose'. |
|
| 361 | + if ( |
|
| 362 | + $statut == 'publie' |
|
| 363 | + && !autoriser('publierdans', 'rubrique', $id_parent) |
|
| 364 | + ) { |
|
| 365 | + $champs['statut'] = 'prop'; |
|
| 366 | + } |
|
| 367 | + } |
|
| 368 | + |
|
| 369 | + // Envoyer aux plugins |
|
| 370 | + $champs = pipeline( |
|
| 371 | + 'pre_edition', |
|
| 372 | + [ |
|
| 373 | + 'args' => [ |
|
| 374 | + 'table' => 'spip_articles', |
|
| 375 | + 'table_objet' => 'articles', |
|
| 376 | + 'spip_table_objet' => 'spip_articles', |
|
| 377 | + 'objet' => 'article', |
|
| 378 | + 'id_objet' => $id_article, |
|
| 379 | + 'action' => 'instituer', |
|
| 380 | + 'statut_ancien' => $statut_ancien, |
|
| 381 | + 'date_ancienne' => $date_ancienne, |
|
| 382 | + ], |
|
| 383 | + 'data' => $champs |
|
| 384 | + ] |
|
| 385 | + ); |
|
| 386 | + |
|
| 387 | + if (!(is_countable($champs) ? count($champs) : 0)) { |
|
| 388 | + return ''; |
|
| 389 | + } |
|
| 390 | + |
|
| 391 | + // Envoyer les modifs. |
|
| 392 | + editer_article_heritage($id_article, $id_rubrique, $statut_ancien, $champs, $calcul_rub); |
|
| 393 | + |
|
| 394 | + // Invalider les caches |
|
| 395 | + include_spip('inc/invalideur'); |
|
| 396 | + suivre_invalideur("id='article/$id_article'"); |
|
| 397 | + |
|
| 398 | + if ($date) { |
|
| 399 | + $t = strtotime((string) $date); |
|
| 400 | + $p = @$GLOBALS['meta']['date_prochain_postdate']; |
|
| 401 | + if ($t > time() && (!$p || $t < $p)) { |
|
| 402 | + ecrire_meta('date_prochain_postdate', $t); |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + // Pipeline |
|
| 407 | + pipeline( |
|
| 408 | + 'post_edition', |
|
| 409 | + [ |
|
| 410 | + 'args' => [ |
|
| 411 | + 'table' => 'spip_articles', |
|
| 412 | + 'table_objet' => 'articles', |
|
| 413 | + 'spip_table_objet' => 'spip_articles', |
|
| 414 | + 'objet' => 'article', |
|
| 415 | + 'id_objet' => $id_article, |
|
| 416 | + 'action' => 'instituer', |
|
| 417 | + 'statut_ancien' => $statut_ancien, |
|
| 418 | + 'date_ancienne' => $date_ancienne, |
|
| 419 | + ], |
|
| 420 | + 'data' => $champs |
|
| 421 | + ] |
|
| 422 | + ); |
|
| 423 | + |
|
| 424 | + // Notifications |
|
| 425 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 426 | + $notifications( |
|
| 427 | + 'article_instituer', |
|
| 428 | + $id_article, |
|
| 429 | + [ |
|
| 430 | + 'statut' => $statut, |
|
| 431 | + 'statut_ancien' => $statut_ancien, |
|
| 432 | + 'date' => $date, |
|
| 433 | + 'date_ancienne' => $date_ancienne, |
|
| 434 | + 'id_parent_ancien' => $id_rubrique, |
|
| 435 | + 'champs' => $champs, |
|
| 436 | + ] |
|
| 437 | + ); |
|
| 438 | + $notifications( |
|
| 439 | + 'objet_instituer', |
|
| 440 | + $id_article, |
|
| 441 | + [ |
|
| 442 | + 'objet' => 'article', |
|
| 443 | + 'id_objet' => $id_article, |
|
| 444 | + 'statut' => $statut, |
|
| 445 | + 'statut_ancien' => $statut_ancien, |
|
| 446 | + 'date' => $date, |
|
| 447 | + 'date_ancienne' => $date_ancienne, |
|
| 448 | + 'id_parent_ancien' => $id_rubrique, |
|
| 449 | + 'champs' => $champs, |
|
| 450 | + ] |
|
| 451 | + ); |
|
| 452 | + |
|
| 453 | + // Rétro-compat |
|
| 454 | + $notifications( |
|
| 455 | + 'instituerarticle', |
|
| 456 | + $id_article, |
|
| 457 | + ['statut' => $statut, 'statut_ancien' => $statut_ancien, 'date' => $date, 'date_ancienne' => $date_ancienne] |
|
| 458 | + ); |
|
| 459 | + } |
|
| 460 | + |
|
| 461 | + return ''; // pas d'erreur |
|
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | /** |
@@ -483,37 +483,37 @@ discard block |
||
| 483 | 483 | */ |
| 484 | 484 | function editer_article_heritage($id_article, $id_rubrique, $statut, $champs, $cond = true) { |
| 485 | 485 | |
| 486 | - // Si on deplace l'article |
|
| 487 | - // changer aussi son secteur et sa langue (si heritee) |
|
| 488 | - if (isset($champs['id_rubrique'])) { |
|
| 489 | - $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 490 | - |
|
| 491 | - $langue = $row_rub['lang']; |
|
| 492 | - $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 493 | - if ( |
|
| 494 | - sql_fetsel( |
|
| 495 | - '1', |
|
| 496 | - 'spip_articles', |
|
| 497 | - 'id_article=' . (int) $id_article . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 498 | - ) |
|
| 499 | - ) { |
|
| 500 | - $champs['lang'] = $langue; |
|
| 501 | - } |
|
| 502 | - } |
|
| 503 | - |
|
| 504 | - if (!$champs) { |
|
| 505 | - return; |
|
| 506 | - } |
|
| 507 | - |
|
| 508 | - sql_updateq('spip_articles', $champs, 'id_article=' . (int) $id_article); |
|
| 509 | - |
|
| 510 | - // Changer le statut des rubriques concernees |
|
| 511 | - |
|
| 512 | - if ($cond) { |
|
| 513 | - include_spip('inc/rubriques'); |
|
| 514 | - $postdate = ($GLOBALS['meta']['post_dates'] == 'non' && isset($champs['date']) && strtotime((string) $champs['date']) < time()) ? $champs['date'] : false; |
|
| 515 | - calculer_rubriques_if($id_rubrique, $champs, ['statut_ancien' => $statut], $postdate); |
|
| 516 | - } |
|
| 486 | + // Si on deplace l'article |
|
| 487 | + // changer aussi son secteur et sa langue (si heritee) |
|
| 488 | + if (isset($champs['id_rubrique'])) { |
|
| 489 | + $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 490 | + |
|
| 491 | + $langue = $row_rub['lang']; |
|
| 492 | + $champs['id_secteur'] = $row_rub['id_secteur']; |
|
| 493 | + if ( |
|
| 494 | + sql_fetsel( |
|
| 495 | + '1', |
|
| 496 | + 'spip_articles', |
|
| 497 | + 'id_article=' . (int) $id_article . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 498 | + ) |
|
| 499 | + ) { |
|
| 500 | + $champs['lang'] = $langue; |
|
| 501 | + } |
|
| 502 | + } |
|
| 503 | + |
|
| 504 | + if (!$champs) { |
|
| 505 | + return; |
|
| 506 | + } |
|
| 507 | + |
|
| 508 | + sql_updateq('spip_articles', $champs, 'id_article=' . (int) $id_article); |
|
| 509 | + |
|
| 510 | + // Changer le statut des rubriques concernees |
|
| 511 | + |
|
| 512 | + if ($cond) { |
|
| 513 | + include_spip('inc/rubriques'); |
|
| 514 | + $postdate = ($GLOBALS['meta']['post_dates'] == 'non' && isset($champs['date']) && strtotime((string) $champs['date']) < time()) ? $champs['date'] : false; |
|
| 515 | + calculer_rubriques_if($id_rubrique, $champs, ['statut_ancien' => $statut], $postdate); |
|
| 516 | + } |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -522,10 +522,10 @@ discard block |
||
| 522 | 522 | * @return void |
| 523 | 523 | */ |
| 524 | 524 | function trop_longs_articles() { |
| 525 | - if (is_array($plus = _request('texte_plus'))) { |
|
| 526 | - foreach ($plus as $n => $t) { |
|
| 527 | - $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', (string) $t); |
|
| 528 | - } |
|
| 529 | - set_request('texte', implode('', $plus) . _request('texte')); |
|
| 530 | - } |
|
| 525 | + if (is_array($plus = _request('texte_plus'))) { |
|
| 526 | + foreach ($plus as $n => $t) { |
|
| 527 | + $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', (string) $t); |
|
| 528 | + } |
|
| 529 | + set_request('texte', implode('', $plus) . _request('texte')); |
|
| 530 | + } |
|
| 531 | 531 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | ); |
| 105 | 105 | |
| 106 | 106 | // Si l'article est publie, invalider les caches et demander sa reindexation |
| 107 | - $t = sql_getfetsel('statut', 'spip_articles', 'id_article=' . (int) $id_article); |
|
| 107 | + $t = sql_getfetsel('statut', 'spip_articles', 'id_article='.(int) $id_article); |
|
| 108 | 108 | $invalideur = $indexation = false; |
| 109 | 109 | if ($t == 'publie') { |
| 110 | 110 | $invalideur = "id='article/$id_article'"; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $id_article, |
| 118 | 118 | [ |
| 119 | 119 | 'data' => $set, |
| 120 | - 'nonvide' => ['titre' => _T('info_nouvel_article') . ' ' . _T('info_numero_abbreviation') . $id_article], |
|
| 120 | + 'nonvide' => ['titre' => _T('info_nouvel_article').' '._T('info_numero_abbreviation').$id_article], |
|
| 121 | 121 | 'invalideur' => $invalideur, |
| 122 | 122 | 'indexation' => $indexation, |
| 123 | 123 | 'date_modif' => 'date_modif' // champ a mettre a date('Y-m-d H:i:s') s'il y a modif |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | } elseif (autoriser('modifier', 'article', $id_article) && $s != 'publie') { |
| 329 | 329 | $statut = $champs['statut'] = $s; |
| 330 | 330 | } else { |
| 331 | - spip_logger()->info("editer_article $id_article refus " . implode(' ', $c)); |
|
| 331 | + spip_logger()->info("editer_article $id_article refus ".implode(' ', $c)); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | // En cas de publication, fixer la date a "maintenant" |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | isset($c['id_parent']) |
| 352 | 352 | && ($id_parent = $c['id_parent']) |
| 353 | 353 | && $id_parent != $id_rubrique |
| 354 | - && sql_fetsel('1', 'spip_rubriques', 'id_rubrique=' . (int) $id_parent) |
|
| 354 | + && sql_fetsel('1', 'spip_rubriques', 'id_rubrique='.(int) $id_parent) |
|
| 355 | 355 | ) { |
| 356 | 356 | $champs['id_rubrique'] = $id_parent; |
| 357 | 357 | |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | // Si on deplace l'article |
| 487 | 487 | // changer aussi son secteur et sa langue (si heritee) |
| 488 | 488 | if (isset($champs['id_rubrique'])) { |
| 489 | - $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique=' . sql_quote($champs['id_rubrique'])); |
|
| 489 | + $row_rub = sql_fetsel('id_secteur, lang', 'spip_rubriques', 'id_rubrique='.sql_quote($champs['id_rubrique'])); |
|
| 490 | 490 | |
| 491 | 491 | $langue = $row_rub['lang']; |
| 492 | 492 | $champs['id_secteur'] = $row_rub['id_secteur']; |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | sql_fetsel( |
| 495 | 495 | '1', |
| 496 | 496 | 'spip_articles', |
| 497 | - 'id_article=' . (int) $id_article . " AND langue_choisie<>'oui' AND lang<>" . sql_quote($langue) |
|
| 497 | + 'id_article='.(int) $id_article." AND langue_choisie<>'oui' AND lang<>".sql_quote($langue) |
|
| 498 | 498 | ) |
| 499 | 499 | ) { |
| 500 | 500 | $champs['lang'] = $langue; |
@@ -505,7 +505,7 @@ discard block |
||
| 505 | 505 | return; |
| 506 | 506 | } |
| 507 | 507 | |
| 508 | - sql_updateq('spip_articles', $champs, 'id_article=' . (int) $id_article); |
|
| 508 | + sql_updateq('spip_articles', $champs, 'id_article='.(int) $id_article); |
|
| 509 | 509 | |
| 510 | 510 | // Changer le statut des rubriques concernees |
| 511 | 511 | |
@@ -526,6 +526,6 @@ discard block |
||
| 526 | 526 | foreach ($plus as $n => $t) { |
| 527 | 527 | $plus[$n] = preg_replace(",<!--SPIP-->[\n\r]*,", '', (string) $t); |
| 528 | 528 | } |
| 529 | - set_request('texte', implode('', $plus) . _request('texte')); |
|
| 529 | + set_request('texte', implode('', $plus)._request('texte')); |
|
| 530 | 530 | } |
| 531 | 531 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Rubriques\Edition |
| 16 | 16 | */ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | include_spip('inc/rubriques'); |
@@ -37,34 +37,34 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function action_editer_rubrique_dist($arg = null) { |
| 39 | 39 | |
| 40 | - if (is_null($arg)) { |
|
| 41 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 42 | - $arg = $securiser_action(); |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - if (!$id_rubrique = (int) $arg) { |
|
| 46 | - if ($arg != 'oui') { |
|
| 47 | - include_spip('inc/headers'); |
|
| 48 | - redirige_url_ecrire(); |
|
| 49 | - } |
|
| 50 | - $id_rubrique = rubrique_inserer(_request('id_parent')); |
|
| 51 | - } |
|
| 52 | - |
|
| 53 | - $err = rubrique_modifier($id_rubrique); |
|
| 54 | - |
|
| 55 | - if (_request('redirect')) { |
|
| 56 | - $redirect = parametre_url( |
|
| 57 | - urldecode((string) _request('redirect')), |
|
| 58 | - 'id_rubrique', |
|
| 59 | - $id_rubrique, |
|
| 60 | - '&' |
|
| 61 | - ); |
|
| 62 | - |
|
| 63 | - include_spip('inc/headers'); |
|
| 64 | - redirige_par_entete($redirect); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - return [$id_rubrique, $err]; |
|
| 40 | + if (is_null($arg)) { |
|
| 41 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 42 | + $arg = $securiser_action(); |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + if (!$id_rubrique = (int) $arg) { |
|
| 46 | + if ($arg != 'oui') { |
|
| 47 | + include_spip('inc/headers'); |
|
| 48 | + redirige_url_ecrire(); |
|
| 49 | + } |
|
| 50 | + $id_rubrique = rubrique_inserer(_request('id_parent')); |
|
| 51 | + } |
|
| 52 | + |
|
| 53 | + $err = rubrique_modifier($id_rubrique); |
|
| 54 | + |
|
| 55 | + if (_request('redirect')) { |
|
| 56 | + $redirect = parametre_url( |
|
| 57 | + urldecode((string) _request('redirect')), |
|
| 58 | + 'id_rubrique', |
|
| 59 | + $id_rubrique, |
|
| 60 | + '&' |
|
| 61 | + ); |
|
| 62 | + |
|
| 63 | + include_spip('inc/headers'); |
|
| 64 | + redirige_par_entete($redirect); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + return [$id_rubrique, $err]; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
@@ -79,64 +79,64 @@ discard block |
||
| 79 | 79 | * Identifiant de la rubrique crée |
| 80 | 80 | */ |
| 81 | 81 | function rubrique_inserer($id_parent, $set = null) { |
| 82 | - $champs = [ |
|
| 83 | - 'titre' => _T('item_nouvelle_rubrique'), |
|
| 84 | - 'id_parent' => (int) $id_parent, |
|
| 85 | - 'statut' => 'prepa' |
|
| 86 | - ]; |
|
| 87 | - |
|
| 88 | - if ($set) { |
|
| 89 | - $champs = array_merge($champs, $set); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // Envoyer aux plugins |
|
| 93 | - $champs = pipeline( |
|
| 94 | - 'pre_insertion', |
|
| 95 | - [ |
|
| 96 | - 'args' => [ |
|
| 97 | - 'table' => 'spip_rubriques', |
|
| 98 | - ], |
|
| 99 | - 'data' => $champs |
|
| 100 | - ] |
|
| 101 | - ); |
|
| 102 | - |
|
| 103 | - $id_rubrique = sql_insertq('spip_rubriques', $champs); |
|
| 104 | - pipeline( |
|
| 105 | - 'post_insertion', |
|
| 106 | - [ |
|
| 107 | - 'args' => [ |
|
| 108 | - 'table' => 'spip_rubriques', |
|
| 109 | - 'id_objet' => $id_rubrique |
|
| 110 | - ], |
|
| 111 | - 'data' => $champs |
|
| 112 | - ] |
|
| 113 | - ); |
|
| 114 | - propager_les_secteurs(); |
|
| 115 | - calculer_langues_rubriques(); |
|
| 116 | - |
|
| 117 | - // Appeler une notification |
|
| 118 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 119 | - $notifications( |
|
| 120 | - 'rubrique_inserer', |
|
| 121 | - $id_rubrique, |
|
| 122 | - [ |
|
| 123 | - 'id_parent' => $id_parent, |
|
| 124 | - 'champs' => $champs, |
|
| 125 | - ] |
|
| 126 | - ); |
|
| 127 | - $notifications( |
|
| 128 | - 'objet_inserer', |
|
| 129 | - $id_rubrique, |
|
| 130 | - [ |
|
| 131 | - 'objet' => 'rubrique', |
|
| 132 | - 'id_objet' => $id_rubrique, |
|
| 133 | - 'id_parent' => $id_parent, |
|
| 134 | - 'champs' => $champs, |
|
| 135 | - ] |
|
| 136 | - ); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - return $id_rubrique; |
|
| 82 | + $champs = [ |
|
| 83 | + 'titre' => _T('item_nouvelle_rubrique'), |
|
| 84 | + 'id_parent' => (int) $id_parent, |
|
| 85 | + 'statut' => 'prepa' |
|
| 86 | + ]; |
|
| 87 | + |
|
| 88 | + if ($set) { |
|
| 89 | + $champs = array_merge($champs, $set); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // Envoyer aux plugins |
|
| 93 | + $champs = pipeline( |
|
| 94 | + 'pre_insertion', |
|
| 95 | + [ |
|
| 96 | + 'args' => [ |
|
| 97 | + 'table' => 'spip_rubriques', |
|
| 98 | + ], |
|
| 99 | + 'data' => $champs |
|
| 100 | + ] |
|
| 101 | + ); |
|
| 102 | + |
|
| 103 | + $id_rubrique = sql_insertq('spip_rubriques', $champs); |
|
| 104 | + pipeline( |
|
| 105 | + 'post_insertion', |
|
| 106 | + [ |
|
| 107 | + 'args' => [ |
|
| 108 | + 'table' => 'spip_rubriques', |
|
| 109 | + 'id_objet' => $id_rubrique |
|
| 110 | + ], |
|
| 111 | + 'data' => $champs |
|
| 112 | + ] |
|
| 113 | + ); |
|
| 114 | + propager_les_secteurs(); |
|
| 115 | + calculer_langues_rubriques(); |
|
| 116 | + |
|
| 117 | + // Appeler une notification |
|
| 118 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 119 | + $notifications( |
|
| 120 | + 'rubrique_inserer', |
|
| 121 | + $id_rubrique, |
|
| 122 | + [ |
|
| 123 | + 'id_parent' => $id_parent, |
|
| 124 | + 'champs' => $champs, |
|
| 125 | + ] |
|
| 126 | + ); |
|
| 127 | + $notifications( |
|
| 128 | + 'objet_inserer', |
|
| 129 | + $id_rubrique, |
|
| 130 | + [ |
|
| 131 | + 'objet' => 'rubrique', |
|
| 132 | + 'id_objet' => $id_rubrique, |
|
| 133 | + 'id_parent' => $id_parent, |
|
| 134 | + 'champs' => $champs, |
|
| 135 | + ] |
|
| 136 | + ); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + return $id_rubrique; |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -152,46 +152,46 @@ discard block |
||
| 152 | 152 | * - chaîne : texte d'un message d'erreur |
| 153 | 153 | */ |
| 154 | 154 | function rubrique_modifier($id_rubrique, $set = null) { |
| 155 | - include_spip('inc/autoriser'); |
|
| 156 | - include_spip('inc/filtres'); |
|
| 157 | - |
|
| 158 | - include_spip('inc/modifier'); |
|
| 159 | - $c = collecter_requests( |
|
| 160 | - // include list |
|
| 161 | - objet_info('rubrique', 'champs_editables'), |
|
| 162 | - // exclude list |
|
| 163 | - ['id_parent', 'confirme_deplace'], |
|
| 164 | - // donnees eventuellement fournies |
|
| 165 | - $set |
|
| 166 | - ); |
|
| 167 | - |
|
| 168 | - if ( |
|
| 169 | - $err = objet_modifier_champs( |
|
| 170 | - 'rubrique', |
|
| 171 | - $id_rubrique, |
|
| 172 | - [ |
|
| 173 | - 'data' => $set, |
|
| 174 | - 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 175 | - ], |
|
| 176 | - $c |
|
| 177 | - ) |
|
| 178 | - ) { |
|
| 179 | - return $err; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - $c = collecter_requests(['id_parent', 'confirme_deplace'], [], $set); |
|
| 183 | - // Deplacer la rubrique |
|
| 184 | - if (isset($c['id_parent'])) { |
|
| 185 | - $err = rubrique_instituer($id_rubrique, $c); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - // invalider les caches marques de cette rubrique |
|
| 189 | - include_spip('inc/invalideur'); |
|
| 190 | - suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 191 | - // et celui de menu_rubriques |
|
| 192 | - effacer_meta('date_calcul_rubriques'); |
|
| 193 | - |
|
| 194 | - return $err; |
|
| 155 | + include_spip('inc/autoriser'); |
|
| 156 | + include_spip('inc/filtres'); |
|
| 157 | + |
|
| 158 | + include_spip('inc/modifier'); |
|
| 159 | + $c = collecter_requests( |
|
| 160 | + // include list |
|
| 161 | + objet_info('rubrique', 'champs_editables'), |
|
| 162 | + // exclude list |
|
| 163 | + ['id_parent', 'confirme_deplace'], |
|
| 164 | + // donnees eventuellement fournies |
|
| 165 | + $set |
|
| 166 | + ); |
|
| 167 | + |
|
| 168 | + if ( |
|
| 169 | + $err = objet_modifier_champs( |
|
| 170 | + 'rubrique', |
|
| 171 | + $id_rubrique, |
|
| 172 | + [ |
|
| 173 | + 'data' => $set, |
|
| 174 | + 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 175 | + ], |
|
| 176 | + $c |
|
| 177 | + ) |
|
| 178 | + ) { |
|
| 179 | + return $err; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + $c = collecter_requests(['id_parent', 'confirme_deplace'], [], $set); |
|
| 183 | + // Deplacer la rubrique |
|
| 184 | + if (isset($c['id_parent'])) { |
|
| 185 | + $err = rubrique_instituer($id_rubrique, $c); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + // invalider les caches marques de cette rubrique |
|
| 189 | + include_spip('inc/invalideur'); |
|
| 190 | + suivre_invalideur("id='rubrique/$id_rubrique'"); |
|
| 191 | + // et celui de menu_rubriques |
|
| 192 | + effacer_meta('date_calcul_rubriques'); |
|
| 193 | + |
|
| 194 | + return $err; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | /** |
@@ -214,29 +214,29 @@ discard block |
||
| 214 | 214 | * false si la confirmation du déplacement n'est pas présente |
| 215 | 215 | */ |
| 216 | 216 | function editer_rubrique_breves($id_rubrique, $id_parent, $c = []) { |
| 217 | - if (!sql_table_exists('spip_breves')) { |
|
| 218 | - return true; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) { |
|
| 222 | - return true; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - if (empty($c['confirme_deplace']) || $c['confirme_deplace'] != 'oui') { |
|
| 226 | - return false; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - if ( |
|
| 230 | - $id_secteur = sql_getfetsel( |
|
| 231 | - 'id_secteur', |
|
| 232 | - 'spip_rubriques', |
|
| 233 | - "id_rubrique=$id_parent" |
|
| 234 | - ) |
|
| 235 | - ) { |
|
| 236 | - sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique"); |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - return true; |
|
| 217 | + if (!sql_table_exists('spip_breves')) { |
|
| 218 | + return true; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + if (!sql_countsel('spip_breves', "id_rubrique=$id_rubrique")) { |
|
| 222 | + return true; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + if (empty($c['confirme_deplace']) || $c['confirme_deplace'] != 'oui') { |
|
| 226 | + return false; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + if ( |
|
| 230 | + $id_secteur = sql_getfetsel( |
|
| 231 | + 'id_secteur', |
|
| 232 | + 'spip_rubriques', |
|
| 233 | + "id_rubrique=$id_parent" |
|
| 234 | + ) |
|
| 235 | + ) { |
|
| 236 | + sql_updateq('spip_breves', ['id_rubrique' => $id_secteur], "id_rubrique=$id_rubrique"); |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + return true; |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | |
@@ -258,72 +258,72 @@ discard block |
||
| 258 | 258 | * Chaîne : texte du message d'erreur |
| 259 | 259 | */ |
| 260 | 260 | function rubrique_instituer($id_rubrique, $c) { |
| 261 | - // traitement de la rubrique parente |
|
| 262 | - // interdiction de deplacer vers ou a partir d'une rubrique |
|
| 263 | - // qu'on n'administre pas. |
|
| 264 | - |
|
| 265 | - if (null !== ($id_parent = $c['id_parent'])) { |
|
| 266 | - $id_parent = (int) $id_parent; |
|
| 267 | - $filles = calcul_branche_in($id_rubrique); |
|
| 268 | - if (str_contains(",$id_parent,", (string) ",$filles,")) { |
|
| 269 | - spip_logger()->info("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent"); |
|
| 270 | - } else { |
|
| 271 | - $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 272 | - $old_parent = $s['id_parent']; |
|
| 273 | - |
|
| 274 | - if ( |
|
| 275 | - !($id_parent != $old_parent |
|
| 276 | - && autoriser('publierdans', 'rubrique', $id_parent) |
|
| 277 | - && autoriser('creerrubriquedans', 'rubrique', $id_parent) |
|
| 278 | - && autoriser('publierdans', 'rubrique', $old_parent) |
|
| 279 | - ) |
|
| 280 | - ) { |
|
| 281 | - if ($s['statut'] != 'prepa') { |
|
| 282 | - spip_logger()->info("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 283 | - } |
|
| 284 | - } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
|
| 285 | - $statut_ancien = $s['statut']; |
|
| 286 | - sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique"); |
|
| 287 | - |
|
| 288 | - |
|
| 289 | - propager_les_secteurs(); |
|
| 290 | - |
|
| 291 | - // Deplacement d'une rubrique publiee ==> chgt general de leur statut |
|
| 292 | - if ($statut_ancien == 'publie') { |
|
| 293 | - calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]); |
|
| 294 | - } |
|
| 295 | - // Creation ou deplacement d'une rubrique non publiee |
|
| 296 | - // invalider le cache de leur menu |
|
| 297 | - elseif (!$statut_ancien || $old_parent != $id_parent) { |
|
| 298 | - effacer_meta('date_calcul_rubriques'); |
|
| 299 | - } |
|
| 300 | - |
|
| 301 | - calculer_langues_rubriques(); |
|
| 302 | - |
|
| 303 | - // Appeler une notification |
|
| 304 | - if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 305 | - $notifications( |
|
| 306 | - 'rubrique_instituer', |
|
| 307 | - $id_rubrique, |
|
| 308 | - [ |
|
| 309 | - 'statut_ancien' => $statut_ancien, |
|
| 310 | - 'id_parent_ancien' => $old_parent, |
|
| 311 | - ] |
|
| 312 | - ); |
|
| 313 | - $notifications( |
|
| 314 | - 'objet_instituer', |
|
| 315 | - $id_rubrique, |
|
| 316 | - [ |
|
| 317 | - 'objet' => 'rubrique', |
|
| 318 | - 'id_objet' => $id_rubrique, |
|
| 319 | - 'statut_ancien' => $statut_ancien, |
|
| 320 | - 'id_parent_ancien' => $old_parent, |
|
| 321 | - ] |
|
| 322 | - ); |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - } |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - return ''; // pas d'erreur |
|
| 261 | + // traitement de la rubrique parente |
|
| 262 | + // interdiction de deplacer vers ou a partir d'une rubrique |
|
| 263 | + // qu'on n'administre pas. |
|
| 264 | + |
|
| 265 | + if (null !== ($id_parent = $c['id_parent'])) { |
|
| 266 | + $id_parent = (int) $id_parent; |
|
| 267 | + $filles = calcul_branche_in($id_rubrique); |
|
| 268 | + if (str_contains(",$id_parent,", (string) ",$filles,")) { |
|
| 269 | + spip_logger()->info("La rubrique $id_rubrique ne peut etre fille de sa descendante $id_parent"); |
|
| 270 | + } else { |
|
| 271 | + $s = sql_fetsel('id_parent, statut', 'spip_rubriques', "id_rubrique=$id_rubrique"); |
|
| 272 | + $old_parent = $s['id_parent']; |
|
| 273 | + |
|
| 274 | + if ( |
|
| 275 | + !($id_parent != $old_parent |
|
| 276 | + && autoriser('publierdans', 'rubrique', $id_parent) |
|
| 277 | + && autoriser('creerrubriquedans', 'rubrique', $id_parent) |
|
| 278 | + && autoriser('publierdans', 'rubrique', $old_parent) |
|
| 279 | + ) |
|
| 280 | + ) { |
|
| 281 | + if ($s['statut'] != 'prepa') { |
|
| 282 | + spip_logger()->info("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 283 | + } |
|
| 284 | + } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
|
| 285 | + $statut_ancien = $s['statut']; |
|
| 286 | + sql_updateq('spip_rubriques', ['id_parent' => $id_parent], "id_rubrique=$id_rubrique"); |
|
| 287 | + |
|
| 288 | + |
|
| 289 | + propager_les_secteurs(); |
|
| 290 | + |
|
| 291 | + // Deplacement d'une rubrique publiee ==> chgt general de leur statut |
|
| 292 | + if ($statut_ancien == 'publie') { |
|
| 293 | + calculer_rubriques_if($old_parent, ['id_rubrique' => $id_parent], ['statut_ancien' => $statut_ancien]); |
|
| 294 | + } |
|
| 295 | + // Creation ou deplacement d'une rubrique non publiee |
|
| 296 | + // invalider le cache de leur menu |
|
| 297 | + elseif (!$statut_ancien || $old_parent != $id_parent) { |
|
| 298 | + effacer_meta('date_calcul_rubriques'); |
|
| 299 | + } |
|
| 300 | + |
|
| 301 | + calculer_langues_rubriques(); |
|
| 302 | + |
|
| 303 | + // Appeler une notification |
|
| 304 | + if ($notifications = charger_fonction('notifications', 'inc')) { |
|
| 305 | + $notifications( |
|
| 306 | + 'rubrique_instituer', |
|
| 307 | + $id_rubrique, |
|
| 308 | + [ |
|
| 309 | + 'statut_ancien' => $statut_ancien, |
|
| 310 | + 'id_parent_ancien' => $old_parent, |
|
| 311 | + ] |
|
| 312 | + ); |
|
| 313 | + $notifications( |
|
| 314 | + 'objet_instituer', |
|
| 315 | + $id_rubrique, |
|
| 316 | + [ |
|
| 317 | + 'objet' => 'rubrique', |
|
| 318 | + 'id_objet' => $id_rubrique, |
|
| 319 | + 'statut_ancien' => $statut_ancien, |
|
| 320 | + 'id_parent_ancien' => $old_parent, |
|
| 321 | + ] |
|
| 322 | + ); |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + } |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + return ''; // pas d'erreur |
|
| 329 | 329 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $id_rubrique, |
| 172 | 172 | [ |
| 173 | 173 | 'data' => $set, |
| 174 | - 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique') . ' ' . _T('info_numero_abbreviation') . $id_rubrique] |
|
| 174 | + 'nonvide' => ['titre' => _T('titre_nouvelle_rubrique').' '._T('info_numero_abbreviation').$id_rubrique] |
|
| 175 | 175 | ], |
| 176 | 176 | $c |
| 177 | 177 | ) |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | ) |
| 280 | 280 | ) { |
| 281 | 281 | if ($s['statut'] != 'prepa') { |
| 282 | - spip_logger()->info("deplacement de $id_rubrique vers $id_parent refuse a " . $GLOBALS['visiteur_session']['id_auteur'] . ' ' . $GLOBALS['visiteur_session']['statut']); |
|
| 282 | + spip_logger()->info("deplacement de $id_rubrique vers $id_parent refuse a ".$GLOBALS['visiteur_session']['id_auteur'].' '.$GLOBALS['visiteur_session']['statut']); |
|
| 283 | 283 | } |
| 284 | 284 | } elseif (editer_rubrique_breves($id_rubrique, $id_parent, $c)) { |
| 285 | 285 | $statut_ancien = $s['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 | /** |
@@ -27,50 +27,50 @@ discard block |
||
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | 29 | function enregistre_modif_plugin() { |
| 30 | - include_spip('inc/plugin'); |
|
| 31 | - // recuperer les plugins dans l'ordre des $_POST |
|
| 32 | - $test = []; |
|
| 33 | - foreach (liste_plugin_files() as $file) { |
|
| 34 | - $test['s' . substr(md5(_DIR_PLUGINS . $file), 0, 16)] = $file; |
|
| 35 | - } |
|
| 36 | - if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 37 | - foreach (liste_plugin_files(_DIR_PLUGINS_SUPPL) as $file) { |
|
| 38 | - $test['s' . substr(md5(_DIR_PLUGINS_SUPPL . $file), 0, 16)] = $file; |
|
| 39 | - } |
|
| 40 | - } |
|
| 30 | + include_spip('inc/plugin'); |
|
| 31 | + // recuperer les plugins dans l'ordre des $_POST |
|
| 32 | + $test = []; |
|
| 33 | + foreach (liste_plugin_files() as $file) { |
|
| 34 | + $test['s' . substr(md5(_DIR_PLUGINS . $file), 0, 16)] = $file; |
|
| 35 | + } |
|
| 36 | + if (defined('_DIR_PLUGINS_SUPPL')) { |
|
| 37 | + foreach (liste_plugin_files(_DIR_PLUGINS_SUPPL) as $file) { |
|
| 38 | + $test['s' . substr(md5(_DIR_PLUGINS_SUPPL . $file), 0, 16)] = $file; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - $plugin = []; |
|
| 42 | + $plugin = []; |
|
| 43 | 43 | |
| 44 | - foreach ($_POST as $choix => $val) { |
|
| 45 | - if (isset($test[$choix]) && $val == 'O') { |
|
| 46 | - $plugin[] = $test[$choix]; |
|
| 47 | - } |
|
| 48 | - } |
|
| 44 | + foreach ($_POST as $choix => $val) { |
|
| 45 | + if (isset($test[$choix]) && $val == 'O') { |
|
| 46 | + $plugin[] = $test[$choix]; |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - spip_logger()->info(sprintf( |
|
| 51 | - 'Changement des plugins actifs par l’auteur %s: %s', |
|
| 52 | - $GLOBALS['visiteur_session']['id_auteur'], |
|
| 53 | - implode(',', $plugin) |
|
| 54 | - )); |
|
| 55 | - ecrire_plugin_actifs($plugin); |
|
| 50 | + spip_logger()->info(sprintf( |
|
| 51 | + 'Changement des plugins actifs par l’auteur %s: %s', |
|
| 52 | + $GLOBALS['visiteur_session']['id_auteur'], |
|
| 53 | + implode(',', $plugin) |
|
| 54 | + )); |
|
| 55 | + ecrire_plugin_actifs($plugin); |
|
| 56 | 56 | |
| 57 | - // Chaque fois que l'on valide des plugins, on memorise la liste de ces plugins comme etant "interessants", avec un score initial, qui sera decremente a chaque tour : ainsi un plugin active pourra reter visible a l'ecran, jusqu'a ce qu'il tombe dans l'oubli. |
|
| 58 | - $plugins_interessants = @unserialize($GLOBALS['meta']['plugins_interessants']); |
|
| 59 | - if (!is_array($plugins_interessants)) { |
|
| 60 | - $plugins_interessants = []; |
|
| 61 | - } |
|
| 57 | + // Chaque fois que l'on valide des plugins, on memorise la liste de ces plugins comme etant "interessants", avec un score initial, qui sera decremente a chaque tour : ainsi un plugin active pourra reter visible a l'ecran, jusqu'a ce qu'il tombe dans l'oubli. |
|
| 58 | + $plugins_interessants = @unserialize($GLOBALS['meta']['plugins_interessants']); |
|
| 59 | + if (!is_array($plugins_interessants)) { |
|
| 60 | + $plugins_interessants = []; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $plugins_interessants2 = []; |
|
| 63 | + $plugins_interessants2 = []; |
|
| 64 | 64 | |
| 65 | - foreach ($plugins_interessants as $plug => $score) { |
|
| 66 | - if ($score > 1) { |
|
| 67 | - $plugins_interessants2[$plug] = $score - 1; |
|
| 68 | - } |
|
| 69 | - } |
|
| 70 | - foreach ($plugin as $plug) { |
|
| 71 | - $plugins_interessants2[$plug] = 10; |
|
| 72 | - } // score initial |
|
| 73 | - ecrire_meta('plugins_interessants', serialize($plugins_interessants2)); |
|
| 65 | + foreach ($plugins_interessants as $plug => $score) { |
|
| 66 | + if ($score > 1) { |
|
| 67 | + $plugins_interessants2[$plug] = $score - 1; |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | + foreach ($plugin as $plug) { |
|
| 71 | + $plugins_interessants2[$plug] = 10; |
|
| 72 | + } // score initial |
|
| 73 | + ecrire_meta('plugins_interessants', serialize($plugins_interessants2)); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | /** |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | function action_activer_plugins_dist() { |
| 84 | 84 | |
| 85 | - $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 86 | - $securiser_action(); |
|
| 85 | + $securiser_action = charger_fonction('securiser_action', 'inc'); |
|
| 86 | + $securiser_action(); |
|
| 87 | 87 | |
| 88 | - if (!autoriser('configurer', '_plugins')) { |
|
| 89 | - die('erreur'); |
|
| 90 | - } |
|
| 91 | - // forcer la maj des meta pour les cas de modif de numero de version base via phpmyadmin |
|
| 92 | - lire_metas(); |
|
| 93 | - enregistre_modif_plugin(); |
|
| 88 | + if (!autoriser('configurer', '_plugins')) { |
|
| 89 | + die('erreur'); |
|
| 90 | + } |
|
| 91 | + // forcer la maj des meta pour les cas de modif de numero de version base via phpmyadmin |
|
| 92 | + lire_metas(); |
|
| 93 | + enregistre_modif_plugin(); |
|
| 94 | 94 | } |
@@ -31,11 +31,11 @@ |
||
| 31 | 31 | // recuperer les plugins dans l'ordre des $_POST |
| 32 | 32 | $test = []; |
| 33 | 33 | foreach (liste_plugin_files() as $file) { |
| 34 | - $test['s' . substr(md5(_DIR_PLUGINS . $file), 0, 16)] = $file; |
|
| 34 | + $test['s'.substr(md5(_DIR_PLUGINS.$file), 0, 16)] = $file; |
|
| 35 | 35 | } |
| 36 | 36 | if (defined('_DIR_PLUGINS_SUPPL')) { |
| 37 | 37 | foreach (liste_plugin_files(_DIR_PLUGINS_SUPPL) as $file) { |
| 38 | - $test['s' . substr(md5(_DIR_PLUGINS_SUPPL . $file), 0, 16)] = $file; |
|
| 38 | + $test['s'.substr(md5(_DIR_PLUGINS_SUPPL.$file), 0, 16)] = $file; |
|
| 39 | 39 | } |
| 40 | 40 | } |
| 41 | 41 | |