Exemplo n.º 1
0
 $alertRules = MonitisApiHelper::getNotificationRuleByType($monitorType, $groupId);
 if (!$alertRules) {
     $alertRules = MonitisConf::$settings['groups'][$monitorType]['alert'];
 }
 if (is_array($contactsToRemove)) {
     foreach ($contactsToRemove as $contact) {
         $contactInfo = $notifications->existContact($contact);
         $ids = $notifications->getGroupIdsByContcatId($contactInfo['contactId']);
         if (in_array($groupId, $ids)) {
             $indexToRemove = array_search($groupId, $ids);
             array_splice($ids, $indexToRemove, 1);
         }
         $params = array('contactId' => $contactInfo['contactId'], 'contactGroupIds' => implode(',', $ids), 'textType' => '0');
         $response = MonitisApi::editContact($params);
         if ($response['status'] == 'ok') {
             MonitisApiHelper::deleteNotificationRule($contactInfo['contactId'], $monitorType);
         }
     }
 }
 if (is_array($contactsToAdd)) {
     foreach ($contactsToAdd as $contact) {
         $contactInfo = $notifications->existContact($contact);
         if ($contactInfo) {
             $ids = $notifications->getGroupIdsByContcatId($contactInfo['contactId']);
             if (!in_array($groupId, $ids)) {
                 array_push($ids, $groupId);
             }
             $params = array('contactId' => $contactInfo['contactId'], 'contactGroupIds' => implode(",", $ids), 'activeFlag' => 1, 'textType' => '0');
             MonitisApi::editContact($params);
             $notificationRuleIdsOnContact = $notifications->getNotifRuleIds($contactInfo['contactId'], $monitorType);
             if ($notificationRuleIdsOnContact) {