Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/auth/extension/PhabricatorAuthMainMenuBarExtension.php
12256 views
1
<?php
2
3
final class PhabricatorAuthMainMenuBarExtension
4
extends PhabricatorMainMenuBarExtension {
5
6
const MAINMENUBARKEY = 'auth';
7
8
public function isExtensionEnabledForViewer(PhabricatorUser $viewer) {
9
return true;
10
}
11
12
public function shouldRequireFullSession() {
13
return false;
14
}
15
16
public function getExtensionOrder() {
17
return 900;
18
}
19
20
public function buildMainMenus() {
21
$viewer = $this->getViewer();
22
23
if ($viewer->isLoggedIn()) {
24
return array();
25
}
26
27
$controller = $this->getController();
28
if ($controller instanceof PhabricatorAuthController) {
29
// Don't show the "Login" item on auth controllers, since they're
30
// generally all related to logging in anyway.
31
return array();
32
}
33
34
return array(
35
$this->buildLoginMenu(),
36
);
37
}
38
39
private function buildLoginMenu() {
40
$controller = $this->getController();
41
42
// See T13636. This button may be rendered by the 404 controller on sites
43
// other than the primary PlatformSite. Link the button to the primary
44
// site.
45
46
$uri = '/auth/start/';
47
$uri = PhabricatorEnv::getURI($uri);
48
$uri = new PhutilURI($uri);
49
if ($controller) {
50
$path = $controller->getRequest()->getPath();
51
$uri->replaceQueryParam('next', $path);
52
}
53
54
return id(new PHUIButtonView())
55
->setTag('a')
56
->setText(pht('Log In'))
57
->setHref($uri)
58
->setNoCSS(true)
59
->addClass('phabricator-core-login-button');
60
}
61
62
}
63
64