Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F436308
DarkConsoleController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
DarkConsoleController.php
View Options
<?php
final
class
DarkConsoleController
extends
PhabricatorController
{
protected
$op
;
protected
$data
;
public
function
shouldRequireLogin
()
{
return
!
PhabricatorEnv
::
getEnvConfig
(
'darkconsole.always-on'
);
}
public
function
shouldRequireEnabledUser
()
{
return
!
PhabricatorEnv
::
getEnvConfig
(
'darkconsole.always-on'
);
}
public
function
shouldAllowPartialSessions
()
{
return
true
;
}
public
function
handleRequest
(
AphrontRequest
$request
)
{
$viewer
=
$this
->
getViewer
();
$response
=
id
(
new
AphrontAjaxResponse
())->
setDisableConsole
(
true
);
if
(!
$viewer
->
isLoggedIn
())
{
return
$response
;
}
// This should be '0' when closed and '1' when opened
$visible
=
$request
->
getStr
(
'visible'
);
if
(
phutil_nonempty_string
(
$visible
))
{
$this
->
writeDarkConsoleSetting
(
PhabricatorDarkConsoleVisibleSetting
::
SETTINGKEY
,
(
int
)
$visible
);
return
$response
;
}
$tab
=
$request
->
getStr
(
'tab'
);
if
(
phutil_nonempty_string
(
$tab
))
{
$this
->
writeDarkConsoleSetting
(
PhabricatorDarkConsoleTabSetting
::
SETTINGKEY
,
$tab
);
return
$response
;
}
return
new
Aphront404Response
();
}
private
function
writeDarkConsoleSetting
(
$key
,
$value
)
{
$viewer
=
$this
->
getViewer
();
$request
=
$this
->
getRequest
();
$preferences
=
PhabricatorUserPreferences
::
loadUserPreferences
(
$viewer
);
$editor
=
id
(
new
PhabricatorUserPreferencesEditor
())
->
setActor
(
$viewer
)
->
setContentSourceFromRequest
(
$request
)
->
setContinueOnNoEffect
(
true
)
->
setContinueOnMissingFields
(
true
);
$xactions
=
array
();
$xactions
[]
=
$preferences
->
newTransaction
(
$key
,
$value
);
$editor
->
applyTransactions
(
$preferences
,
$xactions
);
// Reload the user to regenerate their preferences cache. If we don't
// do this, the "Services" tab gets misleadingly spammed up with cache
// fills that are only filling because you toggled the console or switched
// tabs. This makes it harder to see what's really going on, so just force
// a cache regeneration here.
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$viewer
->
getPHID
()))
->
needUserSettings
(
true
)
->
execute
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 3, 10:50 PM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
59039
Default Alt Text
DarkConsoleController.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment