Sackgesicht VIP
Total posts: 1,636
04 Май 2016 06:59

Is there a way to create own events, beside the existing events?

Is there a special api available for event recording in audit log? I dont want to insert records to it manually.

Something like eventRecord($event_id, $parameter) where $event_id is a free defined id higher than the existing ID's (maybe starting with 100) and $parameter an optional parameter, which can be stored in the params column. It will automatically insert all the other columns like record_id, section_id, user_id, type_id, ctime, ip etc.

Последние изменения: 10 Май 2016


Sergey
Total posts: 13,748
05 Май 2016 16:17

For audit log you can use

ATlog::log($record, 'my_custom_event');

Where record is an object or ID of the record.


Sackgesicht VIP
Total posts: 1,636
06 Май 2016 02:08

An additional parameter ($params) would complete the existing setup.

Naming it ADDlog::log($record, 'my_custom_event', $params) would be more obvious then ATlog::log.....


Sergey
Total posts: 13,748
10 Май 2016 07:26

It is names AT after Audit Trail.

What params for?


Sackgesicht VIP
Total posts: 1,636
10 Май 2016 08:15

$params can be a universal storage for something additional to the action.... it can hold an URL for example, it can be a text etc

Example: I have an upload field for PDF. This upload file holds 12 PDF files and i can open them from the list view. Now i want to record the click when i open a PDf. To know which PDF i opened, i need the URL or name of the file, otherwise the audit trail entry would almost be useless, since i dont know which file was clicked.

There are other scenarions, where the action and the record_id would not be enough to describe what happened.


Sergey
Total posts: 13,748
10 Май 2016 11:18

You can always attach additional data to $record.

$record['PDF Clicked'] = $file;

Or

$record->PDF_Clicked = $file;

Depending on what you pass to ATlog Array or Object.

Работает на Cobalt