| @@ 445-488 (lines=44) @@ | ||
| 442 | * @param Session $session The session |
|
| 443 | * @return string |
|
| 444 | */ |
|
| 445 | private function getUserStatusForSession($userId, Session $session) |
|
| 446 | {
|
|
| 447 | if (empty($userId)) {
|
|
| 448 | return 'NO'; |
|
| 449 | } |
|
| 450 | ||
| 451 | $entityManager = Database::getManager(); |
|
| 452 | $scuRepo = $entityManager->getRepository('ChamiloCoreBundle:SessionRelCourseRelUser');
|
|
| 453 | ||
| 454 | $buySaleTable = Database::get_main_table(self::TABLE_SALE); |
|
| 455 | ||
| 456 | // Check if user bought the course |
|
| 457 | $sale = Database::select( |
|
| 458 | 'COUNT(1) as qty', |
|
| 459 | $buySaleTable, |
|
| 460 | [ |
|
| 461 | 'where' => [ |
|
| 462 | 'user_id = ? AND product_type = ? AND product_id = ? AND status = ?' => [ |
|
| 463 | $userId, |
|
| 464 | self::PRODUCT_TYPE_SESSION, |
|
| 465 | $session->getId(), |
|
| 466 | self::SALE_STATUS_PENDING |
|
| 467 | ] |
|
| 468 | ] |
|
| 469 | ], |
|
| 470 | 'first' |
|
| 471 | ); |
|
| 472 | ||
| 473 | if ($sale['qty'] > 0) {
|
|
| 474 | return "TMP"; |
|
| 475 | } |
|
| 476 | ||
| 477 | // Check if user is already subscribe to session |
|
| 478 | $userSubscription = $scuRepo->findBy([ |
|
| 479 | 'session' => $session, |
|
| 480 | 'user' => $userId |
|
| 481 | ]); |
|
| 482 | ||
| 483 | if (!empty($userSubscription)) {
|
|
| 484 | return 'YES'; |
|
| 485 | } |
|
| 486 | ||
| 487 | return 'NO'; |
|
| 488 | } |
|
| 489 | ||
| 490 | /** |
|
| 491 | * Lists current user session details, including each session course details |
|
| @@ 555-598 (lines=44) @@ | ||
| 552 | * |
|
| 553 | * @return string |
|
| 554 | */ |
|
| 555 | private function getUserStatusForCourse($userId, Course $course) |
|
| 556 | {
|
|
| 557 | if (empty($userId)) {
|
|
| 558 | return 'NO'; |
|
| 559 | } |
|
| 560 | ||
| 561 | $entityManager = Database::getManager(); |
|
| 562 | $cuRepo = $entityManager->getRepository('ChamiloCoreBundle:CourseRelUser');
|
|
| 563 | ||
| 564 | $buySaleTable = Database::get_main_table(self::TABLE_SALE); |
|
| 565 | ||
| 566 | // Check if user bought the course |
|
| 567 | $sale = Database::select( |
|
| 568 | 'COUNT(1) as qty', |
|
| 569 | $buySaleTable, |
|
| 570 | [ |
|
| 571 | 'where' => [ |
|
| 572 | 'user_id = ? AND product_type = ? AND product_id = ? AND status = ?' => [ |
|
| 573 | $userId, |
|
| 574 | self::PRODUCT_TYPE_COURSE, |
|
| 575 | $course->getId(), |
|
| 576 | self::SALE_STATUS_PENDING |
|
| 577 | ] |
|
| 578 | ] |
|
| 579 | ], |
|
| 580 | 'first' |
|
| 581 | ); |
|
| 582 | ||
| 583 | if ($sale['qty'] > 0) {
|
|
| 584 | return "TMP"; |
|
| 585 | } |
|
| 586 | ||
| 587 | // Check if user is already subscribe to course |
|
| 588 | $userSubscription = $cuRepo->findBy([ |
|
| 589 | 'course' => $course, |
|
| 590 | 'user' => $userId |
|
| 591 | ]); |
|
| 592 | ||
| 593 | if (!empty($userSubscription)) {
|
|
| 594 | return 'YES'; |
|
| 595 | } |
|
| 596 | ||
| 597 | return 'NO'; |
|
| 598 | } |
|
| 599 | ||
| 600 | /** |
|
| 601 | * Lists current user course details |
|