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));
 }
Ejemplo n.º 2
0
 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));
     }
 }
 protected function guessCancelURI(PhabricatorUser $viewer, PhabricatorApplicationTransaction $xaction)
 {
     // Take an educated guess at the URI where the transactions appear so we
     // can send the cancel button somewhere sensible. This won't always get the
     // best answer (for example, Diffusion's history is visible on a page other
     // than the main object view page) but should always get a reasonable one.
     $cancel_uri = '/';
     $handle = id(new PhabricatorHandleQuery())->setViewer($viewer)->withPHIDs(array($xaction->getObjectPHID()))->executeOne();
     if ($handle) {
         $cancel_uri = $handle->getURI();
     }
     return $cancel_uri;
 }
 public function applyApplicationTransactionExternalEffects(PhabricatorApplicationTransaction $xaction)
 {
     $object_phid = $xaction->getObjectPHID();
     $old = $this->decodeValue($xaction->getOldValue());
     $new = $this->decodeValue($xaction->getNewValue());
     $old_phids = array_fuse($old);
     $new_phids = array_fuse($new);
     $rem_phids = array_diff_key($old_phids, $new_phids);
     $add_phids = array_diff_key($new_phids, $old_phids);
     $altered_phids = $rem_phids + $add_phids;
     if (!$altered_phids) {
         return;
     }
     $authorizations = id(new DrydockAuthorizationQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withObjectPHIDs(array($object_phid))->withBlueprintPHIDs($altered_phids)->execute();
     $authorizations = mpull($authorizations, null, 'getBlueprintPHID');
     $state_active = DrydockAuthorization::OBJECTAUTH_ACTIVE;
     $state_inactive = DrydockAuthorization::OBJECTAUTH_INACTIVE;
     $state_requested = DrydockAuthorization::BLUEPRINTAUTH_REQUESTED;
     // Disable the object side of the authorization for any existing
     // authorizations.
     foreach ($rem_phids as $rem_phid) {
         $authorization = idx($authorizations, $rem_phid);
         if (!$authorization) {
             continue;
         }
         $authorization->setObjectAuthorizationState($state_inactive)->save();
     }
     // For new authorizations, either add them or reactivate them depending
     // on the current state.
     foreach ($add_phids as $add_phid) {
         $needs_update = false;
         $authorization = idx($authorizations, $add_phid);
         if (!$authorization) {
             $authorization = id(new DrydockAuthorization())->setObjectPHID($object_phid)->setObjectAuthorizationState($state_active)->setBlueprintPHID($add_phid)->setBlueprintAuthorizationState($state_requested);
             $needs_update = true;
         } else {
             $current_state = $authorization->getObjectAuthorizationState();
             if ($current_state != $state_active) {
                 $authorization->setObjectAuthorizationState($state_active);
                 $needs_update = true;
             }
         }
         if ($needs_update) {
             $authorization->save();
         }
     }
 }
 public function getApplicationTransactionTitleForFeed(PhabricatorApplicationTransaction $xaction)
 {
     $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(), $new, $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(), $old, $new, $xaction->renderHandleLink($object_phid));
         }
     }
 }
 public function getApplicationTransactionTitleForFeed(PhabricatorApplicationTransaction $xaction)
 {
     $author_phid = $xaction->getAuthorPHID();
     $object_phid = $xaction->getObjectPHID();
     $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 for %s, added %d: %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName(), $xaction->renderHandleLink($object_phid), phutil_count($add), $xaction->renderHandleList($add));
     } else {
         if ($rem && !$add) {
             return pht('%s updated %s for %s, removed %s: %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName(), $xaction->renderHandleLink($object_phid), phutil_count($rem), $xaction->renderHandleList($rem));
         } else {
             return pht('%s updated %s for %s, added %s: %s; removed %s: %s.', $xaction->renderHandleLink($author_phid), $this->getFieldName(), $xaction->renderHandleLink($object_phid), phutil_count($add), $xaction->renderHandleList($add), phutil_count($rem), $xaction->renderHandleList($rem));
         }
     }
 }
 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 applyApplicationTransactionExternalEffects(PhabricatorApplicationTransaction $xaction)
 {
     $old = $this->decodeValue($xaction->getOldValue());
     $new = $this->decodeValue($xaction->getNewValue());
     DrydockAuthorization::applyAuthorizationChanges($this->getViewer(), $xaction->getObjectPHID(), $old, $new);
 }