Index: branches/5.2.x/core/units/logs/change_logs/change_log_eh.php =================================================================== diff -u -N -r14244 -r14639 --- branches/5.2.x/core/units/logs/change_logs/change_log_eh.php (.../change_log_eh.php) (revision 14244) +++ branches/5.2.x/core/units/logs/change_logs/change_log_eh.php (.../change_log_eh.php) (revision 14639) @@ -1,22 +1,61 @@ getObject(); - /* @var $object kDBItem */ + /** + * Allows to override standard permission mapping + * + */ + function mapPermissions() + { + parent::mapPermissions(); - $sql = 'UPDATE ' . $this->Application->getUnitOption('session-log', 'TableName') . ' - SET AffectedItems = AffectedItems - 1 - WHERE SessionLogId = ' . $object->GetDBField('SessionLogId'); - $this->Conn->Query($sql); - } - } \ No newline at end of file + $permissions = Array ( + 'OnEnableLog' => Array ('self' => 'view'), + ); + + $this->permMapping = array_merge($this->permMapping, $permissions); + } + + /** + * Updates affected record count in session, when change log record is deleted + * + * @param kEvent $event + */ + function OnAfterItemDelete(&$event) + { + parent::OnAfterItemDelete($event); + + $object =& $event->getObject(); + /* @var $object kDBItem */ + + $sql = 'UPDATE ' . $this->Application->getUnitOption('session-log', 'TableName') . ' + SET AffectedItems = AffectedItems - 1 + WHERE SessionLogId = ' . $object->GetDBField('SessionLogId'); + $this->Conn->Query($sql); + } + + /** + * Changes configuration value to enable log writing + * + * @param kEvent $event + */ + function OnEnableLog(&$event) + { + $this->Application->SetConfigValue('UseChangeLog', 1); + } +} \ No newline at end of file