private function createChangesetId(Tracker_Artifact $artifact, PFUser $submitter, $submitted_on) { $email = null; if ($submitter->isAnonymous()) { $email = $submitter->getEmail(); } return $this->changeset_dao->create($artifact->getId(), $submitter->getId(), $email, $submitted_on); }
/** * Update an artifact (means create a new changeset) * * @param array $fields_data Artifact fields values * @param string $comment The comment (follow-up) associated with the artifact update * @param PFUser $submitter The user who is doing the update * @param boolean $send_notification true if a notification must be sent, false otherwise * @param string $comment_format The comment (follow-up) type ("text" | "html") * * @throws Tracker_Exception In the validation * @throws Tracker_NoChangeException In the validation * * @return Tracker_Artifact_Changeset|Boolean The new changeset if update is done without error, false otherwise */ public function create(Tracker_Artifact $artifact, array $fields_data, $comment, PFUser $submitter, $submitted_on, $send_notification, $comment_format) { $this->changeset_dao->startTransaction(); $comment = trim($comment); $email = null; if ($submitter->isAnonymous()) { $email = $submitter->getEmail(); } $this->validateNewChangeset($artifact, $fields_data, $comment, $submitter, $email); $previous_changeset = $artifact->getLastChangeset(); /* * Post actions were run by validateNewChangeset but they modified a * different set of $fields_data in the case of massChange or soap requests; * we run them again for the current $fields_data */ $artifact->getWorkflow()->before($fields_data, $submitter, $artifact); $changeset_id = $this->changeset_dao->create($artifact->getId(), $submitter->getId(), $email, $submitted_on); if (!$changeset_id) { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker_artifact', 'unable_update')); $this->changeset_dao->rollBack(); throw new Tracker_ChangesetNotCreatedException(); } if (!$this->storeComment($artifact, $comment, $submitter, $submitted_on, $comment_format, $changeset_id)) { $this->changeset_dao->rollBack(); throw new Tracker_CommentNotStoredException(); } $this->storeFieldsValues($artifact, $previous_changeset, $fields_data, $submitter, $changeset_id); $new_changeset = new Tracker_Artifact_Changeset($changeset_id, $artifact, $submitter->getId(), $submitted_on, $email); $artifact->addChangeset($new_changeset); $save_after_ok = $this->saveArtifactAfterNewChangeset($artifact, $fields_data, $submitter, $new_changeset, $previous_changeset); if (!$save_after_ok) { $this->changeset_dao->rollBack(); throw new Tracker_AfterSaveException(); } $this->event_manager->processEvent(TRACKER_EVENT_ARTIFACT_POST_UPDATE, array('artifact' => $artifact)); try { $this->changeset_dao->commit(); } catch (Exception $exception) { throw new Tracker_ChangesetCommitException(); } if ($send_notification) { $artifact->getChangeset($changeset_id)->notify(); } return $new_changeset; }