<zakform>
<element type="zak_cgi_form_element_email">
- <id>email</id>
+ <id>code</id>
<label>E-mail</label>
+ <type>string</type>
+ <is-key>TRUE</is-key>
<validator type="zak_form_element_validator_notempty"></validator>
</element>
<element type="zak_cgi_form_element_email">
<id>email_conferma</id>
<label>Conferma E-mail</label>
+ <to-save>FALSE</to-save>
<validator type="zak_form_element_validator_notempty"></validator>
</element>
<element type="zak_cgi_form_element_text">
<id>name</id>
<label>Nome</label>
+ <type>string</type>
+ <maxlength>100</maxlength>
<filter type="zak_form_element_filter_trim"></filter>
<validator type="zak_form_element_validator_notempty"></validator>
</element>
<element type="zak_cgi_form_element_text">
<id>surname</id>
<label>Cognome</label>
+ <type>string</type>
+ <maxlength>100</maxlength>
<filter type="zak_form_element_filter_trim"></filter>
<validator type="zak_form_element_validator_notempty"></validator>
</element>
<element type="zak_cgi_form_element_submit">
<id>submit</id>
+ <to-save>FALSE</to-save>
<zak-cgi-content>Conferma</zak-cgi-content>
</element>
- <validator type="zak_form_validator_compare" type_comp="e" element1="email" element2="email_conferma"></validator>
+ <validator type="zak_form_validator_compare" type_comp="e" element1="code" element2="email_conferma"></validator>
</zakform>
#endif
#include <libzakform/libzakform.h>
+#include <libzakformgdaex/libzakformgdaex.h>
#include "user.h"
CtplEnviron *env;
ZakCgiForm *form;
+ ZakFormGdaexProvider *form_provider;
gchar *filename;
gchar *content;
GPtrArray *ar_messages;
GString *msg;
+ GError *error;
+ gchar *cnc_string;
+ GdaEx *gdaex_authedb;
+
Commons *commons = (Commons *)user_data;
if (get_is_logged (commons))
zak_cgi_form_bind (form);
if (zak_form_form_is_valid (ZAK_FORM_FORM (form)))
{
- ctpl_environ_push_string (env, "form", "Form is valid!!!");
+ /* leggo i parametri per libzakautho */
+ error = NULL;
+ cnc_string = g_key_file_get_value (commons->config, "ZAKAUTHE", "cnc_string", &error);
+ if (cnc_string == NULL || error != NULL)
+ {
+ g_warning ("Impossibile leggere la stringa di connessione per libzakauthe dal file di configurazione: %s.",
+ error != NULL && error->message != NULL ? error->message : "nessun dettaglio");
+ ctpl_environ_push_string (env, "form", "Form is valid!!! NOT SAVED!!!");
+ }
+ else
+ {
+ gdaex_authedb = gdaex_new_from_string (cnc_string);
+ if (gdaex_authedb == NULL)
+ {
+ g_warning ("Errore nella connessione al database libzakauthe: %s", cnc_string);
+ ctpl_environ_push_string (env, "form", "Form is valid!!! NOT SAVED!!!");
+ }
+ else
+ {
+ form_provider = zak_form_gdaex_provider_new (gdaex_authedb, "users");
+ if (form_provider == NULL)
+ {
+ g_warning ("Errore nella creazione dewl form_provider.");
+ ctpl_environ_push_string (env, "form", "Form is valid!!! NOT SAVED!!!");
+ }
+ else
+ {
+ if (zak_form_form_insert (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (form_provider)))
+ {
+ ctpl_environ_push_string (env, "form", "Form is valid!!! SAVED WITH SUCCESS!!!");
+ }
+ else
+ {
+ ctpl_environ_push_string (env, "form", "Form is valid!!! NOT SAVED!!!");
+ }
+ }
+ }
+ }
}
else
{