@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 92 lines 2.3 kB view raw
1<?php 2 3final class PhrequentCurtainExtension 4 extends PHUICurtainExtension { 5 6 const EXTENSIONKEY = 'phrequent.time'; 7 8 public function shouldEnableForObject($object) { 9 return ($object instanceof PhrequentTrackableInterface); 10 } 11 12 public function getExtensionApplication() { 13 return new PhabricatorPhrequentApplication(); 14 } 15 16 public function buildCurtainPanel($object) { 17 $viewer = $this->getViewer(); 18 19 $events = id(new PhrequentUserTimeQuery()) 20 ->setViewer($viewer) 21 ->withObjectPHIDs(array($object->getPHID())) 22 ->needPreemptingEvents(true) 23 ->execute(); 24 $event_groups = mgroup($events, 'getUserPHID'); 25 26 if (!$events) { 27 return; 28 } 29 30 $handles = $viewer->loadHandles(array_keys($event_groups)); 31 $status_view = new PHUIStatusListView(); 32 $now = PhabricatorTime::getNow(); 33 34 foreach ($event_groups as $user_phid => $event_group) { 35 $item = new PHUIStatusItemView(); 36 $item->setTarget($handles[$user_phid]->renderLink()); 37 38 $state = 'stopped'; 39 foreach ($event_group as $event) { 40 if ($event->getDateEnded() === null) { 41 if ($event->isPreempted()) { 42 $state = 'suspended'; 43 } else { 44 $state = 'active'; 45 break; 46 } 47 } 48 } 49 50 switch ($state) { 51 case 'active': 52 $item->setIcon( 53 PHUIStatusItemView::ICON_CLOCK, 54 'green', 55 pht('Working Now')); 56 break; 57 case 'suspended': 58 $item->setIcon( 59 PHUIStatusItemView::ICON_CLOCK, 60 'yellow', 61 pht('Interrupted')); 62 break; 63 case 'stopped': 64 $item->setIcon( 65 PHUIStatusItemView::ICON_CLOCK, 66 'bluegrey', 67 pht('Not Working Now')); 68 break; 69 } 70 71 $block = new PhrequentTimeBlock($event_group); 72 73 $duration = $block->getTimeSpentOnObject( 74 $object->getPHID(), 75 $now); 76 77 $duration_display = phutil_format_relative_time_detailed( 78 $duration, 79 $levels = 3); 80 81 $item->setNote($duration_display); 82 83 $status_view->addItem($item); 84 } 85 86 return $this->newPanel() 87 ->setHeaderText(pht('Time Spent')) 88 ->setOrder(40000) 89 ->appendChild($status_view); 90 } 91 92}