Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F92655406
PonderCommentSaveController.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
Fri, Nov 22, 10:54
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Nov 24, 10:54 (2 d)
Engine
blob
Format
Raw Data
Handle
22480140
Attached To
rPH Phabricator
PonderCommentSaveController.php
View Options
<?php
final
class
PonderCommentSaveController
extends
PonderController
{
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
if
(!
$request
->
isFormPost
())
{
return
new
Aphront400Response
();
}
$user
=
$request
->
getUser
();
$question_id
=
$request
->
getInt
(
'question_id'
);
$question
=
PonderQuestionQuery
::
loadSingle
(
$user
,
$question_id
);
if
(!
$question
)
{
return
new
Aphront404Response
();
}
$question
->
attachRelated
();
$target
=
$request
->
getStr
(
'target'
);
$objects
=
id
(
new
PhabricatorObjectHandleData
(
array
(
$target
)))
->
setViewer
(
$user
)
->
loadHandles
();
if
(!
$objects
)
{
return
new
Aphront404Response
();
}
$content
=
$request
->
getStr
(
'content'
);
if
(!
strlen
(
trim
(
$content
)))
{
$dialog
=
new
AphrontDialogView
();
$dialog
->
setUser
(
$request
->
getUser
());
$dialog
->
setTitle
(
'Empty comment'
);
$dialog
->
appendChild
(
phutil_tag
(
'p'
,
array
(),
pht
(
'Your comment must not be empty.'
)));
$dialog
->
addCancelButton
(
'/Q'
.
$question_id
);
return
id
(
new
AphrontDialogResponse
())->
setDialog
(
$dialog
);
}
$res
=
new
PonderComment
();
$res
->
setContent
(
$content
)
->
setAuthorPHID
(
$user
->
getPHID
())
->
setTargetPHID
(
$target
);
id
(
new
PonderCommentEditor
())
->
setQuestion
(
$question
)
->
setComment
(
$res
)
->
setTargetPHID
(
$target
)
->
setActor
(
$user
)
->
save
();
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
id
(
new
PhutilURI
(
'/Q'
.
$question
->
getID
())));
}
}
Event Timeline
Log In to Comment