]> saetta.ns0.it Git - bcity/fe/commitdiff
Saving new user.
authorAndrea Zagli <azagli@libero.it>
Sun, 7 Feb 2016 17:00:29 +0000 (18:00 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 7 Feb 2016 17:00:29 +0000 (18:00 +0100)
configure.ac
data/bcity_fe/form/user_register.form
debugcgi.sh [new file with mode: 0755]
src/commons.h
src/user.c

index fc359a2ea89d53d4dcc8423dd6686978665c5fda..8c66f32df5394fa07973ba37f15256f3a2d7bc58 100644 (file)
@@ -48,7 +48,8 @@ PKG_CHECK_MODULES(BCITYFE, [glib-2.0 >= 2.36
                             libzakautho >= 0.0.5
                             libzakutils
                             libzakform
-                            libzakcgi])
+                            libzakcgi
+                            libzakformgdaex])
 
 AC_SUBST(BCITYFE_CFLAGS)
 AC_SUBST(BCITYFE_LIBS)
index 3404934cb681e5b19b049ef87a9c02e9f0dab6d8..00b456fe0544e82ba8bc02d20bcc633145da18ff 100644 (file)
@@ -2,20 +2,25 @@
 <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>
diff --git a/debugcgi.sh b/debugcgi.sh
new file mode 100755 (executable)
index 0000000..f57bf57
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+PID=`ps ax | grep bcity_fe | grep -v grep | awk ' { print $1 }'`
+gdb --pid $PID
index a239d5a73ba7a6bddb4d3e0ed4ff68789183609c..4ead6fafdc495b8140e5fbf3c575982974d9a8d2 100644 (file)
@@ -43,8 +43,6 @@ typedef struct
                gulong hid_main_on_before_execute;
                gulong hid_main_on_after_execute;
 
-               GdaEx *gdaex_sit;
-
                ZakCgiMain *zcgi_main;
                ZakCgiSession *zcgi_session;
 
index f984d0ccc083c6659bab441a644de7e2af3ec64e..0f5c6c635e56cae8802033c78b8b95d44c561b2e 100644 (file)
@@ -21,6 +21,7 @@
 #endif
 
 #include <libzakform/libzakform.h>
+#include <libzakformgdaex/libzakformgdaex.h>
 
 #include "user.h"
 
@@ -30,6 +31,7 @@ user_register (GMatchInfo *minfo, gpointer user_data)
        CtplEnviron *env;
 
        ZakCgiForm *form;
+       ZakFormGdaexProvider *form_provider;
 
        gchar *filename;
        gchar *content;
@@ -38,6 +40,10 @@ user_register (GMatchInfo *minfo, gpointer user_data)
        GPtrArray *ar_messages;
        GString *msg;
 
+       GError *error;
+       gchar *cnc_string;
+       GdaEx *gdaex_authedb;
+
        Commons *commons = (Commons *)user_data;
 
        if (get_is_logged (commons))
@@ -63,7 +69,44 @@ user_register (GMatchInfo *minfo, gpointer user_data)
                                        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
                                                {