|
@@ 740-745 (lines=6) @@
|
| 737 |
|
|
| 738 |
|
// Check in advance whether the user has already been registered on the platform. |
| 739 |
|
$sql = "SELECT status FROM " . $user_table . " WHERE user_id = $user_id "; |
| 740 |
|
if (Database::num_rows(Database::query($sql)) == 0) { |
| 741 |
|
if ($debug) { |
| 742 |
|
error_log('The user has not been registered to the platform'); |
| 743 |
|
} |
| 744 |
|
return false; // The user has not been registered to the platform. |
| 745 |
|
} |
| 746 |
|
|
| 747 |
|
// Check whether the user has already been subscribed to this course. |
| 748 |
|
$sql = "SELECT * FROM $course_user_table |
|
@@ 753-758 (lines=6) @@
|
| 750 |
|
user_id = $user_id AND |
| 751 |
|
relation_type <> " . COURSE_RELATION_TYPE_RRHH . " AND |
| 752 |
|
c_id = $courseId"; |
| 753 |
|
if (Database::num_rows(Database::query($sql)) > 0) { |
| 754 |
|
if ($debug) { |
| 755 |
|
error_log('The user has been already subscribed to the course'); |
| 756 |
|
} |
| 757 |
|
return false; // The user has been subscribed to the course. |
| 758 |
|
} |
| 759 |
|
|
| 760 |
|
if (!api_is_course_admin()) { |
| 761 |
|
// Check in advance whether subscription is allowed or not for this course. |
|
@@ 764-769 (lines=6) @@
|
| 761 |
|
// Check in advance whether subscription is allowed or not for this course. |
| 762 |
|
$sql = "SELECT code, visibility FROM $course_table |
| 763 |
|
WHERE id = $courseId AND subscribe = '" . SUBSCRIBE_NOT_ALLOWED . "'"; |
| 764 |
|
if (Database::num_rows(Database::query($sql)) > 0) { |
| 765 |
|
if ($debug) { |
| 766 |
|
error_log('Subscription is not allowed for this course'); |
| 767 |
|
} |
| 768 |
|
return false; // Subscription is not allowed for this course. |
| 769 |
|
} |
| 770 |
|
} |
| 771 |
|
|
| 772 |
|
// Ok, subscribe the user. |