2 /*=====================================================================*\
3 || ###################################################################
5 || # Copyright ©2002-2007 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 ©2002 - 2007, Blue Static
35 class UserHelpAPI
extends BSApi
41 protected $fields = array(
42 'keystring' => array(TYPE_STR
, REQ_AUTO
),
43 'title' => array(TYPE_STR
, REQ_YES
),
44 'body' => array(TYPE_STR
, REQ_YES
)
51 protected $table = 'fieldhelp';
57 protected $prefix = TABLE_PREFIX
;
60 * A static function that returns an array of all the keystrings that
61 * are not allowed to be deleted
63 * @return array Array of keystrings
65 public static function not_able_to_delete()
88 protected function post_insert()
96 protected function post_update()
104 protected function pre_delete()
106 if (in_array($this->values
['keystring'], self
::not_able_to_delete()))
108 throw new FieldException(T('You cannot delete this user help text because the system needs it.'), 'keystring');
115 protected function post_delete()
123 protected function validate_title($field)
125 return $this->_verifyIsNotEmpty($field);
131 protected function validate_keystring($field)
133 if ($this->_verifyIsNotEmpty('keystring'))
138 if (preg_match('#[^a-z0-9_]#', $this->values
['keystring']))
140 $this->_error(new FieldException(T('The unique key can only contain lowercase letters, underscores, and numbers.'), $field));
144 if (BSApp
::$db->queryFirst("SELECT * FROM " . TABLE_PREFIX
. "fieldhelp WHERE keystring = '" . BSApp
::$input->escape($this->values
['keystring']) . "'"))
146 $this->_error(new FieldException(T('The unique key must be unique.'), $field));
154 /*=====================================================================*\
155 || ###################################################################
158 || ###################################################################
159 \*=====================================================================*/