Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/maniphest/conduit/ManiphestGetTaskTransactionsConduitAPIMethod.php b/src/applications/maniphest/conduit/ManiphestGetTaskTransactionsConduitAPIMethod.php
index 8b0d0496cf..357d118bc4 100644
--- a/src/applications/maniphest/conduit/ManiphestGetTaskTransactionsConduitAPIMethod.php
+++ b/src/applications/maniphest/conduit/ManiphestGetTaskTransactionsConduitAPIMethod.php
@@ -1,76 +1,86 @@
<?php
final class ManiphestGetTaskTransactionsConduitAPIMethod
extends ManiphestConduitAPIMethod {
public function getAPIMethodName() {
return 'maniphest.gettasktransactions';
}
public function getMethodDescription() {
return pht('Retrieve Maniphest task transactions.');
}
protected function defineParamTypes() {
return array(
'ids' => 'required list<int>',
);
}
protected function defineReturnType() {
return 'nonempty list<dict<string, wild>>';
}
+ public function getMethodStatus() {
+ return self::METHOD_STATUS_FROZEN;
+ }
+
+ public function getMethodStatusDescription() {
+ return pht(
+ 'This method is frozen and will eventually be deprecated. New code '.
+ 'should use "transaction.search" instead.');
+ }
+
protected function execute(ConduitAPIRequest $request) {
$results = array();
$task_ids = $request->getValue('ids');
if (!$task_ids) {
return $results;
}
$tasks = id(new ManiphestTaskQuery())
->setViewer($request->getUser())
->withIDs($task_ids)
->execute();
$tasks = mpull($tasks, null, 'getPHID');
$transactions = array();
if ($tasks) {
$transactions = id(new ManiphestTransactionQuery())
->setViewer($request->getUser())
->withObjectPHIDs(mpull($tasks, 'getPHID'))
->needComments(true)
->execute();
}
foreach ($transactions as $transaction) {
$task_phid = $transaction->getObjectPHID();
if (empty($tasks[$task_phid])) {
continue;
}
$task_id = $tasks[$task_phid]->getID();
$comments = null;
if ($transaction->hasComment()) {
$comments = $transaction->getComment()->getContent();
}
$results[$task_id][] = array(
'taskID' => $task_id,
'transactionID' => $transaction->getID(),
'transactionPHID' => $transaction->getPHID(),
'transactionType' => $transaction->getTransactionType(),
'oldValue' => $transaction->getOldValue(),
'newValue' => $transaction->getNewValue(),
'comments' => $comments,
'authorPHID' => $transaction->getAuthorPHID(),
'dateCreated' => $transaction->getDateCreated(),
);
}
return $results;
}
}
diff --git a/src/applications/maniphest/xaction/ManiphestTaskPriorityTransaction.php b/src/applications/maniphest/xaction/ManiphestTaskPriorityTransaction.php
index 2ed7c4e15b..83f38fc659 100644
--- a/src/applications/maniphest/xaction/ManiphestTaskPriorityTransaction.php
+++ b/src/applications/maniphest/xaction/ManiphestTaskPriorityTransaction.php
@@ -1,178 +1,175 @@
<?php
final class ManiphestTaskPriorityTransaction
extends ManiphestTaskTransactionType {
const TRANSACTIONTYPE = 'priority';
public function generateOldValue($object) {
- if ($this->isNewObject()) {
- return null;
- }
- return $object->getPriority();
+ return (string)$object->getPriority();
}
public function generateNewValue($object, $value) {
// `$value` is supposed to be a keyword, but if the priority
// assigned to a task has been removed from the config,
// no such keyword will be available. Other edits to the task
- // should still be allowed, even if the priority is no longer
+ // should still be allowed, even if the priority is no longer
// valid, so treat this as a no-op.
if ($value === ManiphestTaskPriority::UNKNOWN_PRIORITY_KEYWORD) {
- return $object->getPriority();
+ return (string)$object->getPriority();
}
return (string)ManiphestTaskPriority::getTaskPriorityFromKeyword($value);
}
public function applyInternalEffects($object, $value) {
$object->setPriority($value);
}
public function getActionStrength() {
return 1.1;
}
public function getActionName() {
$old = $this->getOldValue();
$new = $this->getNewValue();
if ($old == ManiphestTaskPriority::getDefaultPriority()) {
return pht('Triaged');
} else if ($old > $new) {
return pht('Lowered Priority');
} else {
return pht('Raised Priority');
}
}
public function getTitle() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$old_name = ManiphestTaskPriority::getTaskPriorityName($old);
$new_name = ManiphestTaskPriority::getTaskPriorityName($new);
if ($old == ManiphestTaskPriority::getDefaultPriority()) {
return pht(
'%s triaged this task as %s priority.',
$this->renderAuthor(),
$this->renderValue($new_name));
} else if ($old > $new) {
return pht(
'%s lowered the priority of this task from %s to %s.',
$this->renderAuthor(),
$this->renderValue($old_name),
$this->renderValue($new_name));
} else {
return pht(
'%s raised the priority of this task from %s to %s.',
$this->renderAuthor(),
$this->renderValue($old_name),
$this->renderValue($new_name));
}
}
public function getTitleForFeed() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$old_name = ManiphestTaskPriority::getTaskPriorityName($old);
$new_name = ManiphestTaskPriority::getTaskPriorityName($new);
if ($old == ManiphestTaskPriority::getDefaultPriority()) {
return pht(
'%s triaged %s as %s priority.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderValue($new_name));
} else if ($old > $new) {
return pht(
'%s lowered the priority of %s from %s to %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderValue($old_name),
$this->renderValue($new_name));
} else {
return pht(
'%s raised the priority of %s from %s to %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderValue($old_name),
$this->renderValue($new_name));
}
}
public function getIcon() {
$old = $this->getOldValue();
$new = $this->getNewValue();
if ($old == ManiphestTaskPriority::getDefaultPriority()) {
return 'fa-arrow-right';
} else if ($old > $new) {
return 'fa-arrow-down';
} else {
return 'fa-arrow-up';
}
}
public function getColor() {
$old = $this->getOldValue();
$new = $this->getNewValue();
if ($old == ManiphestTaskPriority::getDefaultPriority()) {
return 'green';
} else if ($old > $new) {
return 'grey';
} else {
return 'yellow';
}
}
public function validateTransactions($object, array $xactions) {
$errors = array();
$content_source = $this->getEditor()->getContentSource();
$is_web = ($content_source instanceof PhabricatorWebContentSource);
foreach ($xactions as $xaction) {
$value = $xaction->getNewValue();
// If this is a legitimate keyword like "low" or "high", this transaction
// is fine and apply normally.
$keyword = ManiphestTaskPriority::getTaskPriorityFromKeyword($value);
if ($keyword !== null) {
continue;
}
// If this is the magic "don't change things" value for editing tasks
// with an obsolete priority constant in the database, let it through if
// this is a web edit.
if ($value === ManiphestTaskPriority::UNKNOWN_PRIORITY_KEYWORD) {
if ($is_web) {
continue;
}
}
$keyword_list = array();
foreach (ManiphestTaskPriority::getTaskPriorityMap() as $pri => $name) {
$keyword = ManiphestTaskPriority::getKeywordForTaskPriority($pri);
if ($keyword === null) {
continue;
}
$keyword_list[] = $keyword;
}
$errors[] = $this->newInvalidError(
pht(
'Task priority "%s" is not a valid task priority. Use a priority '.
'keyword to choose a task priority: %s.',
$value,
implode(', ', $keyword_list)),
$xaction);
}
return $errors;
}
}
diff --git a/src/applications/maniphest/xaction/ManiphestTaskStatusTransaction.php b/src/applications/maniphest/xaction/ManiphestTaskStatusTransaction.php
index a3780e81b9..dd51a63799 100644
--- a/src/applications/maniphest/xaction/ManiphestTaskStatusTransaction.php
+++ b/src/applications/maniphest/xaction/ManiphestTaskStatusTransaction.php
@@ -1,243 +1,240 @@
<?php
final class ManiphestTaskStatusTransaction
extends ManiphestTaskTransactionType {
const TRANSACTIONTYPE = 'status';
public function generateOldValue($object) {
- if ($this->isNewObject()) {
- return null;
- }
return $object->getStatus();
}
public function applyInternalEffects($object, $value) {
$object->setStatus($value);
}
public function shouldHide() {
if ($this->getOldValue() === null) {
return true;
} else {
return false;
}
}
public function getActionStrength() {
return 1.3;
}
public function getActionName() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$action = ManiphestTaskStatus::getStatusActionName($new);
if ($action) {
return $action;
}
$old_closed = ManiphestTaskStatus::isClosedStatus($old);
$new_closed = ManiphestTaskStatus::isClosedStatus($new);
if ($new_closed && !$old_closed) {
return pht('Closed');
} else if (!$new_closed && $old_closed) {
return pht('Reopened');
} else {
return pht('Changed Status');
}
}
public function getTitle() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$old_closed = ManiphestTaskStatus::isClosedStatus($old);
$new_closed = ManiphestTaskStatus::isClosedStatus($new);
$old_name = ManiphestTaskStatus::getTaskStatusName($old);
$new_name = ManiphestTaskStatus::getTaskStatusName($new);
$commit_phid = $this->getMetadataValue('commitPHID');
if ($new_closed && !$old_closed) {
if ($new == ManiphestTaskStatus::getDuplicateStatus()) {
if ($commit_phid) {
return pht(
'%s closed this task as a duplicate by committing %s.',
$this->renderAuthor(),
$this->renderHandle($commit_phid));
} else {
return pht(
'%s closed this task as a duplicate.',
$this->renderAuthor());
}
} else {
if ($commit_phid) {
return pht(
'%s closed this task as %s by committing %s.',
$this->renderAuthor(),
$this->renderValue($new_name),
$this->renderHandle($commit_phid));
} else {
return pht(
'%s closed this task as %s.',
$this->renderAuthor(),
$this->renderValue($new_name));
}
}
} else if (!$new_closed && $old_closed) {
if ($commit_phid) {
return pht(
'%s reopened this task as %s by committing %s.',
$this->renderAuthor(),
$this->renderValue($new_name),
$this->renderHandle($commit_phid));
} else {
return pht(
'%s reopened this task as %s.',
$this->renderAuthor(),
$this->renderValue($new_name));
}
} else {
if ($commit_phid) {
return pht(
'%s changed the task status from %s to %s by committing %s.',
$this->renderAuthor(),
$this->renderValue($old_name),
$this->renderValue($new_name),
$this->renderHandle($commit_phid));
} else {
return pht(
'%s changed the task status from %s to %s.',
$this->renderAuthor(),
$this->renderValue($old_name),
$this->renderValue($new_name));
}
}
}
public function getTitleForFeed() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$old_closed = ManiphestTaskStatus::isClosedStatus($old);
$new_closed = ManiphestTaskStatus::isClosedStatus($new);
$old_name = ManiphestTaskStatus::getTaskStatusName($old);
$new_name = ManiphestTaskStatus::getTaskStatusName($new);
$commit_phid = $this->getMetadataValue('commitPHID');
if ($new_closed && !$old_closed) {
if ($new == ManiphestTaskStatus::getDuplicateStatus()) {
if ($commit_phid) {
return pht(
'%s closed %s as a duplicate by committing %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderHandle($commit_phid));
} else {
return pht(
'%s closed %s as a duplicate.',
$this->renderAuthor(),
$this->renderObject());
}
} else {
if ($commit_phid) {
return pht(
'%s closed %s as %s by committing %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderValue($new_name),
$this->renderHandle($commit_phid));
} else {
return pht(
'%s closed %s as %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderValue($new_name));
}
}
} else if (!$new_closed && $old_closed) {
if ($commit_phid) {
return pht(
'%s reopened %s as %s by committing %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderValue($new_name),
$this->renderHandle($commit_phid));
} else {
return pht(
'%s reopened %s as "%s".',
$this->renderAuthor(),
$this->renderObject(),
$new_name);
}
} else {
if ($commit_phid) {
return pht(
'%s changed the status of %s from %s to %s by committing %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderValue($old_name),
$this->renderValue($new_name),
$this->renderHandle($commit_phid));
} else {
return pht(
'%s changed the status of %s from %s to %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderValue($old_name),
$this->renderValue($new_name));
}
}
}
public function getIcon() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$action = ManiphestTaskStatus::getStatusIcon($new);
if ($action !== null) {
return $action;
}
if (ManiphestTaskStatus::isClosedStatus($new)) {
return 'fa-check';
} else {
return 'fa-pencil';
}
}
public function getColor() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$color = ManiphestTaskStatus::getStatusColor($new);
if ($color !== null) {
return $color;
}
if (ManiphestTaskStatus::isOpenStatus($new)) {
return 'green';
} else {
return 'indigo';
}
}
public function getTransactionTypeForConduit($xaction) {
return 'status';
}
public function getFieldValuesForConduit($xaction, $data) {
return array(
'old' => $xaction->getOldValue(),
'new' => $xaction->getNewValue(),
);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Wed, Apr 30, 4:55 AM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
108558
Default Alt Text
(15 KB)

Event Timeline