Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14002294
D9764.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D9764.id.diff
View Options
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
@@ -46,9 +46,32 @@
$this->buildOrderClause($conn_r),
$this->buildLimitClause($conn_r));
- $documents = $table->loadAllFromArray($data);
+ $signatures = $table->loadAllFromArray($data);
- return $documents;
+ return $signatures;
+ }
+
+ protected function willFilterPage(array $signatures) {
+ $document_phids = mpull($signatures, 'getDocumentPHID');
+
+ $documents = id(new LegalpadDocumentQuery())
+ ->setParentQuery($this)
+ ->setViewer($this->getViewer())
+ ->withPHIDs($document_phids)
+ ->execute();
+ $documents = mpull($documents, null, 'getPHID');
+
+ foreach ($signatures as $key => $signature) {
+ $document_phid = $signature->getDocumentPHID();
+ $document = idx($documents, $document_phid);
+ if ($document) {
+ $signature->attachDocument($document);
+ } else {
+ unset($signatures[$key]);
+ }
+ }
+
+ return $signatures;
}
protected function buildWhereClause($conn_r) {
@@ -56,35 +79,35 @@
$where[] = $this->buildPagingClause($conn_r);
- if ($this->ids) {
+ if ($this->ids !== null) {
$where[] = qsprintf(
$conn_r,
'id IN (%Ld)',
$this->ids);
}
- if ($this->documentPHIDs) {
+ if ($this->documentPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
'documentPHID IN (%Ls)',
$this->documentPHIDs);
}
- if ($this->signerPHIDs) {
+ if ($this->signerPHIDs !== null) {
$where[] = qsprintf(
$conn_r,
'signerPHID IN (%Ls)',
$this->signerPHIDs);
}
- if ($this->documentVersions) {
+ if ($this->documentVersions !== null) {
$where[] = qsprintf(
$conn_r,
'documentVersion IN (%Ld)',
$this->documentVersions);
}
- if ($this->secretKeys) {
+ if ($this->secretKeys !== null) {
$where[] = qsprintf(
$conn_r,
'secretKey IN (%Ls)',
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
@@ -14,6 +14,8 @@
protected $verified;
protected $secretKey;
+ private $document = self::ATTACHABLE;
+
public function getConfiguration() {
return array(
self::CONFIG_SERIALIZATION => array(
@@ -30,10 +32,22 @@
}
public function isVerified() {
- return $this->getVerified() != self::UNVERIFIED;
+ return ($this->getVerified() != self::UNVERIFIED);
+ }
+
+ public function getDocument() {
+ return $this->assertAttached($this->document);
+ }
+
+ public function attachDocument(LegalpadDocument $document) {
+ $this->document = $document;
+ return $this;
}
+
+
/* -( PhabricatorPolicyInterface )----------------------------------------- */
+
public function getCapabilities() {
return array(
PhabricatorPolicyCapability::CAN_VIEW,
@@ -43,12 +57,13 @@
public function getPolicy($capability) {
switch ($capability) {
case PhabricatorPolicyCapability::CAN_VIEW:
- return PhabricatorPolicies::POLICY_USER;
+ return $this->getDocument()->getPolicy(
+ PhabricatorPolicyCapability::CAN_EDIT);
}
}
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
- return false;
+ return ($viewer->getPHID() == $this->getSignerPHID());
}
public function describeAutomaticCapability($capability) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 26, 5:30 PM (2 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6745034
Default Alt Text
D9764.id.diff (3 KB)
Attached To
Mode
D9764: Make document signatures visible to only document owners and signers
Attached
Detach File
Event Timeline
Log In to Comment