Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/conpherence/view/ConpherenceParticipantView.php
12256 views
1
<?php
2
3
final class ConpherenceParticipantView extends AphrontView {
4
5
private $conpherence;
6
private $updateURI;
7
8
public function setConpherence(ConpherenceThread $conpherence) {
9
$this->conpherence = $conpherence;
10
return $this;
11
}
12
13
public function setUpdateURI($uri) {
14
$this->updateURI = $uri;
15
return $this;
16
}
17
18
public function render() {
19
$conpherence = $this->conpherence;
20
$viewer = $this->getViewer();
21
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);
31
32
$head_handles = mpull($head_handles, null, 'getName');
33
$handles = $head_handles + $handles;
34
35
$can_edit = PhabricatorPolicyFilter::hasCapability(
36
$viewer,
37
$conpherence,
38
PhabricatorPolicyCapability::CAN_EDIT);
39
40
$body = array();
41
foreach ($handles as $handle) {
42
$user_phid = $handle->getPHID();
43
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',
56
),
57
),
58
$icon);
59
} else {
60
$remove_html = null;
61
}
62
63
$body[] = phutil_tag(
64
'div',
65
array(
66
'class' => 'person-entry grouped',
67
),
68
array(
69
phutil_tag(
70
'a',
71
array(
72
'class' => 'pic',
73
'href' => $handle->getURI(),
74
),
75
phutil_tag(
76
'img',
77
array(
78
'src' => $handle->getImageURI(),
79
),
80
'')),
81
$handle->renderLink(),
82
$remove_html,
83
));
84
}
85
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');
91
92
$header = id(new PHUIHeaderView())
93
->setHeader(pht('Participants (%d)', $count))
94
->addClass('widgets-header')
95
->addActionItem($new_icon);
96
97
$content = javelin_tag(
98
'div',
99
array(
100
'class' => 'widgets-body',
101
'id' => 'widgets-people',
102
'sigil' => 'widgets-people',
103
),
104
array(
105
$header,
106
$body,
107
));
108
109
return $content;
110
}
111
112
}
113
114