SproutCMS

This is the code documentation for the SproutCMS project

function logAction()

Stores a history item in the database, recording an add (i.e. insert), edit, or delete.
Should be called AFTER the action has been made.
N.B. This is a low-level method; the friendlier wrapper methods are preferred;
e.g. Controller::logAdd, Controller::logEdit

Usage

int $Controller->logAction ( string $table , int $record_id , int $type , array $data [, int $parent_log_id ] );

Arguments

  1. string $table
    The table which had data modified by the query
  2. int $record_id
    The id of the added/edited/deleted record
  3. int $type
    ENUM value from history_items.type
  4. array $data
    Data associated with an add/edit.
           The handling differs based on the $type parameter:
           'Add' ignored
           'Edit' should be an array of the pre-update data, used to build a diff
           'Delete' should contain the complete data of the deleted record
           'Add category' should contain ['cat_id' => value]
           'Delete category' should contain ['cat_id' => value]
           'Change password' should be an empty array
  5. int $parent_log_id = 0
    ID of a parent log entry in the history_items table.
           This is used when multiple records are deleted by a single action.
           Undoing that action can then restore all of the deleted data.
           N.B. This is only relevant for deletes

Exceptions thrown

  • QueryException

Return value

  • int
    ID of the record inserted into the history_items table;
            0 if no insert was done; -1 if it failed