]>
src.bluestatic.org Git - bugdar.git/blob - includes/api_userhelp.php
2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright (c)2004-2008 Blue Static
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.
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
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 \*=====================================================================*/
22 require_once ISSO
. '/Api.php';
24 require_once('./includes/functions_datastore.php');
30 * @copyright Copyright (c)2004 - 2008, Blue Static
34 class UserHelpAPI
extends BSApi
40 protected $fields = array(
41 'keystring' => array(TYPE_STR
, REQ_AUTO
),
42 'title' => array(TYPE_STR
, REQ_YES
),
43 'body' => array(TYPE_STR
, REQ_YES
)
50 protected $table = 'fieldhelp';
56 protected $prefix = TABLE_PREFIX
;
59 * A static function that returns an array of all the keystrings that
60 * are not allowed to be deleted
62 * @return array Array of keystrings
64 public static function not_able_to_delete()
87 protected function post_insert()
95 protected function post_update()
103 protected function pre_delete()
105 if (in_array($this->values
['keystring'], self
::not_able_to_delete()))
107 throw new FieldException(T('You cannot delete this user help text because the system needs it.'), 'keystring');
114 protected function post_delete()
122 protected function validate_title($field)
124 return $this->_verifyIsNotEmpty($field);
130 protected function validate_keystring($field)
132 if ($this->_verifyIsNotEmpty('keystring'))
137 if (preg_match('#[^a-z0-9_]#', $this->values
['keystring']))
139 $this->_error(new FieldException(T('The unique key can only contain lowercase letters, underscores, and numbers.'), $field));
143 if (BSApp
::$db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . BSApp
::$input->escape($this->values
['keystring']) . "'"))
145 $this->_error(new FieldException(T('The unique key must be unique.'), $field));