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); }
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; }