How to send current login User-ID to PostgreSQL

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to send current login User-ID to PostgreSQL

pcav
Hi all,
I've unclear how to send current Lizmap user to PostgreSQL. I followed:
https://docs.lizmap.com/current/en/publish/advanced_lizmap_config.html#examples
adding form_variables.js to media/js/default
however, I do not know how to activate this for a specific table/field.
Simply adding
   rilevatore: 'lizmap_user_login'
where rilevatore is the name of the field of one table does not work.
Can I have a more detailed example?
Thanks in advance.
--
Paolo Cavallini - www.faunalia.eu
QGIS.ORG Chair:
http://planet.qgis.org/planet/user/28/tag/qgis%20board/
_______________________________________________
Lizmap mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/lizmap
Reply | Threaded
Open this post in threaded view
|

R: How to send current login User-ID to PostgreSQL

robertomarzocchi
Hi Paolo,

We are using the following script and it works. Actually we do not use firstname, lastname and organization but only login field. 


var formPrefix = 'jforms_view_edition';

// Name of the QGIS vector layer fields which must containt the user info
var userFields = {
    login: 'login',
    firstname: 'lizmap_user_firstname',
    lastname: 'lizmap_user_lastname',
    organization: 'lizmap_user_organization'
};


lizMap.events.on({

    'lizmapeditionformdisplayed': function(e){

        // If user is logged in
        if( $('#info-user-login').length ){
            // Loop through the needed fields
            for( var f in userFields ){
                // If the user has some data for this property
                if( $('#info-user-' + f).text() ){
                    // If the field exists in the form
                    var fi = $('#' + formPrefix + '_' + userFields[f]);
                    if( fi.length ){
                        // Set val from lizmap user data
                        fi.val( $('#info-user-' + f).text() )
                        // Set disabled
                     // fi.attr('disabled', 'disabled');
						fi.hide();
                    }
                }
            }
        }

    }

});




Eng. Roberto Marzocchi, PhD
CTO - Chief Technology Officer
Gter srl (Unige spin-off)
Via Ruffini 9R - 16128 Genova
P.IVA/CF 01998770992
ph: 010-0899150 - mob: 349-8786575

--
Gter social

-----------------------------------------------------------------
Please consider the environment before printing this email!



---- Attivato lun, 24 feb 2020 11:04:57 +0100 Paolo Cavallini <[hidden email]> ha scritto ----

Hi all,
I've unclear how to send current Lizmap user to PostgreSQL. I followed:
https://docs.lizmap.com/current/en/publish/advanced_lizmap_config.html#examples
adding form_variables.js to media/js/default
however, I do not know how to activate this for a specific table/field.
Simply adding
rilevatore: 'lizmap_user_login'
where rilevatore is the name of the field of one table does not work.
Can I have a more detailed example?
Thanks in advance.
--
Paolo Cavallini - www.faunalia.eu
QGIS.ORG Chair:
http://planet.qgis.org/planet/user/28/tag/qgis%20board/
_______________________________________________
Lizmap mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/lizmap



_______________________________________________
Lizmap mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/lizmap
Reply | Threaded
Open this post in threaded view
|

Re: How to send current login User-ID to PostgreSQL

pcav
Thanks Roberto for the reply.
So the variable is not lizmap_user_login, as per the manualk, but simply
login?
It is enough to define:
fieldname: 'login'
for each fieldname in any table to be filled with the login variable?
it is not necessary to define which table should get it, nor a default
variable for the table?
Cheers.

Il 24/02/20 11:55, Roberto Marzocchi ha scritto:

> Hi Paolo,
>
> We are using the following script and it works. Actually we do not use
> firstname, lastname and organization but only login field. 
>
>
> var formPrefix = 'jforms_view_edition';
>
> // Name of the QGIS vector layer fields which must containt the user info
> var userFields = {
>     login: 'login',
>     firstname: 'lizmap_user_firstname',
>     lastname: 'lizmap_user_lastname',
>     organization: 'lizmap_user_organization'
> };
>
>
> lizMap.events.on({
>
>     'lizmapeditionformdisplayed': function(e){
>
>         // If user is logged in
>         if( $('#info-user-login').length ){
>             // Loop through the needed fields
>             for( var f in userFields ){
>                 // If the user has some data for this property
>                 if( $('#info-user-' + f).text() ){
>                     // If the field exists in the form
>                     var fi = $('#' + formPrefix + '_' + userFields[f]);
>                     if( fi.length ){
>                         // Set val from lizmap user data
>                         fi.val( $('#info-user-' + f).text() )
>                         // Set disabled
>                      // fi.attr('disabled', 'disabled');
> fi.hide();
>                     }
>                 }
>             }
>         }
>
>     }
>
> });
>
>
>
>
>
> /Eng. Roberto Marzocchi, PhD/
> /CTO - Chief Technology Officer/
> /Gter srl (Unige spin-off)/
> /Via Ruffini 9R - 16128 Genova /
> /P.IVA/CF/ <http://P.IVA/CF>/01998770992 /
> /ph: 010-//0899150//- mob: 349-8786575 /
> /E-mail: //[hidden email]/
> <mailto:[hidden email]>///www.gter.it/ <http://www.gter.it>//
>
> /-- /
> /Gter social /
> /www.twitter.com/Gteronline/ <http://www.twitter.com/Gteronline>/-
> //www.facebook.com/Gteronline/ <http://www.facebook.com/Gteronline>//
> /www.linkedin.com/company/gter-srl-innovazione-in-geomatica-gnss-e-gis/
> <http://www.linkedin.com/company/gter-srl-innovazione-in-geomatica-gnss-e-gis>//
>
> /----------------------------------------------------------------- /
> /Please consider the environment before printing this email!/
>
>
>
> ---- Attivato lun, 24 feb 2020 11:04:57 +0100 *Paolo Cavallini
> <[hidden email] <mailto:[hidden email]>>* ha scritto ----
>
>     Hi all,
>     I've unclear how to send current Lizmap user to PostgreSQL. I followed:
>     https://docs.lizmap.com/current/en/publish/advanced_lizmap_config.html#examples
>     adding form_variables.js to media/js/default
>     however, I do not know how to activate this for a specific table/field.
>     Simply adding
>     rilevatore: 'lizmap_user_login'
>     where rilevatore is the name of the field of one table does not work.
>     Can I have a more detailed example?
>     Thanks in advance.
>     --
>     Paolo Cavallini - www.faunalia.eu <http://www.faunalia.eu>
>     QGIS.ORG Chair:
>     http://planet.qgis.org/planet/user/28/tag/qgis%20board/
>     _______________________________________________
>     Lizmap mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.osgeo.org/mailman/listinfo/lizmap
>
>
>

