mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-29 02:02:41 +01:00
16ce63ec20
Summary: Fixes T7254. This reverts the previous functionality, but makes pertinent updates like scaling the images to 35 x 35. Codebase had moved on quite a bit so far from a straight revert but nothing too tricky relative to the code that was here before. This does not allow for changing the images from the conpherence durable column view -- that would require some JS trickery, but also doesn't fit into the current notion of the column being "light". Can always modify this later. Test Plan: - from full conpherence, uploaded a square pic and things looked nice - from full conpherence, uploaded a rectangular pic and wasnt happy, so reinvoked edit dialog and used crop control to make it better - noted could not update picture from conpherence durable column - used different user and noted could see custom picture Reviewers: epriestley Reviewed By: epriestley Subscribers: CodeMouse92, Korvin, epriestley Maniphest Tasks: T7254 Differential Revision: https://secure.phabricator.com/D12648
103 lines
3 KiB
PHP
103 lines
3 KiB
PHP
<?php
|
|
|
|
final class ConpherenceNotificationPanelController
|
|
extends ConpherenceController {
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
|
$user = $request->getUser();
|
|
$conpherences = array();
|
|
$unread_status = ConpherenceParticipationStatus::BEHIND;
|
|
|
|
$participant_data = id(new ConpherenceParticipantQuery())
|
|
->withParticipantPHIDs(array($user->getPHID()))
|
|
->setLimit(5)
|
|
->execute();
|
|
|
|
if ($participant_data) {
|
|
$conpherences = id(new ConpherenceThreadQuery())
|
|
->setViewer($user)
|
|
->withPHIDs(array_keys($participant_data))
|
|
->needCropPics(true)
|
|
->needTransactions(true)
|
|
->setTransactionLimit(3 * 5)
|
|
->needParticipantCache(true)
|
|
->execute();
|
|
}
|
|
|
|
if ($conpherences) {
|
|
require_celerity_resource('conpherence-notification-css');
|
|
// re-order the conpherences based on participation data
|
|
$conpherences = array_select_keys(
|
|
$conpherences, array_keys($participant_data));
|
|
$view = new AphrontNullView();
|
|
foreach ($conpherences as $conpherence) {
|
|
$p_data = $participant_data[$conpherence->getPHID()];
|
|
$d_data = $conpherence->getDisplayData($user);
|
|
$classes = array(
|
|
'phabricator-notification',
|
|
'conpherence-notification',
|
|
);
|
|
|
|
if ($p_data->getParticipationStatus() == $unread_status) {
|
|
$classes[] = 'phabricator-notification-unread';
|
|
}
|
|
$uri = $this->getApplicationURI($conpherence->getID().'/');
|
|
$title = $d_data['title'];
|
|
$subtitle = $d_data['subtitle'];
|
|
$unread_count = $d_data['unread_count'];
|
|
$epoch = $d_data['epoch'];
|
|
$image = $d_data['image'];
|
|
|
|
$msg_view = id(new ConpherenceMenuItemView())
|
|
->setUser($user)
|
|
->setTitle($title)
|
|
->setSubtitle($subtitle)
|
|
->setHref($uri)
|
|
->setEpoch($epoch)
|
|
->setImageURI($image)
|
|
->setUnreadCount($unread_count);
|
|
|
|
$view->appendChild(javelin_tag(
|
|
'div',
|
|
array(
|
|
'class' => implode(' ', $classes),
|
|
'sigil' => 'notification',
|
|
'meta' => array(
|
|
'href' => $uri,
|
|
),
|
|
),
|
|
$msg_view));
|
|
}
|
|
$content = $view->render();
|
|
} else {
|
|
$content = phutil_tag_div(
|
|
'phabricator-notification no-notifications',
|
|
pht('You have no messages.'));
|
|
}
|
|
|
|
$content = hsprintf(
|
|
'<div class="phabricator-notification-header">%s</div>'.
|
|
'%s',
|
|
phutil_tag(
|
|
'a',
|
|
array(
|
|
'href' => '/conpherence/',
|
|
),
|
|
pht('Messages')),
|
|
$content);
|
|
|
|
$unread = id(new ConpherenceParticipantCountQuery())
|
|
->withParticipantPHIDs(array($user->getPHID()))
|
|
->withParticipationStatus($unread_status)
|
|
->execute();
|
|
$unread_count = idx($unread, $user->getPHID(), 0);
|
|
|
|
$json = array(
|
|
'content' => $content,
|
|
'number' => (int)$unread_count,
|
|
);
|
|
|
|
return id(new AphrontAjaxResponse())->setContent($json);
|
|
}
|
|
|
|
}
|