Index: branches/5.1.x/core/units/logs/session_logs/session_log_eh.php =================================================================== diff -u -N -r13086 -r13161 --- branches/5.1.x/core/units/logs/session_logs/session_log_eh.php (.../session_log_eh.php) (revision 13086) +++ branches/5.1.x/core/units/logs/session_logs/session_log_eh.php (.../session_log_eh.php) (revision 13161) @@ -1,6 +1,6 @@ Update(); } + /** + * Don't allow to delete other user's messages + * + * @param kEvent $event + */ + function customProcessing(&$event, $type) + { + if ($event->Name == 'OnMassDelete' && $type == 'before') { + $ids = $event->getEventParam('ids'); + if ($ids) { + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); + $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); + + $sql = 'SELECT ' . $id_field . ' + FROM ' . $table_name . ' + WHERE ' . $id_field . ' IN (' . implode(',', $ids) . ') AND Status <> ' . SESSION_LOG_ACTIVE; + $allowed_ids = $this->Conn->GetCol($sql); + + $event->setEventParam('ids', $allowed_ids); + } + } + } + + /** + * Delete changes, related to deleted session + * + * @param kEvent $event + */ + function OnAfterItemDelete(&$event) + { + parent::OnAfterItemDelete($event); + + $object =& $event->getObject(); + /* @var $object kDBItem */ + + $sql = 'SELECT ' . $this->Application->getUnitOption('change-log', 'IDField') . ' + FROM ' . $this->Application->getUnitOption('change-log', 'TableName') . ' + WHERE SessionLogId = ' . $object->GetID(); + $related_ids = $this->Conn->GetCol($sql); + + if ($related_ids) { + $temp_handler =& $this->Application->recallObject('change-log_TempHandler', 'kTempTablesHandler'); + /* @var $temp_handler kTempTablesHandler */ + + $temp_handler->DeleteItems('change-log', '', $related_ids); + } + } + } \ No newline at end of file