require_once('./includes/api_bug.php');
require_once('./includes/api_comment.php');
-APIError(array(new API_Error_Handler($message), 'user_cumulative'));
-
$bug = $db->queryFirst("
SELECT bug.*, user.email, user.displayname, user.showemail
FROM " . TABLE_PREFIX . "bug AS bug
// setup logging
require_once('./includes/class_logging.php');
-$log = new Logging;
+$log = new Logging();
$log->set_bugid($bug['bugid']);
-$notif = new NotificationCenter;
+$notif = new NotificationCenter();
$bugapi = new BugAPI();
-$bugapi->set('bugid', $input->in['bugid']);
-$bugapi->set_condition();
-$bugapi->dorelations = array();
+$bugapi->set('bugid', $input->in['bugid']);
$bugapi->fetch();
// ###################################################################
$message->errorPermission();
}
- $bugapi->delete();
+ $bugapi->remove();
$message->redirect(T('The entire bug has been deleted.'), 'index.php');
}
if ($_POST['do'] == 'update')
{
- if (!((can_perform('caneditown', $bug['product']) AND bugdar::$userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND bugdar::$userinfo['userid'] != $bug['userid'])) AND !can_perform('canpostcomments', $bug['product']))
+ if (!((can_perform('caneditown', $bug['product']) && bugdar::$userinfo['userid'] == $bug['userid']) || (can_perform('caneditother', $bug['product']) && bugdar::$userinfo['userid'] != $bug['userid'])) && !can_perform('canpostcomments', $bug['product']))
{
$message->errorPermission();
}
$dependencies = preg_split('#([^0-9].*?)#', $input->in['dependency'], -1, PREG_SPLIT_NO_EMPTY);
$dependencies = ((sizeof($dependencies) < 1) ? '' : implode(', ', $dependencies));
- if ((can_perform('caneditown', $bug['product']) AND bugdar::$userinfo['userid'] == $bug['userid']) OR (can_perform('caneditother', $bug['product']) AND bugdar::$userinfo['userid'] != $bug['userid']))
+ if ((can_perform('caneditown', $bug['product']) && bugdar::$userinfo['userid'] == $bug['userid']) || (can_perform('caneditother', $bug['product']) && bugdar::$userinfo['userid'] != $bug['userid']))
{
$bugapi->set('summary', $input->in['summary']);
$bugapi->set('severity', $input->in['severity']);
class BugAPI extends BSApi
{
/**
- * Database fields
- * @var array
- * @access private
- */
- var $fields = array(
- 'bugid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'),
+ * Database fields
+ * @var array
+ */
+ protected $fields = array(
+ 'bugid' => array(TYPE_UINT, REQ_AUTO),
'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')),
+ 'product' => array(TYPE_UINT, REQ_YES),
+ 'component' => array(TYPE_UINT, REQ_NO),
+ 'version' => array(TYPE_UINT, REQ_YES),
+ 'summary' => array(TYPE_STR, REQ_YES),
+ 'priority' => array(TYPE_UINT, REQ_NO),
+ 'severity' => array(TYPE_UINT, REQ_NO),
+ 'status' => array(TYPE_UINT, REQ_NO),
+ 'resolution' => array(TYPE_UINT, REQ_NO),
+ 'assignedto' => array(TYPE_UINT, REQ_NO),
'duplicateof' => array(TYPE_STR, REQ_NO),
'dependency' => array(TYPE_STR, REQ_NO),
'hidden' => array(TYPE_BOOL, REQ_NO),
);
/**
- * Database table
- * @var string
- * @access private
- */
- var $table = 'bug';
+ * Database table
+ * @var string
+ */
+ protected $table = 'bug';
/**
- * Table prefix
- * @var string
- * @access private
- */
- var $prefix = TABLE_PREFIX;
+ * Table prefix
+ * @var string
+ */
+ protected $prefix = TABLE_PREFIX;
- // ###################################################################
/**
- * Subclassed set() that will intercept any custom fields and handle
- * them appropriately, but everyting else will be passed to the parent.
- */
+ * 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"]))
+ if (preg_match('/^custom/', $field) == 1 && !isset($this->fields["$field"]))
{
$this->fields["$field"] = array(TYPE_STR, REQ_NO);
}
parent::set($field, $value, $doclean, $doverify);
}
- // ###################################################################
/**
- * Set field: dateline
- *
- * @access private
- */
- function set_dateline()
+ * Set field: dateline
+ */
+ protected function set_dateline()
{
$this->set('dateline', time());
}
- // ###################################################################
/**
- * Post-insert
- *
- * @access private
- */
- function post_insert()
+ * Post-insert
+ */
+ protected function post_insert()
{
BSApp::$db->query("INSERT INTO " . TABLE_PREFIX . "vote (bugid, votefor, voteagainst) VALUES (" . $this->insertid . ", 0, 0)");
}
- // ###################################################################
/**
- * Post-delete
- *
- * @access private
- */
- function post_delete()
+ * Post-delete
+ */
+ protected function post_delete()
{
BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "comment WHERE bugid = " . $this->values['bugid']);
BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "favorite WHERE bugid = " . $this->values['bugid']);
BSApp::$db->query("DELETE FROM " . TABLE_PREFIX . "vote WHERE bugid = " . $this->values['bugid']);
}
- // ###################################################################
/**
- * Verify: product
- *
- * @access private
- */
- function verify_product()
+ * Verify: product
+ */
+ protected function validate_product($field)
{
- if (!($nozero = $this->verify_nozero('product')))
+ if (!$this->_verifyIsNotZero('product'))
{
- return $nozero;
+ return false;
}
- if (!bugdar::$datastore['product'][ $this->values['product'] ])
+ if (!bugdar::$datastore['product'][$this->values['product']])
{
+ $this->_error(new FieldException(L_INVALID_ID, $field));
return false;
}
+
return true;
}
- // ###################################################################
/**
- * Verify: componentid
- *
- * @access private
- */
- function verify_component()
+ * Verify: componentid
+ */
+ protected function validate_component($field)
{
if ($this->values['component'] != 0)
{
- $component = bugdar::$datastore['component'][ $this->values['component'] ];
- $product = bugdar::$datastore['product'][ $this->values['product'] ];
- $version = bugdar::$datastore['version'][ $this->values['version'] ];
+ $component = bugdar::$datastore['component'][ $this->values['component'] ];
+ $product = bugdar::$datastore['product'][ $this->values['product'] ];
+ $version = bugdar::$datastore['version'][ $this->values['version'] ];
if ($component['parentid'] != $product['productid'])
{
+ $this->_error(new FieldException(L_INVALID_ID, $field));
return false;
}
- if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0)
+ if (($version['productid'] != $component['productid'] && $version['productid'] != $product['productid']) && $version['productid'] != 0)
{
+ $this->_error(new FieldException(L_INVALID_ID, $field));
return false;
}
}
return true;
}
- // ###################################################################
/**
- * Verify: versionid
- *
- * @access private
- */
- function verify_version()
+ * Verify: versionid
+ */
+ protected function validate_version()
{
- if (!($nozero = $this->verify_nozero('version')))
+ if ($this->_verifyIsNotZero('version'))
{
- return $nozero;
+ return false;
}
if (!bugdar::$datastore['version'][ $this->values['version'] ])
{
+ $this->_error(new FieldException(L_INVALID_ID, $field));
return false;
}
return true;
}
- // ###################################################################
/**
- * Verify: priority
- *
- * @access private
- */
- function verify_priority()
+ * Verify: priority
+ */
+ protected function validate_priority()
{
if (!bugdar::$datastore['priority'][ $this->values['priority'] ])
{
return true;
}
- // ###################################################################
/**
- * Verify: severity
- *
- * @access private
- */
- function verify_severity()
+ * Verify: severity
+ *
+ * @access private
+ */
+ protected function validate_severity()
{
if (!bugdar::$datastore['severity'][ $this->values['severity'] ])
{
return true;
}
- // ###################################################################
/**
- * Verify: status
- *
- * @access private
- */
- function verify_status()
+ * Verify: status
+ */
+ protected function validate_status()
{
if (!bugdar::$datastore['status'][ $this->values['status'] ])
{
return true;
}
- // ###################################################################
/**
- * Verify: resolution
- *
- * @access private
- */
- function verify_resolution()
+ * Verify: resolution
+ */
+ protected function validate_resolution()
{
if (!bugdar::$datastore['resolution'][ $this->values['resolution'] ])
{
return true;
}
- // ###################################################################
/**
- * Verify: assignedto
- *
- * @access private
- */
- function verify_assignedto()
+ * Verify: assignedto
+ *
+ * @access private
+ */
+ protected function validate_assignedto()
{
- if (!bugdar::$datastore['assignto'][ $this->values['assignedto'] ] AND $this->values['assignedto'] != 0)
+ if (!bugdar::$datastore['assignto'][ $this->values['assignedto'] ] && $this->values['assignedto'] != 0)
{
$this->set('assignedto', bugdar::$options['defaultassign']);
}