Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
load('api', null);
/**
* API: Bug
*
* Note: When priority, severity, status, and resolution should throw a
* verification error, they actually set it to the default value
*
* @author Blue Static
* @copyright Copyright ©2002 - 2007, Blue Static
* @version $Revision$
* @package Bugdar
*
*/
class BugAPI extends API
{
/**
* Database fields
* @var array
* @access private
*/
var $fields = array(
'bugid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'),
'userid' => array(TYPE_UINT, REQ_NO),
'username' => array(TYPE_STR, REQ_NO),
'dateline' => array(TYPE_UINT, REQ_SET),
'product' => array(TYPE_UINT, REQ_YES, ':self'),
'component' => array(TYPE_UINT, REQ_NO, ':self'),
'version' => array(TYPE_UINT, REQ_YES, ':self'),
'summary' => array(TYPE_STR, REQ_YES, 'verify_noempty'),
'priority' => array(TYPE_UINT, REQ_NO, ':self'),
'severity' => array(TYPE_UINT, REQ_NO, ':self'),
'status' => array(TYPE_UINT, REQ_NO, ':self'),
'resolution' => array(TYPE_UINT, REQ_NO, ':self'),
'assignedto' => array(TYPE_UINT, REQ_NO, ':self', array('includes/api_user.php', 'UserAPI')),
'duplicateof' => array(TYPE_STR, REQ_NO),
'dependency' => array(TYPE_STR, REQ_NO),
'hidden' => array(TYPE_BOOL, REQ_NO),
'initialreport' => array(TYPE_UINT, REQ_NO),
'lastposttime' => array(TYPE_UINT, REQ_NO),
'lastpostby' => array(TYPE_UINT, REQ_NO),
'lastpostbyname' => array(TYPE_STR, REQ_NO),
'hiddenlastposttime' => array(TYPE_UINT, REQ_NO),
'hiddenlastpostby' => array(TYPE_UINT, REQ_NO),
'hiddenlastpostbyname' => array(TYPE_STR, REQ_NO)
);
/**
* Database table
* @var string
* @access private
*/
var $table = 'bug';
/**
* Table prefix
* @var string
* @access private
*/
var $prefix = TABLE_PREFIX;
// ###################################################################
/**
* Subclassed set() that will intercept any custom fields and handle
* them appropriately, but everyting else will be passed to the parent.
*/
function set($field, $value, $doclean = true, $doverify = true)
{
// it's a custom field, so add it in
if (preg_match('#^custom#', $field) == 1 AND !isset($this->fields["$field"]))
{
$this->fields["$field"] = array(TYPE_STR, REQ_NO);
}
// TODO - (r1524) one day we can change this back to call_user_func_array(array($this, 'parent::set'), func_get_args())
parent::set($field, $value, $doclean, $doverify);
}
// ###################################################################
/**
* Set field: dateline
*
* @access private
*/
function set_dateline()
{
$this->set('dateline', time());
}
// ###################################################################
/**
* Post-insert
*
* @access private
*/
function post_insert()
{
$this->registry->db->query("INSERT INTO " . TABLE_PREFIX . "vote (bugid, votefor, voteagainst) VALUES (" . $this->insertid . ", 0, 0)");
}
// ###################################################################
/**
* Post-delete
*
* @access private
*/
function post_delete()
{
$this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "comment WHERE bugid = " . $this->values['bugid']);
$this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "favorite WHERE bugid = " . $this->values['bugid']);
$this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "history WHERE bugid = " . $this->values['bugid']);
$this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "vote WHERE bugid = " . $this->values['bugid']);
}
// ###################################################################
/**
* Verify: product
*
* @access private
*/
function verify_product()
{
if (!($nozero = $this->verify_nozero('product')))
{
return $nozero;
}
if (!$this->registry->datastore['product'][ $this->values['product'] ])
{
return false;
}
return true;
}
// ###################################################################
/**
* Verify: componentid
*
* @access private
*/
function verify_component()
{
if ($this->values['component'] != 0)
{
$component = $this->registry->datastore['component'][ $this->values['component'] ];
$product = $this->registry->datastore['product'][ $this->values['product'] ];
$version = $this->registry->datastore['version'][ $this->values['version'] ];
if ($component['parentid'] != $product['productid'])
{
return false;
}
if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0)
{
return false;
}
}
return true;
}
// ###################################################################
/**
* Verify: versionid
*
* @access private
*/
function verify_version()
{
if (!($nozero = $this->verify_nozero('version')))
{
return $nozero;
}
if (!$this->registry->datastore['version'][ $this->values['version'] ])
{
return false;
}
return true;
}
// ###################################################################
/**
* Verify: priority
*
* @access private
*/
function verify_priority()
{
if (!$this->registry->datastore['priority'][ $this->values['priority'] ])
{
$this->set('priority', $this->registry->options['defaultpriority']);
}
return true;
}
// ###################################################################
/**
* Verify: severity
*
* @access private
*/
function verify_severity()
{
if (!$this->registry->datastore['severity'][ $this->values['severity'] ])
{
$this->set('severity', $this->registry->options['defaultseverity']);
}
return true;
}
// ###################################################################
/**
* Verify: status
*
* @access private
*/
function verify_status()
{
if (!$this->registry->datastore['status'][ $this->values['status'] ])
{
$this->set('status', $this->registry->options['defaultstatus']);
}
return true;
}
// ###################################################################
/**
* Verify: resolution
*
* @access private
*/
function verify_resolution()
{
if (!$this->registry->datastore['resolution'][ $this->values['resolution'] ])
{
$this->set('resolution', $this->registry->options['defaultresolve']);
}
return true;
}
// ###################################################################
/**
* Verify: assignedto
*
* @access private
*/
function verify_assignedto()
{
if (!$this->registry->datastore['assignto'][ $this->values['assignedto'] ] AND $this->values['assignedto'] != 0)
{
$this->set('assignedto', $this->registry->options['defaultassign']);
}
return true;
}
}
/*=====================================================================*\
|| ###################################################################
|| # $HeadURL$
|| # $Id$
|| ###################################################################
\*=====================================================================*/
?>