array(TYPE_STR, REQ_AUTO), 'title' => array(TYPE_STR, REQ_YES), 'body' => array(TYPE_STR, REQ_YES) ); /** * Database table * @var string */ protected $table = 'fieldhelp'; /** * Table prefix * @var string */ protected $prefix = TABLE_PREFIX; /** * A static function that returns an array of all the keystrings that * are not allowed to be deleted * * @return array Array of keystrings */ public static function not_able_to_delete() { return array( 'assignedto', 'bugid', 'dateline', 'dependency', 'duplicateof', 'priority', 'product', 'reporter', 'resolution', 'severity', 'status', 'summary', 'newreply', 'columnorder' ); } /** * Post-insert */ protected function post_insert() { build_user_help(); } /** * Post-update */ protected function post_update() { build_user_help(); } /** * Pre-delete */ protected function pre_delete() { if (in_array($this->values['keystring'], self::not_able_to_delete())) { throw new FieldException(T('You cannot delete this user help text because the system needs it.'), 'keystring'); } } /** * Post-delete */ protected function post_delete() { build_user_help(); } /** * Validate: title */ protected function validate_title($field) { return $this->_verifyIsNotEmpty($field); } /** * Verify: keystring */ protected function validate_keystring($field) { if ($this->_verifyIsNotEmpty('keystring')) { return false; } if (preg_match('#[^a-z0-9_]#', $this->values['keystring'])) { $this->_error(new FieldException(T('The unique key can only contain lowercase letters, underscores, and numbers.'), $field)); return false; } if (BSApp::$db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "fieldhelp WHERE keystring = '" . BSApp::$input->escape($this->values['keystring']) . "'")) { $this->_error(new FieldException(T('The unique key must be unique.'), $field)); return false; } return true; } } ?>