forked from phacility/phabricator
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Third-Party] Add extension to kick back to author
- Loading branch information
1 parent
6002117
commit 8e442fc
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
class KickBackAction 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 "swisspol.kick"; | ||
} | ||
|
||
public function getActionName() { | ||
return pht('Reassign to author'); | ||
} | ||
|
||
public function getActionType() { | ||
return HeraldAdapter::VALUE_NONE; | ||
} | ||
|
||
public function applyEffect( | ||
HeraldAdapter $adapter, | ||
$object, | ||
HeraldEffect $effect) { | ||
|
||
$task = $object; | ||
|
||
$xactions = array(); | ||
|
||
$xactions[] = id(new ManiphestTransaction()) | ||
->setTransactionType(ManiphestTransaction::TYPE_OWNER) | ||
->setNewValue($original_author); | ||
|
||
foreach ($xactions as $xaction) { | ||
$adapter->queueTransaction($xaction); | ||
} | ||
|
||
return new HeraldApplyTranscript( | ||
$effect, | ||
true, | ||
pht('Reassigned to original author')); | ||
} | ||
} |