%myconfig

by Armaghan Saqib, Thursday, December 15, 2022, 00:27 (498 days ago) @ Armaghan Saqib
edited by Armaghan Saqib, Thursday, December 15, 2022, 00:46

When you add new users in sql-ledger using admin.pl (or through HR--Employees--Add Employee), it is added to the 'users/members' text file. This 'members' file is a text file which stores information in key/value pairs with username as the section name.

Here is one such section:

[admin@demo]
company=UK DEMO
dateformat=mm-dd-yy
dbconnect=dbi:Pg:dbname=demo;host=localhost
dbdriver=Pg
dbhost=localhost
dbname=demo
dboptions=set DateStyle to 'POSTGRES, US'
dbuser=postgres
[email protected]
name=admin
numberformat=1,000.00
password=adZILgCC7Lk7U
stylesheet=sql-ledger.css
templates=demo
vclimit=1000

When this user logs in into sql-ledger, a conf file named after this user is created in the users folder in Perl syntax (actually, a hash variable named %myconfig) and then included in the perl code. For example in this example '[email protected]' will be created and executed whenever you will login or access any sql-ledger function.

Within the sql-ledger Perl code, you can access user configuration from this user hash variable using standard syntax. So $myconfig{dbname} will return the current database name and $myconfig{company} will return the company name.

This Perl hash is also passed from executable scripts to modules (in SL folder) as a reference as part of parameters list. So in modules you access this using hash reference syntax. This means that now $myconfig->{dbname} will return the current database name.

Exercises:

1. Open users/members and see what is in it.
2. Open any conf file in users/ folder and see how user information is stored there.


Complete thread:

 RSS Feed of thread