1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* For licensing terms, see /license.txt */ |
6
|
|
|
|
7
|
|
|
namespace Chamilo\CourseBundle\Entity; |
8
|
|
|
|
9
|
|
|
use Chamilo\CoreBundle\Entity\AbstractResource; |
10
|
|
|
use Chamilo\CoreBundle\Entity\ResourceInterface; |
11
|
|
|
use DateTime; |
12
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
13
|
|
|
use Doctrine\Common\Collections\Collection; |
14
|
|
|
use Doctrine\ORM\Mapping as ORM; |
15
|
|
|
use Gedmo\Mapping\Annotation as Gedmo; |
16
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Course forums. |
20
|
|
|
* |
21
|
|
|
* @ORM\Table( |
22
|
|
|
* name="c_forum_forum", |
23
|
|
|
* indexes={ |
24
|
|
|
* } |
25
|
|
|
* ) |
26
|
|
|
* @ORM\Entity(repositoryClass="Chamilo\CourseBundle\Repository\CForumRepository") |
27
|
|
|
*/ |
28
|
|
|
class CForum extends AbstractResource implements ResourceInterface |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* @ORM\Column(name="iid", type="integer") |
32
|
|
|
* @ORM\Id |
33
|
|
|
* @ORM\GeneratedValue |
34
|
|
|
*/ |
35
|
|
|
protected int $iid; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @Assert\NotBlank |
39
|
|
|
* |
40
|
|
|
* @ORM\Column(name="forum_title", type="string", length=255, nullable=false) |
41
|
|
|
*/ |
42
|
|
|
protected string $forumTitle; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @ORM\Column(name="forum_comment", type="text", nullable=true) |
46
|
|
|
*/ |
47
|
|
|
protected ?string $forumComment; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @ORM\Column(name="forum_threads", type="integer", nullable=true) |
51
|
|
|
*/ |
52
|
|
|
protected ?int $forumThreads = null; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @ORM\Column(name="forum_posts", type="integer", nullable=true) |
56
|
|
|
*/ |
57
|
|
|
protected ?int $forumPosts; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumPost") |
61
|
|
|
* @ORM\JoinColumn(name="forum_last_post", referencedColumnName="iid") |
62
|
|
|
*/ |
63
|
|
|
protected ?CForumPost $forumLastPost = null; |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @Gedmo\SortableGroup |
67
|
|
|
* |
68
|
|
|
* @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumCategory", inversedBy="forums") |
69
|
|
|
* @ORM\JoinColumn(name="forum_category", referencedColumnName="iid", nullable=true, onDelete="SET NULL") |
70
|
|
|
*/ |
71
|
|
|
protected ?CForumCategory $forumCategory = null; |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @ORM\Column(name="allow_anonymous", type="integer", nullable=true) |
75
|
|
|
*/ |
76
|
|
|
protected ?int $allowAnonymous = null; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @ORM\Column(name="allow_edit", type="integer", nullable=true) |
80
|
|
|
*/ |
81
|
|
|
protected ?int $allowEdit = null; |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @ORM\Column(name="approval_direct_post", type="string", length=20, nullable=true) |
85
|
|
|
*/ |
86
|
|
|
protected ?string $approvalDirectPost = null; |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @ORM\Column(name="allow_attachments", type="integer", nullable=true) |
90
|
|
|
*/ |
91
|
|
|
protected ?int $allowAttachments = null; |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @ORM\Column(name="allow_new_threads", type="integer", nullable=true) |
95
|
|
|
*/ |
96
|
|
|
protected ?int $allowNewThreads = null; |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @ORM\Column(name="default_view", type="string", length=20, nullable=true) |
100
|
|
|
*/ |
101
|
|
|
protected ?string $defaultView = null; |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @ORM\Column(name="forum_of_group", type="string", length=20, nullable=true) |
105
|
|
|
*/ |
106
|
|
|
protected ?string $forumOfGroup; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @ORM\Column(name="forum_group_public_private", type="string", length=20, nullable=true) |
110
|
|
|
*/ |
111
|
|
|
protected ?string $forumGroupPublicPrivate; |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @Gedmo\SortablePosition |
115
|
|
|
* |
116
|
|
|
* @ORM\Column(name="forum_order", type="integer", nullable=true) |
117
|
|
|
*/ |
118
|
|
|
protected ?int $forumOrder = null; |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @ORM\Column(name="locked", type="integer", nullable=false) |
122
|
|
|
*/ |
123
|
|
|
protected int $locked; |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* @ORM\Column(name="forum_image", type="string", length=255, nullable=false) |
127
|
|
|
*/ |
128
|
|
|
protected string $forumImage; |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* @ORM\Column(name="start_time", type="datetime", nullable=true) |
132
|
|
|
*/ |
133
|
|
|
protected ?DateTime $startTime = null; |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @ORM\Column(name="end_time", type="datetime", nullable=true) |
137
|
|
|
*/ |
138
|
|
|
protected ?DateTime $endTime = null; |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @ORM\OneToOne(targetEntity="Chamilo\CourseBundle\Entity\CLp", inversedBy="forum") |
142
|
|
|
* @ORM\JoinColumn(name="lp_id", referencedColumnName="iid", nullable=true) |
143
|
|
|
*/ |
144
|
|
|
protected ?CLp $lp = null; |
145
|
|
|
|
146
|
|
|
/** |
147
|
|
|
* @ORM\Column(name="moderated", type="boolean", nullable=true) |
148
|
|
|
*/ |
149
|
|
|
protected ?bool $moderated = null; |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @var Collection|CForumThread[] |
153
|
|
|
* |
154
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumThread", mappedBy="forum") |
155
|
|
|
*/ |
156
|
|
|
protected Collection $threads; |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @var Collection|CForumPost[] |
160
|
|
|
* |
161
|
|
|
* @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumPost", mappedBy="forum") |
162
|
|
|
*/ |
163
|
|
|
protected Collection $posts; |
164
|
|
|
|
165
|
|
|
public function __construct() |
166
|
|
|
{ |
167
|
|
|
$this->threads = new ArrayCollection(); |
168
|
|
|
$this->posts = new ArrayCollection(); |
169
|
|
|
$this->locked = 0; |
170
|
|
|
$this->forumComment = ''; |
171
|
|
|
$this->forumImage = ''; |
172
|
|
|
$this->forumOfGroup = ''; |
173
|
|
|
$this->forumPosts = 0; |
174
|
|
|
$this->forumGroupPublicPrivate = ''; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
public function __toString(): string |
178
|
|
|
{ |
179
|
|
|
return $this->getForumTitle(); |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function setForumTitle(string $forumTitle): self |
183
|
|
|
{ |
184
|
|
|
$this->forumTitle = $forumTitle; |
185
|
|
|
|
186
|
|
|
return $this; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
|
public function getForumTitle(): string |
190
|
|
|
{ |
191
|
|
|
return $this->forumTitle; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
public function setForumComment(string $forumComment): self |
195
|
|
|
{ |
196
|
|
|
$this->forumComment = $forumComment; |
197
|
|
|
|
198
|
|
|
return $this; |
199
|
|
|
} |
200
|
|
|
|
201
|
|
|
public function getForumComment(): string |
202
|
|
|
{ |
203
|
|
|
return $this->forumComment; |
|
|
|
|
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
public function setForumThreads(int $forumThreads): self |
207
|
|
|
{ |
208
|
|
|
$this->forumThreads = $forumThreads; |
209
|
|
|
|
210
|
|
|
return $this; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Get forumThreads. |
215
|
|
|
* |
216
|
|
|
* @return int |
217
|
|
|
*/ |
218
|
|
|
public function getForumThreads() |
219
|
|
|
{ |
220
|
|
|
return $this->forumThreads; |
221
|
|
|
} |
222
|
|
|
|
223
|
|
|
public function hasThread(CForumThread $thread): bool |
224
|
|
|
{ |
225
|
|
|
return $this->threads->contains($thread); |
226
|
|
|
} |
227
|
|
|
|
228
|
|
|
public function setForumPosts(int $forumPosts): self |
229
|
|
|
{ |
230
|
|
|
$this->forumPosts = $forumPosts; |
231
|
|
|
|
232
|
|
|
return $this; |
233
|
|
|
} |
234
|
|
|
|
235
|
|
|
/** |
236
|
|
|
* Get forumPosts. |
237
|
|
|
* |
238
|
|
|
* @return int |
239
|
|
|
*/ |
240
|
|
|
public function getForumPosts() |
241
|
|
|
{ |
242
|
|
|
return $this->forumPosts; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
public function setForumCategory(CForumCategory $forumCategory = null): self |
246
|
|
|
{ |
247
|
|
|
$this->forumCategory = $forumCategory; |
248
|
|
|
|
249
|
|
|
return $this; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* Get forumCategory. |
254
|
|
|
* |
255
|
|
|
* @return null|CForumCategory |
256
|
|
|
*/ |
257
|
|
|
public function getForumCategory() |
258
|
|
|
{ |
259
|
|
|
return $this->forumCategory; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
public function setAllowAnonymous(int $allowAnonymous): self |
263
|
|
|
{ |
264
|
|
|
$this->allowAnonymous = $allowAnonymous; |
265
|
|
|
|
266
|
|
|
return $this; |
267
|
|
|
} |
268
|
|
|
|
269
|
|
|
/** |
270
|
|
|
* Get allowAnonymous. |
271
|
|
|
* |
272
|
|
|
* @return int |
273
|
|
|
*/ |
274
|
|
|
public function getAllowAnonymous() |
275
|
|
|
{ |
276
|
|
|
return $this->allowAnonymous; |
277
|
|
|
} |
278
|
|
|
|
279
|
|
|
public function setAllowEdit(int $allowEdit): self |
280
|
|
|
{ |
281
|
|
|
$this->allowEdit = $allowEdit; |
282
|
|
|
|
283
|
|
|
return $this; |
284
|
|
|
} |
285
|
|
|
|
286
|
|
|
/** |
287
|
|
|
* Get allowEdit. |
288
|
|
|
* |
289
|
|
|
* @return int |
290
|
|
|
*/ |
291
|
|
|
public function getAllowEdit() |
292
|
|
|
{ |
293
|
|
|
return $this->allowEdit; |
294
|
|
|
} |
295
|
|
|
|
296
|
|
|
public function setApprovalDirectPost(string $approvalDirectPost): self |
297
|
|
|
{ |
298
|
|
|
$this->approvalDirectPost = $approvalDirectPost; |
299
|
|
|
|
300
|
|
|
return $this; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
/** |
304
|
|
|
* Get approvalDirectPost. |
305
|
|
|
* |
306
|
|
|
* @return string |
307
|
|
|
*/ |
308
|
|
|
public function getApprovalDirectPost() |
309
|
|
|
{ |
310
|
|
|
return $this->approvalDirectPost; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
public function setAllowAttachments(int $allowAttachments): self |
314
|
|
|
{ |
315
|
|
|
$this->allowAttachments = $allowAttachments; |
316
|
|
|
|
317
|
|
|
return $this; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
/** |
321
|
|
|
* Get allowAttachments. |
322
|
|
|
* |
323
|
|
|
* @return int |
324
|
|
|
*/ |
325
|
|
|
public function getAllowAttachments() |
326
|
|
|
{ |
327
|
|
|
return $this->allowAttachments; |
328
|
|
|
} |
329
|
|
|
|
330
|
|
|
public function setAllowNewThreads(int $allowNewThreads): self |
331
|
|
|
{ |
332
|
|
|
$this->allowNewThreads = $allowNewThreads; |
333
|
|
|
|
334
|
|
|
return $this; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
/** |
338
|
|
|
* Get allowNewThreads. |
339
|
|
|
* |
340
|
|
|
* @return int |
341
|
|
|
*/ |
342
|
|
|
public function getAllowNewThreads() |
343
|
|
|
{ |
344
|
|
|
return $this->allowNewThreads; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
public function setDefaultView(string $defaultView): self |
348
|
|
|
{ |
349
|
|
|
$this->defaultView = $defaultView; |
350
|
|
|
|
351
|
|
|
return $this; |
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
/** |
355
|
|
|
* Get defaultView. |
356
|
|
|
* |
357
|
|
|
* @return string |
358
|
|
|
*/ |
359
|
|
|
public function getDefaultView() |
360
|
|
|
{ |
361
|
|
|
return $this->defaultView; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
public function setForumOfGroup(string $forumOfGroup): self |
365
|
|
|
{ |
366
|
|
|
$this->forumOfGroup = $forumOfGroup; |
367
|
|
|
|
368
|
|
|
return $this; |
369
|
|
|
} |
370
|
|
|
|
371
|
|
|
/** |
372
|
|
|
* Get forumOfGroup. |
373
|
|
|
* |
374
|
|
|
* @return string |
375
|
|
|
*/ |
376
|
|
|
public function getForumOfGroup() |
377
|
|
|
{ |
378
|
|
|
return $this->forumOfGroup; |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
public function getForumGroupPublicPrivate(): string |
382
|
|
|
{ |
383
|
|
|
return $this->forumGroupPublicPrivate; |
|
|
|
|
384
|
|
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* @return $this |
388
|
|
|
*/ |
389
|
|
|
public function setForumGroupPublicPrivate(string $forumGroupPublicPrivate) |
390
|
|
|
{ |
391
|
|
|
$this->forumGroupPublicPrivate = $forumGroupPublicPrivate; |
392
|
|
|
|
393
|
|
|
return $this; |
394
|
|
|
} |
395
|
|
|
|
396
|
|
|
public function setForumOrder(int $forumOrder): self |
397
|
|
|
{ |
398
|
|
|
$this->forumOrder = $forumOrder; |
399
|
|
|
|
400
|
|
|
return $this; |
401
|
|
|
} |
402
|
|
|
|
403
|
|
|
/** |
404
|
|
|
* Get forumOrder. |
405
|
|
|
* |
406
|
|
|
* @return int |
407
|
|
|
*/ |
408
|
|
|
public function getForumOrder() |
409
|
|
|
{ |
410
|
|
|
return $this->forumOrder; |
411
|
|
|
} |
412
|
|
|
|
413
|
|
|
public function setLocked(int $locked): self |
414
|
|
|
{ |
415
|
|
|
$this->locked = $locked; |
416
|
|
|
|
417
|
|
|
return $this; |
418
|
|
|
} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* Get locked. |
422
|
|
|
* |
423
|
|
|
* @return int |
424
|
|
|
*/ |
425
|
|
|
public function getLocked() |
426
|
|
|
{ |
427
|
|
|
return $this->locked; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
public function setForumImage(string $forumImage): self |
431
|
|
|
{ |
432
|
|
|
$this->forumImage = $forumImage; |
433
|
|
|
|
434
|
|
|
return $this; |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
/** |
438
|
|
|
* Get forumImage. |
439
|
|
|
* |
440
|
|
|
* @return string |
441
|
|
|
*/ |
442
|
|
|
public function getForumImage() |
443
|
|
|
{ |
444
|
|
|
return $this->forumImage; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
public function setStartTime(?DateTime $startTime): self |
448
|
|
|
{ |
449
|
|
|
$this->startTime = $startTime; |
450
|
|
|
|
451
|
|
|
return $this; |
452
|
|
|
} |
453
|
|
|
|
454
|
|
|
/** |
455
|
|
|
* Get startTime. |
456
|
|
|
* |
457
|
|
|
* @return DateTime |
458
|
|
|
*/ |
459
|
|
|
public function getStartTime() |
460
|
|
|
{ |
461
|
|
|
return $this->startTime; |
462
|
|
|
} |
463
|
|
|
|
464
|
|
|
public function setEndTime(?DateTime $endTime): self |
465
|
|
|
{ |
466
|
|
|
$this->endTime = $endTime; |
467
|
|
|
|
468
|
|
|
return $this; |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* Get endTime. |
473
|
|
|
* |
474
|
|
|
* @return DateTime |
475
|
|
|
*/ |
476
|
|
|
public function getEndTime() |
477
|
|
|
{ |
478
|
|
|
return $this->endTime; |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
public function isModerated(): bool |
482
|
|
|
{ |
483
|
|
|
return $this->moderated; |
|
|
|
|
484
|
|
|
} |
485
|
|
|
|
486
|
|
|
public function setModerated(bool $moderated): self |
487
|
|
|
{ |
488
|
|
|
$this->moderated = $moderated; |
489
|
|
|
|
490
|
|
|
return $this; |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
/** |
494
|
|
|
* Get iid. |
495
|
|
|
* |
496
|
|
|
* @return int |
497
|
|
|
*/ |
498
|
|
|
public function getIid() |
499
|
|
|
{ |
500
|
|
|
return $this->iid; |
501
|
|
|
} |
502
|
|
|
|
503
|
|
|
/** |
504
|
|
|
* Get threads. |
505
|
|
|
* |
506
|
|
|
* @return Collection|CForumThread[] |
507
|
|
|
*/ |
508
|
|
|
public function getThreads() |
509
|
|
|
{ |
510
|
|
|
return $this->threads; |
511
|
|
|
} |
512
|
|
|
|
513
|
|
|
public function getForumLastPost(): ?CForumPost |
514
|
|
|
{ |
515
|
|
|
return $this->forumLastPost; |
516
|
|
|
} |
517
|
|
|
|
518
|
|
|
public function setForumLastPost(CForumPost $forumLastPost): self |
519
|
|
|
{ |
520
|
|
|
$this->forumLastPost = $forumLastPost; |
521
|
|
|
|
522
|
|
|
return $this; |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
public function getLp(): ?CLp |
526
|
|
|
{ |
527
|
|
|
return $this->lp; |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
public function setLp(?CLp $lp): self |
531
|
|
|
{ |
532
|
|
|
$this->lp = $lp; |
533
|
|
|
|
534
|
|
|
return $this; |
535
|
|
|
} |
536
|
|
|
|
537
|
|
|
/** |
538
|
|
|
* @return Collection|CForumPost[] |
539
|
|
|
*/ |
540
|
|
|
public function getPosts() |
541
|
|
|
{ |
542
|
|
|
return $this->posts; |
543
|
|
|
} |
544
|
|
|
|
545
|
|
|
public function getResourceIdentifier(): int |
546
|
|
|
{ |
547
|
|
|
return $this->getIid(); |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
public function getResourceName(): string |
551
|
|
|
{ |
552
|
|
|
return $this->getForumTitle(); |
553
|
|
|
} |
554
|
|
|
|
555
|
|
|
public function setResourceName(string $name): self |
556
|
|
|
{ |
557
|
|
|
return $this->setForumTitle($name); |
558
|
|
|
} |
559
|
|
|
} |
560
|
|
|
|