Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2680818
D25558.1734627232.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
7 KB
Referenced Files
None
Subscribers
None
D25558.1734627232.diff
View Options
diff --git a/src/deepclone/controller/DeepcloneController.php b/src/deepclone/controller/DeepcloneController.php
--- a/src/deepclone/controller/DeepcloneController.php
+++ b/src/deepclone/controller/DeepcloneController.php
@@ -12,9 +12,11 @@
return new Aphront404Response();
}
- $task = id(new ManiphestTaskQuery())
+ $query = new ManiphestTaskQuery();
+ $task = $query
->setViewer($viewer)
->withPHIDs(array($task_id))
+ ->withOpenSubtasks(true)
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
@@ -29,83 +31,14 @@
return new Aphront404Response();
}
+ $transactions = id(new ManiphestTransactionQuery())
+ ->setViewer($request->getUser())
+ ->withObjectPHIDs(mpull([$task], 'getPHID'))
+ ->needComments(true)
+ ->execute();
+
if ($request->isFormPost()) {
- return $this->triggerTransaction($request, $task);
- // $properties = $provider->readFormValuesFromRequest($request);
- // list($errors, $issues, $properties) = $provider->processEditForm(
- // $request,
- // $properties);
-
- // $xactions = array();
-
- // if (!$errors) {
- // if ($is_new) {
- // if (!phutil_nonempty_string($config->getProviderType())) {
- // $config->setProviderType($provider->getProviderType());
- // }
- // if (!phutil_nonempty_string($config->getProviderDomain())) {
- // $config->setProviderDomain($provider->getProviderDomain());
- // }
- // }
-
- // $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
- // ->setTransactionType(
- // PhabricatorAuthProviderConfigTransaction::TYPE_LOGIN)
- // ->setNewValue($request->getInt('allowLogin', 0));
-
- // $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
- // ->setTransactionType(
- // PhabricatorAuthProviderConfigTransaction::TYPE_REGISTRATION)
- // ->setNewValue($request->getInt('allowRegistration', 0));
-
- // $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
- // ->setTransactionType(
- // PhabricatorAuthProviderConfigTransaction::TYPE_LINK)
- // ->setNewValue($request->getInt('allowLink', 0));
-
- // $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
- // ->setTransactionType(
- // PhabricatorAuthProviderConfigTransaction::TYPE_UNLINK)
- // ->setNewValue($request->getInt('allowUnlink', 0));
-
- // $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
- // ->setTransactionType(
- // PhabricatorAuthProviderConfigTransaction::TYPE_TRUST_EMAILS)
- // ->setNewValue($request->getInt('trustEmails', 0));
-
- // if ($provider->supportsAutoLogin()) {
- // $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
- // ->setTransactionType(
- // PhabricatorAuthProviderConfigTransaction::TYPE_AUTO_LOGIN)
- // ->setNewValue($request->getInt('autoLogin', 0));
- // }
-
- // foreach ($properties as $key => $value) {
- // $xactions[] = id(new PhabricatorAuthProviderConfigTransaction())
- // ->setTransactionType(
- // PhabricatorAuthProviderConfigTransaction::TYPE_PROPERTY)
- // ->setMetadataValue('auth:property', $key)
- // ->setNewValue($value);
- // }
-
- // if ($is_new) {
- // $config->save();
- // }
-
- // $editor = id(new PhabricatorAuthProviderConfigEditor())
- // ->setActor($viewer)
- // ->setContentSourceFromRequest($request)
- // ->setContinueOnNoEffect(true);
-
- // try {
- // $editor->applyTransactions($config, $xactions);
- // $next_uri = $config->getURI();
-
- // return id(new AphrontRedirectResponse())->setURI($next_uri);
- // } catch (Exception $ex) {
- // $validation_exception = $ex;
- // }
- // }
+ return $this->triggerTransaction($request, $task, $transactions);
} else {
return $this->buildForm($task);
}
@@ -121,18 +54,14 @@
->addCheckbox(
'copy_comments',
1,
- pht('Copy all the comments of the task/s to the new task/s'),
- )
- )
+ pht('Copy all the comments of the task/s to the new task/s')))
->appendChild(
id(new AphrontFormCheckboxControl())
->setLabel('Deep Clone Task')
->addCheckbox(
'deep_clone',
1,
- 'Create a clone of all the sub tasks of this task',
- )
- );
+ 'Create a clone of all the sub tasks of this task'));
$handle = $this->getHandle($task);
@@ -178,12 +107,61 @@
return $handle;
}
- private function triggerTransaction(AphrontRequest $request, ManiphestTask $task) {
- $deepCloneRaw = $request->getStr('deep_clone');
- $deepClone = $deepCloneRaw === '1';
- $copyCommentsRaw = $request->getStr('copy_comments');
- $copyComments = $copyCommentsRaw === '1';
+ private function triggerTransaction(
+ AphrontRequest $request,
+ ManiphestTask $task,
+ array $transactions) {
+ $deep_clone = $request->getStr('deep_clone') === '1';
+ $copy_comments = $request->getStr('copy_comments') === '1';
+
+ $task_clone = new ManiphestTask();
+
+ $task_clone->setTitle($task->getTitle());
+ $task_clone->setDescription($task->getDescription());
+ $task_clone->setAuthorPHID($task->getAuthorPHID());
+ $task_clone->setOwnerPHID($task->getOwnerPHID());
+ $task_clone->setStatus($task->getStatus());
+ $task_clone->setPriority(ManiphestTaskPriority::getDefaultPriority());
+ $task_clone->setSubtype($task->getSubtype());
+ $task_clone->setViewPolicy($task->getViewPolicy());
+ $task_clone->setEditPolicy($task->getEditPolicy());
+
+ $task_clone->save();
+
+ $xactions = [];
+
+ $xactions[] = id(new ManiphestTransaction())
+ ->setTransactionType(PhabricatorCoreCreateTransaction::TRANSACTIONTYPE);
+ $xactions[] = id(new ManiphestTransaction())
+ ->setTransactionType(ManiphestTaskPriorityTransaction::TRANSACTIONTYPE)
+ ->setNewValue(
+ $task->getPriorityKeyword());
+
+ foreach ($transactions as &$transaction) {
+ if ($transaction->getTransactionType() !== 'core:comment') {
+ continue;
+ }
+
+ if ($copy_comments === false) {
+ continue;
+ }
+
+ $transaction_clone = id(new ManiphestTransaction())
+ ->setTransactionType(PhabricatorTransactions::TYPE_COMMENT);
+
+ $transaction_clone->attachComment(
+ id(new ManiphestTransactionComment())
+ ->setContent($transaction->getComment()->getContent()));
+
+ $xactions[] = $transaction_clone;
+ }
+
+ id(new ManiphestTransactionEditor())
+ ->setActor($this->getViewer())
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->applyTransactions($task_clone, $xactions);
- throw new Exception("Deep Clone $deepClone $deepCloneRaw Copy Comments $copyComments $copyCommentsRaw");
+ return id(new AphrontRedirectResponse())->setURI($task_clone->getURI());
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Dec 19, 16:53 (9 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1015173
Default Alt Text
D25558.1734627232.diff (7 KB)
Attached To
Mode
D25558: Initial work
Attached
Detach File
Event Timeline
Log In to Comment