Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/storage/PhabricatorProjectTransaction.php
| Show All 22 Lines | final class PhabricatorProjectTransaction | ||||
| } | } | ||||
| public function getRequiredHandlePHIDs() { | public function getRequiredHandlePHIDs() { | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| $req_phids = array(); | $req_phids = array(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case PhabricatorProjectTransaction::TYPE_MEMBERS: | case self::TYPE_MEMBERS: | ||||
| $add = array_diff($new, $old); | $add = array_diff($new, $old); | ||||
| $rem = array_diff($old, $new); | $rem = array_diff($old, $new); | ||||
| $req_phids = array_merge($add, $rem); | $req_phids = array_merge($add, $rem); | ||||
| break; | break; | ||||
| case PhabricatorProjectTransaction::TYPE_IMAGE: | case self::TYPE_IMAGE: | ||||
| $req_phids[] = $old; | $req_phids[] = $old; | ||||
| $req_phids[] = $new; | $req_phids[] = $new; | ||||
| break; | break; | ||||
| } | } | ||||
| return array_merge($req_phids, parent::getRequiredHandlePHIDs()); | return array_merge($req_phids, parent::getRequiredHandlePHIDs()); | ||||
| } | } | ||||
| public function getColor() { | public function getColor() { | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case PhabricatorProjectTransaction::TYPE_STATUS: | case self::TYPE_STATUS: | ||||
| if ($old == 0) { | if ($old == 0) { | ||||
| return 'red'; | return 'red'; | ||||
| } else { | } else { | ||||
| return 'green'; | return 'green'; | ||||
| } | } | ||||
| } | } | ||||
| return parent::getColor(); | return parent::getColor(); | ||||
| } | } | ||||
| public function getIcon() { | public function getIcon() { | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case PhabricatorProjectTransaction::TYPE_STATUS: | case self::TYPE_STATUS: | ||||
| if ($old == 0) { | if ($old == 0) { | ||||
| return 'fa-ban'; | return 'fa-ban'; | ||||
| } else { | } else { | ||||
| return 'fa-check'; | return 'fa-check'; | ||||
| } | } | ||||
| case PhabricatorProjectTransaction::TYPE_LOCKED: | case self::TYPE_LOCKED: | ||||
| if ($new) { | if ($new) { | ||||
| return 'fa-lock'; | return 'fa-lock'; | ||||
| } else { | } else { | ||||
| return 'fa-unlock'; | return 'fa-unlock'; | ||||
| } | } | ||||
| case PhabricatorProjectTransaction::TYPE_ICON: | case self::TYPE_ICON: | ||||
| return $new; | return $new; | ||||
| case PhabricatorProjectTransaction::TYPE_IMAGE: | case self::TYPE_IMAGE: | ||||
| return 'fa-photo'; | return 'fa-photo'; | ||||
| case PhabricatorProjectTransaction::TYPE_MEMBERS: | case self::TYPE_MEMBERS: | ||||
| return 'fa-user'; | return 'fa-user'; | ||||
| case PhabricatorProjectTransaction::TYPE_SLUGS: | case self::TYPE_SLUGS: | ||||
| return 'fa-tag'; | return 'fa-tag'; | ||||
| } | } | ||||
| return parent::getIcon(); | return parent::getIcon(); | ||||
| } | } | ||||
| public function getTitle() { | public function getTitle() { | ||||
| $old = $this->getOldValue(); | $old = $this->getOldValue(); | ||||
| $new = $this->getNewValue(); | $new = $this->getNewValue(); | ||||
| $author_handle = $this->renderHandleLink($this->getAuthorPHID()); | $author_handle = $this->renderHandleLink($this->getAuthorPHID()); | ||||
| switch ($this->getTransactionType()) { | switch ($this->getTransactionType()) { | ||||
| case PhabricatorProjectTransaction::TYPE_NAME: | case self::TYPE_NAME: | ||||
| if ($old === null) { | if ($old === null) { | ||||
| return pht( | return pht( | ||||
| '%s created this project.', | '%s created this project.', | ||||
| $author_handle); | $author_handle); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s renamed this project from "%s" to "%s".', | '%s renamed this project from "%s" to "%s".', | ||||
| $author_handle, | $author_handle, | ||||
| $old, | $old, | ||||
| $new); | $new); | ||||
| } | } | ||||
| case PhabricatorProjectTransaction::TYPE_STATUS: | case self::TYPE_STATUS: | ||||
| if ($old == 0) { | if ($old == 0) { | ||||
| return pht( | return pht( | ||||
| '%s archived this project.', | '%s archived this project.', | ||||
| $author_handle); | $author_handle); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s activated this project.', | '%s activated this project.', | ||||
| $author_handle); | $author_handle); | ||||
| } | } | ||||
| case PhabricatorProjectTransaction::TYPE_IMAGE: | case self::TYPE_IMAGE: | ||||
| // TODO: Some day, it would be nice to show the images. | // TODO: Some day, it would be nice to show the images. | ||||
| if (!$old) { | if (!$old) { | ||||
| return pht( | return pht( | ||||
| '%s set this project\'s image to %s.', | '%s set this project\'s image to %s.', | ||||
| $author_handle, | $author_handle, | ||||
| $this->renderHandleLink($new)); | $this->renderHandleLink($new)); | ||||
| } else if (!$new) { | } else if (!$new) { | ||||
| return pht( | return pht( | ||||
| '%s removed this project\'s image.', | '%s removed this project\'s image.', | ||||
| $author_handle); | $author_handle); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s updated this project\'s image from %s to %s.', | '%s updated this project\'s image from %s to %s.', | ||||
| $author_handle, | $author_handle, | ||||
| $this->renderHandleLink($old), | $this->renderHandleLink($old), | ||||
| $this->renderHandleLink($new)); | $this->renderHandleLink($new)); | ||||
| } | } | ||||
| case PhabricatorProjectTransaction::TYPE_ICON: | case self::TYPE_ICON: | ||||
| return pht( | return pht( | ||||
| '%s set this project\'s icon to %s.', | '%s set this project\'s icon to %s.', | ||||
| $author_handle, | $author_handle, | ||||
| PhabricatorProjectIcon::getLabel($new)); | PhabricatorProjectIcon::getLabel($new)); | ||||
| case PhabricatorProjectTransaction::TYPE_COLOR: | case self::TYPE_COLOR: | ||||
| return pht( | return pht( | ||||
| '%s set this project\'s color to %s.', | '%s set this project\'s color to %s.', | ||||
| $author_handle, | $author_handle, | ||||
| PHUITagView::getShadeName($new)); | PHUITagView::getShadeName($new)); | ||||
| case PhabricatorProjectTransaction::TYPE_LOCKED: | case self::TYPE_LOCKED: | ||||
| if ($new) { | if ($new) { | ||||
| return pht( | return pht( | ||||
| '%s locked this project\'s membership.', | '%s locked this project\'s membership.', | ||||
| $author_handle); | $author_handle); | ||||
| } else { | } else { | ||||
| return pht( | return pht( | ||||
| '%s unlocked this project\'s membership.', | '%s unlocked this project\'s membership.', | ||||
| $author_handle); | $author_handle); | ||||
| } | } | ||||
| case PhabricatorProjectTransaction::TYPE_SLUGS: | case self::TYPE_SLUGS: | ||||
| $add = array_diff($new, $old); | $add = array_diff($new, $old); | ||||
| $rem = array_diff($old, $new); | $rem = array_diff($old, $new); | ||||
| if ($add && $rem) { | if ($add && $rem) { | ||||
| return pht( | return pht( | ||||
| '%s changed project hashtag(s), added %d: %s; removed %d: %s.', | '%s changed project hashtag(s), added %d: %s; removed %d: %s.', | ||||
| $author_handle, | $author_handle, | ||||
| count($add), | count($add), | ||||
| Show All 9 Lines | switch ($this->getTransactionType()) { | ||||
| } else if ($rem) { | } else if ($rem) { | ||||
| return pht( | return pht( | ||||
| '%s removed %d project hashtag(s): %s.', | '%s removed %d project hashtag(s): %s.', | ||||
| $author_handle, | $author_handle, | ||||
| count($rem), | count($rem), | ||||
| $this->renderSlugList($rem)); | $this->renderSlugList($rem)); | ||||
| } | } | ||||
| case PhabricatorProjectTransaction::TYPE_MEMBERS: | case self::TYPE_MEMBERS: | ||||
| $add = array_diff($new, $old); | $add = array_diff($new, $old); | ||||
| $rem = array_diff($old, $new); | $rem = array_diff($old, $new); | ||||
| if ($add && $rem) { | if ($add && $rem) { | ||||
| return pht( | return pht( | ||||
| '%s changed project member(s), added %d: %s; removed %d: %s.', | '%s changed project member(s), added %d: %s; removed %d: %s.', | ||||
| $author_handle, | $author_handle, | ||||
| count($add), | count($add), | ||||
| ▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines | |||||