Differential D20011 Diff 47810 src/applications/settings/panel/PhabricatorContactNumbersSettingsPanel.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/panel/PhabricatorContactNumbersSettingsPanel.php
| <?php | <?php | ||||
| final class PhabricatorContactNumbersSettingsPanel | final class PhabricatorContactNumbersSettingsPanel | ||||
| extends PhabricatorSettingsPanel { | extends PhabricatorSettingsPanel { | ||||
| public function getPanelKey() { | public function getPanelKey() { | ||||
| return 'contact'; | return 'contact'; | ||||
| } | } | ||||
| public function getPanelName() { | public function getPanelName() { | ||||
| return pht('Contact Numbers'); | return pht('Contact Numbers'); | ||||
| } | } | ||||
| public function getPanelMenuIcon() { | public function getPanelMenuIcon() { | ||||
| return 'fa-mobile'; | return 'fa-hashtag'; | ||||
| } | } | ||||
| public function getPanelGroupKey() { | public function getPanelGroupKey() { | ||||
| return PhabricatorSettingsAuthenticationPanelGroup::PANELGROUPKEY; | return PhabricatorSettingsAuthenticationPanelGroup::PANELGROUPKEY; | ||||
| } | } | ||||
| public function isMultiFactorEnrollmentPanel() { | public function isMultiFactorEnrollmentPanel() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| public function processRequest(AphrontRequest $request) { | public function processRequest(AphrontRequest $request) { | ||||
| $user = $this->getUser(); | $user = $this->getUser(); | ||||
| $viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
| $numbers = id(new PhabricatorAuthContactNumberQuery()) | $numbers = id(new PhabricatorAuthContactNumberQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->withObjectPHIDs(array($user->getPHID())) | ->withObjectPHIDs(array($user->getPHID())) | ||||
| ->execute(); | ->execute(); | ||||
| $numbers = msortv($numbers, 'getSortVector'); | |||||
| $rows = array(); | $rows = array(); | ||||
| $row_classes = array(); | |||||
| foreach ($numbers as $number) { | foreach ($numbers as $number) { | ||||
| if ($number->getIsPrimary()) { | |||||
| $primary_display = pht('Primary'); | |||||
| $row_classes[] = 'highlighted'; | |||||
| } else { | |||||
| $primary_display = null; | |||||
| $row_classes[] = null; | |||||
| } | |||||
| $rows[] = array( | $rows[] = array( | ||||
| $number->newIconView(), | $number->newIconView(), | ||||
| phutil_tag( | phutil_tag( | ||||
| 'a', | 'a', | ||||
| array( | array( | ||||
| 'href' => $number->getURI(), | 'href' => $number->getURI(), | ||||
| ), | ), | ||||
| $number->getDisplayName()), | $number->getDisplayName()), | ||||
| $primary_display, | |||||
| phabricator_datetime($number->getDateCreated(), $viewer), | phabricator_datetime($number->getDateCreated(), $viewer), | ||||
| ); | ); | ||||
| } | } | ||||
| $table = id(new AphrontTableView($rows)) | $table = id(new AphrontTableView($rows)) | ||||
| ->setNoDataString( | ->setNoDataString( | ||||
| pht("You haven't added any contact numbers to your account.")) | pht("You haven't added any contact numbers to your account.")) | ||||
| ->setRowClasses($row_classes) | |||||
| ->setHeaders( | ->setHeaders( | ||||
| array( | array( | ||||
| null, | null, | ||||
| pht('Number'), | pht('Number'), | ||||
| pht('Status'), | |||||
| pht('Created'), | pht('Created'), | ||||
| )) | )) | ||||
| ->setColumnClasses( | ->setColumnClasses( | ||||
| array( | array( | ||||
| null, | null, | ||||
| 'wide pri', | 'wide pri', | ||||
| null, | |||||
| 'right', | 'right', | ||||
| )); | )); | ||||
| $buttons = array(); | $buttons = array(); | ||||
| $buttons[] = id(new PHUIButtonView()) | $buttons[] = id(new PHUIButtonView()) | ||||
| ->setTag('a') | ->setTag('a') | ||||
| ->setIcon('fa-plus') | ->setIcon('fa-plus') | ||||
| ->setText(pht('Add Contact Number')) | ->setText(pht('Add Contact Number')) | ||||
| ->setHref('/auth/contact/edit/') | ->setHref('/auth/contact/edit/') | ||||
| ->setColor(PHUIButtonView::GREY); | ->setColor(PHUIButtonView::GREY); | ||||
| return $this->newBox(pht('Contact Numbers'), $table, $buttons); | return $this->newBox(pht('Contact Numbers'), $table, $buttons); | ||||
| } | } | ||||
| } | } | ||||