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
* ONLY OPTIONAL WHEN YOU PLAN TO IMMEDIATELY CALL ->create()
* @return boolean success.
*/
- function Artifact(&$ArtifactType, $data=false) {
+ function __construct(&$ArtifactType, $data=false) {
$this->Error();
$this->ArtifactType =& $ArtifactType;
// 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;
}
}
return $this->data_array['status_name'];
}
+ /**
+ * getCustomStatusName - get custom status value text.
+ *
+ * @return string The custom status name.
+ */
+ function getCustomStatusName() {
+ $custom_status_id = $this->ArtifactType->getCustomStatusField();
+ if ($custom_status_id) {
+ $result = db_query_params ('SELECT element_name FROM artifact_extra_field_elements aefe, artifact_extra_field_data aefd
+ WHERE artifact_id=$1 AND aefd.extra_field_id=$2 AND CAST(aefd.field_data AS INTEGER)=aefe.element_id',
+ array ($this->getID(), $custom_status_id)) ;
+ if ($result) {
+ return db_result($result, 0, 'element_name');
+ }
+ }
+ return $this->data_array['status_name'];
+ }
+
/**
* getPriority - get priority flag.
*
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;
}
$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)) {
// Check that assigned_to is a tech for the tracker
if ($assigned_to != 100) {
- if (!forge_check_perm ('tracker', $this->ArtifactType->getID(), 'tech')) {
+ if (!forge_check_perm_for_user ($assigned_to, 'tracker', $this->ArtifactType->getID(), 'tech')) {
$this->setError(_("Invalid assigned_to (assigned person is not a technician)"));
return false;
}
skip it and continue to next item
*/
- if (empty($extra_fields)) {
- return true;
- }
$update = false;
//get a list of extra fields for this artifact_type
$ef = $this->ArtifactType->getExtraFields();
$efk=array_keys($ef);
+ if (empty($extra_fields) && empty($ef)) {
+ return true;
+ }
+
// If there is a status field, then check against the workflow.
// Unless if we change type.
if (! isset($changes['Type']) || !$changes['Type']) {
// Get previous value.
$res = db_query_params ('SELECT field_data FROM artifact_extra_field_data
WHERE artifact_id=$1 AND extra_field_id=$2',
- array($this->getID(),
- $efid));
+ array($this->getID(),
+ $efid));
$old = (db_numrows($res)>0) ? db_result($res,0,'field_data') : 100;
if ($old != $extra_fields[$efid]) {
$atw = new ArtifactWorkflow($this->ArtifactType, $efid);
$sess = session_get_user() ;
if ($type == 1) { // Initial opening
if ($sess) {
- $body = $this->ArtifactType->getName() ." item #". $this->getID() .", was opened at ". date( _('Y-m-d H:i'), $this->getOpenDate() ) . " by " . $sess->getRealName () ;
+ $body = $this->ArtifactType->Group->getUnixName() . '-' . $this->ArtifactType->getName() ." item #". $this->getID() .", was opened at ". date( _('Y-m-d H:i'), $this->getOpenDate() ) . " by " . $sess->getRealName () ;
} else {
- $body = $this->ArtifactType->getName() ." item #". $this->getID() .", was opened at ". date( _('Y-m-d H:i'), $this->getOpenDate() ) ;
+ $body = $this->ArtifactType->Group->getUnixName() . '-' . $this->ArtifactType->getName() ." item #". $this->getID() .", was opened at ". date( _('Y-m-d H:i'), $this->getOpenDate() ) ;
}
} else {
if ($sess) {
- $body = $this->ArtifactType->getName() .
+ $body = $this->ArtifactType->Group->getUnixName() . '-' . $this->ArtifactType->getName() .
" item #" . $this->getID() .
" was changed at " .
date(_('Y-m-d H:i'), $tm) . " by " .
$sess->getRealName();
} else {
- $body = $this->ArtifactType->getName() .
+ $body = $this->ArtifactType->Group->getUnixName() . '-' . $this->ArtifactType->getName() .
" item #" . $this->getID() .
" was changed at " .
date(_('Y-m-d H:i'), $tm);
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 ;