Completed
Push — 1.11.x ( d9fa56...83eb78 )
by José
94:51 queued 50:37
created

Session::setShowDescription()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Entity;
5
6
use Chamilo\UserBundle\Entity\User;
7
use Doctrine\Common\Collections\ArrayCollection;
8
use Doctrine\Common\Collections\Criteria;
9
use Doctrine\ORM\Mapping as ORM;
10
11
//use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
12
//use Gedmo\Mapping\Annotation as Gedmo;
13
14
/**
15
 * Session
16
 * UniqueEntity("name")
17
 * @ORM\Table(
18
 *      name="session",
19
 *      uniqueConstraints={@ORM\UniqueConstraint(name="name", columns={"name"})},
20
 *      indexes={
21
 *          @ORM\Index(name="idx_id_coach", columns={"id_coach"}),
22
 *          @ORM\Index(name="idx_id_session_admin_id", columns={"session_admin_id"})
23
 *      }
24
 * )
25
 * @ORM\Entity(repositoryClass="Chamilo\CoreBundle\Entity\Repository\SessionRepository")
26
 */
27
class Session
28
{
29
    const VISIBLE = 1;
30
    const READ_ONLY = 2;
31
    const INVISIBLE = 3;
32
    const AVAILABLE = 4;
33
34
    const STUDENT = 0;
35
    const DRH = 1;
36
    const COACH = 2;
37
38
    /**
39
     * @var integer
40
     *
41
     * @ORM\Column(name="id", type="integer", nullable=false, unique=false)
42
     * @ORM\Id
43
     * @ORM\GeneratedValue(strategy="AUTO")
44
     */
45
    private $id;
46
47
    /**
48
     * @var string
49
     *
50
     * @ORM\Column(name="name", type="string", length=150, nullable=false, unique=false)
51
     */
52
    private $name;
53
54
    /**
55
     * @var string
56
     *
57
     * @ORM\Column(name="description", type="text", nullable=true, unique=false)
58
     */
59
    private $description;
60
61
    /**
62
     * @var string
63
     *
64
     * @ORM\Column(name="show_description", type="boolean", nullable=true)
65
     */
66
    private $showDescription;
67
68
    /**
69
     * @var integer
70
     *
71
     * @ORM\Column(name="duration", type="integer", nullable=true)
72
     */
73
    private $duration;
74
75
    /**
76
     * @var integer
77
     *
78
     * @ORM\Column(name="nbr_courses", type="smallint", nullable=true, unique=false)
79
     */
80
    private $nbrCourses;
81
82
    /**
83
     * @var integer
84
     *
85
     * @ORM\Column(name="nbr_users", type="integer", nullable=true, unique=false)
86
     */
87
    private $nbrUsers;
88
89
    /**
90
     * @var integer
91
     *
92
     * @ORM\Column(name="nbr_classes", type="integer", nullable=true, unique=false)
93
     */
94
    private $nbrClasses;
95
96
    /**
97
     * @var integer
98
     *
99
     * @ORM\Column(name="session_admin_id", type="integer", nullable=true, unique=false)
100
     */
101
    private $sessionAdminId;
102
103
    /**
104
     * @var integer
105
     *
106
     * @ORM\Column(name="visibility", type="integer", nullable=false, unique=false)
107
     */
108
    private $visibility;
109
110
    /**
111
     * @var integer
112
     *
113
     * @ORM\Column(name="promotion_id", type="integer", nullable=true, unique=false)
114
     */
115
    private $promotionId;
116
117
    /**
118
     * @var \DateTime
119
     *
120
     * @ORM\Column(name="display_start_date", type="datetime", nullable=true, unique=false)
121
     */
122
    private $displayStartDate;
123
124
    /**
125
     * @var \DateTime
126
     *
127
     * @ORM\Column(name="display_end_date", type="datetime", nullable=true, unique=false)
128
     */
129
    private $displayEndDate;
130
131
    /**
132
     * @var \DateTime
133
     *
134
     * @ORM\Column(name="access_start_date", type="datetime", nullable=true, unique=false)
135
     */
136
    private $accessStartDate;
137
138
    /**
139
     * @var \DateTime
140
     *
141
     * @ORM\Column(name="access_end_date", type="datetime", nullable=true, unique=false)
142
     */
143
    private $accessEndDate;
144
145
    /**
146
     * @var \DateTime
147
     *
148
     * @ORM\Column(name="coach_access_start_date", type="datetime", nullable=true, unique=false)
149
     */
150
    private $coachAccessStartDate;
151
152
    /**
153
     * @var \DateTime
154
     *
155
     * @ORM\Column(name="coach_access_end_date", type="datetime", nullable=true, unique=false)
156
     */
157
    private $coachAccessEndDate;
158
159
    /**
160
     * @ORM\OneToMany(targetEntity="Chamilo\CourseBundle\Entity\CItemProperty", mappedBy="session")
161
     **/
162
    //private $items;
163
164
    /**
165
     * @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User", inversedBy="sessionAsGeneralCoach")
166
     * @ORM\JoinColumn(name="id_coach", referencedColumnName="id")
167
     **/
168
    private $generalCoach;
169
170
    /**
171
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\SessionCategory", inversedBy="session")
172
     * @ORM\JoinColumn(name="session_category_id", referencedColumnName="id")
173
     **/
174
    private $category;
175
176
    /**
177
     * @var ArrayCollection
178
     * @ORM\OneToMany(targetEntity="SessionRelCourse", mappedBy="session", cascade={"persist"}, orphanRemoval=true)
179
     **/
180
    protected $courses;
181
182
    /**
183
     * @var ArrayCollection
184
     * @ORM\OneToMany(targetEntity="SessionRelUser", mappedBy="session", cascade={"persist"}, orphanRemoval=true)
185
     **/
186
    protected $users;
187
188
    /**
189
     * @var ArrayCollection
190
     * @ORM\OneToMany(targetEntity="SessionRelCourseRelUser", mappedBy="session", cascade={"persist"}, orphanRemoval=true)
191
     **/
192
    protected $userCourseSubscriptions;
193
194
    /**
195
     * @var Course
196
     **/
197
    protected $currentCourse;
198
199
    /**
200
     * @var boolean
201
     * @ORM\Column(name="send_subscription_notification", type="boolean", nullable=false, options={"default":false})
202
     */
203
    private $sendSubscriptionNotification;
204
205
    /**
206
     * Constructor
207
     */
208
    public function __construct()
209
    {
210
        $this->items = new ArrayCollection();
211
212
        $this->nbrClasses = 0;
213
        $this->nbrUsers = 0;
214
        $this->nbrUsers = 0;
215
216
        $this->displayStartDate = new \DateTime();
217
        $this->displayEndDate = new \DateTime();
218
        $this->accessStartDate = new \DateTime();
219
        $this->accessEndDate = new \DateTime();
220
        $this->coachAccessStartDate = new \DateTime();
221
        $this->coachAccessEndDate = new \DateTime();
222
        $this->visibility = 1;
223
224
        $this->courses = new ArrayCollection();
225
        $this->users = new ArrayCollection();
226
        $this->userCourseSubscriptions = new ArrayCollection();
227
        $this->showDescription = 0;
0 ignored issues
show
Documentation Bug introduced by
The property $showDescription was declared of type string, but 0 is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
228
        $this->category = null;
229
    }
230
231
    /**
232
     * @return int
233
     */
234
    public function getDuration()
235
    {
236
        return $this->duration;
237
    }
238
239
    /**
240
     * @param int $duration
241
     */
242
    public function setDuration($duration)
243
    {
244
        $this->duration = $duration;
245
    }
246
247
    /**
248
     * @return string
249
     */
250
    public function getShowDescription()
251
    {
252
        return $this->showDescription;
253
    }
254
255
    /**
256
     * @param string $showDescription
257
     */
258
    public function setShowDescription($showDescription)
259
    {
260
        $this->showDescription = $showDescription;
261
    }
262
263
    /**
264
     * @return string
265
     */
266
    public function __toString()
267
    {
268
        return (string) $this->getName();
269
    }
270
271
    /**
272
     * Get id
273
     *
274
     * @return integer
275
     */
276
    public function getId()
277
    {
278
        return $this->id;
279
    }
280
281
    /**
282
     * @param int $id
283
     */
284
    public function setId($id)
285
    {
286
        $this->id = $id;
287
    }
288
289
    /**
290
     * @return ArrayCollection
291
     */
292
    public function getUsers()
293
    {
294
        return $this->users;
295
    }
296
297
    /**
298
     * @param $users
299
     */
300
    public function setUsers($users)
301
    {
302
        $this->users = new ArrayCollection();
303
304
        foreach ($users as $user) {
305
            $this->addUser($user);
306
        }
307
    }
308
309
    /**
310
     * @param SessionRelUser $user
311
     */
312
    public function addUser(SessionRelUser $user)
313
    {
314
        $user->setSession($this);
315
316
        if (!$this->hasUser($user)) {
317
            $this->users[] = $user;
318
        }
319
    }
320
321
    /**
322
     * @param int $status
323
     * @param User $user
324
     */
325
    public function addUserInSession($status, User $user)
326
    {
327
        $sessionRelUser = new SessionRelUser();
328
        $sessionRelUser->setSession($this);
329
        $sessionRelUser->setUser($user);
330
        $sessionRelUser->setRelationType($status);
331
332
        $this->addUser($sessionRelUser);
333
    }
334
335
    /**
336
     * @param SessionRelUser $subscription
337
     * @return bool
338
     */
339 View Code Duplication
    public function hasUser(SessionRelUser $subscription)
340
    {
341
        if ($this->getUsers()->count()) {
342
            $criteria = Criteria::create()->where(
343
                Criteria::expr()->eq("user", $subscription->getUser())
344
            )->andWhere(
345
                Criteria::expr()->eq("session", $subscription->getSession())
346
            )->andWhere(
347
                Criteria::expr()->eq("relationType", $subscription->getRelationType())
348
            );
349
350
            $relation = $this->getUsers()->matching($criteria);
351
352
            return $relation->count() > 0;
353
        }
354
355
        return false;
356
    }
357
358
    /**
359
     * @return ArrayCollection
360
     */
361
    public function getCourses()
362
    {
363
        return $this->courses;
364
    }
365
366
    /**
367
     * @param $courses
368
     */
369
    public function setCourses($courses)
370
    {
371
        $this->courses = new ArrayCollection();
372
373
        foreach ($courses as $course) {
374
            $this->addCourses($course);
375
        }
376
    }
377
378
    /**
379
     * @param SessionRelCourse $course
380
     */
381
    public function addCourses(SessionRelCourse $course)
382
    {
383
        $course->setSession($this);
384
        $this->courses[] = $course;
385
    }
386
387
    /**
388
     * @param Course $course
389
     *
390
     * @return bool
391
     */
392
    public function hasCourse(Course $course)
393
    {
394
        if ($this->getCourses()->count()) {
395
            $criteria = Criteria::create()->where(
396
                Criteria::expr()->eq("course", $course)
397
            );
398
            $relation = $this->getCourses()->matching($criteria);
399
400
            return $relation->count() > 0;
401
        }
402
403
        return false;
404
    }
405
406
407
    /**
408
     * Remove $course
409
     *
410
     * @param SessionRelCourse $course
411
     */
412
    public function removeCourses($course)
413
    {
414
        foreach ($this->courses as $key => $value) {
415
            if ($value->getId() == $course->getId()) {
416
                unset($this->courses[$key]);
417
            }
418
        }
419
    }
420
421
    /**
422
     * @param User $user
423
     * @param Course $course
424
     * @param int $status if not set it will check if the user is registered
425
     * with any status
426
     *
427
     * @return bool
428
     */
429
    public function hasUserInCourse(User $user, Course $course, $status = null)
430
    {
431
        $relation = $this->getUserInCourse($user, $course, $status);
432
433
        return $relation->count() > 0;
434
    }
435
436
    /**
437
     * @param User $user
438
     * @param Course $course
439
     *
440
     * @return bool
441
     */
442
    public function hasStudentInCourse(User $user, Course $course)
443
    {
444
        return $this->hasUserInCourse($user, $course, self::STUDENT);
445
    }
446
447
    /**
448
     * @param User $user
449
     * @param Course $course
450
     *
451
     * @return bool
452
     */
453
    public function hasCoachInCourseWithStatus(User $user, Course $course)
454
    {
455
        return $this->hasUserInCourse($user, $course, self::COACH);
456
    }
457
458
    /**
459
     * @param User $user
460
     * @param Course $course
461
     * @param string $status
462
     *
463
     * @return \Doctrine\Common\Collections\Collection|static
464
     */
465
    public function getUserInCourse(User $user, Course $course, $status = null)
466
    {
467
        $criteria = Criteria::create()->where(
468
            Criteria::expr()->eq("course", $course)
469
        )->andWhere(
470
            Criteria::expr()->eq("user", $user)
471
        );
472
473
        if (!is_null($status))  {
474
            $criteria->andWhere(
475
                Criteria::expr()->eq("status", $status)
476
            );
477
        }
478
479
        return $this->getUserCourseSubscriptions()->matching($criteria);
480
    }
481
482
    /**
483
     * Set name
484
     *
485
     * @param string $name
486
     * @return Session
487
     */
488
    public function setName($name)
489
    {
490
        $this->name = $name;
491
492
        return $this;
493
    }
494
495
    /**
496
     * Get name
497
     *
498
     * @return string
499
     */
500
    public function getName()
501
    {
502
        return $this->name;
503
    }
504
505
    /**
506
     * Set description
507
     *
508
     * @param string $description
509
     * @return Groups
510
     */
511
    public function setDescription($description)
512
    {
513
        $this->description = $description;
514
515
        return $this;
516
    }
517
518
    /**
519
     * Get description
520
     *
521
     * @return string
522
     */
523
    public function getDescription()
524
    {
525
        return $this->description;
526
    }
527
528
    /**
529
     * Set nbrCourses
530
     *
531
     * @param integer $nbrCourses
532
     * @return Session
533
     */
534
    public function setNbrCourses($nbrCourses)
535
    {
536
        $this->nbrCourses = $nbrCourses;
537
538
        return $this;
539
    }
540
541
    /**
542
     * Get nbrCourses
543
     *
544
     * @return integer
545
     */
546
    public function getNbrCourses()
547
    {
548
        return $this->nbrCourses;
549
    }
550
551
    /**
552
     * Set nbrUsers
553
     *
554
     * @param integer $nbrUsers
555
     * @return Session
556
     */
557
    public function setNbrUsers($nbrUsers)
558
    {
559
        $this->nbrUsers = $nbrUsers;
560
561
        return $this;
562
    }
563
564
    /**
565
     * Get nbrUsers
566
     *
567
     * @return integer
568
     */
569
    public function getNbrUsers()
570
    {
571
        return $this->nbrUsers;
572
    }
573
574
    /**
575
     * Set nbrClasses
576
     *
577
     * @param integer $nbrClasses
578
     * @return Session
579
     */
580
    public function setNbrClasses($nbrClasses)
581
    {
582
        $this->nbrClasses = $nbrClasses;
583
584
        return $this;
585
    }
586
587
    /**
588
     * Get nbrClasses
589
     *
590
     * @return integer
591
     */
592
    public function getNbrClasses()
593
    {
594
        return $this->nbrClasses;
595
    }
596
597
    /**
598
     * Set sessionAdminId
599
     *
600
     * @param integer $sessionAdminId
601
     * @return Session
602
     */
603
    public function setSessionAdminId($sessionAdminId)
604
    {
605
        $this->sessionAdminId = $sessionAdminId;
606
607
        return $this;
608
    }
609
610
    /**
611
     * Get sessionAdminId
612
     *
613
     * @return integer
614
     */
615
    public function getSessionAdminId()
616
    {
617
        return $this->sessionAdminId;
618
    }
619
620
    /**
621
     * Set visibility
622
     *
623
     * @param integer $visibility
624
     * @return Session
625
     */
626
    public function setVisibility($visibility)
627
    {
628
        $this->visibility = $visibility;
629
630
        return $this;
631
    }
632
633
    /**
634
     * Get visibility
635
     *
636
     * @return integer
637
     */
638
    public function getVisibility()
639
    {
640
        return $this->visibility;
641
    }
642
643
    /**
644
     * Set promotionId
645
     *
646
     * @param integer $promotionId
647
     * @return Session
648
     */
649
    public function setPromotionId($promotionId)
650
    {
651
        $this->promotionId = $promotionId;
652
653
        return $this;
654
    }
655
656
    /**
657
     * Get promotionId
658
     *
659
     * @return integer
660
     */
661
    public function getPromotionId()
662
    {
663
        return $this->promotionId;
664
    }
665
666
    /**
667
     * Set displayStartDate
668
     *
669
     * @param \DateTime $displayStartDate
670
     * @return Session
671
     */
672
    public function setDisplayStartDate($displayStartDate)
673
    {
674
        $this->displayStartDate = $displayStartDate;
675
676
        return $this;
677
    }
678
679
    /**
680
     * Get displayStartDate
681
     *
682
     * @return \DateTime
683
     */
684
    public function getDisplayStartDate()
685
    {
686
        return $this->displayStartDate;
687
    }
688
689
    /**
690
     * Set displayEndDate
691
     *
692
     * @param \DateTime $displayEndDate
693
     * @return Session
694
     */
695
    public function setDisplayEndDate($displayEndDate)
696
    {
697
        $this->displayEndDate = $displayEndDate;
698
699
        return $this;
700
    }
701
702
    /**
703
     * Get displayEndDate
704
     *
705
     * @return \DateTime
706
     */
707
    public function getDisplayEndDate()
708
    {
709
        return $this->displayEndDate;
710
    }
711
712
    /**
713
     * Set accessStartDate
714
     *
715
     * @param \DateTime $accessStartDate
716
     * @return Session
717
     */
718
    public function setAccessStartDate($accessStartDate)
719
    {
720
        $this->accessStartDate = $accessStartDate;
721
722
        return $this;
723
    }
724
725
    /**
726
     * Get accessStartDate
727
     *
728
     * @return \DateTime
729
     */
730
    public function getAccessStartDate()
731
    {
732
        return $this->accessStartDate;
733
    }
734
735
    /**
736
     * Set accessEndDate
737
     *
738
     * @param \DateTime $accessEndDate
739
     * @return Session
740
     */
741
    public function setAccessEndDate($accessEndDate)
742
    {
743
        $this->accessEndDate = $accessEndDate;
744
745
        return $this;
746
    }
747
748
    /**
749
     * Get accessEndDate
750
     *
751
     * @return \DateTime
752
     */
753
    public function getAccessEndDate()
754
    {
755
        return $this->accessEndDate;
756
    }
757
758
    /**
759
     * Set coachAccessStartDate
760
     *
761
     * @param \DateTime $coachAccessStartDate
762
     * @return Session
763
     */
764
    public function setCoachAccessStartDate($coachAccessStartDate)
765
    {
766
        $this->coachAccessStartDate = $coachAccessStartDate;
767
768
        return $this;
769
    }
770
771
    /**
772
     * Get coachAccessStartDate
773
     *
774
     * @return \DateTime
775
     */
776
    public function getCoachAccessStartDate()
777
    {
778
        return $this->coachAccessStartDate;
779
    }
780
781
    /**
782
     * Set coachAccessEndDate
783
     *
784
     * @param \DateTime $coachAccessEndDate
785
     * @return Session
786
     */
787
    public function setCoachAccessEndDate($coachAccessEndDate)
788
    {
789
        $this->coachAccessEndDate = $coachAccessEndDate;
790
791
        return $this;
792
    }
793
794
    /**
795
     * Get coachAccessEndDate
796
     *
797
     * @return \DateTime
798
     */
799
    public function getCoachAccessEndDate()
800
    {
801
        return $this->coachAccessEndDate;
802
    }
803
804
    /**
805
     * Get id
806
     *
807
     * @return integer
808
     */
809
    public function getGeneralCoach()
810
    {
811
        return $this->generalCoach;
812
    }
813
814
    /**
815
     * @param $coach
816
     */
817
    public function setGeneralCoach($coach)
818
    {
819
        $this->generalCoach = $coach;
820
    }
821
822
    /**
823
     * @return mixed
824
     */
825
    public function getCategory()
826
    {
827
        return $this->category;
828
    }
829
830
    /**
831
     * @param $category
832
     * @return $this
833
     */
834
    public function setCategory($category)
835
    {
836
        $this->category = $category;
837
838
        return $this;
839
    }
840
841
    /**
842
     * @return array
843
     */
844
    public static function getStatusList()
845
    {
846
        return array(
847
            self::VISIBLE => 'status_visible',
848
            self::READ_ONLY => 'status_read_only',
849
            self::INVISIBLE => 'status_invisible',
850
            self::AVAILABLE => 'status_available',
851
        );
852
    }
853
854
    /**
855
     * Check if session is visible
856
     * @return bool
857
     */
858
    public function isActive()
859
    {
860
        $now = new \Datetime('now');
861
862
        if ($now > $this->getAccessStartDate()) {
863
864
            return true;
865
        }
866
867
        return false;
868
    }
869
870
    /**
871
     * @param Course $course
872
     */
873
    public function addCourse(Course $course)
874
    {
875
        $entity = new SessionRelCourse();
876
        $entity->setCourse($course);
877
        $this->addCourses($entity);
878
    }
879
880
    /**
881
     * @return ArrayCollection
882
     */
883
    public function getUserCourseSubscriptions()
884
    {
885
        return $this->userCourseSubscriptions;
886
    }
887
888
    /**
889
     * @param ArrayCollection $userCourseSubscriptions
890
     */
891
    public function setUserCourseSubscriptions($userCourseSubscriptions)
892
    {
893
        $this->userCourseSubscriptions = new ArrayCollection();
894
895
        foreach ($userCourseSubscriptions as $item) {
896
            $this->addUserCourseSubscription($item);
897
        }
898
    }
899
900
    /**
901
     * @param SessionRelCourseRelUser $subscription
902
     */
903
    public function addUserCourseSubscription(SessionRelCourseRelUser $subscription)
904
    {
905
        $subscription->setSession($this);
906
        if (!$this->hasUserCourseSubscription($subscription)) {
907
            $this->userCourseSubscriptions[] = $subscription;
908
        }
909
    }
910
911
    /**
912
     * @param int $status
913
     * @param User $user
914
     * @param Course $course
915
     */
916
    public function addUserInCourse($status, User $user, Course $course)
917
    {
918
        $userRelCourseRelSession = new SessionRelCourseRelUser();
919
        $userRelCourseRelSession->setCourse($course);
920
        $userRelCourseRelSession->setUser($user);
921
        $userRelCourseRelSession->setSession($this);
922
        $userRelCourseRelSession->setStatus($status);
923
        $this->addUserCourseSubscription($userRelCourseRelSession);
924
    }
925
926
    /**
927
     * @param SessionRelCourseRelUser $subscription
928
     * @return bool
929
     */
930 View Code Duplication
    public function hasUserCourseSubscription(SessionRelCourseRelUser $subscription)
931
    {
932
        if ($this->getUserCourseSubscriptions()->count()) {
933
            $criteria = Criteria::create()->where(
934
                Criteria::expr()->eq("user", $subscription->getUser())
935
            )->andWhere(
936
                Criteria::expr()->eq("course", $subscription->getCourse())
937
            )->andWhere(
938
                Criteria::expr()->eq("session", $subscription->getSession())
939
            );
940
            $relation = $this->getUserCourseSubscriptions()->matching($criteria);
941
942
            return $relation->count() > 0;
943
        }
944
945
        return false;
946
    }
947
948
    /**
949
     * @return Course
950
     */
951
    public function getCurrentCourse()
952
    {
953
        return $this->currentCourse;
954
    }
955
956
    /**
957
     * @param Course $course
958
     * @return $this
959
     */
960
    public function setCurrentCourse(Course $course)
961
    {
962
        // If the session is registered in the course session list.
963
        if ($this->getCourses()->contains($course->getId())) {
964
            $this->currentCourse = $course;
965
        }
966
        return $this;
967
    }
968
969
    /**
970
     * Set $sendSubscriptionNotification
971
     * @param boolean $sendNotification
972
     * @return \Chamilo\CoreBundle\Entity\Session
973
     */
974
    public function setSendSubscriptionNotification($sendNotification)
975
    {
976
        $this->sendSubscriptionNotification = $sendNotification;
977
978
        return $this;
979
    }
980
981
    /**
982
     * Get $sendSubscriptionNotification
983
     * @return boolean
984
     */
985
    public function getSendSubscriptionNotification()
986
    {
987
        return $this->sendSubscriptionNotification;
988
    }
989
990
    /**
991
     * Get user from course by status
992
     * @param \Chamilo\CoreBundle\Entity\Course $course
993
     * @param string $status
994
     * @return \Doctrine\Common\Collections\Collection|static
995
     */
996
    public function getUserCourseSubscriptionsByStatus(Course $course, $status)
997
    {
998
        $criteria = Criteria::create()
999
            ->where(
1000
                Criteria::expr()->eq("course", $course)
1001
            )
1002
            ->andWhere(
1003
                Criteria::expr()->eq("status", $status)
1004
            );
1005
1006
        return $this->userCourseSubscriptions->matching($criteria);
1007
    }
1008
1009
    public function getBuyCoursePluginPrice()
1010
    {
1011
        // start buycourse validation
1012
        // display the course price and buy button if the buycourses plugin is enabled and this course is configured
1013
        $plugin = \BuyCoursesPlugin::create();
1014
        $isThisCourseInSale = $plugin->buyCoursesForGridCatalogVerificator($this->id, \BuyCoursesPlugin::PRODUCT_TYPE_SESSION);
1015
        $return = [];
1016
1017
        if ($isThisCourseInSale) {
1018
            // set the Price label
1019
            $return['html'] = $isThisCourseInSale['html'];
1020
            // set the Buy button instead register.
1021
            if ($isThisCourseInSale['verificator']) {
1022
                $return['buy_button'] = $plugin->returnBuyCourseButton($this->id, \BuyCoursesPlugin::PRODUCT_TYPE_SESSION);
1023
            }
1024
        }
1025
        // end buycourse validation
1026
        return $return;
1027
    }
1028
1029
}
1030