Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78400554
PhabricatorSlowvoteCloseController.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
Tue, Aug 20, 15:23
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Aug 22, 15:23 (2 d)
Engine
blob
Format
Raw Data
Handle
20040101
Attached To
rPH Phabricator
PhabricatorSlowvoteCloseController.php
View Options
<?php
final
class
PhabricatorSlowvoteCloseController
extends
PhabricatorSlowvoteController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
$poll
=
id
(
new
PhabricatorSlowvoteQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
))
->
executeOne
();
if
(!
$poll
)
{
return
new
Aphront404Response
();
}
$close_uri
=
'/V'
.
$poll
->
getID
();
if
(
$request
->
isFormPost
())
{
if
(
$poll
->
getIsClosed
())
{
$new_status
=
0
;
}
else
{
$new_status
=
1
;
}
$xactions
=
array
();
$xactions
[]
=
id
(
new
PhabricatorSlowvoteTransaction
())
->
setTransactionType
(
PhabricatorSlowvoteTransaction
::
TYPE_CLOSE
)
->
setNewValue
(
$new_status
);
id
(
new
PhabricatorSlowvoteEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
)
->
applyTransactions
(
$poll
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())->
setURI
(
$close_uri
);
}
if
(
$poll
->
getIsClosed
())
{
$title
=
pht
(
'Reopen Poll'
);
$content
=
pht
(
'Are you sure you want to reopen the poll?'
);
$submit
=
pht
(
'Reopen'
);
}
else
{
$title
=
pht
(
'Close Poll'
);
$content
=
pht
(
'Are you sure you want to close the poll?'
);
$submit
=
pht
(
'Close'
);
}
return
$this
->
newDialog
()
->
setTitle
(
$title
)
->
appendChild
(
$content
)
->
addSubmitButton
(
$submit
)
->
addCancelButton
(
$close_uri
);
}
}
Event Timeline
Log In to Comment