Completed
Push — master ( 23e37a...6a2455 )
by Julito
13:06 queued 16s
created

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