Highway to PSR2
[openemr.git] / library / ESign / Signature.php
blob8507f30ff478e5fa5408b4014e42cc67febff6cd
1 <?php
3 namespace ESign;
5 /**
6 * Signature class
8 * Copyright (C) 2013 OEMR 501c3 www.oemr.org
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @package OpenEMR
22 * @author Ken Chapple <ken@mi-squared.com>
23 * @author Medical Information Integration, LLC
24 * @link http://www.open-emr.org
25 **/
27 require_once $GLOBALS['srcdir'].'/ESign/SignatureIF.php';
28 require_once $GLOBALS['srcdir'].'/ESign/Utils/Verification.php';
30 class Signature implements SignatureIF
32 private $id; // id of the signature
33 private $tid;
34 private $table;
35 private $isLock = null; // flag signifying whether the signable object is locked
36 private $uid; // user id of the signer
37 private $firstName; // first name of signer
38 private $lastName; // last name of signer
39 private $datetime; // date and time of the signature
40 private $hash; // hash of the thing being signed on (SignableIF)
41 private $signatureHash = null; // hash of data in this signature
42 private $amendment = null; // note about the signature, if any
44 private $_verification = null;
46 public function __construct($id, $tid, $table, $isLock, $uid, $firstName, $lastName, $datetime, $hash, $amendment = null, $signatureHash = null)
48 $this->id = $id;
49 $this->tid = $tid;
50 $this->table = $table;
51 $this->isLock = $isLock;
52 $this->uid = $uid;
53 $this->firstName = $firstName;
54 $this->lastName = $lastName;
55 $this->datetime = $datetime;
56 $this->hash = $hash;
57 $this->amendment = $amendment;
58 $this->signatureHash = $signatureHash;
60 $this->_verification = new Utils_Verification();
63 public function getClass()
65 $class = "";
66 if ($this->isLock() === true) {
67 $class .= " locked";
70 return $class;
73 public function getId()
75 return $this->id;
78 public function getUid()
80 return $this->uid;
83 public function setUid($uid)
85 $this->uid = $uid;
88 public function getFirstName()
90 return $this->firstName;
93 public function getLastName()
95 return $this->lastName;
98 public function getDatetime()
100 return $this->datetime;
103 public function isLock()
105 if ($this->isLock > 0) {
106 return true;
109 return false;
112 public function getAmendment()
114 return $this->amendment;
117 public function getData()
119 $data = array( $this->tid, $this->table, $this->uid, $this->isLock, $this->hash, $this->amendment );
120 return $data;
123 public function verify()
125 return $this->_verification->verify($this->getData(), $this->signatureHash);