@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.

Allow setting of Archive/Active on Paste

Summary: Ref T9076, adds basic plumbing for setting the state of a Paste.

Test Plan: Archive Paste, Activate Paste, New Paste

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T9076

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

+74
+2
resources/sql/autopatches/20150805.paste.status.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_pastebin.pastebin_paste 2 + ADD status VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
+2
resources/sql/autopatches/20150805.paste.status.2.sql
··· 1 + UPDATE {$NAMESPACE}_pastebin.pastebin_paste 2 + SET status = 'active' WHERE status = '';
+12
src/applications/paste/controller/PhabricatorPasteEditController.php
··· 64 64 } 65 65 $v_view_policy = $paste->getViewPolicy(); 66 66 $v_edit_policy = $paste->getEditPolicy(); 67 + $v_status = $paste->getStatus(); 67 68 68 69 if ($is_create) { 69 70 $v_projects = array(); ··· 85 86 $v_edit_policy = $request->getStr('can_edit'); 86 87 $v_projects = $request->getArr('projects'); 87 88 $v_space = $request->getStr('spacePHID'); 89 + $v_status = $request->getStr('status'); 88 90 89 91 // NOTE: The author is the only editor and can always view the paste, 90 92 // so it's impossible for them to choose an invalid policy. ··· 115 117 $xactions[] = id(new PhabricatorPasteTransaction()) 116 118 ->setTransactionType(PhabricatorTransactions::TYPE_SPACE) 117 119 ->setNewValue($v_space); 120 + $xactions[] = id(new PhabricatorPasteTransaction()) 121 + ->setTransactionType(PhabricatorPasteTransaction::TYPE_STATUS) 122 + ->setNewValue($v_status); 118 123 119 124 $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 120 125 $xactions[] = id(new PhabricatorPasteTransaction()) ··· 179 184 ->setPolicies($policies) 180 185 ->setValue($v_edit_policy) 181 186 ->setName('can_edit')); 187 + 188 + $form->appendChild( 189 + id(new AphrontFormSelectControl()) 190 + ->setLabel(pht('Status')) 191 + ->setName('status') 192 + ->setValue($v_status) 193 + ->setOptions($paste->getStatusNameMap())); 182 194 183 195 $form->appendControl( 184 196 id(new AphrontFormTokenizerControl())
+12
src/applications/paste/controller/PhabricatorPasteViewController.php
··· 115 115 private function buildHeaderView(PhabricatorPaste $paste) { 116 116 $title = (nonempty($paste->getTitle())) ? 117 117 $paste->getTitle() : pht('(An Untitled Masterwork)'); 118 + 119 + if ($paste->isArchived()) { 120 + $header_icon = 'fa-ban'; 121 + $header_name = pht('Archived'); 122 + $header_color = 'dark'; 123 + } else { 124 + $header_icon = 'fa-check'; 125 + $header_name = pht('Active'); 126 + $header_color = 'bluegrey'; 127 + } 128 + 118 129 $header = id(new PHUIHeaderView()) 119 130 ->setHeader($title) 120 131 ->setUser($this->getRequest()->getUser()) 132 + ->setStatus($header_icon, $header_color, $header_name) 121 133 ->setPolicyObject($paste); 122 134 123 135 return $header;
+8
src/applications/paste/editor/PhabricatorPasteEditor.php
··· 33 33 $types[] = PhabricatorPasteTransaction::TYPE_CONTENT; 34 34 $types[] = PhabricatorPasteTransaction::TYPE_TITLE; 35 35 $types[] = PhabricatorPasteTransaction::TYPE_LANGUAGE; 36 + $types[] = PhabricatorPasteTransaction::TYPE_STATUS; 36 37 $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY; 37 38 $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY; 38 39 $types[] = PhabricatorTransactions::TYPE_COMMENT; ··· 51 52 return $object->getTitle(); 52 53 case PhabricatorPasteTransaction::TYPE_LANGUAGE: 53 54 return $object->getLanguage(); 55 + case PhabricatorPasteTransaction::TYPE_STATUS: 56 + return $object->getStatus(); 54 57 } 55 58 } 56 59 ··· 62 65 case PhabricatorPasteTransaction::TYPE_CONTENT: 63 66 case PhabricatorPasteTransaction::TYPE_TITLE: 64 67 case PhabricatorPasteTransaction::TYPE_LANGUAGE: 68 + case PhabricatorPasteTransaction::TYPE_STATUS: 65 69 return $xaction->getNewValue(); 66 70 } 67 71 } ··· 80 84 case PhabricatorPasteTransaction::TYPE_LANGUAGE: 81 85 $object->setLanguage($xaction->getNewValue()); 82 86 return; 87 + case PhabricatorPasteTransaction::TYPE_STATUS: 88 + $object->setStatus($xaction->getNewValue()); 89 + return; 83 90 } 84 91 85 92 return parent::applyCustomInternalTransaction($object, $xaction); ··· 93 100 case PhabricatorPasteTransaction::TYPE_CONTENT: 94 101 case PhabricatorPasteTransaction::TYPE_TITLE: 95 102 case PhabricatorPasteTransaction::TYPE_LANGUAGE: 103 + case PhabricatorPasteTransaction::TYPE_STATUS: 96 104 return; 97 105 } 98 106
+17
src/applications/paste/storage/PhabricatorPaste.php
··· 20 20 protected $viewPolicy; 21 21 protected $editPolicy; 22 22 protected $mailKey; 23 + protected $status; 23 24 protected $spacePHID; 25 + 26 + const STATUS_ACTIVE = 'active'; 27 + const STATUS_ARCHIVED = 'archived'; 24 28 25 29 private $content = self::ATTACHABLE; 26 30 private $rawContent = self::ATTACHABLE; ··· 36 40 37 41 return id(new PhabricatorPaste()) 38 42 ->setTitle('') 43 + ->setStatus(self::STATUS_ACTIVE) 39 44 ->setAuthorPHID($actor->getPHID()) 40 45 ->setViewPolicy($view_policy) 41 46 ->setEditPolicy($edit_policy) 42 47 ->setSpacePHID($actor->getDefaultSpacePHID()); 43 48 } 44 49 50 + public static function getStatusNameMap() { 51 + return array( 52 + self::STATUS_ACTIVE => pht('Active'), 53 + self::STATUS_ARCHIVED => pht('Archived'), 54 + ); 55 + } 56 + 45 57 public function getURI() { 46 58 return '/'.$this->getMonogram(); 47 59 } ··· 54 66 return array( 55 67 self::CONFIG_AUX_PHID => true, 56 68 self::CONFIG_COLUMN_SCHEMA => array( 69 + 'status' => 'text32', 57 70 'title' => 'text255', 58 71 'language' => 'text64', 59 72 'mailKey' => 'bytes20', ··· 83 96 public function generatePHID() { 84 97 return PhabricatorPHID::generateNewPHID( 85 98 PhabricatorPastePastePHIDType::TYPECONST); 99 + } 100 + 101 + public function isArchived() { 102 + return ($this->getStatus() == self::STATUS_ARCHIVED); 86 103 } 87 104 88 105 public function save() {
+21
src/applications/paste/storage/PhabricatorPasteTransaction.php
··· 6 6 const TYPE_CONTENT = 'paste.create'; 7 7 const TYPE_TITLE = 'paste.title'; 8 8 const TYPE_LANGUAGE = 'paste.language'; 9 + const TYPE_STATUS = 'paste.status'; 9 10 10 11 const MAILTAG_CONTENT = 'paste-content'; 11 12 const MAILTAG_OTHER = 'paste-other'; ··· 89 90 "%s updated the paste's language.", 90 91 $this->renderHandleLink($author_phid)); 91 92 break; 93 + case self::TYPE_STATUS: 94 + return pht( 95 + "%s updated the paste's status.", 96 + $this->renderHandleLink($author_phid)); 97 + break; 98 + 92 99 } 93 100 94 101 return parent::getTitle(); ··· 127 134 '%s updated the language for %s.', 128 135 $this->renderHandleLink($author_phid), 129 136 $this->renderHandleLink($object_phid)); 137 + break; 138 + case self::TYPE_STATUS: 139 + switch ($new) { 140 + case self::STATUS_OPEN: 141 + return pht( 142 + '%s activated %s.', 143 + $this->renderHandleLink($author_phid), 144 + $this->renderHandleLink($object_phid)); 145 + case self::STATUS_CLOSED: 146 + return pht( 147 + '%s archived %s.', 148 + $this->renderHandleLink($author_phid), 149 + $this->renderHandleLink($object_phid)); 150 + } 130 151 break; 131 152 } 132 153