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), 'comment_parsed' => array(TYPE_NONE, REQ_SET), 'hidden' => array(TYPE_BOOL, REQ_NO) ); /** * Database table * @var string */ protected $table = 'comment'; /** * Table prefix * @var string */ protected $prefix = TABLE_PREFIX; /** * Set field: dateline */ protected function set_dateline() { $this->set('dateline', time()); } /** * Set field: comment_parsed */ protected function set_comment_parsed() { $comment = $this->values['comment']; if ($this->values['parselinks']) { $comment = str_replace('bug://new', '' . T('New Bug') . '', $comment); $comment = preg_replace('#bug://((report|problem)/)?([0-9]*)#i', 'bug \3', $comment); $comment = preg_replace('#(https?://|www\.)\S+#i', '\0', $comment); } if (bugdar::$options['allowhtml']) { $this->set('comment_parsed', nl2br(BSApp::$input->unsanitize($comment))); } else { $this->set('comment_parsed', nl2br($comment)); } } /** * Pre-update */ protected function pre_update() { $this->set_comment_parsed(); } /** * Pre-delete */ protected function pre_delete() { 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); } } ?>