Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F102748683
PhabricatorApplicationTransactionCommentEditController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Feb 23, 19:08
Size
2 KB
Mime Type
text/x-php
Expires
Tue, Feb 25, 19:08 (2 d)
Engine
blob
Format
Raw Data
Handle
24419278
Attached To
rPH Phabricator
PhabricatorApplicationTransactionCommentEditController.php
View Options
<?php
final
class
PhabricatorApplicationTransactionCommentEditController
extends
PhabricatorApplicationTransactionController
{
private
$phid
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
phid
=
$data
[
'phid'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$xaction
=
id
(
new
PhabricatorObjectQuery
())
->
withPHIDs
(
array
(
$this
->
phid
))
->
setViewer
(
$user
)
->
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
();
}
$obj_phid
=
$xaction
->
getObjectPHID
();
$obj_handle
=
id
(
new
PhabricatorHandleQuery
())
->
setViewer
(
$user
)
->
withPHIDs
(
array
(
$obj_phid
))
->
executeOne
();
if
(
$request
->
isDialogFormPost
())
{
$text
=
$request
->
getStr
(
'text'
);
$comment
=
$xaction
->
getApplicationTransactionCommentObject
();
$comment
->
setContent
(
$text
);
if
(!
strlen
(
$text
))
{
$comment
->
setIsDeleted
(
true
);
}
$editor
=
id
(
new
PhabricatorApplicationTransactionCommentEditor
())
->
setActor
(
$user
)
->
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
());
}
}
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$user
)
->
setSubmitURI
(
$this
->
getApplicationURI
(
'/transactions/edit/'
.
$xaction
->
getPHID
().
'/'
))
->
setTitle
(
pht
(
'Edit Comment'
));
$dialog
->
addHiddenInput
(
'anchor'
,
$request
->
getStr
(
'anchor'
))
->
appendChild
(
id
(
new
PHUIFormLayoutView
())
->
setFullWidth
(
true
)
->
appendChild
(
id
(
new
PhabricatorRemarkupControl
())
->
setName
(
'text'
)
->
setValue
(
$xaction
->
getComment
()->
getContent
())));
$dialog
->
addSubmitButton
(
pht
(
'Save Changes'
))
->
addCancelButton
(
$obj_handle
->
getURI
());
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
}
Event Timeline
Log In to Comment