This is an update to for the logs taken from the initial post located here: https://fabrikar.com/forums/index.php?threads/doc-logs-plugin.12308/
-------------------------------------------------------------------------------------------
Installation
-------------------------------------------------------------------------------------------
Usage
This plugin must be installed and added to your form.
There are several configuration
Options which range from
- logging to database
- Logging to file (csv, htm, txt)
- logging to email
-------------------------------------------------------------------------------------------
Screenshot of settings (older version)
-------------------------------------------------------------------------------------------
Plugin configuration (based on the latest version in Joomla 3 series)
-------------------------------------------------------------------------------------------
Record in DB
- Will records the logs in the database
- Yes/No
Table suffix
Leave blank to record into the default #__{package}_log table. Enter a suffix (e.g. _history) to automatically create and then fill a custom DB based on the table from where the records are added/edited (if the form stores records in the table jos_fb_mytable, the logs will be stored in jos_fb_mytable_history with the example suffix is given above).
-------------------------------------------------------------------------------------------
Date format
-------------------------------------------------------------------------------------------
Record IP
Record user Referrer?
Record User Agent?
-------------------------------------------------------------------------------------------
OR template message
Customize the message to store in the file and/or DB.
- Use {tablename___elementname} Placeholders to insert the form's data into the message.</li><li>{Add/Edit} will be replaced by added/edited.
- {DATE} will be replaced by the date defined above.
- Use {$_SERVER->REMOTE_ADDR}, {$_SERVER->HTTP_REFERER} and {$_SERVER->HTTP_USER_AGENT} to record those data.
- For creating a CSV file labels and/or recording into a custom table (see 'Suffix table' option above), define the labels/fields by putting them between '++' (specify the fieldtype if you record in DB with ==) and the data to record between double quotes.
- Examples and info at http://bit.ly/3TFwEl
Example Templates for CSV data
In #__fabrik_log and/or a TXT or HTM file: you can record a human-readable sentence such as:
"User Fedepia added a record entitled This is my title, on 2009-08-25 09:10:32. His IP is XXX.XXX.XX.XX"
Template message:
User {$my->username} {Add/Edit} a record entitled {testfabrik___title_element}, on {DATE}. His IP is {$_SERVER->REMOTE_ADDR}
In custom DB and/or CSV file: you will need to define the fields/CSV labels and also the data to record:
Fields/CSV labels --> username, action, title, date, ip
Data to record -----> Fedepia, added, This is my title, 2009-08-25 09:10:32, XXX.XXX.XX.XX
Template message for CSV only:
++username++ "{$my->username}" ++action++ "{Add/Edit}" ++title++ "{testfabrik___title_element}" ++date++ "{DATE}" ++ip++ "{$_SERVER->REMOTE_ADDR}"
or
++username++ ++action++ ++title++ ++date++ ++ip++ "{$my->username}" "{Add/Edit}" "{testfabrik___title_element}" "{DATE}" "{$_SERVER->REMOTE_ADDR}"
Template message for CSV AND/OR Custom DB:
++username==varchar++ "{$my->username}" ++action==varchar++ "{Add/Edit}" ++title==varchar++ "{testfabrik___title_element}" ++date==datetime++ "{DATE}" ++ip==varchar++ "{$_SERVER->REMOTE_ADDR}"
or
++username==varchar++ ++action==varchar++ ++title==varchar++ ++date=datetime++ ++ip==varchar++ "{$my->username}" "{Add/Edit}" "{testfabrik___title_element}" "{DATE}" "{$_SERVER->REMOTE_ADDR}"
Combining readable sentence and fields/CSV labels: Indeed, you may want both by using either:
- A readable sentence to record in #__fabrik_log AND a CSV file.
- A custom Database AND a readable sentence in a TXT or HTM file.
In both cases template message
User ++username==varchar++ "{$my->username}" ++action==varchar++ "{Add/Edit}" a record entitled ++title==varchar++ "{testfabrik___title_element}", on ++date==datetime++ "{DATE}". His ip is ++ip==varchar++ "{$_SERVER->REMOTE_ADDR}"
-------------------------------------------------------------------------------------------
Compare data (Work In Progress!!)
If 'Yes' then the changes made on an edited record will be displayed in the file and/or DB
-------------------------------------------------------------------------------------------
Record in File
Will records the logs in a file
Path
Path, starting from the J!Root, where the log files will be stored. Default use the existing folder 'logs/'. Use {tablename___elementname}
Placeholders to insert the form's data into the path (e.g logs/mydir/{mytable___userelement}/). The folder(s) will be created if not exists. WITH ending slash.
examples
logs/by_user/form_id_{testfabrik___fabrik_internal_id}/
logs/{$my->username}/formname/
Filename
Name of the log file. Use {tablename___elementname}
Placeholders to insert the form's data into the filename (e.g logs_user{mytable___userelement}). The file will be opened if it already exists or will be created if it doesn't. Without space or special characters.
example
formname-{$my->username}
Add random filename
Will add a random filename after the one you choose above, depending on the length you specify below. THE 'APPEND METHOD' BELOW WILL NOT WORK WITH THIS OPTION TURNED ON!
Length
Length of the random filename to generate
File format
File format you want to use. If CSV and if you choose the Append option below, please choose once and for all which data (IP, Referrer, ...) will be stored and don't change it afterwards as the columns will not match anymore.
Dataset separator
Separator to use between different datasets within the same file (for HTM or TXT only)
Append or Overwrite
If Append is selected, the new log data will be added at the end of the file. If Overwrite is selected, the new log data will replace existing ones
-------------------------------------------------------------------------------------------
Record details view
Will keep track of users visiting a record's details view depending on what you want to register. For now, this is recording in the default #__{package}_log DB
If visitor
If the user visiting the details view is not a registered one, what do we do? 'No' won't record anything, 'IP Address' will record the visitor's IP and 'Generic' will record 'Visitor' in the DB
Record form load
Record loading of the page in form view (as well as submitting of form)
-------------------------------------------------------------------------------------------
Send Email
Send an email with the log summary
Email To
Comma separated list of email addresses (no spaces!), may use
Placeholders
Email Subject
The subject line for email may use
Placeholders.