From: Olivier Tétard Date: Mon, 7 Oct 2013 08:03:31 +0000 (+0200) Subject: Changement du format de stockage de la configuration des montants X-Git-Url: http://olivier.miskin.fr/git/?a=commitdiff_plain;h=800a8b6733d42c0cae4aa9d4895cad217dc3fac1;p=spip_souscriptions.git Changement du format de stockage de la configuration des montants --- diff --git a/formulaires/configurer_souscription.php b/formulaires/configurer_souscription.php index 882fdaa..f9f6741 100644 --- a/formulaires/configurer_souscription.php +++ b/formulaires/configurer_souscription.php @@ -6,13 +6,13 @@ include_spip('inc/config'); function formulaires_configurer_souscription_charger_dist() { - $valeurs = array('adhesion_montants' => montants_array2str(lire_config("souscription/adhesion_montants")), + $valeurs = array('adhesion_montants' => lire_config("souscription/adhesion_montants"), 'adhesion_type_saisie' => lire_config("souscription/adhesion_type_saisie"), "adhesion_activer" => lire_config("souscription/adhesion_activer"), "adhesion_montants_description" => lire_config("souscription/adhesion_montants_description"), "adhesion_montants_label" => lire_config("souscription/adhesion_montants_label"), - 'don_montants' => montants_array2str(lire_config("souscription/don_montants")), + 'don_montants' => lire_config("souscription/don_montants"), 'don_type_saisie' => lire_config("souscription/don_type_saisie"), "don_activer" => lire_config("souscription/don_activer"), "don_montants_description" => lire_config("souscription/don_montants_description"), @@ -56,13 +56,13 @@ function formulaires_configurer_souscription_verifier_dist() { function formulaires_configurer_souscription_traiter_dist() { - ecrire_config("souscription/adhesion_montants", montants_str2array(_request("adhesion_montants"))); + ecrire_config("souscription/adhesion_montants", _request("adhesion_montants")); ecrire_config("souscription/adhesion_type_saisie", _request("adhesion_type_saisie")); ecrire_config("souscription/adhesion_activer", _request("adhesion_activer")); ecrire_config("souscription/adhesion_montants_description", _request("adhesion_montants_description")); ecrire_config("souscription/adhesion_montants_label", _request("adhesion_montants_label")); - ecrire_config("souscription/don_montants", montants_str2array(_request("don_montants"))); + ecrire_config("souscription/don_montants", _request("don_montants")); ecrire_config("souscription/don_type_saisie", _request("don_type_saisie")); ecrire_config("souscription/don_activer", _request("don_activer")); ecrire_config("souscription/don_montants_description", _request("don_montants_description")); diff --git a/formulaires/souscription.php b/formulaires/souscription.php index 8ef91f3..8f3fe01 100644 --- a/formulaires/souscription.php +++ b/formulaires/souscription.php @@ -86,7 +86,7 @@ function formulaires_souscription_charger_dist($id_souscription_campagne) { } else { $montant_type = $campagne['type_saisie']; - $montant_datas = montants_str2array($campagne['montants']); + $montant_datas = $campagne['montants']; } $montant_label = lire_config("souscription/${type}_montants_label", _T('souscription:label_montant')); @@ -106,7 +106,7 @@ function formulaires_souscription_charger_dist($id_souscription_campagne) { 'telephone' => '', 'id_souscription_campagne' => $id_souscription_campagne, 'type_souscription' => $type, - 'montant_datas' => $montant_datas, + 'montant_datas' => montants_str2array($montant_datas), 'montant_type' => $montant_type, 'montant_label' => $montant_label, 'montant_explication' => $montant_explication diff --git a/paquet.xml b/paquet.xml index 9512c9d..1b08168 100644 --- a/paquet.xml +++ b/paquet.xml @@ -5,7 +5,7 @@ compatibilite="[3.0.5;3.0.*]" logo="" documentation="" - schema="0.5"> + schema="0.6"> Souscription Olivier Tétard diff --git a/souscription_administrations.php b/souscription_administrations.php index 8e10fc0..a41b0fc 100644 --- a/souscription_administrations.php +++ b/souscription_administrations.php @@ -40,10 +40,31 @@ function souscription_upgrade($nom_meta_base_version, $version_cible) { array('sql_alter', "TABLE spip_souscription_campagnes ADD type_saisie varchar(255) NOT NULL DEFAULT ''"), array('sql_alter', "TABLE spip_souscription_campagnes ADD montants text NOT NULL DEFAULT ''")); + $maj['0.6'] = array(array('maj_configuration_montants')); + include_spip('base/upgrade'); maj_plugin($nom_meta_base_version, $version_cible, $maj); } +/* Fonction permettant de changer le format des montants globaux pour + * le plugin souscription. Les montants étaient stockés sous la forme + * d'un array() sérialisés. Il sont désormais stockés dans leur format + * chaine de caractères. */ +function maj_configuration_montants() { + foreach(array('adhesion_montants', 'don_montants') as $cfg) { + $cle_cfg = "souscription/${cfg}"; + + $montants_orig = lire_config($cle_cfg); + + $montants = ""; + foreach($montants_orig as $prix => $description) { + $montants .= $prix . "|" . $description . "\n"; + } + + ecrire_config($cle_cfg, $montants); + } +} + /** * Fonction de désinstallation du plugin Souscription. * diff --git a/souscription_fonctions.php b/souscription_fonctions.php index 072b924..1ed1e80 100644 --- a/souscription_fonctions.php +++ b/souscription_fonctions.php @@ -43,17 +43,6 @@ function balise_AVANCEMENT_CAMPAGNE_dist($p) { return $p; } -function montants_array2str($array) { - include_spip('inc/saisies'); - - $montants = ""; - foreach($array as $prix => $description) { - $montants .= $prix . "|" . $description . "\n"; - } - - return $montants; -} - function montants_str2array($str) { include_spip('inc/saisies');