Passed
Push — master ( ea0e05...21d25a )
by Julito
08:49
created

CForumForum::setAllowNewThreads()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
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
 * CForumForum.
20
 *
21
 * @ORM\Table(
22
 *     name="c_forum_forum",
23
 *     indexes={
24
 *     }
25
 * )
26
 * @ORM\Entity
27
 */
28
class CForumForum 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="session_id", type="integer", nullable=false)
127
     */
128
    protected int $sessionId;
129
130
    /**
131
     * @ORM\Column(name="forum_image", type="string", length=255, nullable=false)
132
     */
133
    protected string $forumImage;
134
135
    /**
136
     * @ORM\Column(name="start_time", type="datetime", nullable=true)
137
     */
138
    protected ?DateTime $startTime = null;
139
140
    /**
141
     * @ORM\Column(name="end_time", type="datetime", nullable=true)
142
     */
143
    protected ?DateTime $endTime = null;
144
145
    /**
146
     * @ORM\OneToOne(targetEntity="Chamilo\CourseBundle\Entity\CLp", inversedBy="forum")
147
     * @ORM\JoinColumn(name="lp_id", referencedColumnName="iid", nullable=true)
148
     */
149
    protected ?CLp $lp = null;
150
151
    /**
152
     * @ORM\Column(name="moderated", type="boolean", nullable=true)
153
     */
154
    protected ?bool $moderated = null;
155
156
    /**
157
     * @var Collection|CForumThread[]
158
     *
159
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumThread", mappedBy="forum")
160
     */
161
    protected Collection $threads;
162
163
    /**
164
     * @var Collection|CForumPost[]
165
     *
166
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumPost", mappedBy="forum")
167
     */
168
    protected Collection $posts;
169
170
    public function __construct()
171
    {
172
        $this->threads = new ArrayCollection();
173
        $this->posts = new ArrayCollection();
174
        $this->locked = 0;
175
        $this->forumComment = '';
176
        $this->forumImage = '';
177
        $this->forumOfGroup = '';
178
        $this->forumPosts = 0;
179
        $this->forumGroupPublicPrivate = '';
180
    }
181
182
    public function __toString(): string
183
    {
184
        return $this->getForumTitle();
185
    }
186
187
    public function setForumTitle(string $forumTitle): self
188
    {
189
        $this->forumTitle = $forumTitle;
190
191
        return $this;
192
    }
193
194
    public function getForumTitle(): string
195
    {
196
        return $this->forumTitle;
197
    }
198
199
    public function setForumComment(string $forumComment): self
200
    {
201
        $this->forumComment = $forumComment;
202
203
        return $this;
204
    }
205
206
    public function getForumComment(): string
207
    {
208
        return $this->forumComment;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->forumComment could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
209
    }
210
211
    public function setForumThreads(int $forumThreads): self
212
    {
213
        $this->forumThreads = $forumThreads;
214
215
        return $this;
216
    }
217
218
    /**
219
     * Get forumThreads.
220
     *
221
     * @return int
222
     */
223
    public function getForumThreads()
224
    {
225
        return $this->forumThreads;
226
    }
227
228
    public function hasThread(CForumThread $thread): bool
229
    {
230
        return $this->threads->contains($thread);
231
    }
232
233
    /**
234
     * Set forumPosts.
235
     *
236
     * @return CForumForum
237
     */
238
    public function setForumPosts(int $forumPosts)
239
    {
240
        $this->forumPosts = $forumPosts;
241
242
        return $this;
243
    }
244
245
    /**
246
     * Get forumPosts.
247
     *
248
     * @return int
249
     */
250
    public function getForumPosts()
251
    {
252
        return $this->forumPosts;
253
    }
254
255
    /**
256
     * Set forumCategory.
257
     *
258
     * @return CForumForum
259
     */
260
    public function setForumCategory(CForumCategory $forumCategory = null)
261
    {
262
        $this->forumCategory = $forumCategory;
263
264
        return $this;
265
    }
266
267
    /**
268
     * Get forumCategory.
269
     *
270
     * @return null|CForumCategory
271
     */
