diff --git a/swad_attendance.c b/swad_attendance.c index d434635c2..1fea800ab 100644 --- a/swad_attendance.c +++ b/swad_attendance.c @@ -3040,7 +3040,9 @@ static void Att_ListStdsAttendanceTable (unsigned NumStdsInList,long *LstSelecte UsrDat.UsrCod = LstSelectedUsrCods[NumStd]; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student { - UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (UsrDat.UsrCod); + UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + true); Att_WriteRowStdSeveralAttEvents (NumStd,&UsrDat); } } @@ -3247,7 +3249,9 @@ static void Att_ListStdsWithAttEventsDetails (unsigned NumStdsInList,long *LstSe UsrDat.UsrCod = LstSelectedUsrCods[NumStd]; if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student { - UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (UsrDat.UsrCod); + UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + true); Att_ListAttEventsForAStd (NumStd,&UsrDat); } } diff --git a/swad_changelog.h b/swad_changelog.h index 51420e6d6..038d74c47 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -98,11 +98,12 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.132.6 (2015/09/17)" +#define Log_PLATFORM_VERSION "SWAD 14.132.7 (2015/09/17)" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* + Version 14.132.7: Sep 17, 2015 Changes in users' IDs. (184706 lines) Version 14.132.6: Sep 17, 2015 Changes in users' IDs. (184640 lines) 12 changes necessary in database: UPDATE actions SET Obsolete='Y' WHERE ActCod='1239'; diff --git a/swad_enrollment.c b/swad_enrollment.c index e2a4129c3..418c4fa32 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -797,7 +797,9 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe) /***** Check if the other user belongs to the current course *****/ if (Gbl.CurrentCrs.Crs.CrsCod > 0) - UsrBelongsToCrs = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false); + UsrBelongsToCrs = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false); if (Gbl.CurrentIns.Ins.InsCod > 0) { @@ -1609,7 +1611,9 @@ static void Enr_RegisterUsr (struct UsrData *UsrDat,Rol_Role_t RegRemRole, /***** Register user in current course in database *****/ if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected { - if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) // User does belong to current course, modify his/her role + if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) // User does belong to current course, modify his/her role Enr_ModifyRoleInCurrentCrs (UsrDat,RegRemRole,Cns_QUIET); else Enr_RegisterUsrInCurrentCrs (UsrDat,RegRemRole,Cns_QUIET, @@ -1982,7 +1986,9 @@ void Enr_AskIfRejectSignUp (void) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // If user's data exist... { - if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) + if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) { /* User already belongs to this course */ sprintf (Gbl.Message,Txt_THE_USER_X_is_already_enrolled_in_the_course_Y, @@ -2037,7 +2043,9 @@ void Enr_RejectSignUp (void) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // If user's data exist... { - if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) + if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) { /* User already belongs to this course */ sprintf (Gbl.Message,Txt_THE_USER_X_is_already_enrolled_in_the_course_Y, @@ -2406,7 +2414,9 @@ void Enr_ShowEnrollmentRequests (void) DesiredRole = Rol_ConvertUnsignedStrToRole (row[3]); if (UsrExists) - UsrBelongsToCrs = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,Crs.CrsCod,false); + UsrBelongsToCrs = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod, + Crs.CrsCod, + false); else UsrBelongsToCrs = false; @@ -2751,9 +2761,13 @@ static void Enr_AskIfRegRemUsr (struct ListUsrCods *ListUsrCods,Rol_Role_t Role) if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected { /* Check if this user belongs to the current course */ - if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) + if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) { - Gbl.Usrs.Other.UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (Gbl.Usrs.Other.UsrDat.UsrCod); + Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + true); if (Gbl.Usrs.Other.UsrDat.Accepted) sprintf (Gbl.Message,Txt_THE_USER_X_is_already_enrolled_in_the_course_Y, Gbl.Usrs.Other.UsrDat.FullName,Gbl.CurrentCrs.Crs.FullName); @@ -3218,7 +3232,9 @@ void Enr_CreateNewUsr (void) /***** Register user in current course in database *****/ if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected { - if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) // User does belong to current course, modify his/her role + if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) // User does belong to current course, modify his/her role Enr_ModifyRoleInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole,Cns_VERBOSE); else Enr_RegisterUsrInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole,Cns_VERBOSE, @@ -3282,7 +3298,9 @@ void Enr_ModifyUsr (void) NewRole = Rec_GetRoleFromRecordForm (); /***** Register user in current course in database *****/ - if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) // User does belong to current course, modify his/her role + if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) // User does belong to current course, modify his/her role Enr_ModifyRoleInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole,Cns_VERBOSE); else Enr_RegisterUsrInCurrentCrs (&Gbl.Usrs.Other.UsrDat,NewRole,Cns_VERBOSE, @@ -3398,7 +3416,9 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat,bool ItsMe) extern const char *Txt_Remove_user_from_this_course; extern const char *Txt_User_not_found_or_you_do_not_have_permission_; - if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) + if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) { sprintf (Gbl.Message, ItsMe ? Txt_Do_you_really_want_to_be_removed_from_the_course_X : @@ -3432,7 +3452,9 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course * extern const char *Txt_User_not_found_or_you_do_not_have_permission_; char Query[1024]; - if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod,Crs->CrsCod,false)) // User belongs to the course + if (Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod, + Crs->CrsCod, + false)) // User belongs to the course { /***** Remove user from all the attendance events in course *****/ Att_RemoveUsrFromCrsAttEvents (UsrDat->UsrCod,Crs->CrsCod); diff --git a/swad_file_browser.c b/swad_file_browser.c index c162591f2..acaa6b902 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -2938,7 +2938,9 @@ static void Brw_ShowFileBrowsersAsgWrkCrs (void) Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat); if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get user's data from database - if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) + if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) ZIP_CreateDirCompressionUsr (&UsrDat); } @@ -2967,7 +2969,9 @@ static void Brw_ShowFileBrowsersAsgWrkCrs (void) Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat); if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get of the database the data of the user - if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) + if (Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) { /***** Show a row with the data of the owner of the works *****/ fprintf (Gbl.F.Out,""); diff --git a/swad_photo.c b/swad_photo.c index e2bed7071..0840a5406 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -135,19 +135,27 @@ bool Pho_CheckIfICanChangeOtherUsrPhoto (const struct UsrData *UsrDat) case Rol_TEACHER: /* If I am a teacher in current course, I only can change the photo of users from current course */ - return UsrDat->Accepted; + return Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + true); case Rol_DEG_ADM: /* If I am an administrator of current degree, I only can change the photo of users from current degree */ - return Usr_CheckIfUsrBelongsToDeg (UsrDat->UsrCod,Gbl.CurrentDeg.Deg.DegCod,true); + return Usr_CheckIfUsrBelongsToDeg (UsrDat->UsrCod, + Gbl.CurrentDeg.Deg.DegCod, + true); case Rol_CTR_ADM: /* If I am an administrator of current centre, I only can change the photo of users from current centre */ - return Usr_CheckIfUsrBelongsToCtr (UsrDat->UsrCod,Gbl.CurrentCtr.Ctr.CtrCod,true); + return Usr_CheckIfUsrBelongsToCtr (UsrDat->UsrCod, + Gbl.CurrentCtr.Ctr.CtrCod, + true); case Rol_INS_ADM: /* If I am an administrator of current institution, I only can change the photo of users from current institution */ - return Usr_CheckIfUsrBelongsToIns (UsrDat->UsrCod,Gbl.CurrentIns.Ins.InsCod,true); + return Usr_CheckIfUsrBelongsToIns (UsrDat->UsrCod, + Gbl.CurrentIns.Ins.InsCod, + true); case Rol_SYS_ADM: return true; default: @@ -337,7 +345,9 @@ void Pho_SendPhotoUsr (void) { if (Pho_CheckIfICanChangeOtherUsrPhoto (&Gbl.Usrs.Other.UsrDat)) // If I have permission to change user's photo... { - Gbl.Usrs.Other.UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (Gbl.Usrs.Other.UsrDat.UsrCod); + Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + true); Pho_ReqUsrPhoto (&Gbl.Usrs.Other.UsrDat); // Request user's photograph } else diff --git a/swad_profile.c b/swad_profile.c index cbe50b8b1..d837ff32d 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -222,7 +222,9 @@ bool Prf_ShowUserProfile (void) Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB = Rol_GetRoleInCrs (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Usrs.Other.UsrDat.UsrCod); /* Get if user has accepted enrollment in current course */ - Gbl.Usrs.Other.UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (Gbl.Usrs.Other.UsrDat.UsrCod); + Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + true); } fprintf (Gbl.F.Out,"" diff --git a/swad_record.c b/swad_record.c index 8257aa5d1..5fbdce1d5 100644 --- a/swad_record.c +++ b/swad_record.c @@ -966,7 +966,9 @@ static void Rec_ShowRecordOneStdCrs (void) bool ItsMe; /***** Get if student has accepted enrollment in current course *****/ - Gbl.Usrs.Other.UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (Gbl.Usrs.Other.UsrDat.UsrCod); + Gbl.Usrs.Other.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Other.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + true); /***** Asign users listing type depending on current action *****/ Gbl.Usrs.Listing.RecsUsrs = Rec_RECORD_USERS_STUDENTS; @@ -1071,9 +1073,13 @@ void Rec_ListRecordsStdsCrs (void) Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDat.EncryptedUsrCod,Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); Usr_GetUsrCodFromEncryptedUsrCod (&UsrDat); if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat)) // Get from the database the data of the student - if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) + if (Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) { - UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (UsrDat.UsrCod); + UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + true); fprintf (Gbl.F.Out,"
Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (UsrDat->UsrCod); + UsrDat->Accepted = Usr_CheckIfUsrBelongsToCrs (UsrDat->UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + true); /***** Show user's record *****/ fprintf (Gbl.F.Out,"
"); @@ -2224,9 +2239,8 @@ void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView, (Gbl.CurrentIns.Ins.InsCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_INS_ADM) || Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM) { - Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ? ActReqMdfStd : - (UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ActReqMdfTch : - ActReqMdfGst)); + Act_FormStart (UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ActReqMdfTch : + ActReqMdfStd); Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); Act_LinkFormSubmit (Txt_Admin_user,NULL); fprintf (Gbl.F.Out,"
RoleInCurrentCrsDB == Rol_UNKNOWN) UsrDat->RoleInCurrentCrsDB = (UsrDat->Roles < (1 << Rol_STUDENT)) ? Rol__GUEST_ : // User does not belong to any course - Rol_VISITOR; // User belongs to some courses + Rol_VISITOR; // User belongs to some courses /* Get name */ strncpy (UsrDat->Surname1 ,row[2],sizeof (UsrDat->Surname1 ) - 1); @@ -1013,11 +1013,18 @@ void Usr_GetMyCourses (void) /**************** Check if a user belongs to an institution ******************/ /*****************************************************************************/ -bool Usr_CheckIfUsrBelongsToIns (long UsrCod,long InsCod,bool CountOnlyAcceptedCourses) +bool Usr_CheckIfUsrBelongsToIns (long UsrCod, + long InsCod, + bool CountOnlyAcceptedCourses) { char Query[512]; const char *SubQuery; + /***** Trivial case *****/ + if (UsrCod <= 0 || + InsCod <= 0) + return false; + /***** Get is a user belongs to an institution from database *****/ SubQuery = (CountOnlyAcceptedCourses ? " AND crs_usr.Accepted='Y'" : ""); @@ -1036,11 +1043,18 @@ bool Usr_CheckIfUsrBelongsToIns (long UsrCod,long InsCod,bool CountOnlyAcceptedC /******************* Check if a user belongs to a centre *********************/ /*****************************************************************************/ -bool Usr_CheckIfUsrBelongsToCtr (long UsrCod,long CtrCod,bool CountOnlyAcceptedCourses) +bool Usr_CheckIfUsrBelongsToCtr (long UsrCod, + long CtrCod, + bool CountOnlyAcceptedCourses) { char Query[512]; const char *SubQuery; + /***** Trivial case *****/ + if (UsrCod <= 0 || + CtrCod <= 0) + return false; + /***** Get is a user belongs to a centre from database *****/ SubQuery = (CountOnlyAcceptedCourses ? " AND crs_usr.Accepted='Y'" : ""); @@ -1058,11 +1072,18 @@ bool Usr_CheckIfUsrBelongsToCtr (long UsrCod,long CtrCod,bool CountOnlyAcceptedC /******************* Check if a user belongs to a degree *********************/ /*****************************************************************************/ -bool Usr_CheckIfUsrBelongsToDeg (long UsrCod,long DegCod,bool CountOnlyAcceptedCourses) +bool Usr_CheckIfUsrBelongsToDeg (long UsrCod, + long DegCod, + bool CountOnlyAcceptedCourses) { char Query[512]; const char *SubQuery; + /***** Trivial case *****/ + if (UsrCod <= 0 || + DegCod <= 0) + return false; + /***** Get is a user belongs to a degree from database *****/ SubQuery = (CountOnlyAcceptedCourses ? " AND crs_usr.Accepted='Y'" : ""); @@ -1079,12 +1100,14 @@ bool Usr_CheckIfUsrBelongsToDeg (long UsrCod,long DegCod,bool CountOnlyAcceptedC /******************** Check if a user belongs to a course ********************/ /*****************************************************************************/ -bool Usr_CheckIfUsrBelongsToCrs (long UsrCod,long CrsCod,bool CountOnlyAcceptedCourses) +bool Usr_CheckIfUsrBelongsToCrs (long UsrCod, + long CrsCod, + bool CountOnlyAcceptedCourses) { char Query[512]; const char *SubQuery; - /***** If user code or course code not valid... *****/ + /***** Trivial case *****/ if (UsrCod <= 0 || CrsCod <= 0) return false; @@ -2394,7 +2417,11 @@ static void Usr_SetUsrRoleAndPrefs (void) else Gbl.Usrs.Me.IBelongToCurrentCrs = false; if (Gbl.Usrs.Me.IBelongToCurrentCrs) - Gbl.Usrs.Me.UsrDat.Accepted = Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (Gbl.Usrs.Me.UsrDat.UsrCod); + Gbl.Usrs.Me.UsrDat.Accepted = Usr_CheckIfUsrBelongsToCrs (Gbl.Usrs.Me.UsrDat.UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + true); + else + Gbl.Usrs.Me.UsrDat.Accepted = false; /***** Check if I belong to current degree *****/ if (Gbl.CurrentDeg.Deg.DegCod > 0) @@ -2560,36 +2587,6 @@ bool Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (struct UsrData *UsrDat) return false; } -/*****************************************************************************/ -/********* Get if a user has accepted to belong to current course ************/ -/*****************************************************************************/ - -bool Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (long UsrCod) - { - char Query[128]; - MYSQL_RES *mysql_res; - MYSQL_ROW row; - bool Accepted = false; - - /***** Get if a user has accepted belonging to current course *****/ - sprintf (Query,"SELECT Accepted FROM crs_usr" - " WHERE CrsCod='%ld' AND UsrCod='%ld'", - Gbl.CurrentCrs.Crs.CrsCod,UsrCod); - if (DB_QuerySELECT (Query,&mysql_res, - "can not check if a user has accepted" - " the enrollment in the current course") == 1) - { - /* Get if accepted */ - row = mysql_fetch_row (mysql_res); - Accepted = (Str_ConvertToUpperLetter (row[0][0]) == 'Y'); - } - - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - - return Accepted; - } - /*****************************************************************************/ /********* Update my last accessed course, tab and time in database **********/ /*****************************************************************************/ diff --git a/swad_user.h b/swad_user.h index 2c56d1931..fa3c27040 100644 --- a/swad_user.h +++ b/swad_user.h @@ -220,10 +220,18 @@ void Usr_GetMyInstitutions (void); void Usr_GetMyCentres (void); void Usr_GetMyDegrees (void); void Usr_GetMyCourses (void); -bool Usr_CheckIfUsrBelongsToIns (long UsrCod,long InsCod,bool CountOnlyAcceptedCourses); -bool Usr_CheckIfUsrBelongsToCtr (long UsrCod,long CtrCod,bool CountOnlyAcceptedCourses); -bool Usr_CheckIfUsrBelongsToDeg (long UsrCod,long DegCod,bool CountOnlyAcceptedCourses); -bool Usr_CheckIfUsrBelongsToCrs (long UsrCod,long CrsCod,bool CountOnlyAcceptedCourses); +bool Usr_CheckIfUsrBelongsToIns (long UsrCod, + long InsCod, + bool CountOnlyAcceptedCourses); +bool Usr_CheckIfUsrBelongsToCtr (long UsrCod, + long CtrCod, + bool CountOnlyAcceptedCourses); +bool Usr_CheckIfUsrBelongsToDeg (long UsrCod, + long DegCod, + bool CountOnlyAcceptedCourses); +bool Usr_CheckIfUsrBelongsToCrs (long UsrCod, + long CrsCod, + bool CountOnlyAcceptedCourses); bool Usr_CheckIfIBelongToIns (long InsCod); bool Usr_CheckIfIBelongToCtr (long CtrCod); bool Usr_CheckIfIBelongToDeg (long DegCod); @@ -257,7 +265,6 @@ void Usr_WarningWhenDegreeTypeDoesntAllowDirectLogin (void); void Usr_ShowFormsLogoutAndRole (void); bool Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (struct UsrData *UsrDat); -bool Usr_GetIfUserHasAcceptedEnrollmentInCurrentCrs (long UsrCod); void Usr_UpdateMyLastData (void); void Usr_InsertMyLastCrsTabAndTime (void); diff --git a/swad_web_service.c b/swad_web_service.c index e1704a52a..cbe9060da 100644 --- a/swad_web_service.c +++ b/swad_web_service.c @@ -2459,7 +2459,9 @@ int swad__sendAttendanceUsers (struct soap *soap, if (Usr_ChkIfUsrCodExists (UsrCod)) // The user must belong to course, // but it's not necessary he/she belongs to groups associated to the event - if (Usr_CheckIfUsrBelongsToCrs (UsrCod,Gbl.CurrentCrs.Crs.CrsCod,false)) + if (Usr_CheckIfUsrBelongsToCrs (UsrCod, + Gbl.CurrentCrs.Crs.CrsCod, + false)) { /* Mark user as present */ Att_RegUsrInAttEventNotChangingComments (Att.AttCod,UsrCod);