Changeset View
Changeset View
Standalone View
Standalone View
src/applications/legalpad/storage/LegalpadDocumentSignature.php
<?php | <?php | ||||
final class LegalpadDocumentSignature | final class LegalpadDocumentSignature | ||||
extends LegalpadDAO | extends LegalpadDAO | ||||
implements PhabricatorPolicyInterface { | implements | ||||
PhabricatorPolicyInterface, | |||||
PhabricatorConduitResultInterface { | |||||
const VERIFIED = 0; | const VERIFIED = 0; | ||||
const UNVERIFIED = 1; | const UNVERIFIED = 1; | ||||
protected $documentPHID; | protected $documentPHID; | ||||
protected $documentVersion; | protected $documentVersion; | ||||
protected $signatureType; | protected $signatureType; | ||||
protected $signerPHID; | protected $signerPHID; | ||||
protected $signerName; | protected $signerName; | ||||
protected $signerEmail; | protected $signerEmail; | ||||
protected $signatureData = array(); | protected $signatureData = array(); | ||||
protected $verified; | protected $verified; | ||||
protected $isExemption = 0; | protected $isExemption = 0; | ||||
protected $exemptionPHID; | protected $exemptionPHID; | ||||
protected $secretKey; | protected $secretKey; | ||||
private $document = self::ATTACHABLE; | private $document = self::ATTACHABLE; | ||||
protected function getConfiguration() { | protected function getConfiguration() { | ||||
return array( | return array( | ||||
self::CONFIG_AUX_PHID => true, | |||||
self::CONFIG_SERIALIZATION => array( | self::CONFIG_SERIALIZATION => array( | ||||
'signatureData' => self::SERIALIZATION_JSON, | 'signatureData' => self::SERIALIZATION_JSON, | ||||
), | ), | ||||
self::CONFIG_COLUMN_SCHEMA => array( | self::CONFIG_COLUMN_SCHEMA => array( | ||||
'documentVersion' => 'uint32', | 'documentVersion' => 'uint32', | ||||
'signatureType' => 'text4', | 'signatureType' => 'text4', | ||||
'signerPHID' => 'phid?', | 'signerPHID' => 'phid?', | ||||
'signerName' => 'text255', | 'signerName' => 'text255', | ||||
Show All 12 Lines | return array( | ||||
), | ), | ||||
'key_document' => array( | 'key_document' => array( | ||||
'columns' => array('documentPHID', 'signerPHID', 'documentVersion'), | 'columns' => array('documentPHID', 'signerPHID', 'documentVersion'), | ||||
), | ), | ||||
), | ), | ||||
) + parent::getConfiguration(); | ) + parent::getConfiguration(); | ||||
} | } | ||||
public function getPHIDType() { | |||||
return PhabricatorLegalpadDocumentSignaturePHIDType::TYPECONST; | |||||
} | |||||
public function generatePHID() { | |||||
return PhabricatorPHID::generateNewPHID($this->getPHIDType()); | |||||
} | |||||
speck: Maybe use `$this->getPHIDType()` | |||||
Done Inline Actionswill do! roguelazer: will do! | |||||
public function save() { | public function save() { | ||||
if (!$this->getSecretKey()) { | if (!$this->getSecretKey()) { | ||||
$this->setSecretKey(Filesystem::readRandomCharacters(20)); | $this->setSecretKey(Filesystem::readRandomCharacters(20)); | ||||
} | } | ||||
return parent::save(); | return parent::save(); | ||||
} | } | ||||
public function isVerified() { | public function isVerified() { | ||||
return ($this->getVerified() != self::UNVERIFIED); | return ($this->getVerified() != self::UNVERIFIED); | ||||
} | } | ||||
public function getDocument() { | public function getDocument() { | ||||
return $this->assertAttached($this->document); | return $this->assertAttached($this->document); | ||||
} | } | ||||
public function attachDocument(LegalpadDocument $document) { | public function attachDocument(LegalpadDocument $document) { | ||||
$this->document = $document; | $this->document = $document; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getSignerPHID() { | |||||
return $this->signerPHID; | |||||
} | |||||
public function getIsExemption() { | |||||
return (bool)$this->isExemption; | |||||
} | |||||
public function getExemptionPHID() { | |||||
return $this->exemptionPHID; | |||||
} | |||||
public function getSignerName() { | |||||
return $this->signerName; | |||||
} | |||||
public function getSignerEmail() { | |||||
return $this->signerEmail; | |||||
} | |||||
public function getDocumentVersion() { | |||||
return (int)$this->documentVersion; | |||||
} | |||||
/* -( PhabricatorConduitResultInterface )---------------------------------- */ | |||||
public function getFieldSpecificationsForConduit() { | |||||
return array( | |||||
id(new PhabricatorConduitSearchFieldSpecification()) | |||||
->setKey('documentPHID') | |||||
->setType('phid') | |||||
->setDescription(pht('The PHID of the document')), | |||||
id(new PhabricatorConduitSearchFieldSpecification()) | |||||
->setKey('signerPHID') | |||||
->setType('phid?') | |||||
->setDescription(pht('The PHID of the signer')), | |||||
id(new PhabricatorConduitSearchFieldSpecification()) | |||||
->setKey('exemptionPHID') | |||||
->setType('phid?') | |||||
->setDescription(pht('The PHID of the user who granted the exemption')), | |||||
id(new PhabricatorConduitSearchFieldSpecification()) | |||||
->setKey('signerName') | |||||
->setType('string') | |||||
->setDescription(pht('The name used by the signer.')), | |||||
id(new PhabricatorConduitSearchFieldSpecification()) | |||||
->setKey('signerEmail') | |||||
->setType('string') | |||||
->setDescription(pht('The email used by the signer.')), | |||||
id(new PhabricatorConduitSearchFieldSpecification()) | |||||
->setKey('isExemption') | |||||
->setType('bool') | |||||
->setDescription(pht('Whether or not this signature is an exemption')), | |||||
); | |||||
} | |||||
public function getFieldValuesForConduit() { | |||||
return array( | |||||
'documentPHID' => $this->getDocumentPHID(), | |||||
'signerPHID' => $this->getSignerPHID(), | |||||
'exemptionPHID' => $this->getExemptionPHID(), | |||||
'signerName' => $this->getSignerName(), | |||||
'signerEmail' => $this->getSignerEmail(), | |||||
'isExemption' => $this->getIsExemption(), | |||||
); | |||||
} | |||||
public function getConduitSearchAttachments() { | |||||
return array(); | |||||
} | |||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */ | /* -( PhabricatorPolicyInterface )----------------------------------------- */ | ||||
public function getCapabilities() { | public function getCapabilities() { | ||||
return array( | return array( | ||||
PhabricatorPolicyCapability::CAN_VIEW, | PhabricatorPolicyCapability::CAN_VIEW, | ||||
); | ); | ||||
Show All 15 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0
Maybe use $this->getPHIDType()