169 public static function actualizeHandlers($chainId, array $fieldsNew =
null, array $fieldsOld =
null)
181 if($settingsOld && $settingsOld->isClosedTrigger())
184 $agentName = Trigger\Manager::getClosedEventAgentName(
185 $settingsOld->getEventModuleId(),
186 $settingsOld->getEventType(),
190 $agent = new \CAgent;
191 $agentListDb = $agent->GetList(array(), array(
'MODULE_ID' =>
'sender',
'NAME' => $agentName));
192 while($agentItem = $agentListDb->Fetch())
193 $agent->Delete($agentItem[
'ID']);
198 if($settingsNew && $settingsNew->isClosedTrigger())
201 $chainDb = MailingChainTable::getList(array(
202 'select' => array(
'ID'),
203 'filter' => array(
'=ID' => $chainId,
'=MAILING.ACTIVE' =>
'Y')
205 if(!$chainDb->fetch())
209 $agentName = Trigger\Manager::getClosedEventAgentName(
210 $settingsNew->getEventModuleId(),
211 $settingsNew->getEventType(),
216 $agentTime = $settingsNew->getClosedTriggerTime();
217 $agentInterval = $settingsNew->getClosedTriggerInterval();
218 if($agentInterval <= 0) $agentInterval = 1440;
220 $agentTimeArray = explode(
":", $agentTime);
222 $agentDate->
setTime((
int)$agentTimeArray[0], (
int)$agentTimeArray[1]);
225 if($agentDate->getTimestamp() < time())
226 $agentDate->add(
"1 days");
229 $agent = new \CAgent;
230 $agent->AddAgent($agentName,
'sender',
'N', $agentInterval*60,
'',
'Y', $agentDate->toString());
236 if($settingsOld && !$settingsOld->isClosedTrigger() && $settingsOld->getFullEventType())
240 if(!$settingsNew || $settingsOld->getFullEventType() != $settingsNew->getFullEventType())
242 Trigger\Manager::actualizeHandler(array(
243 'MODULE_ID' => $settingsOld->getEventModuleId(),
244 'EVENT_TYPE' => $settingsOld->getEventType(),
245 'CALLED_BEFORE_CHANGE' =>
true
251 if($settingsNew && $settingsNew->getFullEventType())
253 $calledBeforeChange = ($fieldsOld ? false :
true);
254 Trigger\Manager::actualizeHandler(array(
255 'MODULE_ID' => $settingsNew->getEventModuleId(),
256 'EVENT_TYPE' => $settingsNew->getEventType(),
257 'CALLED_BEFORE_CHANGE' => $calledBeforeChange
272 $entity = static::getEntity();
273 $connection = $entity->getConnection();
275 \CTimeZone::disable();
277 'DELETE FROM %s WHERE %s',
278 $connection->getSqlHelper()->quote($entity->getDbTableName()),
279 Query::buildFilterSql($entity, $filter)
281 $res = $connection->query($sql);
282 \CTimeZone::enable();