Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97435366
ManiphestTaskOwnerTransaction.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
Sat, Jan 4, 10:25
Size
3 KB
Mime Type
text/x-php
Expires
Mon, Jan 6, 10:25 (2 d)
Engine
blob
Format
Raw Data
Handle
23408036
Attached To
rPH Phabricator
ManiphestTaskOwnerTransaction.php
View Options
<?php
final
class
ManiphestTaskOwnerTransaction
extends
ManiphestTaskTransactionType
{
const
TRANSACTIONTYPE
=
'reassign'
;
public
function
generateOldValue
(
$object
)
{
return
nonempty
(
$object
->
getOwnerPHID
(),
null
);
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
// Update the "ownerOrdering" column to contain the full name of the
// owner, if the task is assigned.
$handle
=
null
;
if
(
$value
)
{
$handle
=
id
(
new
PhabricatorHandleQuery
())
->
setViewer
(
$this
->
getActor
())
->
withPHIDs
(
array
(
$value
))
->
executeOne
();
}
if
(
$handle
)
{
$object
->
setOwnerOrdering
(
$handle
->
getName
());
}
else
{
$object
->
setOwnerOrdering
(
null
);
}
$object
->
setOwnerPHID
(
$value
);
}
public
function
getActionStrength
()
{
return
1.2
;
}
public
function
getActionName
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
if
(
$this
->
getAuthorPHID
()
==
$new
)
{
return
pht
(
'Claimed'
);
}
else
if
(!
$new
)
{
return
pht
(
'Unassigned'
);
}
else
if
(!
$old
)
{
return
pht
(
'Assigned'
);
}
else
{
return
pht
(
'Reassigned'
);
}
}
public
function
getTitle
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
if
(
$this
->
getAuthorPHID
()
==
$new
)
{
return
pht
(
'%s claimed this task.'
,
$this
->
renderAuthor
());
}
else
if
(!
$new
)
{
return
pht
(
'%s removed %s as the assignee of this task.'
,
$this
->
renderAuthor
(),
$this
->
renderHandle
(
$old
));
}
else
if
(!
$old
)
{
return
pht
(
'%s assigned this task to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderHandle
(
$new
));
}
else
{
return
pht
(
'%s reassigned this task from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderHandle
(
$old
),
$this
->
renderHandle
(
$new
));
}
}
public
function
getTitleForFeed
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
if
(
$this
->
getAuthorPHID
()
==
$new
)
{
return
pht
(
'%s claimed %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
());
}
else
if
(!
$new
)
{
return
pht
(
'%s placed %s up for grabs.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
());
}
else
if
(!
$old
)
{
return
pht
(
'%s assigned %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
(),
$this
->
renderHandle
(
$new
));
}
else
{
return
pht
(
'%s reassigned %s from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
(),
$this
->
renderHandle
(
$old
),
$this
->
renderHandle
(
$new
));
}
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
foreach
(
$xactions
as
$xaction
)
{
$old
=
$xaction
->
getOldValue
();
$new
=
$xaction
->
getNewValue
();
if
(!
strlen
(
$new
))
{
continue
;
}
if
(
$new
===
$old
)
{
continue
;
}
$assignee_list
=
id
(
new
PhabricatorPeopleQuery
())
->
setViewer
(
$this
->
getActor
())
->
withPHIDs
(
array
(
$new
))
->
execute
();
if
(!
$assignee_list
)
{
$errors
[]
=
$this
->
newInvalidError
(
pht
(
'User "%s" is not a valid user.'
,
$new
));
}
}
return
$errors
;
}
public
function
getIcon
()
{
return
'fa-user'
;
}
public
function
getColor
()
{
$old
=
$this
->
getOldValue
();
$new
=
$this
->
getNewValue
();
if
(
$this
->
getAuthorPHID
()
==
$new
)
{
return
'green'
;
}
else
if
(!
$new
)
{
return
'black'
;
}
else
if
(!
$old
)
{
return
'green'
;
}
else
{
return
'green'
;
}
}
public
function
getTransactionTypeForConduit
(
$xaction
)
{
return
'owner'
;
}
public
function
getFieldValuesForConduit
(
$xaction
,
$data
)
{
return
array
(
'old'
=>
$xaction
->
getOldValue
(),
'new'
=>
$xaction
->
getNewValue
(),
);
}
}
Event Timeline
Log In to Comment