Events


CodeExtinguisher employs the excellent Khaos :: EventManager library to handle system-wide events. The codexevents.php file in the khaos/plugins/ directory contains the default events. If you want to add you own code (which doesn't override the default events), then you can refer to the EventManager documentation (link provided earlier) to add them.

 

Here is a list of events and their purpose:

 

preInsertHook($data=array())

Gets called before $data is to be sent to the database for insertion. Calls preInsertHook on each plugin.

 

postInsertHook($data=array())

Gets called after $data is formatted for the database, and inserted. Calls postInsertHook on each plugin.

 

preEditHook($table,$id) 

Gets called before $data is to be sent to the database to be updated. Calls preEditHook on each plugin.

 

postEditHook($data) 

Gets called after $data is formatted for the database, and updated. Calls postEditHook on each plugin.

 

preDeleteHook($table,$id) 

Gets called before $id is to be deleted from $table. Calls preDeleteHook on each plugin.

 

postDeleteHook($table,$id) 

Gets called after $id is deleted for $table. Calls postDeleteHook on each plugin.

 

checkRecordOwnership($action,$table,$id)

Establishes that the user has the ability to do $action on the record of $id in $table. If this function returns true, then the user is allowed to take that action. Otherwise, he will get a message telling him that he doesn't have the proper permission.

 

getDbFields($data=array())

Calls getFieldName() on each plugin when data is being requested from the database. Each plugin (unless overridden), returns the name of that plugin as the name of the field. Plugins that return NULL are removed from the return array of this function. This is useful in situations where the plugin doesn't have an associated field in the table (ManyToMany, OneToMany, Template, etc..)

 

getQueryFields($data=array()) 

Calls getQueryName() on each plugin when the main query is getting constructed. getQueryName() in turns calls getFieldName() which returns the name of that plugin as the name of the field. Next, getQueryName prepends the name of the table to the field name. This is very useful when plugins store information in other tables (ManyToMany, OneToMany), and that information needs to get JOIN'd in the main query. Plugins that return NULL are removed from the return array of this function. 

 

prepForDisplay($data=array())

 

prepForDelete($table,$id)

Similar to prepForDisplay, except it doesn't do anything by default, and is there in case your own plugins need to overlaod it.

 

prepForDb($data=array()) 

 

getDbTables() Returns the name of the table associated with that field. Used in the getQueryName() function.