Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
Bugdar - Blob - ViewGit - Blue Static
<?php
/*=====================================================================*\
|| ###################################################################
|| # Bugdar [#]version[#]
|| # Copyright ©2002-[#]year[#] Blue Static
|| #
|| # This program is free software; you can redistribute it and/or modify
|| # it under the terms of the GNU General Public License as published by
|| # the Free Software Foundation; version [#]gpl[#] of the License.
|| #
|| # This program is distributed in the hope that it will be useful, but
|| # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|| # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|| # more details.
|| #
|| # You should have received a copy of the GNU General Public License along
|| # with this program; if not, write to the Free Software Foundation, Inc.,
|| # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|| ###################################################################
\*=====================================================================*/

$GLOBALS['isso:callback']->load('api', null);

/**
* API: Comment
*
* @author		Blue Static
* @copyright	Copyright ©2002 - [#]year[#], Blue Static
* @version		$Revision$
* @package		Bugdar
*
*/
class CommentAPI extends API
{
	/**
	* Fields
	* @var	array
	* @access	private
	*/
	var $fields = array(
		'commentid'			=> array(TYPE_UINT,	REQ_AUTO,	'verify_nozero'),
		'bugid'				=> array(TYPE_UINT,	REQ_YES,	'verify_nozero'),
		'userid'			=> array(TYPE_UINT,	REQ_NO,		null,				array('includes/api_user.php', 'UserAPI')),
		'dateline'			=> array(TYPE_UINT,	REQ_SET),
		'parselinks'		=> array(TYPE_BOOL,	REQ_NO),
		'comment'			=> array(TYPE_STR,	REQ_YES,	'verify_noempty'),
		'comment_parsed'	=> array(TYPE_NONE,	REQ_SET),
		'hidden'			=> array(TYPE_BOOL,	REQ_NO)
	);

	/**
	* Database table
	* @var	string
	* @access	private
	*/
	var $table = 'comment';

	/**
	* Table prefix
	* @var	string
	* @access	private
	*/
	var $prefix = TABLE_PREFIX;

	// ###################################################################
	/**
	* Set field: dateline
	*
	* @access	private
	*/
	function set_dateline()
	{
		$this->set('dateline', time());
	}

	// ###################################################################
	/**
	* Set field: comment_parsed
	*
	* @access	private
	*/
	function set_comment_parsed()
	{
		$comment = $this->values['comment'];
		if ($this->values['parselinks'])
		{
			$comment = str_replace('bug://new', '<a href="newreport.php">' . _('New Bug') . '</a>', $comment);
			$comment = preg_replace('#bug://((report|problem)/)?([0-9]*)#i', '<a href="showreport.php?bugid=\3">bug \3</a>', $comment);
			$comment = preg_replace('#(https?://|www\.)\S+#i', '<a href="\0">\0</a>', $comment);
		}

		if ($this->registry->options['allowhtml'])
		{
			$this->set('comment_parsed', nl2br($this->registry->unsanitize($comment)));
		}
		else
		{
			$this->set('comment_parsed', nl2br($comment));
		}
	}

	// ###################################################################
	/**
	* Pre-update
	*
	* @access	private
	*/
	function pre_update()
	{
		$this->set_comment_parsed();
	}

	// ###################################################################
	/**
	* Pre-delete
	*
	* @access	private
	*/
	function pre_delete()
	{
		if ($this->registry->db->query_first("SELECT * FROM " . TABLE_PREFIX . "bug WHERE initialreport = " . $this->values['commentid']))
		{
			$this->error(_('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).'));
		}
	}
}

/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>