Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93263241
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
Wed, Nov 27, 11:04
Size
1 KB
Mime Type
text/x-php
Expires
Fri, Nov 29, 11:04 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
22605895
Attached To
rPH Phabricator
PhabricatorSlowvoteCloseController.php
View Options
<?php
final
class
PhabricatorSlowvoteCloseController
extends
PhabricatorSlowvoteController
{
private
$id
;
public
function
willProcessRequest
(
array
$data
)
{
$this
->
id
=
$data
[
'id'
];
}
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$user
=
$request
->
getUser
();
$poll
=
id
(
new
PhabricatorSlowvoteQuery
())
->
setViewer
(
$user
)
->
withIDs
(
array
(
$this
->
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
(
$user
)
->
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