| @@ 365-408 (lines=44) @@ | ||
| 362 | * @param \Chamilo\CoreBundle\Entity\Session $session The session |
|
| 363 | * @return string |
|
| 364 | */ |
|
| 365 | private function getUserStatusForSession($userId, \Chamilo\CoreBundle\Entity\Session $session) |
|
| 366 | {
|
|
| 367 | if (empty($userId)) {
|
|
| 368 | return 'NO'; |
|
| 369 | } |
|
| 370 | ||
| 371 | $entityManager = Database::getManager(); |
|
| 372 | $scuRepo = $entityManager->getRepository('ChamiloCoreBundle:SessionRelCourseRelUser');
|
|
| 373 | ||
| 374 | $buySaleTable = Database::get_main_table(self::TABLE_SALE); |
|
| 375 | ||
| 376 | // Check if user bought the course |
|
| 377 | $sale = Database::select( |
|
| 378 | 'COUNT(1) as qty', |
|
| 379 | $buySaleTable, |
|
| 380 | [ |
|
| 381 | 'where' => [ |
|
| 382 | 'user_id = ? AND product_type = ? AND product_id = ? AND status = ?' => [ |
|
| 383 | $userId, |
|
| 384 | self::PRODUCT_TYPE_SESSION, |
|
| 385 | $session->getId(), |
|
| 386 | self::SALE_STATUS_PENDING |
|
| 387 | ] |
|
| 388 | ] |
|
| 389 | ], |
|
| 390 | 'first' |
|
| 391 | ); |
|
| 392 | ||
| 393 | if ($sale['qty'] > 0) {
|
|
| 394 | return "TMP"; |
|
| 395 | } |
|
| 396 | ||
| 397 | // Check if user is already subscribe to session |
|
| 398 | $userSubscription = $scuRepo->findBy([ |
|
| 399 | 'session' => $session, |
|
| 400 | 'user' => $userId |
|
| 401 | ]); |
|
| 402 | ||
| 403 | if (!empty($userSubscription)) {
|
|
| 404 | return 'YES'; |
|
| 405 | } |
|
| 406 | ||
| 407 | return 'NO'; |
|
| 408 | } |
|
| 409 | ||
| 410 | /** |
|
| 411 | * Lists current user session details, including each session course details |
|
| @@ 474-517 (lines=44) @@ | ||
| 471 | * @param \Chamilo\CoreBundle\Entity\Course $course The course |
|
| 472 | * @return string |
|
| 473 | */ |
|
| 474 | private function getUserStatusForCourse($userId, \Chamilo\CoreBundle\Entity\Course $course) |
|
| 475 | {
|
|
| 476 | if (empty($userId)) {
|
|
| 477 | return 'NO'; |
|
| 478 | } |
|
| 479 | ||
| 480 | $entityManager = Database::getManager(); |
|
| 481 | $cuRepo = $entityManager->getRepository('ChamiloCoreBundle:CourseRelUser');
|
|
| 482 | ||
| 483 | $buySaleTable = Database::get_main_table(self::TABLE_SALE); |
|
| 484 | ||
| 485 | // Check if user bought the course |
|
| 486 | $sale = Database::select( |
|
| 487 | 'COUNT(1) as qty', |
|
| 488 | $buySaleTable, |
|
| 489 | [ |
|
| 490 | 'where' => [ |
|
| 491 | 'user_id = ? AND product_type = ? AND product_id = ? AND status = ?' => [ |
|
| 492 | $userId, |
|
| 493 | self::PRODUCT_TYPE_COURSE, |
|
| 494 | $course->getId(), |
|
| 495 | self::SALE_STATUS_PENDING |
|
| 496 | ] |
|
| 497 | ] |
|
| 498 | ], |
|
| 499 | 'first' |
|
| 500 | ); |
|
| 501 | ||
| 502 | if ($sale['qty'] > 0) {
|
|
| 503 | return "TMP"; |
|
| 504 | } |
|
| 505 | ||
| 506 | // Check if user is already subscribe to course |
|
| 507 | $userSubscription = $cuRepo->findBy([ |
|
| 508 | 'course' => $course, |
|
| 509 | 'user' => $userId |
|
| 510 | ]); |
|
| 511 | ||
| 512 | if (!empty($userSubscription)) {
|
|
| 513 | return 'YES'; |
|
| 514 | } |
|
| 515 | ||
| 516 | return 'NO'; |
|
| 517 | } |
|
| 518 | ||
| 519 | /** |
|
| 520 | * Lists current user course details |
|