Differential D14811 Diff 35807 src/applications/transactions/storage/PhabricatorApplicationTransaction.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/storage/PhabricatorApplicationTransaction.php
Show First 20 Lines • Show All 475 Lines • ▼ Show 20 Lines | public function shouldHide() { | ||||
if ($this->hasComment()) { | if ($this->hasComment()) { | ||||
return false; | return false; | ||||
} | } | ||||
// Hide creation transactions if the old value is empty. These are | // Hide creation transactions if the old value is empty. These are | ||||
// transactions like "alice set the task tile to: ...", which are | // transactions like "alice set the task tile to: ...", which are | ||||
// essentially never interesting. | // essentially never interesting. | ||||
if ($this->getIsCreateTransaction()) { | if ($this->getIsCreateTransaction()) { | ||||
switch ($this->getTransactionType()) { | |||||
case PhabricatorTransactions::TYPE_VIEW_POLICY: | |||||
case PhabricatorTransactions::TYPE_EDIT_POLICY: | |||||
case PhabricatorTransactions::TYPE_JOIN_POLICY: | |||||
case PhabricatorTransactions::TYPE_SPACE: | |||||
break; | |||||
default: | |||||
$old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
if (is_array($old) && !$old) { | if (is_array($old) && !$old) { | ||||
return true; | return true; | ||||
} | } | ||||
if (!strlen($old)) { | if (!strlen($old)) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
} | |||||
// Hide creation transactions setting values to defaults, even if | // Hide creation transactions setting values to defaults, even if | ||||
// the old value is not empty. For example, tasks may have a global | // the old value is not empty. For example, tasks may have a global | ||||
// default view policy of "All Users", but a particular form sets the | // default view policy of "All Users", but a particular form sets the | ||||
// policy to "Administrators". The transaction corresponding to this | // policy to "Administrators". The transaction corresponding to this | ||||
// change is not interesting, since it is the default behavior of the | // change is not interesting, since it is the default behavior of the | ||||
// form. | // form. | ||||
if ($this->getIsCreateTransaction()) { | if ($this->getIsCreateTransaction()) { | ||||
if ($this->getIsDefaultTransaction()) { | if ($this->getIsDefaultTransaction()) { | ||||
return true; | return true; | ||||
} | } | ||||
} | } | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhabricatorTransactions::TYPE_VIEW_POLICY: | case PhabricatorTransactions::TYPE_VIEW_POLICY: | ||||
case PhabricatorTransactions::TYPE_EDIT_POLICY: | case PhabricatorTransactions::TYPE_EDIT_POLICY: | ||||
case PhabricatorTransactions::TYPE_JOIN_POLICY: | case PhabricatorTransactions::TYPE_JOIN_POLICY: | ||||
case PhabricatorTransactions::TYPE_SPACE: | case PhabricatorTransactions::TYPE_SPACE: | ||||
if ($this->getIsCreateTransaction()) { | |||||
break; | |||||
} | |||||
// TODO: Remove this eventually, this is handling old changes during | |||||
// object creation prior to the introduction of "create" and "default" | |||||
// transaction display flags. | |||||
if ($this->getOldValue() === null) { | if ($this->getOldValue() === null) { | ||||
return true; | return true; | ||||
} else { | } else { | ||||
return false; | return false; | ||||
} | } | ||||
break; | break; | ||||
case PhabricatorTransactions::TYPE_CUSTOMFIELD: | case PhabricatorTransactions::TYPE_CUSTOMFIELD: | ||||
$field = $this->getTransactionCustomField(); | $field = $this->getTransactionCustomField(); | ||||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | public function getTitle() { | ||||
$new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
case PhabricatorTransactions::TYPE_COMMENT: | case PhabricatorTransactions::TYPE_COMMENT: | ||||
return pht( | return pht( | ||||
'%s added a comment.', | '%s added a comment.', | ||||
$this->renderHandleLink($author_phid)); | $this->renderHandleLink($author_phid)); | ||||
case PhabricatorTransactions::TYPE_VIEW_POLICY: | case PhabricatorTransactions::TYPE_VIEW_POLICY: | ||||
if ($this->getIsCreateTransaction()) { | |||||
return pht( | |||||
'%s created this object with visibility "%s".', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderPolicyName($new, 'new')); | |||||
} else { | |||||
return pht( | return pht( | ||||
'%s changed the visibility from "%s" to "%s".', | '%s changed the visibility from "%s" to "%s".', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->renderPolicyName($old, 'old'), | $this->renderPolicyName($old, 'old'), | ||||
$this->renderPolicyName($new, 'new')); | $this->renderPolicyName($new, 'new')); | ||||
} | |||||
case PhabricatorTransactions::TYPE_EDIT_POLICY: | case PhabricatorTransactions::TYPE_EDIT_POLICY: | ||||
if ($this->getIsCreateTransaction()) { | |||||
return pht( | |||||
'%s created this object with edit policy "%s".', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderPolicyName($new, 'new')); | |||||
} else { | |||||
return pht( | return pht( | ||||
'%s changed the edit policy from "%s" to "%s".', | '%s changed the edit policy from "%s" to "%s".', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->renderPolicyName($old, 'old'), | $this->renderPolicyName($old, 'old'), | ||||
$this->renderPolicyName($new, 'new')); | $this->renderPolicyName($new, 'new')); | ||||
} | |||||
case PhabricatorTransactions::TYPE_JOIN_POLICY: | case PhabricatorTransactions::TYPE_JOIN_POLICY: | ||||
if ($this->getIsCreateTransaction()) { | |||||
return pht( | |||||
'%s created this object with join policy "%s".', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderPolicyName($new, 'new')); | |||||
} else { | |||||
return pht( | return pht( | ||||
'%s changed the join policy from "%s" to "%s".', | '%s changed the join policy from "%s" to "%s".', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->renderPolicyName($old, 'old'), | $this->renderPolicyName($old, 'old'), | ||||
$this->renderPolicyName($new, 'new')); | $this->renderPolicyName($new, 'new')); | ||||
} | |||||
case PhabricatorTransactions::TYPE_SPACE: | case PhabricatorTransactions::TYPE_SPACE: | ||||
if ($this->getIsCreateTransaction()) { | |||||
return pht( | |||||
'%s created this object in space %s.', | |||||
$this->renderHandleLink($author_phid), | |||||
$this->renderHandleLink($new)); | |||||
} else { | |||||
return pht( | return pht( | ||||
'%s shifted this object from the %s space to the %s space.', | '%s shifted this object from the %s space to the %s space.', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
$this->renderHandleLink($old), | $this->renderHandleLink($old), | ||||
$this->renderHandleLink($new)); | $this->renderHandleLink($new)); | ||||
} | |||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS: | case PhabricatorTransactions::TYPE_SUBSCRIBERS: | ||||
$add = array_diff($new, $old); | $add = array_diff($new, $old); | ||||
$rem = array_diff($old, $new); | $rem = array_diff($old, $new); | ||||
if ($add && $rem) { | if ($add && $rem) { | ||||
return pht( | return pht( | ||||
'%s edited subscriber(s), added %d: %s; removed %d: %s.', | '%s edited subscriber(s), added %d: %s; removed %d: %s.', | ||||
$this->renderHandleLink($author_phid), | $this->renderHandleLink($author_phid), | ||||
▲ Show 20 Lines • Show All 617 Lines • Show Last 20 Lines |