Differential D18526 Diff 44493 src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/panel/PhabricatorExternalAccountsSettingsPanel.php
Show All 25 Lines | $accounts = id(new PhabricatorExternalAccountQuery()) | ||||
->needImages(true) | ->needImages(true) | ||||
->requireCapabilities( | ->requireCapabilities( | ||||
array( | array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
PhabricatorPolicyCapability::CAN_EDIT, | PhabricatorPolicyCapability::CAN_EDIT, | ||||
)) | )) | ||||
->execute(); | ->execute(); | ||||
$linked_head = id(new PHUIHeaderView()) | $linked_head = pht('Linked Accounts and Authentication'); | ||||
->setHeader(pht('Linked Accounts and Authentication')); | |||||
$linked = id(new PHUIObjectItemListView()) | $linked = id(new PHUIObjectItemListView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setFlush(true) | |||||
->setNoDataString(pht('You have no linked accounts.')); | ->setNoDataString(pht('You have no linked accounts.')); | ||||
$login_accounts = 0; | $login_accounts = 0; | ||||
foreach ($accounts as $account) { | foreach ($accounts as $account) { | ||||
if ($account->isUsableForLogin()) { | if ($account->isUsableForLogin()) { | ||||
$login_accounts++; | $login_accounts++; | ||||
} | } | ||||
} | } | ||||
foreach ($accounts as $account) { | foreach ($accounts as $account) { | ||||
$item = id(new PHUIObjectItemView()); | $item = new PHUIObjectItemView(); | ||||
$provider = idx($providers, $account->getProviderKey()); | $provider = idx($providers, $account->getProviderKey()); | ||||
if ($provider) { | if ($provider) { | ||||
$item->setHeader($provider->getProviderName()); | $item->setHeader($provider->getProviderName()); | ||||
$can_unlink = $provider->shouldAllowAccountUnlink(); | $can_unlink = $provider->shouldAllowAccountUnlink(); | ||||
if (!$can_unlink) { | if (!$can_unlink) { | ||||
$item->addAttribute(pht('Permanently Linked')); | $item->addAttribute(pht('Permanently Linked')); | ||||
} | } | ||||
Show All 30 Lines | foreach ($accounts as $account) { | ||||
if ($provider) { | if ($provider) { | ||||
$provider->willRenderLinkedAccount($viewer, $item, $account); | $provider->willRenderLinkedAccount($viewer, $item, $account); | ||||
} | } | ||||
$linked->addItem($item); | $linked->addItem($item); | ||||
} | } | ||||
$linkable_head = id(new PHUIHeaderView()) | $linkable_head = pht('Add External Account'); | ||||
->setHeader(pht('Add External Account')); | |||||
$linkable = id(new PHUIObjectItemListView()) | $linkable = id(new PHUIObjectItemListView()) | ||||
->setUser($viewer) | ->setUser($viewer) | ||||
->setFlush(true) | |||||
->setNoDataString( | ->setNoDataString( | ||||
pht('Your account is linked with all available providers.')); | pht('Your account is linked with all available providers.')); | ||||
$accounts = mpull($accounts, null, 'getProviderKey'); | $accounts = mpull($accounts, null, 'getProviderKey'); | ||||
$providers = PhabricatorAuthProvider::getAllEnabledProviders(); | $providers = PhabricatorAuthProvider::getAllEnabledProviders(); | ||||
$providers = msort($providers, 'getProviderName'); | $providers = msort($providers, 'getProviderName'); | ||||
foreach ($providers as $key => $provider) { | foreach ($providers as $key => $provider) { | ||||
if (isset($accounts[$key])) { | if (isset($accounts[$key])) { | ||||
continue; | continue; | ||||
} | } | ||||
if (!$provider->shouldAllowAccountLink()) { | if (!$provider->shouldAllowAccountLink()) { | ||||
continue; | continue; | ||||
} | } | ||||
$link_uri = '/auth/link/'.$provider->getProviderKey().'/'; | $link_uri = '/auth/link/'.$provider->getProviderKey().'/'; | ||||
$item = id(new PHUIObjectItemView()); | $item = id(new PHUIObjectItemView()) | ||||
$item->setHeader($provider->getProviderName()); | ->setHeader($provider->getProviderName()) | ||||
$item->setHref($link_uri); | ->setHref($link_uri) | ||||
$item->addAction( | ->addAction( | ||||
id(new PHUIListItemView()) | id(new PHUIListItemView()) | ||||
->setIcon('fa-link') | ->setIcon('fa-link') | ||||
->setHref($link_uri)); | ->setHref($link_uri)); | ||||
$linkable->addItem($item); | $linkable->addItem($item); | ||||
} | } | ||||
$linked_box = id(new PHUIObjectBoxView()) | $linked_box = $this->newBox($linked_head, $linked); | ||||
->setHeader($linked_head) | $linkable_box = $this->newBox($linkable_head, $linkable); | ||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
->setObjectList($linked); | |||||
$linkable_box = id(new PHUIObjectBoxView()) | |||||
->setHeader($linkable_head) | |||||
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) | |||||
->setObjectList($linkable); | |||||
return array( | return array( | ||||
$linked_box, | $linked_box, | ||||
$linkable_box, | $linkable_box, | ||||
); | ); | ||||
} | } | ||||
} | } |