Version 15.240.4

This commit is contained in:
Antonio Cañas Vargas 2016-07-04 10:26:44 +02:00
parent 20522920f4
commit e2e4d25001
2 changed files with 42 additions and 33 deletions

View File

@ -138,13 +138,14 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.240.3 (2016-07-04)" #define Log_PLATFORM_VERSION "SWAD 15.240.4 (2016-07-04)"
#define CSS_FILE "swad15.229.css" #define CSS_FILE "swad15.229.css"
#define JS_FILE "swad15.238.1.js" #define JS_FILE "swad15.238.1.js"
// Number of lines (includes comments but not blank lines) has been got with the following command: // 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 // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
/* /*
Version 15.240.4: Jul 04, 2015 Fixed bugs in web service, reported by Rubén Martín Hidalgo. (203589 lines)
Version 15.240.3: Jul 04, 2015 N.A. year is shown at foot in edition of courses. (? lines) Version 15.240.3: Jul 04, 2015 N.A. year is shown at foot in edition of courses. (? lines)
Version 15.240.2: Jul 02, 2015 Fixed bug in edition of courses. (203548 lines) Version 15.240.2: Jul 02, 2015 Fixed bug in edition of courses. (203548 lines)
Version 15.240.1: Jul 02, 2015 Fixed bug in web service. (203539 lines) Version 15.240.1: Jul 02, 2015 Fixed bug in web service. (203539 lines)

View File

@ -156,6 +156,36 @@ static const char *Svc_Functions[1+Svc_NUM_FUNCTIONS] =
"findUsers", // 25 "findUsers", // 25
}; };
#define Svc_NUM_ROLES 4
typedef enum
{
Svc_ROLE_UNKNOWN = 0, // User not logged in
Svc_ROLE__GUEST_ = 1, // User not belonging to any course
Svc_ROLE_STUDENT = 2, // Student in current course
Svc_ROLE_TEACHER = 3, // Teacher in current course
} Svc_Role_t;
Rol_Role_t Svc_SvcRole_to_RolRole[Svc_NUM_ROLES] =
{
Rol_UNKNOWN, // Svc_ROLE_UNKNOWN
Rol__GUEST_, // Svc_ROLE__GUEST_
Rol_STUDENT, // Svc_ROLE_STUDENT
Rol_TEACHER, // Svc_ROLE_TEACHER
};
Svc_Role_t Svc_RolRole_to_SvcRole[Rol_NUM_ROLES] =
{
Svc_ROLE_UNKNOWN, // Rol_UNKNOWN
Svc_ROLE__GUEST_, // Rol__GUEST_
Svc_ROLE_UNKNOWN, // Rol_VISITOR
Svc_ROLE_STUDENT, // Rol_STUDENT
Svc_ROLE_TEACHER, // Rol_TEACHER
Svc_ROLE_UNKNOWN, // Rol_DEG_ADM
Svc_ROLE_UNKNOWN, // Rol_CTR_ADM
Svc_ROLE_UNKNOWN, // Rol_INS_ADM
Svc_ROLE_UNKNOWN, // Rol_SYS_ADM
};
/*****************************************************************************/ /*****************************************************************************/
/********************************* Data types ********************************/ /********************************* Data types ********************************/
/*****************************************************************************/ /*****************************************************************************/
@ -174,7 +204,6 @@ static int Svc_GenerateNewWSKey (long UsrCod,char *WSKey);
static int Svc_RemoveOldWSKeys (void); static int Svc_RemoveOldWSKeys (void);
static int Svc_GetCurrentDegCodFromCurrentCrsCod (void); static int Svc_GetCurrentDegCodFromCurrentCrsCod (void);
static int Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod); static int Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod);
static int Svc_GetRoleFromInternalRole (Rol_Role_t Role);
static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input static int Svc_CheckParamsNewAccount (char *NewNicknameWithArroba, // Input
char *NewNicknameWithoutArroba, // Output char *NewNicknameWithoutArroba, // Output
@ -600,27 +629,6 @@ static int Svc_GetSomeUsrDataFromUsrCod (struct UsrData *UsrDat,long CrsCod)
return SOAP_OK; return SOAP_OK;
} }
/*****************************************************************************/
/****** Get the role returned via web service from internal role code ********/
/*****************************************************************************/
static int Svc_GetRoleFromInternalRole (Rol_Role_t Role)
{
switch (Role)
{
case Rol__GUEST_:
case Rol_VISITOR:
return 1; // guest or visitor
case Rol_STUDENT:
return 2; // student
case Rol_TEACHER:
return 3; // teacher
default:
return 0; // unknown
}
return 0; // unknown
}
/*****************************************************************************/ /*****************************************************************************/
/**************************** Get info of my marks ***************************/ /**************************** Get info of my marks ***************************/
/*****************************************************************************/ /*****************************************************************************/
@ -876,7 +884,7 @@ int swad__loginByUserPasswordKey (struct soap *soap,
strncpy (loginByUserPasswordKeyOut->userBirthday,Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,4+2+2); strncpy (loginByUserPasswordKeyOut->userBirthday,Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,4+2+2);
loginByUserPasswordKeyOut->userBirthday[4+2+2] = '\0'; loginByUserPasswordKeyOut->userBirthday[4+2+2] = '\0';
loginByUserPasswordKeyOut->userRole = Svc_GetRoleFromInternalRole (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB); loginByUserPasswordKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB];
} }
else else
{ {
@ -1011,7 +1019,7 @@ int swad__loginBySessionKey (struct soap *soap,
strncpy (loginBySessionKeyOut->userBirthday,Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,4+2+2); strncpy (loginBySessionKeyOut->userBirthday,Gbl.Usrs.Me.UsrDat.Birthday.YYYYMMDD,4+2+2);
loginBySessionKeyOut->userBirthday[4+2+2] = '\0'; loginBySessionKeyOut->userBirthday[4+2+2] = '\0';
loginBySessionKeyOut->userRole = Svc_GetRoleFromInternalRole (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB); loginBySessionKeyOut->userRole = Svc_RolRole_to_SvcRole[Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB];
} }
else else
{ {
@ -1212,7 +1220,7 @@ int swad__getCourses (struct soap *soap,
/* Get role (row[3]) */ /* Get role (row[3]) */
if (sscanf (row[3],"%u",&Role) != 1) // Role in this course if (sscanf (row[3],"%u",&Role) != 1) // Role in this course
Role = Rol_UNKNOWN; Role = Rol_UNKNOWN;
getCoursesOut->coursesArray.__ptr[NumRow].userRole = Svc_GetRoleFromInternalRole (Role); getCoursesOut->coursesArray.__ptr[NumRow].userRole = Svc_RolRole_to_SvcRole[Role];
} }
} }
@ -1390,12 +1398,12 @@ int swad__getUsers (struct soap *soap,
return ReturnCode; return ReturnCode;
/***** Check requested users' role *****/ /***** Check requested users' role *****/
if (userRole < 2 || // Students if (userRole != Svc_ROLE_STUDENT && // Students
userRole > 3) // Teachers userRole != Svc_ROLE_TEACHER) // Teachers
return soap_sender_fault (Gbl.soap, return soap_sender_fault (Gbl.soap,
"Bad requested users' type", "Bad requested users' type",
"User roles allowed are 2 (students) or 3 (teachers)"); "User roles allowed are 2 (students) or 3 (teachers)");
Role = (Rol_Role_t) userRole; Role = Svc_SvcRole_to_RolRole[userRole];
/***** Create a list of groups selected *****/ /***** Create a list of groups selected *****/
Svc_GetLstGrpsSel (groups); Svc_GetLstGrpsSel (groups);
@ -1469,12 +1477,12 @@ int swad__findUsers (struct soap *soap,
} }
/***** Check requested users' role *****/ /***** Check requested users' role *****/
if (userRole < 0 || if (userRole < Svc_ROLE_UNKNOWN ||
userRole > 3) userRole > Svc_ROLE_TEACHER)
return soap_sender_fault (Gbl.soap, return soap_sender_fault (Gbl.soap,
"Bad requested users' type", "Bad requested users' type",
"User roles allowed are 0 (all),1 (guests), 2 (students) or 3 (teachers)"); "User roles allowed are 0 (all), 1 (guests), 2 (students) or 3 (teachers)");
Role = (Rol_Role_t) userRole; Role = Svc_SvcRole_to_RolRole[userRole];
/***** Query users beloging to course or group from database *****/ /***** Query users beloging to course or group from database *****/
strncpy (Gbl.Search.Str,filter,Sch_MAX_LENGTH_STRING_TO_FIND); strncpy (Gbl.Search.Str,filter,Sch_MAX_LENGTH_STRING_TO_FIND);