272
    public function getForumCategory()
273
    {
274
        return $this->forumCategory;
275
    }
276
277
    /**
278
     * Set allowAnonymous.
279
     *
280
     * @return CForumForum
281
     */
282
    public function setAllowAnonymous(int $allowAnonymous)
283
    {
284
        $this->allowAnonymous = $allowAnonymous;
285
286
        return $this;
287
    }
288
289
    /**
290
     * Get allowAnonymous.
291
     *
292
     * @return int
293
     */
294
    public function getAllowAnonymous()
295
    {
296
        return $this->allowAnonymous;
297
    }
298
299
    public function setAllowEdit(int $allowEdit): self
300
    {
301
        $this->allowEdit = $allowEdit;
302
303
        return $this;
304
    }
305
306
    /**
307
     * Get allowEdit.
308
     *
309
     * @return int
310
     */
311
    public function getAllowEdit()
312
    {
313
        return $this->allowEdit;
314
    }
315
316
    /**
317
     * Set approvalDirectPost.
318
     *
319
     * @return CForumForum
320
     */
321
    public function setApprovalDirectPost(string $approvalDirectPost)
322
    {
323
        $this->approvalDirectPost = $approvalDirectPost;
324
325
        return $this;
326
    }
327
328
    /**
329
     * Get approvalDirectPost.
330
     *
331
     * @return string
332
     */
333
    public function getApprovalDirectPost()
334
    {
335
        return $this->approvalDirectPost;
336
    }
337
338
    /**
339
     * Set allowAttachments.
340
     *
341
     * @return CForumForum
342
     */
343
    public function setAllowAttachments(int $allowAttachments)
344
    {
345
        $this->allowAttachments = $allowAttachments;
346
347
        return $this;
348
    }
349
350
    /**
351
     * Get allowAttachments.
352
     *
353
     * @return int
354
     */
355
    public function getAllowAttachments()
356
    {
357
        return $this->allowAttachments;
358
    }
359
360
    /**
361
     * Set allowNewThreads.
362
     *
363
     * @return CForumForum
364
     */
365
    public function setAllowNewThreads(int $allowNewThreads)
366
    {
367
        $this->allowNewThreads = $allowNewThreads;
368
369
        return $this;
370
    }
371
372
    /**
373
     * Get allowNewThreads.
374
     *
375
     * @return int
376
     */
377
    public function getAllowNewThreads()
378
    {
379
        return $this->allowNewThreads;
380
    }
381
382
    /**
383
     * Set defaultView.
384
     *
385
     * @return CForumForum
386
     */
387
    public function setDefaultView(string $defaultView)
388
    {
389
        $this->defaultView = $defaultView;
390
391
        return $this;
392
    }
393
394
    /**
395
     * Get defaultView.
396
     *
397
     * @return string
398
     */
399
    public function getDefaultView()
400
    {
401
        return $this->defaultView;
402
    }
403
404
    /**
405
     * Set forumOfGroup.
406
     *
407
     * @return CForumForum
408
     */
409
    public function setForumOfGroup(string $forumOfGroup)
410
    {
411
        $this->forumOfGroup = $forumOfGroup;
412
413
        return $this;
414
    }
415
416
    /**
417
     * Get forumOfGroup.
418
     *
419
     * @return string
420
     */
421
    public function getForumOfGroup()
422
    {
423
        return $this->forumOfGroup;
424
    }
425
426
    public function getForumGroupPublicPrivate(): string
427
    {
428
        return $this->forumGroupPublicPrivate;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->forumGroupPublicPrivate could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
429
    }
430
431
    /**
432
     * @return $this
433
     */
434
    public function setForumGroupPublicPrivate(string $forumGroupPublicPrivate)
435
    {
436
        $this->forumGroupPublicPrivate = $forumGroupPublicPrivate;
437
438
        return $this;
439
    }
440
441
    /**
442
     * Set forumOrder.
443
     *
444
     * @return CForumForum
445
     */
446
    public function setForumOrder(int $forumOrder)
