The existing manager log is implemented by this function around line 1880 (Revo 2.3.1) of the core/model/modx/modx.class.php file:
/**
* Logs a manager action.
*
* @param string $action The action to pull from the lexicon module.
* @param string $class_key The class key that the action is being performed on.
* @param mixed $item The primary key id or array of keys to grab the object with.
* @return modManagerLog The newly created modManagerLog object.
*/
public function logManagerAction($action, $class_key, $item) {
$userId = 0;
if ($this->user instanceof modUser) {
$userId = $this->user->get('id');
}
$ml = $this->newObject('modManagerLog');
$ml->set('user', (integer) $userId);
$ml->set('occurred', strftime('%Y-%m-%d %H:%M:%S'));
$ml->set('action', empty($action) ? 'unknown' : $action);
$ml->set('classKey', empty($class_key) ? '' : $class_key);
$ml->set('item', empty($item) ? 'unknown' : $item);
if (!$ml->save()) {
$this->log(modX::LOG_LEVEL_ERROR, $this->lexicon('manager_log_err_save'));
return null;
}
return $ml;
}
And this is the schema of the manager_log table:
<object class="modManagerLog" table="manager_log" extends="xPDOSimpleObject">
<field key="user" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="occurred" dbtype="datetime" phptype="datetime" null="true" default="0000-00-00 00:00:00" />
<field key="action" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
<field key="classKey" dbtype="varchar" precision="100" phptype="string" null="false" default="" />
<field key="item" dbtype="varchar" precision="255" phptype="string" null="false" default="0" />
<aggregate alias="User" class="modUser" local="user" foreign="id" owner="foreign" cardinality="one" />
</object>
You can find the calls to the logManagerAction function in the core/model/modx/modprocessor.class.php with its various abstract processor classes. For example, in the process function of the abstract class modObjectCreateProcessor on line 659 you will see
$this->fireAfterSaveEvent();
$this->logManagerAction();
return $this->cleanup();
This means that every MODX object will automatically have a row inserted into the manager_log table after the new object has been saved.
[ed. note: sottwell last edited this post 11 years, 11 months ago.]