-
-
Notifications
You must be signed in to change notification settings - Fork 111
Expand file tree
/
Copy pathUserElement.php
More file actions
67 lines (60 loc) · 1.83 KB
/
UserElement.php
File metadata and controls
67 lines (60 loc) · 1.83 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
<?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 OCP\AppFramework\Db\Entity;
use OCP\DB\Types;
/**
* @method void setId(int $id)
* @method int getId()
* @method void setType(string $type)
* @method string getType()
* @method void setNodeId(int $nodeId)
* @method int getNodeId()
* @method void setUserId(string $userId)
* @method void setStarred(int $starred)
* @method int getStarred()
* @method ?\DateTime getCreatedAt()
* @method void setMetadata(array $metadata)
* @method ?array getMetadata()
*/
class UserElement extends Entity {
public string $type = '';
protected int $nodeId = 0;
protected string $userId = '';
public bool $starred = false;
public ?\DateTime $createdAt = null;
protected ?array $metadata = null;
/** @var ?array{url: string, nodeId: non-negative-int} */
public ?array $file = null;
public function __construct() {
$this->addType('id', Types::INTEGER);
$this->addType('type', Types::STRING);
$this->addType('nodeId', Types::INTEGER);
$this->addType('userId', Types::STRING);
$this->addType('starred', Types::INTEGER);
$this->addType('createdAt', Types::DATETIME);
$this->addType('metadata', Types::JSON);
}
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;
}
/**
* @param \DateTime|string $createdAt
*/
public function setCreatedAt($createdAt): void {
if (!$createdAt instanceof \DateTime) {
$createdAt = new \DateTime($createdAt, new \DateTimeZone('UTC'));
}
$this->createdAt = $createdAt;
$this->markFieldUpdated('createdAt');
}
}