Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F112692570
PhabricatorOAuthClientViewController.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, May 12, 08:21
Size
3 KB
Mime Type
text/x-php
Expires
Wed, May 14, 08:21 (2 d)
Engine
blob
Format
Raw Data
Handle
26130007
Attached To
rPH Phabricator
PhabricatorOAuthClientViewController.php
View Options
<?php
final
class
PhabricatorOAuthClientViewController
extends
PhabricatorOAuthClientBaseController
{
public
function
processRequest
()
{
$request
=
$this
->
getRequest
();
$viewer
=
$request
->
getUser
();
$client
=
id
(
new
PhabricatorOAuthServerClientQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$this
->
getClientPHID
()))
->
executeOne
();
if
(!
$client
)
{
return
new
Aphront404Response
();
}
$header
=
$this
->
buildHeaderView
(
$client
);
$actions
=
$this
->
buildActionView
(
$client
);
$properties
=
$this
->
buildPropertyListView
(
$client
);
$properties
->
setActionList
(
$actions
);
$crumbs
=
$this
->
buildApplicationCrumbs
();
$crumbs
->
addTextCrumb
(
$client
->
getName
());
$box
=
id
(
new
PHUIObjectBoxView
())
->
setHeader
(
$header
)
->
addPropertyList
(
$properties
);
return
$this
->
buildApplicationPage
(
array
(
$crumbs
,
$box
,
),
array
(
'title'
=>
pht
(
'OAuth Application: %s'
,
$client
->
getName
()),
));
}
private
function
buildHeaderView
(
PhabricatorOAuthServerClient
$client
)
{
$viewer
=
$this
->
getRequest
()->
getUser
();
$header
=
id
(
new
PHUIHeaderView
())
->
setUser
(
$viewer
)
->
setHeader
(
pht
(
'OAuth Application: %s'
,
$client
->
getName
()))
->
setPolicyObject
(
$client
);
return
$header
;
}
private
function
buildActionView
(
PhabricatorOAuthServerClient
$client
)
{
$viewer
=
$this
->
getRequest
()->
getUser
();
$can_edit
=
PhabricatorPolicyFilter
::
hasCapability
(
$viewer
,
$client
,
PhabricatorPolicyCapability
::
CAN_EDIT
);
$authorization
=
id
(
new
PhabricatorOAuthClientAuthorizationQuery
())
->
setViewer
(
$viewer
)
->
withUserPHIDs
(
array
(
$viewer
->
getPHID
()))
->
withClientPHIDs
(
array
(
$client
->
getPHID
()))
->
executeOne
();
$is_authorized
=
(
bool
)
$authorization
;
$view
=
id
(
new
PhabricatorActionListView
())
->
setUser
(
$viewer
);
$view
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'Edit Application'
))
->
setIcon
(
'fa-pencil'
)
->
setWorkflow
(!
$can_edit
)
->
setDisabled
(!
$can_edit
)
->
setHref
(
$client
->
getEditURI
()));
$view
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'Delete Application'
))
->
setIcon
(
'fa-times'
)
->
setWorkflow
(
true
)
->
setDisabled
(!
$can_edit
)
->
setHref
(
$client
->
getDeleteURI
()));
$view
->
addAction
(
id
(
new
PhabricatorActionView
())
->
setName
(
pht
(
'Create Test Authorization'
))
->
setIcon
(
'fa-wrench'
)
->
setWorkflow
(
true
)
->
setDisabled
(
$is_authorized
)
->
setHref
(
$this
->
getApplicationURI
(
'test/'
.
$client
->
getID
().
'/'
)));
return
$view
;
}
private
function
buildPropertyListView
(
PhabricatorOAuthServerClient
$client
)
{
$viewer
=
$this
->
getRequest
()->
getUser
();
$view
=
id
(
new
PHUIPropertyListView
())
->
setUser
(
$viewer
);
$view
->
addProperty
(
pht
(
'Client ID'
),
$client
->
getPHID
());
$view
->
addProperty
(
pht
(
'Client Secret'
),
$client
->
getSecret
());
$view
->
addProperty
(
pht
(
'Redirect URI'
),
$client
->
getRedirectURI
());
$view
->
addProperty
(
pht
(
'Created'
),
phabricator_datetime
(
$client
->
getDateCreated
(),
$viewer
));
return
$view
;
}
}
Event Timeline
Log In to Comment