@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * @package SPIP\Core\Formulaires |
| 16 | 16 | **/ |
| 17 | 17 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 18 | - return; |
|
| 18 | + return; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | |
@@ -35,25 +35,25 @@ discard block |
||
| 35 | 35 | * ($table_source,$objet,$id_objet,$objet_lien) |
| 36 | 36 | */ |
| 37 | 37 | function determine_source_lien_objet($a, $b, $c) { |
| 38 | - $table_source = $objet_lien = $objet = $id_objet = null; |
|
| 39 | - // auteurs, article, 23 : |
|
| 40 | - // associer des auteurs à l'article 23, sur la table pivot spip_auteurs_liens |
|
| 41 | - if (is_numeric($c) and !is_numeric($b)) { |
|
| 42 | - $table_source = table_objet($a); |
|
| 43 | - $objet_lien = objet_type($a); |
|
| 44 | - $objet = objet_type($b); |
|
| 45 | - $id_objet = $c; |
|
| 46 | - } |
|
| 47 | - // article, 23, auteurs |
|
| 48 | - // associer des auteurs à l'article 23, sur la table pivot spip_articles_liens |
|
| 49 | - if (is_numeric($b) and !is_numeric($c)) { |
|
| 50 | - $table_source = table_objet($c); |
|
| 51 | - $objet_lien = objet_type($a); |
|
| 52 | - $objet = objet_type($a); |
|
| 53 | - $id_objet = $b; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return array($table_source, $objet, $id_objet, $objet_lien); |
|
| 38 | + $table_source = $objet_lien = $objet = $id_objet = null; |
|
| 39 | + // auteurs, article, 23 : |
|
| 40 | + // associer des auteurs à l'article 23, sur la table pivot spip_auteurs_liens |
|
| 41 | + if (is_numeric($c) and !is_numeric($b)) { |
|
| 42 | + $table_source = table_objet($a); |
|
| 43 | + $objet_lien = objet_type($a); |
|
| 44 | + $objet = objet_type($b); |
|
| 45 | + $id_objet = $c; |
|
| 46 | + } |
|
| 47 | + // article, 23, auteurs |
|
| 48 | + // associer des auteurs à l'article 23, sur la table pivot spip_articles_liens |
|
| 49 | + if (is_numeric($b) and !is_numeric($c)) { |
|
| 50 | + $table_source = table_objet($c); |
|
| 51 | + $objet_lien = objet_type($a); |
|
| 52 | + $objet = objet_type($a); |
|
| 53 | + $id_objet = $b; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return array($table_source, $objet, $id_objet, $objet_lien); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
@@ -79,78 +79,78 @@ discard block |
||
| 79 | 79 | */ |
| 80 | 80 | function formulaires_editer_liens_charger_dist($a, $b, $c, $options = array()) { |
| 81 | 81 | |
| 82 | - // compat avec ancienne signature ou le 4eme argument est $editable |
|
| 83 | - if (!is_array($options)) { |
|
| 84 | - $options = array('editable' => $options); |
|
| 85 | - } elseif (!isset($options['editable'])) { |
|
| 86 | - $options['editable'] = true; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $editable = $options['editable']; |
|
| 90 | - |
|
| 91 | - list($table_source, $objet, $id_objet, $objet_lien) = determine_source_lien_objet($a, $b, $c); |
|
| 92 | - if (!$table_source or !$objet or !$objet_lien or !$id_objet) { |
|
| 93 | - return false; |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - $objet_source = objet_type($table_source); |
|
| 97 | - $table_sql_source = table_objet_sql($objet_source); |
|
| 98 | - |
|
| 99 | - // verifier existence de la table xxx_liens |
|
| 100 | - include_spip('action/editer_liens'); |
|
| 101 | - if (!objet_associable($objet_lien)) { |
|
| 102 | - return false; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - // L'éditabilité :) est définie par un test permanent (par exemple "associermots") ET le 4ème argument |
|
| 106 | - include_spip('inc/autoriser'); |
|
| 107 | - $editable = ($editable and autoriser('associer' . $table_source, $objet, $id_objet) |
|
| 108 | - and autoriser('modifier', $objet, $id_objet)); |
|
| 109 | - |
|
| 110 | - if (!$editable and !count(objet_trouver_liens( |
|
| 111 | - array($objet_lien => '*'), |
|
| 112 | - array(($objet_lien == $objet_source ? $objet : $objet_source) => $id_objet) |
|
| 113 | - ))) { |
|
| 114 | - return false; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - // squelettes de vue et de d'association |
|
| 118 | - // ils sont différents si des rôles sont définis. |
|
| 119 | - $skel_vue = $table_source . '_lies'; |
|
| 120 | - $skel_ajout = $table_source . '_associer'; |
|
| 121 | - |
|
| 122 | - // description des roles |
|
| 123 | - include_spip('inc/roles'); |
|
| 124 | - if ($roles = roles_presents($objet_source, $objet)) { |
|
| 125 | - // on demande de nouveaux squelettes en conséquence |
|
| 126 | - $skel_vue = $table_source . '_roles_lies'; |
|
| 127 | - $skel_ajout = $table_source . '_roles_associer'; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - $valeurs = array( |
|
| 131 | - 'id' => "$table_source-$objet-$id_objet-$objet_lien", // identifiant unique pour les id du form |
|
| 132 | - '_vue_liee' => $skel_vue, |
|
| 133 | - '_vue_ajout' => $skel_ajout, |
|
| 134 | - '_objet_lien' => $objet_lien, |
|
| 135 | - 'id_lien_ajoute' => _request('id_lien_ajoute'), |
|
| 136 | - 'objet' => $objet, |
|
| 137 | - 'id_objet' => $id_objet, |
|
| 138 | - 'objet_source' => $objet_source, |
|
| 139 | - 'table_source' => $table_source, |
|
| 140 | - 'recherche' => '', |
|
| 141 | - 'visible' => 0, |
|
| 142 | - 'ajouter_lien' => '', |
|
| 143 | - 'supprimer_lien' => '', |
|
| 144 | - 'qualifier_lien' => '', |
|
| 145 | - '_roles' => $roles, # description des roles |
|
| 146 | - '_oups' => _request('_oups'), |
|
| 147 | - 'editable' => $editable, |
|
| 148 | - ); |
|
| 149 | - |
|
| 150 | - // les options non definies dans $valeurs sont passees telles quelles au formulaire html |
|
| 151 | - $valeurs = array_merge($options, $valeurs); |
|
| 152 | - |
|
| 153 | - return $valeurs; |
|
| 82 | + // compat avec ancienne signature ou le 4eme argument est $editable |
|
| 83 | + if (!is_array($options)) { |
|
| 84 | + $options = array('editable' => $options); |
|
| 85 | + } elseif (!isset($options['editable'])) { |
|
| 86 | + $options['editable'] = true; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $editable = $options['editable']; |
|
| 90 | + |
|
| 91 | + list($table_source, $objet, $id_objet, $objet_lien) = determine_source_lien_objet($a, $b, $c); |
|
| 92 | + if (!$table_source or !$objet or !$objet_lien or !$id_objet) { |
|
| 93 | + return false; |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + $objet_source = objet_type($table_source); |
|
| 97 | + $table_sql_source = table_objet_sql($objet_source); |
|
| 98 | + |
|
| 99 | + // verifier existence de la table xxx_liens |
|
| 100 | + include_spip('action/editer_liens'); |
|
| 101 | + if (!objet_associable($objet_lien)) { |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + // L'éditabilité :) est définie par un test permanent (par exemple "associermots") ET le 4ème argument |
|
| 106 | + include_spip('inc/autoriser'); |
|
| 107 | + $editable = ($editable and autoriser('associer' . $table_source, $objet, $id_objet) |
|
| 108 | + and autoriser('modifier', $objet, $id_objet)); |
|
| 109 | + |
|
| 110 | + if (!$editable and !count(objet_trouver_liens( |
|
| 111 | + array($objet_lien => '*'), |
|
| 112 | + array(($objet_lien == $objet_source ? $objet : $objet_source) => $id_objet) |
|
| 113 | + ))) { |
|
| 114 | + return false; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + // squelettes de vue et de d'association |
|
| 118 | + // ils sont différents si des rôles sont définis. |
|
| 119 | + $skel_vue = $table_source . '_lies'; |
|
| 120 | + $skel_ajout = $table_source . '_associer'; |
|
| 121 | + |
|
| 122 | + // description des roles |
|
| 123 | + include_spip('inc/roles'); |
|
| 124 | + if ($roles = roles_presents($objet_source, $objet)) { |
|
| 125 | + // on demande de nouveaux squelettes en conséquence |
|
| 126 | + $skel_vue = $table_source . '_roles_lies'; |
|
| 127 | + $skel_ajout = $table_source . '_roles_associer'; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + $valeurs = array( |
|
| 131 | + 'id' => "$table_source-$objet-$id_objet-$objet_lien", // identifiant unique pour les id du form |
|
| 132 | + '_vue_liee' => $skel_vue, |
|
| 133 | + '_vue_ajout' => $skel_ajout, |
|
| 134 | + '_objet_lien' => $objet_lien, |
|
| 135 | + 'id_lien_ajoute' => _request('id_lien_ajoute'), |
|
| 136 | + 'objet' => $objet, |
|
| 137 | + 'id_objet' => $id_objet, |
|
| 138 | + 'objet_source' => $objet_source, |
|
| 139 | + 'table_source' => $table_source, |
|
| 140 | + 'recherche' => '', |
|
| 141 | + 'visible' => 0, |
|
| 142 | + 'ajouter_lien' => '', |
|
| 143 | + 'supprimer_lien' => '', |
|
| 144 | + 'qualifier_lien' => '', |
|
| 145 | + '_roles' => $roles, # description des roles |
|
| 146 | + '_oups' => _request('_oups'), |
|
| 147 | + 'editable' => $editable, |
|
| 148 | + ); |
|
| 149 | + |
|
| 150 | + // les options non definies dans $valeurs sont passees telles quelles au formulaire html |
|
| 151 | + $valeurs = array_merge($options, $valeurs); |
|
| 152 | + |
|
| 153 | + return $valeurs; |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | /** |
@@ -187,136 +187,136 @@ discard block |
||
| 187 | 187 | * @return array |
| 188 | 188 | */ |
| 189 | 189 | function formulaires_editer_liens_traiter_dist($a, $b, $c, $options = array()) { |
| 190 | - // compat avec ancienne signature ou le 4eme argument est $editable |
|
| 191 | - if (!is_array($options)) { |
|
| 192 | - $options = array('editable' => $options); |
|
| 193 | - } elseif (!isset($options['editable'])) { |
|
| 194 | - $options['editable'] = true; |
|
| 195 | - } |
|
| 196 | - |
|
| 197 | - $editable = $options['editable']; |
|
| 198 | - |
|
| 199 | - $res = array('editable' => $editable ? true : false); |
|
| 200 | - list($table_source, $objet, $id_objet, $objet_lien) = determine_source_lien_objet($a, $b, $c); |
|
| 201 | - if (!$table_source or !$objet or !$objet_lien) { |
|
| 202 | - return $res; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - |
|
| 206 | - if (_request('tout_voir')) { |
|
| 207 | - set_request('recherche', ''); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - include_spip('inc/autoriser'); |
|
| 211 | - if (autoriser('modifier', $objet, $id_objet)) { |
|
| 212 | - // annuler les suppressions du coup d'avant ! |
|
| 213 | - if (_request('annuler_oups') |
|
| 214 | - and $oups = _request('_oups') |
|
| 215 | - and $oups = unserialize($oups) |
|
| 216 | - ) { |
|
| 217 | - if ($oups_objets = charger_fonction("editer_liens_oups_{$table_source}_{$objet}_{$objet_lien}", 'action', true)) { |
|
| 218 | - $oups_objets($oups); |
|
| 219 | - } else { |
|
| 220 | - $objet_source = objet_type($table_source); |
|
| 221 | - include_spip('action/editer_liens'); |
|
| 222 | - foreach ($oups as $oup) { |
|
| 223 | - if ($objet_lien == $objet_source) { |
|
| 224 | - objet_associer(array($objet_source => $oup[$objet_source]), array($objet => $oup[$objet]), $oup); |
|
| 225 | - } else { |
|
| 226 | - objet_associer(array($objet => $oup[$objet]), array($objet_source => $oup[$objet_source]), $oup); |
|
| 227 | - } |
|
| 228 | - } |
|
| 229 | - } |
|
| 230 | - # oups ne persiste que pour la derniere action, si suppression |
|
| 231 | - set_request('_oups'); |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - $supprimer = _request('supprimer_lien'); |
|
| 235 | - $ajouter = _request('ajouter_lien'); |
|
| 236 | - |
|
| 237 | - // il est possible de preciser dans une seule variable un remplacement : |
|
| 238 | - // remplacer_lien[old][new] |
|
| 239 | - if ($remplacer = _request('remplacer_lien')) { |
|
| 240 | - foreach ($remplacer as $k => $v) { |
|
| 241 | - if ($old = lien_verifier_action($k, '')) { |
|
| 242 | - foreach (is_array($v) ? $v : array($v) as $kn => $vn) { |
|
| 243 | - if ($new = lien_verifier_action($kn, $vn)) { |
|
| 244 | - $supprimer[$old] = 'x'; |
|
| 245 | - $ajouter[$new] = '+'; |
|
| 246 | - } |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - if ($supprimer) { |
|
| 253 | - if ($supprimer_objets = charger_fonction( |
|
| 254 | - "editer_liens_supprimer_{$table_source}_{$objet}_{$objet_lien}", |
|
| 255 | - 'action', |
|
| 256 | - true |
|
| 257 | - )) { |
|
| 258 | - $oups = $supprimer_objets($supprimer); |
|
| 259 | - } else { |
|
| 260 | - include_spip('action/editer_liens'); |
|
| 261 | - $oups = array(); |
|
| 262 | - |
|
| 263 | - foreach ($supprimer as $k => $v) { |
|
| 264 | - if ($lien = lien_verifier_action($k, $v)) { |
|
| 265 | - $lien = explode('-', $lien); |
|
| 266 | - list($objet_source, $ids, $objet_lie, $idl, $role) = $lien; |
|
| 267 | - // appliquer une condition sur le rôle si défini ('*' pour tous les roles) |
|
| 268 | - $cond = (!is_null($role) ? array('role' => $role) : array()); |
|
| 269 | - if ($objet_lien == $objet_source) { |
|
| 270 | - $oups = array_merge( |
|
| 271 | - $oups, |
|
| 272 | - objet_trouver_liens(array($objet_source => $ids), array($objet_lie => $idl), $cond) |
|
| 273 | - ); |
|
| 274 | - objet_dissocier(array($objet_source => $ids), array($objet_lie => $idl), $cond); |
|
| 275 | - } else { |
|
| 276 | - $oups = array_merge( |
|
| 277 | - $oups, |
|
| 278 | - objet_trouver_liens(array($objet_lie => $idl), array($objet_source => $ids), $cond) |
|
| 279 | - ); |
|
| 280 | - objet_dissocier(array($objet_lie => $idl), array($objet_source => $ids), $cond); |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - set_request('_oups', $oups ? serialize($oups) : null); |
|
| 286 | - } |
|
| 287 | - |
|
| 288 | - if ($ajouter) { |
|
| 289 | - if ($ajouter_objets = charger_fonction("editer_liens_ajouter_{$table_source}_{$objet}_{$objet_lien}", 'action', true) |
|
| 290 | - ) { |
|
| 291 | - $ajout_ok = $ajouter_objets($ajouter); |
|
| 292 | - } else { |
|
| 293 | - $ajout_ok = false; |
|
| 294 | - include_spip('action/editer_liens'); |
|
| 295 | - foreach ($ajouter as $k => $v) { |
|
| 296 | - if ($lien = lien_verifier_action($k, $v)) { |
|
| 297 | - $ajout_ok = true; |
|
| 298 | - list($objet1, $ids, $objet2, $idl) = explode('-', $lien); |
|
| 299 | - $qualifs = lien_retrouver_qualif($objet_lien, $lien); |
|
| 300 | - if ($objet_lien == $objet1) { |
|
| 301 | - lien_ajouter_liaisons($objet1, $ids, $objet2, $idl, $qualifs); |
|
| 302 | - } else { |
|
| 303 | - lien_ajouter_liaisons($objet2, $idl, $objet1, $ids, $qualifs); |
|
| 304 | - } |
|
| 305 | - set_request('id_lien_ajoute', $ids); |
|
| 306 | - } |
|
| 307 | - } |
|
| 308 | - } |
|
| 309 | - # oups ne persiste que pour la derniere action, si suppression |
|
| 310 | - # une suppression suivie d'un ajout dans le meme hit est un remplacement |
|
| 311 | - # non annulable ! |
|
| 312 | - if ($ajout_ok) { |
|
| 313 | - set_request('_oups'); |
|
| 314 | - } |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - |
|
| 319 | - return $res; |
|
| 190 | + // compat avec ancienne signature ou le 4eme argument est $editable |
|
| 191 | + if (!is_array($options)) { |
|
| 192 | + $options = array('editable' => $options); |
|
| 193 | + } elseif (!isset($options['editable'])) { |
|
| 194 | + $options['editable'] = true; |
|
| 195 | + } |
|
| 196 | + |
|
| 197 | + $editable = $options['editable']; |
|
| 198 | + |
|
| 199 | + $res = array('editable' => $editable ? true : false); |
|
| 200 | + list($table_source, $objet, $id_objet, $objet_lien) = determine_source_lien_objet($a, $b, $c); |
|
| 201 | + if (!$table_source or !$objet or !$objet_lien) { |
|
| 202 | + return $res; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + |
|
| 206 | + if (_request('tout_voir')) { |
|
| 207 | + set_request('recherche', ''); |
|
| 208 | + } |
|
| 209 | + |
|
| 210 | + include_spip('inc/autoriser'); |
|
| 211 | + if (autoriser('modifier', $objet, $id_objet)) { |
|
| 212 | + // annuler les suppressions du coup d'avant ! |
|
| 213 | + if (_request('annuler_oups') |
|
| 214 | + and $oups = _request('_oups') |
|
| 215 | + and $oups = unserialize($oups) |
|
| 216 | + ) { |
|
| 217 | + if ($oups_objets = charger_fonction("editer_liens_oups_{$table_source}_{$objet}_{$objet_lien}", 'action', true)) { |
|
| 218 | + $oups_objets($oups); |
|
| 219 | + } else { |
|
| 220 | + $objet_source = objet_type($table_source); |
|
| 221 | + include_spip('action/editer_liens'); |
|
| 222 | + foreach ($oups as $oup) { |
|
| 223 | + if ($objet_lien == $objet_source) { |
|
| 224 | + objet_associer(array($objet_source => $oup[$objet_source]), array($objet => $oup[$objet]), $oup); |
|
| 225 | + } else { |
|
| 226 | + objet_associer(array($objet => $oup[$objet]), array($objet_source => $oup[$objet_source]), $oup); |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | + } |
|
| 230 | + # oups ne persiste que pour la derniere action, si suppression |
|
| 231 | + set_request('_oups'); |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + $supprimer = _request('supprimer_lien'); |
|
| 235 | + $ajouter = _request('ajouter_lien'); |
|
| 236 | + |
|
| 237 | + // il est possible de preciser dans une seule variable un remplacement : |
|
| 238 | + // remplacer_lien[old][new] |
|
| 239 | + if ($remplacer = _request('remplacer_lien')) { |
|
| 240 | + foreach ($remplacer as $k => $v) { |
|
| 241 | + if ($old = lien_verifier_action($k, '')) { |
|
| 242 | + foreach (is_array($v) ? $v : array($v) as $kn => $vn) { |
|
| 243 | + if ($new = lien_verifier_action($kn, $vn)) { |
|
| 244 | + $supprimer[$old] = 'x'; |
|
| 245 | + $ajouter[$new] = '+'; |
|
| 246 | + } |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + if ($supprimer) { |
|
| 253 | + if ($supprimer_objets = charger_fonction( |
|
| 254 | + "editer_liens_supprimer_{$table_source}_{$objet}_{$objet_lien}", |
|
| 255 | + 'action', |
|
| 256 | + true |
|
| 257 | + )) { |
|
| 258 | + $oups = $supprimer_objets($supprimer); |
|
| 259 | + } else { |
|
| 260 | + include_spip('action/editer_liens'); |
|
| 261 | + $oups = array(); |
|
| 262 | + |
|
| 263 | + foreach ($supprimer as $k => $v) { |
|
| 264 | + if ($lien = lien_verifier_action($k, $v)) { |
|
| 265 | + $lien = explode('-', $lien); |
|
| 266 | + list($objet_source, $ids, $objet_lie, $idl, $role) = $lien; |
|
| 267 | + // appliquer une condition sur le rôle si défini ('*' pour tous les roles) |
|
| 268 | + $cond = (!is_null($role) ? array('role' => $role) : array()); |
|
| 269 | + if ($objet_lien == $objet_source) { |
|
| 270 | + $oups = array_merge( |
|
| 271 | + $oups, |
|
| 272 | + objet_trouver_liens(array($objet_source => $ids), array($objet_lie => $idl), $cond) |
|
| 273 | + ); |
|
| 274 | + objet_dissocier(array($objet_source => $ids), array($objet_lie => $idl), $cond); |
|
| 275 | + } else { |
|
| 276 | + $oups = array_merge( |
|
| 277 | + $oups, |
|
| 278 | + objet_trouver_liens(array($objet_lie => $idl), array($objet_source => $ids), $cond) |
|
| 279 | + ); |
|
| 280 | + objet_dissocier(array($objet_lie => $idl), array($objet_source => $ids), $cond); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + set_request('_oups', $oups ? serialize($oups) : null); |
|
| 286 | + } |
|
| 287 | + |
|
| 288 | + if ($ajouter) { |
|
| 289 | + if ($ajouter_objets = charger_fonction("editer_liens_ajouter_{$table_source}_{$objet}_{$objet_lien}", 'action', true) |
|
| 290 | + ) { |
|
| 291 | + $ajout_ok = $ajouter_objets($ajouter); |
|
| 292 | + } else { |
|
| 293 | + $ajout_ok = false; |
|
| 294 | + include_spip('action/editer_liens'); |
|
| 295 | + foreach ($ajouter as $k => $v) { |
|
| 296 | + if ($lien = lien_verifier_action($k, $v)) { |
|
| 297 | + $ajout_ok = true; |
|
| 298 | + list($objet1, $ids, $objet2, $idl) = explode('-', $lien); |
|
| 299 | + $qualifs = lien_retrouver_qualif($objet_lien, $lien); |
|
| 300 | + if ($objet_lien == $objet1) { |
|
| 301 | + lien_ajouter_liaisons($objet1, $ids, $objet2, $idl, $qualifs); |
|
| 302 | + } else { |
|
| 303 | + lien_ajouter_liaisons($objet2, $idl, $objet1, $ids, $qualifs); |
|
| 304 | + } |
|
| 305 | + set_request('id_lien_ajoute', $ids); |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | + # oups ne persiste que pour la derniere action, si suppression |
|
| 310 | + # une suppression suivie d'un ajout dans le meme hit est un remplacement |
|
| 311 | + # non annulable ! |
|
| 312 | + if ($ajout_ok) { |
|
| 313 | + set_request('_oups'); |
|
| 314 | + } |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + |
|
| 319 | + return $res; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | |
@@ -339,24 +339,24 @@ discard block |
||
| 339 | 339 | * @return string Action demandée si trouvée, sinon '' |
| 340 | 340 | */ |
| 341 | 341 | function lien_verifier_action($k, $v) { |
| 342 | - $action = ''; |
|
| 343 | - if (preg_match(',^\w+-[\w*]+-[\w*]+-[\w*]+(-[\w*])?,', $k)) { |
|
| 344 | - $action = $k; |
|
| 345 | - } |
|
| 346 | - if (preg_match(',^\w+-[\w*]+-[\w*]+-[\w*]+(-[\w*])?,', $v)) { |
|
| 347 | - if (is_numeric($k)) { |
|
| 348 | - $action = $v; |
|
| 349 | - } |
|
| 350 | - if (_request($k)) { |
|
| 351 | - $action = $v; |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - // ajout un role null fictif (plus pratique) si pas défini |
|
| 355 | - if ($action and count(explode('-', $action)) == 4) { |
|
| 356 | - $action .= '-'; |
|
| 357 | - } |
|
| 358 | - |
|
| 359 | - return $action; |
|
| 342 | + $action = ''; |
|
| 343 | + if (preg_match(',^\w+-[\w*]+-[\w*]+-[\w*]+(-[\w*])?,', $k)) { |
|
| 344 | + $action = $k; |
|
| 345 | + } |
|
| 346 | + if (preg_match(',^\w+-[\w*]+-[\w*]+-[\w*]+(-[\w*])?,', $v)) { |
|
| 347 | + if (is_numeric($k)) { |
|
| 348 | + $action = $v; |
|
| 349 | + } |
|
| 350 | + if (_request($k)) { |
|
| 351 | + $action = $v; |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + // ajout un role null fictif (plus pratique) si pas défini |
|
| 355 | + if ($action and count(explode('-', $action)) == 4) { |
|
| 356 | + $action .= '-'; |
|
| 357 | + } |
|
| 358 | + |
|
| 359 | + return $action; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | |
@@ -372,65 +372,65 @@ discard block |
||
| 372 | 372 | * Liste des qualifs pour chaque lien. Tableau vide s'il n'y en a pas. |
| 373 | 373 | **/ |
| 374 | 374 | function lien_retrouver_qualif($objet_lien, $lien) { |
| 375 | - // un role est défini dans la liaison |
|
| 376 | - $defs = explode('-', $lien); |
|
| 377 | - list($objet1, , $objet2, , $role) = $defs; |
|
| 378 | - if ($objet_lien == $objet1) { |
|
| 379 | - $colonne_role = roles_colonne($objet1, $objet2); |
|
| 380 | - } else { |
|
| 381 | - $colonne_role = roles_colonne($objet2, $objet1); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - // cas ou le role est defini en 5e argument de l'action sur le lien (suppression, ajout rapide sans autre attribut) |
|
| 385 | - if ($role) { |
|
| 386 | - return array( |
|
| 387 | - // un seul lien avec ce role |
|
| 388 | - array($colonne_role => $role) |
|
| 389 | - ); |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - // retrouver les rôles postés pour cette liaison, s'il y en a. |
|
| 393 | - $qualifier_lien = _request('qualifier_lien'); |
|
| 394 | - if (!$qualifier_lien or !is_array($qualifier_lien)) { |
|
| 395 | - return array(); |
|
| 396 | - } |
|
| 397 | - |
|
| 398 | - // pas avec l'action complete (incluant le role) |
|
| 399 | - $qualif = array(); |
|
| 400 | - if ((!isset($qualifier_lien[$lien]) or !$qualif = $qualifier_lien[$lien]) |
|
| 401 | - and count($defs) == 5 |
|
| 402 | - ) { |
|
| 403 | - // on tente avec l'action sans le role |
|
| 404 | - array_pop($defs); |
|
| 405 | - $lien = implode('-', $defs); |
|
| 406 | - if (!isset($qualifier_lien[$lien]) or !$qualif = $qualifier_lien[$lien]) { |
|
| 407 | - $qualif = array(); |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - // $qualif de la forme array(role=>array(...),valeur=>array(...),....) |
|
| 412 | - // on le reforme en array(array(role=>..,valeur=>..,..),array(role=>..,valeur=>..,..),...) |
|
| 413 | - $qualifs = array(); |
|
| 414 | - while (count($qualif)) { |
|
| 415 | - $q = array(); |
|
| 416 | - foreach ($qualif as $att => $values) { |
|
| 417 | - if (is_array($values)) { |
|
| 418 | - $q[$att] = array_shift($qualif[$att]); |
|
| 419 | - if (!count($qualif[$att])) { |
|
| 420 | - unset($qualif[$att]); |
|
| 421 | - } |
|
| 422 | - } else { |
|
| 423 | - $q[$att] = $values; |
|
| 424 | - unset($qualif[$att]); |
|
| 425 | - } |
|
| 426 | - } |
|
| 427 | - // pas de rôle vide |
|
| 428 | - if (!$colonne_role or !isset($q[$colonne_role]) or $q[$colonne_role]) { |
|
| 429 | - $qualifs[] = $q; |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - return $qualifs; |
|
| 375 | + // un role est défini dans la liaison |
|
| 376 | + $defs = explode('-', $lien); |
|
| 377 | + list($objet1, , $objet2, , $role) = $defs; |
|
| 378 | + if ($objet_lien == $objet1) { |
|
| 379 | + $colonne_role = roles_colonne($objet1, $objet2); |
|
| 380 | + } else { |
|
| 381 | + $colonne_role = roles_colonne($objet2, $objet1); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + // cas ou le role est defini en 5e argument de l'action sur le lien (suppression, ajout rapide sans autre attribut) |
|
| 385 | + if ($role) { |
|
| 386 | + return array( |
|
| 387 | + // un seul lien avec ce role |
|
| 388 | + array($colonne_role => $role) |
|
| 389 | + ); |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + // retrouver les rôles postés pour cette liaison, s'il y en a. |
|
| 393 | + $qualifier_lien = _request('qualifier_lien'); |
|
| 394 | + if (!$qualifier_lien or !is_array($qualifier_lien)) { |
|
| 395 | + return array(); |
|
| 396 | + } |
|
| 397 | + |
|
| 398 | + // pas avec l'action complete (incluant le role) |
|
| 399 | + $qualif = array(); |
|
| 400 | + if ((!isset($qualifier_lien[$lien]) or !$qualif = $qualifier_lien[$lien]) |
|
| 401 | + and count($defs) == 5 |
|
| 402 | + ) { |
|
| 403 | + // on tente avec l'action sans le role |
|
| 404 | + array_pop($defs); |
|
| 405 | + $lien = implode('-', $defs); |
|
| 406 | + if (!isset($qualifier_lien[$lien]) or !$qualif = $qualifier_lien[$lien]) { |
|
| 407 | + $qualif = array(); |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + // $qualif de la forme array(role=>array(...),valeur=>array(...),....) |
|
| 412 | + // on le reforme en array(array(role=>..,valeur=>..,..),array(role=>..,valeur=>..,..),...) |
|
| 413 | + $qualifs = array(); |
|
| 414 | + while (count($qualif)) { |
|
| 415 | + $q = array(); |
|
| 416 | + foreach ($qualif as $att => $values) { |
|
| 417 | + if (is_array($values)) { |
|
| 418 | + $q[$att] = array_shift($qualif[$att]); |
|
| 419 | + if (!count($qualif[$att])) { |
|
| 420 | + unset($qualif[$att]); |
|
| 421 | + } |
|
| 422 | + } else { |
|
| 423 | + $q[$att] = $values; |
|
| 424 | + unset($qualif[$att]); |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | + // pas de rôle vide |
|
| 428 | + if (!$colonne_role or !isset($q[$colonne_role]) or $q[$colonne_role]) { |
|
| 429 | + $qualifs[] = $q; |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + return $qualifs; |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | /** |
@@ -449,12 +449,12 @@ discard block |
||
| 449 | 449 | **/ |
| 450 | 450 | function lien_ajouter_liaisons($objet_source, $ids, $objet_lien, $idl, $qualifs) { |
| 451 | 451 | |
| 452 | - // retrouver la colonne de roles s'il y en a a lier |
|
| 453 | - if (is_array($qualifs) and count($qualifs)) { |
|
| 454 | - foreach ($qualifs as $qualif) { |
|
| 455 | - objet_associer(array($objet_source => $ids), array($objet_lien => $idl), $qualif); |
|
| 456 | - } |
|
| 457 | - } else { |
|
| 458 | - objet_associer(array($objet_source => $ids), array($objet_lien => $idl)); |
|
| 459 | - } |
|
| 452 | + // retrouver la colonne de roles s'il y en a a lier |
|
| 453 | + if (is_array($qualifs) and count($qualifs)) { |
|
| 454 | + foreach ($qualifs as $qualif) { |
|
| 455 | + objet_associer(array($objet_source => $ids), array($objet_lien => $idl), $qualif); |
|
| 456 | + } |
|
| 457 | + } else { |
|
| 458 | + objet_associer(array($objet_source => $ids), array($objet_lien => $idl)); |
|
| 459 | + } |
|
| 460 | 460 | } |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | |
| 105 | 105 | // L'éditabilité :) est définie par un test permanent (par exemple "associermots") ET le 4ème argument |
| 106 | 106 | include_spip('inc/autoriser'); |
| 107 | - $editable = ($editable and autoriser('associer' . $table_source, $objet, $id_objet) |
|
| 107 | + $editable = ($editable and autoriser('associer'.$table_source, $objet, $id_objet) |
|
| 108 | 108 | and autoriser('modifier', $objet, $id_objet)); |
| 109 | 109 | |
| 110 | 110 | if (!$editable and !count(objet_trouver_liens( |
@@ -116,15 +116,15 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | // squelettes de vue et de d'association |
| 118 | 118 | // ils sont différents si des rôles sont définis. |
| 119 | - $skel_vue = $table_source . '_lies'; |
|
| 120 | - $skel_ajout = $table_source . '_associer'; |
|
| 119 | + $skel_vue = $table_source.'_lies'; |
|
| 120 | + $skel_ajout = $table_source.'_associer'; |
|
| 121 | 121 | |
| 122 | 122 | // description des roles |
| 123 | 123 | include_spip('inc/roles'); |
| 124 | 124 | if ($roles = roles_presents($objet_source, $objet)) { |
| 125 | 125 | // on demande de nouveaux squelettes en conséquence |
| 126 | - $skel_vue = $table_source . '_roles_lies'; |
|
| 127 | - $skel_ajout = $table_source . '_roles_associer'; |
|
| 126 | + $skel_vue = $table_source.'_roles_lies'; |
|
| 127 | + $skel_ajout = $table_source.'_roles_associer'; |
|
| 128 | 128 | } |
| 129 | 129 | |
| 130 | 130 | $valeurs = array( |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | function lien_retrouver_qualif($objet_lien, $lien) { |
| 375 | 375 | // un role est défini dans la liaison |
| 376 | 376 | $defs = explode('-', $lien); |
| 377 | - list($objet1, , $objet2, , $role) = $defs; |
|
| 377 | + list($objet1,, $objet2,, $role) = $defs; |
|
| 378 | 378 | if ($objet_lien == $objet1) { |
| 379 | 379 | $colonne_role = roles_colonne($objet1, $objet2); |
| 380 | 380 | } else { |
@@ -11,34 +11,34 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_logos_charger_dist() { |
| 18 | - $valeurs = array(); |
|
| 19 | - foreach (array( |
|
| 20 | - 'activer_logos', |
|
| 21 | - 'activer_logos_survol' |
|
| 22 | - ) as $m) { |
|
| 23 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - return $valeurs; |
|
| 18 | + $valeurs = array(); |
|
| 19 | + foreach (array( |
|
| 20 | + 'activer_logos', |
|
| 21 | + 'activer_logos_survol' |
|
| 22 | + ) as $m) { |
|
| 23 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + return $valeurs; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | function formulaires_configurer_logos_traiter_dist() { |
| 31 | - $res = array('editable' => true); |
|
| 32 | - foreach (array( |
|
| 33 | - 'activer_logos', |
|
| 34 | - 'activer_logos_survol', |
|
| 35 | - ) as $m) { |
|
| 36 | - if (!is_null($v = _request($m))) { |
|
| 37 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 42 | - |
|
| 43 | - return $res; |
|
| 31 | + $res = array('editable' => true); |
|
| 32 | + foreach (array( |
|
| 33 | + 'activer_logos', |
|
| 34 | + 'activer_logos_survol', |
|
| 35 | + ) as $m) { |
|
| 36 | + if (!is_null($v = _request($m))) { |
|
| 37 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 42 | + |
|
| 43 | + return $res; |
|
| 44 | 44 | } |
@@ -11,34 +11,34 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_rubriques_charger_dist() { |
| 18 | - $valeurs = array(); |
|
| 19 | - foreach (array( |
|
| 20 | - 'rubriques_descriptif', |
|
| 21 | - 'rubriques_texte' |
|
| 22 | - ) as $m) { |
|
| 23 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - return $valeurs; |
|
| 18 | + $valeurs = array(); |
|
| 19 | + foreach (array( |
|
| 20 | + 'rubriques_descriptif', |
|
| 21 | + 'rubriques_texte' |
|
| 22 | + ) as $m) { |
|
| 23 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + return $valeurs; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | function formulaires_configurer_rubriques_traiter_dist() { |
| 31 | - $res = array('editable' => true); |
|
| 32 | - foreach (array( |
|
| 33 | - 'rubriques_descriptif', |
|
| 34 | - 'rubriques_texte' |
|
| 35 | - ) as $m) { |
|
| 36 | - if (!is_null($v = _request($m))) { |
|
| 37 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 42 | - |
|
| 43 | - return $res; |
|
| 31 | + $res = array('editable' => true); |
|
| 32 | + foreach (array( |
|
| 33 | + 'rubriques_descriptif', |
|
| 34 | + 'rubriques_texte' |
|
| 35 | + ) as $m) { |
|
| 36 | + if (!is_null($v = _request($m))) { |
|
| 37 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 42 | + |
|
| 43 | + return $res; |
|
| 44 | 44 | } |
@@ -11,61 +11,61 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_articles_charger_dist() { |
| 18 | - $valeurs = array(); |
|
| 19 | - foreach (array( |
|
| 20 | - 'articles_surtitre', |
|
| 21 | - 'articles_soustitre', |
|
| 22 | - 'articles_descriptif', |
|
| 23 | - 'articles_chapeau', |
|
| 24 | - 'articles_texte', |
|
| 25 | - 'articles_ps', |
|
| 26 | - 'articles_redac', |
|
| 27 | - 'articles_urlref', |
|
| 28 | - 'post_dates', |
|
| 29 | - 'articles_redirection', |
|
| 30 | - ) as $m) { |
|
| 31 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 32 | - } |
|
| 18 | + $valeurs = array(); |
|
| 19 | + foreach (array( |
|
| 20 | + 'articles_surtitre', |
|
| 21 | + 'articles_soustitre', |
|
| 22 | + 'articles_descriptif', |
|
| 23 | + 'articles_chapeau', |
|
| 24 | + 'articles_texte', |
|
| 25 | + 'articles_ps', |
|
| 26 | + 'articles_redac', |
|
| 27 | + 'articles_urlref', |
|
| 28 | + 'post_dates', |
|
| 29 | + 'articles_redirection', |
|
| 30 | + ) as $m) { |
|
| 31 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - return $valeurs; |
|
| 34 | + return $valeurs; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | function formulaires_configurer_articles_traiter_dist() { |
| 39 | - $res = array('editable' => true); |
|
| 40 | - $purger_skel = false; |
|
| 41 | - // Purger les squelettes si un changement de meta les affecte |
|
| 42 | - if ($i = _request('post_dates') and ($i != $GLOBALS['meta']['post_dates'])) { |
|
| 43 | - $purger_skel = true; |
|
| 44 | - } |
|
| 39 | + $res = array('editable' => true); |
|
| 40 | + $purger_skel = false; |
|
| 41 | + // Purger les squelettes si un changement de meta les affecte |
|
| 42 | + if ($i = _request('post_dates') and ($i != $GLOBALS['meta']['post_dates'])) { |
|
| 43 | + $purger_skel = true; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - foreach (array( |
|
| 47 | - 'articles_surtitre', |
|
| 48 | - 'articles_soustitre', |
|
| 49 | - 'articles_descriptif', |
|
| 50 | - 'articles_chapeau', |
|
| 51 | - 'articles_texte', |
|
| 52 | - 'articles_ps', |
|
| 53 | - 'articles_redac', |
|
| 54 | - 'articles_urlref', |
|
| 55 | - 'post_dates', |
|
| 56 | - 'articles_redirection', |
|
| 57 | - ) as $m) { |
|
| 58 | - if (!is_null($v = _request($m))) { |
|
| 59 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 60 | - } |
|
| 61 | - } |
|
| 46 | + foreach (array( |
|
| 47 | + 'articles_surtitre', |
|
| 48 | + 'articles_soustitre', |
|
| 49 | + 'articles_descriptif', |
|
| 50 | + 'articles_chapeau', |
|
| 51 | + 'articles_texte', |
|
| 52 | + 'articles_ps', |
|
| 53 | + 'articles_redac', |
|
| 54 | + 'articles_urlref', |
|
| 55 | + 'post_dates', |
|
| 56 | + 'articles_redirection', |
|
| 57 | + ) as $m) { |
|
| 58 | + if (!is_null($v = _request($m))) { |
|
| 59 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - if ($purger_skel) { |
|
| 64 | - include_spip('inc/invalideur'); |
|
| 65 | - purger_repertoire(_DIR_SKELS); |
|
| 66 | - } |
|
| 63 | + if ($purger_skel) { |
|
| 64 | + include_spip('inc/invalideur'); |
|
| 65 | + purger_repertoire(_DIR_SKELS); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 68 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 69 | 69 | |
| 70 | - return $res; |
|
| 70 | + return $res; |
|
| 71 | 71 | } |
@@ -11,64 +11,64 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_rediriger_article_charger_dist($id_article, $retour = '') { |
| 18 | 18 | |
| 19 | - include_spip('inc/autoriser'); |
|
| 20 | - if (!autoriser('modifier', 'article', $id_article)) { |
|
| 21 | - return false; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - $row = sql_fetsel('id_article,virtuel', 'spip_articles', 'id_article=' . intval($id_article)); |
|
| 25 | - if (!$row['id_article']) { |
|
| 26 | - return false; |
|
| 27 | - } |
|
| 28 | - include_spip('inc/lien'); |
|
| 29 | - $redirection = virtuel_redirige($row['virtuel']); |
|
| 30 | - |
|
| 31 | - if (!$redirection |
|
| 32 | - and $GLOBALS['meta']['articles_redirection'] != 'oui' |
|
| 33 | - ) { |
|
| 34 | - return false; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - include_spip('inc/texte'); |
|
| 39 | - $valeurs = array( |
|
| 40 | - 'redirection' => $redirection, |
|
| 41 | - 'id' => $id_article, |
|
| 42 | - '_afficher_url' => ($redirection ? propre("[->$redirection]") : ''), |
|
| 43 | - ); |
|
| 44 | - |
|
| 45 | - return $valeurs; |
|
| 19 | + include_spip('inc/autoriser'); |
|
| 20 | + if (!autoriser('modifier', 'article', $id_article)) { |
|
| 21 | + return false; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + $row = sql_fetsel('id_article,virtuel', 'spip_articles', 'id_article=' . intval($id_article)); |
|
| 25 | + if (!$row['id_article']) { |
|
| 26 | + return false; |
|
| 27 | + } |
|
| 28 | + include_spip('inc/lien'); |
|
| 29 | + $redirection = virtuel_redirige($row['virtuel']); |
|
| 30 | + |
|
| 31 | + if (!$redirection |
|
| 32 | + and $GLOBALS['meta']['articles_redirection'] != 'oui' |
|
| 33 | + ) { |
|
| 34 | + return false; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + include_spip('inc/texte'); |
|
| 39 | + $valeurs = array( |
|
| 40 | + 'redirection' => $redirection, |
|
| 41 | + 'id' => $id_article, |
|
| 42 | + '_afficher_url' => ($redirection ? propre("[->$redirection]") : ''), |
|
| 43 | + ); |
|
| 44 | + |
|
| 45 | + return $valeurs; |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | function formulaires_rediriger_article_verifier_dist($id_article, $retour = '') { |
| 49 | - $erreurs = array(); |
|
| 49 | + $erreurs = array(); |
|
| 50 | 50 | |
| 51 | - if (($redirection = _request('redirection')) == $id_article || $redirection == 'art' . $id_article) { |
|
| 52 | - $erreurs['redirection'] = _T('info_redirection_boucle'); |
|
| 53 | - } |
|
| 51 | + if (($redirection = _request('redirection')) == $id_article || $redirection == 'art' . $id_article) { |
|
| 52 | + $erreurs['redirection'] = _T('info_redirection_boucle'); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - return $erreurs; |
|
| 55 | + return $erreurs; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | function formulaires_rediriger_article_traiter_dist($id_article, $retour = '') { |
| 59 | 59 | |
| 60 | - $url = preg_replace(',^\s*https?://$,i', '', rtrim(_request('redirection'))); |
|
| 61 | - if ($url) { |
|
| 62 | - $url = corriger_caracteres($url); |
|
| 63 | - } |
|
| 60 | + $url = preg_replace(',^\s*https?://$,i', '', rtrim(_request('redirection'))); |
|
| 61 | + if ($url) { |
|
| 62 | + $url = corriger_caracteres($url); |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - include_spip('action/editer_article'); |
|
| 66 | - articles_set($id_article, array('virtuel' => $url)); |
|
| 65 | + include_spip('action/editer_article'); |
|
| 66 | + articles_set($id_article, array('virtuel' => $url)); |
|
| 67 | 67 | |
| 68 | - $js = _AJAX ? '<script type="text/javascript">if (window.ajaxReload) ajaxReload("wysiwyg");</script>' : ''; |
|
| 68 | + $js = _AJAX ? '<script type="text/javascript">if (window.ajaxReload) ajaxReload("wysiwyg");</script>' : ''; |
|
| 69 | 69 | |
| 70 | - return array( |
|
| 71 | - 'message_ok' => ($url ? _T('info_redirection_activee') : _T('info_redirection_desactivee')) . $js, |
|
| 72 | - 'editable' => true |
|
| 73 | - ); |
|
| 70 | + return array( |
|
| 71 | + 'message_ok' => ($url ? _T('info_redirection_activee') : _T('info_redirection_desactivee')) . $js, |
|
| 72 | + 'editable' => true |
|
| 73 | + ); |
|
| 74 | 74 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | return false; |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - $row = sql_fetsel('id_article,virtuel', 'spip_articles', 'id_article=' . intval($id_article)); |
|
| 24 | + $row = sql_fetsel('id_article,virtuel', 'spip_articles', 'id_article='.intval($id_article)); |
|
| 25 | 25 | if (!$row['id_article']) { |
| 26 | 26 | return false; |
| 27 | 27 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | function formulaires_rediriger_article_verifier_dist($id_article, $retour = '') { |
| 49 | 49 | $erreurs = array(); |
| 50 | 50 | |
| 51 | - if (($redirection = _request('redirection')) == $id_article || $redirection == 'art' . $id_article) { |
|
| 51 | + if (($redirection = _request('redirection')) == $id_article || $redirection == 'art'.$id_article) { |
|
| 52 | 52 | $erreurs['redirection'] = _T('info_redirection_boucle'); |
| 53 | 53 | } |
| 54 | 54 | |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | $js = _AJAX ? '<script type="text/javascript">if (window.ajaxReload) ajaxReload("wysiwyg");</script>' : ''; |
| 69 | 69 | |
| 70 | 70 | return array( |
| 71 | - 'message_ok' => ($url ? _T('info_redirection_activee') : _T('info_redirection_desactivee')) . $js, |
|
| 71 | + 'message_ok' => ($url ? _T('info_redirection_activee') : _T('info_redirection_desactivee')).$js, |
|
| 72 | 72 | 'editable' => true |
| 73 | 73 | ); |
| 74 | 74 | } |
@@ -11,140 +11,140 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | include_spip('inc/presentation'); |
| 17 | 17 | include_spip('inc/config'); |
| 18 | 18 | |
| 19 | 19 | function formulaires_configurer_relayeur_charger_dist() { |
| 20 | - $valeurs = array( |
|
| 21 | - 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 22 | - 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 23 | - 'test_proxy' => 'http://www.spip.net/', |
|
| 24 | - ); |
|
| 20 | + $valeurs = array( |
|
| 21 | + 'http_proxy' => no_password_proxy_url(lire_config('http_proxy', '')), |
|
| 22 | + 'http_noproxy' => lire_config('http_noproxy', ''), |
|
| 23 | + 'test_proxy' => 'http://www.spip.net/', |
|
| 24 | + ); |
|
| 25 | 25 | |
| 26 | - return $valeurs; |
|
| 26 | + return $valeurs; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | function formulaires_configurer_relayeur_verifier_dist() { |
| 30 | - $erreurs = array(); |
|
| 31 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 32 | - $http_noproxy = _request('http_noproxy'); |
|
| 33 | - |
|
| 34 | - if ($http_proxy and !tester_url_absolue($http_proxy)) { |
|
| 35 | - $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - if (!isset($erreurs['http_proxy']) and _request('tester_proxy')) { |
|
| 39 | - if (!$http_proxy) { |
|
| 40 | - $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 41 | - } else { |
|
| 42 | - include_spip('inc/distant'); |
|
| 43 | - $test_proxy = _request('test_proxy'); |
|
| 44 | - $t = parse_url($test_proxy); |
|
| 45 | - if (!@$t['host']) { |
|
| 46 | - $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 47 | - } else { |
|
| 48 | - include_spip('inc/texte'); // pour aide, couper, lang |
|
| 49 | - $info = ''; |
|
| 50 | - if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 51 | - $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // il faut fausser le proxy actuel pour faire le test ! |
|
| 55 | - $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 56 | - $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 57 | - $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 58 | - $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 59 | - $page = recuperer_page($test_proxy, true); |
|
| 60 | - $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 61 | - $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 62 | - if ($page) { |
|
| 63 | - $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 64 | - $erreurs['message_erreur'] = ''; |
|
| 65 | - } else { |
|
| 66 | - $erreurs['message_erreur'] = $info . _T( |
|
| 67 | - 'info_impossible_lire_page', |
|
| 68 | - array('test_proxy' => "<tt>$test_proxy</tt>") |
|
| 69 | - ) |
|
| 70 | - . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 71 | - . aider('confhttpproxy'); |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - return $erreurs; |
|
| 30 | + $erreurs = array(); |
|
| 31 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 32 | + $http_noproxy = _request('http_noproxy'); |
|
| 33 | + |
|
| 34 | + if ($http_proxy and !tester_url_absolue($http_proxy)) { |
|
| 35 | + $erreurs['http_proxy'] = _T('info_url_proxy_pas_conforme'); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + if (!isset($erreurs['http_proxy']) and _request('tester_proxy')) { |
|
| 39 | + if (!$http_proxy) { |
|
| 40 | + $erreurs['http_proxy'] = _T('info_obligatoire'); |
|
| 41 | + } else { |
|
| 42 | + include_spip('inc/distant'); |
|
| 43 | + $test_proxy = _request('test_proxy'); |
|
| 44 | + $t = parse_url($test_proxy); |
|
| 45 | + if (!@$t['host']) { |
|
| 46 | + $erreurs['test_proxy'] = _T('info_adresse_non_indiquee'); |
|
| 47 | + } else { |
|
| 48 | + include_spip('inc/texte'); // pour aide, couper, lang |
|
| 49 | + $info = ''; |
|
| 50 | + if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
|
| 51 | + $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // il faut fausser le proxy actuel pour faire le test ! |
|
| 55 | + $cur_http_proxy = $GLOBALS['meta']['http_proxy']; |
|
| 56 | + $cur_http_noproxy = $GLOBALS['meta']['http_noproxy']; |
|
| 57 | + $GLOBALS['meta']['http_proxy'] = $http_proxy; |
|
| 58 | + $GLOBALS['meta']['http_noproxy'] = $http_noproxy; |
|
| 59 | + $page = recuperer_page($test_proxy, true); |
|
| 60 | + $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
|
| 61 | + $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
|
| 62 | + if ($page) { |
|
| 63 | + $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 64 | + $erreurs['message_erreur'] = ''; |
|
| 65 | + } else { |
|
| 66 | + $erreurs['message_erreur'] = $info . _T( |
|
| 67 | + 'info_impossible_lire_page', |
|
| 68 | + array('test_proxy' => "<tt>$test_proxy</tt>") |
|
| 69 | + ) |
|
| 70 | + . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 71 | + . aider('confhttpproxy'); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + return $erreurs; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | function formulaires_configurer_relayeur_traiter_dist() { |
| 81 | - $res = array('editable' => true); |
|
| 81 | + $res = array('editable' => true); |
|
| 82 | 82 | |
| 83 | - $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 84 | - $http_noproxy = _request('http_noproxy'); |
|
| 85 | - if ($http_proxy !== null) { |
|
| 86 | - ecrire_meta('http_proxy', $http_proxy); |
|
| 87 | - } |
|
| 83 | + $http_proxy = relayeur_saisie_ou_config(_request('http_proxy'), lire_config('http_proxy', '')); |
|
| 84 | + $http_noproxy = _request('http_noproxy'); |
|
| 85 | + if ($http_proxy !== null) { |
|
| 86 | + ecrire_meta('http_proxy', $http_proxy); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - if ($http_noproxy !== null) { |
|
| 90 | - ecrire_meta('http_noproxy', $http_noproxy); |
|
| 91 | - } |
|
| 89 | + if ($http_noproxy !== null) { |
|
| 90 | + ecrire_meta('http_noproxy', $http_noproxy); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 93 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 94 | 94 | |
| 95 | - return $res; |
|
| 95 | + return $res; |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | function relayeur_saisie_ou_config($http_proxy, $default) { |
| 99 | - // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 100 | - if (preg_match(',:\*\*\*\*@,', $http_proxy)) { |
|
| 101 | - $http_proxy = $default; |
|
| 102 | - } |
|
| 99 | + // http_proxy : ne pas prendre en compte la modif si le password est '****' |
|
| 100 | + if (preg_match(',:\*\*\*\*@,', $http_proxy)) { |
|
| 101 | + $http_proxy = $default; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - return $http_proxy; |
|
| 104 | + return $http_proxy; |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | // Function glue_url : le pendant de parse_url |
| 108 | 108 | // http://code.spip.net/@glue_url |
| 109 | 109 | function glue_url($url) { |
| 110 | - if (!is_array($url)) { |
|
| 111 | - return false; |
|
| 112 | - } |
|
| 113 | - // scheme |
|
| 114 | - $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : ''; |
|
| 115 | - // user & pass |
|
| 116 | - if (!empty($url['user'])) { |
|
| 117 | - $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 118 | - } |
|
| 119 | - // host |
|
| 120 | - $uri .= $url['host']; |
|
| 121 | - // port |
|
| 122 | - $port = (!empty($url['port'])) ? ':' . $url['port'] : ''; |
|
| 123 | - $uri .= $port; |
|
| 124 | - // path |
|
| 125 | - $uri .= $url['path']; |
|
| 110 | + if (!is_array($url)) { |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 113 | + // scheme |
|
| 114 | + $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : ''; |
|
| 115 | + // user & pass |
|
| 116 | + if (!empty($url['user'])) { |
|
| 117 | + $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 118 | + } |
|
| 119 | + // host |
|
| 120 | + $uri .= $url['host']; |
|
| 121 | + // port |
|
| 122 | + $port = (!empty($url['port'])) ? ':' . $url['port'] : ''; |
|
| 123 | + $uri .= $port; |
|
| 124 | + // path |
|
| 125 | + $uri .= $url['path']; |
|
| 126 | 126 | // fragment or query |
| 127 | - if (isset($url['fragment'])) { |
|
| 128 | - $uri .= '#' . $url['fragment']; |
|
| 129 | - } elseif (isset($url['query'])) { |
|
| 130 | - $uri .= '?' . $url['query']; |
|
| 131 | - } |
|
| 127 | + if (isset($url['fragment'])) { |
|
| 128 | + $uri .= '#' . $url['fragment']; |
|
| 129 | + } elseif (isset($url['query'])) { |
|
| 130 | + $uri .= '?' . $url['query']; |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - return $uri; |
|
| 133 | + return $uri; |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | |
| 137 | 137 | // Ne pas afficher la partie 'password' du proxy |
| 138 | 138 | // http://code.spip.net/@no_password_proxy_url |
| 139 | 139 | function no_password_proxy_url($http_proxy) { |
| 140 | - if ($http_proxy |
|
| 141 | - and $p = @parse_url($http_proxy) |
|
| 142 | - and isset($p['pass']) |
|
| 143 | - and $p['pass'] |
|
| 144 | - ) { |
|
| 145 | - $p['pass'] = '****'; |
|
| 146 | - $http_proxy = glue_url($p); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - return $http_proxy; |
|
| 140 | + if ($http_proxy |
|
| 141 | + and $p = @parse_url($http_proxy) |
|
| 142 | + and isset($p['pass']) |
|
| 143 | + and $p['pass'] |
|
| 144 | + ) { |
|
| 145 | + $p['pass'] = '****'; |
|
| 146 | + $http_proxy = glue_url($p); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + return $http_proxy; |
|
| 150 | 150 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | include_spip('inc/texte'); // pour aide, couper, lang |
| 49 | 49 | $info = ''; |
| 50 | 50 | if (!need_proxy($t['host'], $http_proxy, $http_noproxy)) { |
| 51 | - $info = '<strong>' . _T('page_pas_proxy') . '</strong><br />'; |
|
| 51 | + $info = '<strong>'._T('page_pas_proxy').'</strong><br />'; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // il faut fausser le proxy actuel pour faire le test ! |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | $GLOBALS['meta']['http_proxy'] = $cur_http_proxy; |
| 61 | 61 | $GLOBALS['meta']['http_noproxy'] = $cur_http_noproxy; |
| 62 | 62 | if ($page) { |
| 63 | - $erreurs['message_ok'] = _T('info_proxy_ok') . "<br />$info\n<tt>" . couper(entites_html($page), 300) . '</tt>'; |
|
| 63 | + $erreurs['message_ok'] = _T('info_proxy_ok')."<br />$info\n<tt>".couper(entites_html($page), 300).'</tt>'; |
|
| 64 | 64 | $erreurs['message_erreur'] = ''; |
| 65 | 65 | } else { |
| 66 | - $erreurs['message_erreur'] = $info . _T( |
|
| 66 | + $erreurs['message_erreur'] = $info._T( |
|
| 67 | 67 | 'info_impossible_lire_page', |
| 68 | 68 | array('test_proxy' => "<tt>$test_proxy</tt>") |
| 69 | 69 | ) |
| 70 | - . ' <b><tt>' . no_password_proxy_url($http_proxy) . '</tt></b>.' |
|
| 70 | + . ' <b><tt>'.no_password_proxy_url($http_proxy).'</tt></b>.' |
|
| 71 | 71 | . aider('confhttpproxy'); |
| 72 | 72 | } |
| 73 | 73 | } |
@@ -111,23 +111,23 @@ discard block |
||
| 111 | 111 | return false; |
| 112 | 112 | } |
| 113 | 113 | // scheme |
| 114 | - $uri = (!empty($url['scheme'])) ? $url['scheme'] . '://' : ''; |
|
| 114 | + $uri = (!empty($url['scheme'])) ? $url['scheme'].'://' : ''; |
|
| 115 | 115 | // user & pass |
| 116 | 116 | if (!empty($url['user'])) { |
| 117 | - $uri .= $url['user'] . ':' . $url['pass'] . '@'; |
|
| 117 | + $uri .= $url['user'].':'.$url['pass'].'@'; |
|
| 118 | 118 | } |
| 119 | 119 | // host |
| 120 | 120 | $uri .= $url['host']; |
| 121 | 121 | // port |
| 122 | - $port = (!empty($url['port'])) ? ':' . $url['port'] : ''; |
|
| 122 | + $port = (!empty($url['port'])) ? ':'.$url['port'] : ''; |
|
| 123 | 123 | $uri .= $port; |
| 124 | 124 | // path |
| 125 | 125 | $uri .= $url['path']; |
| 126 | 126 | // fragment or query |
| 127 | 127 | if (isset($url['fragment'])) { |
| 128 | - $uri .= '#' . $url['fragment']; |
|
| 128 | + $uri .= '#'.$url['fragment']; |
|
| 129 | 129 | } elseif (isset($url['query'])) { |
| 130 | - $uri .= '?' . $url['query']; |
|
| 130 | + $uri .= '?'.$url['query']; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | return $uri; |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | **/ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -28,22 +28,22 @@ discard block |
||
| 28 | 28 | * Environnement du formulaire |
| 29 | 29 | **/ |
| 30 | 30 | function formulaires_configurer_reducteur_charger_dist() { |
| 31 | - $valeurs = array(); |
|
| 32 | - foreach (array( |
|
| 33 | - 'image_process', |
|
| 34 | - 'formats_graphiques', |
|
| 35 | - 'creer_preview', |
|
| 36 | - 'taille_preview', |
|
| 37 | - ) as $m) { |
|
| 38 | - $valeurs[$m] = isset($GLOBALS['meta'][$m]) ? $GLOBALS['meta'][$m] : null; |
|
| 39 | - } |
|
| 31 | + $valeurs = array(); |
|
| 32 | + foreach (array( |
|
| 33 | + 'image_process', |
|
| 34 | + 'formats_graphiques', |
|
| 35 | + 'creer_preview', |
|
| 36 | + 'taille_preview', |
|
| 37 | + ) as $m) { |
|
| 38 | + $valeurs[$m] = isset($GLOBALS['meta'][$m]) ? $GLOBALS['meta'][$m] : null; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - $valeurs['taille_preview'] = intval($valeurs['taille_preview']); |
|
| 42 | - if ($valeurs['taille_preview'] < 10) { |
|
| 43 | - $valeurs['taille_preview'] = 120; |
|
| 44 | - } |
|
| 41 | + $valeurs['taille_preview'] = intval($valeurs['taille_preview']); |
|
| 42 | + if ($valeurs['taille_preview'] < 10) { |
|
| 43 | + $valeurs['taille_preview'] = 120; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - return $valeurs; |
|
| 46 | + return $valeurs; |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | |
@@ -54,51 +54,51 @@ discard block |
||
| 54 | 54 | * Retours des traitements |
| 55 | 55 | **/ |
| 56 | 56 | function formulaires_configurer_reducteur_traiter_dist() { |
| 57 | - $res = array('editable' => true); |
|
| 57 | + $res = array('editable' => true); |
|
| 58 | 58 | |
| 59 | - if (is_array($image_process = _request('image_process_'))) { |
|
| 60 | - $image_process = array_keys($image_process); |
|
| 61 | - $image_process = reset($image_process); |
|
| 59 | + if (is_array($image_process = _request('image_process_'))) { |
|
| 60 | + $image_process = array_keys($image_process); |
|
| 61 | + $image_process = reset($image_process); |
|
| 62 | 62 | |
| 63 | - // application du choix de vignette |
|
| 64 | - if ($image_process) { |
|
| 65 | - // mettre a jour les formats graphiques lisibles |
|
| 66 | - switch ($image_process) { |
|
| 67 | - case 'gd1': |
|
| 68 | - case 'gd2': |
|
| 69 | - $formats_graphiques = $GLOBALS['meta']['gd_formats_read']; |
|
| 70 | - break; |
|
| 71 | - case 'netpbm': |
|
| 72 | - $formats_graphiques = $GLOBALS['meta']['netpbm_formats']; |
|
| 73 | - break; |
|
| 74 | - case 'convert': |
|
| 75 | - case 'imagick': |
|
| 76 | - $formats_graphiques = 'gif,jpg,png'; |
|
| 77 | - break; |
|
| 78 | - default: #debug |
|
| 79 | - $formats_graphiques = ''; |
|
| 80 | - $image_process = 'non'; |
|
| 81 | - break; |
|
| 82 | - } |
|
| 83 | - ecrire_meta('formats_graphiques', $formats_graphiques, 'non'); |
|
| 84 | - ecrire_meta('image_process', $image_process, 'non'); |
|
| 85 | - } |
|
| 86 | - } |
|
| 63 | + // application du choix de vignette |
|
| 64 | + if ($image_process) { |
|
| 65 | + // mettre a jour les formats graphiques lisibles |
|
| 66 | + switch ($image_process) { |
|
| 67 | + case 'gd1': |
|
| 68 | + case 'gd2': |
|
| 69 | + $formats_graphiques = $GLOBALS['meta']['gd_formats_read']; |
|
| 70 | + break; |
|
| 71 | + case 'netpbm': |
|
| 72 | + $formats_graphiques = $GLOBALS['meta']['netpbm_formats']; |
|
| 73 | + break; |
|
| 74 | + case 'convert': |
|
| 75 | + case 'imagick': |
|
| 76 | + $formats_graphiques = 'gif,jpg,png'; |
|
| 77 | + break; |
|
| 78 | + default: #debug |
|
| 79 | + $formats_graphiques = ''; |
|
| 80 | + $image_process = 'non'; |
|
| 81 | + break; |
|
| 82 | + } |
|
| 83 | + ecrire_meta('formats_graphiques', $formats_graphiques, 'non'); |
|
| 84 | + ecrire_meta('image_process', $image_process, 'non'); |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - foreach (array( |
|
| 89 | - 'creer_preview' |
|
| 90 | - ) as $m) { |
|
| 91 | - if (!is_null($v = _request($m))) { |
|
| 92 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 93 | - } |
|
| 94 | - } |
|
| 95 | - if (!is_null($v = _request('taille_preview'))) { |
|
| 96 | - ecrire_meta('taille_preview', intval($v)); |
|
| 97 | - } |
|
| 88 | + foreach (array( |
|
| 89 | + 'creer_preview' |
|
| 90 | + ) as $m) { |
|
| 91 | + if (!is_null($v = _request($m))) { |
|
| 92 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 93 | + } |
|
| 94 | + } |
|
| 95 | + if (!is_null($v = _request('taille_preview'))) { |
|
| 96 | + ecrire_meta('taille_preview', intval($v)); |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 99 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 100 | 100 | |
| 101 | - return $res; |
|
| 101 | + return $res; |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -111,36 +111,36 @@ discard block |
||
| 111 | 111 | * URL d'action pour tester la librairie graphique en créant une vignette |
| 112 | 112 | **/ |
| 113 | 113 | function url_vignette_choix($process) { |
| 114 | - switch ($process) { |
|
| 115 | - case 'gd2': |
|
| 116 | - if (!function_exists('ImageCreateTrueColor')) { |
|
| 117 | - return ''; |
|
| 118 | - } |
|
| 119 | - break; |
|
| 120 | - case 'gd1': |
|
| 121 | - if (!function_exists('ImageGif') |
|
| 122 | - and !function_exists('ImageJpeg') |
|
| 123 | - and !function_exists('ImagePng') |
|
| 124 | - ) { |
|
| 125 | - return ''; |
|
| 126 | - } |
|
| 127 | - break; |
|
| 128 | - case 'netpbm': |
|
| 129 | - if (defined('_PNMSCALE_COMMAND') and _PNMSCALE_COMMAND == '') { |
|
| 130 | - return ''; |
|
| 131 | - } |
|
| 132 | - break; |
|
| 133 | - case 'imagick': |
|
| 134 | - if (!method_exists('Imagick', 'readImage')) { |
|
| 135 | - return ''; |
|
| 136 | - } |
|
| 137 | - break; |
|
| 138 | - case 'convert': |
|
| 139 | - if (defined('_CONVERT_COMMAND') and _CONVERT_COMMAND == '') { |
|
| 140 | - return ''; |
|
| 141 | - } |
|
| 142 | - break; |
|
| 143 | - } |
|
| 114 | + switch ($process) { |
|
| 115 | + case 'gd2': |
|
| 116 | + if (!function_exists('ImageCreateTrueColor')) { |
|
| 117 | + return ''; |
|
| 118 | + } |
|
| 119 | + break; |
|
| 120 | + case 'gd1': |
|
| 121 | + if (!function_exists('ImageGif') |
|
| 122 | + and !function_exists('ImageJpeg') |
|
| 123 | + and !function_exists('ImagePng') |
|
| 124 | + ) { |
|
| 125 | + return ''; |
|
| 126 | + } |
|
| 127 | + break; |
|
| 128 | + case 'netpbm': |
|
| 129 | + if (defined('_PNMSCALE_COMMAND') and _PNMSCALE_COMMAND == '') { |
|
| 130 | + return ''; |
|
| 131 | + } |
|
| 132 | + break; |
|
| 133 | + case 'imagick': |
|
| 134 | + if (!method_exists('Imagick', 'readImage')) { |
|
| 135 | + return ''; |
|
| 136 | + } |
|
| 137 | + break; |
|
| 138 | + case 'convert': |
|
| 139 | + if (defined('_CONVERT_COMMAND') and _CONVERT_COMMAND == '') { |
|
| 140 | + return ''; |
|
| 141 | + } |
|
| 142 | + break; |
|
| 143 | + } |
|
| 144 | 144 | |
| 145 | - return generer_url_action('tester', "arg=$process&time=" . time()); |
|
| 145 | + return generer_url_action('tester', "arg=$process&time=" . time()); |
|
| 146 | 146 | } |
@@ -142,5 +142,5 @@ |
||
| 142 | 142 | break; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return generer_url_action('tester', "arg=$process&time=" . time()); |
|
| 145 | + return generer_url_action('tester', "arg=$process&time=".time()); |
|
| 146 | 146 | } |
@@ -11,87 +11,87 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function formulaires_configurer_annonces_charger_dist() { |
| 18 | - $valeurs = array(); |
|
| 19 | - foreach (array( |
|
| 20 | - 'suivi_edito', |
|
| 21 | - 'adresse_suivi', |
|
| 22 | - 'adresse_suivi_inscription', |
|
| 23 | - 'quoi_de_neuf', |
|
| 24 | - 'adresse_neuf', |
|
| 25 | - 'jours_neuf', |
|
| 26 | - 'email_envoi', |
|
| 27 | - ) as $m) { |
|
| 28 | - $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 29 | - } |
|
| 18 | + $valeurs = array(); |
|
| 19 | + foreach (array( |
|
| 20 | + 'suivi_edito', |
|
| 21 | + 'adresse_suivi', |
|
| 22 | + 'adresse_suivi_inscription', |
|
| 23 | + 'quoi_de_neuf', |
|
| 24 | + 'adresse_neuf', |
|
| 25 | + 'jours_neuf', |
|
| 26 | + 'email_envoi', |
|
| 27 | + ) as $m) { |
|
| 28 | + $valeurs[$m] = $GLOBALS['meta'][$m]; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - return $valeurs; |
|
| 31 | + return $valeurs; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | function formulaires_configurer_annonces_verifier_dist() { |
| 35 | - $erreurs = array(); |
|
| 36 | - if (_request('suivi_edito') == 'oui') { |
|
| 37 | - if (!$email = _request('adresse_suivi')) { |
|
| 38 | - $erreurs['adresse_suivi'] = _T('info_obligatoire'); |
|
| 39 | - } else { |
|
| 40 | - include_spip('inc/filtres'); |
|
| 41 | - if (!email_valide($email)) { |
|
| 42 | - $erreurs['adresse_suivi'] = _T('form_prop_indiquer_email'); |
|
| 43 | - } |
|
| 44 | - } |
|
| 45 | - } |
|
| 46 | - if (_request('quoi_de_neuf') == 'oui') { |
|
| 47 | - if (!$email = _request('adresse_neuf')) { |
|
| 48 | - $erreurs['adresse_neuf'] = _T('info_obligatoire'); |
|
| 49 | - } else { |
|
| 50 | - include_spip('inc/filtres'); |
|
| 51 | - if (!email_valide($email)) { |
|
| 52 | - $erreurs['adresse_neuf'] = _T('form_prop_indiquer_email'); |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - if (!$email = _request('jours_neuf')) { |
|
| 56 | - $erreurs['jours_neuf'] = _T('info_obligatoire'); |
|
| 57 | - } |
|
| 58 | - } |
|
| 35 | + $erreurs = array(); |
|
| 36 | + if (_request('suivi_edito') == 'oui') { |
|
| 37 | + if (!$email = _request('adresse_suivi')) { |
|
| 38 | + $erreurs['adresse_suivi'] = _T('info_obligatoire'); |
|
| 39 | + } else { |
|
| 40 | + include_spip('inc/filtres'); |
|
| 41 | + if (!email_valide($email)) { |
|
| 42 | + $erreurs['adresse_suivi'] = _T('form_prop_indiquer_email'); |
|
| 43 | + } |
|
| 44 | + } |
|
| 45 | + } |
|
| 46 | + if (_request('quoi_de_neuf') == 'oui') { |
|
| 47 | + if (!$email = _request('adresse_neuf')) { |
|
| 48 | + $erreurs['adresse_neuf'] = _T('info_obligatoire'); |
|
| 49 | + } else { |
|
| 50 | + include_spip('inc/filtres'); |
|
| 51 | + if (!email_valide($email)) { |
|
| 52 | + $erreurs['adresse_neuf'] = _T('form_prop_indiquer_email'); |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + if (!$email = _request('jours_neuf')) { |
|
| 56 | + $erreurs['jours_neuf'] = _T('info_obligatoire'); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - return $erreurs; |
|
| 60 | + return $erreurs; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | function formulaires_configurer_annonces_traiter_dist() { |
| 64 | - $res = array('editable' => true); |
|
| 65 | - foreach (array( |
|
| 66 | - 'suivi_edito', |
|
| 67 | - 'quoi_de_neuf', |
|
| 68 | - ) as $m) { |
|
| 69 | - if (!is_null($v = _request($m))) { |
|
| 70 | - ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 71 | - } |
|
| 72 | - } |
|
| 64 | + $res = array('editable' => true); |
|
| 65 | + foreach (array( |
|
| 66 | + 'suivi_edito', |
|
| 67 | + 'quoi_de_neuf', |
|
| 68 | + ) as $m) { |
|
| 69 | + if (!is_null($v = _request($m))) { |
|
| 70 | + ecrire_meta($m, $v == 'oui' ? 'oui' : 'non'); |
|
| 71 | + } |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - foreach (array( |
|
| 75 | - 'adresse_suivi', |
|
| 76 | - 'adresse_suivi_inscription', |
|
| 77 | - 'adresse_neuf', |
|
| 78 | - 'jours_neuf', |
|
| 79 | - 'email_envoi', |
|
| 80 | - ) as $m) { |
|
| 81 | - if (!is_null($v = _request($m))) { |
|
| 82 | - ecrire_meta($m, $v); |
|
| 83 | - } |
|
| 84 | - } |
|
| 74 | + foreach (array( |
|
| 75 | + 'adresse_suivi', |
|
| 76 | + 'adresse_suivi_inscription', |
|
| 77 | + 'adresse_neuf', |
|
| 78 | + 'jours_neuf', |
|
| 79 | + 'email_envoi', |
|
| 80 | + ) as $m) { |
|
| 81 | + if (!is_null($v = _request($m))) { |
|
| 82 | + ecrire_meta($m, $v); |
|
| 83 | + } |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - $res['message_ok'] = _T('config_info_enregistree'); |
|
| 87 | - // provoquer l'envoi des nouveautes en supprimant le fichier lock |
|
| 88 | - if (_request('envoi_now')) { |
|
| 89 | - effacer_meta('dernier_envoi_neuf'); |
|
| 90 | - $id_job = job_queue_add('mail', 'Test Envoi des nouveautes', array(0), 'genie/'); |
|
| 91 | - include_spip('inc/queue'); |
|
| 92 | - queue_schedule(array($id_job)); |
|
| 93 | - $res['message_ok'] .= '<br />' . _T('info_liste_nouveautes_envoyee'); |
|
| 94 | - } |
|
| 86 | + $res['message_ok'] = _T('config_info_enregistree'); |
|
| 87 | + // provoquer l'envoi des nouveautes en supprimant le fichier lock |
|
| 88 | + if (_request('envoi_now')) { |
|
| 89 | + effacer_meta('dernier_envoi_neuf'); |
|
| 90 | + $id_job = job_queue_add('mail', 'Test Envoi des nouveautes', array(0), 'genie/'); |
|
| 91 | + include_spip('inc/queue'); |
|
| 92 | + queue_schedule(array($id_job)); |
|
| 93 | + $res['message_ok'] .= '<br />' . _T('info_liste_nouveautes_envoyee'); |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - return $res; |
|
| 96 | + return $res; |
|
| 97 | 97 | } |
@@ -90,7 +90,7 @@ |
||
| 90 | 90 | $id_job = job_queue_add('mail', 'Test Envoi des nouveautes', array(0), 'genie/'); |
| 91 | 91 | include_spip('inc/queue'); |
| 92 | 92 | queue_schedule(array($id_job)); |
| 93 | - $res['message_ok'] .= '<br />' . _T('info_liste_nouveautes_envoyee'); |
|
| 93 | + $res['message_ok'] .= '<br />'._T('info_liste_nouveautes_envoyee'); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | return $res; |
@@ -11,221 +11,221 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/install'); |
| 18 | 18 | |
| 19 | 19 | function formulaires_declarer_bases_charger_dist() { |
| 20 | - list($adresse_db, $login_db, $pass_db, $sel, $server_db) = analyse_fichier_connection(_FILE_CONNECT); |
|
| 21 | - |
|
| 22 | - $deja = bases_referencees(_FILE_CONNECT); |
|
| 23 | - // proposer un nom de connect si pas encore saisi |
|
| 24 | - $nom_connect = ''; |
|
| 25 | - if (defined('_DECLARER_CHOIX_DB')) { |
|
| 26 | - $nom_connect = _DECLARER_CHOIX_DB; |
|
| 27 | - $n = ''; |
|
| 28 | - while (in_array($nom_connect . $n, $deja)) { |
|
| 29 | - $n = ($n ? $n + 1 : 1); |
|
| 30 | - } |
|
| 31 | - $nom_connect = $nom_connect . $n; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - $valeurs = array( |
|
| 35 | - '_etapes' => 3, |
|
| 36 | - '_bases_deja' => $deja, |
|
| 37 | - '_bases_prop' => defined('_DECLARER_SERVEUR_DB') ? liste_bases(_DECLARER_SERVEUR_DB) : '', |
|
| 38 | - '_tables' => (defined('_DECLARER_SERVEUR_DB') and defined('_DECLARER_CHOIX_DB')) ? |
|
| 39 | - $tables = sql_alltable('%', _DECLARER_SERVEUR_DB) |
|
| 40 | - : |
|
| 41 | - array(), |
|
| 42 | - 'main_db' => '', |
|
| 43 | - '_serveurs' => liste_serveurs(), |
|
| 44 | - 'sql_serveur_db' => 'sqlite3', // valeur par defaut |
|
| 45 | - 'adresse_db' => $adresse_db, |
|
| 46 | - 'login_db' => '', |
|
| 47 | - 'pass_db' => '', |
|
| 48 | - 'choix_db' => '', |
|
| 49 | - 'table_new' => '', |
|
| 50 | - 'nom_connect' => $nom_connect, |
|
| 51 | - ); |
|
| 52 | - |
|
| 53 | - return $valeurs; |
|
| 20 | + list($adresse_db, $login_db, $pass_db, $sel, $server_db) = analyse_fichier_connection(_FILE_CONNECT); |
|
| 21 | + |
|
| 22 | + $deja = bases_referencees(_FILE_CONNECT); |
|
| 23 | + // proposer un nom de connect si pas encore saisi |
|
| 24 | + $nom_connect = ''; |
|
| 25 | + if (defined('_DECLARER_CHOIX_DB')) { |
|
| 26 | + $nom_connect = _DECLARER_CHOIX_DB; |
|
| 27 | + $n = ''; |
|
| 28 | + while (in_array($nom_connect . $n, $deja)) { |
|
| 29 | + $n = ($n ? $n + 1 : 1); |
|
| 30 | + } |
|
| 31 | + $nom_connect = $nom_connect . $n; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + $valeurs = array( |
|
| 35 | + '_etapes' => 3, |
|
| 36 | + '_bases_deja' => $deja, |
|
| 37 | + '_bases_prop' => defined('_DECLARER_SERVEUR_DB') ? liste_bases(_DECLARER_SERVEUR_DB) : '', |
|
| 38 | + '_tables' => (defined('_DECLARER_SERVEUR_DB') and defined('_DECLARER_CHOIX_DB')) ? |
|
| 39 | + $tables = sql_alltable('%', _DECLARER_SERVEUR_DB) |
|
| 40 | + : |
|
| 41 | + array(), |
|
| 42 | + 'main_db' => '', |
|
| 43 | + '_serveurs' => liste_serveurs(), |
|
| 44 | + 'sql_serveur_db' => 'sqlite3', // valeur par defaut |
|
| 45 | + 'adresse_db' => $adresse_db, |
|
| 46 | + 'login_db' => '', |
|
| 47 | + 'pass_db' => '', |
|
| 48 | + 'choix_db' => '', |
|
| 49 | + 'table_new' => '', |
|
| 50 | + 'nom_connect' => $nom_connect, |
|
| 51 | + ); |
|
| 52 | + |
|
| 53 | + return $valeurs; |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | function liste_serveurs() { |
| 57 | - $options = array(); |
|
| 58 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 59 | - $d = opendir($dir); |
|
| 60 | - if (!$d) { |
|
| 61 | - return array(); |
|
| 62 | - } |
|
| 63 | - while ($f = readdir($d)) { |
|
| 64 | - if ((preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 65 | - and is_readable($f = $dir . $f) |
|
| 66 | - ) { |
|
| 67 | - require_once($f); |
|
| 68 | - $s = $s[1]; |
|
| 69 | - $v = 'spip_versions_' . $s; |
|
| 70 | - if (function_exists($v) and $v()) { |
|
| 71 | - $options[$s] = "install_select_type_$s"; |
|
| 72 | - } else { |
|
| 73 | - spip_log("$s: portage indisponible"); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - ksort($options); |
|
| 78 | - |
|
| 79 | - return $options; |
|
| 57 | + $options = array(); |
|
| 58 | + $dir = _DIR_RESTREINT . 'req/'; |
|
| 59 | + $d = opendir($dir); |
|
| 60 | + if (!$d) { |
|
| 61 | + return array(); |
|
| 62 | + } |
|
| 63 | + while ($f = readdir($d)) { |
|
| 64 | + if ((preg_match('/^(.*)[.]php$/', $f, $s)) |
|
| 65 | + and is_readable($f = $dir . $f) |
|
| 66 | + ) { |
|
| 67 | + require_once($f); |
|
| 68 | + $s = $s[1]; |
|
| 69 | + $v = 'spip_versions_' . $s; |
|
| 70 | + if (function_exists($v) and $v()) { |
|
| 71 | + $options[$s] = "install_select_type_$s"; |
|
| 72 | + } else { |
|
| 73 | + spip_log("$s: portage indisponible"); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + ksort($options); |
|
| 78 | + |
|
| 79 | + return $options; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | function liste_bases($server_db) { |
| 83 | - if (is_null($server_db) |
|
| 84 | - or !$result = sql_listdbs($server_db) |
|
| 85 | - ) { |
|
| 86 | - return ''; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $noms = array(); |
|
| 90 | - |
|
| 91 | - // si sqlite : result est deja un tableau |
|
| 92 | - if (is_array($result)) { |
|
| 93 | - $noms = $result; |
|
| 94 | - } else { |
|
| 95 | - while ($row = sql_fetch($result, $server_db)) { |
|
| 96 | - $noms[] = reset($row); |
|
| 97 | - } |
|
| 98 | - } |
|
| 99 | - |
|
| 100 | - return $noms; |
|
| 83 | + if (is_null($server_db) |
|
| 84 | + or !$result = sql_listdbs($server_db) |
|
| 85 | + ) { |
|
| 86 | + return ''; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $noms = array(); |
|
| 90 | + |
|
| 91 | + // si sqlite : result est deja un tableau |
|
| 92 | + if (is_array($result)) { |
|
| 93 | + $noms = $result; |
|
| 94 | + } else { |
|
| 95 | + while ($row = sql_fetch($result, $server_db)) { |
|
| 96 | + $noms[] = reset($row); |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | + |
|
| 100 | + return $noms; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | function formulaires_declarer_bases_verifier_1_dist() { |
| 104 | - $erreurs = array(); |
|
| 105 | - list($def_adresse_db, $def_login_db, $def_pass_db, $sel_db, $def_serveur_db) = analyse_fichier_connection(_FILE_CONNECT); |
|
| 106 | - |
|
| 107 | - if (!$adresse_db = _request('adresse_db')) { |
|
| 108 | - if (defined('_INSTALL_HOST_DB')) { |
|
| 109 | - $adresse_db = _INSTALL_HOST_DB; |
|
| 110 | - } else { |
|
| 111 | - $adresse_db = $def_adresse_db; |
|
| 112 | - } |
|
| 113 | - } |
|
| 114 | - if (!$serveur_db = _request('sql_serveur_db')) { |
|
| 115 | - if (defined('_INSTALL_SERVER_DB')) { |
|
| 116 | - $serveur_db = _INSTALL_SERVER_DB; |
|
| 117 | - } else { |
|
| 118 | - $serveur_db = $def_serveur_db; |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - $login_db = $pass_db = ''; |
|
| 123 | - if (!preg_match(',^sqlite,i', $serveur_db)) { |
|
| 124 | - if (!$login_db = _request('login_db')) { |
|
| 125 | - if (defined('_INSTALL_USER_DB')) { |
|
| 126 | - $login_db = _INSTALL_USER_DB; |
|
| 127 | - } else { |
|
| 128 | - $login_db = $def_login_db; |
|
| 129 | - } |
|
| 130 | - } |
|
| 131 | - if (!$pass_db = _request('pass_db')) { |
|
| 132 | - if (defined('_INSTALL_PASS_DB')) { |
|
| 133 | - $pass_db = _INSTALL_PASS_DB; |
|
| 134 | - } else { |
|
| 135 | - $pass_db = $def_pass_db; |
|
| 136 | - } |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
|
| 141 | - if ($link) { |
|
| 142 | - $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 143 | - $GLOBALS['connexions'][$serveur_db] = $link; |
|
| 144 | - define('_DECLARER_SERVEUR_DB', $serveur_db); |
|
| 145 | - define('_DECLARER_ADRESSE_DB', $adresse_db); |
|
| 146 | - define('_DECLARER_LOGIN_DB', $login_db); |
|
| 147 | - define('_DECLARER_PASS_DB', $pass_db); |
|
| 148 | - // si on est sur le meme serveur que connect.php |
|
| 149 | - // indiquer quelle est la db utilisee pour l'exclure des choix possibles |
|
| 150 | - if ($serveur_db == $def_serveur_db and $adresse_db == $def_adresse_db) { |
|
| 151 | - set_request('main_db', $sel_db); |
|
| 152 | - } else { |
|
| 153 | - set_request('main_db', ''); |
|
| 154 | - } |
|
| 155 | - } else { |
|
| 156 | - $erreurs['message_erreur'] = _T('avis_connexion_echec_1'); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - return $erreurs; |
|
| 104 | + $erreurs = array(); |
|
| 105 | + list($def_adresse_db, $def_login_db, $def_pass_db, $sel_db, $def_serveur_db) = analyse_fichier_connection(_FILE_CONNECT); |
|
| 106 | + |
|
| 107 | + if (!$adresse_db = _request('adresse_db')) { |
|
| 108 | + if (defined('_INSTALL_HOST_DB')) { |
|
| 109 | + $adresse_db = _INSTALL_HOST_DB; |
|
| 110 | + } else { |
|
| 111 | + $adresse_db = $def_adresse_db; |
|
| 112 | + } |
|
| 113 | + } |
|
| 114 | + if (!$serveur_db = _request('sql_serveur_db')) { |
|
| 115 | + if (defined('_INSTALL_SERVER_DB')) { |
|
| 116 | + $serveur_db = _INSTALL_SERVER_DB; |
|
| 117 | + } else { |
|
| 118 | + $serveur_db = $def_serveur_db; |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + $login_db = $pass_db = ''; |
|
| 123 | + if (!preg_match(',^sqlite,i', $serveur_db)) { |
|
| 124 | + if (!$login_db = _request('login_db')) { |
|
| 125 | + if (defined('_INSTALL_USER_DB')) { |
|
| 126 | + $login_db = _INSTALL_USER_DB; |
|
| 127 | + } else { |
|
| 128 | + $login_db = $def_login_db; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + if (!$pass_db = _request('pass_db')) { |
|
| 132 | + if (defined('_INSTALL_PASS_DB')) { |
|
| 133 | + $pass_db = _INSTALL_PASS_DB; |
|
| 134 | + } else { |
|
| 135 | + $pass_db = $def_pass_db; |
|
| 136 | + } |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
|
| 141 | + if ($link) { |
|
| 142 | + $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 143 | + $GLOBALS['connexions'][$serveur_db] = $link; |
|
| 144 | + define('_DECLARER_SERVEUR_DB', $serveur_db); |
|
| 145 | + define('_DECLARER_ADRESSE_DB', $adresse_db); |
|
| 146 | + define('_DECLARER_LOGIN_DB', $login_db); |
|
| 147 | + define('_DECLARER_PASS_DB', $pass_db); |
|
| 148 | + // si on est sur le meme serveur que connect.php |
|
| 149 | + // indiquer quelle est la db utilisee pour l'exclure des choix possibles |
|
| 150 | + if ($serveur_db == $def_serveur_db and $adresse_db == $def_adresse_db) { |
|
| 151 | + set_request('main_db', $sel_db); |
|
| 152 | + } else { |
|
| 153 | + set_request('main_db', ''); |
|
| 154 | + } |
|
| 155 | + } else { |
|
| 156 | + $erreurs['message_erreur'] = _T('avis_connexion_echec_1'); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + return $erreurs; |
|
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | function formulaires_declarer_bases_verifier_2_dist() { |
| 163 | - $erreurs = array(); |
|
| 164 | - $choix_db = _request('choix_db'); |
|
| 165 | - if ($choix_db == '-1') { |
|
| 166 | - $choix_db = _request('table_new'); |
|
| 167 | - } |
|
| 168 | - if (!$choix_db) { |
|
| 169 | - $erreurs['choix_db'] = _T('info_obligatoire'); |
|
| 170 | - } else { |
|
| 171 | - define('_ECRIRE_INSTALL', 1); // hackons sqlite |
|
| 172 | - if (!sql_selectdb($choix_db, _DECLARER_SERVEUR_DB)) { |
|
| 173 | - $erreurs['choix_db'] = _T('avis_base_inaccessible', array('base' => $choix_db)); |
|
| 174 | - } else { |
|
| 175 | - define('_DECLARER_CHOIX_DB', $choix_db); |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - return $erreurs; |
|
| 163 | + $erreurs = array(); |
|
| 164 | + $choix_db = _request('choix_db'); |
|
| 165 | + if ($choix_db == '-1') { |
|
| 166 | + $choix_db = _request('table_new'); |
|
| 167 | + } |
|
| 168 | + if (!$choix_db) { |
|
| 169 | + $erreurs['choix_db'] = _T('info_obligatoire'); |
|
| 170 | + } else { |
|
| 171 | + define('_ECRIRE_INSTALL', 1); // hackons sqlite |
|
| 172 | + if (!sql_selectdb($choix_db, _DECLARER_SERVEUR_DB)) { |
|
| 173 | + $erreurs['choix_db'] = _T('avis_base_inaccessible', array('base' => $choix_db)); |
|
| 174 | + } else { |
|
| 175 | + define('_DECLARER_CHOIX_DB', $choix_db); |
|
| 176 | + } |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + return $erreurs; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | function formulaires_declarer_bases_verifier_3_dist() { |
| 183 | - $erreurs = array(); |
|
| 184 | - $nom_connect = _request('nom_connect'); |
|
| 185 | - if (!$nom_connect) { |
|
| 186 | - $erreurs['nom_connect'] = _T('info_obligatoire'); |
|
| 187 | - } else { |
|
| 188 | - // securite : le nom doit etre un mot sans caracteres speciaux |
|
| 189 | - $f = preg_replace(',[^\w],', '', $nom_connect); |
|
| 190 | - if ($f !== $nom_connect) { |
|
| 191 | - $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
|
| 192 | - } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 193 | - $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
|
| 194 | - } else { |
|
| 195 | - define('_DECLARER_NOM_CONNECT', $nom_connect); |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - return $erreurs; |
|
| 183 | + $erreurs = array(); |
|
| 184 | + $nom_connect = _request('nom_connect'); |
|
| 185 | + if (!$nom_connect) { |
|
| 186 | + $erreurs['nom_connect'] = _T('info_obligatoire'); |
|
| 187 | + } else { |
|
| 188 | + // securite : le nom doit etre un mot sans caracteres speciaux |
|
| 189 | + $f = preg_replace(',[^\w],', '', $nom_connect); |
|
| 190 | + if ($f !== $nom_connect) { |
|
| 191 | + $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
|
| 192 | + } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 193 | + $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
|
| 194 | + } else { |
|
| 195 | + define('_DECLARER_NOM_CONNECT', $nom_connect); |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + return $erreurs; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | function formulaires_declarer_bases_traiter_dist() { |
| 203 | 203 | |
| 204 | - $adresse_db = _DECLARER_ADRESSE_DB; |
|
| 205 | - if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 206 | - list(, $adresse_db, $port) = $r; |
|
| 207 | - } else { |
|
| 208 | - $port = ''; |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - $server_db = addcslashes(_DECLARER_SERVEUR_DB, "'\\"); |
|
| 212 | - |
|
| 213 | - $conn = install_mode_appel($server_db) |
|
| 214 | - . install_connexion( |
|
| 215 | - $adresse_db, |
|
| 216 | - $port, |
|
| 217 | - _DECLARER_LOGIN_DB, |
|
| 218 | - _DECLARER_PASS_DB, |
|
| 219 | - _DECLARER_CHOIX_DB, |
|
| 220 | - _DECLARER_SERVEUR_DB, |
|
| 221 | - '', |
|
| 222 | - '', |
|
| 223 | - '' |
|
| 224 | - ); |
|
| 225 | - |
|
| 226 | - install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 227 | - |
|
| 228 | - return array( |
|
| 229 | - 'message_ok' => _T('install_connect_ok', array('connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>')) |
|
| 230 | - ); |
|
| 204 | + $adresse_db = _DECLARER_ADRESSE_DB; |
|
| 205 | + if (preg_match(',(.*):(.*),', $adresse_db, $r)) { |
|
| 206 | + list(, $adresse_db, $port) = $r; |
|
| 207 | + } else { |
|
| 208 | + $port = ''; |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + $server_db = addcslashes(_DECLARER_SERVEUR_DB, "'\\"); |
|
| 212 | + |
|
| 213 | + $conn = install_mode_appel($server_db) |
|
| 214 | + . install_connexion( |
|
| 215 | + $adresse_db, |
|
| 216 | + $port, |
|
| 217 | + _DECLARER_LOGIN_DB, |
|
| 218 | + _DECLARER_PASS_DB, |
|
| 219 | + _DECLARER_CHOIX_DB, |
|
| 220 | + _DECLARER_SERVEUR_DB, |
|
| 221 | + '', |
|
| 222 | + '', |
|
| 223 | + '' |
|
| 224 | + ); |
|
| 225 | + |
|
| 226 | + install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 227 | + |
|
| 228 | + return array( |
|
| 229 | + 'message_ok' => _T('install_connect_ok', array('connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>')) |
|
| 230 | + ); |
|
| 231 | 231 | } |
@@ -25,10 +25,10 @@ discard block |
||
| 25 | 25 | if (defined('_DECLARER_CHOIX_DB')) { |
| 26 | 26 | $nom_connect = _DECLARER_CHOIX_DB; |
| 27 | 27 | $n = ''; |
| 28 | - while (in_array($nom_connect . $n, $deja)) { |
|
| 28 | + while (in_array($nom_connect.$n, $deja)) { |
|
| 29 | 29 | $n = ($n ? $n + 1 : 1); |
| 30 | 30 | } |
| 31 | - $nom_connect = $nom_connect . $n; |
|
| 31 | + $nom_connect = $nom_connect.$n; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | $valeurs = array( |
@@ -55,18 +55,18 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | function liste_serveurs() { |
| 57 | 57 | $options = array(); |
| 58 | - $dir = _DIR_RESTREINT . 'req/'; |
|
| 58 | + $dir = _DIR_RESTREINT.'req/'; |
|
| 59 | 59 | $d = opendir($dir); |
| 60 | 60 | if (!$d) { |
| 61 | 61 | return array(); |
| 62 | 62 | } |
| 63 | 63 | while ($f = readdir($d)) { |
| 64 | 64 | if ((preg_match('/^(.*)[.]php$/', $f, $s)) |
| 65 | - and is_readable($f = $dir . $f) |
|
| 65 | + and is_readable($f = $dir.$f) |
|
| 66 | 66 | ) { |
| 67 | 67 | require_once($f); |
| 68 | 68 | $s = $s[1]; |
| 69 | - $v = 'spip_versions_' . $s; |
|
| 69 | + $v = 'spip_versions_'.$s; |
|
| 70 | 70 | if (function_exists($v) and $v()) { |
| 71 | 71 | $options[$s] = "install_select_type_$s"; |
| 72 | 72 | } else { |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | |
| 140 | 140 | $link = spip_connect_db($adresse_db, '', $login_db, $pass_db, '@test@', $serveur_db); |
| 141 | 141 | if ($link) { |
| 142 | - $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_' . $serveur_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 142 | + $GLOBALS['connexions'][$serveur_db][$GLOBALS['spip_sql_version']] = $GLOBALS['spip_'.$serveur_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 143 | 143 | $GLOBALS['connexions'][$serveur_db] = $link; |
| 144 | 144 | define('_DECLARER_SERVEUR_DB', $serveur_db); |
| 145 | 145 | define('_DECLARER_ADRESSE_DB', $adresse_db); |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | $f = preg_replace(',[^\w],', '', $nom_connect); |
| 190 | 190 | if ($f !== $nom_connect) { |
| 191 | 191 | $erreurs['nom_connect'] = _T('erreur_nom_connect_incorrect'); |
| 192 | - } elseif (file_exists(_DIR_CONNECT . $nom_connect . '.php')) { |
|
| 192 | + } elseif (file_exists(_DIR_CONNECT.$nom_connect.'.php')) { |
|
| 193 | 193 | $erreurs['nom_connect'] = _T('erreur_connect_deja_existant'); |
| 194 | 194 | } else { |
| 195 | 195 | define('_DECLARER_NOM_CONNECT', $nom_connect); |
@@ -223,9 +223,9 @@ discard block |
||
| 223 | 223 | '' |
| 224 | 224 | ); |
| 225 | 225 | |
| 226 | - install_fichier_connexion(_DIR_CONNECT . _DECLARER_NOM_CONNECT . '.php', $conn); |
|
| 226 | + install_fichier_connexion(_DIR_CONNECT._DECLARER_NOM_CONNECT.'.php', $conn); |
|
| 227 | 227 | |
| 228 | 228 | return array( |
| 229 | - 'message_ok' => _T('install_connect_ok', array('connect' => '<strong>' . _DECLARER_NOM_CONNECT . '</strong>')) |
|
| 229 | + 'message_ok' => _T('install_connect_ok', array('connect' => '<strong>'._DECLARER_NOM_CONNECT.'</strong>')) |
|
| 230 | 230 | ); |
| 231 | 231 | } |