1<?php
2
3// Pandora FMS - http://pandorafms.com
4// ==================================================
5// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
6// Please see http://pandorafms.org for full contribution list
7
8// This program is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Lesser General Public License
10// as published by the Free Software Foundation; version 2
11
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16
17/**
18 * @package Include
19 * @subpackage Post Process
20 */
21
22// Load global vars
23global $config;
24
25function post_process_get_custom_values() {
26	global $config;
27
28	if (!isset($config['post_process_custom_values'])) {
29		$return = array();
30	}
31	else {
32		$return = json_decode(
33			$config['post_process_custom_values'], true);
34	}
35
36	if (empty($return)) {
37		$return = array();
38	}
39
40	return $return;
41}
42
43function post_process_add_custom_value($text, $value) {
44	global $config;
45
46	$value = (string)$value;
47
48	$post_process_custom_values = post_process_get_custom_values();
49
50	$post_process_custom_values[$value] = $text;
51
52	$new_conf = json_encode($post_process_custom_values);
53	$return = config_update_value(
54		'post_process_custom_values', $new_conf);
55
56	if ($return) {
57		$config['post_process_custom_values'] = $new_conf;
58
59		return true;
60	}
61	else {
62		return false;
63	}
64}
65
66function post_process_delete_custom_value($value) {
67	global $config;
68
69	$post_process_custom_values = post_process_get_custom_values();
70
71	unset($post_process_custom_values[$value]);
72
73	$new_conf = json_encode($post_process_custom_values);
74	$return = config_update_value(
75		'post_process_custom_values', $new_conf);
76
77	if ($return) {
78		$config['post_process_custom_values'] = $new_conf;
79
80		return true;
81	}
82	else {
83		return false;
84	}
85}
86?>