Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F100501374
AlmanacDevice.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
Fri, Jan 31, 07:18
Size
2 KB
Mime Type
text/x-php
Expires
Sun, Feb 2, 07:18 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23977492
Attached To
rPH Phabricator
AlmanacDevice.php
View Options
<?php
final
class
AlmanacDevice
extends
AlmanacDAO
implements
PhabricatorPolicyInterface
{
protected
$name
;
protected
$nameIndex
;
protected
$mailKey
;
protected
$viewPolicy
;
protected
$editPolicy
;
public
static
function
initializeNewDevice
()
{
return
id
(
new
AlmanacDevice
())
->
setViewPolicy
(
PhabricatorPolicies
::
POLICY_USER
)
->
setEditPolicy
(
PhabricatorPolicies
::
POLICY_ADMIN
);
}
public
function
getConfiguration
()
{
return
array
(
self
::
CONFIG_AUX_PHID
=>
true
,
self
::
CONFIG_COLUMN_SCHEMA
=>
array
(
'name'
=>
'text128'
,
'nameIndex'
=>
'bytes12'
,
),
self
::
CONFIG_KEY_SCHEMA
=>
array
(
'key_name'
=>
array
(
'columns'
=>
array
(
'nameIndex'
),
'unique'
=>
true
,
),
'key_nametext'
=>
array
(
'columns'
=>
array
(
'name'
),
),
),
)
+
parent
::
getConfiguration
();
}
public
function
generatePHID
()
{
return
PhabricatorPHID
::
generateNewPHID
(
AlmanacDevicePHIDType
::
TYPECONST
);
}
public
function
save
()
{
AlmanacNames
::
validateServiceOrDeviceName
(
$this
->
getName
());
$this
->
nameIndex
=
PhabricatorHash
::
digestForIndex
(
$this
->
getName
());
if
(!
$this
->
mailKey
)
{
$this
->
mailKey
=
Filesystem
::
readRandomCharacters
(
20
);
}
return
parent
::
save
();
}
public
function
getURI
()
{
return
'/almanac/device/view/'
.
$this
->
getName
().
'/'
;
}
/* -( PhabricatorPolicyInterface )----------------------------------------- */
public
function
getCapabilities
()
{
return
array
(
PhabricatorPolicyCapability
::
CAN_VIEW
,
PhabricatorPolicyCapability
::
CAN_EDIT
,
);
}
public
function
getPolicy
(
$capability
)
{
switch
(
$capability
)
{
case
PhabricatorPolicyCapability
::
CAN_VIEW
:
return
$this
->
getViewPolicy
();
case
PhabricatorPolicyCapability
::
CAN_EDIT
:
return
$this
->
getEditPolicy
();
}
}
public
function
hasAutomaticCapability
(
$capability
,
PhabricatorUser
$viewer
)
{
return
false
;
}
public
function
describeAutomaticCapability
(
$capability
)
{
return
null
;
}
}
Event Timeline
Log In to Comment