Example #1
0
 private static function trigger($action, $params)
 {
     CTrigger::$error = array();
     switch ($action) {
         case 'add':
             $result = CTrigger::add($params);
             break;
         case 'get':
             $result = CTrigger::get($params);
             break;
         case 'getById':
             $result = CTrigger::getById($params);
             break;
         case 'getId':
             $result = CTrigger::getId($params);
             break;
         case 'update':
             $result = CTrigger::update($params);
             break;
         case 'delete':
             $result = CTrigger::delete($params);
             break;
         default:
             self::$result = array('error' => ZBX_API_ERROR_NO_METHOD, 'data' => 'Method: "' . $action . '" doesn\'t exist.');
             return;
             //exit function
     }
     if ($result !== false) {
         self::$result = array('result' => $result);
     } else {
         self::$result = array_shift(CTrigger::$error);
     }
 }
Example #2
0
                                                 $triggerids = array();
                                                 $options = array('triggerids' => $_REQUEST['g_triggerid'], 'editable' => 1, 'select_hosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND, 'expandDescription' => 1);
                                                 $triggers = CTrigger::get($options);
                                                 foreach ($triggers as $tnum => $trigger) {
                                                     if ($trigger['templateid'] != 0) {
                                                         unset($triggers[$tnum]);
                                                         error(S_CANNOT_DELETE_TRIGGER . ' [ ' . $trigger['description'] . ' ] (' . S_TEMPLATED_TRIGGER . ')');
                                                         continue;
                                                     }
                                                     $triggerids[] = $trigger['triggerid'];
                                                     $host = reset($trigger['hosts']);
                                                     add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_TRIGGER, $trigger['triggerid'], $host['host'] . ':' . $trigger['description'], NULL, NULL, NULL);
                                                 }
                                                 $go_result = !empty($triggerids);
                                                 if ($go_result) {
                                                     $go_result = CTrigger::delete($triggerids);
                                                 }
                                                 $go_result = DBend($go_result);
                                                 show_messages($go_result, S_TRIGGERS_DELETED, S_CANNOT_DELETE_TRIGGERS);
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }