@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add PhabricatorBadgeArchiveController

Summary: Allows archive and activate on badges from action list. Ref T9414

Test Plan: Archive, Activate, New, Edit

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9414

Differential Revision: https://secure.phabricator.com/D14727

+103 -30
+2
src/__phutil_library_map__.php
··· 1750 1750 'PhabricatorAutoEventListener' => 'infrastructure/events/PhabricatorAutoEventListener.php', 1751 1751 'PhabricatorBadgeHasRecipientEdgeType' => 'applications/badges/edge/PhabricatorBadgeHasRecipientEdgeType.php', 1752 1752 'PhabricatorBadgesApplication' => 'applications/badges/application/PhabricatorBadgesApplication.php', 1753 + 'PhabricatorBadgesArchiveController' => 'applications/badges/controller/PhabricatorBadgesArchiveController.php', 1753 1754 'PhabricatorBadgesBadge' => 'applications/badges/storage/PhabricatorBadgesBadge.php', 1754 1755 'PhabricatorBadgesCommentController' => 'applications/badges/controller/PhabricatorBadgesCommentController.php', 1755 1756 'PhabricatorBadgesController' => 'applications/badges/controller/PhabricatorBadgesController.php', ··· 5807 5808 'PhabricatorAutoEventListener' => 'PhabricatorEventListener', 5808 5809 'PhabricatorBadgeHasRecipientEdgeType' => 'PhabricatorEdgeType', 5809 5810 'PhabricatorBadgesApplication' => 'PhabricatorApplication', 5811 + 'PhabricatorBadgesArchiveController' => 'PhabricatorBadgesController', 5810 5812 'PhabricatorBadgesBadge' => array( 5811 5813 'PhabricatorBadgesDAO', 5812 5814 'PhabricatorPolicyInterface',
+2
src/applications/badges/application/PhabricatorBadgesApplication.php
··· 45 45 => 'PhabricatorBadgesCommentController', 46 46 'edit/(?:(?P<id>\d+)/)?' 47 47 => 'PhabricatorBadgesEditController', 48 + 'archive/(?:(?P<id>\d+)/)?' 49 + => 'PhabricatorBadgesArchiveController', 48 50 'view/(?:(?P<id>\d+)/)?' 49 51 => 'PhabricatorBadgesViewController', 50 52 'icon/(?P<id>[1-9]\d*)/'
+68
src/applications/badges/controller/PhabricatorBadgesArchiveController.php
··· 1 + <?php 2 + 3 + final class PhabricatorBadgesArchiveController 4 + extends PhabricatorBadgesController { 5 + 6 + public function handleRequest(AphrontRequest $request) { 7 + $viewer = $request->getViewer(); 8 + $id = $request->getURIData('id'); 9 + 10 + $badge = id(new PhabricatorBadgesQuery()) 11 + ->setViewer($viewer) 12 + ->withIDs(array($id)) 13 + ->requireCapabilities( 14 + array( 15 + PhabricatorPolicyCapability::CAN_VIEW, 16 + PhabricatorPolicyCapability::CAN_EDIT, 17 + )) 18 + ->executeOne(); 19 + if (!$badge) { 20 + return new Aphront404Response(); 21 + } 22 + 23 + $view_uri = $this->getApplicationURI('view/'.$badge->getID().'/'); 24 + 25 + if ($request->isFormPost()) { 26 + if ($badge->isArchived()) { 27 + $new_status = PhabricatorBadgesBadge::STATUS_ACTIVE; 28 + } else { 29 + $new_status = PhabricatorBadgesBadge::STATUS_ARCHIVED; 30 + } 31 + 32 + $xactions = array(); 33 + 34 + $xactions[] = id(new PhabricatorBadgesTransaction()) 35 + ->setTransactionType(PhabricatorBadgesTransaction::TYPE_STATUS) 36 + ->setNewValue($new_status); 37 + 38 + id(new PhabricatorBadgesEditor()) 39 + ->setActor($viewer) 40 + ->setContentSourceFromRequest($request) 41 + ->setContinueOnNoEffect(true) 42 + ->setContinueOnMissingFields(true) 43 + ->applyTransactions($badge, $xactions); 44 + 45 + return id(new AphrontRedirectResponse())->setURI($view_uri); 46 + } 47 + 48 + if ($badge->isArchived()) { 49 + $title = pht('Activate Badge'); 50 + $body = pht('This badge will be re-commissioned into service.'); 51 + $button = pht('Activate Badge'); 52 + } else { 53 + $title = pht('Archive Badge'); 54 + $body = pht( 55 + 'This dedicated badge, once a distinguish icon of this install, '. 56 + 'shall be immediately retired from service, but will never far from '. 57 + 'our hearts. Godspeed.'); 58 + $button = pht('Archive Badge'); 59 + } 60 + 61 + return $this->newDialog() 62 + ->setTitle($title) 63 + ->appendChild($body) 64 + ->addCancelButton($view_uri) 65 + ->addSubmitButton($button); 66 + } 67 + 68 + }
-16
src/applications/badges/controller/PhabricatorBadgesEditController.php
··· 43 43 44 44 $e_name = true; 45 45 $v_name = $badge->getName(); 46 - 47 46 $v_icon = $badge->getIcon(); 48 - 49 47 $v_flav = $badge->getFlavor(); 50 48 $v_desc = $badge->getDescription(); 51 49 $v_qual = $badge->getQuality(); 52 - $v_stat = $badge->getStatus(); 53 - 54 50 $v_edit = $badge->getEditPolicy(); 55 51 56 52 $validation_exception = null; ··· 59 55 $v_flav = $request->getStr('flavor'); 60 56 $v_desc = $request->getStr('description'); 61 57 $v_icon = $request->getStr('icon'); 62 - $v_stat = $request->getStr('status'); 63 58 $v_qual = $request->getStr('quality'); 64 59 65 60 $v_view = $request->getStr('viewPolicy'); ··· 70 65 $type_desc = PhabricatorBadgesTransaction::TYPE_DESCRIPTION; 71 66 $type_icon = PhabricatorBadgesTransaction::TYPE_ICON; 72 67 $type_qual = PhabricatorBadgesTransaction::TYPE_QUALITY; 73 - $type_stat = PhabricatorBadgesTransaction::TYPE_STATUS; 74 68 75 69 $type_edit = PhabricatorTransactions::TYPE_EDIT_POLICY; 76 70 ··· 97 91 ->setNewValue($v_qual); 98 92 99 93 $xactions[] = id(new PhabricatorBadgesTransaction()) 100 - ->setTransactionType($type_stat) 101 - ->setNewValue($v_stat); 102 - 103 - $xactions[] = id(new PhabricatorBadgesTransaction()) 104 94 ->setTransactionType($type_edit) 105 95 ->setNewValue($v_edit); 106 96 ··· 160 150 ->setLabel(pht('Quality')) 161 151 ->setValue($v_qual) 162 152 ->setOptions($badge->getQualityNameMap())) 163 - ->appendChild( 164 - id(new AphrontFormSelectControl()) 165 - ->setLabel(pht('Status')) 166 - ->setName('status') 167 - ->setValue($v_stat) 168 - ->setOptions($badge->getStatusNameMap())) 169 153 ->appendChild( 170 154 id(new PhabricatorRemarkupControl()) 171 155 ->setUser($viewer)
+19 -2
src/applications/badges/controller/PhabricatorBadgesViewController.php
··· 24 24 $crumbs->addTextCrumb($badge->getName()); 25 25 $title = $badge->getName(); 26 26 27 - if ($badge->isClosed()) { 27 + if ($badge->isArchived()) { 28 28 $status_icon = 'fa-ban'; 29 29 $status_color = 'dark'; 30 30 } else { ··· 138 138 ->setName(pht('Edit Badge')) 139 139 ->setIcon('fa-pencil') 140 140 ->setDisabled(!$can_edit) 141 - ->setWorkflow(!$can_edit) 142 141 ->setHref($this->getApplicationURI("/edit/{$id}/"))); 142 + 143 + if ($badge->isArchived()) { 144 + $view->addAction( 145 + id(new PhabricatorActionView()) 146 + ->setName(pht('Activate Badge')) 147 + ->setIcon('fa-check') 148 + ->setDisabled(!$can_edit) 149 + ->setWorkflow($can_edit) 150 + ->setHref($this->getApplicationURI("/archive/{$id}/"))); 151 + } else { 152 + $view->addAction( 153 + id(new PhabricatorActionView()) 154 + ->setName(pht('Archive Badge')) 155 + ->setIcon('fa-ban') 156 + ->setDisabled(!$can_edit) 157 + ->setWorkflow($can_edit) 158 + ->setHref($this->getApplicationURI("/archive/{$id}/"))); 159 + } 143 160 144 161 $view->addAction( 145 162 id(new PhabricatorActionView())
+1 -1
src/applications/badges/phid/PhabricatorBadgesPHIDType.php
··· 35 35 $id = $badge->getID(); 36 36 $name = $badge->getName(); 37 37 38 - if ($badge->isClosed()) { 38 + if ($badge->isArchived()) { 39 39 $handle->setStatus(PhabricatorObjectHandle::STATUS_CLOSED); 40 40 } 41 41
+2 -2
src/applications/badges/query/PhabricatorBadgesSearchEngine.php
··· 84 84 return $query->setParameter( 85 85 'statuses', 86 86 array( 87 - PhabricatorBadgesBadge::STATUS_OPEN, 87 + PhabricatorBadgesBadge::STATUS_ACTIVE, 88 88 )); 89 89 } 90 90 ··· 124 124 ->addAttribute($quality) 125 125 ->addAttribute($badge->getFlavor()); 126 126 127 - if ($badge->isClosed()) { 127 + if ($badge->isArchived()) { 128 128 $item->setDisabled(true); 129 129 $item->addIcon('fa-ban', pht('Archived')); 130 130 }
+7 -7
src/applications/badges/storage/PhabricatorBadgesBadge.php
··· 21 21 22 22 private $recipientPHIDs = self::ATTACHABLE; 23 23 24 - const STATUS_OPEN = 'open'; 25 - const STATUS_CLOSED = 'closed'; 24 + const STATUS_ACTIVE = 'open'; 25 + const STATUS_ARCHIVED = 'closed'; 26 26 27 27 const DEFAULT_ICON = 'fa-star'; 28 28 const DEFAULT_QUALITY = 'green'; ··· 37 37 38 38 public static function getStatusNameMap() { 39 39 return array( 40 - self::STATUS_OPEN => pht('Active'), 41 - self::STATUS_CLOSED => pht('Archived'), 40 + self::STATUS_ACTIVE => pht('Active'), 41 + self::STATUS_ARCHIVED => pht('Archived'), 42 42 ); 43 43 } 44 44 ··· 74 74 ->setQuality(self::DEFAULT_QUALITY) 75 75 ->setCreatorPHID($actor->getPHID()) 76 76 ->setEditPolicy($edit_policy) 77 - ->setStatus(self::STATUS_OPEN); 77 + ->setStatus(self::STATUS_ACTIVE); 78 78 } 79 79 80 80 protected function getConfiguration() { ··· 102 102 PhabricatorPHID::generateNewPHID(PhabricatorBadgesPHIDType::TYPECONST); 103 103 } 104 104 105 - public function isClosed() { 106 - return ($this->getStatus() == self::STATUS_CLOSED); 105 + public function isArchived() { 106 + return ($this->getStatus() == self::STATUS_ARCHIVED); 107 107 } 108 108 109 109 public function attachRecipientPHIDs(array $phids) {
+2 -2
src/applications/badges/storage/PhabricatorBadgesTransaction.php
··· 155 155 $this->renderHandleLink($object_phid)); 156 156 case self::TYPE_STATUS: 157 157 switch ($new) { 158 - case PhabricatorBadgesBadge::STATUS_OPEN: 158 + case PhabricatorBadgesBadge::STATUS_ACTIVE: 159 159 return pht( 160 160 '%s activated %s.', 161 161 $this->renderHandleLink($author_phid), 162 162 $this->renderHandleLink($object_phid)); 163 - case PhabricatorBadgesBadge::STATUS_CLOSED: 163 + case PhabricatorBadgesBadge::STATUS_ARCHIVED: 164 164 return pht( 165 165 '%s archived %s.', 166 166 $this->renderHandleLink($author_phid),