|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* For licensing terms, see /license.txt */ |
|
4
|
|
|
|
|
5
|
|
|
declare(strict_types=1); |
|
6
|
|
|
|
|
7
|
|
|
namespace Chamilo\CourseBundle\Entity; |
|
8
|
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Entity\AbstractResource; |
|
10
|
|
|
use Chamilo\CoreBundle\Entity\ResourceInterface; |
|
11
|
|
|
use Chamilo\CourseBundle\Repository\CForumRepository; |
|
12
|
|
|
use DateTime; |
|
13
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
14
|
|
|
use Doctrine\Common\Collections\Collection; |
|
15
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
16
|
|
|
use Stringable; |
|
17
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Course forums. |
|
21
|
|
|
*/ |
|
22
|
|
|
#[ORM\Table(name: 'c_forum_forum')] |
|
23
|
|
|
#[ORM\Entity(repositoryClass: CForumRepository::class)] |
|
24
|
|
|
class CForum extends AbstractResource implements ResourceInterface, Stringable |
|
25
|
|
|
{ |
|
26
|
|
|
#[ORM\Column(name: 'iid', type: 'integer')] |
|
27
|
|
|
#[ORM\Id] |
|
28
|
|
|
#[ORM\GeneratedValue] |
|
29
|
|
|
protected ?int $iid = null; |
|
30
|
|
|
|
|
31
|
|
|
#[Assert\NotBlank] |
|
32
|
|
|
#[ORM\Column(name: 'title', type: 'string', length: 255, nullable: false)] |
|
33
|
|
|
protected string $title; |
|
34
|
|
|
|
|
35
|
|
|
#[ORM\Column(name: 'forum_comment', type: 'text', nullable: true)] |
|
36
|
|
|
protected ?string $forumComment; |
|
37
|
|
|
|
|
38
|
|
|
#[ORM\Column(name: 'forum_threads', type: 'integer', nullable: true)] |
|
39
|
|
|
protected ?int $forumThreads = null; |
|
40
|
|
|
|
|
41
|
|
|
#[ORM\Column(name: 'forum_posts', type: 'integer', nullable: true)] |
|
42
|
|
|
protected ?int $forumPosts; |
|
43
|
|
|
|
|
44
|
|
|
#[ORM\ManyToOne(targetEntity: CForumPost::class)] |
|
45
|
|
|
#[ORM\JoinColumn(name: 'forum_last_post', referencedColumnName: 'iid')] |
|
46
|
|
|
protected ?CForumPost $forumLastPost = null; |
|
47
|
|
|
|
|
48
|
|
|
#[ORM\ManyToOne(targetEntity: CForumCategory::class, inversedBy: 'forums')] |
|
49
|
|
|
#[ORM\JoinColumn(name: 'forum_category', referencedColumnName: 'iid', nullable: true, onDelete: 'SET NULL')] |
|
50
|
|
|
protected ?CForumCategory $forumCategory = null; |
|
51
|
|
|
|
|
52
|
|
|
#[ORM\Column(name: 'allow_anonymous', type: 'integer', nullable: true)] |
|
53
|
|
|
protected ?int $allowAnonymous = null; |
|
54
|
|
|
|
|
55
|
|
|
#[ORM\Column(name: 'allow_edit', type: 'integer', nullable: true)] |
|
56
|
|
|
protected ?int $allowEdit = null; |
|
57
|
|
|
|
|
58
|
|
|
#[ORM\Column(name: 'approval_direct_post', type: 'string', length: 20, nullable: true)] |
|
59
|
|
|
protected ?string $approvalDirectPost = null; |
|
60
|
|
|
|
|
61
|
|
|
#[ORM\Column(name: 'allow_attachments', type: 'integer', nullable: true)] |
|
62
|
|
|
protected ?int $allowAttachments = null; |
|
63
|
|
|
|
|
64
|
|
|
#[ORM\Column(name: 'allow_new_threads', type: 'integer', nullable: true)] |
|
65
|
|
|
protected ?int $allowNewThreads = null; |
|
66
|
|
|
|
|
67
|
|
|
#[ORM\Column(name: 'default_view', type: 'string', length: 20, nullable: true)] |
|
68
|
|
|
protected ?string $defaultView = null; |
|
69
|
|
|
|
|
70
|
|
|
#[ORM\Column(name: 'forum_of_group', type: 'string', length: 20, nullable: true)] |
|
71
|
|
|
protected ?string $forumOfGroup; |
|
72
|
|
|
|
|
73
|
|
|
#[ORM\Column(name: 'forum_group_public_private', type: 'string', length: 20, nullable: true)] |
|
74
|
|
|
protected ?string $forumGroupPublicPrivate; |
|
75
|
|
|
|
|
76
|
|
|
#[ORM\Column(name: 'locked', type: 'integer', nullable: false)] |
|
77
|
|
|
protected int $locked; |
|
78
|
|
|
|
|
79
|
|
|
#[ORM\Column(name: 'forum_image', type: 'string', length: 255, nullable: false)] |
|
80
|
|
|
protected string $forumImage; |
|
81
|
|
|
|
|
82
|
|
|
#[ORM\Column(name: 'start_time', type: 'datetime', nullable: true)] |
|
83
|
|
|
protected ?DateTime $startTime = null; |
|
84
|
|
|
|
|
85
|
|
|
#[ORM\Column(name: 'end_time', type: 'datetime', nullable: true)] |
|
86
|
|
|
protected ?DateTime $endTime = null; |
|
87
|
|
|
|
|
88
|
|
|
#[ORM\ManyToOne(targetEntity: CLp::class, cascade: ['remove'], inversedBy: 'forums')] |
|
89
|
|
|
#[ORM\JoinColumn(name: 'lp_id', referencedColumnName: 'iid', nullable: true, onDelete: 'SET NULL')] |
|
90
|
|
|
protected ?CLp $lp = null; |
|
91
|
|
|
|
|
92
|
|
|
#[ORM\Column(name: 'moderated', type: 'boolean', nullable: true)] |
|
93
|
|
|
protected ?bool $moderated = null; |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @var Collection<int, CForumThread> |
|
97
|
|
|
*/ |
|
98
|
|
|
#[ORM\OneToMany(mappedBy: 'forum', targetEntity: CForumThread::class, cascade: ['persist'], orphanRemoval: true)] |
|
99
|
|
|
protected Collection $threads; |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @var Collection<int, CForumPost> |
|
103
|
|
|
*/ |
|
104
|
|
|
#[ORM\OneToMany(mappedBy: 'forum', targetEntity: CForumPost::class, cascade: ['persist'], orphanRemoval: true)] |
|
105
|
|
|
protected Collection $posts; |
|
106
|
|
|
|
|
107
|
|
|
public function __construct() |
|
108
|
|
|
{ |
|
109
|
|
|
$this->threads = new ArrayCollection(); |
|
110
|
|
|
$this->posts = new ArrayCollection(); |
|
111
|
|
|
$this->locked = 0; |
|
112
|
|
|
$this->forumComment = ''; |
|
113
|
|
|
$this->forumImage = ''; |
|
114
|
|
|
$this->forumOfGroup = ''; |
|
115
|
|
|
$this->forumPosts = 0; |
|
116
|
|
|
$this->forumGroupPublicPrivate = ''; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
public function __toString(): string |
|
120
|
|
|
{ |
|
121
|
|
|
return $this->getTitle(); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
public function setTitle(string $title): self |
|
125
|
|
|
{ |
|
126
|
|
|
$this->title = $title; |
|
127
|
|
|
|
|
128
|
|
|
return $this; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
public function getTitle(): string |
|
132
|
|
|
{ |
|
133
|
|
|
return $this->title; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
public function setForumComment(string $forumComment): self |
|
137
|
|
|
{ |
|
138
|
|
|
$this->forumComment = $forumComment; |
|
139
|
|
|
|
|
140
|
|
|
return $this; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
public function getForumComment(): string |
|
144
|
|
|
{ |
|
145
|
|
|
return $this->forumComment; |
|
|
|
|
|
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
|
|
public function setForumThreads(int $forumThreads): self |
|
149
|
|
|
{ |
|
150
|
|
|
$this->forumThreads = $forumThreads; |
|
151
|
|
|
|
|
152
|
|
|
return $this; |
|
153
|
|
|
} |
|
154
|
|
|
|
|
155
|
|
|
public function getForumThreads(): ?int |
|
156
|
|
|
{ |
|
157
|
|
|
return $this->forumThreads; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
public function hasThread(CForumThread $thread): bool |
|
161
|
|
|
{ |
|
162
|
|
|
return $this->threads->contains($thread); |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
public function setForumPosts(int $forumPosts): self |
|
166
|
|
|
{ |
|
167
|
|
|
$this->forumPosts = $forumPosts; |
|
168
|
|
|
|
|
169
|
|
|
return $this; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
public function getForumPosts(): ?int |
|
173
|
|
|
{ |
|
174
|
|
|
return $this->forumPosts; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
public function setForumCategory(?CForumCategory $forumCategory = null): self |
|
178
|
|
|
{ |
|
179
|
|
|
$forumCategory?->getForums()->add($this); |
|
180
|
|
|
$this->forumCategory = $forumCategory; |
|
181
|
|
|
|
|
182
|
|
|
return $this; |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
public function getForumCategory(): ?CForumCategory |
|
186
|
|
|
{ |
|
187
|
|
|
return $this->forumCategory; |
|
188
|
|
|
} |
|
189
|
|
|
|
|
190
|
|
|
public function setAllowAnonymous(int $allowAnonymous): self |
|
191
|
|
|
{ |
|
192
|
|
|
$this->allowAnonymous = $allowAnonymous; |
|
193
|
|
|
|
|
194
|
|
|
return $this; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
public function getAllowAnonymous(): ?int |
|
198
|
|
|
{ |
|
199
|
|
|
return $this->allowAnonymous; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
public function setAllowEdit(int $allowEdit): self |
|
203
|
|
|
{ |
|
204
|
|
|
$this->allowEdit = $allowEdit; |
|
205
|
|
|
|
|
206
|
|
|
return $this; |
|
207
|
|
|
} |
|
208
|
|
|
|
|
209
|
|
|
public function getAllowEdit(): ?int |
|
210
|
|
|
{ |
|
211
|
|
|
return $this->allowEdit; |
|
212
|
|
|
} |
|
213
|
|
|
|
|
214
|
|
|
public function setApprovalDirectPost(string $approvalDirectPost): self |
|
215
|
|
|
{ |
|
216
|
|
|
$this->approvalDirectPost = $approvalDirectPost; |
|
217
|
|
|
|
|
218
|
|
|
return $this; |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
public function getApprovalDirectPost(): ?string |
|
222
|
|
|
{ |
|
223
|
|
|
return $this->approvalDirectPost; |
|
224
|
|
|
} |
|
225
|
|
|
|
|
226
|
|
|
public function setAllowAttachments(int $allowAttachments): self |
|
227
|
|
|
{ |
|
228
|
|
|
$this->allowAttachments = $allowAttachments; |
|
229
|
|
|
|
|
230
|
|
|
return $this; |
|
231
|
|
|
} |
|
232
|
|
|
|
|
233
|
|
|
public function getAllowAttachments(): ?int |
|
234
|
|
|
{ |
|
235
|
|
|
return $this->allowAttachments; |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
public function setAllowNewThreads(int $allowNewThreads): self |
|
239
|
|
|
{ |
|
240
|
|
|
$this->allowNewThreads = $allowNewThreads; |
|
241
|
|
|
|
|
242
|
|
|
return $this; |
|
243
|
|
|
} |
|
244
|
|
|
|
|
245
|
|
|
public function getAllowNewThreads(): ?int |
|
246
|
|
|
{ |
|
247
|
|
|
return $this->allowNewThreads; |
|
248
|
|
|
} |
|
249
|
|
|
|
|
250
|
|
|
public function setDefaultView(string $defaultView): self |
|
251
|
|
|
{ |
|
252
|
|
|
$this->defaultView = $defaultView; |
|
253
|
|
|
|
|
254
|
|
|
return $this; |
|
255
|
|
|
} |
|
256
|
|
|
|
|
257
|
|
|
public function getDefaultView(): ?string |
|
258
|
|
|
{ |
|
259
|
|
|
return $this->defaultView; |
|
260
|
|
|
} |
|
261
|
|
|
|
|
262
|
|
|
public function setForumOfGroup(string $forumOfGroup): self |
|
263
|
|
|
{ |
|
264
|
|
|
$this->forumOfGroup = $forumOfGroup; |
|
265
|
|
|
|
|
266
|
|
|
return $this; |
|
267
|
|
|
} |
|
268
|
|
|
|
|
269
|
|
|
public function getForumOfGroup(): ?string |
|
270
|
|
|
{ |
|
271
|
|
|
return $this->forumOfGroup; |
|
272
|
|
|
} |
|
273
|
|
|
|
|
274
|
|
|
public function getForumGroupPublicPrivate(): string |
|
275
|
|
|
{ |
|
276
|
|
|
return $this->forumGroupPublicPrivate; |
|
|
|
|
|
|
277
|
|
|
} |
|
278
|
|
|
|
|
279
|
|
|
public function setForumGroupPublicPrivate(string $forumGroupPublicPrivate): static |
|
280
|
|
|
{ |
|
281
|
|
|
$this->forumGroupPublicPrivate = $forumGroupPublicPrivate; |
|
282
|
|
|
|
|
283
|
|
|
return $this; |
|
284
|
|
|
} |
|
285
|
|
|
|
|
286
|
|
|
public function setLocked(int $locked): self |
|
287
|
|
|
{ |
|
288
|
|
|
$this->locked = $locked; |
|
289
|
|
|
|
|
290
|
|
|
return $this; |
|
291
|
|
|
} |
|
292
|
|
|
|
|
293
|
|
|
public function getLocked(): int |
|
294
|
|
|
{ |
|
295
|
|
|
return $this->locked; |
|
296
|
|
|
} |
|
297
|
|
|
|
|
298
|
|
|
public function setForumImage(string $forumImage): self |
|
299
|
|
|
{ |
|
300
|
|
|
$this->forumImage = $forumImage; |
|
301
|
|
|
|
|
302
|
|
|
return $this; |
|
303
|
|
|
} |
|
304
|
|
|
|
|
305
|
|
|
public function getForumImage(): string |
|
306
|
|
|
{ |
|
307
|
|
|
return $this->forumImage; |
|
308
|
|
|
} |
|
309
|
|
|
|
|
310
|
|
|
public function setStartTime(?DateTime $startTime): self |
|
311
|
|
|
{ |
|
312
|
|
|
$this->startTime = $startTime; |
|
313
|
|
|
|
|
314
|
|
|
return $this; |
|
315
|
|
|
} |
|
316
|
|
|
|
|
317
|
|
|
public function getStartTime(): ?DateTime |
|
318
|
|
|
{ |
|
319
|
|
|
return $this->startTime; |
|
320
|
|
|
} |
|
321
|
|
|
|
|
322
|
|
|
public function setEndTime(?DateTime $endTime): self |
|
323
|
|
|
{ |
|
324
|
|
|
$this->endTime = $endTime; |
|
325
|
|
|
|
|
326
|
|
|
return $this; |
|
327
|
|
|
} |
|
328
|
|
|
|
|
329
|
|
|
public function getEndTime(): ?DateTime |
|
330
|
|
|
{ |
|
331
|
|
|
return $this->endTime; |
|
332
|
|
|
} |
|
333
|
|
|
|
|
334
|
|
|
public function isModerated(): bool |
|
335
|
|
|
{ |
|
336
|
|
|
return $this->moderated; |
|
|
|
|
|
|
337
|
|
|
} |
|
338
|
|
|
|
|
339
|
|
|
public function setModerated(bool $moderated): self |
|
340
|
|
|
{ |
|
341
|
|
|
$this->moderated = $moderated; |
|
342
|
|
|
|
|
343
|
|
|
return $this; |
|
344
|
|
|
} |
|
345
|
|
|
|
|
346
|
|
|
public function getIid(): ?int |
|
347
|
|
|
{ |
|
348
|
|
|
return $this->iid; |
|
349
|
|
|
} |
|
350
|
|
|
|
|
351
|
|
|
public function getThreads(): Collection |
|
352
|
|
|
{ |
|
353
|
|
|
return $this->threads; |
|
354
|
|
|
} |
|
355
|
|
|
|
|
356
|
|
|
public function getForumLastPost(): ?CForumPost |
|
357
|
|
|
{ |
|
358
|
|
|
return $this->forumLastPost; |
|
359
|
|
|
} |
|
360
|
|
|
|
|
361
|
|
|
public function setForumLastPost(CForumPost $forumLastPost): self |
|
362
|
|
|
{ |
|
363
|
|
|
$this->forumLastPost = $forumLastPost; |
|
364
|
|
|
|
|
365
|
|
|
return $this; |
|
366
|
|
|
} |
|
367
|
|
|
|
|
368
|
|
|
public function getLp(): ?CLp |
|
369
|
|
|
{ |
|
370
|
|
|
return $this->lp; |
|
371
|
|
|
} |
|
372
|
|
|
|
|
373
|
|
|
public function setLp(?CLp $lp): self |
|
374
|
|
|
{ |
|
375
|
|
|
$this->lp = $lp; |
|
376
|
|
|
|
|
377
|
|
|
return $this; |
|
378
|
|
|
} |
|
379
|
|
|
|
|
380
|
|
|
/** |
|
381
|
|
|
* @return Collection<int, CForumPost> |
|
382
|
|
|
*/ |
|
383
|
|
|
public function getPosts(): Collection |
|
384
|
|
|
{ |
|
385
|
|
|
return $this->posts; |
|
386
|
|
|
} |
|
387
|
|
|
|
|
388
|
|
|
public function getResourceIdentifier(): int |
|
389
|
|
|
{ |
|
390
|
|
|
return $this->getIid(); |
|
|
|
|
|
|
391
|
|
|
} |
|
392
|
|
|
|
|
393
|
|
|
public function getResourceName(): string |
|
394
|
|
|
{ |
|
395
|
|
|
return $this->getTitle(); |
|
396
|
|
|
} |
|
397
|
|
|
|
|
398
|
|
|
public function setResourceName(string $name): self |
|
399
|
|
|
{ |
|
400
|
|
|
return $this->setTitle($name); |
|
401
|
|
|
} |
|
402
|
|
|
} |
|
403
|
|
|
|