Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F190655
SecurityPolicyEnforcerAction.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
epriestley
Aug 14 2014, 9:28 PM
2014-08-14 21:28:41 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
SecurityPolicyEnforcerAction.php
View Options
<?php
class
SecurityPolicyEnforcerAction
extends
HeraldCustomAction
{
public
function
appliesToAdapter
(
HeraldAdapter
$adapter
)
{
return
$adapter
instanceof
HeraldManiphestTaskAdapter
;
}
public
function
appliesToRuleType
(
$rule_type
)
{
switch
(
$rule_type
)
{
case
HeraldRuleTypeConfig
::
RULE_TYPE_GLOBAL
:
return
true
;
case
HeraldRuleTypeConfig
::
RULE_TYPE_PERSONAL
:
case
HeraldRuleTypeConfig
::
RULE_TYPE_OBJECT
:
default
:
return
false
;
}
}
public
function
getActionKey
()
{
return
"SecurityPolicy"
;
}
public
function
getActionName
()
{
return
"Ensure Security Task Policy Are Enforced"
;
}
public
function
getActionType
()
{
return
HeraldAdapter
::
VALUE_NONE
;
}
public
function
applyEffect
(
HeraldAdapter
$adapter
,
$object
,
HeraldEffect
$effect
)
{
$task
=
$object
;
$viewer
=
PhabricatorUser
::
getOmnipotentUser
();
$field_list
=
PhabricatorCustomField
::
getObjectFields
(
$task
,
PhabricatorCustomField
::
ROLE_EDIT
);
$field_list
->
setViewer
(
$viewer
)
->
readFieldsFromStorage
(
$task
);
$field_value
=
null
;
foreach
(
$field_list
->
getFields
()
as
$field
)
{
$field_key
=
$field
->
getFieldKey
();
// NOTE: Replace 'std:maniphest:ext_id' with your actual field key.
if
(
$field_key
==
'std:maniphest:ext_id'
)
{
$field_value
=
$field
->
getValueForStorage
();
break
;
}
}
$transactions
=
array
();
$transactions
[]
=
id
(
new
ManiphestTransaction
())
->
setTransactionType
(
ManiphestTransaction
::
TYPE_TITLE
)
->
setNewValue
(
$field_value
);
foreach
(
$transactions
as
$transaction
)
{
$adapter
->
queueTransaction
(
$transaction
);
}
return
new
HeraldApplyTranscript
(
$effect
,
true
,
pht
(
'Set security policy'
));
}
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/xn/6v/jy7mpfucnzloakqz
Default Alt Text
SecurityPolicyEnforcerAction.php (1 KB)
Attached To
Mode
P1236 SecurityPolicyEnforcerAction.php
Attached
Detach File
Event Timeline
Log In to Comment