public function moveArtifactBeforeWithHistoryChangeLogging($artifact_id, $successor_id, $context_id, $project_id) { $old_global_rank = $this->getGlobalRank($artifact_id); $this->priority_dao->moveArtifactBefore($artifact_id, $successor_id); $new_global_rank = $this->getGlobalRank($artifact_id); if ($old_global_rank !== $new_global_rank) { $this->logPriorityChange($artifact_id, $artifact_id, $successor_id, $context_id, $project_id, $old_global_rank); } }
/** * Process the artifact functions * * @param Tracker_IDisplayTrackerLayout $layout Displays the page header and footer * @param Codendi_Request $request The data from the user * @param User $current_user The current user * * @return void */ public function process(Tracker_IDisplayTrackerLayout $layout, $request, $current_user) { switch ($request->get('func')) { case 'update-comment': if ((int) $request->get('changeset_id') && $request->get('content')) { if ($changeset = $this->getChangeset($request->get('changeset_id'))) { $comment_format = $this->validateCommentFormat($request, 'comment_format'); $changeset->updateComment($request->get('content'), $current_user, $comment_format); if ($request->isAjax()) { //We assume that we can only change a comment from a followUp echo $changeset->getComment()->fetchFollowUp(); } } } break; case 'preview-attachment': case 'show-attachment': if ((int) $request->get('field') && (int) $request->get('attachment')) { $ff = Tracker_FormElementFactory::instance(); //TODO: check that the user can read the field if ($field = $ff->getFormElementByid($request->get('field'))) { $method = explode('-', $request->get('func')); $method = $method[0]; $method .= 'Attachment'; if (method_exists($field, $method)) { $field->{$method}($request->get('attachment')); } } } break; case 'artifact-delete-changeset': // @see comment in Tracker_Artifact_Changeset::fetchFollowUp() //if ($changeset = $this->getChangeset($request->get('changeset'))) { // $changeset->delete($current_user); //} $GLOBALS['Response']->redirect('?aid=' . $this->id); break; case 'artifact-update': //TODO : check permissions on this action? $fields_data = $request->get('artifact'); $comment_format = $this->validateCommentFormat($request, 'comment_formatnew'); $this->setUseArtifactPermissions($request->get('use_artifact_permissions') ? 1 : 0); $this->getTracker()->augmentDataFromRequest($fields_data); if ($this->createNewChangeset($fields_data, $request->get('artifact_followup_comment'), $current_user, $request->get('email'), true, $comment_format)) { $art_link = $this->fetchDirectLinkToArtifact(); $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_index', 'update_success', array($art_link)), CODENDI_PURIFIER_LIGHT); $redirect = $this->getRedirectUrlAfterArtifactUpdate($request, $this->tracker_id, $this->getId()); $this->summonArtifactRedirectors($request, $redirect); $GLOBALS['Response']->redirect($redirect->toUrl()); //die(); } else { $this->display($layout, $request, $current_user); } break; case 'unassociate-artifact-to': $artlink_fields = $this->getFormElementFactory()->getUsedArtifactLinkFields($this->getTracker()); $linked_artifact_id = $request->get('linked-artifact-id'); if (count($artlink_fields)) { $this->unlinkArtifact($artlink_fields, $linked_artifact_id, $current_user); $this->summonArtifactAssociators($request, $current_user, $linked_artifact_id); } else { $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_tracker', 'must_have_artifact_link_field')); $GLOBALS['Response']->sendStatusCode(400); } break; case 'associate-artifact-to': $linked_artifact_id = $request->get('linked-artifact-id'); if (!$this->linkArtifact($linked_artifact_id, $current_user)) { $GLOBALS['Response']->sendStatusCode(400); } else { $this->summonArtifactAssociators($request, $current_user, $linked_artifact_id); } break; case 'higher-priority-than': $dao = new Tracker_Artifact_PriorityDao(); $dao->moveArtifactBefore($this->getId(), (int) $request->get('target-id')); break; case 'lesser-priority-than': $dao = new Tracker_Artifact_PriorityDao(); $dao->moveArtifactAfter($this->getId(), (int) $request->get('target-id')); break; default: if ($request->isAjax()) { echo $this->fetchTooltip($current_user); } else { $this->display($layout, $request, $current_user); } break; } }