3 final class ConpherenceNotificationPanelController
4 extends ConpherenceController
{
6 public function handleRequest(AphrontRequest
$request) {
7 $user = $request->getUser();
8 $conpherences = array();
9 require_celerity_resource('conpherence-notification-css');
11 $participant_data = id(new ConpherenceParticipantQuery())
12 ->withParticipantPHIDs(array($user->getPHID()))
15 $participant_data = mpull($participant_data, null, 'getConpherencePHID');
17 if ($participant_data) {
18 $conpherences = id(new ConpherenceThreadQuery())
20 ->withPHIDs(array_keys($participant_data))
21 ->needProfileImage(true)
22 ->needTransactions(true)
23 ->setTransactionLimit(100)
28 // re-order the conpherences based on participation data
29 $conpherences = array_select_keys(
30 $conpherences, array_keys($participant_data));
31 $view = new AphrontNullView();
32 foreach ($conpherences as $conpherence) {
33 $p_data = $participant_data[$conpherence->getPHID()];
34 $d_data = $conpherence->getDisplayData($user);
36 'phabricator-notification',
37 'conpherence-notification',
40 if (!$p_data->isUpToDate($conpherence)) {
41 $classes[] = 'phabricator-notification-unread';
43 $uri = $this->getApplicationURI($conpherence->getID().'/');
44 $title = $d_data['title'];
45 $subtitle = $d_data['subtitle'];
46 $unread_count = $d_data['unread_count'];
47 $epoch = $d_data['epoch'];
48 $image = $d_data['image'];
50 $msg_view = id(new ConpherenceMenuItemView())
53 ->setSubtitle($subtitle)
57 ->setUnreadCount($unread_count);
59 $view->appendChild(javelin_tag(
62 'class' => implode(' ', $classes),
63 'sigil' => 'notification',
70 $content = $view->render();
72 $rooms_uri = phutil_tag(
75 'href' => '/conpherence/',
76 'class' => 'no-room-notification',
78 pht('You have joined no rooms.'));
80 $content = phutil_tag_div(
81 'phabricator-notification no-notifications', $rooms_uri);
85 '<div class="phabricator-notification-header grouped">%s%s</div>'.
90 'href' => '/conpherence/',
93 $this->renderPersistentOption(),
96 $unread = id(new ConpherenceParticipantCountQuery())
97 ->withParticipantPHIDs(array($user->getPHID()))
100 $unread_count = idx($unread, $user->getPHID(), 0);
103 'content' => $content,
104 'number' => (int)$unread_count,
107 return id(new AphrontAjaxResponse())->setContent($json);
110 private function renderPersistentOption() {
111 $viewer = $this->getViewer();
112 $column_key = PhabricatorConpherenceColumnVisibleSetting
::SETTINGKEY
;
113 $show = (bool)$viewer->getUserSetting($column_key, false);
118 'class' => 'persistent-option',
124 'type' => 'checkbox',
125 'checked' => ($show) ?
'checked' : null,
127 'sigil' => 'conpherence-persist-column',
132 pht('Persistent Chat')),