|
@@ 761-766 (lines=6) @@
|
| 758 |
|
|
| 759 |
|
// Check in advance whether the user has already been registered on the platform. |
| 760 |
|
$sql = "SELECT status FROM " . $user_table . " WHERE user_id = $user_id "; |
| 761 |
|
if (Database::num_rows(Database::query($sql)) == 0) { |
| 762 |
|
if ($debug) { |
| 763 |
|
error_log('The user has not been registered to the platform'); |
| 764 |
|
} |
| 765 |
|
return false; // The user has not been registered to the platform. |
| 766 |
|
} |
| 767 |
|
|
| 768 |
|
// Check whether the user has already been subscribed to this course. |
| 769 |
|
$sql = "SELECT * FROM $course_user_table |
|
@@ 774-779 (lines=6) @@
|
| 771 |
|
user_id = $user_id AND |
| 772 |
|
relation_type <> " . COURSE_RELATION_TYPE_RRHH . " AND |
| 773 |
|
c_id = $courseId"; |
| 774 |
|
if (Database::num_rows(Database::query($sql)) > 0) { |
| 775 |
|
if ($debug) { |
| 776 |
|
error_log('The user has been already subscribed to the course'); |
| 777 |
|
} |
| 778 |
|
return false; // The user has been subscribed to the course. |
| 779 |
|
} |
| 780 |
|
|
| 781 |
|
if (!api_is_course_admin()) { |
| 782 |
|
// Check in advance whether subscription is allowed or not for this course. |
|
@@ 785-790 (lines=6) @@
|
| 782 |
|
// Check in advance whether subscription is allowed or not for this course. |
| 783 |
|
$sql = "SELECT code, visibility FROM $course_table |
| 784 |
|
WHERE id = $courseId AND subscribe = '" . SUBSCRIBE_NOT_ALLOWED . "'"; |
| 785 |
|
if (Database::num_rows(Database::query($sql)) > 0) { |
| 786 |
|
if ($debug) { |
| 787 |
|
error_log('Subscription is not allowed for this course'); |
| 788 |
|
} |
| 789 |
|
return false; // Subscription is not allowed for this course. |
| 790 |
|
} |
| 791 |
|
} |
| 792 |
|
|
| 793 |
|
// Ok, subscribe the user. |