Version 15.143.6

This commit is contained in:
Antonio Cañas Vargas 2016-03-03 00:40:23 +01:00
parent fd32898ec7
commit 1d2c540258
5 changed files with 128 additions and 74 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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,"<td class=\"CENTER_MIDDLE %s\">"
"<img src=\"%s/%s16x16.gif\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"</td>",
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,"<td class=\"CENTER_MIDDLE %s\">"
"<img src=\"%s/%s16x16.gif\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"</td>",
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,"<td class=\"DAT CENTER_MIDDLE %s\">"
@ -1269,16 +1270,19 @@ static void Deg_ListDegreeTypesForEdition (void)
fprintf (Gbl.F.Out,"</td>");
/* Direct log in is allowed for this degree type? */
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">");
Act_FormStart (ActChgDegTypLog);
Deg_PutParamOtherDegTypCod (Gbl.Degs.DegTypes.Lst[NumDegTyp].DegTypCod);
fprintf (Gbl.F.Out,"<input type=\"checkbox\" name=\"AllowDirectLogIn\" value=\"Y\"%s"
" onchange=\"document.getElementById('%s').submit();\" />",
Gbl.Degs.DegTypes.Lst[NumDegTyp].AllowDirectLogIn ? " checked=\"checked\"" :
"",
Gbl.Form.Id);
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>");
if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists
{
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">");
Act_FormStart (ActChgDegTypLog);
Deg_PutParamOtherDegTypCod (Gbl.Degs.DegTypes.Lst[NumDegTyp].DegTypCod);
fprintf (Gbl.F.Out,"<input type=\"checkbox\" name=\"AllowDirectLogIn\" value=\"Y\"%s"
" onchange=\"document.getElementById('%s').submit();\" />",
Gbl.Degs.DegTypes.Lst[NumDegTyp].AllowDirectLogIn ? " checked=\"checked\"" :
"",
Gbl.Form.Id);
Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>");
}
/* Number of degrees of this type */
fprintf (Gbl.F.Out,"<td class=\"DAT CENTER_MIDDLE\">"
@ -1706,13 +1710,14 @@ static void Deg_PutFormToCreateDegType (void)
fprintf (Gbl.F.Out,"<tr>"
"<th class=\"CENTER_MIDDLE\">"
"%s"
"</th>"
"<th class=\"CENTER_MIDDLE\">"
"%s"
"</th>"
"</tr>",
Txt_Type_of_BR_degree,
Txt_Direct_authentication);
"</th>",
Txt_Type_of_BR_degree);
if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists
fprintf (Gbl.F.Out,"<th class=\"CENTER_MIDDLE\">"
"%s"
"</th>",
Txt_Direct_authentication);
fprintf (Gbl.F.Out,"</tr>");
/***** Degree type name *****/
fprintf (Gbl.F.Out,"<tr>"
@ -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,"<td class=\"CENTER_MIDDLE\">"
"<input type=\"checkbox\" name=\"AllowDirectLogIn\" value=\"Y\"%s />"
"</td>"
"<td></td>"
"</tr>",
Gbl.Degs.EditingDegTyp.AllowDirectLogIn ? " checked=\"checked\"" :
"");
if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
"<input type=\"checkbox\" name=\"AllowDirectLogIn\" value=\"Y\"%s />"
"</td>"
"<td></td>"
"</tr>",
Gbl.Degs.EditingDegTyp.AllowDirectLogIn ? " checked=\"checked\"" :
"");
/***** Send button and end frame *****/
@ -1880,16 +1886,17 @@ static void Deg_PutHeadDegreeTypesForSeeing (void)
"<th class=\"BM\"></th>"
"<th class=\"CENTER_MIDDLE\">"
"%s"
"</th>"
"<th class=\"CENTER_MIDDLE\">"
"%s"
"</th>"
"<th class=\"RIGHT_MIDDLE\">"
"</th>",
Txt_Type_of_BR_degree);
if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists
fprintf (Gbl.F.Out,"<th class=\"CENTER_MIDDLE\">"
"%s"
"</th>",
Txt_Direct_authentication);
fprintf (Gbl.F.Out,"<th class=\"RIGHT_MIDDLE\">"
"%s"
"</th>"
"</tr>",
Txt_Type_of_BR_degree,
Txt_Direct_authentication,
Txt_Degrees_ABBREVIATION);
}
@ -1911,17 +1918,19 @@ static void Deg_PutHeadDegreeTypesForEdition (void)
"</th>"
"<th class=\"CENTER_MIDDLE\">"
"%s"
"</th>"
"<th class=\"CENTER_MIDDLE\">"
"%s"
"</th>"
"<th class=\"RIGHT_MIDDLE\">"
"</th>",
Txt_Code,
Txt_Type_of_BR_degree);
if (Cfg_EXTERNAL_LOGIN_SERVICE_SHORT_NAME[0]) // If external login service exists
fprintf (Gbl.F.Out,"<th class=\"CENTER_MIDDLE\">"
"%s"
"</th>"
"</tr>",
Txt_Direct_authentication);
fprintf (Gbl.F.Out,"<th class=\"RIGHT_MIDDLE\">"
"%s"
"</th>"
"</tr>",
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'",

View File

@ -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';

View File

@ -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