2013-07-03 20:15:45 +02:00
|
|
|
<?php
|
|
|
|
|
2014-01-17 20:40:26 +01:00
|
|
|
final class LegalpadDocumentSignature
|
|
|
|
extends LegalpadDAO
|
|
|
|
implements PhabricatorPolicyInterface {
|
2013-07-03 20:15:45 +02:00
|
|
|
|
2014-01-15 02:17:18 +01:00
|
|
|
const VERIFIED = 0;
|
|
|
|
const UNVERIFIED = 1;
|
|
|
|
|
2013-07-03 20:15:45 +02:00
|
|
|
protected $documentPHID;
|
2013-07-10 20:46:39 +02:00
|
|
|
protected $documentVersion;
|
2014-07-04 17:04:28 +02:00
|
|
|
protected $signatureType;
|
2013-07-03 20:15:45 +02:00
|
|
|
protected $signerPHID;
|
2014-06-29 16:51:03 +02:00
|
|
|
protected $signerName;
|
|
|
|
protected $signerEmail;
|
2013-07-10 20:46:39 +02:00
|
|
|
protected $signatureData = array();
|
2014-01-15 02:17:18 +01:00
|
|
|
protected $verified;
|
2014-07-02 13:59:35 +02:00
|
|
|
protected $isExemption = 0;
|
|
|
|
protected $exemptionPHID;
|
2014-01-15 02:17:18 +01:00
|
|
|
protected $secretKey;
|
2013-07-10 20:46:39 +02:00
|
|
|
|
2014-06-29 01:36:15 +02:00
|
|
|
private $document = self::ATTACHABLE;
|
|
|
|
|
2013-07-10 20:46:39 +02:00
|
|
|
public function getConfiguration() {
|
|
|
|
return array(
|
|
|
|
self::CONFIG_SERIALIZATION => array(
|
|
|
|
'signatureData' => self::SERIALIZATION_JSON,
|
|
|
|
),
|
|
|
|
) + parent::getConfiguration();
|
|
|
|
}
|
|
|
|
|
2014-01-15 02:17:18 +01:00
|
|
|
public function save() {
|
|
|
|
if (!$this->getSecretKey()) {
|
|
|
|
$this->setSecretKey(Filesystem::readRandomCharacters(20));
|
|
|
|
}
|
|
|
|
return parent::save();
|
|
|
|
}
|
2013-07-10 20:46:39 +02:00
|
|
|
|
2014-01-15 02:17:18 +01:00
|
|
|
public function isVerified() {
|
2014-06-29 01:36:15 +02:00
|
|
|
return ($this->getVerified() != self::UNVERIFIED);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getDocument() {
|
|
|
|
return $this->assertAttached($this->document);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function attachDocument(LegalpadDocument $document) {
|
|
|
|
$this->document = $document;
|
|
|
|
return $this;
|
2014-01-15 02:17:18 +01:00
|
|
|
}
|
2014-06-29 01:36:15 +02:00
|
|
|
|
|
|
|
|
2014-01-17 20:40:26 +01:00
|
|
|
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
|
|
|
|
2014-06-29 01:36:15 +02:00
|
|
|
|
2014-01-17 20:40:26 +01:00
|
|
|
public function getCapabilities() {
|
|
|
|
return array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPolicy($capability) {
|
|
|
|
switch ($capability) {
|
|
|
|
case PhabricatorPolicyCapability::CAN_VIEW:
|
2014-06-29 01:36:15 +02:00
|
|
|
return $this->getDocument()->getPolicy(
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT);
|
2014-01-17 20:40:26 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
|
2014-06-29 01:36:15 +02:00
|
|
|
return ($viewer->getPHID() == $this->getSignerPHID());
|
2014-01-17 20:40:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function describeAutomaticCapability($capability) {
|
|
|
|
return null;
|
|
|
|
}
|
2013-07-03 20:15:45 +02:00
|
|
|
|
|
|
|
}
|