]> src.bluestatic.org Git - bugdar.git/blob - includes/api_userhelp.php
Fix a bug in ConstructVersionSelect() that would cause all the versions to be selected
[bugdar.git] / includes / api_userhelp.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright ©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: User help
28 *
29 * @author Blue Static
30 * @copyright Copyright ©2002 - 2007, Blue Static
31 * @version $Revision$
32 * @package Bugdar
33 *
34 */
35 class UserHelpAPI extends API
36 {
37 /**
38 * Fields
39 * @var array
40 * @access private
41 */
42 var $fields = array(
43 'keystring' => array(TYPE_STR, REQ_AUTO),
44 'title' => array(TYPE_STR, REQ_YES, 'verify_noempty'),
45 'body' => array(TYPE_STR, REQ_YES)
46 );
47
48 /**
49 * Database table
50 * @var string
51 * @access private
52 */
53 var $table = 'fieldhelp';
54
55 /**
56 * Table prefix
57 * @var string
58 * @access private
59 */
60 var $prefix = TABLE_PREFIX;
61
62 // ###################################################################
63 /**
64 * A static function that returns an array of all the keystrings that
65 * are not allowed to be deleted
66 *
67 * @access public
68 *
69 * @return array Array of keystrings
70 */
71 function not_able_to_delete()
72 {
73 return array(
74 'assignedto',
75 'bugid',
76 'dateline',
77 'dependency',
78 'duplicateof',
79 'priority',
80 'product',
81 'reporter',
82 'resolution',
83 'severity',
84 'status',
85 'summary',
86 'newreply',
87 'columnorder'
88 );
89 }
90
91 // ###################################################################
92 /**
93 * Pre-insert
94 *
95 * @access private
96 */
97 function pre_insert()
98 {
99 if (($err = $this->verify_keystring()) !== true)
100 {
101 $this->error($err);
102 }
103 }
104
105 // ###################################################################
106 /**
107 * Post-insert
108 *
109 * @access private
110 */
111 function post_insert()
112 {
113 build_user_help();
114 }
115
116 // ###################################################################
117 /**
118 * Post-update
119 *
120 * @access private
121 */
122 function post_update()
123 {
124 build_user_help();
125 }
126
127 // ###################################################################
128 /**
129 * Pre-delete
130 *
131 * @access private
132 */
133 function pre_delete()
134 {
135 if (in_array($this->values['keystring'], UserHelpAPI::not_able_to_delete()))
136 {
137 return false;
138 }
139 return true;
140 }
141
142 // ###################################################################
143 /**
144 * Post-delete
145 *
146 * @access private
147 */
148 function post_delete()
149 {
150 build_user_help();
151 }
152
153 // ###################################################################
154 /**
155 * Verify: keystring
156 *
157 * @access private
158 */
159 function verify_keystring()
160 {
161 if (!is_bool($ne = $this->verify_noempty('keystring')))
162 {
163 return $ne;
164 }
165
166 if (preg_match('#[^a-z0-9_]#', $this->values['keystring']))
167 {
168 return T('The unique key can only contain lowercase letters, underscores, and numbers.');
169 }
170
171 if ($this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "fieldhelp WHERE keystring = '" . $this->registry->escape($this->values['keystring']) . "'"))
172 {
173 return T('The unique key must be unique.');
174 }
175
176 return true;
177 }
178 }
179
180 /*=====================================================================*\
181 || ###################################################################
182 || # $HeadURL$
183 || # $Id$
184 || ###################################################################
185 \*=====================================================================*/
186 ?>