case 'add' : {
if (!$ath->allowsAnon() && !session_loggedin()) {
- exit_error('ERROR',_('Artifact: This ArtifactType Does Not Allow Anonymous Submissions. Please Login.'));
+ exit_permission_denied();
} else {
- include ('add.php');
+ include $gfwww.'tracker/add.php';
}
break;
}
*/
$ah=new ArtifactHtml($ath);
+ $feedback = '';
if (!$ah || !is_object($ah)) {
form_release_key(getStringFromRequest('form_key'));
exit_error('ERROR','Artifact Could Not Be Created');
exit_error('ERROR',_('Artifact: This ArtifactType Does Not Allow Anonymous Submissions. Please Login.'));
} else {
if (empty($user_email)) {
- $user_email=false;
+ $user_email=false;
} else {
if (!validate_email($user_email)) {
form_release_key(getStringFromRequest('form_key'));
exit_error('ERROR', _('Invalid Email Address'));
}
}
+ if ($user_email) {
+ $details = "Anonymous message posted by $user_email\n\n".
+ $details;
+ }
if (!$ah->create($summary,$details,$assigned_to,$priority,$extra_fields)) {
form_release_key(getStringFromRequest('form_key'));
exit_error('ERROR',$ah->getErrorMessage());
//
// Attach files to this Artifact.
//
+ $ext_feedback = '';
for ($i=0; $i<5; $i++) {
- $error=$_FILES['input_file']['error'][$i];
+ $f = getUploadedFile("input_file$i");
+ $error = $f['error'];
if (isset($error) && $error > 0) {
+ $n = $i+1;
+ if ($error === 1 || $error === 2) {
+ // UPLOAD_ERR_INI_SIZE or UPLOAD_ERR_FORM_SIZE
+ $ext_feedback .= "<br />ERROR: Skipping attachement $n: file is too large.";
+ } elseif ($error === 3) {
+ // UPLOAD_ERR_PARTIAL
+ $ext_feedback .= "<br />ERROR: Skipping attachement $n: transfert interrupted.";
+ }
continue;
}
- $file_name=$_FILES['input_file']['name'][$i];
- $tmp_name=$_FILES['input_file']['tmp_name'][$i];
+ $file_name = $f['name'];
+ $tmp_name = $f['tmp_name'];
+ $size = $f['size'];
+ $type = $f['type'];
if (!is_uploaded_file($tmp_name)) {
continue;
}
- $size=$_FILES['input_file']['size'][$i];
- $type=$_FILES['input_file']['type'][$i];
$afh=new ArtifactFileHtml($ah);
if (!$afh || !is_object($afh)) {
$feedback .= 'Could Not Create File Object';
- // } elseif ($afh->isError()) {
- // $feedback .= $afh->getErrorMessage();
+ } elseif ($afh->isError()) {
+ $feedback .= $afh->getErrorMessage();
} else {
if (!util_check_fileupload($tmp_name)) {
form_release_key(getStringFromRequest('form_key'));
}
}
$feedback .= _('Item Successfully Created');
- include 'browse.php';
+ $feedback .= $ext_feedback;
+ include $gfwww.'tracker/browse.php';
}
}
break;
$assigned_to = getStringFromRequest('assigned_to');
$canned_response = getIntFromRequest("canned_response");
$extra_fields = getArrayFromRequest('extra_fields');
-
+
$count=count($artifact_id_list);
if (!$ath->userIsAdmin()) {
// in some cases (ie: textfields) the value is not passed, but
// this doesn't mean we must delete the existing value
if (array_key_exists($efid, $extra_fields)) {
- $f = $extra_fields[$efid];
+ $f = $extra_fields[$efid];
if ($f == '100') {
// no change
} else {
$ef[$efid] = $f;
}
+ } else {
+ $ef[$efid] = addslashes($ef[$efid]);
}
}
}
$feedback = _('Updated Successfully'); }
}
unset ($extra_fields_choice);
- include ('browse.php');
+ include $gfwww.'tracker/browse.php';
break;
}
case 'postmod' : {
$summary = getStringFromRequest('summary');
$canned_response = getStringFromRequest('canned_response');
$details = getStringFromRequest('details');
+ $description = getStringFromRequest('description');
$new_artifact_type_id = getIntFromRequest('new_artifact_type_id');
$extra_fields = getStringFromRequest('extra_fields');
-
+ $user_email = getStringFromRequest('user_email', false);
+ $was_error = false;
+
/*
Technicians can modify limited fields - to be certain
no one is hacking around, we override any fields they don't have
*/
if (!form_key_is_valid(getStringFromRequest('form_key'))) {
exit_form_double_submit();
- }
+ }
$ah=new ArtifactHtml($ath,$artifact_id);
if (!$ah || !is_object($ah)) {
- exit_error('ERROR','Artifact Could Not Be Created');
+ exit_error('ERROR', _('Artifact Could Not Be Created'));
} else if ($ah->isError()) {
exit_error('ERROR',$ah->getErrorMessage());
} else if (!$ath->allowsAnon() && !session_loggedin()) {
//admin and techs can do everything
//techs will have certain fields overridden inside the update() function call
if (!$ah->update($priority,$status_id,
- $assigned_to,$summary,$canned_response,$details,$new_artifact_type_id,$extra_fields)) {
- $feedback =_('Tracker Item'). ': '.$ah->getErrorMessage();
+ $assigned_to,$summary,$canned_response,$details,$new_artifact_type_id,$extra_fields, $description)) {
+ form_release_key(getStringFromRequest('form_key'));
+ $error_msg .= _('Tracker Item'). ': '.$ah->getErrorMessage();
$ah->clearError();
$was_error=true;
}
} else {
- if (session_loggedin() && ($ah->getSubmittedBy() == user_getid())) {
-
- //submitter can only add files & comments
-
- $delete_file=false;
+ // Everyone else can add comments
+ if ($details) {
if ($ah->addMessage($details,$user_email,true)) {
$feedback=_('Comment added');
} else {
- if ( (strlen($details)>0) ) { //if there was no message, then itยดs not an error but addMessage returns false and sets missing params error
+ if ( (strlen($details)>0) ) { //if there was no message, then it's not an error but addMessage returns false and sets missing params error
//some kind of error in creation
exit_error($ah->getErrorMessage(),$feedback);
} else {
//some kind of error in creation
exit_error('ERROR',$ah->getErrorMessage());
}
-
}
}
- //
- // Attach files to this Artifact.
- //
- for ($i=0; $i<5; $i++) {
- $error=$_FILES['input_file']['error'][$i];
- if (isset($error) && $error > 0) {
- continue;
- }
- $file_name=$_FILES['input_file']['name'][$i];
- $tmp_name=$_FILES['input_file']['tmp_name'][$i];
- if (!is_uploaded_file($tmp_name)) {
- continue;
- }
- $size=$_FILES['input_file']['size'][$i];
- $type=$_FILES['input_file']['type'][$i];
-
- $afh=new ArtifactFileHtml($ah);
- if (!$afh || !is_object($afh)) {
- $feedback .= 'Could Not Create File Object';
- // } elseif ($afh->isError()) {
- // $feedback .= $afh->getErrorMessage();
- } else {
- if (!util_check_fileupload($tmp_name)) {
- form_release_key(getStringFromRequest('form_key'));
- exit_error("Error","Invalid filename");
+ // Admin, Techs and Submitter can add files.
+ if ($ath->userIsAdmin() || $ath->userIsTechnician() ||
+ (session_loggedin() && ($ah->getSubmittedBy() == user_getid()))) {
+ //
+ // Attach files to this Artifact.
+ //
+ $ext_feedback = '';
+ for ($i=0; $i<5; $i++) {
+ $f = getUploadedFile("input_file$i");
+ $error = $f['error'];
+ if (isset($error) && $error > 0) {
+ $n = $i+1;
+ if ($error === 1 || $error === 2) {
+ // UPLOAD_ERR_INI_SIZE or UPLOAD_ERR_FORM_SIZE
+ $ext_feedback .= "<br />" .
+ sprintf(_("ERROR: Skipping attachment %d: file is too large."), $n);
+ } elseif ($error === 3) {
+ // UPLOAD_ERR_PARTIAL
+ $ext_feedback .= "<br />" .
+ sprintf(_("ERROR: Skipping attachment %d: transfer interrupted."), $n);
+ }
+ continue;
}
- if (!$afh->upload($tmp_name,$file_name,$type,' ')) {
- $feedback .= ' <br />'._('File Upload: Error').':'.$afh->getErrorMessage();
- $was_error=true;
- } else {
- $feedback .= ' <br />'._('File Upload: Successful');
+ $file_name = $f['name'];
+ $tmp_name = $f['tmp_name'];
+ $size = $f['size'];
+ $type = $f['type'];
+
+ if (!is_uploaded_file($tmp_name)) {
+ continue;
}
- }
- }
- //
- // Delete list of files from this artifact
- //
- $delete_file = getStringFromRequest('delete_file');
- if ($delete_file) {
- $count=count($delete_file);
- for ($i=0; $i<$count; $i++) {
- $afh=new ArtifactFileHtml($ah,$delete_file[$i]);
+ $afh=new ArtifactFileHtml($ah);
if (!$afh || !is_object($afh)) {
- $feedback .= 'Could Not Create File Object::'.$delete_file[$i];
+ $feedback .= 'Could Not Create File Object';
} elseif ($afh->isError()) {
- $feedback .= $afh->getErrorMessage().'::'.$delete_file[$i];
+ $feedback .= $afh->getErrorMessage();
} else {
- if (!$afh->delete()) {
- $feedback .= ' <br />'._('File Delete:').': '.$afh->getErrorMessage();
+ if (!util_check_fileupload($tmp_name)) {
+ form_release_key(getStringFromRequest('form_key'));
+ exit_error("Error","Invalid filename");
+ }
+ if (!$afh->upload($tmp_name,$file_name,$type,' ')) {
+ $feedback .= ' <br />'._('File Upload: Error').':'.$afh->getErrorMessage();
$was_error=true;
} else {
- $feedback .= ' <br />'._('File Delete: Successful');
+ $feedback .= ' <br />'._('File Upload: Successful');
}
}
}
+
+ // Admin and Techs can delete files.
+ if ($ath->userIsAdmin() || $ath->userIsTechnician()) {
+ //
+ // Delete list of files from this artifact
+ //
+ $delete_file = getStringFromRequest('delete_file');
+ if ($delete_file) {
+ $count=count($delete_file);
+ for ($i=0; $i<$count; $i++) {
+ $afh=new ArtifactFileHtml($ah,$delete_file[$i]);
+ if (!$afh || !is_object($afh)) {
+ $feedback .= 'Could Not Create File Object::'.$delete_file[$i];
+ } elseif ($afh->isError()) {
+ $feedback .= $afh->getErrorMessage().'::'.$delete_file[$i];
+ } else {
+ if (!$afh->delete()) {
+ $feedback .= ' <br />'._('File Delete:').': '.$afh->getErrorMessage();
+ $was_error=true;
+ } else {
+ $feedback .= ' <br />'._('File Delete: Successful');
+ }
+ }
+ }
+ }
+ }
+
+ //
+ // Show just one feedback entry if no errors
+ //
+ if (!$was_error) {
+ $feedback = _('Updated successfully');
+ }
+ $feedback .= $ext_feedback;
+ include $gfwww.'tracker/browse.php';
+ break;
}
- //
- // Show just one feedback entry if no errors
- //
- if (!$was_error) {
- $feedback = _('Updated successfully');
- }
- include ('browse.php');
}
- break;
}
- case 'monitor' : {
- $artifact_id = getIntFromRequest('artifact_id');
- if ($artifact_id) {
- $ah=new ArtifactHtml($ath,$artifact_id);
- if (!$ah || !is_object($ah)) {
- exit_error('ERROR','Artifact Could Not Be Created');
- } else if ($ah->isError()) {
- exit_error('ERROR',$ah->getErrorMessage());
- } else {
- $ah->setMonitor();
- $feedback=$ah->getErrorMessage();
-
- include 'browse.php';
+ case 'monitor' : {
+ if (!session_loggedin()) {
+ exit_permission_denied();
}
- } else {
- $at=new ArtifactType($group,$atid);
- if (!$at || !is_object($at)) {
- exit_error('ERROR','Artifact Could Not Be Created');
- } else if ($at->isError()) {
- exit_error('ERROR',$at->getErrorMessage());
+ $start = getIntFromRequest('start');
+ $stop = getIntFromRequest('stop');
+ $artifact_id = getIntFromRequest('artifact_id');
+
+ // Fix to prevent collision with the start variable used in browse.
+ $_GET['start'] = 0;
+
+ if ($artifact_id) {
+ $ah=new ArtifactHtml($ath,$artifact_id);
+ if (!$ah || !is_object($ah)) {
+ exit_error('ERROR','Artifact Could Not Be Created');
+ } else if ($ah->isError()) {
+ exit_error('ERROR',$ah->getErrorMessage());
+ } else {
+ if ($start && $ah->isMonitoring())
+ $feedback = _('Monitoring Started');
+ elseif ($stop && !$ah->isMonitoring())
+ $feedback = _('Monitoring Deactivated');
+ else {
+ $ah->setMonitor();
+ $feedback=$ah->getErrorMessage();
+ }
+ include $gfwww.'tracker/browse.php';
+ }
} else {
- $at->setMonitor();
- $feedback=$at->getErrorMessage();
- $at->clearError();
- include 'browse.php';
+ $at=new ArtifactType($group,$atid);
+ if (!$at || !is_object($at)) {
+ exit_error('ERROR','Artifact Could Not Be Created');
+ } else if ($at->isError()) {
+ exit_error('ERROR',$at->getErrorMessage());
+ } else {
+ if ($start && $at->isMonitoring())
+ $feedback = _('Monitoring Started');
+ elseif ($stop && !$at->isMonitoring())
+ $feedback = _('Monitoring Deactivated');
+ else {
+ $at->setMonitor();
+ $feedback=$at->getErrorMessage();
+ $at->clearError();
+ }
+ include $gfwww.'tracker/browse.php';
+ }
}
+ break;
}
- break;
- }
- //
- // Show delete form
- //
- case 'deleteartifact' : {
- if ($ath->userIsAdmin()) {
- $aid = getStringFromRequest('aid');
- $ah= new ArtifactHtml($ath,$aid);
- if (!$ah || !is_object($ah)) {
- exit_error('ERROR','Artifact Could Not Be Created');
- } elseif ($ah->isError()) {
- exit_error('ERROR',$ah->getErrorMessage());
+ //
+ // Show delete form
+ //
+ case 'deleteartifact' : {
+ if ($ath->userIsAdmin()) {
+ $aid = getStringFromRequest('aid');
+ $ah= new ArtifactHtml($ath,$aid);
+ if (!$ah || !is_object($ah)) {
+ exit_error('ERROR','Artifact Could Not Be Created');
+ } elseif ($ah->isError()) {
+ exit_error('ERROR',$ah->getErrorMessage());
+ }
+ include $gfwww.'tracker/deleteartifact.php';
+ } else {
+ exit_permission_denied();
}
- include 'deleteartifact.php';
- } else {
- exit_permission_denied();
+ break;
}
- break;
- }
- //
- // Handle the actual delete
- //
+ //
+ // Handle the actual delete
+ //
- case 'postdeleteartifact' : {
- if (!form_key_is_valid(getStringFromRequest('form_key'))) {
- exit_form_double_submit();
- }
- if ($ath->userIsAdmin()) {
- $aid = getStringFromRequest('aid');
- $ah= new ArtifactHtml($ath,$aid);
- if (!$ah || !is_object($ah)) {
- exit_error('ERROR','Artifact Could Not Be Created');
- } elseif ($ah->isError()) {
- exit_error('ERROR',$ah->getErrorMessage());
+ case 'postdeleteartifact' : {
+ if (!form_key_is_valid(getStringFromRequest('form_key'))) {
+ exit_form_double_submit();
}
- if (!getStringFromRequest('confirm_delete')) {
- $feedback .= _('Confirmation failed. Artifact not deleted');
- }
- else {
- if (!$ah->delete(true)) {
- $feedback .= _('Artifact Delete Failed') . ': '.$ah->getErrorMessage();
- } else {
- $feedback .= _('Artifact Deleted Successfully');
+ if ($ath->userIsAdmin()) {
+ $aid = getStringFromRequest('aid');
+ $ah= new ArtifactHtml($ath,$aid);
+ if (!$ah || !is_object($ah)) {
+ exit_error('ERROR','Artifact Could Not Be Created');
+ } elseif ($ah->isError()) {
+ exit_error('ERROR',$ah->getErrorMessage());
+ }
+ if (!getStringFromRequest('confirm_delete')) {
+ $feedback .= _('Confirmation failed. Artifact not deleted');
}
+ else {
+ if (!$ah->delete(true)) {
+ $feedback .= _('Artifact Delete Failed') . ': '.$ah->getErrorMessage();
+ } else {
+ $feedback .= _('Artifact Deleted Successfully');
+ }
+ }
+ include $gfwww.'tracker/browse.php';
+ } else {
+ exit_permission_denied();
}
- include 'browse.php';
- } else {
- exit_permission_denied();
+ break;
}
- break;
- }
- case 'taskmgr' : {
- include 'taskmgr.php';
- break;
- }
- case 'browse' : {
- include 'browse.php';
- break;
- }
- case 'query' : {
- include ('query.php');
- break;
- }
- case 'downloadcsv' : {
- include ('downloadcsv.php');
- break;
- }
- case 'download' : {
- $aid = getStringFromRequest('aid');
- Header("Redirect: ".$GLOBALS['sys_urlprefix']."/tracker/download.php?group_id=$group_id&atid=$atid&aid=$aid&file_id=$file_id");
- break;
- }
- case 'detail' : {
- $aid = getStringFromRequest('aid');
+ case 'taskmgr' : {
+ include $gfwww.'tracker/taskmgr.php';
+ break;
+ }
+ case 'browse' : {
+ include $gfwww.'tracker/browse.php';
+ break;
+ }
+ case 'query' : {
+ include $gfwww.'tracker/query.php';
+ break;
+ }
+ case 'downloadcsv' : {
+ include $gfwww.'tracker/downloadcsv.php';
+ break;
+ }
+ case 'download' : {
+ $aid = getIntFromRequest('aid');
+ Header("Redirect: ".util_make_url ("/tracker/download.php?group_id=$group_id&atid=$atid&aid=$aid&file_id=$file_id"));
+ break;
+ }
+ case 'detail' : {
+ $aid = getIntFromRequest('aid');
- //
- // users can modify their own tickets in a limited way if they submitted them
- // even if they are not artifact admins
- //
- $ah=new ArtifactHtml($ath,$aid);
- if (!$ah || !is_object($ah)) {
- exit_error('ERROR','Artifact Could Not Be Created');
- } else if ($ah->isError()) {
- exit_error('ERROR',$ah->getErrorMessage());
- } else {
- if ($ath->userIsAdmin()) {
- include 'mod.php';
- } elseif ($ath->userIsTechnician()) {
- include 'mod-limited.php';
+ //
+ // users can modify their own tickets in a limited way if they submitted them
+ // even if they are not artifact admins
+ //
+ $ah=new ArtifactHtml($ath,$aid);
+ if (!$ah || !is_object($ah)) {
+ exit_error('ERROR','Artifact Could Not Be Created');
+ } else if ($ah->isError()) {
+ exit_error('ERROR',$ah->getErrorMessage());
} else {
- include 'detail.php';
+ if ($ath->userIsAdmin()) {
+ include $gfwww.'tracker/mod.php';
+ } elseif ($ath->userIsTechnician()) {
+ include $gfwww.'tracker/mod-limited.php';
+ } else {
+ include $gfwww.'tracker/detail.php';
+ }
}
+ break;
+ }
+ default : {
+ include $gfwww.'tracker/browse.php';
+ break;
}
- break;
- }
- default : {
- include 'browse.php';
- break;
}
-}
-?>
+ // Local Variables:
+ // mode: php
+ // c-file-style: "bsd"
+ // End:
+
+ ?>