2016-06-22 14:35:40 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class ManiphestTaskRelationship
|
|
|
|
extends PhabricatorObjectRelationship {
|
|
|
|
|
|
|
|
public function isEnabledForObject($object) {
|
|
|
|
$viewer = $this->getViewer();
|
|
|
|
|
|
|
|
$has_app = PhabricatorApplication::isClassInstalledForViewer(
|
|
|
|
'PhabricatorManiphestApplication',
|
|
|
|
$viewer);
|
|
|
|
if (!$has_app) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ($object instanceof ManiphestTask);
|
|
|
|
}
|
|
|
|
|
Convert Maniphest merge operations to modern Relationship code
Summary:
Ref T4788. Fixes T7820. This updates the "Merge Duplicates In" interaction, and adds a "Close as Duplicate" action.
These are the last interactions that were using the old code, so it removes that code.
Merges are now recorded as real edges, so we can show them in the UI later on (originally from T9390, etc).
Also provides more general support for relationships which need EDIT permission, not-undoable relationships like merges, preventing relating an object to itself, and relationship side effects like merges.
Finally, fixes a couple of behaviors around typing an exact object name (like `T123`) to find the related object.
Test Plan:
- Merged tasks into the current task.
- Closed the current task as a duplicate of another task.
- Edited other relationships.
- Searched for tasks, commits, etc., by object monogram.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4788, T7820
Differential Revision: https://secure.phabricator.com/D16196
2016-06-29 20:09:27 +02:00
|
|
|
protected function newMergeIntoTransactions(ManiphestTask $task) {
|
|
|
|
return array(
|
|
|
|
id(new ManiphestTransaction())
|
2017-05-15 19:23:20 +02:00
|
|
|
->setTransactionType(
|
|
|
|
ManiphestTaskMergedIntoTransaction::TRANSACTIONTYPE)
|
Convert Maniphest merge operations to modern Relationship code
Summary:
Ref T4788. Fixes T7820. This updates the "Merge Duplicates In" interaction, and adds a "Close as Duplicate" action.
These are the last interactions that were using the old code, so it removes that code.
Merges are now recorded as real edges, so we can show them in the UI later on (originally from T9390, etc).
Also provides more general support for relationships which need EDIT permission, not-undoable relationships like merges, preventing relating an object to itself, and relationship side effects like merges.
Finally, fixes a couple of behaviors around typing an exact object name (like `T123`) to find the related object.
Test Plan:
- Merged tasks into the current task.
- Closed the current task as a duplicate of another task.
- Edited other relationships.
- Searched for tasks, commits, etc., by object monogram.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4788, T7820
Differential Revision: https://secure.phabricator.com/D16196
2016-06-29 20:09:27 +02:00
|
|
|
->setNewValue($task->getPHID()),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function newMergeFromTransactions(array $tasks) {
|
|
|
|
$xactions = array();
|
|
|
|
|
|
|
|
$subscriber_phids = $this->loadMergeSubscriberPHIDs($tasks);
|
|
|
|
|
|
|
|
$xactions[] = id(new ManiphestTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_SUBSCRIBERS)
|
|
|
|
->setNewValue(array('+' => $subscriber_phids));
|
|
|
|
|
|
|
|
$xactions[] = id(new ManiphestTransaction())
|
2017-05-15 19:23:20 +02:00
|
|
|
->setTransactionType(
|
|
|
|
ManiphestTaskMergedFromTransaction::TRANSACTIONTYPE)
|
Convert Maniphest merge operations to modern Relationship code
Summary:
Ref T4788. Fixes T7820. This updates the "Merge Duplicates In" interaction, and adds a "Close as Duplicate" action.
These are the last interactions that were using the old code, so it removes that code.
Merges are now recorded as real edges, so we can show them in the UI later on (originally from T9390, etc).
Also provides more general support for relationships which need EDIT permission, not-undoable relationships like merges, preventing relating an object to itself, and relationship side effects like merges.
Finally, fixes a couple of behaviors around typing an exact object name (like `T123`) to find the related object.
Test Plan:
- Merged tasks into the current task.
- Closed the current task as a duplicate of another task.
- Edited other relationships.
- Searched for tasks, commits, etc., by object monogram.
Reviewers: chad
Reviewed By: chad
Maniphest Tasks: T4788, T7820
Differential Revision: https://secure.phabricator.com/D16196
2016-06-29 20:09:27 +02:00
|
|
|
->setNewValue(mpull($tasks, 'getPHID'));
|
|
|
|
|
|
|
|
return $xactions;
|
|
|
|
}
|
|
|
|
|
|
|
|
private function loadMergeSubscriberPHIDs(array $tasks) {
|
|
|
|
$phids = array();
|
|
|
|
|
|
|
|
foreach ($tasks as $task) {
|
|
|
|
$phids[] = $task->getAuthorPHID();
|
|
|
|
$phids[] = $task->getOwnerPHID();
|
|
|
|
}
|
|
|
|
|
|
|
|
$subscribers = id(new PhabricatorSubscribersQuery())
|
|
|
|
->withObjectPHIDs(mpull($tasks, 'getPHID'))
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
foreach ($subscribers as $phid => $subscriber_list) {
|
|
|
|
foreach ($subscriber_list as $subscriber) {
|
|
|
|
$phids[] = $subscriber;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$phids = array_unique($phids);
|
|
|
|
$phids = array_filter($phids);
|
|
|
|
|
|
|
|
return $phids;
|
|
|
|
}
|
|
|
|
|
2016-06-22 14:35:40 +02:00
|
|
|
}
|