...
 
Commits (4)
#Descriptif du plugin
![](http://dev.lutece.paris.fr/jenkins/buildStatus/icon?job=form-plugin-form-deploy)
# Descriptif du plugin
Create a form in front-office pages from a back-office interface.
......
......@@ -3,7 +3,7 @@
<parent>
<artifactId>lutece-global-pom</artifactId>
<groupId>fr.paris.lutece.tools</groupId>
<version>3.0.11</version>
<version>4.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>fr.paris.lutece.plugins</groupId>
......
......@@ -104,7 +104,6 @@ public class Form implements AdminWorkgroupResource, RBACResource
private boolean _bAutomaticCleaning;
private boolean _bCleaningByRemoval;
private int _nNbDaysBeforeCleaning;
private int _nMaxNumberResponse;
/**
* Initialize the Form
......@@ -897,26 +896,4 @@ public class Form implements AdminWorkgroupResource, RBACResource
{
this._nNbDaysBeforeCleaning = nNbDaysBeforeCleaning;
}
/**
* Set the maximum number of responses before deactivation of the form
*
* @param nMaxNumberResponse
* The maximum number of responses
*/
public void setMaxNumberResponse( int nMaxNumberResponse )
{
this._nMaxNumberResponse = nMaxNumberResponse;
}
/**
* Get the the maximum number of responses before deactivation of the form
*
* @return The maximum number of responses
*/
public int getMaxNumberResponse( )
{
return this._nMaxNumberResponse;
}
}
......@@ -62,28 +62,28 @@ public final class FormDAO implements IFormDAO
+ "libelle_validate_button,libelle_reset_button,date_begin_disponibility,date_end_disponibility,"
+ " active,auto_publication,date_creation,limit_number_response,id_recap,active_requirement,information_1,"
+ " information_2,information_3,information_4,information_5, supports_https, code_theme, active_mylutece_authentification,"
+ " id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning, max_number_response" + " FROM form_form WHERE id_form = ?";
+ " id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning" + " FROM form_form WHERE id_form = ?";
private static final String SQL_QUERY_INSERT = "INSERT INTO form_form ( id_form,title,front_office_title,is_shown_front_office_title,description, welcome_message,"
+ "unavailability_message,requirement_message,workgroup,"
+ "id_mailing_list,active_captcha,active_store_adresse,"
+ "libelle_validate_button,libelle_reset_button,date_begin_disponibility,"
+ " date_end_disponibility,active,auto_publication,date_creation,limit_number_response,"
+ " id_recap,active_requirement,information_1,information_2,information_3,information_4,information_5, "
+ " supports_https, code_theme, active_mylutece_authentification, id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning, max_number_response ) "
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ " supports_https, code_theme, active_mylutece_authentification, id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning ) "
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
private static final String SQL_QUERY_DELETE = "DELETE FROM form_form WHERE id_form = ? ";
private static final String SQL_QUERY_UPDATE = "UPDATE form_form SET id_form=?,title=?,front_office_title=?,is_shown_front_office_title=?,description=?, welcome_message=?,"
+ "unavailability_message=?, requirement_message=?,workgroup=?,"
+ "id_mailing_list=?,active_captcha=?,active_store_adresse=?,"
+ "libelle_validate_button=?,libelle_reset_button=?,date_begin_disponibility=?,date_end_disponibility=?,active=?,auto_publication=?,limit_number_response=? ,active_requirement=?,"
+ "information_1=? ,information_2=? ,information_3=? ,information_4=? ,information_5=?, supports_https = ?, code_theme = ?, "
+ "active_mylutece_authentification=? ,id_category=?, automatic_cleaning = ?, cleaning_by_removal = ?, nb_days_before_cleaning = ?,max_number_response=? WHERE id_form=?";
+ "active_mylutece_authentification=? ,id_category=?, automatic_cleaning = ?, cleaning_by_removal = ?, nb_days_before_cleaning = ? WHERE id_form=?";
private static final String SQL_QUERY_SELECT_FORM_BY_FILTER = "SELECT id_form,title,front_office_title,is_shown_front_office_title,description, welcome_message,"
+ "unavailability_message, requirement_message,workgroup,"
+ "id_mailing_list,active_captcha,active_store_adresse,"
+ "libelle_validate_button,libelle_reset_button,date_begin_disponibility,date_end_disponibility,active,"
+ " auto_publication,date_creation,limit_number_response,id_recap,active_requirement,information_1,"
+ " information_2,information_3,information_4,information_5,supports_https, code_theme, active_mylutece_authentification, id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning, max_number_response "
+ " information_2,information_3,information_4,information_5,supports_https, code_theme, active_mylutece_authentification, id_category, automatic_cleaning, cleaning_by_removal, nb_days_before_cleaning "
+ " FROM form_form ";
private static final String SQL_QUERY_SELECT_ALL_THEMES = "SELECT id_form, code_theme FROM form_form";
private static final String SQL_QUERY_FIND_ANONYMIZE_ENTRIES = " SELECT id_entry FROM form_anonymize_fields WHERE id_form = ? ";
......@@ -186,7 +186,6 @@ public final class FormDAO implements IFormDAO
daoUtil.setBoolean( nIndex++, form.getAutomaticCleaning( ) );
daoUtil.setBoolean( nIndex++, form.getCleaningByRemoval( ) );
daoUtil.setInt( nIndex++, form.getNbDaysBeforeCleaning( ) );
daoUtil.setInt( nIndex++, form.getMaxNumberResponse( ) );
daoUtil.executeUpdate( );
daoUtil.free( );
......@@ -254,7 +253,6 @@ public final class FormDAO implements IFormDAO
form.setAutomaticCleaning( daoUtil.getBoolean( nIndex++ ) );
form.setCleaningByRemoval( daoUtil.getBoolean( nIndex++ ) );
form.setNbDaysBeforeCleaning( daoUtil.getInt( nIndex++ ) );
form.setMaxNumberResponse( daoUtil.getInt( nIndex++ ) );
}
daoUtil.free( );
......@@ -323,7 +321,6 @@ public final class FormDAO implements IFormDAO
daoUtil.setBoolean( nIndex++, form.getAutomaticCleaning( ) );
daoUtil.setBoolean( nIndex++, form.getCleaningByRemoval( ) );
daoUtil.setInt( nIndex++, form.getNbDaysBeforeCleaning( ) );
daoUtil.setInt( nIndex++, form.getMaxNumberResponse( ) );
daoUtil.setInt( nIndex++, form.getIdForm( ) );
......@@ -490,7 +487,6 @@ public final class FormDAO implements IFormDAO
form.setAutomaticCleaning( daoUtil.getBoolean( nIndex++ ) );
form.setCleaningByRemoval( daoUtil.getBoolean( nIndex++ ) );
form.setNbDaysBeforeCleaning( daoUtil.getInt( nIndex++ ) );
form.setMaxNumberResponse( daoUtil.getInt( nIndex++ ) );
formList.add( form );
}
......
......@@ -139,8 +139,6 @@ createForm.labelActiveRequirement=Enable requirement
createForm.labelActiveRequirementComment=The user must activate requirement before submit form
createForm.labelLimitNumberResponse=Limit number of answers
createForm.labelLimitNumberResponseComment=Limit the number of answers by just one answer by people who validate the form.
createForm.labelMaxNumberResponse=Maximum number of answers
createForm.labelMaxNumberResponseComment=Limit the total number of answers. ( "0" = No limit).
createForm.labelLibelleBackUrl=Back URL
createForm.labelPublication=Publication
createForm.labelPublicationMode=Publication mode
......
......@@ -137,8 +137,6 @@ createForm.labelActiveRequirement=Activer les conditions d'utilisation
createForm.labelActiveRequirementComment=Oblige l'utilisateur &#224; valider les conditions d'utilisation avant de soumettre le formulaire.
createForm.labelLimitNumberResponse=Limiter le nombre de r\u00e9ponses
createForm.labelLimitNumberResponseComment=Permet de n'autoriser qu'une seule r\u00e9ponse par r\u00e9pondant.
createForm.labelMaxNumberResponse=Nombre maximum de r\u00e9ponses
createForm.labelMaxNumberResponseComment=Permet de limiter le nombre total de r\u00e9ponses au formulaire. ( "0" = pas de limite).
createForm.labelLibelleBackUrl=URL de retour
createForm.labelPublication=Publication
createForm.labelPublicationMode=Mode de publication
......
......@@ -536,15 +536,6 @@ public class FormApp implements XPageApplication
return null;
}
ResponseFilter responseFilter = new ResponseFilter( );
responseFilter.setIdResource( Integer.parseInt( strFormId ) );
// If max number of responses is set and reached, then deactivate access to the form
if ( ( form.getMaxNumberResponse( ) > 0 ) && ( FormSubmitHome.getCountFormSubmit( responseFilter, plugin ) >= form.getMaxNumberResponse( ) ) )
{
model.put( MARK_MESSAGE_FORM_INACTIVE, form.getUnavailabilityMessage( ) );
}
// Check if the session contains all the attributes set by the mandatory EntryTypeSession
if ( !FormService.getInstance( ).isSessionValid( form, request ) )
{
......
......@@ -183,7 +183,6 @@ public abstract class ModifyFormJspBean extends FormJspBean
private static final String PARAMETER_CLEANING_BY_REMOVAL = "cleaningByRemoval";
private static final String PARAMETER_NB_DAYS_BEFORE_CLEANING = "nb_days_before_cleaning";
private static final String PARAMETER_WORKGROUP = "workgroup";
private static final String PARAMETER_MAX_NUMBER_RESPONSE = "max_number_response";
// other constants
private static final String EMPTY_STRING = "";
......@@ -1053,7 +1052,6 @@ public abstract class ModifyFormJspBean extends FormJspBean
String strActiveMyLuteceAuthentification = request.getParameter( PARAMETER_ACTIVE_MYLUTECE_AUTHENTIFICATION );
String strSupportsHTTPS = request.getParameter( PARAMETER_SUPPORT_HTTPS );
String strActiveCaptcha = request.getParameter( PARAMETER_ACTIVE_CAPTCHA );
String strMaxNumberResponse = request.getParameter( PARAMETER_MAX_NUMBER_RESPONSE );
form.setWorkgroup( strWorkgroup );
......@@ -1113,17 +1111,6 @@ public abstract class ModifyFormJspBean extends FormJspBean
form.setInfoComplementary5( strInformationComplementary5 );
}
try
{
int nMaxNumberResponse = Integer.parseInt( strMaxNumberResponse );
form.setMaxNumberResponse( nMaxNumberResponse >= 0 ? nMaxNumberResponse : 0 );
}
catch( NumberFormatException ne )
{
AppLogService.error( ne.getMessage( ), ne );
return getHomeUrl( request );
}
return null; // No error
}
......
......@@ -153,7 +153,6 @@ CREATE TABLE form_form (
automatic_cleaning SMALLINT default 0,
cleaning_by_removal SMALLINT default 0,
nb_days_before_cleaning INT default 0,
max_number_response INT default 0,
PRIMARY KEY (id_form)
);
......
......@@ -56,7 +56,7 @@ INSERT INTO form_export_format (id_export,title,description,extension,xsl_file)
-- register an exemple form
INSERT INTO form_recap (id_recap, back_url, id_graph_type, recap_message, recap_data, graph, graph_three_dimension, graph_legende, graph_value_legende, graph_label) VALUES (1,'jsp/site/Portal.jsp',2,'Merci pour vos réponses.',1,1,1,0,NULL,1);
INSERT INTO form_form (id_form, title, description, welcome_message, unavailability_message, requirement_message, workgroup, id_mailing_list, active_captcha, active_store_adresse, libelle_validate_button, libelle_reset_button, date_begin_disponibility, date_end_disponibility, active, auto_publication, date_creation, limit_number_response, id_recap, active_requirement, code_theme,automatic_cleaning,cleaning_by_removal,nb_days_before_cleaning,max_number_response) VALUES (1,'Qu''attendez vous d''un CMS open-source ?','Décrivez nous vos attentes pour un CMS open-source.','<p>Les réponses seront effacées toutes les heures environ.\r\n</p>\r\n<p>Les choix par défaut sont ceux retenus pour Lutece.\r\n</p>','Le formulaire n''est plus disponible.','Les réponses seront effacées toutes les 3 heures environ.\r\n<br />','all',0,0,1,'Soumettre','Réinitialiser',NULL,NULL,1,0,'2009-06-16 10:49:31',0,1,0,NULL,0,0,30,0);
INSERT INTO form_form (id_form, title, description, welcome_message, unavailability_message, requirement_message, workgroup, id_mailing_list, active_captcha, active_store_adresse, libelle_validate_button, libelle_reset_button, date_begin_disponibility, date_end_disponibility, active, auto_publication, date_creation, limit_number_response, id_recap, active_requirement, code_theme,automatic_cleaning,cleaning_by_removal,nb_days_before_cleaning) VALUES (1,'Qu''attendez vous d''un CMS open-source ?','Décrivez nous vos attentes pour un CMS open-source.','<p>Les réponses seront effacées toutes les heures environ.\r\n</p>\r\n<p>Les choix par défaut sont ceux retenus pour Lutece.\r\n</p>','Le formulaire n''est plus disponible.','Les réponses seront effacées toutes les 3 heures environ.\r\n<br />','all',0,0,1,'Soumettre','Réinitialiser',NULL,NULL,1,0,'2009-06-16 10:49:31',0,1,0,NULL,0,0,30);
INSERT INTO form_form_parameter (parameter_key, parameter_value) VALUES ('active_captcha', '0');
INSERT INTO form_form_parameter (parameter_key, parameter_value) VALUES ('limit_number_response', '0');
......
ALTER TABLE form_form ADD COLUMN max_number_response INT default 0;
\ No newline at end of file
......@@ -58,23 +58,16 @@ public class EntryHomeTest extends LuteceTestCase
private final static int ID_ENTRY_TYPE_1 = 1;
private final Plugin _plugin = PluginService.getPlugin( "form" );
/**
* The the creation of an entry
*/
public void testCreate( )
public Entry createEntry( )
{
FormHomeTest formHomeTest = new FormHomeTest( );
formHomeTest.testCreate( );
Form form = formHomeTest.createForm( );
Entry entry = new Entry( );
EntryType entryType = new EntryType( );
entryType.setIdType( ID_ENTRY_TYPE_1 );
FormDAO formDAO = new FormDAO( );
int LastPrimaryKey = formDAO.newPrimaryKey( _plugin ) - 1;
Form form = FormHome.findByPrimaryKey( LastPrimaryKey, _plugin );
entry.setComment( COMMENT_1 );
entry.setEntryType( entryType );
entry.setFieldInLine( FIELD_IN_LINE_1 );
......@@ -85,6 +78,15 @@ public class EntryHomeTest extends LuteceTestCase
entry.setTitle( TITLE_1 );
EntryHome.create( entry );
return entry;
}
/**
* The the creation of an entry
*/
public void testCreate( )
{
Entry entry = createEntry( );
Entry storedEntry = EntryHome.findByPrimaryKey( entry.getIdEntry( ) );
......@@ -125,7 +127,7 @@ public class EntryHomeTest extends LuteceTestCase
*/
public void testUpdate( )
{
Entry loadEntry = EntryHome.findByPrimaryKey( ID_ENTRY_1 );
Entry loadEntry = createEntry( );
Entry entry = new Entry( );
......
......@@ -57,10 +57,7 @@ public class FormHomeTest extends LuteceTestCase
private final static boolean LIMIT_NUMBER_RESPONSE_2 = false;
private final Plugin _plugin = PluginService.getPlugin( "form" );
/**
* Test of create method, of class fr.paris.lutece.plugins.form.business.FormHome.
*/
public void testCreate( )
public Form createForm( )
{
Form form = new Form( );
form.setTitle( TITLE_1 );
......@@ -85,6 +82,17 @@ public class FormHomeTest extends LuteceTestCase
recap.setIdRecap( RecapHome.create( recap, _plugin ) );
form.setRecap( recap );
FormHome.create( form, _plugin );
return form;
}
/**
* Test of create method, of class fr.paris.lutece.plugins.form.business.FormHome.
*/
public void testCreate( )
{
Form form = createForm( );
Form storedForm = FormHome.findByPrimaryKey( form.getIdForm( ), _plugin );
......@@ -113,7 +121,7 @@ public class FormHomeTest extends LuteceTestCase
*/
public void testCopy( )
{
Form loadForm = FormHome.findByPrimaryKey( ID_1, _plugin );
Form loadForm = createForm( );
FormHome.copy( loadForm, _plugin );
......@@ -145,12 +153,9 @@ public class FormHomeTest extends LuteceTestCase
*/
public void testUpdate( )
{
FormDAO formDAO = new FormDAO( );
int LastPrimaryKey = formDAO.newPrimaryKey( _plugin ) - 1;
Form loadForm = FormHome.findByPrimaryKey( LastPrimaryKey, _plugin );
Form form = new Form( );
form.setIdForm( loadForm.getIdForm( ) );
Form form = createForm( );
form.setTitle( TITLE_2 );
form.setDescription( DESCRIPTION_2 );
form.setWelcomeMessage( WELCOME_MESSAGE_2 );
......@@ -170,7 +175,7 @@ public class FormHomeTest extends LuteceTestCase
form.setLimitNumberResponse( LIMIT_NUMBER_RESPONSE_2 );
Recap recap = new Recap( );
recap.setIdRecap( loadForm.getRecap( ).getIdRecap( ) );
recap.setIdRecap( form.getRecap( ).getIdRecap( ) );
form.setRecap( recap );
FormHome.update( form, _plugin );
......@@ -217,13 +222,12 @@ public class FormHomeTest extends LuteceTestCase
*/
public void testRemove( )
{
FormDAO formDAO = new FormDAO( );
int LastPrimaryKey = formDAO.newPrimaryKey( _plugin ) - 1;
Form loadForm = FormHome.findByPrimaryKey( LastPrimaryKey, _plugin );
FormHome.remove( loadForm.getIdForm( ), _plugin );
Form form = createForm( );
FormHome.remove( form.getIdForm( ), _plugin );
Form formStored = FormHome.findByPrimaryKey( loadForm.getIdForm( ), _plugin );
Form formStored = FormHome.findByPrimaryKey( form.getIdForm( ), _plugin );
assertNull( formStored );
}
}
......@@ -57,10 +57,7 @@ public class ResponseHomeTest extends LuteceTestCase
private final static String VALUE_RESPONSE_1 = "response value 1";
private final static String VALUE_RESPONSE_2 = "response value 2";
/**
* Test the creation of a response
*/
public void testCreate( )
public Response createResponse( )
{
Response response = new Response( );
......@@ -88,6 +85,16 @@ public class ResponseHomeTest extends LuteceTestCase
response.setResponseValue( VALUE_RESPONSE_1 );
ResponseHome.create( response );
return response;
}
/**
* Test the creation of a response
*/
public void testCreate( )
{
Response response = createResponse( );
Response responseStored = ResponseHome.findByPrimaryKey( response.getIdResponse( ) );
......@@ -104,7 +111,7 @@ public class ResponseHomeTest extends LuteceTestCase
*/
public void testUpdate( )
{
Response responseLoad = ResponseHome.findByPrimaryKey( ID_RESPONSE_1 );
Response responseLoad = createResponse( );
Response response = new Response( );
......@@ -152,7 +159,7 @@ public class ResponseHomeTest extends LuteceTestCase
*/
public void testRemove( )
{
Response responseLoad = ResponseHome.findByPrimaryKey( ID_RESPONSE_1 );
Response responseLoad = createResponse( );
ResponseHome.remove( responseLoad.getIdResponse( ) );
......
......@@ -35,9 +35,6 @@
<@formGroup labelFor='limit_number_response' labelKey='#i18n{form.createForm.labelLimitNumberResponse}' helpKey='#i18n{form.createForm.labelLimitNumberResponseComment}'>
<@checkBox name='limit_number_response' id='limit_number_response' value='1' checked=form?exists && form.limitNumberResponse />
</@formGroup>
<@formGroup labelFor='max_number_response' labelKey='#i18n{form.createForm.labelMaxNumberResponse}' helpKey='#i18n{form.createForm.labelMaxNumberResponseComment}'>
<@input name='max_number_response' id='max_number_response' type='number' value=form.maxNumberResponse!'0' />
</@formGroup>
<@formGroup labelFor='active_store_adresse' labelKey='#i18n{form.createForm.labelStoreAdresse}' helpKey='#i18n{form.createForm.labelStoreAdresseComment}'>
<@checkBox labelFor='active_store_adresse' name='active_store_adresse' id='active_store_adresse' value='1' checked=form?exists && form.activeStoreAdresse />
</@formGroup>
......