public function handlePanelRequest(AphrontRequest $request, PhabricatorController $controller)
 {
     $viewer = $request->getViewer();
     $application = $this->getApplication();
     $path = $request->getURIData('path');
     if (strlen($path)) {
         return new Aphront404Response();
     }
     $uri = $request->getRequestURI();
     $uri->setQueryParams(array());
     $new = $request->getStr('new');
     $edit = $request->getInt('edit');
     $delete = $request->getInt('delete');
     if ($new) {
         return $this->returnNewAddressResponse($request, $uri, $application);
     }
     if ($edit) {
         return $this->returnEditAddressResponse($request, $uri, $edit);
     }
     if ($delete) {
         return $this->returnDeleteAddressResponse($request, $uri, $delete);
     }
     $table = $this->buildEmailTable($is_edit = true, $request->getInt('id'));
     $form = id(new AphrontFormView())->setUser($viewer);
     $crumbs = $controller->buildPanelCrumbs($this);
     $crumbs->addTextCrumb(pht('Edit Application Emails'));
     $crumbs->setBorder(true);
     $header = id(new PHUIHeaderView())->setHeader(pht('Edit Application Emails: %s', $application->getName()))->setSubheader($application->getAppEmailBlurb())->setHeaderIcon('fa-pencil');
     $icon = id(new PHUIIconView())->setIcon('fa-plus');
     $button = new PHUIButtonView();
     $button->setText(pht('Add New Address'));
     $button->setTag('a');
     $button->setHref($uri->alter('new', 'true'));
     $button->setIcon($icon);
     $button->addSigil('workflow');
     $header->addActionLink($button);
     $object_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Emails'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setTable($table);
     $title = $application->getName();
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter($object_box);
     return $controller->buildPanelPage($this, $title, $crumbs, $view);
 }
 private function buildBrowseTable($browse_results, $browse_paths, $browse_exception, array $handles)
 {
     require_celerity_resource('diffusion-icons-css');
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $drequest = $this->getDiffusionRequest();
     $repository = $drequest->getRepository();
     if ($browse_exception) {
         if ($repository->isImporting()) {
             // The history table renders a useful message.
             return null;
         } else {
             return $this->renderStatusMessage(pht('Unable to Retrieve Paths'), $browse_exception->getMessage());
         }
     }
     $browse_table = id(new DiffusionBrowseTableView())->setUser($viewer)->setDiffusionRequest($drequest)->setHandles($handles);
     if ($browse_paths) {
         $browse_table->setPaths($browse_paths);
     } else {
         $browse_table->setPaths(array());
     }
     $browse_uri = $drequest->generateURI(array('action' => 'browse'));
     $browse_panel = new PHUIObjectBoxView();
     $header = id(new PHUIHeaderView())->setHeader(pht('Repository'));
     $icon = id(new PHUIIconView())->setIconFont('fa-folder-open');
     $button = new PHUIButtonView();
     $button->setText(pht('Browse Repository'));
     $button->setTag('a');
     $button->setIcon($icon);
     $button->setHref($browse_uri);
     $header->addActionLink($button);
     $browse_panel->setHeader($header);
     $locate_panel = null;
     if ($repository->canUsePathTree()) {
         Javelin::initBehavior('diffusion-locate-file', array('controlID' => 'locate-control', 'inputID' => 'locate-input', 'browseBaseURI' => (string) $drequest->generateURI(array('action' => 'browse')), 'uri' => (string) $drequest->generateURI(array('action' => 'pathtree'))));
         $form = id(new AphrontFormView())->setUser($viewer)->appendChild(id(new AphrontFormTypeaheadControl())->setHardpointID('locate-control')->setID('locate-input')->setLabel(pht('Locate File')));
         $form_box = id(new PHUIBoxView())->appendChild($form->buildLayoutView());
         $locate_panel = id(new PHUIObjectBoxView())->setHeaderText('Locate File')->appendChild($form_box);
     }
     $browse_panel->setTable($browse_table);
     return array($locate_panel, $browse_panel);
 }
 public function processRequest(AphrontRequest $request)
 {
     $user = $this->getUser();
     $editable = PhabricatorEnv::getEnvConfig('account.editable');
     $uri = $request->getRequestURI();
     $uri->setQueryParams(array());
     if ($editable) {
         $new = $request->getStr('new');
         if ($new) {
             return $this->returnNewAddressResponse($request, $uri, $new);
         }
         $delete = $request->getInt('delete');
         if ($delete) {
             return $this->returnDeleteAddressResponse($request, $uri, $delete);
         }
     }
     $verify = $request->getInt('verify');
     if ($verify) {
         return $this->returnVerifyAddressResponse($request, $uri, $verify);
     }
     $primary = $request->getInt('primary');
     if ($primary) {
         return $this->returnPrimaryAddressResponse($request, $uri, $primary);
     }
     $emails = id(new PhabricatorUserEmail())->loadAllWhere('userPHID = %s ORDER BY address', $user->getPHID());
     $rowc = array();
     $rows = array();
     foreach ($emails as $email) {
         $button_verify = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('verify', $email->getID()), 'sigil' => 'workflow'), pht('Verify'));
         $button_make_primary = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('primary', $email->getID()), 'sigil' => 'workflow'), pht('Make Primary'));
         $button_remove = javelin_tag('a', array('class' => 'button small grey', 'href' => $uri->alter('delete', $email->getID()), 'sigil' => 'workflow'), pht('Remove'));
         $button_primary = phutil_tag('a', array('class' => 'button small disabled'), pht('Primary'));
         if (!$email->getIsVerified()) {
             $action = $button_verify;
         } else {
             if ($email->getIsPrimary()) {
                 $action = $button_primary;
             } else {
                 $action = $button_make_primary;
             }
         }
         if ($email->getIsPrimary()) {
             $remove = $button_primary;
             $rowc[] = 'highlighted';
         } else {
             $remove = $button_remove;
             $rowc[] = null;
         }
         $rows[] = array($email->getAddress(), $action, $remove);
     }
     $table = new AphrontTableView($rows);
     $table->setHeaders(array(pht('Email'), pht('Status'), pht('Remove')));
     $table->setColumnClasses(array('wide', 'action', 'action'));
     $table->setRowClasses($rowc);
     $table->setColumnVisibility(array(true, true, $editable));
     $view = new PHUIObjectBoxView();
     $header = new PHUIHeaderView();
     $header->setHeader(pht('Email Addresses'));
     if ($editable) {
         $button = new PHUIButtonView();
         $button->setText(pht('Add New Address'));
         $button->setTag('a');
         $button->setHref($uri->alter('new', 'true'));
         $button->setIcon('fa-plus');
         $button->addSigil('workflow');
         $header->addActionLink($button);
     }
     $view->setHeader($header);
     $view->setTable($table);
     return $view;
 }
 private function buildBrowseTable($browse_results, $browse_paths, $browse_exception, array $handles, PHUIPagerView $pager)
 {
     require_celerity_resource('diffusion-icons-css');
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $drequest = $this->getDiffusionRequest();
     $repository = $drequest->getRepository();
     if ($browse_exception) {
         if ($repository->isImporting()) {
             // The history table renders a useful message.
             return null;
         } else {
             return $this->renderStatusMessage(pht('Unable to Retrieve Paths'), $browse_exception->getMessage());
         }
     }
     $browse_table = id(new DiffusionBrowseTableView())->setUser($viewer)->setDiffusionRequest($drequest)->setHandles($handles);
     if ($browse_paths) {
         $browse_table->setPaths($browse_paths);
     } else {
         $browse_table->setPaths(array());
     }
     $browse_uri = $drequest->generateURI(array('action' => 'browse'));
     $browse_panel = id(new PHUIObjectBoxView())->setBackground(PHUIObjectBoxView::BLUE_PROPERTY);
     $header = id(new PHUIHeaderView())->setHeader($repository->getName());
     $icon = id(new PHUIIconView())->setIcon('fa-folder-open');
     $button = new PHUIButtonView();
     $button->setText(pht('Browse Repository'));
     $button->setTag('a');
     $button->setIcon($icon);
     $button->setHref($browse_uri);
     $header->addActionLink($button);
     $browse_panel->setHeader($header);
     $browse_panel->setTable($browse_table);
     $pager->setURI($browse_uri, 'offset');
     if ($pager->willShowPagingControls()) {
         $pager_box = $this->renderTablePagerBox($pager);
     } else {
         $pager_box = null;
     }
     return array($browse_panel, $pager_box);
 }