|
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
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* @Entity(repositoryClass="Stu\Orm\Repository\PrivateMessageRepository") |
|
18
|
|
|
* @Table( |
|
19
|
|
|
* name="stu_pms", |
|
20
|
|
|
* indexes={ |
|
21
|
|
|
* @Index(name="recipient_folder_idx", columns={"recip_user", "cat_id"}), |
|
22
|
|
|
* @Index(name="correspondence", columns={"recip_user", "send_user"}) |
|
23
|
|
|
* } |
|
24
|
|
|
* ) |
|
25
|
|
|
**/ |
|
26
|
|
|
class PrivateMessage implements PrivateMessageInterface |
|
27
|
|
|
{ |
|
28
|
|
|
/** |
|
29
|
|
|
* @Id |
|
30
|
|
|
* @Column(type="integer") |
|
31
|
|
|
* @GeneratedValue(strategy="IDENTITY") |
|
32
|
|
|
* |
|
33
|
|
|
*/ |
|
34
|
|
|
private int $id; |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @Column(type="integer") |
|
38
|
|
|
* |
|
39
|
|
|
*/ |
|
40
|
|
|
private int $send_user = 0; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @Column(type="integer") |
|
44
|
|
|
* |
|
45
|
|
|
*/ |
|
46
|
|
|
private int $recip_user = 0; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* @Column(type="text") |
|
50
|
|
|
* |
|
51
|
|
|
*/ |
|
52
|
|
|
private string $text = ''; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @Column(type="integer") |
|
56
|
|
|
* |
|
57
|
|
|
*/ |
|
58
|
|
|
private int $date = 0; |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* @Column(type="boolean") |
|
62
|
|
|
* |
|
63
|
|
|
*/ |
|
64
|
|
|
private bool $new = false; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @Column(type="boolean") |
|
68
|
|
|
* |
|
69
|
|
|
*/ |
|
70
|
|
|
private bool $replied = false; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* @Column(type="integer") |
|
74
|
|
|
* |
|
75
|
|
|
*/ |
|
76
|
|
|
private int $cat_id = 0; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* @Column(type="integer", nullable=true) |
|
80
|
|
|
* |
|
81
|
|
|
*/ |
|
82
|
|
|
private ?int $inbox_pm_id = null; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @Column(type="string", nullable=true) |
|
86
|
|
|
* |
|
87
|
|
|
*/ |
|
88
|
|
|
private ?string $href = null; |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @Column(type="integer", nullable=true) |
|
92
|
|
|
* |
|
93
|
|
|
*/ |
|
94
|
|
|
private ?int $deleted = null; |
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* |
|
98
|
|
|
* @ManyToOne(targetEntity="PrivateMessageFolder") |
|
99
|
|
|
* @JoinColumn(name="cat_id", referencedColumnName="id", onDelete="CASCADE") |
|
100
|
|
|
*/ |
|
101
|
|
|
private PrivateMessageFolderInterface $category; |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* |
|
105
|
|
|
* @ManyToOne(targetEntity="User") |
|
106
|
|
|
* @JoinColumn(name="send_user", referencedColumnName="id", onDelete="CASCADE") |
|
107
|
|
|
*/ |
|
108
|
|
|
private UserInterface $sendingUser; |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* |
|
112
|
|
|
* @ManyToOne(targetEntity="User") |
|
113
|
|
|
* @JoinColumn(name="recip_user", referencedColumnName="id", onDelete="CASCADE") |
|
114
|
|
|
*/ |
|
115
|
|
|
private UserInterface $receivingUser; |
|
116
|
|
|
|
|
117
|
|
|
public function getId(): int |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->id; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
public function getSenderId(): int |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->send_user; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function getRecipientId(): int |
|
128
|
|
|
{ |
|
129
|
|
|
return $this->recip_user; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function getText(): string |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->text; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function setText(string $text): PrivateMessageInterface |
|
138
|
|
|
{ |
|
139
|
|
|
$this->text = $text; |
|
140
|
|
|
return $this; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function getDate(): int |
|
144
|
|
|
{ |
|
145
|
|
|
return $this->date; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
public function setDate(int $date): PrivateMessageInterface |
|
149
|
|
|
{ |
|
150
|
|
|
$this->date = $date; |
|
151
|
|
|
return $this; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
public function getNew(): bool |
|
155
|
|
|
{ |
|
156
|
|
|
return $this->new; |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
public function setNew(bool $new): PrivateMessageInterface |
|
160
|
|
|
{ |
|
161
|
|
|
$this->new = $new; |
|
162
|
|
|
return $this; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
public function getReplied(): bool |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->replied; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
public function setReplied(bool $replied): PrivateMessageInterface |
|
171
|
|
|
{ |
|
172
|
|
|
$this->replied = $replied; |
|
173
|
|
|
return $this; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
public function getCategoryId(): int |
|
177
|
|
|
{ |
|
178
|
|
|
return $this->cat_id; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
public function setCategoryId(int $categoryId): PrivateMessageInterface |
|
182
|
|
|
{ |
|
183
|
|
|
$this->cat_id = $categoryId; |
|
184
|
|
|
return $this; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
public function getInboxPmId(): ?int |
|
188
|
|
|
{ |
|
189
|
|
|
return $this->inbox_pm_id; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
public function setInboxPmId(?int $pmId): PrivateMessageInterface |
|
193
|
|
|
{ |
|
194
|
|
|
$this->inbox_pm_id = $pmId; |
|
195
|
|
|
return $this; |
|
196
|
|
|
} |
|
197
|
|
|
|
|
198
|
|
|
public function getHref(): ?string |
|
199
|
|
|
{ |
|
200
|
|
|
return $this->href; |
|
201
|
|
|
} |
|
202
|
|
|
|
|
203
|
|
|
public function setHref(?string $href): PrivateMessageInterface |
|
204
|
|
|
{ |
|
205
|
|
|
$this->href = $href; |
|
206
|
|
|
return $this; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
public function getCategory(): PrivateMessageFolderInterface |
|
210
|
|
|
{ |
|
211
|
|
|
return $this->category; |
|
212
|
|
|
} |
|
213
|
|
|
|
|
214
|
|
|
public function setCategory(PrivateMessageFolderInterface $folder): PrivateMessageInterface |
|
215
|
|
|
{ |
|
216
|
|
|
$this->category = $folder; |
|
217
|
|
|
return $this; |
|
218
|
|
|
} |
|
219
|
|
|
|
|
220
|
|
|
public function getSender(): UserInterface |
|
221
|
|
|
{ |
|
222
|
|
|
return $this->sendingUser; |
|
223
|
|
|
} |
|
224
|
|
|
|
|
225
|
|
|
public function setSender(UserInterface $user): PrivateMessageInterface |
|
226
|
|
|
{ |
|
227
|
|
|
$this->sendingUser = $user; |
|
228
|
|
|
return $this; |
|
229
|
|
|
} |
|
230
|
|
|
|
|
231
|
|
|
public function getRecipient(): UserInterface |
|
232
|
|
|
{ |
|
233
|
|
|
return $this->receivingUser; |
|
234
|
|
|
} |
|
235
|
|
|
|
|
236
|
|
|
public function setRecipient(UserInterface $recipient): PrivateMessageInterface |
|
237
|
|
|
{ |
|
238
|
|
|
$this->receivingUser = $recipient; |
|
239
|
|
|
return $this; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
public function setDeleted(int $timestamp): PrivateMessageInterface |
|
243
|
|
|
{ |
|
244
|
|
|
$this->deleted = $timestamp; |
|
245
|
|
|
|
|
246
|
|
|
return $this; |
|
247
|
|
|
} |
|
248
|
|
|
|
|
249
|
|
|
public function hasTranslation(): bool |
|
250
|
|
|
{ |
|
251
|
|
|
$text = $this->getText(); |
|
252
|
|
|
return strpos($text, '[translate]') !== false && strpos($text, '[/translate]') !== false; |
|
253
|
|
|
} |
|
254
|
|
|
} |
|
255
|
|
|
|