Passed
Push — master ( ff7940...243d80 )
by Julito
16:14
created

CForumPost::getForumId()   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\Resource\AbstractResource;
8
use Chamilo\CoreBundle\Entity\Resource\ResourceInterface;
9
use Doctrine\ORM\Mapping as ORM;
10
11
/**
12
 * CForumPost.
13
 *
14
 * @ORM\Table(
15
 *  name="c_forum_post",
16
 *  indexes={
17
 *      @ORM\Index(name="course", columns={"c_id"}),
18
 *      @ORM\Index(name="poster_id", columns={"poster_id"}),
19
 *      @ORM\Index(name="forum_id", columns={"forum_id"}),
20
 *      @ORM\Index(name="idx_forum_post_thread_id", columns={"thread_id"}),
21
 *      @ORM\Index(name="idx_forum_post_visible", columns={"visible"}),
22
 *      @ORM\Index(name="c_id_visible_post_date", columns={"c_id", "visible", "post_date"})
23
 *  }
24
 * )
25
 * @ORM\Entity
26
 */
27
class CForumPost extends AbstractResource implements ResourceInterface
28
{
29
    public const STATUS_VALIDATED = 1;
30
    public const STATUS_WAITING_MODERATION = 2;
31
    public const STATUS_REJECTED = 3;
32
33
    /**
34
     * @var int
35
     *
36
     * @ORM\Column(name="iid", type="integer")
37
     * @ORM\Id
38
     * @ORM\GeneratedValue
39
     */
40
    protected $iid;
41
42
    /**
43
     * @var int
44
     *
45
     * @ORM\Column(name="c_id", type="integer")
46
     */
47
    protected $cId;
48
49
    /**
50
     * @var int
51
     *
52
     * @ORM\Column(name="post_id", type="integer")
53
     */
54
    protected $postId;
55
56
    /**
57
     * @var string
58
     *
59
     * @ORM\Column(name="post_title", type="string", length=250, nullable=true)
60
     */
61
    protected $postTitle;
62
63
    /**
64
     * @var string
65
     *
66
     * @ORM\Column(name="post_text", type="text", nullable=true)
67
     */
68
    protected $postText;
69
70
    /**
71
     * @var CForumThread|null
72
     *
73
     * @ORM\ManyToOne(targetEntity="Chamilo\CourseBundle\Entity\CForumThread", inversedBy="posts")
74
     * @ORM\JoinColumn(name="thread_id", referencedColumnName="iid")
75
     */
76
    protected $thread;
77
78
    /**
79
     * @var int
80
     *
81
     * @ORM\Column(name="forum_id", type="integer", nullable=true)
82
     */
83
    protected $forumId;
84
85
    /**
86
     * @var int
87
     *
88
     * @ORM\Column(name="poster_id", type="integer", nullable=true)
89
     */
90
    protected $posterId;
91
92
    /**
93
     * @var string
94
     *
95
     * @ORM\Column(name="poster_name", type="string", length=100, nullable=true)
96
     */
97
    protected $posterName;
98
99
    /**
100
     * @var \DateTime
101
     *
102
     * @ORM\Column(name="post_date", type="datetime", nullable=true)
103
     */
104
    protected $postDate;
105
106
    /**
107
     * @var bool
108
     *
109
     * @ORM\Column(name="post_notification", type="boolean", nullable=true)
110
     */
111
    protected $postNotification;
112
113
    /**
114
     * @var int
115
     *
116
     * @ORM\Column(name="post_parent_id", type="integer", nullable=true)
117
     */
118
    protected $postParentId;
119
120
    /**
121
     * @var bool
122
     *
123
     * @ORM\Column(name="visible", type="boolean", nullable=true)
124
     */
125
    protected $visible;
126
127
    /**
128
     * @var int
129
     *
130
     * @ORM\Column(name="status", type="integer", nullable=true)
131
     */
132
    protected $status;
133
134
    /**
135
     * @var CForumAttachment[]
136
     *
137
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CForumAttachment", mappedBy="post")
138
     */
139
    protected $attachments;
140
141
    public function __construct()
142
    {
143
        $this->postId = 0;
144
    }
145
146
    public function __toString(): string
147
    {
148
        return (string) $this->getPostTitle();
149
    }
150
151
    /**
152
     * Set postTitle.
153
     *
154
     * @param string $postTitle
155
     *
156
     * @return CForumPost
157
     */
158
    public function setPostTitle($postTitle)
159
    {
160
        $this->postTitle = $postTitle;
161
162
        return $this;
163
    }
164
165
    /**
166
     * Get postTitle.
167
     *
168
     * @return string
169
     */
170
    public function getPostTitle()
171
    {
172
        return $this->postTitle;
173
    }
174
175
    /**
176
     * Set postText.
177
     *
178
     * @param string $postText
179
     *
180
     * @return CForumPost
181
     */
182
    public function setPostText($postText)
183
    {
184
        $this->postText = $postText;
185
186
        return $this;
187
    }
188
189
    /**
190
     * Get postText.
191
     *
192
     * @return string
193
     */
194
    public function getPostText()
195
    {
196
        return $this->postText;
197
    }
198
199
    /**
200
     * Set thread.
201
     *
202
     * @return CForumPost
203
     */
204
    public function setThread(CForumThread $thread = null)
205
    {
206
        $this->thread = $thread;
207
208
        return $this;
209
    }
210
211
    /**
212
     * Get thread.
213
     *
214
     * @return CForumThread|null
215
     */
216
    public function getThread()
217
    {
218
        return $this->thread;
219
    }
220
221
    /**
222
     * Set forumId.
223
     *
224
     * @param int $forumId
225
     *
226
     * @return CForumPost
227
     */
228
    public function setForumId($forumId)
229
    {
230
        $this->forumId = $forumId;
231
232
        return $this;
233
    }
234
235
    /**
236
     * Get forumId.
237
     *
238
     * @return int
239
     */
240
    public function getForumId()
241
    {
242
        return $this->forumId;
243
    }
244
245
    /**
246
     * Set posterId.
247
     *
248
     * @param int $posterId
249
     *
250
     * @return CForumPost
251
     */
252
    public function setPosterId($posterId)
253
    {
254
        $this->posterId = $posterId;
255
256
        return $this;
257
    }
258
259
    /**
260
     * Get posterId.
261
     *
262
     * @return int
263
     */
264
    public function getPosterId()
265
    {
266
        return $this->posterId;
267
    }
268
269
    /**
270
     * Set posterName.
271
     *
272
     * @param string $posterName
273
     *
274
     * @return CForumPost
275
     */
276
    public function setPosterName($posterName)
277
    {
278
        $this->posterName = $posterName;
279
280
        return $this;
281
    }
282
283
    /**
284
     * Get posterName.
285
     *
286
     * @return string
287
     */
288
    public function getPosterName()
289
    {
290
        return $this->posterName;
291
    }
292
293
    /**
294
     * Set postDate.
295
     *
296
     * @param \DateTime $postDate
297
     *
298
     * @return CForumPost
299
     */
300
    public function setPostDate($postDate)
301
    {
302
        $this->postDate = $postDate;
303
304
        return $this;
305
    }
306
307
    /**
308
     * Get postDate.
309
     *
310
     * @return \DateTime
311
     */
312
    public function getPostDate()
313
    {
314
        return $this->postDate;
315
    }
316
317
    /**
318
     * Set postNotification.
319
     *
320
     * @param bool $postNotification
321
     *
322
     * @return CForumPost
323
     */
324
    public function setPostNotification($postNotification)
325
    {
326
        $this->postNotification = $postNotification;
327
328
        return $this;
329
    }
330
331
    /**
332
     * Get postNotification.
333
     *
334
     * @return bool
335
     */
336
    public function getPostNotification()
337
    {
338
        return $this->postNotification;
339
    }
340
341
    /**
342
     * Set postParentId.
343
     *
344
     * @param int $postParentId
345
     *
346
     * @return CForumPost
347
     */
348
    public function setPostParentId($postParentId)
349
    {
350
        $this->postParentId = $postParentId;
351
352
        return $this;
353
    }
354
355
    /**
356
     * Get postParentId.
357
     *
358
     * @return int
359
     */
360
    public function getPostParentId()
361
    {
362
        return $this->postParentId;
363
    }
364
365
    /**
366
     * Set visible.
367
     *
368
     * @param bool $visible
369
     *
370
     * @return CForumPost
371
     */
372
    public function setVisible($visible)
373
    {
374
        $this->visible = $visible;
375
376
        return $this;
377
    }
378
379
    /**
380
     * Get visible.
381
     *
382
     * @return bool
383
     */
384
    public function getVisible()
385
    {
386
        return $this->visible;
387
    }
388
389
    /**
390
     * Set postId.
391
     *
392
     * @param int $postId
393
     *
394
     * @return CForumPost
395
     */
396
    public function setPostId($postId)
397
    {
398
        $this->postId = $postId;
399
400
        return $this;
401
    }
402
403
    /**
404
     * Get postId.
405
     *
406
     * @return int
407
     */
408
    public function getPostId()
409
    {
410
        return $this->postId;
411
    }
412
413
    /**
414
     * Set cId.
415
     *
416
     * @param int $cId
417
     *
418
     * @return CForumPost
419
     */
420
    public function setCId($cId)
421
    {
422
        $this->cId = $cId;
423
424
        return $this;
425
    }
426
427
    /**
428
     * Get cId.
429
     *
430
     * @return int
431
     */
432
    public function getCId()
433
    {
434
        return $this->cId;
435
    }
436
437
    /**
438
     * @return int
439
     */
440
    public function getStatus()
441
    {
442
        return $this->status;
443
    }
444
445
    /**
446
     * @param int $status
447
     *
448
     * @return CForumPost
449
     */
450
    public function setStatus($status)
451
    {
452
        $this->status = $status;
453
454
        return $this;
455
    }
456
457
    /**
458
     * Get iid.
459
     *
460
     * @return int
461
     */
462
    public function getIid()
463
    {
464
        return $this->iid;
465
    }
466
467
    /**
468
     * @return CForumAttachment[]
469
     */
470
    public function getAttachments(): array
471
    {
472
        return $this->attachments;
473
    }
474
475
    public function removeAttachment(CForumAttachment $attachment)
476
    {
477
        $this->attachments->removeElement($attachment);
478
    }
479
480
    /**
481
     * Resource identifier.
482
     */
483
    public function getResourceIdentifier(): int
484
    {
485
        return $this->getIid();
486
    }
487
488
    public function getResourceName(): string
489
    {
490
        return $this->getPostTitle();
491
    }
492
}
493