1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-24 15:52:41 +01:00
phorge-phorge/src/applications/spaces/storage/PhabricatorSpacesNamespaceTransaction.php
epriestley 88e7cd158f Allow Spaces to be archived
Summary:
Ref T8377. This adds a standard disable/enable feature to Spaces, with a couple of twists:

  - You can't create new stuff in an archived space, and you can't move stuff into an archived space.
  - We don't show results from an archived space by default in ApplicationSearch queries. You can still find these objects if you explicitly search for "Spaces: <the archived space>".

So this is a "put it in a box in the attic" sort of operation, but that seems fairly nice/reasonable.

Test Plan:
  - Archived and activated spaces.
  - Used ApplicationSearch, which omitted archived objects by default but allowed searches for them, specifically, to succeed.
  - Tried to create objects into an archived space (this is not allowed).
  - Edited objects in an archived space (this is OK).

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8377

Differential Revision: https://secure.phabricator.com/D13238
2015-06-11 10:13:47 -07:00

97 lines
2.3 KiB
PHP

<?php
final class PhabricatorSpacesNamespaceTransaction
extends PhabricatorApplicationTransaction {
const TYPE_NAME = 'spaces:name';
const TYPE_DEFAULT = 'spaces:default';
const TYPE_DESCRIPTION = 'spaces:description';
const TYPE_ARCHIVE = 'spaces:archive';
public function getApplicationName() {
return 'spaces';
}
public function getApplicationTransactionType() {
return PhabricatorSpacesNamespacePHIDType::TYPECONST;
}
public function getApplicationTransactionCommentObject() {
return null;
}
public function shouldHide() {
$old = $this->getOldValue();
switch ($this->getTransactionType()) {
case self::TYPE_DESCRIPTION:
return ($old === null);
}
return parent::shouldHide();
}
public function hasChangeDetails() {
switch ($this->getTransactionType()) {
case self::TYPE_DESCRIPTION:
return true;
}
return parent::hasChangeDetails();
}
public function getRemarkupBlocks() {
$blocks = parent::getRemarkupBlocks();
switch ($this->getTransactionType()) {
case self::TYPE_DESCRIPTION:
$blocks[] = $this->getNewValue();
break;
}
return $blocks;
}
public function getTitle() {
$old = $this->getOldValue();
$new = $this->getNewValue();
$author_phid = $this->getAuthorPHID();
switch ($this->getTransactionType()) {
case self::TYPE_NAME:
if ($old === null) {
return pht(
'%s created this space.',
$this->renderHandleLink($author_phid));
} else {
return pht(
'%s renamed this space from "%s" to "%s".',
$this->renderHandleLink($author_phid),
$old,
$new);
}
case self::TYPE_DESCRIPTION:
return pht(
'%s updated the description for this space.',
$this->renderHandleLink($author_phid));
case self::TYPE_DEFAULT:
return pht(
'%s made this the default space.',
$this->renderHandleLink($author_phid));
case self::TYPE_ARCHIVE:
if ($new) {
return pht(
'%s archived this space.',
$this->renderHandleLink($author_phid));
} else {
return pht(
'%s activated this space.',
$this->renderHandleLink($author_phid));
}
}
return parent::getTitle();
}
}