@@ 421-464 (lines=44) @@ | ||
418 | * @param Session $session The session |
|
419 | * @return string |
|
420 | */ |
|
421 | private function getUserStatusForSession($userId, Session $session) |
|
422 | { |
|
423 | if (empty($userId)) { |
|
424 | return 'NO'; |
|
425 | } |
|
426 | ||
427 | $entityManager = Database::getManager(); |
|
428 | $scuRepo = $entityManager->getRepository('ChamiloCoreBundle:SessionRelCourseRelUser'); |
|
429 | ||
430 | $buySaleTable = Database::get_main_table(self::TABLE_SALE); |
|
431 | ||
432 | // Check if user bought the course |
|
433 | $sale = Database::select( |
|
434 | 'COUNT(1) as qty', |
|
435 | $buySaleTable, |
|
436 | [ |
|
437 | 'where' => [ |
|
438 | 'user_id = ? AND product_type = ? AND product_id = ? AND status = ?' => [ |
|
439 | $userId, |
|
440 | self::PRODUCT_TYPE_SESSION, |
|
441 | $session->getId(), |
|
442 | self::SALE_STATUS_PENDING |
|
443 | ] |
|
444 | ] |
|
445 | ], |
|
446 | 'first' |
|
447 | ); |
|
448 | ||
449 | if ($sale['qty'] > 0) { |
|
450 | return "TMP"; |
|
451 | } |
|
452 | ||
453 | // Check if user is already subscribe to session |
|
454 | $userSubscription = $scuRepo->findBy([ |
|
455 | 'session' => $session, |
|
456 | 'user' => $userId |
|
457 | ]); |
|
458 | ||
459 | if (!empty($userSubscription)) { |
|
460 | return 'YES'; |
|
461 | } |
|
462 | ||
463 | return 'NO'; |
|
464 | } |
|
465 | ||
466 | /** |
|
467 | * Lists current user session details, including each session course details |
|
@@ 531-574 (lines=44) @@ | ||
528 | * |
|
529 | * @return string |
|
530 | */ |
|
531 | private function getUserStatusForCourse($userId, Course $course) |
|
532 | { |
|
533 | if (empty($userId)) { |
|
534 | ||
535 | return 'NO'; |
|
536 | } |
|
537 | ||
538 | $entityManager = Database::getManager(); |
|
539 | $cuRepo = $entityManager->getRepository('ChamiloCoreBundle:CourseRelUser'); |
|
540 | ||
541 | $buySaleTable = Database::get_main_table(self::TABLE_SALE); |
|
542 | ||
543 | // Check if user bought the course |
|
544 | $sale = Database::select( |
|
545 | 'COUNT(1) as qty', |
|
546 | $buySaleTable, |
|
547 | [ |
|
548 | 'where' => [ |
|
549 | 'user_id = ? AND product_type = ? AND product_id = ? AND status = ?' => [ |
|
550 | $userId, |
|
551 | self::PRODUCT_TYPE_COURSE, |
|
552 | $course->getId(), |
|
553 | self::SALE_STATUS_PENDING |
|
554 | ] |
|
555 | ] |
|
556 | ], |
|
557 | 'first' |
|
558 | ); |
|
559 | ||
560 | if ($sale['qty'] > 0) { |
|
561 | return "TMP"; |
|
562 | } |
|
563 | ||
564 | // Check if user is already subscribe to course |
|
565 | $userSubscription = $cuRepo->findBy([ |
|
566 | 'course' => $course, |
|
567 | 'user' => $userId |
|
568 | ]); |
|
569 | ||
570 | if (!empty($userSubscription)) { |
|
571 | return 'YES'; |
|
572 | } |
|
573 | ||
574 | return 'NO'; |
|
575 | } |
|
576 | ||
577 | /** |