Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97208736
PhabricatorBadgesEditRecipientsController.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, Jan 3, 11:18
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Jan 5, 11:18 (2 d)
Engine
blob
Format
Raw Data
Handle
23354812
Attached To
rPH Phabricator
PhabricatorBadgesEditRecipientsController.php
View Options
<?php
final
class
PhabricatorBadgesEditRecipientsController
extends
PhabricatorBadgesController
{
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$request
->
getViewer
();
$id
=
$request
->
getURIData
(
'id'
);
$xactions
=
array
();
$badge
=
id
(
new
PhabricatorBadgesQuery
())
->
setViewer
(
$viewer
)
->
withIDs
(
array
(
$id
))
->
requireCapabilities
(
array
(
PhabricatorPolicyCapability
::
CAN_EDIT
,
PhabricatorPolicyCapability
::
CAN_VIEW
,
))
->
executeOne
();
if
(!
$badge
)
{
return
new
Aphront404Response
();
}
$view_uri
=
$this
->
getApplicationURI
(
'recipients/'
.
$badge
->
getID
().
'/'
);
if
(
$request
->
isFormPost
())
{
$award_phids
=
array
();
$add_recipients
=
$request
->
getArr
(
'phids'
);
if
(
$add_recipients
)
{
foreach
(
$add_recipients
as
$phid
)
{
$award_phids
[]
=
$phid
;
}
}
$xactions
[]
=
id
(
new
PhabricatorBadgesTransaction
())
->
setTransactionType
(
PhabricatorBadgesBadgeAwardTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(
$award_phids
);
$editor
=
id
(
new
PhabricatorBadgesEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
)
->
applyTransactions
(
$badge
,
$xactions
);
return
id
(
new
AphrontRedirectResponse
())
->
setURI
(
$view_uri
);
}
$can_edit
=
PhabricatorPolicyFilter
::
hasCapability
(
$viewer
,
$badge
,
PhabricatorPolicyCapability
::
CAN_EDIT
);
$form_box
=
null
;
$title
=
pht
(
'Add Recipient'
);
if
(
$can_edit
)
{
$header_name
=
pht
(
'Edit Recipients'
);
$form
=
new
AphrontFormView
();
$form
->
setUser
(
$viewer
)
->
setFullWidth
(
true
)
->
appendControl
(
id
(
new
AphrontFormTokenizerControl
())
->
setName
(
'phids'
)
->
setLabel
(
pht
(
'Recipients'
))
->
setDatasource
(
new
PhabricatorPeopleDatasource
()));
}
$dialog
=
id
(
new
AphrontDialogView
())
->
setUser
(
$viewer
)
->
setTitle
(
pht
(
'Add Recipients'
))
->
appendForm
(
$form
)
->
addCancelButton
(
$view_uri
)
->
addSubmitButton
(
pht
(
'Add Recipients'
));
return
$dialog
;
}
}
Event Timeline
Log In to Comment