mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 16:30:59 +01:00
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
This commit is contained in:
parent
94926698e0
commit
ffc1b5c26a
6 changed files with 93 additions and 9 deletions
7
resources/sql/autopatches/20140629.legalsig.1.sql
Normal file
7
resources/sql/autopatches/20140629.legalsig.1.sql
Normal file
|
@ -0,0 +1,7 @@
|
|||
ALTER TABLE {$NAMESPACE}_legalpad.legalpad_documentsignature
|
||||
ADD signerName VARCHAR(255) NOT NULL COLLATE utf8_general_ci
|
||||
AFTER signerPHID;
|
||||
|
||||
ALTER TABLE {$NAMESPACE}_legalpad.legalpad_documentsignature
|
||||
ADD signerEmail VARCHAR(255) NOT NULL COLLATE utf8_general_ci
|
||||
AFTER signerName;
|
17
resources/sql/autopatches/20140629.legalsig.2.php
Normal file
17
resources/sql/autopatches/20140629.legalsig.2.php
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
$table = new LegalpadDocumentSignature();
|
||||
$conn_w = $table->establishConnection('w');
|
||||
foreach (new LiskMigrationIterator($table) as $signature) {
|
||||
echo pht("Updating Legalpad signature %d...\n", $signature->getID());
|
||||
|
||||
$data = $signature->getSignatureData();
|
||||
|
||||
queryfx(
|
||||
$conn_w,
|
||||
'UPDATE %T SET signerName = %s, signerEmail = %s WHERE id = %d',
|
||||
$table->getTableName(),
|
||||
(string)idx($data, 'name'),
|
||||
(string)idx($data, 'email'),
|
||||
$signature->getID());
|
||||
}
|
|
@ -82,6 +82,8 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
->setSignerPHID($signer_phid)
|
||||
->setDocumentPHID($document->getPHID())
|
||||
->setDocumentVersion($document->getVersions())
|
||||
->setSignerName((string)idx($signature_data, 'name'))
|
||||
->setSignerEmail((string)idx($signature_data, 'email'))
|
||||
->setSignatureData($signature_data);
|
||||
|
||||
// If the user is logged in, show a notice that they haven't signed.
|
||||
|
@ -118,11 +120,13 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
if ($request->isFormOrHisecPost() && !$has_signed) {
|
||||
|
||||
// Require two-factor auth to sign legal documents.
|
||||
$engine = new PhabricatorAuthSessionEngine();
|
||||
$engine->requireHighSecuritySession(
|
||||
$viewer,
|
||||
$request,
|
||||
'/'.$document->getMonogram());
|
||||
if ($viewer->isLoggedIn()) {
|
||||
$engine = new PhabricatorAuthSessionEngine();
|
||||
$engine->requireHighSecuritySession(
|
||||
$viewer,
|
||||
$request,
|
||||
'/'.$document->getMonogram());
|
||||
}
|
||||
|
||||
$name = $request->getStr('name');
|
||||
$agree = $request->getExists('agree');
|
||||
|
@ -157,6 +161,8 @@ final class LegalpadDocumentSignController extends LegalpadController {
|
|||
}
|
||||
$signature_data['email'] = $email;
|
||||
|
||||
$signature->setSignerName((string)idx($signature_data, 'name'));
|
||||
$signature->setSignerEmail((string)idx($signature_data, 'email'));
|
||||
$signature->setSignatureData($signature_data);
|
||||
|
||||
if (!$agree) {
|
||||
|
|
|
@ -8,6 +8,8 @@ final class LegalpadDocumentSignatureQuery
|
|||
private $signerPHIDs;
|
||||
private $documentVersions;
|
||||
private $secretKeys;
|
||||
private $nameContains;
|
||||
private $emailContains;
|
||||
|
||||
public function withIDs(array $ids) {
|
||||
$this->ids = $ids;
|
||||
|
@ -34,6 +36,16 @@ final class LegalpadDocumentSignatureQuery
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function withNameContains($text) {
|
||||
$this->nameContains = $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withEmailContains($text) {
|
||||
$this->emailContains = $text;
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function loadPage() {
|
||||
$table = new LegalpadDocumentSignature();
|
||||
$conn_r = $table->establishConnection('r');
|
||||
|
@ -114,6 +126,20 @@ final class LegalpadDocumentSignatureQuery
|
|||
$this->secretKeys);
|
||||
}
|
||||
|
||||
if ($this->nameContains !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'signerName LIKE %~',
|
||||
$this->nameContains);
|
||||
}
|
||||
|
||||
if ($this->emailContains !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn_r,
|
||||
'signerEmail LIKE %~',
|
||||
$this->emailContains);
|
||||
}
|
||||
|
||||
return $this->formatWhereClause($where);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,9 @@ final class LegalpadDocumentSignatureSearchEngine
|
|||
PhabricatorLegalpadPHIDTypeDocument::TYPECONST,
|
||||
)));
|
||||
|
||||
$saved->setParameter('nameContains', $request->getStr('nameContains'));
|
||||
$saved->setParameter('emailContains', $request->getStr('emailContains'));
|
||||
|
||||
return $saved;
|
||||
}
|
||||
|
||||
|
@ -54,6 +57,16 @@ final class LegalpadDocumentSignatureSearchEngine
|
|||
}
|
||||
}
|
||||
|
||||
$name_contains = $saved->getParameter('nameContains');
|
||||
if (strlen($name_contains)) {
|
||||
$query->withNameContains($name_contains);
|
||||
}
|
||||
|
||||
$email_contains = $saved->getParameter('emailContains');
|
||||
if (strlen($email_contains)) {
|
||||
$query->withEmailContains($email_contains);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
@ -80,13 +93,26 @@ final class LegalpadDocumentSignatureSearchEngine
|
|||
->setValue(array_select_keys($handles, $document_phids)));
|
||||
}
|
||||
|
||||
$name_contains = $saved_query->getParameter('nameContains', '');
|
||||
$email_contains = $saved_query->getParameter('emailContains', '');
|
||||
|
||||
$form
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/users/')
|
||||
->setName('signers')
|
||||
->setLabel(pht('Signers'))
|
||||
->setValue(array_select_keys($handles, $signer_phids)));
|
||||
->setValue(array_select_keys($handles, $signer_phids)))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel(pht('Name Contains'))
|
||||
->setName('nameContains')
|
||||
->setValue($name_contains))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel(pht('Email Contains'))
|
||||
->setName('emailContains')
|
||||
->setValue($email_contains));
|
||||
}
|
||||
|
||||
protected function getURI($path) {
|
||||
|
@ -159,9 +185,8 @@ final class LegalpadDocumentSignatureSearchEngine
|
|||
|
||||
$rows = array();
|
||||
foreach ($signatures as $signature) {
|
||||
$data = $signature->getSignatureData();
|
||||
$name = idx($data, 'name');
|
||||
$email = idx($data, 'email');
|
||||
$name = $signature->getSignerName();
|
||||
$email = $signature->getSignerEmail();
|
||||
|
||||
$document = $signature->getDocument();
|
||||
|
||||
|
@ -189,6 +214,7 @@ final class LegalpadDocumentSignatureSearchEngine
|
|||
}
|
||||
|
||||
$table = id(new AphrontTableView($rows))
|
||||
->setNoDataString(pht('No signatures match the query.'))
|
||||
->setHeaders(
|
||||
array(
|
||||
'',
|
||||
|
|
|
@ -10,6 +10,8 @@ final class LegalpadDocumentSignature
|
|||
protected $documentPHID;
|
||||
protected $documentVersion;
|
||||
protected $signerPHID;
|
||||
protected $signerName;
|
||||
protected $signerEmail;
|
||||
protected $signatureData = array();
|
||||
protected $verified;
|
||||
protected $secretKey;
|
||||
|
|
Loading…
Reference in a new issue