From 1d2c540258f649bbfa565caf992cd938c927a3b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Thu, 3 Mar 2016 00:40:23 +0100 Subject: [PATCH] Version 15.143.6 --- swad_changelog.h | 3 +- swad_course.c | 28 +++++++-- swad_degree.c | 156 +++++++++++++++++++++++++++++------------------ swad_global.c | 5 +- swad_user.c | 10 +-- 5 files changed, 128 insertions(+), 74 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index e3e46a22f..b59e76c47 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -124,13 +124,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.143.5 (2016-03-02)" +#define Log_PLATFORM_VERSION "SWAD 15.143.6 (2016-03-03)" #define CSS_FILE "swad15.137.2.css" #define JS_FILE "swad15.131.3.js" // 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 15.143.6: Mar 03, 2016 Direct login forms unavailable when external login service unavailable. (196219 lines) Version 15.143.5: Mar 02, 2016 Changed text messages related to edition of courses. (196166 lines) Version 15.143.4: Mar 02, 2016 Changed text messages related to edition of degrees. (196126 lines) Version 15.143.3: Mar 02, 2016 Changed text messages related to edition of centres. (196126 lines) diff --git a/swad_course.c b/swad_course.c index bbc5b8f80..13945af6b 100644 --- a/swad_course.c +++ b/swad_course.c @@ -456,8 +456,13 @@ void Crs_ChangeCourseConfig (void) Gbl.CurrentCrs.Crs.Year = Deg_ConvStrToYear (YearStr); /* Get whether this course allows direct log in or not */ - Par_GetParToText ("AllowDirectLogIn",YN,1); - Gbl.CurrentCrs.Crs.AllowDirectLogIn = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + { + Par_GetParToText ("AllowDirectLogIn",YN,1); + Gbl.CurrentCrs.Crs.AllowDirectLogIn = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + } + else + Gbl.CurrentCrs.Crs.AllowDirectLogIn = true; /***** Update table of degree types *****/ sprintf (Query,"UPDATE courses SET InsCrsCod='%s',Year='%u',AllowDirectLogIn='%c'" @@ -1969,9 +1974,11 @@ static void Crs_CreateCourse (struct Course *Crs,unsigned Status) /***** Insert new course into pending requests *****/ sprintf (Query,"INSERT INTO courses (DegCod,Year,InsCrsCod," "AllowDirectLogIn,Status,RequesterUsrCod,ShortName,FullName)" - " VALUES ('%ld','%u','%s','N','%u','%ld','%s','%s')", + " VALUES ('%ld','%u','%s','%c','%u','%ld','%s','%s')", Crs->DegCod,Crs->Year, Crs->InstitutionalCrsCod, + Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0] ? 'N' : + 'Y', Status, Gbl.Usrs.Me.UsrDat.UsrCod, Crs->ShortName,Crs->FullName); @@ -2044,7 +2051,10 @@ bool Crs_GetDataOfCourseByCod (struct Course *Crs) Crs->CrsCod = -1L; Crs->DegCod = -1L; Crs->Year = 0; - Crs->AllowDirectLogIn = false; + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + Crs->AllowDirectLogIn = false; + else + Crs->AllowDirectLogIn = true; Crs->Status = (Crs_Status_t) 0; Crs->RequesterUsrCod = -1L; Crs->ShortName[0] = '\0'; @@ -2074,7 +2084,10 @@ bool Crs_GetDataOfCourseByCod (struct Course *Crs) Crs->CrsCod = -1L; Crs->DegCod = -1L; Crs->Year = 0; - Crs->AllowDirectLogIn = false; + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + Crs->AllowDirectLogIn = false; + else + Crs->AllowDirectLogIn = true; Crs->Status = (Crs_Status_t) 0; Crs->RequesterUsrCod = -1L; Crs->ShortName[0] = '\0'; @@ -2113,7 +2126,10 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row) Crs->InstitutionalCrsCod[Crs_LENGTH_INSTITUTIONAL_CRS_COD] = '\0'; /***** Get whether this course allows direct log in or not (row[4]) *****/ - Crs->AllowDirectLogIn = (Str_ConvertToUpperLetter (row[4][0]) == 'Y'); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + Crs->AllowDirectLogIn = (Str_ConvertToUpperLetter (row[4][0]) == 'Y'); + else + Crs->AllowDirectLogIn = true; /***** Get course status (row[5]) *****/ if (sscanf (row[5],"%u",&(Crs->Status)) != 1) diff --git a/swad_degree.c b/swad_degree.c index 9eb2da40b..cf9c870e6 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -1190,19 +1190,20 @@ static void Deg_ListDegreeTypesForSeeing (void) BgColor,Gbl.Degs.DegTypes.Lst[NumDegTyp].DegTypName); /* Direct log in is allowed for this degree type? */ - fprintf (Gbl.F.Out,"" - "\"%s\"" - "", - BgColor, - Gbl.Prefs.IconsURL, - Gbl.Degs.DegTypes.Lst[NumDegTyp].AllowDirectLogIn ? "ok_green" : - "tr", - Gbl.Degs.DegTypes.Lst[NumDegTyp].AllowDirectLogIn ? Txt_Direct_authentication_allowed : - Txt_Direct_authentication_not_allowed, - Gbl.Degs.DegTypes.Lst[NumDegTyp].AllowDirectLogIn ? Txt_Direct_authentication_allowed : - Txt_Direct_authentication_not_allowed); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + fprintf (Gbl.F.Out,"" + "\"%s\"" + "", + BgColor, + Gbl.Prefs.IconsURL, + Gbl.Degs.DegTypes.Lst[NumDegTyp].AllowDirectLogIn ? "ok_green" : + "tr", + Gbl.Degs.DegTypes.Lst[NumDegTyp].AllowDirectLogIn ? Txt_Direct_authentication_allowed : + Txt_Direct_authentication_not_allowed, + Gbl.Degs.DegTypes.Lst[NumDegTyp].AllowDirectLogIn ? Txt_Direct_authentication_allowed : + Txt_Direct_authentication_not_allowed); /* Number of degrees of this type */ fprintf (Gbl.F.Out,"" @@ -1269,16 +1270,19 @@ static void Deg_ListDegreeTypesForEdition (void) fprintf (Gbl.F.Out,""); /* Direct log in is allowed for this degree type? */ - fprintf (Gbl.F.Out,""); - Act_FormStart (ActChgDegTypLog); - Deg_PutParamOtherDegTypCod (Gbl.Degs.DegTypes.Lst[NumDegTyp].DegTypCod); - fprintf (Gbl.F.Out,"", - Gbl.Degs.DegTypes.Lst[NumDegTyp].AllowDirectLogIn ? " checked=\"checked\"" : - "", - Gbl.Form.Id); - Act_FormEnd (); - fprintf (Gbl.F.Out,""); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + { + fprintf (Gbl.F.Out,""); + Act_FormStart (ActChgDegTypLog); + Deg_PutParamOtherDegTypCod (Gbl.Degs.DegTypes.Lst[NumDegTyp].DegTypCod); + fprintf (Gbl.F.Out,"", + Gbl.Degs.DegTypes.Lst[NumDegTyp].AllowDirectLogIn ? " checked=\"checked\"" : + "", + Gbl.Form.Id); + Act_FormEnd (); + fprintf (Gbl.F.Out,""); + } /* Number of degrees of this type */ fprintf (Gbl.F.Out,"" @@ -1706,13 +1710,14 @@ static void Deg_PutFormToCreateDegType (void) fprintf (Gbl.F.Out,"" "" "%s" - "" - "" - "%s" - "" - "", - Txt_Type_of_BR_degree, - Txt_Direct_authentication); + "", + Txt_Type_of_BR_degree); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + fprintf (Gbl.F.Out,"" + "%s" + "", + Txt_Direct_authentication); + fprintf (Gbl.F.Out,""); /***** Degree type name *****/ fprintf (Gbl.F.Out,"" @@ -1723,13 +1728,14 @@ static void Deg_PutFormToCreateDegType (void) Deg_MAX_LENGTH_DEGREE_TYPE_NAME,Gbl.Degs.EditingDegTyp.DegTypName); /***** Direct log in is allowed for this degree type? *****/ - fprintf (Gbl.F.Out,"" - "" - "" - "" - "", - Gbl.Degs.EditingDegTyp.AllowDirectLogIn ? " checked=\"checked\"" : - ""); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + fprintf (Gbl.F.Out,"" + "" + "" + "" + "", + Gbl.Degs.EditingDegTyp.AllowDirectLogIn ? " checked=\"checked\"" : + ""); /***** Send button and end frame *****/ @@ -1880,16 +1886,17 @@ static void Deg_PutHeadDegreeTypesForSeeing (void) "" "" "%s" - "" - "" - "%s" - "" - "" + "", + Txt_Type_of_BR_degree); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + fprintf (Gbl.F.Out,"" + "%s" + "", + Txt_Direct_authentication); + fprintf (Gbl.F.Out,"" "%s" "" "", - Txt_Type_of_BR_degree, - Txt_Direct_authentication, Txt_Degrees_ABBREVIATION); } @@ -1911,17 +1918,19 @@ static void Deg_PutHeadDegreeTypesForEdition (void) "" "" "%s" - "" - "" - "%s" - "" - "" + "", + Txt_Code, + Txt_Type_of_BR_degree); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + fprintf (Gbl.F.Out,"" + "%s" + "" + "", + Txt_Direct_authentication); + fprintf (Gbl.F.Out,"" "%s" "" "", - Txt_Code, - Txt_Type_of_BR_degree, - Txt_Direct_authentication, Txt_Degrees_ABBREVIATION); } @@ -2042,6 +2051,9 @@ static void Deg_CreateDegreeType (struct DegreeType *DegTyp) extern const char *Txt_Created_new_type_of_degree_X; char Query[128+Deg_MAX_LENGTH_DEGREE_TYPE_NAME]; + if (!Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service does not exist + DegTyp->AllowDirectLogIn = true; + /***** Create a new degree type *****/ sprintf (Query,"INSERT INTO deg_types" " SET DegTypName='%s',AllowDirectLogIn='%c'", @@ -2218,7 +2230,10 @@ static void Deg_GetListDegTypes (void) Gbl.Degs.DegTypes.Lst[NumRow].DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME] = '\0'; /* Get whether this degree type allows direct log in or not (row[2]) */ - Gbl.Degs.DegTypes.Lst[NumRow].AllowDirectLogIn = (Str_ConvertToUpperLetter (row[2][0]) == 'Y'); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + Gbl.Degs.DegTypes.Lst[NumRow].AllowDirectLogIn = (Str_ConvertToUpperLetter (row[2][0]) == 'Y'); + else + Gbl.Degs.DegTypes.Lst[NumRow].AllowDirectLogIn = true; /* Number of degrees of this type (row[3]) */ if (sscanf (row[3],"%u",&Gbl.Degs.DegTypes.Lst[NumRow].NumDegs) != 1) @@ -2444,8 +2459,13 @@ void Deg_RecFormNewDegTyp (void) Par_GetParToText ("DegTypName",DegTyp->DegTypName,Deg_MAX_LENGTH_DEGREE_TYPE_NAME); /* Get whether this degree type allows direct log in or not */ - Par_GetParToText ("AllowDirectLogIn",YN,1); - DegTyp->AllowDirectLogIn = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + { + Par_GetParToText ("AllowDirectLogIn",YN,1); + DegTyp->AllowDirectLogIn = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + } + else + DegTyp->AllowDirectLogIn = true; if (DegTyp->DegTypName[0]) // If there's a degree type name { @@ -2707,7 +2727,10 @@ bool Deg_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp) { DegTyp->DegTypCod = -1L; DegTyp->DegTypName[0] = '\0'; - DegTyp->AllowDirectLogIn = false; + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + DegTyp->AllowDirectLogIn = false; + else + DegTyp->AllowDirectLogIn = true; DegTyp->NumDegs = 0; return false; } @@ -2727,7 +2750,10 @@ bool Deg_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp) strcpy (DegTyp->DegTypName,row[0]); /* Get whether this degree type allows direct log in or not (row[1]) */ - DegTyp->AllowDirectLogIn = (Str_ConvertToUpperLetter (row[1][0]) == 'Y'); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + DegTyp->AllowDirectLogIn = (Str_ConvertToUpperLetter (row[1][0]) == 'Y'); + else + DegTyp->AllowDirectLogIn = true; /* Count number of degrees of this type */ DegTyp->NumDegs = Deg_CountNumDegsOfType (DegTyp->DegTypCod); @@ -2739,7 +2765,10 @@ bool Deg_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp) { DegTyp->DegTypCod = -1L; DegTyp->DegTypName[0] = '\0'; - DegTyp->AllowDirectLogIn = false; + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + DegTyp->AllowDirectLogIn = false; + else + DegTyp->AllowDirectLogIn = true; DegTyp->NumDegs = 0; return false; } @@ -3331,9 +3360,14 @@ void Deg_ChangeDegTypeLogIn (void) Lay_ShowErrorAndExit ("Code of type of degree not found."); /* Get whether this degree type allows direct log in or not */ - // Do this after getting data of degree type in order to overwrite AllowDirectLogIn with the user preference - Par_GetParToText ("AllowDirectLogIn",YN,1); - DegTyp->AllowDirectLogIn = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + { + // Do this after getting data of degree type in order to overwrite AllowDirectLogIn with the user preference + Par_GetParToText ("AllowDirectLogIn",YN,1); + DegTyp->AllowDirectLogIn = (Str_ConvertToUpperLetter (YN[0]) == 'Y'); + } + else + DegTyp->AllowDirectLogIn = true; /***** Update table of degree types *****/ sprintf (Query,"UPDATE deg_types SET AllowDirectLogIn='%c' WHERE DegTypCod='%ld'", diff --git a/swad_global.c b/swad_global.c index f8c395d59..8e765a7b7 100644 --- a/swad_global.c +++ b/swad_global.c @@ -225,7 +225,10 @@ void Gbl_InitializeGlobals (void) Gbl.CurrentDegTyp.DegTyp.DegTypCod = -1L; Gbl.CurrentDegTyp.DegTyp.DegTypName[0] = '\0'; - Gbl.CurrentDegTyp.DegTyp.AllowDirectLogIn = false; + if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists + Gbl.CurrentDegTyp.DegTyp.AllowDirectLogIn = false; + else + Gbl.CurrentDegTyp.DegTyp.AllowDirectLogIn = true; Gbl.CurrentDeg.Deg.DegCod = -1L; Gbl.CurrentDeg.Deg.ShortName[0] = Gbl.CurrentDeg.Deg.FullName[0] = '\0'; diff --git a/swad_user.c b/swad_user.c index fd0e4859e..6f466f5ee 100644 --- a/swad_user.c +++ b/swad_user.c @@ -2582,10 +2582,10 @@ static void Usr_SetUsrRoleAndPrefs (void) { if (Gbl.Usrs.Me.IBelongToCurrentCrs) { - if (Gbl.Imported.ExternalRole == Rol_UNKNOWN && // I logged in directly, not from external service... - Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT && // ...and I am a student in the current course... - !Gbl.CurrentDegTyp.DegTyp.AllowDirectLogIn && // ...but the current degree type... - !Gbl.CurrentCrs.Crs.AllowDirectLogIn) // ...and the current course do not allow to log in directly + if (Gbl.Imported.ExternalRole == Rol_UNKNOWN && // I logged in directly, not from external service... + Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT && // ...and I am a student in the current course... + !Gbl.CurrentDegTyp.DegTyp.AllowDirectLogIn && // ...but the current degree type... + !Gbl.CurrentCrs.Crs.AllowDirectLogIn) // ...and the current course do not allow to log in directly Gbl.Usrs.Me.AvailableRoles = (1 << Rol_VISITOR); // In this case, my role will be visitor, and an alert will be shown else Gbl.Usrs.Me.AvailableRoles = (1 << Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB); @@ -2635,7 +2635,7 @@ void Usr_WarningWhenDegreeTypeDoesntAllowDirectLogin (void) if (Cfg_EXTERNAL_LOGIN_URL[0] && Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) /* If I belong to current course but my role in current course is visitor, show alert */ if (Gbl.Usrs.Me.IBelongToCurrentCrs && - Gbl.Imported.ExternalRole == Rol_UNKNOWN && // I logged in directly, not from external service... + Gbl.Imported.ExternalRole == Rol_UNKNOWN && // I logged in directly, not from external service... Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT && // ...and I am a student in the current course... !Gbl.CurrentDegTyp.DegTyp.AllowDirectLogIn && // ...but the current degree type... !Gbl.CurrentCrs.Crs.AllowDirectLogIn && // ...and the current course do not allow to log in directly