Path: blob/master/src/applications/legalpad/storage/LegalpadDocumentSignature.php
13459 views
<?php12final class LegalpadDocumentSignature3extends LegalpadDAO4implements PhabricatorPolicyInterface {56const VERIFIED = 0;7const UNVERIFIED = 1;89protected $documentPHID;10protected $documentVersion;11protected $signatureType;12protected $signerPHID;13protected $signerName;14protected $signerEmail;15protected $signatureData = array();16protected $verified;17protected $isExemption = 0;18protected $exemptionPHID;19protected $secretKey;2021private $document = self::ATTACHABLE;2223protected function getConfiguration() {24return array(25self::CONFIG_SERIALIZATION => array(26'signatureData' => self::SERIALIZATION_JSON,27),28self::CONFIG_COLUMN_SCHEMA => array(29'documentVersion' => 'uint32',30'signatureType' => 'text4',31'signerPHID' => 'phid?',32'signerName' => 'text255',33'signerEmail' => 'text255',34'secretKey' => 'bytes20',35'verified' => 'bool?',36'isExemption' => 'bool',37'exemptionPHID' => 'phid?',38),39self::CONFIG_KEY_SCHEMA => array(40'key_signer' => array(41'columns' => array('signerPHID', 'dateModified'),42),43'secretKey' => array(44'columns' => array('secretKey'),45),46'key_document' => array(47'columns' => array('documentPHID', 'signerPHID', 'documentVersion'),48),49),50) + parent::getConfiguration();51}5253public function save() {54if (!$this->getSecretKey()) {55$this->setSecretKey(Filesystem::readRandomCharacters(20));56}57return parent::save();58}5960public function isVerified() {61return ($this->getVerified() != self::UNVERIFIED);62}6364public function getDocument() {65return $this->assertAttached($this->document);66}6768public function attachDocument(LegalpadDocument $document) {69$this->document = $document;70return $this;71}727374/* -( PhabricatorPolicyInterface )----------------------------------------- */757677public function getCapabilities() {78return array(79PhabricatorPolicyCapability::CAN_VIEW,80);81}8283public function getPolicy($capability) {84switch ($capability) {85case PhabricatorPolicyCapability::CAN_VIEW:86return $this->getDocument()->getPolicy(87PhabricatorPolicyCapability::CAN_EDIT);88}89}9091public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {92return ($viewer->getPHID() == $this->getSignerPHID());93}9495}969798