Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96193896
PonderQuestionStatusController.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
Mon, Dec 23, 15:43
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 25, 15:43 (2 d)
Engine
blob
Format
Raw Data
Handle
23141907
Attached To
rPH Phabricator
PonderQuestionStatusController.php
View Options
<?php
final
class
PonderQuestionStatusController
extends
PonderController
{
private
$status
;
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
status
=
idx
(
$data
,
'status'
);
$this
->
id
=
idx
(
$data
,
'id'
);
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$question
=
id
(
new
PonderQuestionQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$this
->
id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$question
)
{
return
new
Aphront404Response
();
}
switch
(
$this
->
status
)
{
case
'open'
:
$status
=
PonderQuestionStatus
::
STATUS_OPEN
;
break
;
case
'close'
:
$status
=
PonderQuestionStatus
::
STATUS_CLOSED
;
break
;
default
:
return
new
Aphront400Response
();
}
$xactions
=
array
();
$xactions
[]
=
id
(
new
PonderQuestionTransaction
())
->
setTransactionType
(
PonderQuestionTransaction
::
TYPE_STATUS
)
->
setNewValue
(
$status
);
$editor
=
id
(
new
PonderQuestionEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
);
$editor
->
applyTransactions
(
$question
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
'/Q'
.
$question
->
getID
());
}
}
Event Timeline
Log In to Comment