Fix DB_MySQL_PDO::escape_binary().
[bugdar.git] / includes / api_automation.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2002-2007 Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 $GLOBALS['isso:callback']->load('api', null);
23
24 require_once('./includes/functions_datastore.php');
25
26 /**
27 * API: Automation
28 *
29 * @author Blue Static
30 * @copyright Copyright (c)2002 - 2007, Blue Static
31 * @version $Revision$
32 * @package Bugdar
33 *
34 */
35 class AutomationAPI extends API
36 {
37 /**
38 * Fields
39 * @var array
40 * @access private
41 */
42 var $fields = array(
43 'actionid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'),
44 'name' => array(TYPE_STR, REQ_YES, 'verify_noempty'),
45 'description' => array(TYPE_STR, REQ_NO),
46 'fieldchanges' => array(TYPE_NONE, REQ_YES, ':self'),
47 'comment' => array(TYPE_STR, REQ_NO)
48 );
49
50 /**
51 * Table
52 * @var string
53 * @access private
54 */
55 var $table = 'automation';
56
57 /**
58 * Table prefix
59 * @var string
60 * @access private
61 */
62 var $prefix = TABLE_PREFIX;
63
64 // ###################################################################
65 /**
66 * Post-insert
67 *
68 * @access private
69 */
70 function post_insert()
71 {
72 build_automations();
73 }
74
75 // ###################################################################
76 /**
77 * Post-update
78 *
79 * @access private
80 */
81 function post_update()
82 {
83 build_automations();
84 }
85
86 // ###################################################################
87 /**
88 * Post-delete
89 *
90 * @access private
91 */
92 function post_delete()
93 {
94 build_automations();
95 }
96
97 // ###################################################################
98 /**
99 * Verify: fieldchanges
100 *
101 * @access private
102 */
103 function verify_fieldchanges()
104 {
105 if (!is_array($this->values['fieldchanges']) OR sizeof($this->values['fieldchanges']) != 2 OR !is_array($this->values['fieldchanges']['custom']) OR !is_array($this->values['fieldchanges']['builtin']))
106 {
107 return T('Invalid array type passed. The fieldchaneges array must be a two-dimensional array: array("builtin" => array("fieldname" => "newvalue" ...), "custom" => array("fieldname" => "fieldvalue" ...))');
108 }
109
110 if (sizeof($this->values['fieldchanges']['custom']) < 1 AND sizeof($this->values['fieldchanges']['builtin']) < 1)
111 {
112 return T('You need to specify some fields to change.');
113 }
114
115 $this->values['fieldchanges'] = serialize($this->values['fieldchanges']);
116
117 return true;
118 }
119 }
120