From 9191d7401d9b0e1cc5b3c811e197076aa5c022be Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 6 Sep 2008 14:18:38 -0400 Subject: [PATCH] Update api_comment.php --- includes/api_comment.php | 97 ++++++++++++++++++++++------------------ 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/includes/api_comment.php b/includes/api_comment.php index cd9e0a5..c191dfe 100644 --- a/includes/api_comment.php +++ b/includes/api_comment.php @@ -33,53 +33,44 @@ require_once ISSO . '/Api.php'; class CommentAPI extends BSApi { /** - * Fields - * @var array - * @access private - */ - var $fields = array( - 'commentid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'), - 'bugid' => array(TYPE_UINT, REQ_YES, 'verify_nozero'), + * Fields + * @var array + */ + protected $fields = array( + 'commentid' => array(TYPE_UINT, REQ_AUTO), + 'bugid' => array(TYPE_UINT, REQ_YES), 'userid' => array(TYPE_UINT, REQ_NO), 'dateline' => array(TYPE_UINT, REQ_SET), 'parselinks' => array(TYPE_BOOL, REQ_NO), - 'comment' => array(TYPE_STR, REQ_YES, 'verify_noempty'), + 'comment' => array(TYPE_STR, REQ_YES), 'comment_parsed' => array(TYPE_NONE, REQ_SET), 'hidden' => array(TYPE_BOOL, REQ_NO) ); /** - * Database table - * @var string - * @access private - */ - var $table = 'comment'; + * Database table + * @var string + */ + protected $table = 'comment'; /** - * Table prefix - * @var string - * @access private - */ - var $prefix = TABLE_PREFIX; + * Table prefix + * @var string + */ + protected $prefix = TABLE_PREFIX; - // ################################################################### /** - * Set field: dateline - * - * @access private - */ - function set_dateline() + * Set field: dateline + */ + protected function set_dateline() { $this->set('dateline', time()); } - // ################################################################### /** - * Set field: comment_parsed - * - * @access private - */ - function set_comment_parsed() + * Set field: comment_parsed + */ + protected function set_comment_parsed() { $comment = $this->values['comment']; if ($this->values['parselinks']) @@ -91,7 +82,7 @@ class CommentAPI extends BSApi if (bugdar::$options['allowhtml']) { - $this->set('comment_parsed', nl2br($this->registry->unsanitize($comment))); + $this->set('comment_parsed', nl2br(BSApp::$input->unsanitize($comment))); } else { @@ -99,30 +90,48 @@ class CommentAPI extends BSApi } } - // ################################################################### /** - * Pre-update - * - * @access private - */ - function pre_update() + * Pre-update + */ + protected function pre_update() { $this->set_comment_parsed(); } - // ################################################################### /** - * Pre-delete - * - * @access private - */ - function pre_delete() + * Pre-delete + */ + protected function pre_delete() { - if ($this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE initialreport = " . $this->values['commentid'])) + if (BSApp::$db->queryFirst("SELECT * FROM " . TABLE_PREFIX . "bug WHERE initialreport = " . $this->values['commentid'])) { $this->error(T('You cannot delete this comment because it is attached to the bug as the first comment. You have to delete the entire bug instead (which is not recommended unless it is spam).')); } } + + /** + * Validate: commentid + */ + protected function validate_commentid($field) + { + return $this->_verifyIsNotZero($field); + } + + /** + * Validate: Bug ID + */ + protected function validate_bugid($field) + { + return $this->_verifyIsNotZero($field); + } + + /** + * Validate: comment + */ + protected function validate_comment($field) + { + return $this->_verifyIsNotEmpty($field); + } } /*=====================================================================*\ -- 2.22.5