mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-28 09:42:41 +01:00
b39f5d651c
Summary: Fixes T8703. The URI handling here was a little unusual. Test Plan: - Edited and deleted comments in several applications, including Macro. - As an admin, deleted others' comments. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8703 Differential Revision: https://secure.phabricator.com/D13469
69 lines
2.1 KiB
PHP
69 lines
2.1 KiB
PHP
<?php
|
|
|
|
final class PhabricatorApplicationTransactionCommentEditController
|
|
extends PhabricatorApplicationTransactionController {
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$viewer = $this->getViewer();
|
|
|
|
$xaction = id(new PhabricatorObjectQuery())
|
|
->setViewer($viewer)
|
|
->withPHIDs(array($request->getURIData('phid')))
|
|
->executeOne();
|
|
if (!$xaction) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
if (!$xaction->getComment()) {
|
|
// You can't currently edit a transaction which doesn't have a comment.
|
|
// Some day you may be able to edit the visibility.
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
if ($xaction->getComment()->getIsRemoved()) {
|
|
// You can't edit history of a transaction with a removed comment.
|
|
return new Aphront400Response();
|
|
}
|
|
|
|
$phid = $xaction->getObjectPHID();
|
|
$handles = $viewer->loadHandles(array($phid));
|
|
$obj_handle = $handles[$phid];
|
|
|
|
if ($request->isDialogFormPost()) {
|
|
$text = $request->getStr('text');
|
|
|
|
$comment = $xaction->getApplicationTransactionCommentObject();
|
|
$comment->setContent($text);
|
|
if (!strlen($text)) {
|
|
$comment->setIsDeleted(true);
|
|
}
|
|
|
|
$editor = id(new PhabricatorApplicationTransactionCommentEditor())
|
|
->setActor($viewer)
|
|
->setContentSource(PhabricatorContentSource::newFromRequest($request))
|
|
->applyEdit($xaction, $comment);
|
|
|
|
if ($request->isAjax()) {
|
|
return id(new AphrontAjaxResponse())->setContent(array());
|
|
} else {
|
|
return id(new AphrontReloadResponse())->setURI($obj_handle->getURI());
|
|
}
|
|
}
|
|
|
|
$form = id(new AphrontFormView())
|
|
->setUser($viewer)
|
|
->setFullWidth(true)
|
|
->appendControl(
|
|
id(new PhabricatorRemarkupControl())
|
|
->setName('text')
|
|
->setValue($xaction->getComment()->getContent()));
|
|
|
|
return $this->newDialog()
|
|
->setTitle(pht('Edit Comment'))
|
|
->addHiddenInput('anchor', $request->getStr('anchor'))
|
|
->appendForm($form)
|
|
->addSubmitButton(pht('Save Changes'))
|
|
->addCancelButton($obj_handle->getURI());
|
|
}
|
|
|
|
}
|