Passed
Push — master ( 8dc8d6...0b0f56 )
by Julito
10:41
created

CForumThread::setThreadViews()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 1
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 Chamilo\CoreBundle\Entity\User;
10
use Doctrine\Common\Collections\ArrayCollection;
11
use Doctrine\ORM\Mapping as ORM;
12
use Symfony\Component\Validator\Constraints as Assert;
13
14
/**
15
 * CForumThread.
16
 *
17
 * @ORM\Table(
18
 *  name="c_forum_thread",
19
 *  indexes={
20
 *      @ORM\Index(name="course", columns={"c_id"}),
21
 *      @ORM\Index(name="idx_forum_thread_forum_id", columns={"forum_id"})
22
 *  }
23
 * )
24
 * @ORM\Entity
25
 */
26
class CForumThread extends AbstractResource implements ResourceInterface
27
{
28
    /**
29
     * @var int
30
     *
31
     * @ORM\Column(name="iid", type="integer")
32
     * @ORM\Id
33
     * @ORM\GeneratedValue
34
     */
35
    protected $iid;
36
37
    /**
38
     * @var int
39
     *
40
     * @ORM\Column(name="c_id", type="integer")
41
     */
42
    protected $cId;
43
44
    /**
45
     * @var string
46
     *
47
     * @Assert\NotBlank()
48
     *
49
     * @ORM\Column(name="thread_title", type="string", length=255, nullable=true)
50
     */
51
    protected $threadTitle;
52
53
    /**
54
     * @var CForumForum|null
55
     *
56
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumForum", inversedBy="threads")
57
     * @ORM\JoinColumn(name="forum_id", referencedColumnName="iid", nullable=true, onDelete="SET NULL")
58
     */
59
    protected $forum;
60
61
    /**
62
     * @var int
63
     *
64
     * @ORM\Column(name="thread_replies", type="integer", nullable=false, options={"unsigned":true, "default" = 0})
65
     */
66
    protected $threadReplies;
67
68
    /**
69
     * @var User
70
     *
71
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\User")
72
     * @ORM\JoinColumn(name="thread_poster_id", referencedColumnName="id")
73
     */
74
    protected $user;
75
76
    /**
77
     * @var int
78
     *
79
     * @ORM\Column(name="thread_views", type="integer", nullable=false, options={"unsigned":true, "default" = 0})
80
     */
81
    protected $threadViews;
82
83
    /**
84
     * @var CForumPost
85
     *
86
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumPost")
87
     * @ORM\JoinColumn(name="thread_last_post", referencedColumnName="iid")
88
     */
89
    protected $threadLastPost;
90
91
    /**
92
     * @var \DateTime
93
     *
94
     * @ORM\Column(name="thread_date", type="datetime", nullable=true)
95
     */
96
    protected $threadDate;
97
98
    /**
99
     * @var bool
100
     *
101
     * @ORM\Column(name="thread_sticky", type="boolean", nullable=true)
102
     */
103
    protected $threadSticky;
104
105
    /**
106
     * @var int
107
     *
108
     * @ORM\Column(name="locked", type="integer", nullable=false)
109
     */
110
    protected $locked;
111
112
    /**
113
     * @var int
114
     *
115
     * @ORM\Column(name="session_id", type="integer", nullable=true)
116
     */
117
    protected $sessionId;
118
119
    /**
120
     * @var string
121
     *
122
     * @ORM\Column(name="thread_title_qualify", type="string", length=255, nullable=true)
123
     */
124
    protected $threadTitleQualify;
125
126
    /**
127
     * @var float
128
     *
129
     * @ORM\Column(name="thread_qualify_max", type="float", precision=6, scale=2, nullable=false)
130
     */
131
    protected $threadQualifyMax;
132
133
    /**
134
     * @var \DateTime
135
     *
136
     * @ORM\Column(name="thread_close_date", type="datetime", nullable=true)
137
     */
138
    protected $threadCloseDate;
139
140
    /**
141
     * @var float
142
     *
143
     * @ORM\Column(name="thread_weight", type="float", precision=6, scale=2, nullable=false)
144
     */
145
    protected $threadWeight;
146
147
    /**
148
     * @var bool
149
     *
150
     * @ORM\Column(name="thread_peer_qualify", type="boolean")
151
     */
152
    protected $threadPeerQualify;
153
154
    /**
155
     * @var int
156
     *
157
     * @ORM\Column(name="lp_item_id", type="integer", options={"unsigned":true})
158
     */
159
    protected $lpItemId;
160
161
    /**
162
     * @var ArrayCollection|CForumPost[]
163
     *
164
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumPost", mappedBy="thread", cascade={"persist", "remove"}, orphanRemoval=true)
165
     */
166
    protected $posts;
167
168
    public function __construct()
169
    {
170
        $this->posts = new ArrayCollection();
171
        $this->threadPeerQualify = false;
172
        $this->threadReplies = 0;
173
        $this->threadViews = 0;
174
        $this->locked = 0;
175
        $this->threadQualifyMax = 0;
176
        $this->threadWeight = 0;
177
        $this->lpItemId = 0;
178
    }
179
180
    public function __toString(): string
181
    {
182
        return (string) $this->getThreadTitle();
183
    }
184
185
    /**
186
     * @return bool
187
     */
188
    public function isThreadPeerQualify()
189
    {
190
        return $this->threadPeerQualify;
191
    }
192
193
    /**
194
     * set threadPeerQualify.
195
     *
196
     * @param bool $threadPeerQualify
197
     *
198
     * @return $this
199
     */
200
    public function setThreadPeerQualify($threadPeerQualify)
201
    {
202
        $this->threadPeerQualify = $threadPeerQualify;
203
204
        return $this;
205
    }
206
207
    /**
208
     * Set threadTitle.
209
     *
210
     * @param string $threadTitle
211
     *
212
     * @return CForumThread
213
     */
214
    public function setThreadTitle($threadTitle)
215
    {
216
        $this->threadTitle = $threadTitle;
217
218
        return $this;
219
    }
220
221
    /**
222
     * Get threadTitle.
223
     *
224
     * @return string
225
     */
226
    public function getThreadTitle()
227
    {
228
        return $this->threadTitle;
229
    }
230
231
    /**
232
     * Set forum.
233
     *
234
     * @return CForumThread
235
     */
236
    public function setForum(CForumForum $forum = null)
237
    {
238
        $this->forum = $forum;
239
240
        return $this;
241
    }
242
243
    /**
244
     * Get forumId.
245
     *
246
     * @return CForumForum|null
247
     */
248
    public function getForum()
249
    {
250
        return $this->forum;
251
    }
252
253
    /**
254
     * Set threadReplies.
255
     *
256
     * @param int $threadReplies
257
     *
258
     * @return CForumThread
259
     */
260
    public function setThreadReplies($threadReplies)
261
    {
262
        $this->threadReplies = $threadReplies;
263
264
        return $this;
265
    }
266
267
    /**
268
     * Get threadReplies.
269
     *
270
     * @return int
271
     */
272
    public function getThreadReplies()
273
    {
274
        return $this->threadReplies;
275
    }
276
277
    /**
278
     * Set threadViews.
279
     *
280
     * @param int $threadViews
281
     *
282
     * @return CForumThread
283
     */
284
    public function setThreadViews($threadViews)
285
    {
286
        $this->threadViews = $threadViews;
287
288
        return $this;
289
    }
290
291
    /**
292
     * Get threadViews.
293
     *
294
     * @return int
295
     */
296
    public function getThreadViews()
297
    {
298
        return $this->threadViews;
299
    }
300
301
    /**
302
     * Set threadDate.
303
     *
304
     * @param \DateTime $threadDate
305
     */
306
    public function setThreadDate($threadDate): self
307
    {
308
        $this->threadDate = $threadDate;
309
310
        return $this;
311
    }
312
313
    /**
314
     * Get threadDate.
315
     *
316
     * @return \DateTime
317
     */
318
    public function getThreadDate()
319
    {
320
        return $this->threadDate;
321
    }
322
323
    /**
324
     * Set threadSticky.
325
     *
326
     * @param bool $threadSticky
327
     *
328
     * @return CForumThread
329
     */
330
    public function setThreadSticky($threadSticky)
331
    {
332
        $this->threadSticky = $threadSticky;
333
334
        return $this;
335
    }
336
337
    /**
338
     * Get threadSticky.
339
     *
340
     * @return bool
341
     */
342
    public function getThreadSticky()
343
    {
344
        return $this->threadSticky;
345
    }
346
347
    /**
348
     * Set locked.
349
     *
350
     * @param int $locked
351
     *
352
     * @return CForumThread
353
     */
354
    public function setLocked($locked)
355
    {
356
        $this->locked = $locked;
357
358
        return $this;
359
    }
360
361
    /**
362
     * Get locked.
363
     *
364
     * @return int
365
     */
366
    public function getLocked()
367
    {
368
        return $this->locked;
369
    }
370
371
    /**
372
     * Set sessionId.
373
     *
374
     * @param int $sessionId
375
     *
376
     * @return CForumThread
377
     */
378
    public function setSessionId($sessionId)
379
    {
380
        $this->sessionId = $sessionId;
381
382
        return $this;
383
    }
384
385
    /**
386
     * Get sessionId.
387
     *
388
     * @return int
389
     */
390
    public function getSessionId()
391
    {
392
        return $this->sessionId;
393
    }
394
395
    /**
396
     * Set threadTitleQualify.
397
     *
398
     * @param string $threadTitleQualify
399
     *
400
     * @return CForumThread
401
     */
402
    public function setThreadTitleQualify($threadTitleQualify)
403
    {
404
        $this->threadTitleQualify = $threadTitleQualify;
405
406
        return $this;
407
    }
408
409
    /**
410
     * Get threadTitleQualify.
411
     *
412
     * @return string
413
     */
414
    public function getThreadTitleQualify()
415
    {
416
        return $this->threadTitleQualify;
417
    }
418
419
    /**
420
     * Set threadQualifyMax.
421
     *
422
     * @param float $threadQualifyMax
423
     *
424
     * @return CForumThread
425
     */
426
    public function setThreadQualifyMax($threadQualifyMax)
427
    {
428
        $this->threadQualifyMax = $threadQualifyMax;
429
430
        return $this;
431
    }
432
433
    /**
434
     * Get threadQualifyMax.
435
     *
436
     * @return float
437
     */
438
    public function getThreadQualifyMax()
439
    {
440
        return $this->threadQualifyMax;
441
    }
442
443
    /**
444
     * Set threadCloseDate.
445
     *
446
     * @param \DateTime $threadCloseDate
447
     *
448
     * @return CForumThread
449
     */
450
    public function setThreadCloseDate($threadCloseDate)
451
    {
452
        $this->threadCloseDate = $threadCloseDate;
453
454
        return $this;
455
    }
456
457
    /**
458
     * Get threadCloseDate.
459
     *
460
     * @return \DateTime
461
     */
462
    public function getThreadCloseDate()
463
    {
464
        return $this->threadCloseDate;
465
    }
466
467
    /**
468
     * Set threadWeight.
469
     *
470
     * @param float $threadWeight
471
     *
472
     * @return CForumThread
473
     */
474
    public function setThreadWeight($threadWeight)
475
    {
476
        $this->threadWeight = $threadWeight;
477
478
        return $this;
479
    }
480
481
    /**
482
     * Get threadWeight.
483
     *
484
     * @return float
485
     */
486
    public function getThreadWeight()
487
    {
488
        return $this->threadWeight;
489
    }
490
491
    /**
492
     * Set cId.
493
     *
494
     * @param int $cId
495
     *
496
     * @return CForumThread
497
     */
498
    public function setCId($cId)
499
    {
500
        $this->cId = $cId;
501
502
        return $this;
503
    }
504
505
    /**
506
     * Get cId.
507
     *
508
     * @return int
509
     */
510
    public function getCId()
511
    {
512
        return $this->cId;
513
    }
514
515
    /**
516
     * Set lpItemId.
517
     *
518
     * @param int $lpItemId
519
     *
520
     * @return $this
521
     */
522
    public function setLpItemId($lpItemId)
523
    {
524
        $this->lpItemId = $lpItemId;
525
526
        return $this;
527
    }
528
529
    /**
530
     * Get lpId.
531
     *
532
     * @return int
533
     */
534
    public function getLpItemId()
535
    {
536
        return $this->lpItemId;
537
    }
538
539
    /**
540
     * Get iid.
541
     *
542
     * @return int
543
     */
544
    public function getIid()
545
    {
546
        return $this->iid;
547
    }
548
549
    public function getUser(): User
550
    {
551
        return $this->user;
552
    }
553
554
    public function setUser(User $user): self
555
    {
556
        $this->user = $user;
557
558
        return $this;
559
    }
560
561
    /**
562
     * @return ArrayCollection|CForumPost[]
563
     */
564
    public function getPosts()
565
    {
566
        return $this->posts;
567
    }
568
569
    public function getThreadLastPost(): ?CForumPost
570
    {
571
        return $this->threadLastPost;
572
    }
573
574
    public function setThreadLastPost(CForumPost $threadLastPost): self
575
    {
576
        $this->threadLastPost = $threadLastPost;
577
578
        return $this;
579
    }
580
581
    public function getResourceIdentifier(): int
582
    {
583
        return $this->getIid();
584
    }
585
586
    public function getResourceName(): string
587
    {
588
        return $this->getThreadTitle();
589
    }
590
591
    public function setResourceName(string $name): self
592
    {
593
        return $this->setThreadTitle($name);
594
    }
595
}
596