Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/logs/system_logs/system_log_eh.php
Show All 21 Lines | |||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function SetCustomQuery(kEvent $event) | protected function SetCustomQuery(kEvent $event) | ||||
{ | { | ||||
parent::SetCustomQuery($event); | parent::SetCustomQuery($event); | ||||
/** @var kDBList $object */ | |||||
$object = $event->getObject(); | $object = $event->getObject(); | ||||
/* @var $object kDBList */ | |||||
if ( $event->Special == 'email' ) { | if ( $event->Special == 'email' ) { | ||||
$unique_id = $event->getEventParam('unique_id'); | $unique_id = $event->getEventParam('unique_id'); | ||||
if ( $unique_id !== false ) { | if ( $unique_id !== false ) { | ||||
$object->addFilter('notification_filter', '%1$s.LogNotificationStatus = ' . kLogger::LNS_SENT); | $object->addFilter('notification_filter', '%1$s.LogNotificationStatus = ' . kLogger::LNS_SENT); | ||||
$object->addFilter('unique_filter', '%1$s.LogUniqueId = ' . $unique_id); | $object->addFilter('unique_filter', '%1$s.LogUniqueId = ' . $unique_id); | ||||
} | } | ||||
else { | else { | ||||
$object->addFilter('notification_filter', '%1$s.LogNotificationStatus = ' . kLogger::LNS_PENDING); | $object->addFilter('notification_filter', '%1$s.LogNotificationStatus = ' . kLogger::LNS_PENDING); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* [SCHEDULED TASK] Sends delayed notification of system log messages | * [SCHEDULED TASK] Sends delayed notification of system log messages | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
* @return void | * @return void | ||||
* @access protected | * @access protected | ||||
*/ | */ | ||||
protected function OnSendNotifications(kEvent $event) | protected function OnSendNotifications(kEvent $event) | ||||
{ | { | ||||
// initialize list outside of e-mail event with right settings | // initialize list outside of e-mail event with right settings | ||||
/** @var kDBList $list */ | |||||
$list = $this->Application->recallObject($event->Prefix . '.email', $event->Prefix . '_List', Array ('per_page' => 20)); | $list = $this->Application->recallObject($event->Prefix . '.email', $event->Prefix . '_List', Array ('per_page' => 20)); | ||||
/* @var $list kDBList */ | |||||
if ( !$list->GetRecordsCount() ) { | if ( !$list->GetRecordsCount() ) { | ||||
// no messages, that needs to be sent | // no messages, that needs to be sent | ||||
return; | return; | ||||
} | } | ||||
$notification_email = $this->Application->ConfigValue('SystemLogNotificationEmail'); | $notification_email = $this->Application->ConfigValue('SystemLogNotificationEmail'); | ||||
if ( !$notification_email ) { | if ( !$notification_email ) { | ||||
$this->Application->removeObject($event->Prefix . '.email'); | $this->Application->removeObject($event->Prefix . '.email'); | ||||
trigger_error('System Log notification E-mail not specified', E_USER_NOTICE); | trigger_error('System Log notification E-mail not specified', E_USER_NOTICE); | ||||
return; | return; | ||||
} | } | ||||
$send_params = Array ( | $send_params = Array ( | ||||
'to_name' => $notification_email, | 'to_name' => $notification_email, | ||||
'to_email' => $notification_email, | 'to_email' => $notification_email, | ||||
); | ); | ||||
$this->Application->emailAdmin('SYSTEM.LOG.NOTIFY', null, $send_params); | $this->Application->emailAdmin('SYSTEM.LOG.NOTIFY', null, $send_params); | ||||
$this->Application->removeObject($event->Prefix . '.email'); | $this->Application->removeObject($event->Prefix . '.email'); | ||||
/** @var kDBItem $object */ | |||||
$object = $event->getObject(Array ('skip_autoload' => true)); | $object = $event->getObject(Array ('skip_autoload' => true)); | ||||
/* @var $object kDBItem */ | |||||
foreach ($list as $fields_hash) { | foreach ($list as $fields_hash) { | ||||
$object->LoadFromHash($fields_hash); | $object->LoadFromHash($fields_hash); | ||||
$object->SetDBField('LogNotificationStatus', kLogger::LNS_SENT); | $object->SetDBField('LogNotificationStatus', kLogger::LNS_SENT); | ||||
$object->Update(); | $object->Update(); | ||||
} | } | ||||
} | } | ||||
Show All 15 Lines | |||||
$sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . ' | $sql = 'SELECT ' . $this->Application->getUnitOption($event->Prefix, 'IDField') . ' | ||||
FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . ' | FROM ' . $this->Application->getUnitOption($event->Prefix, 'TableName') . ' | ||||
WHERE ' . TIMENOW . ' - LogTimestamp > ' . $rotation_interval . ' | WHERE ' . TIMENOW . ' - LogTimestamp > ' . $rotation_interval . ' | ||||
LIMIT 0,50'; | LIMIT 0,50'; | ||||
$ids = $this->Conn->GetCol($sql); | $ids = $this->Conn->GetCol($sql); | ||||
if ( $ids ) { | if ( $ids ) { | ||||
/** @var kTempTablesHandler $temp_handler */ | |||||
$temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | $temp_handler = $this->Application->recallObject($event->getPrefixSpecial() . '_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event)); | ||||
/* @var $temp_handler kTempTablesHandler */ | |||||
$temp_handler->DeleteItems($event->Prefix, $event->Special, $ids); | $temp_handler->DeleteItems($event->Prefix, $event->Special, $ids); | ||||
} | } | ||||
} | } | ||||
} | } |