@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 users to search for signatures by name and email substrings

Summary:
Ref T3116. In the case of anonymous signers, there's no way to do a quick way to check if someone has signed a doc since you can't query by their (nonexistent) external account ID.

Move "name" and "email" to first-class columns and let the engine search for them.

Test Plan: Searched for signatures with name and email fragments.

Reviewers: btrahan, chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T3116

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

+93 -9
+7
resources/sql/autopatches/20140629.legalsig.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_legalpad.legalpad_documentsignature 2 + ADD signerName VARCHAR(255) NOT NULL COLLATE utf8_general_ci 3 + AFTER signerPHID; 4 + 5 + ALTER TABLE {$NAMESPACE}_legalpad.legalpad_documentsignature 6 + ADD signerEmail VARCHAR(255) NOT NULL COLLATE utf8_general_ci 7 + AFTER signerName;
+17
resources/sql/autopatches/20140629.legalsig.2.php
··· 1 + <?php 2 + 3 + $table = new LegalpadDocumentSignature(); 4 + $conn_w = $table->establishConnection('w'); 5 + foreach (new LiskMigrationIterator($table) as $signature) { 6 + echo pht("Updating Legalpad signature %d...\n", $signature->getID()); 7 + 8 + $data = $signature->getSignatureData(); 9 + 10 + queryfx( 11 + $conn_w, 12 + 'UPDATE %T SET signerName = %s, signerEmail = %s WHERE id = %d', 13 + $table->getTableName(), 14 + (string)idx($data, 'name'), 15 + (string)idx($data, 'email'), 16 + $signature->getID()); 17 + }
+11 -5
src/applications/legalpad/controller/LegalpadDocumentSignController.php
··· 82 82 ->setSignerPHID($signer_phid) 83 83 ->setDocumentPHID($document->getPHID()) 84 84 ->setDocumentVersion($document->getVersions()) 85 + ->setSignerName((string)idx($signature_data, 'name')) 86 + ->setSignerEmail((string)idx($signature_data, 'email')) 85 87 ->setSignatureData($signature_data); 86 88 87 89 // If the user is logged in, show a notice that they haven't signed. ··· 118 120 if ($request->isFormOrHisecPost() && !$has_signed) { 119 121 120 122 // Require two-factor auth to sign legal documents. 121 - $engine = new PhabricatorAuthSessionEngine(); 122 - $engine->requireHighSecuritySession( 123 - $viewer, 124 - $request, 125 - '/'.$document->getMonogram()); 123 + if ($viewer->isLoggedIn()) { 124 + $engine = new PhabricatorAuthSessionEngine(); 125 + $engine->requireHighSecuritySession( 126 + $viewer, 127 + $request, 128 + '/'.$document->getMonogram()); 129 + } 126 130 127 131 $name = $request->getStr('name'); 128 132 $agree = $request->getExists('agree'); ··· 157 161 } 158 162 $signature_data['email'] = $email; 159 163 164 + $signature->setSignerName((string)idx($signature_data, 'name')); 165 + $signature->setSignerEmail((string)idx($signature_data, 'email')); 160 166 $signature->setSignatureData($signature_data); 161 167 162 168 if (!$agree) {
+26
src/applications/legalpad/query/LegalpadDocumentSignatureQuery.php
··· 8 8 private $signerPHIDs; 9 9 private $documentVersions; 10 10 private $secretKeys; 11 + private $nameContains; 12 + private $emailContains; 11 13 12 14 public function withIDs(array $ids) { 13 15 $this->ids = $ids; ··· 31 33 32 34 public function withSecretKeys(array $keys) { 33 35 $this->secretKeys = $keys; 36 + return $this; 37 + } 38 + 39 + public function withNameContains($text) { 40 + $this->nameContains = $text; 41 + return $this; 42 + } 43 + 44 + public function withEmailContains($text) { 45 + $this->emailContains = $text; 34 46 return $this; 35 47 } 36 48 ··· 112 124 $conn_r, 113 125 'secretKey IN (%Ls)', 114 126 $this->secretKeys); 127 + } 128 + 129 + if ($this->nameContains !== null) { 130 + $where[] = qsprintf( 131 + $conn_r, 132 + 'signerName LIKE %~', 133 + $this->nameContains); 134 + } 135 + 136 + if ($this->emailContains !== null) { 137 + $where[] = qsprintf( 138 + $conn_r, 139 + 'signerEmail LIKE %~', 140 + $this->emailContains); 115 141 } 116 142 117 143 return $this->formatWhereClause($where);
+30 -4
src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php
··· 34 34 PhabricatorLegalpadPHIDTypeDocument::TYPECONST, 35 35 ))); 36 36 37 + $saved->setParameter('nameContains', $request->getStr('nameContains')); 38 + $saved->setParameter('emailContains', $request->getStr('emailContains')); 39 + 37 40 return $saved; 38 41 } 39 42 ··· 54 57 } 55 58 } 56 59 60 + $name_contains = $saved->getParameter('nameContains'); 61 + if (strlen($name_contains)) { 62 + $query->withNameContains($name_contains); 63 + } 64 + 65 + $email_contains = $saved->getParameter('emailContains'); 66 + if (strlen($email_contains)) { 67 + $query->withEmailContains($email_contains); 68 + } 69 + 57 70 return $query; 58 71 } 59 72 ··· 80 93 ->setValue(array_select_keys($handles, $document_phids))); 81 94 } 82 95 96 + $name_contains = $saved_query->getParameter('nameContains', ''); 97 + $email_contains = $saved_query->getParameter('emailContains', ''); 98 + 83 99 $form 84 100 ->appendChild( 85 101 id(new AphrontFormTokenizerControl()) 86 102 ->setDatasource('/typeahead/common/users/') 87 103 ->setName('signers') 88 104 ->setLabel(pht('Signers')) 89 - ->setValue(array_select_keys($handles, $signer_phids))); 105 + ->setValue(array_select_keys($handles, $signer_phids))) 106 + ->appendChild( 107 + id(new AphrontFormTextControl()) 108 + ->setLabel(pht('Name Contains')) 109 + ->setName('nameContains') 110 + ->setValue($name_contains)) 111 + ->appendChild( 112 + id(new AphrontFormTextControl()) 113 + ->setLabel(pht('Email Contains')) 114 + ->setName('emailContains') 115 + ->setValue($email_contains)); 90 116 } 91 117 92 118 protected function getURI($path) { ··· 159 185 160 186 $rows = array(); 161 187 foreach ($signatures as $signature) { 162 - $data = $signature->getSignatureData(); 163 - $name = idx($data, 'name'); 164 - $email = idx($data, 'email'); 188 + $name = $signature->getSignerName(); 189 + $email = $signature->getSignerEmail(); 165 190 166 191 $document = $signature->getDocument(); 167 192 ··· 189 214 } 190 215 191 216 $table = id(new AphrontTableView($rows)) 217 + ->setNoDataString(pht('No signatures match the query.')) 192 218 ->setHeaders( 193 219 array( 194 220 '',
+2
src/applications/legalpad/storage/LegalpadDocumentSignature.php
··· 10 10 protected $documentPHID; 11 11 protected $documentVersion; 12 12 protected $signerPHID; 13 + protected $signerName; 14 + protected $signerEmail; 13 15 protected $signatureData = array(); 14 16 protected $verified; 15 17 protected $secretKey;