private function buildCurtainView(PhortuneAccount $account, $invoices)
 {
     $viewer = $this->getViewer();
     $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $account, PhabricatorPolicyCapability::CAN_EDIT);
     $edit_uri = $this->getApplicationURI('account/edit/' . $account->getID() . '/');
     $curtain = $this->newCurtainView($account);
     $curtain->addAction(id(new PhabricatorActionView())->setName(pht('Edit Account'))->setIcon('fa-pencil')->setHref($edit_uri)->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $status_items = $this->getStatusItemsForAccount($account, $invoices);
     $status_view = new PHUIStatusListView();
     foreach ($status_items as $item) {
         $status_view->addItem(id(new PHUIStatusItemView())->setIcon(idx($item, 'icon'), idx($item, 'color'), idx($item, 'label'))->setTarget(idx($item, 'target'))->setNote(idx($item, 'note')));
     }
     $member_phids = $account->getMemberPHIDs();
     $handles = $viewer->loadHandles($member_phids);
     $member_list = id(new PHUIObjectItemListView())->setSimple(true);
     foreach ($member_phids as $member_phid) {
         $image_uri = $handles[$member_phid]->getImageURI();
         $image_href = $handles[$member_phid]->getURI();
         $person = $handles[$member_phid];
         $member = id(new PHUIObjectItemView())->setImageURI($image_uri)->setHref($image_href)->setHeader($person->getFullName());
         $member_list->addItem($member);
     }
     $curtain->newPanel()->setHeaderText(pht('Status'))->appendChild($status_view);
     $curtain->newPanel()->setHeaderText(pht('Members'))->appendChild($member_list);
     return $curtain;
 }
 public function render()
 {
     $viewer = $this->getUser();
     $blueprint_phids = $this->getBlueprintPHIDs();
     $object_phid = $this->getObjectPHID();
     // NOTE: We're intentionally letting you see the authorization state on
     // blueprints you can't see because this has a tremendous potential to
     // be extremely confusing otherwise. You still can't see the blueprints
     // themselves, but you can know if the object is authorized on something.
     if ($blueprint_phids) {
         $handles = $viewer->loadHandles($blueprint_phids);
         $authorizations = id(new DrydockAuthorizationQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withObjectPHIDs(array($object_phid))->withBlueprintPHIDs($blueprint_phids)->execute();
         $authorizations = mpull($authorizations, null, 'getBlueprintPHID');
     } else {
         $handles = array();
         $authorizations = array();
     }
     $items = array();
     foreach ($blueprint_phids as $phid) {
         $authorization = idx($authorizations, $phid);
         if (!$authorization) {
             continue;
         }
         $handle = $handles[$phid];
         $item = id(new PHUIStatusItemView())->setTarget($handle->renderLink());
         $state = $authorization->getBlueprintAuthorizationState();
         $item->setIcon(DrydockAuthorization::getBlueprintStateIcon($state), null, DrydockAuthorization::getBlueprintStateName($state));
         $items[] = $item;
     }
     $status = new PHUIStatusListView();
     foreach ($items as $item) {
         $status->addItem($item);
     }
     return $status;
 }
 public function renderPropertyViewValue(array $handles)
 {
     if (!$handles) {
         return null;
     }
     $author_phid = $this->getObject()->getAuthorPHID();
     $viewer_phid = $this->getViewer()->getPHID();
     $viewer_is_author = $author_phid == $viewer_phid;
     $view = new PHUIStatusListView();
     foreach ($handles as $handle) {
         $item = id(new PHUIStatusItemView())->setTarget($handle->renderLink());
         // NOTE: If the viewer isn't the author, we just show generic document
         // icons, because the granular information isn't very useful and there
         // is no need to disclose it.
         // If the viewer is the author, we show exactly what they need to sign.
         if (!$viewer_is_author) {
             $item->setIcon('fa-file-text-o bluegrey');
         } else {
             if (idx($this->getValue(), $handle->getPHID())) {
                 $item->setIcon('fa-check-square-o green');
             } else {
                 $item->setIcon('fa-times red');
             }
         }
         $view->addItem($item);
     }
     return $view;
 }
 private function handlePropertyEvent($ui_event)
 {
     $user = $ui_event->getUser();
     $object = $ui_event->getValue('object');
     if (!$object || !$object->getPHID()) {
         // No object, or the object has no PHID yet..
         return;
     }
     if ($object instanceof HarbormasterBuildable) {
         // Although HarbormasterBuildable implements the correct interface, it
         // does not make sense to show a build's build status. In the best case
         // it is meaningless, and in the worst case it's confusing.
         return;
     }
     if ($object instanceof DifferentialRevision) {
         // TODO: This is a bit hacky and we could probably find a cleaner fix
         // eventually, but we show build status on each diff, immediately below
         // this property list, so it's redundant to show it on the revision view.
         return;
     }
     if (!$object instanceof HarbormasterBuildableInterface) {
         return;
     }
     $buildable_phid = $object->getHarbormasterBuildablePHID();
     if (!$buildable_phid) {
         return;
     }
     if (!$this->canUseApplication($ui_event->getUser())) {
         return;
     }
     $buildable = id(new HarbormasterBuildableQuery())->setViewer($user)->withManualBuildables(false)->withBuildablePHIDs(array($buildable_phid))->needBuilds(true)->executeOne();
     if (!$buildable) {
         return;
     }
     $builds = $buildable->getBuilds();
     $build_handles = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(mpull($builds, 'getPHID'))->execute();
     $status_view = new PHUIStatusListView();
     $buildable_status = $buildable->getBuildableStatus();
     $buildable_icon = HarbormasterBuildable::getBuildableStatusIcon($buildable_status);
     $buildable_color = HarbormasterBuildable::getBuildableStatusColor($buildable_status);
     $buildable_name = HarbormasterBuildable::getBuildableStatusName($buildable_status);
     $target = phutil_tag('a', array('href' => '/' . $buildable->getMonogram()), pht('Buildable %d', $buildable->getID()));
     $target = phutil_tag('strong', array(), $target);
     $status_view->addItem(id(new PHUIStatusItemView())->setIcon($buildable_icon, $buildable_color, $buildable_name)->setTarget($target));
     foreach ($builds as $build) {
         $item = new PHUIStatusItemView();
         $item->setTarget($build_handles[$build->getPHID()]->renderLink());
         $status = $build->getBuildStatus();
         $status_name = HarbormasterBuild::getBuildStatusName($status);
         $icon = HarbormasterBuild::getBuildStatusIcon($status);
         $color = HarbormasterBuild::getBuildStatusColor($status);
         $item->setIcon($icon, $color, $status_name);
         $status_view->addItem($item);
     }
     $view = $ui_event->getValue('view');
     $view->addProperty(pht('Build Status'), $status_view);
 }
 public function render()
 {
     $viewer = $this->getUser();
     $view = new PHUIStatusListView();
     foreach ($this->reviewers as $reviewer) {
         $phid = $reviewer->getReviewerPHID();
         $handle = $this->handles[$phid];
         // If we're missing either the diff or action information for the
         // reviewer, render information as current.
         $is_current = !$this->diff || !$reviewer->getDiffID() || $this->diff->getID() == $reviewer->getDiffID();
         $item = new PHUIStatusItemView();
         $item->setHighlighted($reviewer->hasAuthority($viewer));
         switch ($reviewer->getStatus()) {
             case DifferentialReviewerStatus::STATUS_ADDED:
                 $item->setIcon(PHUIStatusItemView::ICON_OPEN, 'bluegrey', pht('Review Requested'));
                 break;
             case DifferentialReviewerStatus::STATUS_ACCEPTED:
                 if ($is_current) {
                     $item->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green', pht('Accepted'));
                 } else {
                     $item->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'dark', pht('Accepted Prior Diff'));
                 }
                 break;
             case DifferentialReviewerStatus::STATUS_ACCEPTED_OLDER:
                 $item->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'dark', pht('Accepted Prior Diff'));
                 break;
             case DifferentialReviewerStatus::STATUS_REJECTED:
                 if ($is_current) {
                     $item->setIcon(PHUIStatusItemView::ICON_REJECT, 'red', pht('Requested Changes'));
                 } else {
                     $item->setIcon(PHUIStatusItemView::ICON_REJECT, 'dark', pht('Requested Changes to Prior Diff'));
                 }
                 break;
             case DifferentialReviewerStatus::STATUS_REJECTED_OLDER:
                 $item->setIcon(PHUIStatusItemView::ICON_REJECT, 'dark', pht('Rejected Prior Diff'));
                 break;
             case DifferentialReviewerStatus::STATUS_COMMENTED:
                 if ($is_current) {
                     $item->setIcon(PHUIStatusItemView::ICON_INFO, 'blue', pht('Commented'));
                 } else {
                     $item->setIcon('info-dark', pht('Commented Previously'));
                 }
                 break;
             case DifferentialReviewerStatus::STATUS_BLOCKING:
                 $item->setIcon(PHUIStatusItemView::ICON_MINUS, 'red', pht('Blocking Review'));
                 break;
             default:
                 $item->setIcon(PHUIStatusItemView::ICON_QUESTION, 'bluegrey', pht('%s?', $reviewer->getStatus()));
                 break;
         }
         $item->setTarget($handle->renderHovercardLink());
         $view->addItem($item);
     }
     return $view;
 }
 private function handlePropertyEvent($ui_event)
 {
     $user = $ui_event->getUser();
     $object = $ui_event->getValue('object');
     if (!$object || !$object->getPHID()) {
         // No object, or the object has no PHID yet..
         return;
     }
     if ($object instanceof HarbormasterBuildable) {
         // Although HarbormasterBuildable implements the correct interface, it
         // does not make sense to show a build's build status. In the best case
         // it is meaningless, and in the worst case it's confusing.
         return;
     }
     if (!$object instanceof HarbormasterBuildableInterface) {
         return;
     }
     $buildable_phid = $object->getHarbormasterBuildablePHID();
     if (!$buildable_phid) {
         return;
     }
     if (!$this->canUseApplication($ui_event->getUser())) {
         return;
     }
     $buildables = id(new HarbormasterBuildableQuery())->setViewer($user)->withManualBuildables(false)->withBuildablePHIDs(array($buildable_phid))->execute();
     if (!$buildables) {
         return;
     }
     $builds = id(new HarbormasterBuildQuery())->setViewer($user)->withBuildablePHIDs(mpull($buildables, 'getPHID'))->execute();
     if (!$builds) {
         return;
     }
     $build_handles = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(mpull($builds, 'getPHID'))->execute();
     $status_view = new PHUIStatusListView();
     foreach ($builds as $build) {
         $item = new PHUIStatusItemView();
         $item->setTarget($build_handles[$build->getPHID()]->renderLink());
         $status = $build->getBuildStatus();
         $status_name = HarbormasterBuild::getBuildStatusName($status);
         $icon = HarbormasterBuild::getBuildStatusIcon($status);
         $color = HarbormasterBuild::getBuildStatusColor($status);
         $item->setIcon($icon, $color, $status_name);
         $status_view->addItem($item);
     }
     $view = $ui_event->getValue('view');
     $view->addProperty(pht('Build Status'), $status_view);
 }
 public function render()
 {
     $viewer = $this->getUser();
     $blueprint_phids = $this->getBlueprintPHIDs();
     $object_phid = $this->getObjectPHID();
     // NOTE: We're intentionally letting you see the authorization state on
     // blueprints you can't see because this has a tremendous potential to
     // be extremely confusing otherwise. You still can't see the blueprints
     // themselves, but you can know if the object is authorized on something.
     if ($blueprint_phids) {
         $handles = $viewer->loadHandles($blueprint_phids);
         $authorizations = id(new DrydockAuthorizationQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withObjectPHIDs(array($object_phid))->withBlueprintPHIDs($blueprint_phids)->execute();
         $authorizations = mpull($authorizations, null, 'getBlueprintPHID');
     } else {
         $handles = array();
         $authorizations = array();
     }
     $warnings = array();
     $items = array();
     foreach ($blueprint_phids as $phid) {
         $authorization = idx($authorizations, $phid);
         if (!$authorization) {
             continue;
         }
         $handle = $handles[$phid];
         $item = id(new PHUIStatusItemView())->setTarget($handle->renderLink());
         $state = $authorization->getBlueprintAuthorizationState();
         $item->setIcon(DrydockAuthorization::getBlueprintStateIcon($state), null, DrydockAuthorization::getBlueprintStateName($state));
         switch ($state) {
             case DrydockAuthorization::BLUEPRINTAUTH_REQUESTED:
             case DrydockAuthorization::BLUEPRINTAUTH_DECLINED:
                 $warnings[] = $authorization;
                 break;
         }
         $items[] = $item;
     }
     $status = new PHUIStatusListView();
     if ($warnings) {
         $status->addItem(id(new PHUIStatusItemView())->setIcon('fa-exclamation-triangle', 'pink')->setTarget(pht('WARNING: There are %s unapproved authorization(s)!', new PhutilNumber(count($warnings)))));
     }
     foreach ($items as $item) {
         $status->addItem($item);
     }
     return $status;
 }
 private function buildDetailsView(PhortuneMerchant $merchant, array $providers)
 {
     $viewer = $this->getRequest()->getUser();
     $view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($merchant);
     $status_view = new PHUIStatusListView();
     $have_any = false;
     $any_test = false;
     foreach ($providers as $provider_config) {
         $provider = $provider_config->buildProvider();
         if ($provider->isEnabled()) {
             $have_any = true;
         }
         if (!$provider->isAcceptingLivePayments()) {
             $any_test = true;
         }
     }
     if ($have_any) {
         $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Accepts Payments'))->setNote(pht('This merchant can accept payments.')));
         if ($any_test) {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow')->setTarget(pht('Test Mode'))->setNote(pht('This merchant is accepting test payments.')));
         } else {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Live Mode'))->setNote(pht('This merchant is accepting live payments.')));
         }
     } else {
         if ($providers) {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_REJECT, 'red')->setTarget(pht('No Enabled Providers'))->setNote(pht('All of the payment providers for this merchant are ' . 'disabled.')));
         } else {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow')->setTarget(pht('No Providers'))->setNote(pht('This merchant does not have any payment providers configured ' . 'yet, so it can not accept payments. Add a provider.')));
         }
     }
     $view->addProperty(pht('Status'), $status_view);
     return id(new PHUIObjectBoxView())->setHeaderText(pht('Details'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($view);
 }
 public function renderExample()
 {
     $out = array();
     $view = new PHUIStatusListView();
     $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green', pht('Yum'))->setTarget(pht('Apple'))->setNote(pht('You can eat them.')));
     $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ADD, 'blue', pht('Has Peel'))->setTarget(pht('Banana'))->setNote(pht('Comes in bunches.'))->setHighlighted(true));
     $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'dark', pht('Caution'))->setTarget(pht('Pomegranite'))->setNote(pht('Lots of seeds. Watch out.')));
     $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_REJECT, 'red', pht('Bleh!'))->setTarget(pht('Zucchini'))->setNote(pht('Slimy and gross. Yuck!')));
     $out[] = id(new PHUIHeaderView())->setHeader(pht('Fruit and Vegetable Status'));
     $out[] = id(new PHUIBoxView())->addMargin(PHUI::MARGIN_LARGE)->addPadding(PHUI::PADDING_LARGE)->setBorder(true)->appendChild($view);
     $view = new PHUIStatusListView();
     $manifest = array(PHUIStatusItemView::ICON_ACCEPT => 'PHUIStatusItemView::ICON_ACCEPT', PHUIStatusItemView::ICON_REJECT => 'PHUIStatusItemView::ICON_REJECT', PHUIStatusItemView::ICON_LEFT => 'PHUIStatusItemView::ICON_LEFT', PHUIStatusItemView::ICON_RIGHT => 'PHUIStatusItemView::ICON_RIGHT', PHUIStatusItemView::ICON_UP => 'PHUIStatusItemView::ICON_UP', PHUIStatusItemView::ICON_DOWN => 'PHUIStatusItemView::ICON_DOWN', PHUIStatusItemView::ICON_QUESTION => 'PHUIStatusItemView::ICON_QUESTION', PHUIStatusItemView::ICON_WARNING => 'PHUIStatusItemView::ICON_WARNING', PHUIStatusItemView::ICON_INFO => 'PHUIStatusItemView::ICON_INFO', PHUIStatusItemView::ICON_ADD => 'PHUIStatusItemView::ICON_ADD', PHUIStatusItemView::ICON_MINUS => 'PHUIStatusItemView::ICON_MINUS', PHUIStatusItemView::ICON_OPEN => 'PHUIStatusItemView::ICON_OPEN', PHUIStatusItemView::ICON_CLOCK => 'PHUIStatusItemView::ICON_CLOCK');
     foreach ($manifest as $icon => $label) {
         $view->addItem(id(new PHUIStatusItemView())->setIcon($icon, 'indigo')->setTarget($label));
     }
     $out[] = id(new PHUIHeaderView())->setHeader(pht('All Icons'));
     $out[] = id(new PHUIBoxView())->addMargin(PHUI::MARGIN_LARGE)->addPadding(PHUI::PADDING_LARGE)->setBorder(true)->appendChild($view);
     return $out;
 }
 private function buildDetailsView(PhortuneMerchant $merchant, array $providers)
 {
     $viewer = $this->getRequest()->getUser();
     $view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($merchant);
     $status_view = new PHUIStatusListView();
     $have_any = false;
     $any_test = false;
     foreach ($providers as $provider_config) {
         $provider = $provider_config->buildProvider();
         if ($provider->isEnabled()) {
             $have_any = true;
         }
         if (!$provider->isAcceptingLivePayments()) {
             $any_test = true;
         }
     }
     if ($have_any) {
         $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Accepts Payments'))->setNote(pht('This merchant can accept payments.')));
         if ($any_test) {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow')->setTarget(pht('Test Mode'))->setNote(pht('This merchant is accepting test payments.')));
         } else {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Live Mode'))->setNote(pht('This merchant is accepting live payments.')));
         }
     } else {
         if ($providers) {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_REJECT, 'red')->setTarget(pht('No Enabled Providers'))->setNote(pht('All of the payment providers for this merchant are ' . 'disabled.')));
         } else {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow')->setTarget(pht('No Providers'))->setNote(pht('This merchant does not have any payment providers configured ' . 'yet, so it can not accept payments. Add a provider.')));
         }
     }
     $view->addProperty(pht('Status'), $status_view);
     $invoice_from = $merchant->getInvoiceEmail();
     if (!$invoice_from) {
         $invoice_from = pht('No email address set');
         $invoice_from = phutil_tag('em', array(), $invoice_from);
     }
     $view->addProperty(pht('Invoice From'), $invoice_from);
     $description = $merchant->getDescription();
     if (strlen($description)) {
         $description = new PHUIRemarkupView($viewer, $description);
         $view->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $view->addTextContent($description);
     }
     $contact_info = $merchant->getContactInfo();
     if (strlen($contact_info)) {
         $contact_info = new PHUIRemarkupView($viewer, $contact_info);
         $view->addSectionHeader(pht('Contact Info'), PHUIPropertyListView::ICON_SUMMARY);
         $view->addTextContent($contact_info);
     }
     $footer_info = $merchant->getInvoiceFooter();
     if (strlen($footer_info)) {
         $footer_info = new PHUIRemarkupView($viewer, $footer_info);
         $view->addSectionHeader(pht('Invoice Footer'), PHUIPropertyListView::ICON_SUMMARY);
         $view->addTextContent($footer_info);
     }
     return id(new PHUIObjectBoxView())->setHeaderText(pht('Details'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->appendChild($view);
 }
 private function handlePropertyEvent($ui_event)
 {
     $user = $ui_event->getUser();
     $object = $ui_event->getValue('object');
     if (!$object || !$object->getPHID()) {
         // No object, or the object has no PHID yet..
         return;
     }
     if (!$object instanceof PhrequentTrackableInterface) {
         // This object isn't a time trackable object.
         return;
     }
     if (!$this->canUseApplication($ui_event->getUser())) {
         return;
     }
     $events = id(new PhrequentUserTimeQuery())->setViewer($user)->withObjectPHIDs(array($object->getPHID()))->needPreemptingEvents(true)->execute();
     $event_groups = mgroup($events, 'getUserPHID');
     if (!$events) {
         return;
     }
     $handles = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array_keys($event_groups))->execute();
     $status_view = new PHUIStatusListView();
     foreach ($event_groups as $user_phid => $event_group) {
         $item = new PHUIStatusItemView();
         $item->setTarget($handles[$user_phid]->renderLink());
         $state = 'stopped';
         foreach ($event_group as $event) {
             if ($event->getDateEnded() === null) {
                 if ($event->isPreempted()) {
                     $state = 'suspended';
                 } else {
                     $state = 'active';
                     break;
                 }
             }
         }
         switch ($state) {
             case 'active':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'green', pht('Working Now'));
                 break;
             case 'suspended':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'yellow', pht('Interrupted'));
                 break;
             case 'stopped':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'bluegrey', pht('Not Working Now'));
                 break;
         }
         $block = new PhrequentTimeBlock($event_group);
         $item->setNote(phutil_format_relative_time($block->getTimeSpentOnObject($object->getPHID(), time())));
         $status_view->addItem($item);
     }
     $view = $ui_event->getValue('view');
     $view->addProperty(pht('Time Spent'), $status_view);
 }
 public function buildCurtainPanel($object)
 {
     $viewer = $this->getViewer();
     $events = id(new PhrequentUserTimeQuery())->setViewer($viewer)->withObjectPHIDs(array($object->getPHID()))->needPreemptingEvents(true)->execute();
     $event_groups = mgroup($events, 'getUserPHID');
     if (!$events) {
         return;
     }
     $handles = $viewer->loadHandles(array_keys($event_groups));
     $status_view = new PHUIStatusListView();
     foreach ($event_groups as $user_phid => $event_group) {
         $item = new PHUIStatusItemView();
         $item->setTarget($handles[$user_phid]->renderLink());
         $state = 'stopped';
         foreach ($event_group as $event) {
             if ($event->getDateEnded() === null) {
                 if ($event->isPreempted()) {
                     $state = 'suspended';
                 } else {
                     $state = 'active';
                     break;
                 }
             }
         }
         switch ($state) {
             case 'active':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'green', pht('Working Now'));
                 break;
             case 'suspended':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'yellow', pht('Interrupted'));
                 break;
             case 'stopped':
                 $item->setIcon(PHUIStatusItemView::ICON_CLOCK, 'bluegrey', pht('Not Working Now'));
                 break;
         }
         $block = new PhrequentTimeBlock($event_group);
         $item->setNote(phutil_format_relative_time($block->getTimeSpentOnObject($object->getPHID(), time())));
         $status_view->addItem($item);
     }
     return $this->newPanel()->setHeaderText(pht('Time Spent'))->setOrder(40000)->appendChild($status_view);
 }
 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     // TODO: Currently, you must be able to edit an account to view the detail
     // page, because the account must be broadly visible so merchants can
     // process orders but merchants should not be able to see all the details
     // of an account. Ideally this page should be visible to merchants, too,
     // just with less information.
     $can_edit = true;
     $account = id(new PhortuneAccountQuery())->setViewer($viewer)->withIDs(array($request->getURIData('accountID')))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$account) {
         return new Aphront404Response();
     }
     $title = $account->getName();
     $invoices = id(new PhortuneCartQuery())->setViewer($viewer)->withAccountPHIDs(array($account->getPHID()))->needPurchases(true)->withInvoices(true)->execute();
     $crumbs = $this->buildApplicationCrumbs();
     $this->addAccountCrumb($crumbs, $account, $link = false);
     $header = id(new PHUIHeaderView())->setHeader($title);
     $edit_uri = $this->getApplicationURI('account/edit/' . $account->getID() . '/');
     $actions = id(new PhabricatorActionListView())->setUser($viewer)->addAction(id(new PhabricatorActionView())->setName(pht('Edit Account'))->setIcon('fa-pencil')->setHref($edit_uri)->setDisabled(!$can_edit)->setWorkflow(!$can_edit));
     $properties = id(new PHUIPropertyListView())->setObject($account)->setUser($viewer);
     $properties->addProperty(pht('Members'), $viewer->renderHandleList($account->getMemberPHIDs()));
     $status_items = $this->getStatusItemsForAccount($account, $invoices);
     $status_view = new PHUIStatusListView();
     foreach ($status_items as $item) {
         $status_view->addItem(id(new PHUIStatusItemView())->setIcon(idx($item, 'icon'), idx($item, 'color'), idx($item, 'label'))->setTarget(idx($item, 'target'))->setNote(idx($item, 'note')));
     }
     $properties->addProperty(pht('Status'), $status_view);
     $properties->setActionList($actions);
     $invoices = $this->buildInvoicesSection($account, $invoices);
     $purchase_history = $this->buildPurchaseHistorySection($account);
     $charge_history = $this->buildChargeHistorySection($account);
     $subscriptions = $this->buildSubscriptionsSection($account);
     $payment_methods = $this->buildPaymentMethodsSection($account);
     $timeline = $this->buildTransactionTimeline($account, new PhortuneAccountTransactionQuery());
     $timeline->setShouldTerminate(true);
     $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties);
     return $this->buildApplicationPage(array($crumbs, $object_box, $invoices, $purchase_history, $charge_history, $subscriptions, $payment_methods, $timeline), array('title' => $title));
 }
 private function buildPropertyListView(PhortuneMerchant $merchant, array $providers)
 {
     $viewer = $this->getRequest()->getUser();
     $view = id(new PHUIPropertyListView())->setUser($viewer)->setObject($merchant);
     $status_view = new PHUIStatusListView();
     $have_any = false;
     $any_test = false;
     foreach ($providers as $provider_config) {
         $provider = $provider_config->buildProvider();
         if ($provider->isEnabled()) {
             $have_any = true;
         }
         if (!$provider->isAcceptingLivePayments()) {
             $any_test = true;
         }
     }
     if ($have_any) {
         $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Accepts Payments'))->setNote(pht('This merchant can accept payments.')));
         if ($any_test) {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow')->setTarget(pht('Test Mode'))->setNote(pht('This merchant is accepting test payments.')));
         } else {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Live Mode'))->setNote(pht('This merchant is accepting live payments.')));
         }
     } else {
         if ($providers) {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_REJECT, 'red')->setTarget(pht('No Enabled Providers'))->setNote(pht('All of the payment providers for this merchant are ' . 'disabled.')));
         } else {
             $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'yellow')->setTarget(pht('No Providers'))->setNote(pht('This merchant does not have any payment providers configured ' . 'yet, so it can not accept payments. Add a provider.')));
         }
     }
     $view->addProperty(pht('Status'), $status_view);
     $view->addProperty(pht('Members'), $viewer->renderHandleList($merchant->getMemberPHIDs()));
     $view->invokeWillRenderEvent();
     $description = $merchant->getDescription();
     if (strlen($description)) {
         $description = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($description), 'default', $viewer);
         $view->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $view->addTextContent($description);
     }
     return $view;
 }
 private function buildRepositoryStatus(PhabricatorRepository $repository)
 {
     $viewer = $this->getRequest()->getUser();
     $is_cluster = $repository->getAlmanacServicePHID();
     $view = new PHUIStatusListView();
     $messages = id(new PhabricatorRepositoryStatusMessage())->loadAllWhere('repositoryID = %d', $repository->getID());
     $messages = mpull($messages, null, 'getStatusType');
     if ($repository->isTracked()) {
         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Repository Active')));
     } else {
         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'bluegrey')->setTarget(pht('Repository Inactive'))->setNote(pht('Activate this repository to begin or resume import.')));
         return $view;
     }
     $binaries = array();
     $svnlook_check = false;
     switch ($repository->getVersionControlSystem()) {
         case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
             $binaries[] = 'git';
             break;
         case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
             $binaries[] = 'svn';
             break;
         case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
             $binaries[] = 'hg';
             break;
     }
     if ($repository->isHosted()) {
         if ($repository->getServeOverHTTP() != PhabricatorRepository::SERVE_OFF) {
             switch ($repository->getVersionControlSystem()) {
                 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
                     $binaries[] = 'git-http-backend';
                     break;
                 case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
                     $binaries[] = 'svnserve';
                     $binaries[] = 'svnadmin';
                     $binaries[] = 'svnlook';
                     $svnlook_check = true;
                     break;
                 case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
                     $binaries[] = 'hg';
                     break;
             }
         }
         if ($repository->getServeOverSSH() != PhabricatorRepository::SERVE_OFF) {
             switch ($repository->getVersionControlSystem()) {
                 case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
                     $binaries[] = 'git-receive-pack';
                     $binaries[] = 'git-upload-pack';
                     break;
                 case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
                     $binaries[] = 'svnserve';
                     $binaries[] = 'svnadmin';
                     $binaries[] = 'svnlook';
                     $svnlook_check = true;
                     break;
                 case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
                     $binaries[] = 'hg';
                     break;
             }
         }
     }
     $binaries = array_unique($binaries);
     if (!$is_cluster) {
         // We're only checking for binaries if we aren't running with a cluster
         // configuration. In theory, we could check for binaries on the
         // repository host machine, but we'd need to make this more complicated
         // to do that.
         foreach ($binaries as $binary) {
             $where = Filesystem::resolveBinary($binary);
             if (!$where) {
                 $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')->setTarget(pht('Missing Binary %s', phutil_tag('tt', array(), $binary)))->setNote(pht("Unable to find this binary in the webserver's PATH. You may " . "need to configure %s.", $this->getEnvConfigLink())));
             } else {
                 $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Found Binary %s', phutil_tag('tt', array(), $binary)))->setNote(phutil_tag('tt', array(), $where)));
             }
         }
         // This gets checked generically above. However, for svn commit hooks, we
         // need this to be in environment.append-paths because subversion strips
         // PATH.
         if ($svnlook_check) {
             $where = Filesystem::resolveBinary('svnlook');
             if ($where) {
                 $path = substr($where, 0, strlen($where) - strlen('svnlook'));
                 $dirs = PhabricatorEnv::getEnvConfig('environment.append-paths');
                 $in_path = false;
                 foreach ($dirs as $dir) {
                     if (Filesystem::isDescendant($path, $dir)) {
                         $in_path = true;
                         break;
                     }
                 }
                 if (!$in_path) {
                     $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')->setTarget(pht('Missing Binary %s', phutil_tag('tt', array(), $binary)))->setNote(pht('Unable to find this binary in `%s`. ' . 'You need to configure %s and include %s.', 'environment.append-paths', $this->getEnvConfigLink(), $path)));
                 }
             }
         }
     }
     $doc_href = PhabricatorEnv::getDocLink('Managing Daemons with phd');
     $daemon_instructions = pht('Use %s to start daemons. See %s.', phutil_tag('tt', array(), 'bin/phd start'), phutil_tag('a', array('href' => $doc_href), pht('Managing Daemons with phd')));
     $pull_daemon = id(new PhabricatorDaemonLogQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)->withDaemonClasses(array('PhabricatorRepositoryPullLocalDaemon'))->setLimit(1)->execute();
     if ($pull_daemon) {
         // TODO: In a cluster environment, we need a daemon on this repository's
         // host, specifically, and we aren't checking for that right now. This
         // is a reasonable proxy for things being more-or-less correctly set up,
         // though.
         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Pull Daemon Running')));
     } else {
         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')->setTarget(pht('Pull Daemon Not Running'))->setNote($daemon_instructions));
     }
     $task_daemon = id(new PhabricatorDaemonLogQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)->withDaemonClasses(array('PhabricatorTaskmasterDaemon'))->setLimit(1)->execute();
     if ($task_daemon) {
         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Task Daemon Running')));
     } else {
         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')->setTarget(pht('Task Daemon Not Running'))->setNote($daemon_instructions));
     }
     if ($is_cluster) {
         // Just omit this status check for now in cluster environments. We
         // could make a service call and pull it from the repository host
         // eventually.
     } else {
         if ($repository->usesLocalWorkingCopy()) {
             $local_parent = dirname($repository->getLocalPath());
             if (Filesystem::pathExists($local_parent)) {
                 $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Storage Directory OK'))->setNote(phutil_tag('tt', array(), $local_parent)));
             } else {
                 $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')->setTarget(pht('No Storage Directory'))->setNote(pht('Storage directory %s does not exist, or is not readable by ' . 'the webserver. Create this directory or make it readable.', phutil_tag('tt', array(), $local_parent))));
                 return $view;
             }
             $local_path = $repository->getLocalPath();
             $message = idx($messages, PhabricatorRepositoryStatusMessage::TYPE_INIT);
             if ($message) {
                 switch ($message->getStatusCode()) {
                     case PhabricatorRepositoryStatusMessage::CODE_ERROR:
                         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')->setTarget(pht('Initialization Error'))->setNote($message->getParameter('message')));
                         return $view;
                     case PhabricatorRepositoryStatusMessage::CODE_OKAY:
                         if (Filesystem::pathExists($local_path)) {
                             $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Working Copy OK'))->setNote(phutil_tag('tt', array(), $local_path)));
                         } else {
                             $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')->setTarget(pht('Working Copy Error'))->setNote(pht('Working copy %s has been deleted, or is not ' . 'readable by the webserver. Make this directory ' . 'readable. If it has been deleted, the daemons should ' . 'restore it automatically.', phutil_tag('tt', array(), $local_path))));
                             return $view;
                         }
                         break;
                     case PhabricatorRepositoryStatusMessage::CODE_WORKING:
                         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_CLOCK, 'green')->setTarget(pht('Initializing Working Copy'))->setNote(pht('Daemons are initializing the working copy.')));
                         return $view;
                     default:
                         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')->setTarget(pht('Unknown Init Status'))->setNote($message->getStatusCode()));
                         return $view;
                 }
             } else {
                 $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_CLOCK, 'orange')->setTarget(pht('No Working Copy Yet'))->setNote(pht('Waiting for daemons to build a working copy.')));
                 return $view;
             }
         }
     }
     $message = idx($messages, PhabricatorRepositoryStatusMessage::TYPE_FETCH);
     if ($message) {
         switch ($message->getStatusCode()) {
             case PhabricatorRepositoryStatusMessage::CODE_ERROR:
                 $message = $message->getParameter('message');
                 $suggestion = null;
                 if (preg_match('/Permission denied \\(publickey\\)./', $message)) {
                     $suggestion = pht('Public Key Error: This error usually indicates that the ' . 'keypair you have configured does not have permission to ' . 'access the repository.');
                 }
                 $message = phutil_escape_html_newlines($message);
                 if ($suggestion !== null) {
                     $message = array(phutil_tag('strong', array(), $suggestion), phutil_tag('br'), phutil_tag('br'), phutil_tag('em', array(), pht('Raw Error')), phutil_tag('br'), $message);
                 }
                 $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_WARNING, 'red')->setTarget(pht('Update Error'))->setNote($message));
                 return $view;
             case PhabricatorRepositoryStatusMessage::CODE_OKAY:
                 $ago = PhabricatorTime::getNow() - $message->getEpoch();
                 $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Updates OK'))->setNote(pht('Last updated %s (%s ago).', phabricator_datetime($message->getEpoch(), $viewer), phutil_format_relative_time_detailed($ago))));
                 break;
         }
     } else {
         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_CLOCK, 'orange')->setTarget(pht('Waiting For Update'))->setNote(pht('Waiting for daemons to read updates.')));
     }
     if ($repository->isImporting()) {
         $progress = queryfx_all($repository->establishConnection('r'), 'SELECT importStatus, count(*) N FROM %T WHERE repositoryID = %d
       GROUP BY importStatus', id(new PhabricatorRepositoryCommit())->getTableName(), $repository->getID());
         $done = 0;
         $total = 0;
         foreach ($progress as $row) {
             $total += $row['N'] * 4;
             $status = $row['importStatus'];
             if ($status & PhabricatorRepositoryCommit::IMPORTED_MESSAGE) {
                 $done += $row['N'];
             }
             if ($status & PhabricatorRepositoryCommit::IMPORTED_CHANGE) {
                 $done += $row['N'];
             }
             if ($status & PhabricatorRepositoryCommit::IMPORTED_OWNERS) {
                 $done += $row['N'];
             }
             if ($status & PhabricatorRepositoryCommit::IMPORTED_HERALD) {
                 $done += $row['N'];
             }
         }
         if ($total) {
             $percentage = 100 * ($done / $total);
         } else {
             $percentage = 0;
         }
         // Cap this at "99.99%", because it's confusing to users when the actual
         // fraction is "99.996%" and it rounds up to "100.00%".
         if ($percentage > 99.98999999999999) {
             $percentage = 99.98999999999999;
         }
         $percentage = sprintf('%.2f%%', $percentage);
         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_CLOCK, 'green')->setTarget(pht('Importing'))->setNote(pht('%s Complete', $percentage)));
     } else {
         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('Fully Imported')));
     }
     if (idx($messages, PhabricatorRepositoryStatusMessage::TYPE_NEEDS_UPDATE)) {
         $view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_UP, 'indigo')->setTarget(pht('Prioritized'))->setNote(pht('This repository will be updated soon!')));
     }
     return $view;
 }
 private function renderAuditStatusView(array $audit_requests)
 {
     assert_instances_of($audit_requests, 'PhabricatorRepositoryAuditRequest');
     $viewer = $this->getViewer();
     $authority_map = array_fill_keys($this->auditAuthorityPHIDs, true);
     $view = new PHUIStatusListView();
     foreach ($audit_requests as $request) {
         $code = $request->getAuditStatus();
         $item = new PHUIStatusItemView();
         $item->setIcon(PhabricatorAuditStatusConstants::getStatusIcon($code), PhabricatorAuditStatusConstants::getStatusColor($code), PhabricatorAuditStatusConstants::getStatusName($code));
         $note = array();
         foreach ($request->getAuditReasons() as $reason) {
             $note[] = phutil_tag('div', array(), $reason);
         }
         $item->setNote($note);
         $auditor_phid = $request->getAuditorPHID();
         $target = $viewer->renderHandle($auditor_phid);
         $item->setTarget($target);
         if (isset($authority_map[$auditor_phid])) {
             $item->setHighlighted(true);
         }
         $view->addItem($item);
     }
     return $view;
 }
 private function getStatus(HarbormasterBuild $build)
 {
     $status_view = new PHUIStatusListView();
     $item = new PHUIStatusItemView();
     if ($build->isStopping()) {
         $status_name = pht('Pausing');
         $icon = PHUIStatusItemView::ICON_RIGHT;
         $color = 'dark';
     } else {
         $status = $build->getBuildStatus();
         $status_name = HarbormasterBuild::getBuildStatusName($status);
         $icon = HarbormasterBuild::getBuildStatusIcon($status);
         $color = HarbormasterBuild::getBuildStatusColor($status);
     }
     $item->setTarget($status_name);
     $item->setIcon($icon, $color);
     $status_view->addItem($item);
     return $status_view;
 }
 private function buildPropertySection(PhabricatorCalendarEvent $event)
 {
     $viewer = $this->getViewer();
     $properties = id(new PHUIPropertyListView())->setUser($viewer);
     $invitees = $event->getInvitees();
     foreach ($invitees as $key => $invitee) {
         if ($invitee->isUninvited()) {
             unset($invitees[$key]);
         }
     }
     if ($invitees) {
         $invitee_list = new PHUIStatusListView();
         $icon_invited = PHUIStatusItemView::ICON_OPEN;
         $icon_attending = PHUIStatusItemView::ICON_ACCEPT;
         $icon_declined = PHUIStatusItemView::ICON_REJECT;
         $status_invited = PhabricatorCalendarEventInvitee::STATUS_INVITED;
         $status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
         $status_declined = PhabricatorCalendarEventInvitee::STATUS_DECLINED;
         $icon_map = array($status_invited => $icon_invited, $status_attending => $icon_attending, $status_declined => $icon_declined);
         $icon_color_map = array($status_invited => null, $status_attending => 'green', $status_declined => 'red');
         foreach ($invitees as $invitee) {
             $item = new PHUIStatusItemView();
             $invitee_phid = $invitee->getInviteePHID();
             $status = $invitee->getStatus();
             $target = $viewer->renderHandle($invitee_phid);
             $icon = $icon_map[$status];
             $icon_color = $icon_color_map[$status];
             $item->setIcon($icon, $icon_color)->setTarget($target);
             $invitee_list->addItem($item);
         }
     } else {
         $invitee_list = phutil_tag('em', array(), pht('None'));
     }
     $properties->addProperty(pht('Invitees'), $invitee_list);
     $properties->invokeWillRenderEvent();
     return $properties;
 }
 private function buildPropertyView(PhabricatorCalendarEvent $event)
 {
     $viewer = $this->getRequest()->getUser();
     $properties = id(new PHUIPropertyListView())->setUser($viewer)->setObject($event);
     if ($event->getIsAllDay()) {
         $date_start = phabricator_date($event->getDateFrom(), $viewer);
         $date_end = phabricator_date($event->getDateTo(), $viewer);
         if ($date_start == $date_end) {
             $properties->addProperty(pht('Time'), phabricator_date($event->getDateFrom(), $viewer));
         } else {
             $properties->addProperty(pht('Starts'), phabricator_date($event->getDateFrom(), $viewer));
             $properties->addProperty(pht('Ends'), phabricator_date($event->getDateTo(), $viewer));
         }
     } else {
         $properties->addProperty(pht('Starts'), phabricator_datetime($event->getDateFrom(), $viewer));
         $properties->addProperty(pht('Ends'), phabricator_datetime($event->getDateTo(), $viewer));
     }
     if ($event->getIsRecurring()) {
         $properties->addProperty(pht('Recurs'), ucwords(idx($event->getRecurrenceFrequency(), 'rule')));
         if ($event->getRecurrenceEndDate()) {
             $properties->addProperty(pht('Recurrence Ends'), phabricator_datetime($event->getRecurrenceEndDate(), $viewer));
         }
         if ($event->getInstanceOfEventPHID()) {
             $properties->addProperty(pht('Recurrence of Event'), pht('%s of %s', $event->getSequenceIndex(), $viewer->renderHandle($event->getInstanceOfEventPHID())->render()));
         }
     }
     $properties->addProperty(pht('Host'), $viewer->renderHandle($event->getUserPHID()));
     $invitees = $event->getInvitees();
     foreach ($invitees as $key => $invitee) {
         if ($invitee->isUninvited()) {
             unset($invitees[$key]);
         }
     }
     if ($invitees) {
         $invitee_list = new PHUIStatusListView();
         $icon_invited = PHUIStatusItemView::ICON_OPEN;
         $icon_attending = PHUIStatusItemView::ICON_ACCEPT;
         $icon_declined = PHUIStatusItemView::ICON_REJECT;
         $status_invited = PhabricatorCalendarEventInvitee::STATUS_INVITED;
         $status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
         $status_declined = PhabricatorCalendarEventInvitee::STATUS_DECLINED;
         $icon_map = array($status_invited => $icon_invited, $status_attending => $icon_attending, $status_declined => $icon_declined);
         $icon_color_map = array($status_invited => null, $status_attending => 'green', $status_declined => 'red');
         foreach ($invitees as $invitee) {
             $item = new PHUIStatusItemView();
             $invitee_phid = $invitee->getInviteePHID();
             $status = $invitee->getStatus();
             $target = $viewer->renderHandle($invitee_phid);
             $icon = $icon_map[$status];
             $icon_color = $icon_color_map[$status];
             $item->setIcon($icon, $icon_color)->setTarget($target);
             $invitee_list->addItem($item);
         }
     } else {
         $invitee_list = phutil_tag('em', array(), pht('None'));
     }
     $properties->addProperty(pht('Invitees'), $invitee_list);
     $properties->invokeWillRenderEvent();
     $properties->addProperty(pht('Icon'), id(new PhabricatorCalendarIconSet())->getIconLabel($event->getIcon()));
     if (strlen($event->getDescription())) {
         $description = PhabricatorMarkupEngine::renderOneObject(id(new PhabricatorMarkupOneOff())->setContent($event->getDescription()), 'default', $viewer);
         $properties->addSectionHeader(pht('Description'), PHUIPropertyListView::ICON_SUMMARY);
         $properties->addTextContent($description);
     }
     return $properties;
 }
 private function buildProperties(array $properties, array $issues)
 {
     $view = id(new PHUIPropertyListView())->setUser($this->getRequest()->getUser());
     foreach ($properties as $property) {
         list($key, $value) = $property;
         $view->addProperty($key, $value);
     }
     $status_view = new PHUIStatusListView();
     if (!$issues) {
         $status_view->addItem(id(new PHUIStatusItemView())->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green')->setTarget(pht('No Schema Issues')));
     } else {
         foreach ($issues as $issue) {
             $note = PhabricatorConfigStorageSchema::getIssueDescription($issue);
             $status = PhabricatorConfigStorageSchema::getIssueStatus($issue);
             switch ($status) {
                 case PhabricatorConfigStorageSchema::STATUS_WARN:
                     $icon = PHUIStatusItemView::ICON_WARNING;
                     $color = 'yellow';
                     break;
                 case PhabricatorConfigStorageSchema::STATUS_FAIL:
                 default:
                     $icon = PHUIStatusItemView::ICON_REJECT;
                     $color = 'red';
                     break;
             }
             $item = id(new PHUIStatusItemView())->setTarget(PhabricatorConfigStorageSchema::getIssueName($issue))->setIcon($icon, $color)->setNote($note);
             $status_view->addItem($item);
         }
     }
     $view->addProperty(pht('Schema Status'), $status_view);
     return phutil_tag_div('config-page-property', $view);
 }
 private function buildDependsOnList(array $step_phids, $name, array $steps)
 {
     $has_conflicts = false;
     if (count($step_phids) === 0) {
         return null;
     }
     $this->requireResource('harbormaster-css');
     $steps = mpull($steps, null, 'getPHID');
     $header = phutil_tag('div', array('class' => 'harbormaster-artifact-summary-header'), $name);
     $list = new PHUIStatusListView();
     foreach ($step_phids as $step_phid) {
         $error = null;
         if (idx($steps, $step_phid) === null) {
             $icon = PHUIStatusItemView::ICON_WARNING;
             $color = 'red';
             $icon_label = pht('Missing Dependency');
             $has_conflicts = true;
             $error = pht("This dependency specifies a build step which doesn't exist.");
         } else {
             $bound = phutil_tag('strong', array(), idx($steps, $step_phid)->getName());
             $icon = PHUIStatusItemView::ICON_ACCEPT;
             $color = 'green';
             $icon_label = pht('Valid Input');
         }
         if ($error) {
             $note = array(phutil_tag('strong', array(), pht('ERROR:')), ' ', $error);
         } else {
             $note = $bound;
         }
         $list->addItem(id(new PHUIStatusItemView())->setIcon($icon, $color, $icon_label)->setTarget(pht('Build Step'))->setNote($note));
     }
     $ui = array($header, $list);
     return array($ui, $has_conflicts);
 }
 private function buildPropertySection(PhabricatorCalendarEvent $event)
 {
     $viewer = $this->getViewer();
     $properties = id(new PHUIPropertyListView())->setUser($viewer);
     $invitees = $event->getInvitees();
     foreach ($invitees as $key => $invitee) {
         if ($invitee->isUninvited()) {
             unset($invitees[$key]);
         }
     }
     if ($invitees) {
         $invitee_list = new PHUIStatusListView();
         $icon_invited = PHUIStatusItemView::ICON_OPEN;
         $icon_attending = PHUIStatusItemView::ICON_ACCEPT;
         $icon_declined = PHUIStatusItemView::ICON_REJECT;
         $status_invited = PhabricatorCalendarEventInvitee::STATUS_INVITED;
         $status_attending = PhabricatorCalendarEventInvitee::STATUS_ATTENDING;
         $status_declined = PhabricatorCalendarEventInvitee::STATUS_DECLINED;
         $icon_map = array($status_invited => $icon_invited, $status_attending => $icon_attending, $status_declined => $icon_declined);
         $icon_color_map = array($status_invited => null, $status_attending => 'green', $status_declined => 'red');
         $viewer_phid = $viewer->getPHID();
         $is_rsvp_invited = $event->isRSVPInvited($viewer_phid);
         $type_user = PhabricatorPeopleUserPHIDType::TYPECONST;
         $head = array();
         $tail = array();
         foreach ($invitees as $invitee) {
             $item = new PHUIStatusItemView();
             $invitee_phid = $invitee->getInviteePHID();
             $status = $invitee->getStatus();
             $target = $viewer->renderHandle($invitee_phid);
             $is_user = phid_get_type($invitee_phid) == $type_user;
             if (!$is_user) {
                 $icon = 'fa-users';
                 $icon_color = 'blue';
             } else {
                 $icon = $icon_map[$status];
                 $icon_color = $icon_color_map[$status];
             }
             // Highlight invited groups which you're a member of if you have
             // not RSVP'd to an event yet.
             if ($is_rsvp_invited) {
                 if ($invitee_phid != $viewer_phid) {
                     if ($event->hasRSVPAuthority($viewer_phid, $invitee_phid)) {
                         $item->setHighlighted(true);
                     }
                 }
             }
             $item->setIcon($icon, $icon_color)->setTarget($target);
             if ($is_user) {
                 $tail[] = $item;
             } else {
                 $head[] = $item;
             }
         }
         foreach (array_merge($head, $tail) as $item) {
             $invitee_list->addItem($item);
         }
     } else {
         $invitee_list = phutil_tag('em', array(), pht('None'));
     }
     if ($event->isImportedEvent()) {
         $properties->addProperty(pht('Imported By'), pht('%s from %s', $viewer->renderHandle($event->getImportAuthorPHID()), $viewer->renderHandle($event->getImportSourcePHID())));
     }
     $properties->addProperty(pht('Invitees'), $invitee_list);
     $properties->invokeWillRenderEvent();
     return $properties;
 }
 private function renderAuditStatusView(array $audit_requests)
 {
     assert_instances_of($audit_requests, 'PhabricatorRepositoryAuditRequest');
     $phids = mpull($audit_requests, 'getAuditorPHID');
     $this->loadHandles($phids);
     $authority_map = array_fill_keys($this->auditAuthorityPHIDs, true);
     $view = new PHUIStatusListView();
     foreach ($audit_requests as $request) {
         $item = new PHUIStatusItemView();
         switch ($request->getAuditStatus()) {
             case PhabricatorAuditStatusConstants::AUDIT_NOT_REQUIRED:
                 $item->setIcon(PHUIStatusItemView::ICON_OPEN, 'blue', pht('Commented'));
                 break;
             case PhabricatorAuditStatusConstants::AUDIT_REQUIRED:
                 $item->setIcon(PHUIStatusItemView::ICON_WARNING, 'blue', pht('Audit Required'));
                 break;
             case PhabricatorAuditStatusConstants::CONCERNED:
                 $item->setIcon(PHUIStatusItemView::ICON_REJECT, 'red', pht('Concern Raised'));
                 break;
             case PhabricatorAuditStatusConstants::ACCEPTED:
                 $item->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'green', pht('Accepted'));
                 break;
             case PhabricatorAuditStatusConstants::AUDIT_REQUESTED:
                 $item->setIcon(PHUIStatusItemView::ICON_WARNING, 'dark', pht('Audit Requested'));
                 break;
             case PhabricatorAuditStatusConstants::RESIGNED:
                 $item->setIcon(PHUIStatusItemView::ICON_OPEN, 'dark', pht('Resigned'));
                 break;
             case PhabricatorAuditStatusConstants::CLOSED:
                 $item->setIcon(PHUIStatusItemView::ICON_ACCEPT, 'blue', pht('Closed'));
                 break;
             default:
                 $item->setIcon(PHUIStatusItemView::ICON_QUESTION, 'dark', pht('%s?', $request->getAuditStatus()));
                 break;
         }
         $note = array();
         foreach ($request->getAuditReasons() as $reason) {
             $note[] = phutil_tag('div', array(), $reason);
         }
         $item->setNote($note);
         $auditor_phid = $request->getAuditorPHID();
         $target = $this->getHandle($auditor_phid)->renderLink();
         $item->setTarget($target);
         if (isset($authority_map[$auditor_phid])) {
             $item->setHighlighted(true);
         }
         $view->addItem($item);
     }
     return $view;
 }