Update api_comment.php
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 6 Sep 2008 18:18:38 +0000 (14:18 -0400)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 6 Sep 2008 18:18:38 +0000 (14:18 -0400)
includes/api_comment.php

index cd9e0a578689aa66e3cb29f965eb9ffb437fdd42..c191dfe65a443b1a31e355122a7f2d2eb3de3a1b 100644 (file)
@@ -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);
+       }
 }
 
 /*=====================================================================*\