When the user Searches for data in my list, I want to log the request in a table, along with when the search was done, what was searched for, the IP for the search, and how many records were retrieved.
What's the best way to trap the search event and log this?
Log Search
Re: Log Search
Hi,
I would suggest you use the hooks/TABLENAME.php -> init function. Here you can catch the $_REQUEST array and the $_SERVER to catch most of your data. For the amount for matches you need to run the query with the search once.
I would suggest you use the hooks/TABLENAME.php -> init function. Here you can catch the $_REQUEST array and the $_SERVER to catch most of your data. For the amount for matches you need to run the query with the search once.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.
Re: Log Search
I don't understand yet how to hook into the Search process to log the results I'm looking for.
Re: Log Search
Hi,
do as pbötcher suggested: Open the /hooks/tablename.php file in an editor, search for the function tablename_init and use PHP to read the $_REQUEST string.
If it's a search, then isolate the items and formulate the sql request. Once done, use that to retrieve the number of items the search will return (imho not very useful, as this value probably changes over time).
Write all data that you want to log into some logging table. Then simply continue with the "regular" page.
I would suggest, you create a new function for your purpose and simply call that function from within the _init function. This will make handling things in the future much easier for you.
Olaf
do as pbötcher suggested: Open the /hooks/tablename.php file in an editor, search for the function tablename_init and use PHP to read the $_REQUEST string.
If it's a search, then isolate the items and formulate the sql request. Once done, use that to retrieve the number of items the search will return (imho not very useful, as this value probably changes over time).
Write all data that you want to log into some logging table. Then simply continue with the "regular" page.
I would suggest, you create a new function for your purpose and simply call that function from within the _init function. This will make handling things in the future much easier for you.
Olaf
Some postings I was involved, you might find useful:
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view
SingleEdit - Prevent concurrent edits on records; Field Permissions; Column-Value-Based-Permissions; Custom (error) message; Audit Log; Backup your database; Two Factor Authentication; Block brute force (failed) logins; Add 2nd SAVE CHANGES button; Place a search on details view