Пример #1
0
 /**
  * Delete trigger by ids.
  *
  * @param array $triggerIds
  */
 protected function deleteByIds(array $triggerIds)
 {
     // others idx should be deleted as well if they arise at some point
     DB::delete('profiles', ['idx' => 'web.events.filter.triggerid', 'value_id' => $triggerIds]);
     DB::delete('sysmaps_elements', ['elementid' => $triggerIds, 'elementtype' => SYSMAP_ELEMENT_TYPE_TRIGGER]);
     // disable actions
     $actionIds = [];
     $dbActions = DBselect('SELECT DISTINCT actionid' . ' FROM conditions' . ' WHERE conditiontype=' . CONDITION_TYPE_TRIGGER . ' AND ' . dbConditionString('value', $triggerIds));
     while ($dbAction = DBfetch($dbActions)) {
         $actionIds[$dbAction['actionid']] = $dbAction['actionid'];
     }
     DBexecute('UPDATE actions SET status=' . ACTION_STATUS_DISABLED . ' WHERE ' . dbConditionInt('actionid', $actionIds));
     // delete action conditions
     DB::delete('conditions', ['conditiontype' => CONDITION_TYPE_TRIGGER, 'value' => $triggerIds]);
     if ($this->usedInItServices($triggerIds)) {
         DB::update('services', ['values' => ['triggerid' => null, 'showsla' => SERVICE_SHOW_SLA_OFF], 'where' => ['triggerid' => $triggerIds]]);
         updateItServices();
     }
     parent::deleteByIds($triggerIds);
 }
Пример #2
0
 /**
  * Delete trigger by ids.
  *
  * @param array $triggerIds
  */
 protected function deleteByIds(array $triggerIds)
 {
     // others idx should be deleted as well if they arise at some point
     DB::delete('profiles', array('idx' => 'web.events.filter.triggerid', 'value_id' => $triggerIds));
     DB::delete('events', array('objectid' => $triggerIds, 'object' => EVENT_OBJECT_TRIGGER));
     DB::delete('sysmaps_elements', array('elementid' => $triggerIds, 'elementtype' => SYSMAP_ELEMENT_TYPE_TRIGGER));
     // disable actions
     $actionIds = array();
     $dbActions = DBselect('SELECT DISTINCT actionid' . ' FROM conditions' . ' WHERE conditiontype=' . CONDITION_TYPE_TRIGGER . ' AND ' . dbConditionString('value', $triggerIds, false, true));
     while ($dbAction = DBfetch($dbActions)) {
         $actionIds[$dbAction['actionid']] = $dbAction['actionid'];
     }
     DBexecute('UPDATE actions SET status=' . ACTION_STATUS_DISABLED . ' WHERE ' . dbConditionInt('actionid', $actionIds));
     // delete action conditions
     DB::delete('conditions', array('conditiontype' => CONDITION_TYPE_TRIGGER, 'value' => $triggerIds));
     // unlink triggers from IT services
     foreach ($triggerIds as $triggerId) {
         updateServices($triggerId, SERVICE_STATUS_OK);
     }
     DB::update('services', array('values' => array('triggerid' => null, 'showsla' => SERVICE_SHOW_SLA_OFF), 'where' => array('triggerid' => $triggerIds)));
     parent::deleteByIds($triggerIds);
 }