Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15382503
D9776.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Referenced Files
None
Subscribers
None
D9776.diff
View Options
diff --git a/resources/sql/autopatches/20140629.legalsig.1.sql b/resources/sql/autopatches/20140629.legalsig.1.sql
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140629.legalsig.1.sql
@@ -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;
diff --git a/resources/sql/autopatches/20140629.legalsig.2.php b/resources/sql/autopatches/20140629.legalsig.2.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20140629.legalsig.2.php
@@ -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());
+}
diff --git a/src/applications/legalpad/controller/LegalpadDocumentSignController.php b/src/applications/legalpad/controller/LegalpadDocumentSignController.php
--- a/src/applications/legalpad/controller/LegalpadDocumentSignController.php
+++ b/src/applications/legalpad/controller/LegalpadDocumentSignController.php
@@ -82,6 +82,8 @@
->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 @@
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 @@
}
$signature_data['email'] = $email;
+ $signature->setSignerName((string)idx($signature_data, 'name'));
+ $signature->setSignerEmail((string)idx($signature_data, 'email'));
$signature->setSignatureData($signature_data);
if (!$agree) {
diff --git a/src/applications/legalpad/query/LegalpadDocumentSignatureQuery.php b/src/applications/legalpad/query/LegalpadDocumentSignatureQuery.php
--- a/src/applications/legalpad/query/LegalpadDocumentSignatureQuery.php
+++ b/src/applications/legalpad/query/LegalpadDocumentSignatureQuery.php
@@ -8,6 +8,8 @@
private $signerPHIDs;
private $documentVersions;
private $secretKeys;
+ private $nameContains;
+ private $emailContains;
public function withIDs(array $ids) {
$this->ids = $ids;
@@ -34,6 +36,16 @@
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 @@
$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);
}
diff --git a/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php b/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php
--- a/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php
+++ b/src/applications/legalpad/query/LegalpadDocumentSignatureSearchEngine.php
@@ -34,6 +34,9 @@
PhabricatorLegalpadPHIDTypeDocument::TYPECONST,
)));
+ $saved->setParameter('nameContains', $request->getStr('nameContains'));
+ $saved->setParameter('emailContains', $request->getStr('emailContains'));
+
return $saved;
}
@@ -54,6 +57,16 @@
}
}
+ $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 @@
->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 @@
$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 @@
}
$table = id(new AphrontTableView($rows))
+ ->setNoDataString(pht('No signatures match the query.'))
->setHeaders(
array(
'',
diff --git a/src/applications/legalpad/storage/LegalpadDocumentSignature.php b/src/applications/legalpad/storage/LegalpadDocumentSignature.php
--- a/src/applications/legalpad/storage/LegalpadDocumentSignature.php
+++ b/src/applications/legalpad/storage/LegalpadDocumentSignature.php
@@ -10,6 +10,8 @@
protected $documentPHID;
protected $documentVersion;
protected $signerPHID;
+ protected $signerName;
+ protected $signerEmail;
protected $signatureData = array();
protected $verified;
protected $secretKey;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Mar 15, 12:45 PM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7382971
Default Alt Text
D9776.diff (7 KB)
Attached To
Mode
D9776: Allow users to search for signatures by name and email substrings
Attached
Detach File
Event Timeline
Log In to Comment