From 421f899e80d4f66fed251e13607a7db27f0227e1 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Tue, 16 Sep 2008 13:01:21 -0400 Subject: [PATCH] Update api_field.php --- includes/api_field.php | 151 ++++++++++++++++++++--------------------- 1 file changed, 72 insertions(+), 79 deletions(-) diff --git a/includes/api_field.php b/includes/api_field.php index a58dc1d..c75f81b 100644 --- a/includes/api_field.php +++ b/includes/api_field.php @@ -19,32 +19,30 @@ || ################################################################### \*=====================================================================*/ -$GLOBALS['isso:callback']->load('api', null); - +require_once ISSO . '/Api.php'; require_once('./includes/functions_datastore.php'); /** -* API: Field -* -* @author Blue Static -* @copyright Copyright ©2002 - 2007, Blue Static -* @version $Revision$ -* @package Bugdar -* -*/ -class FieldAPI extends API + * API: Field + * + * @author Blue Static + * @copyright Copyright ©2002 - 2007, Blue Static + * @version $Revision$ + * @package Bugdar + * + */ +class FieldAPI extends BSApi { /** - * Fields - * @var array - * @access private - */ - var $fields = array( - 'fieldid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'), - 'name' => array(TYPE_STR, REQ_YES, 'verify_noempty'), + * Fields + * @var array + */ + protected $fields = array( + 'fieldid' => array(TYPE_UINT, REQ_AUTO), + 'name' => array(TYPE_STR, REQ_YES), 'description' => array(TYPE_STR, REQ_NO), - 'type' => array(TYPE_STR, REQ_YES, ':self'), - 'selects' => array(TYPE_STR, REQ_NO, ':self'), + 'type' => array(TYPE_STR, REQ_YES), + 'selects' => array(TYPE_STR, REQ_NO), 'required' => array(TYPE_BOOL, REQ_NO), 'cansearch' => array(TYPE_BOOL, REQ_NO), 'regexmatch' => array(TYPE_STR, REQ_NO), @@ -54,33 +52,27 @@ class FieldAPI extends API ); /** - * Database table - * @var string - * @access private - */ - var $table = 'bugfield'; + * Database table + * @var string + */ + protected $table = 'bugfield'; /** - * Table prefix - * @var string - * @access private - */ - var $prefix = TABLE_PREFIX; + * Table prefix + * @var string + */ + protected $prefix = TABLE_PREFIX; - // ################################################################### /** - * A static method that is used to return an array of all the allowed - * field types. - * - * @access public - * - * @param string Return the display name of a type if the key is passed - * - * @return array An array of all the allowed field types - */ - function field_types($type = null) + * A static method that is used to return an array of all the allowed + * field types. + * + * @param string Return the display name of a type if the key is passed + * + * @return array An array of all the allowed field types + */ + public static function field_types($type = null) { - global $lang; $types = array( 'input_text' => T('Single-Line Text Box'), 'input_checkbox' => T('Checkbox Flag'), @@ -97,71 +89,72 @@ class FieldAPI extends API } } - // ################################################################### /** - * Post-insert - * - * @access private - */ - function post_insert() + * Post-insert + */ + protected function post_insert() { build_user_help(); } - // ################################################################### /** - * Post-update - * - * @access private - */ - function post_update() + * Post-update + */ + protected function post_update() { build_user_help(); } - // ################################################################### /** - * Post-delete - * - * @access private - */ - function post_delete() + * Post-delete + */ + protected function post_delete() { - $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "bugfield WHERE fieldid = " . $this->values['fieldid']); - $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "bugfieldpermission WHERE fieldid = " . $this->values['fieldid']); - $this->registry->db->query("ALTER TABLE " . TABLE_PREFIX . "bug DROP custom" . $this->values['fieldid']); - $this->registry->db->query("OPTIMIZE TABLE " . TABLE_PREFIX . "bug"); + BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "bugfield WHERE fieldid = " . $this->values['fieldid']); + BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "bugfieldpermission WHERE fieldid = " . $this->values['fieldid']); + BSApp::$db->query("ALTER TABLE " . TABLE_PREFIX . "bug DROP custom" . $this->values['fieldid']); + BSApp::$db->query("OPTIMIZE TABLE " . TABLE_PREFIX . "bug"); build_user_help(); } - // ################################################################### /** - * Verify: type - * - * @access private - */ - function verify_type() + * Validate: fieldid + */ + protected function validate_fieldid($field) + { + return $this->_verifyIsNotZero($field); + } + + /** + * Validate: name + */ + protected function validate_name($field) + { + return $this->_verifyIsNotEmpty($field); + } + + /** + * Validate: type + */ + protected function validate_type() { - if (!in_array($this->values['type'], array_keys(FieldAPI::field_types()))) + if (!in_array($this->values['type'], array_keys(self::field_types()))) { return false; } return true; } - // ################################################################### /** - * Verify: selects - * - * @access private - */ - function verify_selects() + * Validate: selects + */ + protected function validate_selects() { static $serialized; - if ($this->values['type'] == 'select_single' OR $this->record['type'] == 'select_single') + if ($this->values['type'] == 'select_single' || $this->record['type'] == 'select_single') { - $this->registry->debug('it works'); + BSApp::debug('it works'); // can't use explode() here because explode() returns !empty() when splitting an empty string // so we have to use preg_split with the PREG_SPLIT_NO_EMPTY flag to prevent this $selects = preg_split("#\n#", trim($this->values['selects']), 0, PREG_SPLIT_NO_EMPTY); -- 2.22.5