2012-12-11 13:59:20 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
abstract class PhabricatorApplicationTransaction
|
|
|
|
extends PhabricatorLiskDAO
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
implements PhabricatorPolicyInterface {
|
2012-12-11 13:59:20 -08:00
|
|
|
|
2012-12-11 14:00:07 -08:00
|
|
|
const TARGET_TEXT = 'text';
|
|
|
|
const TARGET_HTML = 'html';
|
|
|
|
|
2012-12-11 13:59:20 -08:00
|
|
|
protected $phid;
|
|
|
|
protected $objectPHID;
|
|
|
|
protected $authorPHID;
|
|
|
|
protected $viewPolicy;
|
|
|
|
protected $editPolicy;
|
|
|
|
|
|
|
|
protected $commentPHID;
|
|
|
|
protected $commentVersion = 0;
|
|
|
|
protected $transactionType;
|
|
|
|
protected $oldValue;
|
|
|
|
protected $newValue;
|
2013-03-28 08:34:34 -07:00
|
|
|
protected $metadata = array();
|
2012-12-11 13:59:20 -08:00
|
|
|
|
|
|
|
protected $contentSource;
|
|
|
|
|
|
|
|
private $comment;
|
|
|
|
private $commentNotLoaded;
|
|
|
|
|
|
|
|
private $handles;
|
2012-12-11 14:00:07 -08:00
|
|
|
private $renderingTarget = self::TARGET_HTML;
|
2013-03-09 19:23:50 -08:00
|
|
|
private $transactionGroup = array();
|
2012-12-11 13:59:20 -08:00
|
|
|
|
|
|
|
abstract public function getApplicationTransactionType();
|
2013-08-20 10:04:33 -07:00
|
|
|
|
|
|
|
private function getApplicationObjectTypeName() {
|
|
|
|
$types = PhabricatorPHIDType::getAllTypes();
|
|
|
|
|
|
|
|
$type = idx($types, $this->getApplicationTransactionType());
|
|
|
|
if ($type) {
|
|
|
|
return $type->getTypeName();
|
|
|
|
}
|
|
|
|
|
|
|
|
return pht('Object');
|
|
|
|
}
|
2012-12-11 13:59:20 -08:00
|
|
|
|
2013-08-20 10:00:25 -07:00
|
|
|
public function getApplicationTransactionCommentObject() {
|
|
|
|
throw new Exception("Not implemented!");
|
|
|
|
}
|
|
|
|
|
2013-03-09 19:23:50 -08:00
|
|
|
public function getApplicationTransactionViewObject() {
|
|
|
|
return new PhabricatorApplicationTransactionView();
|
|
|
|
}
|
|
|
|
|
2013-03-28 08:34:34 -07:00
|
|
|
public function getMetadataValue($key, $default = null) {
|
|
|
|
return idx($this->metadata, $key, $default);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setMetadataValue($key, $value) {
|
|
|
|
$this->metadata[$key] = $value;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
2012-12-11 13:59:20 -08:00
|
|
|
public function generatePHID() {
|
2013-07-29 06:51:19 -07:00
|
|
|
$type = PhabricatorApplicationTransactionPHIDTypeTransaction::TYPECONST;
|
2012-12-11 13:59:20 -08:00
|
|
|
$subtype = $this->getApplicationTransactionType();
|
|
|
|
|
|
|
|
return PhabricatorPHID::generateNewPHID($type, $subtype);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getConfiguration() {
|
|
|
|
return array(
|
|
|
|
self::CONFIG_AUX_PHID => true,
|
|
|
|
self::CONFIG_SERIALIZATION => array(
|
|
|
|
'oldValue' => self::SERIALIZATION_JSON,
|
|
|
|
'newValue' => self::SERIALIZATION_JSON,
|
2013-03-28 08:34:34 -07:00
|
|
|
'metadata' => self::SERIALIZATION_JSON,
|
2012-12-11 13:59:20 -08:00
|
|
|
),
|
|
|
|
) + parent::getConfiguration();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setContentSource(PhabricatorContentSource $content_source) {
|
|
|
|
$this->contentSource = $content_source->serialize();
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getContentSource() {
|
|
|
|
return PhabricatorContentSource::newFromSerialized($this->contentSource);
|
|
|
|
}
|
|
|
|
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
public function hasComment() {
|
|
|
|
return $this->getComment() && strlen($this->getComment()->getContent());
|
|
|
|
}
|
|
|
|
|
2012-12-11 13:59:20 -08:00
|
|
|
public function getComment() {
|
|
|
|
if ($this->commentNotLoaded) {
|
|
|
|
throw new Exception("Comment for this transaction was not loaded.");
|
|
|
|
}
|
|
|
|
return $this->comment;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function attachComment(
|
|
|
|
PhabricatorApplicationTransactionComment $comment) {
|
|
|
|
$this->comment = $comment;
|
|
|
|
$this->commentNotLoaded = false;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setCommentNotLoaded($not_loaded) {
|
|
|
|
$this->commentNotLoaded = $not_loaded;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -( Rendering )---------------------------------------------------------- */
|
|
|
|
|
2012-12-11 14:00:07 -08:00
|
|
|
public function setRenderingTarget($rendering_target) {
|
|
|
|
$this->renderingTarget = $rendering_target;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRenderingTarget() {
|
|
|
|
return $this->renderingTarget;
|
|
|
|
}
|
|
|
|
|
2012-12-11 13:59:20 -08:00
|
|
|
public function getRequiredHandlePHIDs() {
|
|
|
|
$phids = array();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$phids[] = array($this->getAuthorPHID());
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
|
|
|
$phids[] = $old;
|
|
|
|
$phids[] = $new;
|
|
|
|
break;
|
2013-03-28 08:34:34 -07:00
|
|
|
case PhabricatorTransactions::TYPE_EDGE:
|
|
|
|
$phids[] = ipull($old, 'dst');
|
|
|
|
$phids[] = ipull($new, 'dst');
|
|
|
|
break;
|
2013-05-26 08:43:09 -07:00
|
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
|
|
if (!PhabricatorPolicyQuery::isGlobalPolicy($old)) {
|
|
|
|
$phids[] = array($old);
|
|
|
|
}
|
|
|
|
if (!PhabricatorPolicyQuery::isGlobalPolicy($new)) {
|
|
|
|
$phids[] = array($new);
|
|
|
|
}
|
|
|
|
break;
|
2012-12-11 13:59:20 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return array_mergev($phids);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setHandles(array $handles) {
|
|
|
|
$this->handles = $handles;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getHandle($phid) {
|
|
|
|
if (empty($this->handles[$phid])) {
|
|
|
|
throw new Exception(
|
|
|
|
"Transaction requires a handle ('{$phid}') it did not load.");
|
|
|
|
}
|
|
|
|
return $this->handles[$phid];
|
|
|
|
}
|
|
|
|
|
2013-05-26 09:51:14 -07:00
|
|
|
public function getHandleIfExists($phid) {
|
|
|
|
return idx($this->handles, $phid);
|
|
|
|
}
|
|
|
|
|
2013-01-24 17:23:05 -08:00
|
|
|
public function getHandles() {
|
|
|
|
if ($this->handles === null) {
|
|
|
|
throw new Exception(
|
|
|
|
'Transaction requires handles and it did not load them.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return $this->handles;
|
|
|
|
}
|
|
|
|
|
2013-06-18 10:02:34 -07:00
|
|
|
public function renderHandleLink($phid) {
|
2012-12-11 14:00:07 -08:00
|
|
|
if ($this->renderingTarget == self::TARGET_HTML) {
|
|
|
|
return $this->getHandle($phid)->renderLink();
|
|
|
|
} else {
|
2013-02-13 14:50:15 -08:00
|
|
|
return hsprintf('%s', $this->getHandle($phid)->getName());
|
2012-12-11 14:00:07 -08:00
|
|
|
}
|
2012-12-11 13:59:20 -08:00
|
|
|
}
|
|
|
|
|
2013-06-18 10:02:34 -07:00
|
|
|
public function renderHandleList(array $phids) {
|
2012-12-11 13:59:20 -08:00
|
|
|
$links = array();
|
|
|
|
foreach ($phids as $phid) {
|
|
|
|
$links[] = $this->renderHandleLink($phid);
|
|
|
|
}
|
2013-02-13 14:50:15 -08:00
|
|
|
return phutil_implode_html(', ', $links);
|
2012-12-11 13:59:20 -08:00
|
|
|
}
|
|
|
|
|
2012-12-11 13:59:35 -08:00
|
|
|
public function getIcon() {
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorTransactions::TYPE_COMMENT:
|
|
|
|
return 'comment';
|
|
|
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
|
|
|
return 'message';
|
|
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
|
|
return 'lock';
|
2013-03-28 08:34:34 -07:00
|
|
|
case PhabricatorTransactions::TYPE_EDGE:
|
|
|
|
return 'link';
|
Modernize Macro application
Summary: Adds feed, email, notifications, comments, partial editing, subscriptions, enable/disable, flags and crumbs to Macro.
Test Plan:
{F26839}
{F26840}
{F26841}
{F26842}
{F26843}
{F26844}
{F26845}
Reviewers: vrana, btrahan, chad
Reviewed By: vrana
CC: aran
Maniphest Tasks: T2157, T175, T2104
Differential Revision: https://secure.phabricator.com/D4141
2012-12-11 14:01:03 -08:00
|
|
|
}
|
|
|
|
|
2012-12-11 13:59:35 -08:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getColor() {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2012-12-11 13:59:20 -08:00
|
|
|
public function shouldHide() {
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
|
|
if ($this->getOldValue() === null) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-07-29 08:38:25 -07:00
|
|
|
public function shouldHideForMail() {
|
|
|
|
return $this->shouldHide();
|
|
|
|
}
|
|
|
|
|
Add ApplicationTransaction handling for transactions with no effect
Summary:
When a user submits an action with no effect (like an empty comment, an "abandon" on an already-accepted revision, or a "close, resolved" on a closed task) we want to alert them that their action isn't effective. These warnings fall into two general buckets:
- User is submitting two or more actions, and some aren't effective but some are. Prompt them to apply the effective actions only.
- A special case of this is where the only effective action is a comment. We provide tailored text ("Post Comment") in this case.
- User is submitting one action, which isn't effective. Tell them they're out of luck.
- A special case of this is an empty comment. We provide tailored text in this case.
By default, the transaction editor throws when transactions have no effect. The caller can then deal with this, or use `PhabricatorApplicationTransactionNoEffectResponse` to provide a standard dialog that gives the user information as above. For cases where we expect transactions to have no effect (notably, "edit" forms) we just continue on no-effect unconditionally.
Also fix an issue where new, combined or filtered transactions would not be represented properly in the Ajax response (i.e., return final transactions from `applyTransactions()`), and translate some strings.
Test Plan:
- Submitted empty and nonempy comments in Macro and Pholio.
- Submitted comments with new and existing "@mentions".
- Submitted edits in both applications.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T912, T2104
Differential Revision: https://secure.phabricator.com/D4160
2012-12-11 17:27:40 -08:00
|
|
|
public function getNoEffectDescription() {
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorTransactions::TYPE_COMMENT:
|
|
|
|
return pht('You can not post an empty comment.');
|
|
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
|
|
return pht(
|
|
|
|
'This %s already has that view policy.',
|
|
|
|
$this->getApplicationObjectTypeName());
|
|
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
|
|
return pht(
|
|
|
|
'This %s already has that edit policy.',
|
|
|
|
$this->getApplicationObjectTypeName());
|
|
|
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
|
|
|
return pht(
|
|
|
|
'All users are already subscribed to this %s.',
|
|
|
|
$this->getApplicationObjectTypeName());
|
2013-03-28 08:34:34 -07:00
|
|
|
case PhabricatorTransactions::TYPE_EDGE:
|
|
|
|
return pht('Edges already exist; transaction has no effect.');
|
Add ApplicationTransaction handling for transactions with no effect
Summary:
When a user submits an action with no effect (like an empty comment, an "abandon" on an already-accepted revision, or a "close, resolved" on a closed task) we want to alert them that their action isn't effective. These warnings fall into two general buckets:
- User is submitting two or more actions, and some aren't effective but some are. Prompt them to apply the effective actions only.
- A special case of this is where the only effective action is a comment. We provide tailored text ("Post Comment") in this case.
- User is submitting one action, which isn't effective. Tell them they're out of luck.
- A special case of this is an empty comment. We provide tailored text in this case.
By default, the transaction editor throws when transactions have no effect. The caller can then deal with this, or use `PhabricatorApplicationTransactionNoEffectResponse` to provide a standard dialog that gives the user information as above. For cases where we expect transactions to have no effect (notably, "edit" forms) we just continue on no-effect unconditionally.
Also fix an issue where new, combined or filtered transactions would not be represented properly in the Ajax response (i.e., return final transactions from `applyTransactions()`), and translate some strings.
Test Plan:
- Submitted empty and nonempy comments in Macro and Pholio.
- Submitted comments with new and existing "@mentions".
- Submitted edits in both applications.
Reviewers: btrahan, vrana
Reviewed By: btrahan
CC: aran
Maniphest Tasks: T912, T2104
Differential Revision: https://secure.phabricator.com/D4160
2012-12-11 17:27:40 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return pht('Transaction has no effect.');
|
|
|
|
}
|
|
|
|
|
2012-12-11 13:59:20 -08:00
|
|
|
public function getTitle() {
|
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorTransactions::TYPE_COMMENT:
|
|
|
|
return pht(
|
|
|
|
'%s added a comment.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
|
|
return pht(
|
|
|
|
'%s changed the visibility of this %s from "%s" to "%s".',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->getApplicationObjectTypeName(),
|
2013-05-26 09:51:14 -07:00
|
|
|
PhabricatorPolicy::newFromPolicyAndHandle(
|
|
|
|
$old,
|
|
|
|
$this->getHandleIfExists($old))->renderDescription(),
|
|
|
|
PhabricatorPolicy::newFromPolicyAndHandle(
|
|
|
|
$new,
|
|
|
|
$this->getHandleIfExists($new))->renderDescription());
|
2012-12-11 13:59:20 -08:00
|
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
|
|
return pht(
|
|
|
|
'%s changed the edit policy of this %s from "%s" to "%s".',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->getApplicationObjectTypeName(),
|
2013-05-26 09:51:14 -07:00
|
|
|
PhabricatorPolicy::newFromPolicyAndHandle(
|
|
|
|
$old,
|
|
|
|
$this->getHandleIfExists($old))->renderDescription(),
|
|
|
|
PhabricatorPolicy::newFromPolicyAndHandle(
|
|
|
|
$new,
|
|
|
|
$this->getHandleIfExists($new))->renderDescription());
|
2012-12-11 13:59:20 -08:00
|
|
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
|
|
|
$add = array_diff($new, $old);
|
|
|
|
$rem = array_diff($old, $new);
|
|
|
|
|
|
|
|
if ($add && $rem) {
|
|
|
|
return pht(
|
|
|
|
'%s edited subscriber(s), added %d: %s; removed %d: %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($add),
|
|
|
|
$this->renderHandleList($add),
|
|
|
|
count($rem),
|
|
|
|
$this->renderHandleList($rem));
|
|
|
|
} else if ($add) {
|
|
|
|
return pht(
|
|
|
|
'%s added %d subscriber(s): %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($add),
|
|
|
|
$this->renderHandleList($add));
|
|
|
|
} else {
|
|
|
|
return pht(
|
2013-02-17 09:13:40 -08:00
|
|
|
'%s removed %d subscriber(s): %s.',
|
2012-12-11 13:59:20 -08:00
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($rem),
|
|
|
|
$this->renderHandleList($rem));
|
|
|
|
}
|
|
|
|
break;
|
2013-03-28 08:34:34 -07:00
|
|
|
case PhabricatorTransactions::TYPE_EDGE:
|
2013-07-19 15:59:29 -07:00
|
|
|
$new = ipull($new, 'dst');
|
|
|
|
$old = ipull($old, 'dst');
|
|
|
|
$add = array_diff($new, $old);
|
|
|
|
$rem = array_diff($old, $new);
|
2013-03-28 08:34:34 -07:00
|
|
|
$type = $this->getMetadata('edge:type');
|
2013-07-19 15:59:29 -07:00
|
|
|
$type = head($type);
|
|
|
|
|
|
|
|
if ($add && $rem) {
|
|
|
|
$string = PhabricatorEdgeConfig::getEditStringForEdgeType($type);
|
|
|
|
return pht(
|
|
|
|
$string,
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($add),
|
|
|
|
$this->renderHandleList($add),
|
|
|
|
count($rem),
|
|
|
|
$this->renderHandleList($rem));
|
|
|
|
} else if ($add) {
|
|
|
|
$string = PhabricatorEdgeConfig::getAddStringForEdgeType($type);
|
|
|
|
return pht(
|
|
|
|
$string,
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($add),
|
|
|
|
$this->renderHandleList($add));
|
|
|
|
} else {
|
|
|
|
$string = PhabricatorEdgeConfig::getRemoveStringForEdgeType($type);
|
|
|
|
return pht(
|
|
|
|
$string,
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
count($rem),
|
|
|
|
$this->renderHandleList($rem));
|
|
|
|
}
|
|
|
|
|
2013-09-23 14:29:40 -07:00
|
|
|
case PhabricatorTransactions::TYPE_CUSTOMFIELD:
|
|
|
|
$key = $this->getMetadataValue('customfield:key');
|
|
|
|
$field = PhabricatorCustomField::getObjectField(
|
|
|
|
// TODO: This is a giant hack, but we currently don't have a way to
|
|
|
|
// get the contextual object and this pathway is only hit by
|
|
|
|
// Maniphest. We should provide a way to get the actual object here.
|
|
|
|
new ManiphestTask(),
|
|
|
|
PhabricatorCustomField::ROLE_APPLICATIONTRANSACTIONS,
|
|
|
|
$key);
|
|
|
|
if ($field) {
|
|
|
|
return $field->getApplicationTransactionTitle($this);
|
|
|
|
} else {
|
|
|
|
return pht(
|
|
|
|
'%s edited a custom field.',
|
|
|
|
$this->renderHandleLink($author_phid));
|
|
|
|
}
|
|
|
|
|
2012-12-11 13:59:20 -08:00
|
|
|
default:
|
|
|
|
return pht(
|
|
|
|
'%s edited this %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->getApplicationObjectTypeName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-18 15:15:25 -07:00
|
|
|
public function getTitleForFeed(PhabricatorFeedStory $story) {
|
2012-12-11 14:00:21 -08:00
|
|
|
$author_phid = $this->getAuthorPHID();
|
|
|
|
$object_phid = $this->getObjectPHID();
|
|
|
|
|
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorTransactions::TYPE_COMMENT:
|
|
|
|
return pht(
|
|
|
|
'%s added a comment to %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
|
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
|
|
return pht(
|
|
|
|
'%s changed the visibility for %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
|
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
|
|
return pht(
|
|
|
|
'%s changed the edit policy for %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
|
|
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
|
|
|
return pht(
|
|
|
|
'%s updated subscribers of %s.',
|
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
2013-03-28 08:34:34 -07:00
|
|
|
case PhabricatorTransactions::TYPE_EDGE:
|
2013-07-19 15:59:29 -07:00
|
|
|
$type = $this->getMetadata('edge:type');
|
|
|
|
$type = head($type);
|
|
|
|
$string = PhabricatorEdgeConfig::getFeedStringForEdgeType($type);
|
2013-03-28 08:34:34 -07:00
|
|
|
return pht(
|
2013-07-19 15:59:29 -07:00
|
|
|
$string,
|
2013-03-28 08:34:34 -07:00
|
|
|
$this->renderHandleLink($author_phid),
|
|
|
|
$this->renderHandleLink($object_phid));
|
2012-12-11 14:00:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return $this->getTitle();
|
|
|
|
}
|
|
|
|
|
2013-08-19 11:51:22 -07:00
|
|
|
public function getBodyForFeed(PhabricatorFeedStory $story) {
|
2013-07-25 16:59:36 -07:00
|
|
|
$old = $this->getOldValue();
|
|
|
|
$new = $this->getNewValue();
|
|
|
|
|
|
|
|
$body = null;
|
|
|
|
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorTransactions::TYPE_COMMENT:
|
|
|
|
$text = $this->getComment()->getContent();
|
|
|
|
$body = phutil_escape_html_newlines(
|
|
|
|
phutil_utf8_shorten($text, 128));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return $body;
|
|
|
|
}
|
|
|
|
|
2012-12-11 14:00:07 -08:00
|
|
|
public function getActionStrength() {
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorTransactions::TYPE_COMMENT:
|
|
|
|
return 0.5;
|
|
|
|
}
|
|
|
|
return 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getActionName() {
|
|
|
|
switch ($this->getTransactionType()) {
|
|
|
|
case PhabricatorTransactions::TYPE_COMMENT:
|
|
|
|
return pht('Commented On');
|
|
|
|
case PhabricatorTransactions::TYPE_VIEW_POLICY:
|
|
|
|
case PhabricatorTransactions::TYPE_EDIT_POLICY:
|
|
|
|
return pht('Changed Policy');
|
|
|
|
case PhabricatorTransactions::TYPE_SUBSCRIBERS:
|
|
|
|
return pht('Changed Subscribers');
|
|
|
|
default:
|
|
|
|
return pht('Updated');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getMailTags() {
|
|
|
|
return array();
|
|
|
|
}
|
|
|
|
|
2013-02-17 06:37:02 -08:00
|
|
|
public function hasChangeDetails() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-03-04 12:54:20 -08:00
|
|
|
public function renderChangeDetails(PhabricatorUser $viewer) {
|
2013-02-17 06:37:02 -08:00
|
|
|
return null;
|
|
|
|
}
|
2012-12-11 13:59:20 -08:00
|
|
|
|
2013-03-09 19:23:50 -08:00
|
|
|
public function attachTransactionGroup(array $group) {
|
|
|
|
assert_instances_of($group, 'PhabricatorApplicationTransaction');
|
|
|
|
$this->transactionGroup = $group;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTransactionGroup() {
|
|
|
|
return $this->transactionGroup;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-12-11 13:59:20 -08:00
|
|
|
/* -( PhabricatorPolicyInterface Implementation )-------------------------- */
|
|
|
|
|
|
|
|
|
|
|
|
public function getCapabilities() {
|
|
|
|
return array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPolicy($capability) {
|
|
|
|
switch ($capability) {
|
|
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
|
|
return $this->getViewPolicy();
|
|
|
|
case PhabricatorPolicyCapability::CAN_EDIT:
|
|
|
|
return $this->getEditPolicy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
|
|
return ($viewer->getPHID() == $this->getAuthorPHID());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|