protected function applyCustomInternalTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction) { $new = $xaction->getNewValue(); switch ($xaction->getTransactionType()) { case ReleephRequestTransaction::TYPE_REQUEST: $object->setRequestCommitPHID($new); break; case ReleephRequestTransaction::TYPE_USER_INTENT: $user_phid = $xaction->getAuthorPHID(); $intents = $object->getUserIntents(); $intents[$user_phid] = $new; $object->setUserIntents($intents); break; case ReleephRequestTransaction::TYPE_EDIT_FIELD: $field = newv($xaction->getMetadataValue('fieldClass'), array()); $field->setReleephRequest($object)->setValue($new); break; case ReleephRequestTransaction::TYPE_PICK_STATUS: $object->setPickStatus($new); break; case ReleephRequestTransaction::TYPE_COMMIT: $this->setInBranchFromAction($object, $xaction); $object->setCommitIdentifier($new); break; case ReleephRequestTransaction::TYPE_DISCOVERY: $this->setInBranchFromAction($object, $xaction); $object->setCommitPHID($new); break; case ReleephRequestTransaction::TYPE_MANUAL_IN_BRANCH: $object->setInBranch((int) $new); break; } }
public function getApplicationTransactionTitleForFeed(PhabricatorApplicationTransaction $xaction) { $object_phid = $xaction->getObjectPHID(); $author_phid = $xaction->getAuthorPHID(); $old = $xaction->getOldValue(); $new = $xaction->getNewValue(); return pht('%s updated the test plan for %s.', $xaction->renderHandleLink($author_phid), $xaction->renderHandleLink($object_phid)); }
public function getApplicationTransactionTitle(PhabricatorApplicationTransaction $xaction) { $author_phid = $xaction->getAuthorPHID(); $old = $xaction->getOldValue(); $new = $xaction->getNewValue(); if ($new) { return pht('%s checked %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName()); } else { return pht('%s unchecked %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName()); } }
public function getApplicationTransactionTitleForFeed(PhabricatorApplicationTransaction $xaction, PhabricatorFeedStory $story) { $object_phid = $xaction->getObjectPHID(); $author_phid = $xaction->getAuthorPHID(); $old = $xaction->getOldValue(); $new = $xaction->getNewValue(); if (strlen($old)) { return pht('%s retitled %s, from "%s" to "%s".', $xaction->renderHandleLink($author_phid), $xaction->renderHandleLink($object_phid), $old, $new); } else { return pht('%s created %s.', $xaction->renderHandleLink($author_phid), $xaction->renderHandleLink($object_phid)); } }
public function getApplicationTransactionTitleForFeed(PhabricatorApplicationTransaction $xaction, PhabricatorFeedStory $story) { $object_phid = $xaction->getObjectPHID(); $author_phid = $xaction->getAuthorPHID(); $old = $xaction->getOldValue(); $new = $xaction->getNewValue(); if ($old) { return pht('%s updated the repository for %s from %s to %s.', $xaction->renderHandleLink($author_phid), $xaction->renderHandleLink($object_phid), $xaction->renderHandleLink($old), $xaction->renderHandleLink($new)); } else { return pht('%s set the repository for %s to %s.', $xaction->renderHandleLink($author_phid), $xaction->renderHandleLink($object_phid), $xaction->renderHandleLink($new)); } }
public function getApplicationTransactionTitle(PhabricatorApplicationTransaction $xaction) { $author_phid = $xaction->getAuthorPHID(); $old = $xaction->getOldValue(); $new = $xaction->getNewValue(); if ($old && !$new) { return pht('%s removed %s as %s.', $xaction->renderHandleLink($author_phid), $xaction->renderHandleLink($old), $this->getFieldName()); } else { if ($new && !$old) { return pht('%s set %s to %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName(), $xaction->renderHandleLink($new)); } else { return pht('%s changed %s from %s to %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName(), $xaction->renderHandleLink($old), $xaction->renderHandleLink($new)); } } }
protected function shouldGroupTransactions(PhabricatorApplicationTransaction $u, PhabricatorApplicationTransaction $v) { if ($u->getAuthorPHID() != $v->getAuthorPHID()) { // Don't group transactions by different authors. return false; } if ($v->getDateCreated() - $u->getDateCreated() > 60) { // Don't group if transactions that happened more than 60s apart. return false; } switch ($u->getTransactionType()) { case PhabricatorTransactions::TYPE_COMMENT: case PhabricatorAuditActionConstants::INLINE: break; default: return false; } switch ($v->getTransactionType()) { case PhabricatorAuditActionConstants::INLINE: return true; } return parent::shouldGroupTransactions($u, $v); }
public function getApplicationTransactionTitle(PhabricatorApplicationTransaction $xaction) { $author_phid = $xaction->getAuthorPHID(); $old = $this->decodeValue($xaction->getOldValue()); $new = $this->decodeValue($xaction->getNewValue()); $add = array_diff($new, $old); $rem = array_diff($old, $new); if ($add && !$rem) { return pht('%s updated %s, added %d: %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName(), new PhutilNumber(count($add)), $xaction->renderHandleList($add)); } else { if ($rem && !$add) { return pht('%s updated %s, removed %d: %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName(), new PhutilNumber(count($rem)), $xaction->renderHandleList($rem)); } else { return pht('%s updated %s, added %d: %s; removed %d: %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName(), new PhutilNumber(count($add)), $xaction->renderHandleList($add), new PhutilNumber(count($rem)), $xaction->renderHandleList($rem)); } } }
private function makeAuthorMostRecentParticipant(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction) { $participants = $object->getRecentParticipantPHIDs(); array_unshift($participants, $xaction->getAuthorPHID()); $participants = array_slice(array_unique($participants), 0, 10); $object->setRecentParticipantPHIDs($participants); }
public function getApplicationTransactionTitle(PhabricatorApplicationTransaction $xaction) { $author_phid = $xaction->getAuthorPHID(); // TODO: Expose fancy transactions. return pht('%s edited %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName()); }
/** * Fill in a transaction's common values, like author and content source. */ protected function populateTransaction(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction) { $actor = $this->getActor(); // TODO: This needs to be more sophisticated once we have meta-policies. $xaction->setViewPolicy(PhabricatorPolicies::POLICY_PUBLIC); if ($actor->isOmnipotent()) { $xaction->setEditPolicy(PhabricatorPolicies::POLICY_NOONE); } else { $xaction->setEditPolicy($this->getActingAsPHID()); } // If the transaction already has an explicit author PHID, allow it to // stand. This is used by applications like Owners that hook into the // post-apply change pipeline. if (!$xaction->getAuthorPHID()) { $xaction->setAuthorPHID($this->getActingAsPHID()); } $xaction->setContentSource($this->getContentSource()); $xaction->attachViewer($actor); $xaction->attachObject($object); if ($object->getPHID()) { $xaction->setObjectPHID($object->getPHID()); } return $xaction; }
public function getApplicationTransactionTitle(PhabricatorApplicationTransaction $xaction) { $old = $xaction->getOldValue(); if (!is_array($old)) { $old = array(); } $new = $xaction->getNewValue(); if (!is_array($new)) { $new = array(); } $add = array_diff($new, $old); $rem = array_diff($old, $new); $author_phid = $xaction->getAuthorPHID(); if ($add && $rem) { return pht('%s updated JIRA issue(s): added %d %s; removed %d %s.', $xaction->renderHandleLink($author_phid), phutil_count($add), implode(', ', $add), phutil_count($rem), implode(', ', $rem)); } else { if ($add) { return pht('%s added %d JIRA issue(s): %s.', $xaction->renderHandleLink($author_phid), phutil_count($add), implode(', ', $add)); } else { if ($rem) { return pht('%s removed %d JIRA issue(s): %s.', $xaction->renderHandleLink($author_phid), phutil_count($rem), implode(', ', $rem)); } } } return parent::getApplicationTransactionTitle($xaction); }
private function renderEvent(PhabricatorApplicationTransaction $xaction, array $group) { $viewer = $this->getUser(); $event = id(new PHUITimelineEventView())->setUser($viewer)->setAuthorPHID($xaction->getAuthorPHID())->setTransactionPHID($xaction->getPHID())->setUserHandle($xaction->getHandle($xaction->getAuthorPHID()))->setIcon($xaction->getIcon())->setColor($xaction->getColor())->setHideCommentOptions($this->getHideCommentOptions()); list($token, $token_removed) = $xaction->getToken(); if ($token) { $event->setToken($token, $token_removed); } if (!$this->shouldSuppressTitle($xaction, $group)) { if ($this->renderAsFeed) { $title = $xaction->getTitleForFeed(); } else { $title = $xaction->getTitle(); } if ($xaction->hasChangeDetails()) { if (!$this->isPreview) { $details = $this->buildChangeDetailsLink($xaction); $title = array($title, ' ', $details); } } if (!$this->isPreview) { $more = $this->buildExtraInformationLink($xaction); if ($more) { $title = array($title, ' ', $more); } } $event->setTitle($title); } if ($this->isPreview) { $event->setIsPreview(true); } else { $event->setDateCreated($xaction->getDateCreated())->setContentSource($xaction->getContentSource())->setAnchor($xaction->getID()); } $transaction_type = $xaction->getTransactionType(); $comment_type = PhabricatorTransactions::TYPE_COMMENT; $is_normal_comment = $transaction_type == $comment_type; if ($this->getShowEditActions() && !$this->isPreview && $is_normal_comment) { $has_deleted_comment = $xaction->getComment() && $xaction->getComment()->getIsDeleted(); $has_removed_comment = $xaction->getComment() && $xaction->getComment()->getIsRemoved(); if ($xaction->getCommentVersion() > 1 && !$has_removed_comment) { $event->setIsEdited(true); } if (!$has_removed_comment) { $event->setIsNormalComment(true); } // If we have a place for quoted text to go and this is a quotable // comment, pass the quote target ID to the event view. if ($this->getQuoteTargetID()) { if ($xaction->hasComment()) { if (!$has_removed_comment && !$has_deleted_comment) { $event->setQuoteTargetID($this->getQuoteTargetID()); $event->setQuoteRef($this->getQuoteRef()); } } } $can_edit = PhabricatorPolicyCapability::CAN_EDIT; if ($xaction->hasComment() || $has_deleted_comment) { $has_edit_capability = PhabricatorPolicyFilter::hasCapability($viewer, $xaction, $can_edit); if ($has_edit_capability && !$has_removed_comment) { $event->setIsEditable(true); } if ($has_edit_capability || $viewer->getIsAdmin()) { if (!$has_removed_comment) { $event->setIsRemovable(true); } } } } $comment = $this->renderTransactionContent($xaction); if ($comment) { $event->appendChild($comment); } return $event; }
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) { 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) { $author_phid = $xaction->getAuthorPHID(); $object_phid = $xaction->getObjectPHID(); return pht('%s edited %s on %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName(), $xaction->renderHandleLink($object_phid)); }
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)); } } }