mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-15 03:12:41 +01:00
ffc1b5c26a
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
75 lines
1.7 KiB
PHP
75 lines
1.7 KiB
PHP
<?php
|
|
|
|
final class LegalpadDocumentSignature
|
|
extends LegalpadDAO
|
|
implements PhabricatorPolicyInterface {
|
|
|
|
const VERIFIED = 0;
|
|
const UNVERIFIED = 1;
|
|
|
|
protected $documentPHID;
|
|
protected $documentVersion;
|
|
protected $signerPHID;
|
|
protected $signerName;
|
|
protected $signerEmail;
|
|
protected $signatureData = array();
|
|
protected $verified;
|
|
protected $secretKey;
|
|
|
|
private $document = self::ATTACHABLE;
|
|
|
|
public function getConfiguration() {
|
|
return array(
|
|
self::CONFIG_SERIALIZATION => array(
|
|
'signatureData' => self::SERIALIZATION_JSON,
|
|
),
|
|
) + parent::getConfiguration();
|
|
}
|
|
|
|
public function save() {
|
|
if (!$this->getSecretKey()) {
|
|
$this->setSecretKey(Filesystem::readRandomCharacters(20));
|
|
}
|
|
return parent::save();
|
|
}
|
|
|
|
public function isVerified() {
|
|
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,
|
|
);
|
|
}
|
|
|
|
public function getPolicy($capability) {
|
|
switch ($capability) {
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
|
return $this->getDocument()->getPolicy(
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
|
}
|
|
}
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
|
return ($viewer->getPHID() == $this->getSignerPHID());
|
|
}
|
|
|
|
public function describeAutomaticCapability($capability) {
|
|
return null;
|
|
}
|
|
|
|
}
|