/** * addArtifactFollowup - add a followup to the artifact $artifact_id * * @param string $sessionKey the session hash associated with the session opened by the person who calls the service * @param int $group_id the ID of the group we want to add the follow-up * @param int $group_artifact_id the ID of the tracker we want to add the follow-up * @param int $artifact_id the ID of the artifact we want to add the follow-up * @param string $body the body of the follow-up * @param int $comment_type_id the comment type ID if so, or 100 if comment type is not used * @param int $format the format within the followup will be posted (text/HTML) * @return boolean true if the add is ok or a soap fault if : * - group_id does not match with a valid project, * - group_artifact_id does not match with a valid tracker * - artifact_id does not match with a valid artifact * - the add failed */ function addArtifactFollowup($sessionKey, $group_id, $group_artifact_id, $artifact_id, $body, $comment_type_id, $format) { global $art_field_fact, $ath; if (session_continue($sessionKey)) { try { $pm = ProjectManager::instance(); $grp = $pm->getGroupByIdForSoap($group_id, 'addArtifactFollowup'); } catch (SoapFault $e) { return $e; } $ath = new ArtifactType($grp, $group_artifact_id); if (!$ath || !is_object($ath)) { return new SoapFault(get_artifact_type_fault, 'Could Not Get ArtifactType', 'addArtifactFollowup'); } elseif ($ath->isError()) { return new SoapFault(get_artifact_type_fault, $ath->getErrorMessage(), 'addArtifactFollowup'); } $art_field_fact = new ArtifactFieldFactory($ath); if (!$art_field_fact || !is_object($art_field_fact)) { return new SoapFault(get_artifact_field_factory_fault, 'Could Not Get ArtifactFieldFactory', 'addArtifactFollowup'); } elseif ($art_field_fact->isError()) { return new SoapFault(get_artifact_field_factory_fault, $art_field_fact->getErrorMessage(), 'addArtifactFollowup'); } $a = new Artifact($ath, $artifact_id); if (!$a || !is_object($a)) { return new SoapFault(get_artifact_fault, 'Could Not Get Artifact', 'addArtifactFollowup'); } elseif ($a->isError()) { return new SoapFault(get_artifact_fault, $a->getErrorMessage(), 'addArtifactFollowup'); } // add the follow up with 0 as canned_response_id. To set a canned response, just put the content in the body comment. if (!$a->addFollowUpComment($body, $comment_type_id, 0, &$changes, $format)) { return new SoapFault(create_followup_fault, 'Comment could not be saved', 'addArtifactFollowup'); } else { // Send notification $agnf = new ArtifactGlobalNotificationFactory(); $addresses = $agnf->getAllAddresses($ath->getID(), true); $a->mailFollowupWithPermissions($addresses, $changes); return true; } // Update last_update_date field $a->update_last_update_date(); } else { return new SoapFault(invalid_session_fault, 'Invalid Session', 'addArtifactFollowup'); } }
} break; case 'export': require './export.php'; break; case 'updatecomment': $artifact_id = $request->get('artifact_id'); if (user_isloggedin() && $request->exist('followup_update')) { $followup_update = $request->get('followup_update'); $ah = new ArtifactHtml($ath, $artifact_id); $vFormat = new Valid_WhiteList('comment_format', array(Artifact::FORMAT_HTML, Artifact::FORMAT_TEXT)); $comment_format = $request->getValidated('comment_format', $vFormat, Artifact::FORMAT_TEXT); if ($ah->updateFollowupComment($request->get('artifact_history_id'), $followup_update, $changes, $comment_format)) { $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('tracker_common_artifact', 'followup_upd_succ')); $agnf = new ArtifactGlobalNotificationFactory(); $addresses = $agnf->getAllAddresses($ath->getID(), true); $ah->mailFollowupWithPermissions($addresses, $changes); } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('tracker_common_artifact', 'followup_upd_fail')); } } $GLOBALS['Response']->redirect('?group_id=' . (int) $group_id . '&atid=' . (int) $atid . '&aid=' . (int) $artifact_id . '&func=detail'); break; case 'browse': $masschange = false; if ($request->get('change_report_column')) { $report_id = $request->getValidated('report_id', 'uint'); $field_name = $request->getValidated('change_report_column', 'string'); $arf = new ArtifactReportFactory($ath); if ($report = $arf->getArtifactReportHtml($report_id, $atid)) { $report->toggleFieldColumnUsage($field_name);
function updateArtifact($row, $data, $aid, &$errors, $notify = false) { global $Language; $ah = new ArtifactHtml($this->ath, $aid); if (!$ah || !is_object($ah)) { exit_error($Language->getText('global', 'error'), $Language->getText('tracker_index', 'not_create_art')); } else { if ($ah->isError()) { exit_error($Language->getText('global', 'error'), $ah->getErrorMessage()); } else { // Check if users can update anonymously if (!user_isloggedin() && !$this->ath->allowsAnon()) { exit_not_logged_in(); } if (!$ah->ArtifactType->userIsAdmin()) { exit_permission_denied(); return; } $vfl = $this->prepareVfl($data, $artifact_depend_id, $add_cc, $cc_comment, $comments); //data control layer if (!$ah->handleUpdate($artifact_depend_id, 100, $changes, false, $vfl, true)) { exit_error($Language->getText('global', 'error'), ''); } if ($add_cc) { if (!$ah->updateCC($add_cc, $cc_comment)) { $errors .= $Language->getText('tracker_import_utils', 'problem_add_cc', $ah->getID()) . " "; } } $comments_ok = false; if ($comments) { if ($this->parseFollowUpComments($comments, $parsed_comments, $aid) && $parsed_comments && !empty($parsed_comments)) { $comments_ok = true; $changes = null; if (!$ah->addFollowUpComments($parsed_comments)) { $errors .= $Language->getText('tracker_import_utils', 'problem_insert_followup', $ah->getID()) . " "; $comments_ok = false; return false; } } else { return false; } } if ($notify && (count($changes) > 0 || $add_cc || $comments_ok)) { $agnf = new ArtifactGlobalNotificationFactory(); $ah->mailFollowupWithPermissions($agnf->getAllAddresses($this->ath->getID(), $update = true), $changes); } if (count($changes) > 0 || $add_cc || $comments_ok) { // Update the 'last_update_date' artifact field $res_last_up = $ah->update_last_update_date(); } } } return true; }