load('api', null); /** * API: Bug * * Note: When priority, esverity, status, and resolution should throw a * verification error, they actually set it to the default value * * @author Iris Studios, Inc. * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc. * @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), 'dateline' => array(TYPE_UINT, REQ_SET), 'productid' => array(TYPE_UINT, REQ_YES, ':self'), 'componentid' => array(TYPE_UINT, REQ_NO, ':self'), 'versionid' => 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), 'hiddenlastposttime' => array(TYPE_UINT, REQ_NO), 'hiddenlastpostby' => array(TYPE_UINT, REQ_NO) ); /** * Database table * @var string * @access private */ var $table = 'bug'; /** * Table prefix * @var string * @access private */ var $prefix = TABLE_PREFIX; // ################################################################### /** * 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)"); } // ################################################################### /** * Verify: productid * * @access private */ function verify_productid() { $this->verify_nozero('productid'); if (!$this->registry->datastore['product'][ $this->values['productid'] ]) { return false; } return true; } // ################################################################### /** * Verify: componentid * * @access private */ function verify_componentid() { if ($this->values['componentid'] != 0) { $product = $this->registry->datastore['product'][ $this->values['product'] ]; $version = $this->registry->datastore['version'][ $this->values['version'] ]; if ($component['componentmother'] != $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_versionid() { $this->verify_nozero('versionid'); if (!$this->registry->datastore['version'][ $this->values['versionid'] ]) { 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$ || ################################################################### \*=====================================================================*/ ?>