Page MenuHomestyx hydra

No OneTemporary

diff --git a/src/applications/maniphest/xaction/ManiphestTaskPointsTransaction.php b/src/applications/maniphest/xaction/ManiphestTaskPointsTransaction.php
index 3b24dff590..fae125dccd 100644
--- a/src/applications/maniphest/xaction/ManiphestTaskPointsTransaction.php
+++ b/src/applications/maniphest/xaction/ManiphestTaskPointsTransaction.php
@@ -1,131 +1,136 @@
<?php
final class ManiphestTaskPointsTransaction
extends ManiphestTaskTransactionType {
const TRANSACTIONTYPE = 'points';
public function generateOldValue($object) {
return $this->getValueForPoints($object->getPoints());
}
public function generateNewValue($object, $value) {
return $this->getValueForPoints($value);
}
public function applyInternalEffects($object, $value) {
$object->setPoints($value);
}
public function shouldHide() {
if (!ManiphestTaskPoints::getIsEnabled()) {
return true;
}
return false;
}
public function getTitle() {
$old = $this->getOldValue();
$new = $this->getNewValue();
if ($old === null) {
return pht(
'%s set the point value for this task to %s.',
$this->renderAuthor(),
$this->renderNewValue());
+ } else if ($new === null && $old !== null) {
+ return pht(
+ '%s removed the point value %s for this task.',
+ $this->renderAuthor(),
+ $this->renderOldValue());
} else if ($new === null) {
return pht(
'%s removed the point value for this task.',
$this->renderAuthor());
} else {
return pht(
'%s changed the point value for this task from %s to %s.',
$this->renderAuthor(),
$this->renderOldValue(),
$this->renderNewValue());
}
}
public function getTitleForFeed() {
$old = $this->getOldValue();
$new = $this->getNewValue();
if ($old === null) {
return pht(
'%s set the point value for %s to %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderNewValue());
} else if ($new === null) {
return pht(
'%s removed the point value for %s.',
$this->renderAuthor(),
$this->renderObject());
} else {
return pht(
'%s changed the point value for %s from %s to %s.',
$this->renderAuthor(),
$this->renderObject(),
$this->renderOldValue(),
$this->renderNewValue());
}
}
public function validateTransactions($object, array $xactions) {
$errors = array();
foreach ($xactions as $xaction) {
$new = $xaction->getNewValue();
if (strlen($new) && !is_numeric($new)) {
$errors[] = $this->newInvalidError(
pht('Points value must be numeric or empty.'));
continue;
}
if ((double)$new < 0) {
$errors[] = $this->newInvalidError(
pht('Points value must be nonnegative.'));
continue;
}
}
return $errors;
}
public function getIcon() {
return 'fa-calculator';
}
/**
* Normalize your Story Points from generic stuff to double or null.
* @param mixed $value Your raw Story Points
* @return double|null
*/
private function getValueForPoints($value) {
// The Point can be various types also thanks to Conduit API
// like integers, floats, null, and strings of course.
// Everything meaningful must be printable as a string.
$is_empty = phutil_string_cast($value) === '';
if ($is_empty) {
$value = null;
}
if ($value !== null) {
$value = (double)$value;
}
return $value;
}
public function getTransactionTypeForConduit($xaction) {
return 'points';
}
public function getFieldValuesForConduit($xaction, $data) {
return array(
'old' => $xaction->getOldValue(),
'new' => $xaction->getNewValue(),
);
}
}
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
index 5988970ca6..c437df82fb 100644
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
@@ -1,244 +1,250 @@
<?php
final class PhabricatorStandardCustomFieldDate
extends PhabricatorStandardCustomField {
public function getFieldType() {
return 'date';
}
public function buildFieldIndexes() {
$indexes = array();
$value = $this->getFieldValue();
if (phutil_nonempty_scalar($value)) {
$indexes[] = $this->newNumericIndex((int)$value);
}
return $indexes;
}
public function buildOrderIndex() {
return $this->newNumericIndex(0);
}
public function getValueForStorage() {
$value = $this->getFieldValue();
if (phutil_nonempty_scalar($value)) {
return (int)$value;
} else {
return null;
}
}
public function setValueFromStorage($value) {
if (phutil_nonempty_scalar($value)) {
$value = (int)$value;
} else {
$value = null;
}
return $this->setFieldValue($value);
}
public function renderEditControl(array $handles) {
return $this->newDateControl();
}
public function readValueFromRequest(AphrontRequest $request) {
$control = $this->newDateControl();
$control->setUser($request->getUser());
$value = $control->readValueFromRequest($request);
$this->setFieldValue($value);
}
public function renderPropertyViewValue(array $handles) {
$value = $this->getFieldValue();
if (!$value) {
return null;
}
return phabricator_datetime($value, $this->getViewer());
}
private function newDateControl() {
$control = id(new AphrontFormDateControl())
->setLabel($this->getFieldName())
->setName($this->getFieldKey())
->setUser($this->getViewer())
->setCaption($this->getCaption())
->setAllowNull(!$this->getRequired());
// If the value is already numeric, treat it as an epoch timestamp and set
// it directly. Otherwise, it's likely a field default, which we let users
// specify as a string. Parse the string into an epoch.
$value = $this->getFieldValue();
if ($value !== null && gettype($value) !== 'integer' &&
!ctype_digit($value)) {
$value = PhabricatorTime::parseLocalTime($value, $this->getViewer());
}
// If we don't have anything valid, make sure we pass `null`, since the
// control special-cases that.
$control->setValue(nonempty($value, null));
return $control;
}
public function readApplicationSearchValueFromRequest(
PhabricatorApplicationSearchEngine $engine,
AphrontRequest $request) {
$key = $this->getFieldKey();
return array(
'min' => $request->getStr($key.'.min'),
'max' => $request->getStr($key.'.max'),
);
}
public function applyApplicationSearchConstraintToQuery(
PhabricatorApplicationSearchEngine $engine,
PhabricatorCursorPagedPolicyAwareQuery $query,
$value) {
$viewer = $this->getViewer();
if (!is_array($value)) {
$value = array();
}
$min_str = idx($value, 'min', '');
if (phutil_nonempty_string($min_str)) {
$min = PhabricatorTime::parseLocalTime($min_str, $viewer);
} else {
$min = null;
}
$max_str = idx($value, 'max', '');
if (phutil_nonempty_string($max_str)) {
$max = PhabricatorTime::parseLocalTime($max_str, $viewer);
} else {
$max = null;
}
if (($min !== null) || ($max !== null)) {
$query->withApplicationSearchRangeConstraint(
$this->newNumericIndex(null),
$min,
$max);
}
}
public function appendToApplicationSearchForm(
PhabricatorApplicationSearchEngine $engine,
AphrontFormView $form,
$value) {
if (!is_array($value)) {
$value = array();
}
$form
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('%s After', $this->getFieldName()))
->setName($this->getFieldKey().'.min')
->setValue(idx($value, 'min', '')))
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('%s Before', $this->getFieldName()))
->setName($this->getFieldKey().'.max')
->setValue(idx($value, 'max', '')));
}
public function getApplicationTransactionTitle(
PhabricatorApplicationTransaction $xaction) {
$author_phid = $xaction->getAuthorPHID();
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();
$viewer = $this->getViewer();
$old_date = null;
if ($old) {
$old_date = phabricator_datetime($old, $viewer);
}
$new_date = null;
if ($new) {
$new_date = phabricator_datetime($new, $viewer);
}
if (!$old) {
return pht(
'%s set %s to %s.',
$xaction->renderHandleLink($author_phid),
$this->getFieldName(),
$new_date);
+ } else if (!$new && $old) {
+ return pht(
+ '%s removed %s which was set to %s.',
+ $xaction->renderHandleLink($author_phid),
+ $this->getFieldName(),
+ $old_date);
} else if (!$new) {
return pht(
'%s removed %s.',
$xaction->renderHandleLink($author_phid),
$this->getFieldName());
} else {
return pht(
'%s changed %s from %s to %s.',
$xaction->renderHandleLink($author_phid),
$this->getFieldName(),
$old_date,
$new_date);
}
}
public function getApplicationTransactionTitleForFeed(
PhabricatorApplicationTransaction $xaction) {
$viewer = $this->getViewer();
$author_phid = $xaction->getAuthorPHID();
$object_phid = $xaction->getObjectPHID();
$old = $xaction->getOldValue();
$new = $xaction->getNewValue();
if (!$old) {
return pht(
'%s set %s to %s on %s.',
$xaction->renderHandleLink($author_phid),
$this->getFieldName(),
phabricator_datetime($new, $viewer),
$xaction->renderHandleLink($object_phid));
} else if (!$new) {
return pht(
'%s removed %s on %s.',
$xaction->renderHandleLink($author_phid),
$this->getFieldName(),
$xaction->renderHandleLink($object_phid));
} else {
return pht(
'%s changed %s from %s to %s on %s.',
$xaction->renderHandleLink($author_phid),
$this->getFieldName(),
phabricator_datetime($old, $viewer),
phabricator_datetime($new, $viewer),
$xaction->renderHandleLink($object_phid));
}
}
protected function newConduitSearchParameterType() {
// TODO: Build a new "pair<epoch|null, epoch|null>" type or similar.
return null;
}
protected function newConduitEditParameterType() {
return id(new ConduitEpochParameterType())
->setAllowNull(!$this->getRequired());
}
protected function newExportFieldType() {
return new PhabricatorEpochExportField();
}
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Nov 25, 3:43 AM (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1168
Default Alt Text
(11 KB)

Event Timeline