Passed
Push — master ( 4357b6...fb3111 )
by Julito
08:58
created

CForumForum::getLp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\CourseBundle\Entity;
6
7
use Chamilo\CoreBundle\Entity\AbstractResource;
8
use Chamilo\CoreBundle\Entity\ResourceInterface;
9
use Doctrine\Common\Collections\ArrayCollection;
10
use Doctrine\ORM\Mapping as ORM;
11
use Gedmo\Mapping\Annotation as Gedmo;
12
use Symfony\Component\Validator\Constraints as Assert;
13
14
/**
15
 * CForumForum.
16
 *
17
 * @ORM\Table(
18
 *  name="c_forum_forum",
19
 *  indexes={
20
 *      @ORM\Index(name="course", columns={"c_id"})
21
 *  }
22
 * )
23
 * @ORM\Entity
24
 */
25
class CForumForum extends AbstractResource implements ResourceInterface
26
{
27
    /**
28
     * @var int
29
     *
30
     * @ORM\Column(name="iid", type="integer")
31
     * @ORM\Id
32
     * @ORM\GeneratedValue
33
     */
34
    protected $iid;
35
36
    /**
37
     * @var int
38
     *
39
     * @ORM\Column(name="c_id", type="integer")
40
     */
41
    protected $cId;
42
43
    /**
44
     * @var string
45
     *
46
     * @Assert\NotBlank
47
     *
48
     * @ORM\Column(name="forum_title", type="string", length=255, nullable=false)
49
     */
50
    protected $forumTitle;
51
52
    /**
53
     * @var string
54
     *
55
     * @ORM\Column(name="forum_comment", type="text", nullable=true)
56
     */
57
    protected $forumComment;
58
59
    /**
60
     * @var int
61
     *
62
     * @ORM\Column(name="forum_threads", type="integer", nullable=true)
63
     */
64
    protected $forumThreads;
65
66
    /**
67
     * @var int
68
     *
69
     * @ORM\Column(name="forum_posts", type="integer", nullable=true)
70
     */
71
    protected $forumPosts;
72
73
    /**
74
     * @var CForumPost
75
     *
76
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumPost")
77
     * @ORM\JoinColumn(name="forum_last_post", referencedColumnName="iid")
78
     */
79
    protected $forumLastPost;
80
81
    /**
82
     * @Gedmo\SortableGroup
83
     *
84
     * @var CForumCategory|null
85
     *
86
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumCategory", inversedBy="forums")
87
     * @ORM\JoinColumn(name="forum_category", referencedColumnName="iid", nullable=true, onDelete="SET NULL")
88
     */
89
    protected $forumCategory;
90
91
    /**
92
     * @var int
93
     *
94
     * @ORM\Column(name="allow_anonymous", type="integer", nullable=true)
95
     */
96
    protected $allowAnonymous;
97
98
    /**
99
     * @var int
100
     *
101
     * @ORM\Column(name="allow_edit", type="integer", nullable=true)
102
     */
103
    protected $allowEdit;
104
105
    /**
106
     * @var string
107
     *
108
     * @ORM\Column(name="approval_direct_post", type="string", length=20, nullable=true)
109
     */
110
    protected $approvalDirectPost;
111
112
    /**
113
     * @var int
114
     *
115
     * @ORM\Column(name="allow_attachments", type="integer", nullable=true)
116
     */
117
    protected $allowAttachments;
118
119
    /**
120
     * @var int
121
     *
122
     * @ORM\Column(name="allow_new_threads", type="integer", nullable=true)
123
     */
124
    protected $allowNewThreads;
125
126
    /**
127
     * @var string
128
     *
129
     * @ORM\Column(name="default_view", type="string", length=20, nullable=true)
130
     */
131
    protected $defaultView;
132
133
    /**
134
     * @var string
135
     *
136
     * @ORM\Column(name="forum_of_group", type="string", length=20, nullable=true)
137
     */
138
    protected $forumOfGroup;
139
140
    /**
141
     * @var string
142
     *
143
     * @ORM\Column(name="forum_group_public_private", type="string", length=20, nullable=true)
144
     */
145
    protected $forumGroupPublicPrivate;
146
147
    /**
148
     * @var int
149
     * @Gedmo\SortablePosition
150
     *
151
     * @ORM\Column(name="forum_order", type="integer", nullable=true)
152
     */
153
    protected $forumOrder;
154
155
    /**
156
     * @var int
157
     *
158
     * @ORM\Column(name="locked", type="integer", nullable=false)
159
     */
160
    protected $locked;
161
162
    /**
163
     * @var int
164
     *
165
     * @ORM\Column(name="session_id", type="integer", nullable=false)
166
     */
167
    protected $sessionId;
168
169
    /**
170
     * @var string
171
     *
172
     * @ORM\Column(name="forum_image", type="string", length=255, nullable=false)
173
     */
174
    protected $forumImage;
175
176
    /**
177
     * @var \DateTime
178
     *
179
     * @ORM\Column(name="start_time", type="datetime", nullable=true)
180
     */
181
    protected $startTime;
182
183
    /**
184
     * @var \DateTime
185
     *
186
     * @ORM\Column(name="end_time", type="datetime", nullable=true)
187
     */
188
    protected $endTime;
189
190
    /**
191
     * @ORM\OneToOne(targetEntity="Chamilo\CourseBundle\Entity\CLp", inversedBy="forum")
192
     * @ORM\JoinColumn(name="lp_id", referencedColumnName="iid", nullable=true)
193
     */
194
    protected $lp;
195
196
    /**
197
     * @var bool
198
     *
199
     * @ORM\Column(name="moderated", type="boolean", nullable=true)
200
     */
201
    protected $moderated;
202
203
    /**
204
     * @var ArrayCollection|CForumThread[]
205
     *
206
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumThread", mappedBy="forum")
207
     */
208
    protected $threads;
209
210
    /**
211
     * @var ArrayCollection|CForumPost[]
212
     *
213
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumPost", mappedBy="forum")
214
     */
215
    protected $posts;
216
217
    /**
218
     * CForumForum constructor.
219
     */
220
    public function __construct()
221
    {
222
        $this->threads = new ArrayCollection();
223
        $this->posts = new ArrayCollection();
224
        $this->locked = 0;
225
        $this->forumImage = '';
226
        $this->forumOfGroup = 0;
227
        $this->forumPosts = 0;
228
        $this->forumGroupPublicPrivate = '';
229
    }
230
231
    public function __toString(): string
232
    {
233
        return $this->getForumTitle();
234
    }
235
236
    /**
237
     * Set forumTitle.
238
     *
239
     * @param string $forumTitle
240
     *
241
     * @return CForumForum
242
     */
243
    public function setForumTitle($forumTitle)
244
    {
245
        $this->forumTitle = $forumTitle;
246
247
        return $this;
248
    }
249
250
    /**
251
     * Get forumTitle.
252
     *
253
     * @return string
254
     */
255
    public function getForumTitle()
256
    {
257
        return $this->forumTitle;
258
    }
259
260
    /**
261
     * Set forumComment.
262
     *
263
     * @param string $forumComment
264
     */
265
    public function setForumComment($forumComment): self
266
    {
267
        $this->forumComment = $forumComment;
268
269
        return $this;
270
    }
271
272
    /**
273
     * Get forumComment.
274
     *
275
     * @return string
276
     */
277
    public function getForumComment()
278
    {
279
        return $this->forumComment;
280
    }
281
282
    /**
283
     * Set forumThreads.
284
     *
285
     * @param int $forumThreads
286
     */
287
    public function setForumThreads($forumThreads): self
288
    {
289
        $this->forumThreads = $forumThreads;
290
291
        return $this;
292
    }
293
294
    /**
295
     * Get forumThreads.
296
     *
297
     * @return int
298
     */
299
    public function getForumThreads()
300
    {
301
        return $this->forumThreads;
302
    }
303
304
    public function hasThread($thread)
305
    {
306
        return $this->threads->contains($thread);
307
    }
308
309
    /**
310
     * Set forumPosts.
311
     *
312
     * @param int $forumPosts
313
     *
314
     * @return CForumForum
315
     */
316
    public function setForumPosts($forumPosts)
317
    {
318
        $this->forumPosts = $forumPosts;
319
320
        return $this;
321
    }
322
323
    /**
324
     * Get forumPosts.
325
     *
326
     * @return int
327
     */
328
    public function getForumPosts()
329
    {
330
        return $this->forumPosts;
331
    }
332
333
    /**
334
     * Set forumCategory.
335
     *
336
     * @return CForumForum
337
     */
338
    public function setForumCategory(CForumCategory $forumCategory = null)
339
    {
340
        $this->forumCategory = $forumCategory;
341
342
        return $this;
343
    }
344
345
    /**
346
     * Get forumCategory.
347
     *
348
     * @return CForumCategory|null
349
     */
350
    public function getForumCategory()
351
    {
352
        return $this->forumCategory;
353
    }
354
355
    /**
356
     * Set allowAnonymous.
357
     *
358
     * @param int $allowAnonymous
359
     *
360
     * @return CForumForum
361
     */
362
    public function setAllowAnonymous($allowAnonymous)
363
    {
364
        $this->allowAnonymous = $allowAnonymous;
365
366
        return $this;
367
    }
368
369
    /**
370
     * Get allowAnonymous.
371
     *
372
     * @return int
373
     */
374
    public function getAllowAnonymous()
375
    {
376
        return $this->allowAnonymous;
377
    }
378
379
    /**
380
     * Set allowEdit.
381
     *
382
     * @param int $allowEdit
383
     *
384
     * @return CForumForum
385
     */
386
    public function setAllowEdit($allowEdit)
387
    {
388
        $this->allowEdit = $allowEdit;
389
390
        return $this;
391
    }
392
393
    /**
394
     * Get allowEdit.
395
     *
396
     * @return int
397
     */
398
    public function getAllowEdit()
399
    {
400
        return $this->allowEdit;
401
    }
402
403
    /**
404
     * Set approvalDirectPost.
405
     *
406
     * @param string $approvalDirectPost
407
     *
408
     * @return CForumForum
409
     */
410
    public function setApprovalDirectPost($approvalDirectPost)
411
    {
412
        $this->approvalDirectPost = $approvalDirectPost;
413
414
        return $this;
415
    }
416
417
    /**
418
     * Get approvalDirectPost.
419
     *
420
     * @return string
421
     */
422
    public function getApprovalDirectPost()
423
    {
424
        return $this->approvalDirectPost;
425
    }
426
427
    /**
428
     * Set allowAttachments.
429
     *
430
     * @param int $allowAttachments
431
     *
432
     * @return CForumForum
433
     */
434
    public function setAllowAttachments($allowAttachments)
435
    {
436
        $this->allowAttachments = $allowAttachments;
437
438
        return $this;
439
    }
440
441
    /**
442
     * Get allowAttachments.
443
     *
444
     * @return int
445
     */
446
    public function getAllowAttachments()
447
    {
448
        return $this->allowAttachments;
449
    }
450
451
    /**
452
     * Set allowNewThreads.
453
     *
454
     * @param int $allowNewThreads
455
     *
456
     * @return CForumForum
457
     */
458
    public function setAllowNewThreads($allowNewThreads)
459
    {
460
        $this->allowNewThreads = $allowNewThreads;
461
462
        return $this;
463
    }
464
465
    /**
466
     * Get allowNewThreads.
467
     *
468
     * @return int
469
     */
470
    public function getAllowNewThreads()
471
    {
472
        return $this->allowNewThreads;
473
    }
474
475
    /**
476
     * Set defaultView.
477
     *
478
     * @param string $defaultView
479
     *
480
     * @return CForumForum
481
     */
482
    public function setDefaultView($defaultView)
483
    {
484
        $this->defaultView = $defaultView;
485
486
        return $this;
487
    }
488
489
    /**
490
     * Get defaultView.
491
     *
492
     * @return string
493
     */
494
    public function getDefaultView()
495
    {
496
        return $this->defaultView;
497
    }
498
499
    /**
500
     * Set forumOfGroup.
501
     *
502
     * @param string $forumOfGroup
503
     *
504
     * @return CForumForum
505
     */
506
    public function setForumOfGroup($forumOfGroup)
507
    {
508
        $this->forumOfGroup = $forumOfGroup;
509
510
        return $this;
511
    }
512
513
    /**
514
     * Get forumOfGroup.
515
     *
516
     * @return string
517
     */
518
    public function getForumOfGroup()
519
    {
520
        return $this->forumOfGroup;
521
    }
522
523
    public function getForumGroupPublicPrivate(): string
524
    {
525
        return $this->forumGroupPublicPrivate;
526
    }
527
528
    /**
529
     * @return $this
530
     */
531
    public function setForumGroupPublicPrivate(string $forumGroupPublicPrivate)
532
    {
533
        $this->forumGroupPublicPrivate = $forumGroupPublicPrivate;
534
535
        return $this;
536
    }
537
538
    /**
539
     * Set forumOrder.
540
     *
541
     * @param int $forumOrder
542
     *
543
     * @return CForumForum
544
     */
545
    public function setForumOrder($forumOrder)
546
    {
547
        $this->forumOrder = $forumOrder;
548
549
        return $this;
550
    }
551
552
    /**
553
     * Get forumOrder.
554
     *
555
     * @return int
556
     */
557
    public function getForumOrder()
558
    {
559
        return $this->forumOrder;
560
    }
561
562
    /**
563
     * Set locked.
564
     *
565
     * @param int $locked
566
     *
567
     * @return CForumForum
568
     */
569
    public function setLocked($locked)
570
    {
571
        $this->locked = $locked;
572
573
        return $this;
574
    }
575
576
    /**
577
     * Get locked.
578
     *
579
     * @return int
580
     */
581
    public function getLocked()
582
    {
583
        return $this->locked;
584
    }
585
586
    /**
587
     * Set sessionId.
588
     *
589
     * @param int $sessionId
590
     *
591
     * @return CForumForum
592
     */
593
    public function setSessionId($sessionId)
594
    {
595
        $this->sessionId = $sessionId;
596
597
        return $this;
598
    }
599
600
    /**
601
     * Get sessionId.
602
     *
603
     * @return int
604
     */
605
    public function getSessionId()
606
    {
607
        return $this->sessionId;
608
    }
609
610
    /**
611
     * Set forumImage.
612
     *
613
     * @param string $forumImage
614
     *
615
     * @return CForumForum
616
     */
617
    public function setForumImage($forumImage)
618
    {
619
        $this->forumImage = $forumImage;
620
621
        return $this;
622
    }
623
624
    /**
625
     * Get forumImage.
626
     *
627
     * @return string
628
     */
629
    public function getForumImage()
630
    {
631
        return $this->forumImage;
632
    }
633
634
    /**
635
     * Set startTime.
636
     *
637
     * @param \DateTime $startTime
638
     *
639
     * @return CForumForum
640
     */
641
    public function setStartTime($startTime)
642
    {
643
        $this->startTime = $startTime;
644
645
        return $this;
646
    }
647
648
    /**
649
     * Get startTime.
650
     *
651
     * @return \DateTime
652
     */
653
    public function getStartTime()
654
    {
655
        return $this->startTime;
656
    }
657
658
    /**
659
     * Set endTime.
660
     *
661
     * @param \DateTime $endTime
662
     *
663
     * @return CForumForum
664
     */
665
    public function setEndTime($endTime)
666
    {
667
        $this->endTime = $endTime;
668
669
        return $this;
670
    }
671
672
    /**
673
     * Get endTime.
674
     *
675
     * @return \DateTime
676
     */
677
    public function getEndTime()
678
    {
679
        return $this->endTime;
680
    }
681
682
    /**
683
     * Set cId.
684
     *
685
     * @param int $cId
686
     *
687
     * @return CForumForum
688
     */
689
    public function setCId($cId)
690
    {
691
        $this->cId = $cId;
692
693
        return $this;
694
    }
695
696
    /**
697
     * Get cId.
698
     *
699
     * @return int
700
     */
701
    public function getCId()
702
    {
703
        return $this->cId;
704
    }
705
706
    /**
707
     * Set lpId.
708
     *
709
     * @param int $lpId
710
     *
711
     * @return CForumForum
712
     */
713
    public function setLpId($lpId)
714
    {
715
        $this->lpId = $lpId;
716
717
        return $this;
718
    }
719
720
    /**
721
     * Get lpId.
722
     *
723
     * @return int
724
     */
725
    public function getLpId()
726
    {
727
        return $this->lpId;
728
    }
729
730
    /**
731
     * @return bool
732
     */
733
    public function isModerated()
734
    {
735
        return $this->moderated;
736
    }
737
738
    /**
739
     * @param $moderated
740
     *
741
     * @return $this
742
     */
743
    public function setModerated($moderated)
744
    {
745
        $this->moderated = $moderated;
746
747
        return $this;
748
    }
749
750
    /**
751
     * Get iid.
752
     *
753
     * @return int
754
     */
755
    public function getIid()
756
    {
757
        return $this->iid;
758
    }
759
760
    /**
761
     * Get threads.
762
     *
763
     * @return ArrayCollection|CForumThread[]
764
     */
765
    public function getThreads()
766
    {
767
        return $this->threads;
768
    }
769
770
    public function getForumLastPost(): ?CForumPost
771
    {
772
        return $this->forumLastPost;
773
    }
774
775
    public function setForumLastPost(CForumPost $forumLastPost): self
776
    {
777
        $this->forumLastPost = $forumLastPost;
778
779
        return $this;
780
    }
781
782
    public function getLp(): ?CLp
783
    {
784
        return $this->lp;
785
    }
786
787
    public function setLp(CLp $lp): self
788
    {
789
        $this->lp = $lp;
790
791
        return $this;
792
    }
793
794
    /**
795
     * @return CForumPost[]|ArrayCollection
796
     */
797
    public function getPosts()
798
    {
799
        return $this->posts;
800
    }
801
802
    public function getResourceIdentifier(): int
803
    {
804
        return $this->getIid();
805
    }
806
807
    public function getResourceName(): string
808
    {
809
        return $this->getForumTitle();
810
    }
811
812
    public function setResourceName(string $name): self
813
    {
814
        return $this->setForumTitle($name);
815
    }
816
}
817