Passed
Push — master ( 708b46...c08ace )
by Julito
09:46
created

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