3 final class PhabricatorBadgesRecipientsListView
extends AphrontView
{
9 public function setBadge(PhabricatorBadgesBadge
$badge) {
10 $this->badge
= $badge;
14 public function setAwards(array $awards) {
15 $this->awards
= $awards;
19 public function setHandles(array $handles) {
20 $this->handles
= $handles;
24 public function render() {
25 $viewer = $this->getViewer();
27 $badge = $this->badge
;
28 $handles = $this->handles
;
29 $awards = mpull($this->awards
, null, 'getRecipientPHID');
31 $can_edit = PhabricatorPolicyFilter
::hasCapability(
34 PhabricatorPolicyCapability
::CAN_EDIT
);
36 $award_button = id(new PHUIButtonView())
39 ->setText(pht('Add Recipients'))
41 ->setDisabled(!$can_edit)
42 ->setHref('/badges/recipients/'.$badge->getID().'/add/');
44 $header = id(new PHUIHeaderView())
45 ->setHeader(pht('Recipients'))
46 ->addActionLink($award_button);
48 $list = id(new PHUIObjectItemListView())
49 ->setNoDataString(pht('This badge does not have any recipients.'))
52 foreach ($handles as $handle) {
53 $remove_uri = '/badges/recipients/'.
54 $badge->getID().'/remove/?phid='.$handle->getPHID();
56 $award = $awards[$handle->getPHID()];
57 $awarder_handle = $viewer->renderHandle($award->getAwarderPHID());
58 $award_date = phabricator_date($award->getDateCreated(), $viewer);
60 'Awarded by %s on %s',
61 $awarder_handle->render(),
64 $item = id(new PHUIObjectItemView())
65 ->setHeader($handle->getFullName())
66 ->setSubhead($awarder_info)
67 ->setHref($handle->getURI())
68 ->setImageURI($handle->getImageURI());
72 id(new PHUIListItemView())
74 ->setName(pht('Remove'))
75 ->setHref($remove_uri)
79 $list->addItem($item);
82 $box = id(new PHUIObjectBoxView())
84 ->setBackground(PHUIObjectBoxView
::BLUE_PROPERTY
)
85 ->setObjectList($list);