Index: branches/RC/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r10024 -r10294 --- branches/RC/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 10024) +++ branches/RC/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 10294) @@ -1201,6 +1201,8 @@ $skip_master = false; $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); + $changes_var_name = $this->Prefix.'_changes_'.$this->Application->GetTopmostWid($this->Prefix); + if (!$this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { $live_ids = $temp->SaveEdit($event->getEventParam('master_ids') ? $event->getEventParam('master_ids') : Array()); @@ -1219,7 +1221,12 @@ // NOTE: only works if main item has subitems !!! $this->StoreSelectedIDs($event, $live_ids); } + + $this->SaveLoggedChanges($changes_var_name); } + else { + $this->Application->RemoveVar($changes_var_name); + } $this->clearSelectedIDs($event); $event->redirect_params = Array('opener' => 'u'); @@ -1230,6 +1237,40 @@ } } + function SaveLoggedChanges($changes_var_name) + { + $ses_log_id = $this->Application->RecallVar('_SessionLogId_'); + if (!$ses_log_id) { + return ; + } + + $changes = $this->Application->RecallVar($changes_var_name); + $changes = $changes ? unserialize($changes) : Array (); + if (!$changes) { + return ; + } + + $add_fields = Array ( + 'PortalUserId' => $this->Application->RecallVar('user_id'), + 'SessionLogId' => $ses_log_id, + ); + + $changelog_table = $this->Application->getUnitOption('change-log', 'TableName'); + $sessionlog_table = $this->Application->getUnitOption('session-log', 'TableName'); + + foreach ($changes as $rec) { + $this->Conn->doInsert(array_merge($rec, $add_fields), $changelog_table); + } + + $sql = 'UPDATE '.$sessionlog_table.' + SET AffectedItems = AffectedItems + '.count($changes).' + WHERE SessionLogId = '.$ses_log_id; + $this->Conn->Query($sql); + + $this->Application->RemoveVar($changes_var_name); + } + + /** * Cancels edit * Removes all temp tables and clears selected ids