Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conpherence/query/ConpherenceThreadQuery.php
Show First 20 Lines • Show All 348 Lines • ▼ Show 20 Lines | private function loadWidgetData(array $conpherences) { | ||||
} | } | ||||
$participant_phids = array_mergev($participant_phids); | $participant_phids = array_mergev($participant_phids); | ||||
$file_phids = array_mergev($file_phids); | $file_phids = array_mergev($file_phids); | ||||
$epochs = CalendarTimeUtil::getCalendarEventEpochs( | $epochs = CalendarTimeUtil::getCalendarEventEpochs( | ||||
$this->getViewer()); | $this->getViewer()); | ||||
$start_epoch = $epochs['start_epoch']; | $start_epoch = $epochs['start_epoch']; | ||||
$end_epoch = $epochs['end_epoch']; | $end_epoch = $epochs['end_epoch']; | ||||
$statuses = id(new PhabricatorCalendarEventQuery()) | |||||
if ($participant_phids) { | |||||
$events = id(new PhabricatorCalendarEventQuery()) | |||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withInvitedPHIDs($participant_phids) | ->withInvitedPHIDs($participant_phids) | ||||
->withIsCancelled(false) | |||||
->withDateRange($start_epoch, $end_epoch) | ->withDateRange($start_epoch, $end_epoch) | ||||
->execute(); | ->execute(); | ||||
$events = mpull($events, null, 'getPHID'); | |||||
} else { | |||||
$events = null; | |||||
} | |||||
$statuses = mgroup($statuses, 'getUserPHID'); | $invitees = array(); | ||||
foreach ($events as $event_phid => $event) { | |||||
foreach ($event->getInvitees() as $invitee) { | |||||
$invitees[$invitee->getInviteePHID()][$event_phid] = true; | |||||
} | |||||
} | |||||
// attached files | // attached files | ||||
$files = array(); | $files = array(); | ||||
$file_author_phids = array(); | $file_author_phids = array(); | ||||
$authors = array(); | $authors = array(); | ||||
if ($file_phids) { | if ($file_phids) { | ||||
$files = id(new PhabricatorFileQuery()) | $files = id(new PhabricatorFileQuery()) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withPHIDs($file_phids) | ->withPHIDs($file_phids) | ||||
->execute(); | ->execute(); | ||||
$files = mpull($files, null, 'getPHID'); | $files = mpull($files, null, 'getPHID'); | ||||
$file_author_phids = mpull($files, 'getAuthorPHID', 'getPHID'); | $file_author_phids = mpull($files, 'getAuthorPHID', 'getPHID'); | ||||
$authors = id(new PhabricatorHandleQuery()) | $authors = id(new PhabricatorHandleQuery()) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withPHIDs($file_author_phids) | ->withPHIDs($file_author_phids) | ||||
->execute(); | ->execute(); | ||||
$authors = mpull($authors, null, 'getPHID'); | $authors = mpull($authors, null, 'getPHID'); | ||||
} | } | ||||
foreach ($conpherences as $phid => $conpherence) { | foreach ($conpherences as $phid => $conpherence) { | ||||
$participant_phids = array_keys($conpherence->getParticipants()); | $participant_phids = array_keys($conpherence->getParticipants()); | ||||
$statuses = array_select_keys($statuses, $participant_phids); | $widget_data = array(); | ||||
$statuses = array_mergev($statuses); | |||||
$statuses = msort($statuses, 'getDateFrom'); | $event_phids = array(); | ||||
$participant_invites = array_select_keys($invitees, $participant_phids); | |||||
foreach ($participant_invites as $invite_set) { | |||||
$event_phids += $invite_set; | |||||
} | |||||
$thread_events = array_select_keys($events, array_keys($event_phids)); | |||||
$thread_events = msort($thread_events, 'getDateFrom'); | |||||
$widget_data['events'] = $thread_events; | |||||
$conpherence_files = array(); | $conpherence_files = array(); | ||||
$files_authors = array(); | $files_authors = array(); | ||||
foreach ($conpherence->getFilePHIDs() as $curr_phid) { | foreach ($conpherence->getFilePHIDs() as $curr_phid) { | ||||
$curr_file = idx($files, $curr_phid); | $curr_file = idx($files, $curr_phid); | ||||
if (!$curr_file) { | if (!$curr_file) { | ||||
// this file was deleted or user doesn't have permission to see it | // this file was deleted or user doesn't have permission to see it | ||||
// this is generally weird | // this is generally weird | ||||
continue; | continue; | ||||
} | } | ||||
$conpherence_files[$curr_phid] = $curr_file; | $conpherence_files[$curr_phid] = $curr_file; | ||||
// some files don't have authors so be careful | // some files don't have authors so be careful | ||||
$current_author = null; | $current_author = null; | ||||
$current_author_phid = idx($file_author_phids, $curr_phid); | $current_author_phid = idx($file_author_phids, $curr_phid); | ||||
if ($current_author_phid) { | if ($current_author_phid) { | ||||
$current_author = $authors[$current_author_phid]; | $current_author = $authors[$current_author_phid]; | ||||
} | } | ||||
$files_authors[$curr_phid] = $current_author; | $files_authors[$curr_phid] = $current_author; | ||||
} | } | ||||
$widget_data = array( | $widget_data += array( | ||||
'statuses' => $statuses, | |||||
'files' => $conpherence_files, | 'files' => $conpherence_files, | ||||
'files_authors' => $files_authors, | 'files_authors' => $files_authors, | ||||
); | ); | ||||
$conpherence->attachWidgetData($widget_data); | $conpherence->attachWidgetData($widget_data); | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
private function loadOrigPics(array $conpherences) { | private function loadOrigPics(array $conpherences) { | ||||
return $this->loadPics( | return $this->loadPics( | ||||
▲ Show 20 Lines • Show All 47 Lines • Show Last 20 Lines |