",
- 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,"
"
"",
- 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