[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/conpherence/storage/ -> ConpherenceTransaction.php (source)

   1  <?php
   2  
   3  final class ConpherenceTransaction extends PhabricatorApplicationTransaction {
   4  
   5    public function getApplicationName() {
   6      return 'conpherence';
   7    }
   8  
   9    public function getApplicationTransactionType() {
  10      return PhabricatorConpherenceThreadPHIDType::TYPECONST;
  11    }
  12  
  13    public function getApplicationTransactionCommentObject() {
  14      return new ConpherenceTransactionComment();
  15    }
  16  
  17    public function getNoEffectDescription() {
  18      switch ($this->getTransactionType()) {
  19        case ConpherenceTransactionType::TYPE_PARTICIPANTS:
  20          return pht(
  21            'You can not add a participant who has already been added.');
  22          break;
  23      }
  24  
  25      return parent::getNoEffectDescription();
  26    }
  27  
  28    public function shouldHide() {
  29      $old = $this->getOldValue();
  30  
  31      switch ($this->getTransactionType()) {
  32        case ConpherenceTransactionType::TYPE_PARTICIPANTS:
  33          return ($old === null);
  34        case ConpherenceTransactionType::TYPE_TITLE:
  35        case ConpherenceTransactionType::TYPE_DATE_MARKER:
  36          return false;
  37        case ConpherenceTransactionType::TYPE_FILES:
  38          return true;
  39        // we used to have them so just always hide
  40        case ConpherenceTransactionType::TYPE_PICTURE:
  41        case ConpherenceTransactionType::TYPE_PICTURE_CROP:
  42          return true;
  43      }
  44  
  45      return parent::shouldHide();
  46    }
  47  
  48    public function getTitle() {
  49      $author_phid = $this->getAuthorPHID();
  50  
  51      $old = $this->getOldValue();
  52      $new = $this->getNewValue();
  53  
  54      switch ($this->getTransactionType()) {
  55        case ConpherenceTransactionType::TYPE_TITLE:
  56          if ($old && $new) {
  57            $title = pht(
  58              '%s renamed this conpherence from "%s" to "%s".',
  59              $this->renderHandleLink($author_phid),
  60              $old,
  61              $new);
  62          } else if ($old) {
  63            $title = pht(
  64              '%s deleted the conpherence name "%s".',
  65              $this->renderHandleLink($author_phid),
  66              $old);
  67          } else {
  68            $title = pht(
  69              '%s named this conpherence "%s".',
  70              $this->renderHandleLink($author_phid),
  71              $new);
  72          }
  73          return $title;
  74        case ConpherenceTransactionType::TYPE_FILES:
  75          $add = array_diff($new, $old);
  76          $rem = array_diff($old, $new);
  77  
  78          if ($add && $rem) {
  79            $title = pht(
  80              '%s edited files(s), added %d and removed %d.',
  81              $this->renderHandleLink($author_phid),
  82              count($add),
  83              count($rem));
  84          } else if ($add) {
  85            $title = pht(
  86              '%s added %d files(s).',
  87              $this->renderHandleLink($author_phid),
  88              count($add));
  89          } else {
  90            $title = pht(
  91              '%s removed %d file(s).',
  92              $this->renderHandleLink($author_phid),
  93              count($rem));
  94          }
  95          return $title;
  96          break;
  97        case ConpherenceTransactionType::TYPE_PARTICIPANTS:
  98          $add = array_diff($new, $old);
  99          $rem = array_diff($old, $new);
 100  
 101          if ($add && $rem) {
 102            $title = pht(
 103              '%s edited participant(s), added %d: %s; removed %d: %s.',
 104              $this->renderHandleLink($author_phid),
 105              count($add),
 106              $this->renderHandleList($add),
 107              count($rem),
 108              $this->renderHandleList($rem));
 109          } else if ($add) {
 110            $title = pht(
 111              '%s added %d participant(s): %s.',
 112              $this->renderHandleLink($author_phid),
 113              count($add),
 114              $this->renderHandleList($add));
 115          } else {
 116            $title = pht(
 117              '%s removed %d participant(s): %s.',
 118              $this->renderHandleLink($author_phid),
 119              count($rem),
 120              $this->renderHandleList($rem));
 121          }
 122          return $title;
 123          break;
 124      }
 125  
 126      return parent::getTitle();
 127    }
 128  
 129    public function getRequiredHandlePHIDs() {
 130      $phids = parent::getRequiredHandlePHIDs();
 131  
 132      $old = $this->getOldValue();
 133      $new = $this->getNewValue();
 134  
 135      $phids[] = $this->getAuthorPHID();
 136      switch ($this->getTransactionType()) {
 137        case ConpherenceTransactionType::TYPE_TITLE:
 138        case ConpherenceTransactionType::TYPE_FILES:
 139        case ConpherenceTransactionType::TYPE_DATE_MARKER:
 140          break;
 141        case ConpherenceTransactionType::TYPE_PARTICIPANTS:
 142          $phids = array_merge($phids, $this->getOldValue());
 143          $phids = array_merge($phids, $this->getNewValue());
 144          break;
 145      }
 146  
 147      return $phids;
 148    }
 149  
 150  }


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