Version 15.203.1

This commit is contained in:
Antonio Cañas Vargas 2016-04-23 19:59:45 +02:00
parent 92feff74e4
commit fd6fbdd664
3 changed files with 57 additions and 43 deletions

View File

@ -64,6 +64,8 @@ extern struct Globals Gbl;
static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned MinDigits);
static bool ID_ICanSeeAnotherUsrID (struct UsrData *UsrDat);
static void ID_RemoveUsrID (const struct UsrData *UsrDat,bool ItsMe);
static bool ID_CheckIfConfirmed (long UsrCod,const char *UsrID);
static void ID_RemoveUsrIDFromDB (long UsrCod,const char *UsrID);
@ -348,7 +350,21 @@ static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned Min
void ID_WriteUsrIDs (struct UsrData *UsrDat)
{
unsigned NumID;
bool ICanSeeUsrID = ID_ICanSeeUsrID (UsrDat);
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
bool ICanSeeUsrID;
bool ICanConfirmUsrID;
if (ItsMe)
{
ICanSeeUsrID = true;
ICanConfirmUsrID = false;
}
else // A user distinct than me
{
ICanSeeUsrID = ID_ICanSeeAnotherUsrID (UsrDat);
ICanConfirmUsrID = ICanSeeUsrID &&
!Gbl.Form.Inside; // Not inside a form
}
for (NumID = 0;
NumID < UsrDat->IDs.Num;
@ -365,6 +381,44 @@ void ID_WriteUsrIDs (struct UsrData *UsrDat)
else
fprintf (Gbl.F.Out,"********");
fprintf (Gbl.F.Out,"</span>");
if (ICanConfirmUsrID &&
!UsrDat->IDs.List[NumID].Confirmed)
fprintf (Gbl.F.Out," Confirmar ID"); // TODO: Need translation!!!!
}
}
/*****************************************************************************/
/***************** Check if I can see another user's IDs *********************/
/*****************************************************************************/
// This function should not be called when UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod
static bool ID_ICanSeeAnotherUsrID (struct UsrData *UsrDat)
{
/***** Check if I have permission to see another user's IDs *****/
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_TEACHER:
/* If I am a teacher of current course,
I only can see the user's IDs of students from current course */
return (UsrDat->Accepted &&
UsrDat->RoleInCurrentCrsDB == Rol_STUDENT);
case Rol_DEG_ADM:
/* If I am an administrator of current degree,
I only can see the user's IDs of users from current degree */
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 see the user's IDs of users from current centre */
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 see the user's IDs of users from current institution */
return Usr_CheckIfUsrBelongsToIns (UsrDat->UsrCod,Gbl.CurrentIns.Ins.InsCod,true);
case Rol_SYS_ADM:
return true;
default:
return false;
}
}
@ -826,41 +880,3 @@ void ID_ConfirmUsrID (long UsrCod,const char *UsrID)
UsrCod,UsrID);
DB_QueryINSERT (Query,"can not confirm a user's ID");
}
/*****************************************************************************/
/***************** Check if I can see another user's ID **********************/
/*****************************************************************************/
bool ID_ICanSeeUsrID (struct UsrData *UsrDat)
{
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
if (ItsMe)
return true;
/* Check if I have permission to see another user's ID */
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_TEACHER:
/* If I am a teacher of current course,
I only can see the user's ID of students from current course */
return (UsrDat->Accepted &&
UsrDat->RoleInCurrentCrsDB == Rol_STUDENT);
case Rol_DEG_ADM:
/* If I am an administrator of current degree,
I only can see the user's ID of users from current degree */
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 see the user's ID of users from current centre */
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 see the user's ID of users from current institution */
return Usr_CheckIfUsrBelongsToIns (UsrDat->UsrCod,Gbl.CurrentIns.Ins.InsCod,true);
case Rol_SYS_ADM:
return true;
default:
return false;
}
}

View File

@ -75,6 +75,4 @@ void ID_NewMyUsrID (void);
void ID_NewOtherUsrID (void);
void ID_ConfirmUsrID (long UsrCod,const char *UsrID);
bool ID_ICanSeeUsrID (struct UsrData *UsrDat);
#endif

View File

@ -134,14 +134,14 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.203 (2016-04-23)"
#define Log_PLATFORM_VERSION "SWAD 15.203.1 (2016-04-23)"
#define CSS_FILE "swad15.203.css"
#define JS_FILE "swad15.197.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.204: Apr 23, 2016 New form to confirm another user's ID. (? lines)
Version 15.203.1: Apr 23, 2016 New form to confirm another user's ID. Not finished. (201090 lines)
Version 15.203: Apr 23, 2016 Changes in layout and CSS related to record card. (201076 lines)
Version 15.202.19:Apr 23, 2016 User's ID is shown in green or red in user's account. (201120 lines)
Version 15.202.18:Apr 23, 2016 Change of message about ID in user's account. (201092 lines)