public function process(Tracker_IDisplayTrackerLayout $layout, Codendi_Request $request, PFUser $current_user) { //TODO : check permissions on this action? $comment_format = $this->artifact->validateCommentFormat($request, 'comment_formatnew'); $this->artifact->setUseArtifactPermissions($request->get('use_artifact_permissions') ? 1 : 0); $fields_data = $request->get('artifact'); $fields_data['request_method_called'] = 'artifact-update'; $this->artifact->getTracker()->augmentDataFromRequest($fields_data); unset($fields_data['request_method_called']); try { if ($current_user->isAnonymous()) { $current_user->setEmail($request->get('email')); } $this->artifact->createNewChangeset($fields_data, $request->get('artifact_followup_comment'), $current_user, true, $comment_format); $art_link = $this->artifact->fetchDirectLinkToArtifact(); $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_index', 'update_success', array($art_link)), CODENDI_PURIFIER_LIGHT); $redirect = $this->getRedirectUrlAfterArtifactUpdate($request); $this->artifact->summonArtifactRedirectors($request, $redirect); if ($request->isAjax()) { $this->sendAjaxCardsUpdateInfo($current_user, $this->artifact, $this->form_element_factory); } elseif ($request->existAndNonEmpty('from_overlay')) { echo '<script>window.parent.tuleap.cardwall.cardsEditInPlace.validateEdition(' . $this->artifact->getId() . ')</script>'; return; } else { $GLOBALS['Response']->redirect($redirect->toUrl()); } } catch (Tracker_NoChangeException $e) { if ($request->isAjax()) { $this->sendAjaxCardsUpdateInfo($current_user, $this->artifact, $this->form_element_factory); } else { $GLOBALS['Response']->addFeedback('info', $e->getMessage(), CODENDI_PURIFIER_LIGHT); $render = new Tracker_Artifact_ReadOnlyRenderer($this->event_manager, $this->artifact, $this->form_element_factory, $layout); $render->display($request, $current_user); } } catch (Tracker_Exception $e) { if ($request->isAjax()) { $this->sendAjaxCardsUpdateInfo($current_user, $this->artifact, $this->form_element_factory); } else { $GLOBALS['Response']->addFeedback('error', $e->getMessage()); $render = new Tracker_Artifact_ReadOnlyRenderer($this->event_manager, $this->artifact, $this->form_element_factory, $layout); $render->display($request, $current_user); } } }
/** * Process the artifact functions * * @param Tracker_IDisplayTrackerLayout $layout Displays the page header and footer * @param Codendi_Request $request The data from the user * @param PFUser $current_user The current user * * @return void */ public function process(Tracker_IDisplayTrackerLayout $layout, $request, $current_user) { switch ($request->get('func')) { case 'get-children': $children = $this->getChildPresenterCollection($current_user); $GLOBALS['Response']->sendJSON($children); exit; break; case 'update-comment': if ((int) $request->get('changeset_id') && $request->exist('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, $_SERVER['REQUEST_TIME']); 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': $action = new Tracker_Action_UpdateArtifact($this, $this->getFormElementFactory(), $this->getEventManager()); $action->process($layout, $request, $current_user); break; case 'check-user-can-link-and-unlink': $source_artifact = (int) $request->get('from-artifact'); $destination_artifact = (int) $request->get('to-artifact'); if (!($this->userHasRankingPermissions($source_artifact) && $this->userHasRankingPermissions($destination_artifact))) { $this->sendUserDoesNotHavePermissionsErrorCode(); } break; case 'unassociate-artifact-to': $artlink_fields = $this->getFormElementFactory()->getUsedArtifactLinkFields($this->getTracker()); $linked_artifact_id = $request->get('linked-artifact-id'); if (!$this->userHasRankingPermissions($this->getId())) { $this->sendUserDoesNotHavePermissionsErrorCode(); break; } 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->userHasRankingPermissions($this->getId())) { $this->sendUserDoesNotHavePermissionsErrorCode(); break; } 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': $target_id = (int) $request->get('target-id'); $milestone_id = (int) $request->get('milestone-id'); $project_id = $this->getProjectId(); $user_is_authorized = $this->userHasRankingPermissions($milestone_id); if (!$this->userHasRankingPermissions($milestone_id)) { $this->sendUserDoesNotHavePermissionsErrorCode(); break; } $this->getPriorityManager()->moveArtifactBeforeWithHistoryChangeLogging($this->getId(), $target_id, $milestone_id, $project_id); break; case 'lesser-priority-than': $target_id = (int) $request->get('target-id'); $milestone_id = (int) $request->get('milestone-id'); $project_id = $this->getProjectId(); if (!$this->userHasRankingPermissions($milestone_id)) { $this->sendUserDoesNotHavePermissionsErrorCode(); break; } $this->getPriorityManager()->moveArtifactAfterWithHistoryChangeLogging($this->getId(), $target_id, $milestone_id, $project_id); break; case 'show-in-overlay': $renderer = new Tracker_Artifact_EditOverlayRenderer($this, $this->getEventManager()); $renderer->display($request, $current_user); break; case 'get-new-changesets': $changeset_id = $request->getValidated('changeset_id', 'uint', 0); $changeset_factory = $this->getChangesetFactory(); $GLOBALS['Response']->sendJSON($changeset_factory->getNewChangesetsFormattedForJson($this, $changeset_id)); break; case 'edit': $GLOBALS['Response']->redirect($this->getUri()); break; case 'get-edit-in-place': $renderer = new Tracker_Artifact_Renderer_EditInPlaceRenderer($this, $this->getMustacheRenderer()); $renderer->display($current_user, $request); break; case 'update-in-place': $renderer = new Tracker_Artifact_Renderer_EditInPlaceRenderer($this, $this->getMustacheRenderer()); $renderer->updateArtifact($request, $current_user); break; case 'copy-artifact': $art_link = $this->fetchDirectLinkToArtifact(); $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_artifact', 'copy_mode_info', array($art_link)), CODENDI_PURIFIER_LIGHT); $renderer = new Tracker_Artifact_CopyRenderer($this->getEventManager(), $this, $this->getFormElementFactory(), $layout); $renderer->display($request, $current_user); break; case 'manage-subscription': $artifact_subscriber = new Tracker_ArtifactNotificationSubscriber($this, $this->getDao()); if ($this->doesUserHaveUnsubscribedFromNotification($current_user)) { $artifact_subscriber->subscribeUser($current_user, $request); break; } $artifact_subscriber->unsubscribeUser($current_user, $request); break; default: if ($request->isAjax()) { echo $this->fetchTooltip($current_user); } else { $renderer = new Tracker_Artifact_ReadOnlyRenderer($this->getEventManager(), $this, $this->getFormElementFactory(), $layout); $renderer->display($request, $current_user); } break; } }
public function display(Codendi_Request $request, PFUser $current_user) { parent::display($request, $current_user); }