- Модуль: main
- Путь к файлу: ~/bitrix/modules/main/lib/eventlog/notification.php
- Класс: BitrixMainEventLogNotification
- Вызов: Notification::checkConditions
static function checkConditions($id)
{
$notification = new static($id);
$notification->fill();
if($notification->getAuditTypeId() == '')
{
//nonexistent
return '';
}
$interval = intval($notification->getCheckInterval());
$dateInterval = new MainTypeDateTime();
$dateInterval->add("-T{$interval}M");
$notification->setDateChecked(new MainTypeDateTime());
$result = $notification->data->save();
if(!$result->isSuccess())
{
return '';
}
$filter = QueryQuery::filter()
->where("AUDIT_TYPE_ID", $notification->getAuditTypeId())
->where("TIMESTAMP_X", ">", $dateInterval);
if($notification->getItemId() <> '')
{
$filter->whereLike("ITEM_ID", '%'.$notification->getItemId().'%');
}
if($notification->getUserId() > 0)
{
$filter->where("USER_ID", $notification->getUserId());
}
if($notification->getRemoteAddr() <> '')
{
$filter->whereLike("REMOTE_ADDR", '%'.$notification->getRemoteAddr().'%');
}
if($notification->getUserAgent() <> '')
{
$filter->whereLike("USER_AGENT", '%'.$notification->getUserAgent().'%');
}
if($notification->getRequestUri() <> '')
{
$filter->whereLike("REQUEST_URI", '%'.$notification->getRequestUri().'%');
}
$eventCount = EventLogTable::query()
->addSelect(new FieldsExpressionField('CNT', 'COUNT(1)'))
->where($filter)
->fetch();
if($eventCount["CNT"] >= $notification->getAlertCount())
{
//notification triggered
$notification->setEventCount($eventCount["CNT"]);
$notification->send();
}
return static::getAgentName($id);
}