$sql_session = "SELECT session_id FROM $t_sf sf,$t_sfv sfv WHERE sfv.field_id=sf.id AND field_variable='$original_session_id_name' AND field_value='$original_session_id_value'";
if ($debug) error_log($sql_session);
$res_session = Database::query($sql_session);
$row_session = Database::fetch_row($res_session);
@ -4540,7 +4583,10 @@ function WSSuscribeCoursesToSession($params) {
// Get course list from row_original_course_id_values
$course_list = array();
foreach ($original_course_id_values as $row_original_course_list) {
$sql_course = "SELECT course_code FROM $t_cf cf,$t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$row_original_course_list'";
$sql_course = "SELECT course_code FROM $t_cf cf, $t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$course_code'";
$res_course = Database::query($sql_course);
$row_course = Database::fetch_row($res_course);
if (empty($row_course[0])) {
@ -4577,8 +4623,7 @@ function WSSuscribeCoursesToSession($params) {
$nbr_courses=count($existingCourses);
// get list of users subscribed to this session
$sql="SELECT id_user
FROM $tbl_session_rel_user
$sql= "SELECT id_user FROM $tbl_session_rel_user
WHERE id_session = '$id_session' AND relation_type<>".SESSION_RELATION_TYPE_RRHH."";
$result=Database::query($sql);
$user_list=Database::store_result($result);
@ -4638,7 +4683,6 @@ function WSSuscribeCoursesToSession($params) {
@ -4763,7 +4806,9 @@ function WSUnsuscribeCoursesFromSession($params) {
// Get courses list from row_original_course_id_values
$course_list = array();
foreach ($original_course_id_values as $row_original_course_list) {
$sql_course = "SELECT course_code FROM $t_cf cf,$t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$row_original_course_list'";
$sql_course = "SELECT course_code FROM $t_cf cf,$t_cfv cfv WHERE cfv.field_id=cf.id AND field_variable='$original_course_id_name' AND field_value = '$course_code'";
$res_course = Database::query($sql_course);
$row_course = Database::fetch_row($res_course);
if (empty($row_course[0])) {
@ -4815,7 +4860,6 @@ function WSUnsuscribeCoursesFromSession($params) {