-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathFile.php
More file actions
105 lines (95 loc) · 3.45 KB
/
File.php
File metadata and controls
105 lines (95 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Libresign\Db;
use OCA\Libresign\Enum\SignatureFlow;
use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;
/**
* @method void setId(int $id)
* @method int getId()
* @method void setNodeId(?int $nodeId)
* @method int getNodeId()
* @method void setSignedNodeId(int $nodeId)
* @method ?int getSignedNodeId()
* @method void setSignedHash(string $hash)
* @method ?string getSignedHash()
* @method void setUserId(string $userId)
* @method ?string getUserId()
* @method void setSignRequestId(int $signRequestId)
* @method ?int getSignRequestId()
* @method void setUuid(string $uuid)
* @method string getUuid()
* @method void setCreatedAt(\DateTime $createdAt)
* @method \DateTime getCreatedAt()
* @method void setName(string $name)
* @method string getName()
* @method void setCallback(string $callback)
* @method ?string getCallback()
* @method void setStatus(int $status)
* @method int getStatus()
* @method void setMetadata(array $metadata)
* @method ?array getMetadata()
* @method void setModificationStatus(int $modificationStatus)
* @method int getModificationStatus()
* @method void setSignatureFlow(int $signatureFlow)
* @method int getSignatureFlow()
*/
class File extends Entity {
protected int $nodeId = 0;
protected string $uuid = '';
protected ?\DateTime $createdAt = null;
protected string $name = '';
protected ?int $status = null;
protected ?string $userId = null;
protected ?int $signRequestId = null;
protected ?int $signedNodeId = null;
protected ?string $signedHash = null;
protected ?string $callback = null;
protected ?array $metadata = null;
protected int $modificationStatus = 0;
protected int $signatureFlow = SignatureFlow::NUMERIC_PARALLEL;
public const STATUS_NOT_LIBRESIGN_FILE = -1;
public const STATUS_DRAFT = 0;
public const STATUS_ABLE_TO_SIGN = 1;
public const STATUS_PARTIAL_SIGNED = 2;
public const STATUS_SIGNED = 3;
public const STATUS_DELETED = 4;
public const MODIFICATION_UNCHECKED = 0;
public const MODIFICATION_UNMODIFIED = 1;
public const MODIFICATION_ALLOWED = 2;
public const MODIFICATION_VIOLATION = 3;
public function __construct() {
$this->addType('id', Types::INTEGER);
$this->addType('nodeId', Types::INTEGER);
$this->addType('signRequestId', Types::INTEGER);
$this->addType('signedNodeId', Types::INTEGER);
$this->addType('signedHash', Types::STRING);
$this->addType('userId', Types::STRING);
$this->addType('uuid', Types::STRING);
$this->addType('createdAt', Types::DATETIME);
$this->addType('name', Types::STRING);
$this->addType('callback', Types::STRING);
$this->addType('status', Types::INTEGER);
$this->addType('metadata', Types::JSON);
$this->addType('modificationStatus', Types::SMALLINT);
$this->addType('signatureFlow', Types::SMALLINT);
}
public function isDeletedAccount(): bool {
$metadata = $this->getMetadata();
return isset($metadata['deleted_account']);
}
public function getUserId(): string {
$metadata = $this->getMetadata();
return $metadata['deleted_account']['account'] ?? $this->userId ?? '';
}
public function getSignatureFlowEnum(): \OCA\Libresign\Enum\SignatureFlow {
return \OCA\Libresign\Enum\SignatureFlow::fromNumeric($this->signatureFlow);
}
public function setSignatureFlowEnum(\OCA\Libresign\Enum\SignatureFlow $flow): void {
$this->setSignatureFlow($flow->toNumeric());
}
}