Path: blob/master/src/applications/conpherence/controller/ConpherenceNotificationPanelController.php
12256 views
<?php12final class ConpherenceNotificationPanelController3extends ConpherenceController {45public function handleRequest(AphrontRequest $request) {6$user = $request->getUser();7$conpherences = array();8require_celerity_resource('conpherence-notification-css');910$participant_data = id(new ConpherenceParticipantQuery())11->withParticipantPHIDs(array($user->getPHID()))12->setLimit(5)13->execute();14$participant_data = mpull($participant_data, null, 'getConpherencePHID');1516if ($participant_data) {17$conpherences = id(new ConpherenceThreadQuery())18->setViewer($user)19->withPHIDs(array_keys($participant_data))20->needProfileImage(true)21->needTransactions(true)22->setTransactionLimit(100)23->execute();24}2526if ($conpherences) {27// re-order the conpherences based on participation data28$conpherences = array_select_keys(29$conpherences, array_keys($participant_data));30$view = new AphrontNullView();31foreach ($conpherences as $conpherence) {32$p_data = $participant_data[$conpherence->getPHID()];33$d_data = $conpherence->getDisplayData($user);34$classes = array(35'phabricator-notification',36'conpherence-notification',37);3839if (!$p_data->isUpToDate($conpherence)) {40$classes[] = 'phabricator-notification-unread';41}42$uri = $this->getApplicationURI($conpherence->getID().'/');43$title = $d_data['title'];44$subtitle = $d_data['subtitle'];45$unread_count = $d_data['unread_count'];46$epoch = $d_data['epoch'];47$image = $d_data['image'];4849$msg_view = id(new ConpherenceMenuItemView())50->setUser($user)51->setTitle($title)52->setSubtitle($subtitle)53->setHref($uri)54->setEpoch($epoch)55->setImageURI($image)56->setUnreadCount($unread_count);5758$view->appendChild(javelin_tag(59'div',60array(61'class' => implode(' ', $classes),62'sigil' => 'notification',63'meta' => array(64'href' => $uri,65),66),67$msg_view));68}69$content = $view->render();70} else {71$rooms_uri = phutil_tag(72'a',73array(74'href' => '/conpherence/',75'class' => 'no-room-notification',76),77pht('You have joined no rooms.'));7879$content = phutil_tag_div(80'phabricator-notification no-notifications', $rooms_uri);81}8283$content = hsprintf(84'<div class="phabricator-notification-header grouped">%s%s</div>'.85'%s',86phutil_tag(87'a',88array(89'href' => '/conpherence/',90),91pht('Rooms')),92$this->renderPersistentOption(),93$content);9495$unread = id(new ConpherenceParticipantCountQuery())96->withParticipantPHIDs(array($user->getPHID()))97->withUnread(true)98->execute();99$unread_count = idx($unread, $user->getPHID(), 0);100101$json = array(102'content' => $content,103'number' => (int)$unread_count,104);105106return id(new AphrontAjaxResponse())->setContent($json);107}108109private function renderPersistentOption() {110$viewer = $this->getViewer();111$column_key = PhabricatorConpherenceColumnVisibleSetting::SETTINGKEY;112$show = (bool)$viewer->getUserSetting($column_key, false);113114$view = phutil_tag(115'div',116array(117'class' => 'persistent-option',118),119array(120javelin_tag(121'input',122array(123'type' => 'checkbox',124'checked' => ($show) ? 'checked' : null,125'value' => !$show,126'sigil' => 'conpherence-persist-column',127)),128phutil_tag(129'span',130array(),131pht('Persistent Chat')),132));133134return $view;135}136137}138139140