Page MenuHomePhabricator

D14727.diff
No OneTemporary

D14727.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1750,6 +1750,7 @@
'PhabricatorAutoEventListener' => 'infrastructure/events/PhabricatorAutoEventListener.php',
'PhabricatorBadgeHasRecipientEdgeType' => 'applications/badges/edge/PhabricatorBadgeHasRecipientEdgeType.php',
'PhabricatorBadgesApplication' => 'applications/badges/application/PhabricatorBadgesApplication.php',
+ 'PhabricatorBadgesArchiveController' => 'applications/badges/controller/PhabricatorBadgesArchiveController.php',
'PhabricatorBadgesBadge' => 'applications/badges/storage/PhabricatorBadgesBadge.php',
'PhabricatorBadgesCommentController' => 'applications/badges/controller/PhabricatorBadgesCommentController.php',
'PhabricatorBadgesController' => 'applications/badges/controller/PhabricatorBadgesController.php',
@@ -5807,6 +5808,7 @@
'PhabricatorAutoEventListener' => 'PhabricatorEventListener',
'PhabricatorBadgeHasRecipientEdgeType' => 'PhabricatorEdgeType',
'PhabricatorBadgesApplication' => 'PhabricatorApplication',
+ 'PhabricatorBadgesArchiveController' => 'PhabricatorBadgesController',
'PhabricatorBadgesBadge' => array(
'PhabricatorBadgesDAO',
'PhabricatorPolicyInterface',
diff --git a/src/applications/badges/application/PhabricatorBadgesApplication.php b/src/applications/badges/application/PhabricatorBadgesApplication.php
--- a/src/applications/badges/application/PhabricatorBadgesApplication.php
+++ b/src/applications/badges/application/PhabricatorBadgesApplication.php
@@ -45,6 +45,8 @@
=> 'PhabricatorBadgesCommentController',
'edit/(?:(?P<id>\d+)/)?'
=> 'PhabricatorBadgesEditController',
+ 'archive/(?:(?P<id>\d+)/)?'
+ => 'PhabricatorBadgesArchiveController',
'view/(?:(?P<id>\d+)/)?'
=> 'PhabricatorBadgesViewController',
'icon/(?P<id>[1-9]\d*)/'
diff --git a/src/applications/badges/controller/PhabricatorBadgesArchiveController.php b/src/applications/badges/controller/PhabricatorBadgesArchiveController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/badges/controller/PhabricatorBadgesArchiveController.php
@@ -0,0 +1,68 @@
+<?php
+
+final class PhabricatorBadgesArchiveController
+ extends PhabricatorBadgesController {
+
+ public function handleRequest(AphrontRequest $request) {
+ $viewer = $request->getViewer();
+ $id = $request->getURIData('id');
+
+ $badge = id(new PhabricatorBadgesQuery())
+ ->setViewer($viewer)
+ ->withIDs(array($id))
+ ->requireCapabilities(
+ array(
+ PhabricatorPolicyCapability::CAN_VIEW,
+ PhabricatorPolicyCapability::CAN_EDIT,
+ ))
+ ->executeOne();
+ if (!$badge) {
+ return new Aphront404Response();
+ }
+
+ $view_uri = $this->getApplicationURI('view/'.$badge->getID().'/');
+
+ if ($request->isFormPost()) {
+ if ($badge->isArchived()) {
+ $new_status = PhabricatorBadgesBadge::STATUS_ACTIVE;
+ } else {
+ $new_status = PhabricatorBadgesBadge::STATUS_ARCHIVED;
+ }
+
+ $xactions = array();
+
+ $xactions[] = id(new PhabricatorBadgesTransaction())
+ ->setTransactionType(PhabricatorBadgesTransaction::TYPE_STATUS)
+ ->setNewValue($new_status);
+
+ id(new PhabricatorBadgesEditor())
+ ->setActor($viewer)
+ ->setContentSourceFromRequest($request)
+ ->setContinueOnNoEffect(true)
+ ->setContinueOnMissingFields(true)
+ ->applyTransactions($badge, $xactions);
+
+ return id(new AphrontRedirectResponse())->setURI($view_uri);
+ }
+
+ if ($badge->isArchived()) {
+ $title = pht('Activate Badge');
+ $body = pht('This badge will be re-commissioned into service.');
+ $button = pht('Activate Badge');
+ } else {
+ $title = pht('Archive Badge');
+ $body = pht(
+ 'This dedicated badge, once a distinguish icon of this install, '.
+ 'shall be immediately retired from service, but will never far from '.
+ 'our hearts. Godspeed.');
+ $button = pht('Archive Badge');
+ }
+
+ return $this->newDialog()
+ ->setTitle($title)
+ ->appendChild($body)
+ ->addCancelButton($view_uri)
+ ->addSubmitButton($button);
+ }
+
+}
diff --git a/src/applications/badges/controller/PhabricatorBadgesEditController.php b/src/applications/badges/controller/PhabricatorBadgesEditController.php
--- a/src/applications/badges/controller/PhabricatorBadgesEditController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesEditController.php
@@ -43,14 +43,10 @@
$e_name = true;
$v_name = $badge->getName();
-
$v_icon = $badge->getIcon();
-
$v_flav = $badge->getFlavor();
$v_desc = $badge->getDescription();
$v_qual = $badge->getQuality();
- $v_stat = $badge->getStatus();
-
$v_edit = $badge->getEditPolicy();
$validation_exception = null;
@@ -59,7 +55,6 @@
$v_flav = $request->getStr('flavor');
$v_desc = $request->getStr('description');
$v_icon = $request->getStr('icon');
- $v_stat = $request->getStr('status');
$v_qual = $request->getStr('quality');
$v_view = $request->getStr('viewPolicy');
@@ -70,7 +65,6 @@
$type_desc = PhabricatorBadgesTransaction::TYPE_DESCRIPTION;
$type_icon = PhabricatorBadgesTransaction::TYPE_ICON;
$type_qual = PhabricatorBadgesTransaction::TYPE_QUALITY;
- $type_stat = PhabricatorBadgesTransaction::TYPE_STATUS;
$type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY;
@@ -97,10 +91,6 @@
->setNewValue($v_qual);
$xactions[] = id(new PhabricatorBadgesTransaction())
- ->setTransactionType($type_stat)
- ->setNewValue($v_stat);
-
- $xactions[] = id(new PhabricatorBadgesTransaction())
->setTransactionType($type_edit)
->setNewValue($v_edit);
@@ -161,12 +151,6 @@
->setValue($v_qual)
->setOptions($badge->getQualityNameMap()))
->appendChild(
- id(new AphrontFormSelectControl())
- ->setLabel(pht('Status'))
- ->setName('status')
- ->setValue($v_stat)
- ->setOptions($badge->getStatusNameMap()))
- ->appendChild(
id(new PhabricatorRemarkupControl())
->setUser($viewer)
->setName('description')
diff --git a/src/applications/badges/controller/PhabricatorBadgesViewController.php b/src/applications/badges/controller/PhabricatorBadgesViewController.php
--- a/src/applications/badges/controller/PhabricatorBadgesViewController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesViewController.php
@@ -24,7 +24,7 @@
$crumbs->addTextCrumb($badge->getName());
$title = $badge->getName();
- if ($badge->isClosed()) {
+ if ($badge->isArchived()) {
$status_icon = 'fa-ban';
$status_color = 'dark';
} else {
@@ -138,9 +138,26 @@
->setName(pht('Edit Badge'))
->setIcon('fa-pencil')
->setDisabled(!$can_edit)
- ->setWorkflow(!$can_edit)
->setHref($this->getApplicationURI("/edit/{$id}/")));
+ if ($badge->isArchived()) {
+ $view->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Activate Badge'))
+ ->setIcon('fa-check')
+ ->setDisabled(!$can_edit)
+ ->setWorkflow($can_edit)
+ ->setHref($this->getApplicationURI("/archive/{$id}/")));
+ } else {
+ $view->addAction(
+ id(new PhabricatorActionView())
+ ->setName(pht('Archive Badge'))
+ ->setIcon('fa-ban')
+ ->setDisabled(!$can_edit)
+ ->setWorkflow($can_edit)
+ ->setHref($this->getApplicationURI("/archive/{$id}/")));
+ }
+
$view->addAction(
id(new PhabricatorActionView())
->setName('Manage Recipients')
diff --git a/src/applications/badges/phid/PhabricatorBadgesPHIDType.php b/src/applications/badges/phid/PhabricatorBadgesPHIDType.php
--- a/src/applications/badges/phid/PhabricatorBadgesPHIDType.php
+++ b/src/applications/badges/phid/PhabricatorBadgesPHIDType.php
@@ -35,7 +35,7 @@
$id = $badge->getID();
$name = $badge->getName();
- if ($badge->isClosed()) {
+ if ($badge->isArchived()) {
$handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED);
}
diff --git a/src/applications/badges/query/PhabricatorBadgesSearchEngine.php b/src/applications/badges/query/PhabricatorBadgesSearchEngine.php
--- a/src/applications/badges/query/PhabricatorBadgesSearchEngine.php
+++ b/src/applications/badges/query/PhabricatorBadgesSearchEngine.php
@@ -84,7 +84,7 @@
return $query->setParameter(
'statuses',
array(
- PhabricatorBadgesBadge::STATUS_OPEN,
+ PhabricatorBadgesBadge::STATUS_ACTIVE,
));
}
@@ -124,7 +124,7 @@
->addAttribute($quality)
->addAttribute($badge->getFlavor());
- if ($badge->isClosed()) {
+ if ($badge->isArchived()) {
$item->setDisabled(true);
$item->addIcon('fa-ban', pht('Archived'));
}
diff --git a/src/applications/badges/storage/PhabricatorBadgesBadge.php b/src/applications/badges/storage/PhabricatorBadgesBadge.php
--- a/src/applications/badges/storage/PhabricatorBadgesBadge.php
+++ b/src/applications/badges/storage/PhabricatorBadgesBadge.php
@@ -21,8 +21,8 @@
private $recipientPHIDs = self::ATTACHABLE;
- const STATUS_OPEN = 'open';
- const STATUS_CLOSED = 'closed';
+ const STATUS_ACTIVE = 'open';
+ const STATUS_ARCHIVED = 'closed';
const DEFAULT_ICON = 'fa-star';
const DEFAULT_QUALITY = 'green';
@@ -37,8 +37,8 @@
public static function getStatusNameMap() {
return array(
- self::STATUS_OPEN => pht('Active'),
- self::STATUS_CLOSED => pht('Archived'),
+ self::STATUS_ACTIVE => pht('Active'),
+ self::STATUS_ARCHIVED => pht('Archived'),
);
}
@@ -74,7 +74,7 @@
->setQuality(self::DEFAULT_QUALITY)
->setCreatorPHID($actor->getPHID())
->setEditPolicy($edit_policy)
- ->setStatus(self::STATUS_OPEN);
+ ->setStatus(self::STATUS_ACTIVE);
}
protected function getConfiguration() {
@@ -102,8 +102,8 @@
PhabricatorPHID::generateNewPHID(PhabricatorBadgesPHIDType::TYPECONST);
}
- public function isClosed() {
- return ($this->getStatus() == self::STATUS_CLOSED);
+ public function isArchived() {
+ return ($this->getStatus() == self::STATUS_ARCHIVED);
}
public function attachRecipientPHIDs(array $phids) {
diff --git a/src/applications/badges/storage/PhabricatorBadgesTransaction.php b/src/applications/badges/storage/PhabricatorBadgesTransaction.php
--- a/src/applications/badges/storage/PhabricatorBadgesTransaction.php
+++ b/src/applications/badges/storage/PhabricatorBadgesTransaction.php
@@ -155,12 +155,12 @@
$this->renderHandleLink($object_phid));
case self::TYPE_STATUS:
switch ($new) {
- case PhabricatorBadgesBadge::STATUS_OPEN:
+ case PhabricatorBadgesBadge::STATUS_ACTIVE:
return pht(
'%s activated %s.',
$this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid));
- case PhabricatorBadgesBadge::STATUS_CLOSED:
+ case PhabricatorBadgesBadge::STATUS_ARCHIVED:
return pht(
'%s archived %s.',
$this->renderHandleLink($author_phid),

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 20, 1:10 AM (20 h, 52 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7022167
Default Alt Text
D14727.diff (11 KB)

Event Timeline