Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / conpherence / view / ConpherenceParticipantView.php
blob912a3b8b21719efda2d723c75b6e47800a773822
1 <?php
3 final class ConpherenceParticipantView extends AphrontView {
5 private $conpherence;
6 private $updateURI;
8 public function setConpherence(ConpherenceThread $conpherence) {
9 $this->conpherence = $conpherence;
10 return $this;
13 public function setUpdateURI($uri) {
14 $this->updateURI = $uri;
15 return $this;
18 public function render() {
19 $conpherence = $this->conpherence;
20 $viewer = $this->getViewer();
22 $participants = $conpherence->getParticipants();
23 $count = new PhutilNumber(count($participants));
24 $handles = $conpherence->getHandles();
25 $handles = array_intersect_key($handles, $participants);
26 $head_handles = array_select_keys($handles, array($viewer->getPHID()));
27 $handle_list = mpull($handles, 'getName');
28 natcasesort($handle_list);
29 $handles = mpull($handles, null, 'getName');
30 $handles = array_select_keys($handles, $handle_list);
32 $head_handles = mpull($head_handles, null, 'getName');
33 $handles = $head_handles + $handles;
35 $can_edit = PhabricatorPolicyFilter::hasCapability(
36 $viewer,
37 $conpherence,
38 PhabricatorPolicyCapability::CAN_EDIT);
40 $body = array();
41 foreach ($handles as $handle) {
42 $user_phid = $handle->getPHID();
44 if (($user_phid == $viewer->getPHID()) || $can_edit) {
45 $icon = id(new PHUIIconView())
46 ->setIcon('fa-times')
47 ->addClass('lightbluetext');
48 $remove_html = javelin_tag(
49 'a',
50 array(
51 'class' => 'remove',
52 'sigil' => 'remove-person',
53 'meta' => array(
54 'remove_person' => $user_phid,
55 'action' => 'remove_person',
58 $icon);
59 } else {
60 $remove_html = null;
63 $body[] = phutil_tag(
64 'div',
65 array(
66 'class' => 'person-entry grouped',
68 array(
69 phutil_tag(
70 'a',
71 array(
72 'class' => 'pic',
73 'href' => $handle->getURI(),
75 phutil_tag(
76 'img',
77 array(
78 'src' => $handle->getImageURI(),
80 '')),
81 $handle->renderLink(),
82 $remove_html,
83 ));
86 $new_icon = id(new PHUIIconView())
87 ->setIcon('fa-plus-square')
88 ->setHref($this->updateURI)
89 ->setMetadata(array('widget' => null))
90 ->addSigil('conpherence-widget-adder');
92 $header = id(new PHUIHeaderView())
93 ->setHeader(pht('Participants (%d)', $count))
94 ->addClass('widgets-header')
95 ->addActionItem($new_icon);
97 $content = javelin_tag(
98 'div',
99 array(
100 'class' => 'widgets-body',
101 'id' => 'widgets-people',
102 'sigil' => 'widgets-people',
104 array(
105 $header,
106 $body,
109 return $content;