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

Show signature status on Legalpad main view

Summary: Ref T3116. Tweak the main Legalpad view a bit -- in particular, show signature status.

Test Plan: {F171641}

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T3116

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

+70 -7
+29
src/applications/legalpad/query/LegalpadDocumentQuery.php
··· 14 14 private $needDocumentBodies; 15 15 private $needContributors; 16 16 private $needSignatures; 17 + private $needViewerSignatures; 17 18 18 19 public function withIDs(array $ids) { 19 20 $this->ids = $ids; ··· 65 66 return $this; 66 67 } 67 68 69 + public function needViewerSignatures($need) { 70 + $this->needViewerSignatures = $need; 71 + return $this; 72 + } 73 + 68 74 protected function loadPage() { 69 75 $table = new LegalpadDocument(); 70 76 $conn_r = $table->establishConnection('r'); ··· 116 122 117 123 if ($this->needSignatures) { 118 124 $documents = $this->loadSignatures($documents); 125 + } 126 + 127 + if ($this->needViewerSignatures) { 128 + if ($documents) { 129 + 130 + if ($this->getViewer()->getPHID()) { 131 + $signatures = id(new LegalpadDocumentSignatureQuery()) 132 + ->setViewer($this->getViewer()) 133 + ->withSignerPHIDs(array($this->getViewer()->getPHID())) 134 + ->withDocumentPHIDs(mpull($documents, 'getPHID')) 135 + ->execute(); 136 + $signatures = mpull($signatures, null, 'getDocumentPHID'); 137 + } else { 138 + $signatures = array(); 139 + } 140 + 141 + foreach ($documents as $document) { 142 + $signature = idx($signatures, $document->getPHID()); 143 + $document->attachUserSignature( 144 + $this->getViewer()->getPHID(), 145 + $signature); 146 + } 147 + } 119 148 } 120 149 121 150 return $documents;
+28 -6
src/applications/legalpad/query/LegalpadDocumentSearchEngine.php
··· 29 29 30 30 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 31 31 $query = id(new LegalpadDocumentQuery()) 32 + ->needViewerSignatures(true) 32 33 ->withCreatorPHIDs($saved->getParameter('creatorPHIDs', array())) 33 34 ->withContributorPHIDs($saved->getParameter('contributorPHIDs', array())); 34 35 ··· 111 112 protected function getRequiredHandlePHIDsForResultList( 112 113 array $documents, 113 114 PhabricatorSavedQuery $query) { 114 - return array_mergev(mpull($documents, 'getRecentContributorPHIDs')); 115 + return array(); 115 116 } 116 117 117 118 protected function renderResultList( ··· 126 127 $list->setUser($viewer); 127 128 foreach ($documents as $document) { 128 129 $last_updated = phabricator_date($document->getDateModified(), $viewer); 129 - $recent_contributors = $document->getRecentContributorPHIDs(); 130 - $updater = $handles[reset($recent_contributors)]->renderLink(); 131 130 132 131 $title = $document->getTitle(); 133 132 ··· 136 135 ->setHeader($title) 137 136 ->setHref('/'.$document->getMonogram()) 138 137 ->setObject($document) 139 - ->addIcon('none', pht('Last updated: %s', $last_updated)) 140 - ->addByline(pht('Updated by: %s', $updater)) 141 - ->addAttribute(pht('Versions: %d', $document->getVersions())); 138 + ->addIcon('none', pht('Version %d', $document->getVersions())) 139 + ->addIcon('none', pht('Updated %s', $last_updated)); 140 + 141 + if ($viewer->getPHID()) { 142 + $signature = $document->getUserSignature($viewer->getPHID()); 143 + } else { 144 + $signature = null; 145 + } 146 + 147 + if ($signature) { 148 + $item->addAttribute( 149 + array( 150 + id(new PHUIIconView())->setIconFont('fa-check-square-o', 'green'), 151 + ' ', 152 + pht( 153 + 'Signed on %s', 154 + phabricator_date($signature->getDateCreated(), $viewer)), 155 + )); 156 + } else { 157 + $item->addAttribute( 158 + array( 159 + id(new PHUIIconView())->setIconFont('fa-square-o', 'grey'), 160 + ' ', 161 + pht('Not Signed'), 162 + )); 163 + } 142 164 143 165 $list->addItem($item); 144 166 }
+13 -1
src/applications/legalpad/storage/LegalpadDocument.php
··· 18 18 19 19 private $documentBody = self::ATTACHABLE; 20 20 private $contributors = self::ATTACHABLE; 21 - private $signatures = self::ATTACHABLE; 21 + private $signatures = self::ATTACHABLE; 22 + private $userSignatures = array(); 22 23 23 24 public static function initializeNewDocument(PhabricatorUser $actor) { 24 25 $app = id(new PhabricatorApplicationQuery()) ··· 89 90 90 91 public function getMonogram() { 91 92 return 'L'.$this->getID(); 93 + } 94 + 95 + public function getUserSignature($phid) { 96 + return $this->assertAttachedKey($this->userSignatures, $phid); 97 + } 98 + 99 + public function attachUserSignature( 100 + $user_phid, 101 + LegalpadDocumentSignature $signature = null) { 102 + $this->userSignatures[$user_phid] = $signature; 103 + return $this; 92 104 } 93 105 94 106