3
** Copyright (C) 2000-2005 SIA Zabbix
5
** This program is free software; you can redistribute it and/or modify
6
** it under the terms of the GNU General Public License as published by
7
** the Free Software Foundation; either version 2 of the License, or
8
** (at your option) any later version.
10
** This program is distributed in the hope that it will be useful,
11
** but WITHOUT ANY WARRANTY; without even the implied warranty of
12
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
** GNU General Public License for more details.
15
** You should have received a copy of the GNU General Public License
16
** along with this program; if not, write to the Free Software
17
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
32
int DBadd_action(int triggerid, int userid, char *subject, char *message, int scope, int severity, int recipient, int usrgrpid)
34
char sql[MAX_STRING_LEN];
36
char subject_esc[ACTION_SUBJECT_LEN_MAX];
37
char message_esc[MAX_STRING_LEN];
39
DBescape_string(subject,subject_esc,ACTION_SUBJECT_LEN_MAX);
40
DBescape_string(message,message_esc,MAX_STRING_LEN);
42
if(recipient == RECIPIENT_TYPE_GROUP)
47
snprintf(sql, sizeof(sql)-1,"insert into actions (triggerid, userid, subject, message, scope, severity, recipient) values (%d, %d, '%s', '%s', %d, %d, %d)", triggerid, userid, subject_esc, message_esc, scope, severity, recipient);
49
actionid = DBinsert_id(DBexecute(sql), "actions", "actionid");
59
int DBget_action_by_actionid(int actionid,DB_ACTION *action)
63
char sql[MAX_STRING_LEN];
66
zabbix_log( LOG_LEVEL_DEBUG, "In DBget_action_by_actionid(%d)", actionid);
68
snprintf(sql,sizeof(sql)-1,"select userid,recipient,subject,message from actions where actionid=%d", actionid);
78
action->actionid=actionid;
79
action->userid=atoi(row[0]);
80
action->recipient=atoi(row[1]);
81
action->subject=strdup(row[2]);
82
action->message=strdup(row[3]);
85
DBfree_result(result);