require_once $gfcommon.'tracker/ArtifactMessage.class.php';
require_once $gfcommon.'tracker/ArtifactExtraField.class.php';
require_once $gfcommon.'tracker/ArtifactWorkflow.class.php';
+require_once $gfcommon.'tracker/ArtifactStorage.class.php';
// This string is used when sending the notification mail for identifying the
// user response
/**
* Artifact - constructor.
*
- * @param object The ArtifactType object.
- * @param integer (primary key from database OR complete assoc array)
- * ONLY OPTIONAL WHEN YOU PLAN TO IMMEDIATELY CALL ->create()
- * @return boolean success.
+ * @param ArtifactType $ArtifactType The ArtifactType object.
+ * @param int|bool $data (primary key from database OR complete assoc array)
+ * ONLY OPTIONAL WHEN YOU PLAN TO IMMEDIATELY CALL ->create()
*/
function __construct(&$ArtifactType, $data=false) {
$this->Error();
$this->ArtifactType =& $ArtifactType;
- //was ArtifactType legit?
+ // Was ArtifactType legit?
if (!$ArtifactType || !is_object($ArtifactType)) {
$this->setError(_('No Valid Artifact Type'));
- return false;
+ return;
}
- //did ArtifactType have an error?
+ // Did ArtifactType have an error?
if ($ArtifactType->isError()) {
$this->setError($ArtifactType->getErrorMessage());
- return false;
+ return;
}
- //
- // make sure this person has permission to view artifacts
- //
+ // Make sure this person has permission to view artifacts
if (!forge_check_perm ('tracker', $this->ArtifactType->getID(), 'read')) {
$this->setError(_('Only project members can view private artifact types'));
- return false;
+ return;
}
- //
- // set up data structures
- //
if ($data) {
if (is_array($data)) {
$this->data_array =& $data;
-//
-// Should verify ArtifactType ID
-//
- return true;
} else {
- if (!$this->fetchData($data)) {
- return false;
- } else {
- return true;
- }
+ $this->fetchData($data);
}
}
}
// make sure this person has permission to add artifacts
//
- if (!$this->ArtifactType->isPublic()) {
- //
- // Only admins can post/modify private artifacts
- //
-
-//
-// ape: Disabled, private means only restricted to members. So, no special rules #2503.
-// if (!forge_check_perm ('tracker_admin', $this->ArtifactType->Group->getID()) {
-// $this->setError(_('Only Artifact Admins Can Modify Private Artifact Types'));
-// return false;
-// }
- }
-
//
// get the user_id
//
if(array_key_exists('user', $importData)){
$user = $importData['user'];
} else {
+ if (!forge_check_perm ('tracker',$this->ArtifactType->getID(),'submit')) {
+ $this->setError(_('You are not currently allowed to submit items to this tracker.'));
+ return false;
+ }
+
if (session_loggedin()) {
$user=user_getid();
} else {
- if ($this->ArtifactType->allowsAnon()) {
- $user=100;
- } else {
- $this->setError(_('This Artifact Type Does Not Allow Anonymous Submissions. Please Login.'));
- return false;
- }
+ $user=100;
}
}
db_rollback();
return false;
}
+
+ ArtifactStorage::instance()->deleteFromQuery('SELECT id FROM artifact_file WHERE artifact_id=$1',
+ array ($this->getID())) ;
+
$res = db_query_params ('DELETE FROM artifact_file WHERE artifact_id=$1',
array ($this->getID())) ;
if (!$res) {
$this->setError(_('Error deleting file from db: ').db_error());
db_rollback();
+ ArtifactStorage::instance()->rollback();
return false;
}
$res = db_query_params ('DELETE FROM artifact_message WHERE artifact_id=$1',
if (!$res) {
$this->setError(_('Error deleting message: ').db_error());
db_rollback();
+ ArtifactStorage::instance()->rollback();
return false;
}
$res = db_query_params ('DELETE FROM artifact_history WHERE artifact_id=$1',
if (!$res) {
$this->setError(_('Error deleting history: ').db_error());
db_rollback();
+ ArtifactStorage::instance()->rollback();
return false;
}
$res = db_query_params ('DELETE FROM artifact_monitor WHERE artifact_id=$1',
if (!$res) {
$this->setError(_('Error deleting monitor: ').db_error());
db_rollback();
+ ArtifactStorage::instance()->rollback();
return false;
}
$res = db_query_params ('DELETE FROM artifact WHERE artifact_id=$1',
if (!$res) {
$this->setError(_('Error deleting artifact: ').db_error());
db_rollback();
+ ArtifactStorage::instance()->rollback();
return false;
}
if (!$res) {
$this->setError(_('Error updating artifact counts: ').db_error());
db_rollback();
+ ArtifactStorage::instance()->rollback();
return false;
}
} elseif ($this->getStatusID() == 2) {
if (!$res) {
$this->setError(_('Error updating artifact counts: ').db_error());
db_rollback();
+ ArtifactStorage::instance()->rollback();
return false;
}
}
db_commit();
+ ArtifactStorage::instance()->commit();
return true;
}
/**
* getHistory - returns a result set of audit trail for this support request.
*
- * @return database result set.
+ * @return resource result set.
*/
function getHistory() {
return db_query_params ('SELECT * FROM artifact_history_user_vw WHERE artifact_id=$1 ORDER BY entrydate DESC, id ASC',
}
/**
- * getMessages - get the list of messages attached to this artifact.
+ * getMessages - get the list of messages attached to this artifact.
*
- * @return database result set.
+ * @param string $order
+ * @return resource result set.
*/
- function getMessages($asc=false) {
- return db_query_params ('SELECT * FROM artifact_message_user_vw WHERE artifact_id=$1 ORDER BY adddate ' . ($asc ? 'ASC' : 'DESC') . ', id ASC',
- array ($this->getID())) ;
+ function getMessages($if_i_get_the_person_reinventing_the_wheel='up') {
+ /*
+ * This is necessary because someone committed a change
+ * to this method in FusionForge trunk that accepts 'up'
+ * as default (luckily, it’s the same!) and 'down' as
+ * alternative probability, whereas FusionForge 5.2 has
+ * false as default and true for ascending order, so we
+ * need to check this out and use === to be sure ☹
+ */
+ if ($if_i_get_the_person_reinventing_the_wheel === 'up') {
+ $order = 'DESC';
+ } elseif ($if_i_get_the_person_reinventing_the_wheel === true) {
+ $order = 'ASC';
+ } elseif ($if_i_get_the_person_reinventing_the_wheel === false) {
+ $order = 'DESC';
+ } else {
+ $order = 'ASC';
+ }
+ return db_query_params('SELECT * FROM artifact_message_user_vw WHERE artifact_id=$1 ORDER BY adddate ' . $order . ', id ASC',
+ array($this->getID()));
+ }
+
+ /**
+ * getMessage - get a message attached to this artifact.
+ *
+ * @param int $msg_id id of the message.
+ * @access public
+ * @return database result set.
+ */
+ function getMessage($msg_id) {
+ if (!$msg_id) {
+ return false;
+ }
+ return db_query_params ('SELECT * FROM artifact_message_user_vw WHERE id=$1',
+ array($msg_id));
}
/**
$this->setMissingParamsError();
return false;
}
+ if (!forge_check_perm ('tracker',$this->ArtifactType->getID(),'submit')) {
+ $this->setError(_('You are not currently allowed to submit items to this tracker.'));
+ return false;
+ }
if (session_loggedin()) {
$user_id=user_getid();
$user =& user_get_object($user_id);
// we'll store this email even though it will likely never be used -
// since we have their correct user_id, we can join the USERS table to get email
$by=$user->getEmail();
- } elseif (!$this->ArtifactType->allowsAnon()) {
- $this->setError(_('This Artifact Type Does Not Allow Anonymous Submissions. Please Login.'));
- return false;
} else {
$user_id=100;
if (!$by || !validate_email($by)) {
function marker($prop_name,$changes,$extra_field_id=0) {
if ($prop_name == 'extra_fields' && isset($changes[$prop_name][$extra_field_id])) {
return '>';
- } else if ($prop_name != 'extra_fields' && isset($changes[$prop_name])) {
+ } elseif ($prop_name != 'extra_fields' && isset($changes[$prop_name])) {
return '>';
} else {
return '';
default:
$aa=$a->getExtraFieldDataText();
$ba=$b->getExtraFieldDataText();
- $af=$aa[$this->criterion]['value'];
- $bf=$ba[$this->criterion]['value'];
+ if(!isset($this->criterion) || empty($this->criterion)) {
+ $criterion = 1;
+ }
+ else {
+ $criterion = $this->criterion;
+ }
+ $af=$aa[$criterion]['value'];
+ $bf=$ba[$criterion]['value'];
$namecmp = strcoll ($af,$bf) ;
if ($namecmp != 0) {
return $namecmp ;
// mode: php
// c-file-style: "bsd"
// End:
-
-?>