Ejemplo n.º 1
0
 protected function transactionHasEffect(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case PhabricatorAuditActionConstants::INLINE:
             return $xaction->hasComment();
     }
     return parent::transactionHasEffect($object, $xaction);
 }
 protected function transactionHasEffect(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     switch ($xaction->getTransactionType()) {
         case PhabricatorTransactions::TYPE_COMMENT:
             return $xaction->hasComment();
         case PhabricatorTransactions::TYPE_CUSTOMFIELD:
             $field = $this->getCustomFieldForTransaction($object, $xaction);
             return $field->getApplicationTransactionHasEffect($xaction);
         case PhabricatorTransactions::TYPE_EDGE:
             // A straight value comparison here doesn't always get the right
             // result, because newly added edges aren't fully populated. Instead,
             // compare the changes in a more granular way.
             $old = $xaction->getOldValue();
             $new = $xaction->getNewValue();
             $old_dst = array_keys($old);
             $new_dst = array_keys($new);
             // NOTE: For now, we don't consider edge reordering to be a change.
             // We have very few order-dependent edges and effectively no order
             // oriented UI. This might change in the future.
             sort($old_dst);
             sort($new_dst);
             if ($old_dst !== $new_dst) {
                 // We've added or removed edges, so this transaction definitely
                 // has an effect.
                 return true;
             }
             // We haven't added or removed edges, but we might have changed
             // edge data.
             foreach ($old as $key => $old_value) {
                 $new_value = $new[$key];
                 if ($old_value['data'] !== $new_value['data']) {
                     return true;
                 }
             }
             return false;
     }
     return $xaction->getOldValue() !== $xaction->getNewValue();
 }
 protected function transactionHasEffect(PhabricatorLiskDAO $object, PhabricatorApplicationTransaction $xaction)
 {
     $actor_phid = $this->getActingAsPHID();
     switch ($xaction->getTransactionType()) {
         case DifferentialTransaction::TYPE_INLINE:
             return $xaction->hasComment();
         case DifferentialTransaction::TYPE_ACTION:
             $status_closed = ArcanistDifferentialRevisionStatus::CLOSED;
             $status_abandoned = ArcanistDifferentialRevisionStatus::ABANDONED;
             $status_review = ArcanistDifferentialRevisionStatus::NEEDS_REVIEW;
             $status_revision = ArcanistDifferentialRevisionStatus::NEEDS_REVISION;
             $status_plan = ArcanistDifferentialRevisionStatus::CHANGES_PLANNED;
             $action_type = $xaction->getNewValue();
             switch ($action_type) {
                 case DifferentialAction::ACTION_ACCEPT:
                 case DifferentialAction::ACTION_REJECT:
                     if ($action_type == DifferentialAction::ACTION_ACCEPT) {
                         $new_status = DifferentialReviewerStatus::STATUS_ACCEPTED;
                     } else {
                         $new_status = DifferentialReviewerStatus::STATUS_REJECTED;
                     }
                     $actor = $this->getActor();
                     // These transactions can cause effects in two ways: by altering the
                     // status of an existing reviewer; or by adding the actor as a new
                     // reviewer.
                     $will_add_reviewer = true;
                     foreach ($object->getReviewerStatus() as $reviewer) {
                         if ($reviewer->hasAuthority($actor)) {
                             if ($reviewer->getStatus() != $new_status) {
                                 return true;
                             }
                         }
                         if ($reviewer->getReviewerPHID() == $actor_phid) {
                             $will_add_reviwer = false;
                         }
                     }
                     return $will_add_reviewer;
                 case DifferentialAction::ACTION_CLOSE:
                     return $object->getStatus() != $status_closed;
                 case DifferentialAction::ACTION_ABANDON:
                     return $object->getStatus() != $status_abandoned;
                 case DifferentialAction::ACTION_RECLAIM:
                     return $object->getStatus() == $status_abandoned;
                 case DifferentialAction::ACTION_REOPEN:
                     return $object->getStatus() == $status_closed;
                 case DifferentialAction::ACTION_RETHINK:
                     return $object->getStatus() != $status_plan;
                 case DifferentialAction::ACTION_REQUEST:
                     return $object->getStatus() != $status_review;
                 case DifferentialAction::ACTION_RESIGN:
                     foreach ($object->getReviewerStatus() as $reviewer) {
                         if ($reviewer->getReviewerPHID() == $actor_phid) {
                             return true;
                         }
                     }
                     return false;
                 case DifferentialAction::ACTION_CLAIM:
                     return $actor_phid != $object->getAuthorPHID();
             }
     }
     return parent::transactionHasEffect($object, $xaction);
 }
 protected function renderTransactionContent(PhabricatorApplicationTransaction $xaction)
 {
     $field = PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT;
     $engine = $this->getOrBuildEngine();
     $comment = $xaction->getComment();
     if ($comment) {
         if ($comment->getIsRemoved()) {
             return javelin_tag('span', array('class' => 'comment-deleted', 'sigil' => 'transaction-comment', 'meta' => array('phid' => $comment->getTransactionPHID())), pht('This comment was removed by %s.', $xaction->getHandle($comment->getAuthorPHID())->renderLink()));
         } else {
             if ($comment->getIsDeleted()) {
                 return javelin_tag('span', array('class' => 'comment-deleted', 'sigil' => 'transaction-comment', 'meta' => array('phid' => $comment->getTransactionPHID())), pht('This comment has been deleted.'));
             } else {
                 if ($xaction->hasComment()) {
                     return javelin_tag('span', array('class' => 'transaction-comment', 'sigil' => 'transaction-comment', 'meta' => array('phid' => $comment->getTransactionPHID())), $engine->getOutput($comment, $field));
                 } else {
                     // This is an empty, non-deleted comment. Usually this happens when
                     // rendering previews.
                     return null;
                 }
             }
         }
     }
     return null;
 }