[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/passphrase/storage/ -> PassphraseCredentialTransaction.php (source)

   1  <?php
   2  
   3  final class PassphraseCredentialTransaction
   4    extends PhabricatorApplicationTransaction {
   5  
   6    const TYPE_NAME = 'passphrase:name';
   7    const TYPE_DESCRIPTION = 'passphrase:description';
   8    const TYPE_USERNAME = 'passphrase:username';
   9    const TYPE_SECRET_ID = 'passphrase:secretID';
  10    const TYPE_DESTROY = 'passphrase:destroy';
  11    const TYPE_LOOKEDATSECRET = 'passphrase:lookedAtSecret';
  12    const TYPE_LOCK = 'passphrase:lock';
  13    const TYPE_CONDUIT = 'passphrase:conduit';
  14  
  15    public function getApplicationName() {
  16      return 'passphrase';
  17    }
  18  
  19    public function getApplicationTransactionType() {
  20      return PassphraseCredentialPHIDType::TYPECONST;
  21    }
  22  
  23    public function getApplicationTransactionCommentObject() {
  24      return null;
  25    }
  26  
  27    public function shouldHide() {
  28      $old = $this->getOldValue();
  29      switch ($this->getTransactionType()) {
  30        case self::TYPE_DESCRIPTION:
  31          return ($old === null);
  32        case self::TYPE_LOCK:
  33          return ($old === null);
  34        case self::TYPE_USERNAME:
  35          return !strlen($old);
  36        case self::TYPE_LOOKEDATSECRET:
  37          return false;
  38      }
  39      return parent::shouldHide();
  40    }
  41  
  42    public function getTitle() {
  43      $old = $this->getOldValue();
  44      $new = $this->getNewValue();
  45      $author_phid = $this->getAuthorPHID();
  46  
  47      switch ($this->getTransactionType()) {
  48        case self::TYPE_NAME:
  49          if ($old === null) {
  50            return pht(
  51              '%s created this credential.',
  52              $this->renderHandleLink($author_phid));
  53          } else {
  54            return pht(
  55              '%s renamed this credential from "%s" to "%s".',
  56              $this->renderHandleLink($author_phid),
  57              $old,
  58              $new);
  59          }
  60          break;
  61        case self::TYPE_DESCRIPTION:
  62          return pht(
  63            '%s updated the description for this credential.',
  64            $this->renderHandleLink($author_phid));
  65        case self::TYPE_USERNAME:
  66          if (strlen($old)) {
  67            return pht(
  68              '%s changed the username for this credential from "%s" to "%s".',
  69              $this->renderHandleLink($author_phid),
  70              $old,
  71              $new);
  72          } else {
  73            return pht(
  74              '%s set the username for this credential to "%s".',
  75              $this->renderHandleLink($author_phid),
  76              $new);
  77          }
  78          break;
  79        case self::TYPE_SECRET_ID:
  80          return pht(
  81            '%s updated the secret for this credential.',
  82            $this->renderHandleLink($author_phid));
  83        case self::TYPE_DESTROY:
  84          return pht(
  85            '%s destroyed this credential.',
  86            $this->renderHandleLink($author_phid));
  87        case self::TYPE_LOOKEDATSECRET:
  88          return pht(
  89            '%s examined the secret plaintext for this credential.',
  90            $this->renderHandleLink($author_phid));
  91        case self::TYPE_LOCK:
  92          return pht(
  93            '%s locked this credential.',
  94            $this->renderHandleLink($author_phid));
  95        case self::TYPE_CONDUIT:
  96          if ($old) {
  97            return pht(
  98              '%s disallowed Conduit API access to this credential.',
  99              $this->renderHandleLink($author_phid));
 100          } else {
 101            return pht(
 102              '%s allowed Conduit API access to this credential.',
 103              $this->renderHandleLink($author_phid));
 104          }
 105          break;
 106      }
 107  
 108      return parent::getTitle();
 109    }
 110  
 111    public function hasChangeDetails() {
 112      switch ($this->getTransactionType()) {
 113        case self::TYPE_DESCRIPTION:
 114          return true;
 115      }
 116      return parent::hasChangeDetails();
 117    }
 118  
 119    public function renderChangeDetails(PhabricatorUser $viewer) {
 120      return $this->renderTextCorpusChangeDetails(
 121        $viewer,
 122        json_encode($this->getOldValue()),
 123        json_encode($this->getNewValue()));
 124    }
 125  
 126  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1