447
    {
448
        $this->forumOrder = $forumOrder;
449
450
        return $this;
451
    }
452
453
    /**
454
     * Get forumOrder.
455
     *
456
     * @return int
457
     */
458
    public function getForumOrder()
459
    {
460
        return $this->forumOrder;
461
    }
462
463
    /**
464
     * Set locked.
465
     *
466
     * @return CForumForum
467
     */
468
    public function setLocked(int $locked)
469
    {
470
        $this->locked = $locked;
471
472
        return $this;
473
    }
474
475
    /**
476
     * Get locked.
477
     *
478
     * @return int
479
     */
480
    public function getLocked()
481
    {
482
        return $this->locked;
483
    }
484
485
    /**
486
     * Set sessionId.
487
     *
488
     * @return CForumForum
489
     */
490
    public function setSessionId(int $sessionId)
491
    {
492
        $this->sessionId = $sessionId;
493
494
        return $this;
495
    }
496
497
    /**
498
     * Get sessionId.
499
     *
500
     * @return int
501
     */
502
    public function getSessionId()
503
    {
504
        return $this->sessionId;
505
    }
506
507
    /**
508
     * Set forumImage.
509
     *
510
     * @return CForumForum
511
     */
512
    public function setForumImage(string $forumImage)
513
    {
514
        $this->forumImage = $forumImage;
515
516
        return $this;
517
    }
518
519
    /**
520
     * Get forumImage.
521
     *
522
     * @return string
523
     */
524
    public function getForumImage()
525
    {
526
        return $this->forumImage;
527
    }
528
529
    public function setStartTime(?DateTime $startTime): self
530
    {
531
        $this->startTime = $startTime;
532
533
        return $this;
534
    }
535
536
    /**
537
     * Get startTime.
538
     *
539
     * @return DateTime
540
     */
541
    public function getStartTime()
542
    {
543
        return $this->startTime;
544
    }
545
546
    public function setEndTime(?DateTime $endTime): self
547
    {
548
        $this->endTime = $endTime;
549
550
        return $this;
551
    }
552
553
    /**
554
     * Get endTime.
555
     *
556
     * @return DateTime
557
     */
558
    public function getEndTime()
559
    {
560
        return $this->endTime;
561
    }
562
563
    public function isModerated(): bool
564
    {
565
        return $this->moderated;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->moderated could return the type null which is incompatible with the type-hinted return boolean. Consider adding an additional type-check to rule them out.
Loading history...
566
    }
567
568
    public function setModerated(bool $moderated): self
569
    {
570
        $this->moderated = $moderated;
571
572
        return $this;
573
    }
574
575
    /**
576
     * Get iid.
577
     *
578
     * @return int
579
     */
580
    public function getIid()
581
    {
582
        return $this->iid;
583
    }
584
585
    /**
586
     * Get threads.
587
     *
588
     * @return Collection|CForumThread[]
589
     */
590
    public function getThreads()
591
    {
592
        return $this->threads;
593
    }
594
595
    public function getForumLastPost(): ?CForumPost
596
    {
597
        return $this->forumLastPost;
598
    }
599
600
    public function setForumLastPost(CForumPost $forumLastPost): self
601
    {
602
        $this->forumLastPost = $forumLastPost;
603
604
        return $this;
605
    }
606
607
    public function getLp(): ?CLp
608
    {
609
        return $this->lp;
610
    }
611
612
    public function setLp(?CLp $lp): self
613
    {
614
        $this->lp = $lp;
615
616
        return $this;
617
    }
618
619
    /**
620
     * @return Collection|CForumPost[]
621
     */
622
    public function getPosts()
623
    {
624
        return $this->posts;
625
    }
626
627
    public function getResourceIdentifier(): int
628
    {
629
        return $this->getIid();
630
    }
631
632
    public function getResourceName(): string
633
    {
634
        return $this->getForumTitle();
635
    }
636
637
    public function setResourceName(string $name): self
638
    {
639
        return $this->setForumTitle($name);
640
    }
641
}
642