|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Orm\Entity; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\ORM\Mapping\Column; |
|
8
|
|
|
use Doctrine\ORM\Mapping\Entity; |
|
9
|
|
|
use Doctrine\ORM\Mapping\GeneratedValue; |
|
10
|
|
|
use Doctrine\ORM\Mapping\Id; |
|
11
|
|
|
use Doctrine\ORM\Mapping\Index; |
|
12
|
|
|
use Doctrine\ORM\Mapping\JoinColumn; |
|
13
|
|
|
use Doctrine\ORM\Mapping\ManyToOne; |
|
14
|
|
|
use Doctrine\ORM\Mapping\Table; |
|
15
|
|
|
use Stu\Module\Message\Lib\PrivateMessageFolderTypeEnum; |
|
16
|
|
|
|
|
17
|
|
|
#[Table(name: 'stu_pm_cats')] |
|
18
|
|
|
#[Index(name: 'user_special_idx', columns: ['user_id', 'special'])] |
|
19
|
|
|
#[Entity(repositoryClass: 'Stu\Orm\Repository\PrivateMessageFolderRepository')] |
|
20
|
|
|
class PrivateMessageFolder implements PrivateMessageFolderInterface |
|
21
|
|
|
{ |
|
22
|
|
|
#[Id] |
|
23
|
|
|
#[Column(type: 'integer')] |
|
24
|
|
|
#[GeneratedValue(strategy: 'IDENTITY')] |
|
25
|
|
|
private int $id; |
|
26
|
|
|
|
|
27
|
|
|
#[Column(type: 'integer')] |
|
28
|
|
|
private int $user_id = 0; |
|
29
|
|
|
|
|
30
|
|
|
#[Column(type: 'string')] |
|
31
|
|
|
private string $description = ''; |
|
32
|
|
|
|
|
33
|
|
|
#[Column(type: 'smallint')] |
|
34
|
|
|
private int $sort = 0; |
|
35
|
|
|
|
|
36
|
|
|
#[Column(type: 'smallint', length: 1, enumType: PrivateMessageFolderTypeEnum::class)] |
|
37
|
|
|
private PrivateMessageFolderTypeEnum $special = PrivateMessageFolderTypeEnum::DEFAULT_OWN; |
|
38
|
|
|
|
|
39
|
|
|
#[Column(type: 'integer', nullable: true)] |
|
40
|
|
|
private ?int $deleted = null; |
|
41
|
|
|
|
|
42
|
|
|
#[ManyToOne(targetEntity: 'User')] |
|
43
|
|
|
#[JoinColumn(name: 'user_id', referencedColumnName: 'id', onDelete: 'CASCADE')] |
|
44
|
|
|
private UserInterface $user; |
|
45
|
|
|
|
|
46
|
|
|
public function getId(): int |
|
47
|
|
|
{ |
|
48
|
|
|
return $this->id; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function getUserId(): int |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->user_id; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
public function getUser(): UserInterface |
|
57
|
|
|
{ |
|
58
|
|
|
return $this->user; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
public function setUser(UserInterface $user): PrivateMessageFolderInterface |
|
62
|
|
|
{ |
|
63
|
|
|
$this->user = $user; |
|
64
|
|
|
return $this; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function getDescription(): string |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->description; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function setDescription(string $description): PrivateMessageFolderInterface |
|
73
|
|
|
{ |
|
74
|
|
|
$this->description = $description; |
|
75
|
|
|
return $this; |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
public function getSort(): int |
|
79
|
|
|
{ |
|
80
|
|
|
return $this->sort; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
public function setSort(int $sort): PrivateMessageFolderInterface |
|
84
|
|
|
{ |
|
85
|
|
|
$this->sort = $sort; |
|
86
|
|
|
return $this; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
public function getSpecial(): PrivateMessageFolderTypeEnum |
|
90
|
|
|
{ |
|
91
|
|
|
return $this->special; |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
public function setSpecial(PrivateMessageFolderTypeEnum $special): PrivateMessageFolderInterface |
|
95
|
|
|
{ |
|
96
|
|
|
$this->special = $special; |
|
97
|
|
|
return $this; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
public function isPMOutDir(): bool |
|
101
|
|
|
{ |
|
102
|
|
|
return $this->getSpecial() == PrivateMessageFolderTypeEnum::SPECIAL_PMOUT; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* specifies if you can move a private message to this folder |
|
107
|
|
|
*/ |
|
108
|
|
|
public function isDropable(): bool |
|
109
|
|
|
{ |
|
110
|
|
|
return $this->getSpecial()->isDropable(); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
public function isDeleteAble(): bool |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->getSpecial() === PrivateMessageFolderTypeEnum::DEFAULT_OWN; |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
public function setDeleted(int $timestamp): PrivateMessageFolderInterface |
|
119
|
|
|
{ |
|
120
|
|
|
$this->deleted = $timestamp; |
|
121
|
|
|
|
|
122
|
|
|
return $this; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
public function isDeleted(): bool |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->deleted !== null; |
|
128
|
|
|
} |
|
129
|
|
|
} |
|
130
|
|
|
|