--
Paolo Cavallini - www.faunalia.eu
QGIS.ORG Chair:
http://planet.qgis.org/planet/user/28/tag/qgis%20board/
_______________________________________________
Lizmap mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/lizmap
Reply | Threaded
Open this post in threaded view
|

Re: How to send current login User-ID to PostgreSQL

pcav
In reply to this post by robertomarzocchi
one further question: would the variable 'login' or 'lizmap_user_login'
be available for other tasks, e.g. adding to the print layput? If so,
with which syntax?
Thanks.

Il 24/02/20 11:55, Roberto Marzocchi ha scritto:

> Hi Paolo,
>
> We are using the following script and it works. Actually we do not use
> firstname, lastname and organization but only login field. 
>
>
> var formPrefix = 'jforms_view_edition';
>
> // Name of the QGIS vector layer fields which must containt the user info
> var userFields = {
>     login: 'login',
>     firstname: 'lizmap_user_firstname',
>     lastname: 'lizmap_user_lastname',
>     organization: 'lizmap_user_organization'
> };
>
>
> lizMap.events.on({
>
>     'lizmapeditionformdisplayed': function(e){
>
>         // If user is logged in
>         if( $('#info-user-login').length ){
>             // Loop through the needed fields
>             for( var f in userFields ){
>                 // If the user has some data for this property
>                 if( $('#info-user-' + f).text() ){
>                     // If the field exists in the form
>                     var fi = $('#' + formPrefix + '_' + userFields[f]);
>                     if( fi.length ){
>                         // Set val from lizmap user data
>                         fi.val( $('#info-user-' + f).text() )
>                         // Set disabled
>                      // fi.attr('disabled', 'disabled');
> fi.hide();
>                     }
>                 }
>             }
>         }
>
>     }
>
> });
>
>
>
>
>
> /Eng. Roberto Marzocchi, PhD/
> /CTO - Chief Technology Officer/
> /Gter srl (Unige spin-off)/
> /Via Ruffini 9R - 16128 Genova /
> /P.IVA/CF/ <http://P.IVA/CF>/01998770992 /
> /ph: 010-//0899150//- mob: 349-8786575 /
> /E-mail: //[hidden email]/
> <mailto:[hidden email]>///www.gter.it/ <http://www.gter.it>//
>
> /-- /
> /Gter social /
> /www.twitter.com/Gteronline/ <http://www.twitter.com/Gteronline>/-
> //www.facebook.com/Gteronline/ <http://www.facebook.com/Gteronline>//
> /www.linkedin.com/company/gter-srl-innovazione-in-geomatica-gnss-e-gis/
> <http://www.linkedin.com/company/gter-srl-innovazione-in-geomatica-gnss-e-gis>//
>
> /----------------------------------------------------------------- /
> /Please consider the environment before printing this email!/
>
>
>
> ---- Attivato lun, 24 feb 2020 11:04:57 +0100 *Paolo Cavallini
> <[hidden email] <mailto:[hidden email]>>* ha scritto ----
>
>     Hi all,
>     I've unclear how to send current Lizmap user to PostgreSQL. I followed:
>     https://docs.lizmap.com/current/en/publish/advanced_lizmap_config.html#examples
>     adding form_variables.js to media/js/default
>     however, I do not know how to activate this for a specific table/field.
>     Simply adding
>     rilevatore: 'lizmap_user_login'
>     where rilevatore is the name of the field of one table does not work.
>     Can I have a more detailed example?
>     Thanks in advance.
>     --
>     Paolo Cavallini - www.faunalia.eu <http://www.faunalia.eu>
>     QGIS.ORG Chair:
>     http://planet.qgis.org/planet/user/28/tag/qgis%20board/
>     _______________________________________________
>     Lizmap mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.osgeo.org/mailman/listinfo/lizmap
>
>
>

--
Paolo Cavallini - www.faunalia.eu
QGIS.ORG Chair:
http://planet.qgis.org/planet/user/28/tag/qgis%20board/
_______________________________________________
Lizmap mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/lizmap