From 8230aeff7bebe0aa583ccf975cb1ebd67e55d076 Mon Sep 17 00:00:00 2001 From: "cedric@yterium.com" <> Date: Thu, 6 Feb 2014 15:51:28 +0000 Subject: [PATCH] =?UTF-8?q?Prise=20en=20charge=20du=20statut=20sur=20les?= =?UTF-8?q?=20formulaires.=20Lors=20de=20l'import=20f&t=20les=20formulaire?= =?UTF-8?q?s=20sans=20r=C3=A9ponses=20sont=20mis=20en=20statut=20propos?= =?UTF-8?q?=C3=A9,=20les=20autres=20en=20publi=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action/editer_formulaire.php | 21 +++++++++++++++++++-- base/formidable_tables.php | 20 ++++++++++++++++++++ formidable_administrations.php | 10 ++++++++++ lang/formidable_fr.php | 1 + paquet.xml | 4 ++-- prive/objets/infos/formulaire.html | 2 ++ prive/objets/infos/formulaires_reponse.html | 2 +- prive/objets/liste/formulaires.html | 4 ++-- 8 files changed, 57 insertions(+), 7 deletions(-) diff --git a/action/editer_formulaire.php b/action/editer_formulaire.php index 875ffcb3..13ec60a0 100644 --- a/action/editer_formulaire.php +++ b/action/editer_formulaire.php @@ -39,7 +39,10 @@ function action_editer_formulaire_dist($arg=null) { * @return int id_formulaire */ function formulaire_inserer() { - $champs = array(); + $champs = array( + 'statut' => 'prop', + 'date_creation' => date('Y-m-d H:i:s'), + ); // Envoyer aux plugins $champs = pipeline('pre_insertion', array( @@ -49,7 +52,17 @@ function formulaire_inserer() { 'data' => $champs ) ); - $id_formulaire = sql_insertq("spip_formulaires", array('date_creation' => date('Y-m-d H:i:s'))); + $id_formulaire = sql_insertq("spip_formulaires", $champs); + + pipeline('post_insertion', + array( + 'args' => array( + 'table' => 'spip_formulaires', + 'id_objet' => $id_formulaire + ), + 'data' => $champs + ) + ); return $id_formulaire; } @@ -85,6 +98,10 @@ function formulaire_modifier($id_formulaire, $set=null) { $c)) return $err; + // Modification de statut, changement de rubrique ? + $c = collecter_requests(array('statut'),array(),$set); + include_spip("action/editer_objet"); + $err = objet_instituer('formulaire',$id_formulaire, $c); return $err; } diff --git a/base/formidable_tables.php b/base/formidable_tables.php index c5041485..3c98ce7a 100644 --- a/base/formidable_tables.php +++ b/base/formidable_tables.php @@ -79,9 +79,29 @@ function formidable_declarer_tables_objets_sql($tables) { 'join'=> array( 'id_formulaire' => 'id_formulaire' ), + 'statut'=> array( + array( + 'champ' => 'statut', + 'publie' => 'publie', + 'previsu' => 'publie,prop', + 'exception' => array('statut', 'tout'), + ) + ), + 'texte_changer_statut' => 'formidable:changer_statut', 'rechercher_champs' => array( 'titre' => 5, 'descriptif' => 3 ), + 'statut_titres' => array( + 'prop'=>'info_article_propose', + 'publie'=>'info_article_publie', + 'poubelle'=>'info_article_supprime' + ), + 'statut_textes_instituer' => array( + 'prop' => 'texte_statut_propose_evaluation', + 'publie' => 'texte_statut_publie', + 'poubelle' => 'texte_statut_poubelle', + ), + ); $tables['spip_formulaires_reponses'] = array( diff --git a/formidable_administrations.php b/formidable_administrations.php index 86256378..57876896 100644 --- a/formidable_administrations.php +++ b/formidable_administrations.php @@ -47,6 +47,11 @@ function formidable_upgrade($nom_meta_base_version, $version_cible){ // Renommer la date de création (pas d'abbréviations dans les noms) $maj['0.5.5'] = array(array('sql_alter','TABLE spip_formulaires CHANGE date_crea date_creation datetime NOT NULL DEFAULT "0000-00-00 00:00:00"')); + // statut publie sur les formulaires sans statut + $maj['0.5.6'] = array( + array('sql_updateq','spip_formulaires',array('statut'=>'publie'),"statut=".sql_quote('')), + ); + include_spip('base/upgrade'); maj_plugin($nom_meta_base_version, $version_cible, $maj); } @@ -111,6 +116,11 @@ function formidable_importer_forms(){ // les traitements forms_configure_traitement_formulaire($form,$formulaire); + + // si ce formulaire a des reponses on le met en publie + if (sql_countsel("spip_forms_donnees","id_form=".intval($form['id_form']))) + $formulaire['statut'] = 'publie'; + $id_formulaire = forms_importe_en_base($formulaire); spip_log("Import spip_forms #".$form['id_form']." en spip_formulaires #$id_formulaire","maj"._LOG_INFO_IMPORTANTE); diff --git a/lang/formidable_fr.php b/lang/formidable_fr.php index 97eb59c9..076a6b21 100644 --- a/lang/formidable_fr.php +++ b/lang/formidable_fr.php @@ -31,6 +31,7 @@ $GLOBALS[$GLOBALS['idx_lang']] = array( 'cfg_titre_page_configurer_formidable' => 'Configurer Formidable', 'cfg_titre_parametrages_analyse' => 'Paramétrages de l’analyse des réponses', 'champs' => 'Champs', + 'changer_statut' => 'Ce formulaire est :', // E 'echanger_formulaire_forms_importer' => 'Forms & Tables (.xml)', diff --git a/paquet.xml b/paquet.xml index b2a1fbf9..67dac4d7 100644 --- a/paquet.xml +++ b/paquet.xml @@ -2,10 +2,10 @@ prefix="formidable" categorie="communication" version="2.0.0" - etat="dev" + etat="test" compatibilite="[3.0.0;3.0.*]" logo="images/formidable-64.png" - schema="0.5.5" + schema="0.5.6" documentation="http://www.spip-contrib.net/Formidable-le-generateur-de" > diff --git a/prive/objets/infos/formulaire.html b/prive/objets/infos/formulaire.html index 59afec02..474ce7b3 100644 --- a/prive/objets/infos/formulaire.html +++ b/prive/objets/infos/formulaire.html @@ -2,5 +2,7 @@ <div class='infos'> <div class='numero'><:formidable:voir_numero:><p>#ID_FORMULAIRE</p></div> +[(#FORMULAIRE_INSTITUER_OBJET{formulaire,#ID_FORMULAIRE})] + </div> </BOUCLE_formulaire> \ No newline at end of file diff --git a/prive/objets/infos/formulaires_reponse.html b/prive/objets/infos/formulaires_reponse.html index 04908427..e0859311 100644 --- a/prive/objets/infos/formulaires_reponse.html +++ b/prive/objets/infos/formulaires_reponse.html @@ -2,7 +2,7 @@ <div class='infos'> <div class='numero'><:formidable:reponse_numero:><p>#ID_FORMULAIRES_REPONSE</p></div> -[(#FORMULAIRE_INSTITUER_OBJET{formulaires_reponses,#ID_FORMULAIRES_REPONSE})] +[(#FORMULAIRE_INSTITUER_OBJET{formulaires_reponse,#ID_FORMULAIRES_REPONSE})] </div> </BOUCLE_formulaires_reponse> \ No newline at end of file diff --git a/prive/objets/liste/formulaires.html b/prive/objets/liste/formulaires.html index 0df139d0..606eb157 100644 --- a/prive/objets/liste/formulaires.html +++ b/prive/objets/liste/formulaires.html @@ -20,10 +20,10 @@ <tbody> <BOUCLE_formulaires(FORMULAIRES){id_formulaire?}{statut?}{tri #ENV{order,titre},#GET{defaut_tri}}{recherche?}{pagination #ENV{nb,10}}> <tr class="[(#COMPTEUR_BOUCLE|alterner{row_odd,row_even})][ (#EXPOSE|unique)]"> - <td class="statut">[(#STATUT|puce_statut{formulaire})]</td> + <td class="statut">[(#STATUT|puce_statut{formulaire,#ID_FORMULAIRE})]</td> <td class="titre"><a href="[(#ID_FORMULAIRE|generer_url_entite{formulaire})]">#TITRE</a></td> <td class="identifiant">#IDENTIFIANT</td> - <td class="reponses"><BOUCLE_reponses(FORMULAIRES_REPONSES){id_formulaire} />[<a href="#URL_ECRIRE{formulaires_reponses,id_formulaire=#ID_FORMULAIRE}">(#TOTAL_BOUCLE|singulier_ou_pluriel{formidable:info_1_reponse,formidable:info_nb_reponses})</a>]<//B_reponses></td> + <td class="reponses"><BOUCLE_reponses(FORMULAIRES_REPONSES){id_formulaire}{tout} />[<a href="#URL_ECRIRE{formulaires_reponses,id_formulaire=#ID_FORMULAIRE}">(#TOTAL_BOUCLE|singulier_ou_pluriel{formidable:info_1_reponse,formidable:info_nb_reponses})</a>]<//B_reponses></td> <td class="id_formulaire id">[(#AUTORISER{modifier,formulaire,#ID_FORMULAIRE}|?{ <a href="[(#URL_ECRIRE{formulaire_edit,id_formulaire=#ID_FORMULAIRE})]">#ID_FORMULAIRE</a>, #ID_FORMULAIRE -- GitLab