Version 15.202

This commit is contained in:
Antonio Cañas Vargas 2016-04-23 13:23:09 +02:00
parent 69a4ef50be
commit b60bdd77e7
14 changed files with 376 additions and 341 deletions

View File

@ -1679,6 +1679,10 @@ a:hover img.CENTRE_PHOTO_SHOW
.DAT_SMALL_BLUE {font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:#0080FF; font-size:12pt;} .DAT_SMALL_BLUE {font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:#0080FF; font-size:12pt;}
.DAT_SMALL_YELLOW {font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:#C0C000; font-size:12pt;} .DAT_SMALL_YELLOW {font-family:"Arial Narrow","Nimbus Sans L","DejaVu LGC Sans Condensed",sans-serif; color:#C0C000; font-size:12pt;}
/******************************** User's IDs *********************************/
.USR_ID_C {color:#408020}
.USR_ID_NC {color:#A02020}
/******************************* Record card *********************************/ /******************************* Record card *********************************/
.REC_SHORTCUTS .REC_SHORTCUTS
{ {

View File

@ -345,26 +345,27 @@ static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned Min
/*************************** Write list of user's ID *************************/ /*************************** Write list of user's ID *************************/
/*****************************************************************************/ /*****************************************************************************/
void ID_WriteUsrIDs (struct UsrData *UsrDat,bool ICanSeeUsrID) void ID_WriteUsrIDs (struct UsrData *UsrDat)
{ {
unsigned NumID; unsigned NumID;
bool ICanSeeUsrID = ID_ICanSeeUsrID (UsrDat);
if (ICanSeeUsrID) for (NumID = 0;
for (NumID = 0; NumID < UsrDat->IDs.Num;
NumID < UsrDat->IDs.Num; NumID++)
NumID++) {
{ if (NumID)
if (NumID) fprintf (Gbl.F.Out,"<br />");
fprintf (Gbl.F.Out,"<br />");
if (!UsrDat->IDs.List[NumID].Confirmed) fprintf (Gbl.F.Out,"<span class=\"%s\">",
fprintf (Gbl.F.Out,"<span style=\"color:#804040;\">"); UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" :
"USR_ID_NC");
if (ICanSeeUsrID)
fprintf (Gbl.F.Out,"%s",UsrDat->IDs.List[NumID].ID); fprintf (Gbl.F.Out,"%s",UsrDat->IDs.List[NumID].ID);
if (!UsrDat->IDs.List[NumID].Confirmed) else
fprintf (Gbl.F.Out,"</span>"); fprintf (Gbl.F.Out,"********");
} fprintf (Gbl.F.Out,"</span>");
else }
fprintf (Gbl.F.Out,"********");
} }
/*****************************************************************************/ /*****************************************************************************/
@ -824,13 +825,19 @@ void ID_ConfirmUsrID (long UsrCod,const char *UsrID)
bool ID_ICanSeeUsrID (struct UsrData *UsrDat) 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 */ /* Check if I have permission to see another user's ID */
switch (Gbl.Usrs.Me.LoggedRole) switch (Gbl.Usrs.Me.LoggedRole)
{ {
case Rol_TEACHER: case Rol_TEACHER:
/* If I am a teacher of current course, /* If I am a teacher of current course,
I only can see the user's ID of students from current course */ I only can see the user's ID of students from current course */
return (UsrDat->RoleInCurrentCrsDB == Rol_STUDENT); return (UsrDat->Accepted &&
UsrDat->RoleInCurrentCrsDB == Rol_STUDENT);
case Rol_DEG_ADM: case Rol_DEG_ADM:
/* If I am an administrator of current degree, /* If I am an administrator of current degree,
I only can see the user's ID of users from current degree */ I only can see the user's ID of users from current degree */

View File

@ -64,7 +64,7 @@ void ID_GetParamOtherUsrIDPlain (void);
bool ID_CheckIfUsrIDIsValid (const char *UsrID); bool ID_CheckIfUsrIDIsValid (const char *UsrID);
bool ID_CheckIfUsrIDSeemsAValidID (const char *UsrID); bool ID_CheckIfUsrIDSeemsAValidID (const char *UsrID);
void ID_WriteUsrIDs (struct UsrData *UsrDat,bool ICanSeeUsrID); void ID_WriteUsrIDs (struct UsrData *UsrDat);
void ID_PutLinkToChangeUsrIDs (void); void ID_PutLinkToChangeUsrIDs (void);
void ID_ShowFormOthIDs (void); void ID_ShowFormOthIDs (void);

View File

@ -2008,7 +2008,7 @@ static void Att_WriteRowStdToCallTheRoll (unsigned NumStd,struct UsrData *UsrDat
UsrDat->Accepted ? "DAT_SMALL_N" : UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL", "DAT_SMALL",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,true); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
/***** Write student's name *****/ /***** Write student's name *****/
@ -3217,7 +3217,7 @@ static void Att_WriteRowStdSeveralAttEvents (unsigned NumStd,struct UsrData *Usr
UsrDat->Accepted ? "DAT_SMALL_N" : UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL", "DAT_SMALL",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,true); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
/***** Write student's name *****/ /***** Write student's name *****/
@ -3357,7 +3357,7 @@ static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat)
Gbl.RowEvenOdd, Gbl.RowEvenOdd,
UsrDat->Accepted ? "DAT_SMALL_N" : UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL"); "DAT_SMALL");
ID_WriteUsrIDs (UsrDat,true); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
/***** Write student's name *****/ /***** Write student's name *****/

View File

@ -137,13 +137,17 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.201.8 (2016-04-22)" #define Log_PLATFORM_VERSION "SWAD 15.202 (2016-04-23)"
#define CSS_FILE "swad15.198.css" #define CSS_FILE "swad15.202.css"
#define JS_FILE "swad15.197.js" #define JS_FILE "swad15.197.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.202: Apr 23, 2016 User's IDs are show in green or red.
Code refactoring and bug fixing related to showing user's ID and e-mail. (200908 lines)
Version 15.201.9: Apr 22, 2016 Code refactoring in record card.
Changes in layout of record cards. (200895 lines)
Version 15.201.8: Apr 22, 2016 Code refactoring in record card. Version 15.201.8: Apr 22, 2016 Code refactoring in record card.
Fixed bugs in record cards. (200881 lines) Fixed bugs in record cards. (200881 lines)
Version 15.201.7: Apr 22, 2016 Code refactoring in record card. Version 15.201.7: Apr 22, 2016 Code refactoring in record card.

View File

@ -3457,9 +3457,7 @@ static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat)
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
/***** Show user's ID *****/ /***** Show user's ID *****/
ID_WriteUsrIDs (UsrDat, ID_WriteUsrIDs (UsrDat);
UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ID_ICanSeeUsrID (UsrDat) :
(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER));
/***** Show user's name *****/ /***** Show user's name *****/
fprintf (Gbl.F.Out,"<br />"); fprintf (Gbl.F.Out,"<br />");

View File

@ -1558,3 +1558,47 @@ void Mai_WriteFootNoteEMail (Txt_Language_t Language)
Cfg_PLATFORM_SHORT_NAME, Cfg_PLATFORM_SHORT_NAME,
Cfg_HTTPS_URL_SWAD_CGI); Cfg_HTTPS_URL_SWAD_CGI);
} }
/*****************************************************************************/
/**************** Check if I can see another user's e-mail *******************/
/*****************************************************************************/
bool Mai_ICanSeeEmail (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 e-mail */
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_STUDENT:
/* If I am a student of current course,
I only can see the user's e-mail of teachers from current course */
return (UsrDat->Accepted &&
UsrDat->RoleInCurrentCrsDB == Rol_TEACHER);
case Rol_TEACHER:
/* If I am a teacher of current course,
I only can see the user's e-mail of students or teachers from current course */
return (UsrDat->Accepted &&
(UsrDat->RoleInCurrentCrsDB == Rol_STUDENT ||
UsrDat->RoleInCurrentCrsDB == Rol_TEACHER));
case Rol_DEG_ADM:
/* If I am an administrator of current degree,
I only can see the user's e-mail 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 e-mail 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 e-mail 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

@ -85,4 +85,6 @@ void Mai_CreateFileNameMail (void);
void Mai_WriteWelcomeNoteEMail (struct UsrData *UsrDat); void Mai_WriteWelcomeNoteEMail (struct UsrData *UsrDat);
void Mai_WriteFootNoteEMail (Txt_Language_t Language); void Mai_WriteFootNoteEMail (Txt_Language_t Language);
bool Mai_ICanSeeEmail (struct UsrData *UsrDat);
#endif #endif

View File

@ -493,8 +493,7 @@ static void Msg_ShowOneUniqueRecipient (void)
fprintf (Gbl.F.Out,"<div class=\"MSG_TO_ONE_RCP %s\">", fprintf (Gbl.F.Out,"<div class=\"MSG_TO_ONE_RCP %s\">",
Gbl.Usrs.Other.UsrDat.Accepted ? "DAT_SMALL_NOBR_N" : Gbl.Usrs.Other.UsrDat.Accepted ? "DAT_SMALL_NOBR_N" :
"DAT_SMALL_NOBR"); "DAT_SMALL_NOBR");
ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat, ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat);
ID_ICanSeeUsrID (&Gbl.Usrs.Other.UsrDat));
fprintf (Gbl.F.Out,"</div>"); fprintf (Gbl.F.Out,"</div>");
/***** Write user's name *****/ /***** Write user's name *****/

View File

@ -98,10 +98,10 @@ static void Rec_ShowEmail (struct UsrData *UsrDat,
Rec_RecordViewType_t TypeOfView, Rec_RecordViewType_t TypeOfView,
bool DataForm, bool DataForm,
const char *ClassForm); const char *ClassForm);
static void Rec_ShowUsrIDs (struct UsrData *UsrDat, static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm);
Rec_RecordViewType_t TypeOfView, static void Rec_ShowRole (struct UsrData *UsrDat,
bool DataForm, Rec_RecordViewType_t TypeOfView,
const char *ClassForm); const char *ClassForm);
static void Rec_WriteLinkToDataProtectionClause (void); static void Rec_WriteLinkToDataProtectionClause (void);
@ -1963,12 +1963,7 @@ void Rec_ShowCommonRecordUnmodifiable (struct UsrData *UsrDat)
void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView, void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView,
struct UsrData *UsrDat) struct UsrData *UsrDat)
{ {
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *The_ClassForm[The_NUM_THEMES];
extern const char *Txt_Sex;
extern const char *Txt_Role;
extern const char *Txt_SEX_SINGULAR_Abc[Usr_NUM_SEXS];
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
extern const char *Txt_Surname_1; extern const char *Txt_Surname_1;
extern const char *Txt_Surname_2; extern const char *Txt_Surname_2;
extern const char *Txt_First_name; extern const char *Txt_First_name;
@ -1993,10 +1988,6 @@ void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView,
bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER); // My current role is teacher bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER); // My current role is teacher
bool IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser bool IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser
bool CountryForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD); bool CountryForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD);
bool RoleForm = (TypeOfView == Rec_FORM_SIGN_UP ||
TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_USR ||
TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR);
bool SexForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD);
bool DataForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD || bool DataForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD ||
TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_USR || TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_USR ||
(TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR && (TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR &&
@ -2022,9 +2013,6 @@ void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView,
((TypeOfView == Rec_RECORD_LIST || ((TypeOfView == Rec_RECORD_LIST ||
TypeOfView == Rec_RECORD_PRINT) && TypeOfView == Rec_RECORD_PRINT) &&
UsrDat->RoleInCurrentCrsDB == Rol_TEACHER)); // He/she is a teacher in the current course UsrDat->RoleInCurrentCrsDB == Rol_TEACHER)); // He/she is a teacher in the current course
Usr_Sex_t Sex;
Rol_Role_t Role;
Rol_Role_t DefaultRoleInCurrentCrs;
unsigned NumCty; unsigned NumCty;
struct Institution Ins; struct Institution Ins;
struct Centre Ctr; struct Centre Ctr;
@ -2118,195 +2106,10 @@ void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView,
Rec_ShowEmail (UsrDat,TypeOfView,DataForm,ClassForm); Rec_ShowEmail (UsrDat,TypeOfView,DataForm,ClassForm);
/***** User's ID *****/ /***** User's ID *****/
Rec_ShowUsrIDs (UsrDat,TypeOfView,DataForm,ClassForm); Rec_ShowUsrIDs (UsrDat,ClassForm);
/***** User's role or sex *****/ /***** User's role or sex *****/
if (RoleForm) Rec_ShowRole (UsrDat,TypeOfView,ClassForm);
{
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_MIDDLE\""
" style=\"width:%upx;\">"
"%s:</td>"
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
" style=\"width:%upx;\">",
ClassForm,Rec_C1_BOTTOM,
Txt_Role,
Rec_C2_BOTTOM);
switch (TypeOfView)
{
case Rec_FORM_SIGN_UP: // I want to apply for enrollment
DefaultRoleInCurrentCrs = ((UsrDat->Roles & (1 << Rol_TEACHER)) || // I am teacher in other courses
UsrDat->UsrCod == Gbl.CurrentCrs.Crs.RequesterUsrCod) ? // I am the creator of the course
Rol_TEACHER :
Rol_STUDENT;
fprintf (Gbl.F.Out,"<select name=\"Role\">");
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
fprintf (Gbl.F.Out,"</select>");
break;
case Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR: // The other user already exists in the platform
fprintf (Gbl.F.Out,"<select name=\"Role\">");
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
{
if (UsrDat->RoleInCurrentCrsDB < Rol_STUDENT) // The other user does not belong to current course
{
/* If there is a request of this user, default role is the requested role */
if ((DefaultRoleInCurrentCrs = Rol_GetRequestedRole (UsrDat->UsrCod)) == Rol_UNKNOWN)
DefaultRoleInCurrentCrs = (UsrDat->Roles & (1 << Rol_TEACHER)) ? Rol_TEACHER :
Rol_STUDENT;
}
else
DefaultRoleInCurrentCrs = UsrDat->RoleInCurrentCrsDB;
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol__GUEST_:
case Rol_VISITOR:
case Rol_STUDENT:
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\" disabled=\"disabled\">%s</option>",
(unsigned) Gbl.Usrs.Me.LoggedRole,
Txt_ROLES_SINGUL_Abc[Gbl.Usrs.Me.LoggedRole][UsrDat->Sex]);
break;
case Rol_TEACHER:
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
if (Role == Rol_STUDENT ||
(UsrDat->Roles & (1 << Role))) // A teacher can not upgrade a student (in all other courses) to teacher
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
break;
case Rol_DEG_ADM:
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
break;
default: // The rest of users can not register other users
break;
}
}
else // No course selected
{
DefaultRoleInCurrentCrs = (UsrDat->Roles & ((1 << Rol_STUDENT) |
(1 << Rol_TEACHER))) ? Rol_VISITOR :
Rol__GUEST_;
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\" disabled=\"disabled\">%s</option>",
(unsigned) DefaultRoleInCurrentCrs,
Txt_ROLES_SINGUL_Abc[DefaultRoleInCurrentCrs][UsrDat->Sex]);
}
fprintf (Gbl.F.Out,"</select>");
break;
case Rec_FORM_NEW_RECORD_OTHER_NEW_USR: // The other user does not exist in platform
fprintf (Gbl.F.Out,"<select name=\"Role\">");
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_TEACHER: // A teacher only can create students
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\">%s</option>",
(unsigned) Rol_STUDENT,Txt_ROLES_SINGUL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN]);
break;
case Rol_DEG_ADM: // An administrator can create students and teachers in a course
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\">%s</option>"
"<option value=\"%u\">%s</option>",
(unsigned) Rol_STUDENT,Txt_ROLES_SINGUL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN],
(unsigned) Rol_TEACHER,Txt_ROLES_SINGUL_Abc[Rol_TEACHER][Usr_SEX_UNKNOWN]);
break;
default: // The rest of users can not register other users
break;
}
else // No course selected
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_SYS_ADM:
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\">%s</option>",
(unsigned) Rol__GUEST_,Txt_ROLES_SINGUL_Abc[Rol__GUEST_][Usr_SEX_UNKNOWN]);
break;
default: // The rest of users can not register other users
break;
}
fprintf (Gbl.F.Out,"</select>");
break;
default:
break;
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
else if (SexForm)
{
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_MIDDLE\""
" style=\"width:%upx;\">"
"%s*:</td>"
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
" style=\"width:%upx;\">",
ClassForm,Rec_C1_BOTTOM,
Txt_Sex,
Rec_C2_BOTTOM);
for (Sex = Usr_SEX_FEMALE;
Sex <= Usr_SEX_MALE;
Sex++)
{
fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"Sex\" value=\"%u\"",(unsigned) Sex);
if (Sex == Gbl.Usrs.Me.UsrDat.Sex)
fprintf (Gbl.F.Out," checked=\"checked\"");
fprintf (Gbl.F.Out," />"
"<img src=\"%s/%s16x16.gif\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"%s",
Gbl.Prefs.IconsURL,Usr_StringsSexDB[Sex],
Txt_SEX_SINGULAR_Abc[Sex],
Txt_SEX_SINGULAR_Abc[Sex],
Txt_SEX_SINGULAR_Abc[Sex]);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
else // RoleForm == false, SexForm == false
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_MIDDLE\""
" style=\"width:%upx;\">"
"%s:"
"</td>"
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
" style=\"width:%upx;\">"
"%s"
"</td>"
"</tr>",
ClassForm,Rec_C1_BOTTOM,
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ? Txt_Sex :
Txt_Role,
Rec_C2_BOTTOM,
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ? Txt_SEX_SINGULAR_Abc[UsrDat->Sex] :
Txt_ROLES_SINGUL_Abc[UsrDat->RoleInCurrentCrsDB][UsrDat->Sex]);
/***** Name *****/ /***** Name *****/
/* Surname 1 */ /* Surname 1 */
@ -3236,29 +3039,9 @@ static void Rec_ShowEmail (struct UsrData *UsrDat,
/******************************* Show user's IDs *****************************/ /******************************* Show user's IDs *****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Rec_ShowUsrIDs (struct UsrData *UsrDat, static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm)
Rec_RecordViewType_t TypeOfView,
bool DataForm,
const char *ClassForm)
{ {
extern const char *Txt_ID; extern const char *Txt_ID;
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER); // My current role is teacher
bool HeIsTeacherInThisCourse = (UsrDat->RoleInCurrentCrsDB == Rol_TEACHER); // He/she is a teacher in this course
bool ShowID = (ItsMe ||
Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM ||
DataForm ||
TypeOfView == Rec_FORM_MY_COMMON_RECORD ||
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ||
TypeOfView == Rec_FORM_MY_COURSE_RECORD_AS_STUDENT ||
TypeOfView == Rec_CHECK_MY_COURSE_RECORD_AS_STUDENT ||
(UsrDat->Accepted &&
(((TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR ||
TypeOfView == Rec_CHECK_OTHER_USR_COMMON_RECORD) &&
!(IAmLoggedAsTeacher && HeIsTeacherInThisCourse)) || // A teacher can not see another teacher's ID
((TypeOfView == Rec_RECORD_LIST ||
TypeOfView == Rec_RECORD_PRINT) &&
IAmLoggedAsTeacher && Gbl.Usrs.Listing.RecsUsrs == Rec_RECORD_USERS_STUDENTS))));
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_TOP\"" "<td class=\"%s RIGHT_TOP\""
@ -3269,11 +3052,220 @@ static void Rec_ShowUsrIDs (struct UsrData *UsrDat,
" style=\"width:%upx;\">", " style=\"width:%upx;\">",
ClassForm,Rec_C1_BOTTOM,Txt_ID, ClassForm,Rec_C1_BOTTOM,Txt_ID,
Rec_C2_BOTTOM); Rec_C2_BOTTOM);
ID_WriteUsrIDs (UsrDat,ShowID); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
} }
/*****************************************************************************/
/************************** Show user's role / sex ***************************/
/*****************************************************************************/
static void Rec_ShowRole (struct UsrData *UsrDat,
Rec_RecordViewType_t TypeOfView,
const char *ClassForm)
{
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
extern const char *Txt_Role;
extern const char *Txt_Sex;
extern const char *Txt_SEX_SINGULAR_Abc[Usr_NUM_SEXS];
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
bool RoleForm = (TypeOfView == Rec_FORM_SIGN_UP ||
TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_USR ||
TypeOfView == Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR);
bool SexForm = (TypeOfView == Rec_FORM_MY_COMMON_RECORD);
Rol_Role_t DefaultRoleInCurrentCrs;
Rol_Role_t Role;
Usr_Sex_t Sex;
if (RoleForm)
{
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_MIDDLE\""
" style=\"width:%upx;\">"
"%s:</td>"
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
" style=\"width:%upx;\">",
ClassForm,Rec_C1_BOTTOM,
Txt_Role,
Rec_C2_BOTTOM);
switch (TypeOfView)
{
case Rec_FORM_SIGN_UP: // I want to apply for enrollment
DefaultRoleInCurrentCrs = ((UsrDat->Roles & (1 << Rol_TEACHER)) || // I am teacher in other courses
UsrDat->UsrCod == Gbl.CurrentCrs.Crs.RequesterUsrCod) ? // I am the creator of the course
Rol_TEACHER :
Rol_STUDENT;
fprintf (Gbl.F.Out,"<select name=\"Role\">");
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
fprintf (Gbl.F.Out,"</select>");
break;
case Rec_FORM_MODIFY_RECORD_OTHER_EXISTING_USR: // The other user already exists in the platform
fprintf (Gbl.F.Out,"<select name=\"Role\">");
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
{
if (UsrDat->RoleInCurrentCrsDB < Rol_STUDENT) // The other user does not belong to current course
{
/* If there is a request of this user, default role is the requested role */
if ((DefaultRoleInCurrentCrs = Rol_GetRequestedRole (UsrDat->UsrCod)) == Rol_UNKNOWN)
DefaultRoleInCurrentCrs = (UsrDat->Roles & (1 << Rol_TEACHER)) ? Rol_TEACHER :
Rol_STUDENT;
}
else
DefaultRoleInCurrentCrs = UsrDat->RoleInCurrentCrsDB;
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol__GUEST_:
case Rol_VISITOR:
case Rol_STUDENT:
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\" disabled=\"disabled\">%s</option>",
(unsigned) Gbl.Usrs.Me.LoggedRole,
Txt_ROLES_SINGUL_Abc[Gbl.Usrs.Me.LoggedRole][UsrDat->Sex]);
break;
case Rol_TEACHER:
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
if (Role == Rol_STUDENT ||
(UsrDat->Roles & (1 << Role))) // A teacher can not upgrade a student (in all other courses) to teacher
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
break;
case Rol_DEG_ADM:
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
for (Role = Rol_STUDENT;
Role <= Rol_TEACHER;
Role++)
{
fprintf (Gbl.F.Out,"<option value=\"%u\"",(unsigned) Role);
if (Role == DefaultRoleInCurrentCrs)
fprintf (Gbl.F.Out," selected=\"selected\"");
fprintf (Gbl.F.Out,">%s</option>",
Txt_ROLES_SINGUL_Abc[Role][UsrDat->Sex]);
}
break;
default: // The rest of users can not register other users
break;
}
}
else // No course selected
{
DefaultRoleInCurrentCrs = (UsrDat->Roles & ((1 << Rol_STUDENT) |
(1 << Rol_TEACHER))) ? Rol_VISITOR :
Rol__GUEST_;
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\" disabled=\"disabled\">%s</option>",
(unsigned) DefaultRoleInCurrentCrs,
Txt_ROLES_SINGUL_Abc[DefaultRoleInCurrentCrs][UsrDat->Sex]);
}
fprintf (Gbl.F.Out,"</select>");
break;
case Rec_FORM_NEW_RECORD_OTHER_NEW_USR: // The other user does not exist in platform
fprintf (Gbl.F.Out,"<select name=\"Role\">");
if (Gbl.CurrentCrs.Crs.CrsCod > 0) // Course selected
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_TEACHER: // A teacher only can create students
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\">%s</option>",
(unsigned) Rol_STUDENT,Txt_ROLES_SINGUL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN]);
break;
case Rol_DEG_ADM: // An administrator can create students and teachers in a course
case Rol_CTR_ADM:
case Rol_INS_ADM:
case Rol_SYS_ADM:
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\">%s</option>"
"<option value=\"%u\">%s</option>",
(unsigned) Rol_STUDENT,Txt_ROLES_SINGUL_Abc[Rol_STUDENT][Usr_SEX_UNKNOWN],
(unsigned) Rol_TEACHER,Txt_ROLES_SINGUL_Abc[Rol_TEACHER][Usr_SEX_UNKNOWN]);
break;
default: // The rest of users can not register other users
break;
}
else // No course selected
switch (Gbl.Usrs.Me.LoggedRole)
{
case Rol_SYS_ADM:
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\">%s</option>",
(unsigned) Rol__GUEST_,Txt_ROLES_SINGUL_Abc[Rol__GUEST_][Usr_SEX_UNKNOWN]);
break;
default: // The rest of users can not register other users
break;
}
fprintf (Gbl.F.Out,"</select>");
break;
default:
break;
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
else if (SexForm)
{
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_MIDDLE\""
" style=\"width:%upx;\">"
"%s*:</td>"
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
" style=\"width:%upx;\">",
ClassForm,Rec_C1_BOTTOM,
Txt_Sex,
Rec_C2_BOTTOM);
for (Sex = Usr_SEX_FEMALE;
Sex <= Usr_SEX_MALE;
Sex++)
{
fprintf (Gbl.F.Out,"<input type=\"radio\" name=\"Sex\" value=\"%u\"",(unsigned) Sex);
if (Sex == Gbl.Usrs.Me.UsrDat.Sex)
fprintf (Gbl.F.Out," checked=\"checked\"");
fprintf (Gbl.F.Out," />"
"<img src=\"%s/%s16x16.gif\""
" alt=\"%s\" title=\"%s\""
" class=\"ICON20x20\" />"
"%s",
Gbl.Prefs.IconsURL,Usr_StringsSexDB[Sex],
Txt_SEX_SINGULAR_Abc[Sex],
Txt_SEX_SINGULAR_Abc[Sex],
Txt_SEX_SINGULAR_Abc[Sex]);
}
fprintf (Gbl.F.Out,"</td>"
"</tr>");
}
else // RoleForm == false, SexForm == false
fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_MIDDLE\""
" style=\"width:%upx;\">"
"%s:"
"</td>"
"<td class=\"REC_DAT_BOLD LEFT_MIDDLE\""
" style=\"width:%upx;\">"
"%s"
"</td>"
"</tr>",
ClassForm,Rec_C1_BOTTOM,
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ? Txt_Sex :
Txt_Role,
Rec_C2_BOTTOM,
TypeOfView == Rec_MY_COMMON_RECORD_CHECK ? Txt_SEX_SINGULAR_Abc[UsrDat->Sex] :
Txt_ROLES_SINGUL_Abc[UsrDat->RoleInCurrentCrsDB][UsrDat->Sex]);
}
/*****************************************************************************/ /*****************************************************************************/
/*********************** Write a link to netiquette rules ********************/ /*********************** Write a link to netiquette rules ********************/
/*****************************************************************************/ /*****************************************************************************/

View File

@ -1662,7 +1662,7 @@ static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql
/* Write the user's ID if user is a student */ /* Write the user's ID if user is a student */
fprintf (Gbl.F.Out,"<td class=\"LOG CENTER_TOP COLOR%u\">", fprintf (Gbl.F.Out,"<td class=\"LOG CENTER_TOP COLOR%u\">",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
ID_WriteUsrIDs (&UsrDat,(RoleFromLog == Rol_STUDENT)); ID_WriteUsrIDs (&UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>"); fprintf (Gbl.F.Out,"&nbsp;</td>");
/* Write the first name and the surnames */ /* Write the first name and the surnames */
@ -1821,7 +1821,7 @@ static void Sta_ShowNumHitsPerUsr (unsigned long NumRows,
/* Write the user's ID if user is a student in current course */ /* Write the user's ID if user is a student in current course */
fprintf (Gbl.F.Out,"<td class=\"LOG CENTER_TOP COLOR%u\">", fprintf (Gbl.F.Out,"<td class=\"LOG CENTER_TOP COLOR%u\">",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
ID_WriteUsrIDs (&UsrDat,(UsrDat.RoleInCurrentCrsDB == Rol_STUDENT)); ID_WriteUsrIDs (&UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>"); fprintf (Gbl.F.Out,"&nbsp;</td>");
/* Write the name and the surnames */ /* Write the name and the surnames */

View File

@ -7339,9 +7339,7 @@ static void Tst_ShowDataUsr (struct UsrData *UsrDat,unsigned NumExams)
Act_LinkFormSubmit (UsrDat->FullName,"MSG_AUT"); Act_LinkFormSubmit (UsrDat->FullName,"MSG_AUT");
/***** Show user's ID *****/ /***** Show user's ID *****/
ID_WriteUsrIDs (UsrDat, ID_WriteUsrIDs (UsrDat);
(UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ID_ICanSeeUsrID (UsrDat) :
(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER)));
/***** Show user's name *****/ /***** Show user's name *****/
fprintf (Gbl.F.Out,"<br />%s",UsrDat->Surname1); fprintf (Gbl.F.Out,"<br />%s",UsrDat->Surname1);
@ -7454,7 +7452,7 @@ void Tst_ShowOneTestExam (void)
"</td>" "</td>"
"<td class=\"DAT LEFT_TOP\">", "<td class=\"DAT LEFT_TOP\">",
Txt_ROLES_SINGUL_Abc[Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB][Gbl.Usrs.Other.UsrDat.Sex]); Txt_ROLES_SINGUL_Abc[Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB][Gbl.Usrs.Other.UsrDat.Sex]);
ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat,true); ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat);
fprintf (Gbl.F.Out," %s", fprintf (Gbl.F.Out," %s",
Gbl.Usrs.Other.UsrDat.Surname1); Gbl.Usrs.Other.UsrDat.Surname1);
if (Gbl.Usrs.Other.UsrDat.Surname2[0]) if (Gbl.Usrs.Other.UsrDat.Surname2[0])

View File

@ -129,12 +129,17 @@ static void Usr_SetUsrRoleAndPrefs (void);
static void Usr_InsertMyLastData (void); static void Usr_InsertMyLastData (void);
static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat); static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat);
static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutCheckBoxToSelectUsr); static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,
bool PutCheckBoxToSelectUsr);
static void Usr_WriteRowGstAllData (struct UsrData *UsrDat); static void Usr_WriteRowGstAllData (struct UsrData *UsrDat);
static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char *BgColor,bool ShowEmail, static void Usr_RestrictLengthUsrName (struct UsrData *UsrDat);
const char *MailLink, static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,
const char *InstitutionName,const char *InstitutionLink); const char *BgColor,
static void Usr_WriteUsrData (const char *BgColor,const char *Data,const char *Link,bool NonBreak,bool Accepted); const char *InstitutionName,
const char *InstitutionLink);
static void Usr_WriteUsrData (const char *BgColor,
const char *Data,const char *Link,
bool NonBreak,bool Accepted);
static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,const char *UsrQuery,bool Search,char *Query); static void Usr_BuildQueryToGetUsrsLstCrs (Rol_Role_t Role,const char *UsrQuery,bool Search,char *Query);
static void Usr_GetAdmsLst (Sco_Scope_t Scope); static void Usr_GetAdmsLst (Sco_Scope_t Scope);
@ -2686,7 +2691,6 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat)
{ {
char PhotoURL[PATH_MAX+1]; char PhotoURL[PATH_MAX+1];
bool ShowPhoto; bool ShowPhoto;
char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address
struct Institution Ins; struct Institution Ins;
/***** Start row *****/ /***** Start row *****/
@ -2699,7 +2703,7 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat)
Usr_PutCheckboxToSelectUser (UsrDat,false); Usr_PutCheckboxToSelectUser (UsrDat,false);
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
/***** Student has accepted enrollment in current course? *****/ /***** Guest has accepted enrollment in current course? *****/
fprintf (Gbl.F.Out,"<td class=\"BM%u\">" fprintf (Gbl.F.Out,"<td class=\"BM%u\">"
"<img src=\"%s/tr16x16.gif\"" "<img src=\"%s/tr16x16.gif\""
" alt=\"\" title=\"\"" " alt=\"\" title=\"\""
@ -2716,7 +2720,7 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat)
if (Gbl.Usrs.Listing.WithPhotos) if (Gbl.Usrs.Listing.WithPhotos)
{ {
/***** Show student's photo *****/ /***** Show guest's photo *****/
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE COLOR%u\">", fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE COLOR%u\">",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL); ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL);
@ -2726,26 +2730,21 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat)
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
} }
/***** Prepare data for brief presentation *****/
Usr_RestrictLengthMainData (true,UsrDat,MailLink);
/****** Write user's IDs ******/ /****** Write user's IDs ******/
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE COLOR%u\">", fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE COLOR%u\">",
UsrDat->Accepted ? "DAT_SMALL_N" : UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL", "DAT_SMALL",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER)); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
/***** Write rest of main student's data *****/ /***** Write rest of main guest's data *****/
Ins.InsCod = UsrDat->InsCod; Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],true, Usr_RestrictLengthUsrName (UsrDat);
UsrDat->Email[0] ? MailLink : Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],
NULL, Ins.ShortName,Ins.WWW[0] ? Ins.WWW :
Ins.ShortName, NULL);
Ins.WWW[0] ? Ins.WWW :
NULL);
/***** End row *****/ /***** End row *****/
fprintf (Gbl.F.Out,"</tr>"); fprintf (Gbl.F.Out,"</tr>");
@ -2757,7 +2756,8 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat)
/************ Write a row of a table with the data of a student **************/ /************ Write a row of a table with the data of a student **************/
/*****************************************************************************/ /*****************************************************************************/
void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutCheckBoxToSelectUsr) void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,
bool PutCheckBoxToSelectUsr)
{ {
extern const char *Txt_Enrollment_confirmed; extern const char *Txt_Enrollment_confirmed;
extern const char *Txt_Enrollment_not_confirmed; extern const char *Txt_Enrollment_not_confirmed;
@ -2765,11 +2765,7 @@ void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutChe
char PhotoURL[PATH_MAX+1]; char PhotoURL[PATH_MAX+1];
bool ShowPhoto; bool ShowPhoto;
bool UsrIsTheMsgSender = false; bool UsrIsTheMsgSender = false;
char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address
struct Institution Ins; struct Institution Ins;
bool ShowEmail = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER && UsrDat->Accepted) ||
Gbl.Usrs.Me.LoggedRole == Rol_DEG_ADM ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM;
/***** Start row *****/ /***** Start row *****/
fprintf (Gbl.F.Out,"<tr>"); fprintf (Gbl.F.Out,"<tr>");
@ -2828,26 +2824,21 @@ void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutChe
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
} }
/***** Prepare data for brief presentation *****/
Usr_RestrictLengthMainData (ShowEmail,UsrDat,MailLink);
/****** Write user's ID ******/ /****** Write user's ID ******/
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">", fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">",
UsrDat->Accepted ? "DAT_SMALL_N" : UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL", "DAT_SMALL",
BgColor); BgColor);
ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER)); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
/***** Write rest of main student's data *****/ /***** Write rest of main student's data *****/
Ins.InsCod = UsrDat->InsCod; Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor,ShowEmail, Usr_RestrictLengthUsrName (UsrDat);
UsrDat->Email[0] ? MailLink : Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor,
NULL, Ins.ShortName,Ins.WWW[0] ? Ins.WWW :
Ins.ShortName, NULL);
Ins.WWW[0] ? Ins.WWW :
NULL);
/***** End row *****/ /***** End row *****/
fprintf (Gbl.F.Out,"</tr>"); fprintf (Gbl.F.Out,"</tr>");
@ -2885,14 +2876,14 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat)
/****** Write user's ID ******/ /****** Write user's ID ******/
fprintf (Gbl.F.Out,"<td class=\"DAT_SMALL LEFT_MIDDLE COLOR%u\">", fprintf (Gbl.F.Out,"<td class=\"DAT_SMALL LEFT_MIDDLE COLOR%u\">",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,true); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>"); fprintf (Gbl.F.Out,"&nbsp;</td>");
/***** Write rest of guest's main data *****/ /***** Write rest of guest's main data *****/
Ins.InsCod = UsrDat->InsCod; Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],true, Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],
NULL,Ins.ShortName,NULL); Ins.ShortName,NULL);
/***** Write the rest of the data of the guest *****/ /***** Write the rest of the data of the guest *****/
if (UsrDat->Tch.CtrCod > 0) if (UsrDat->Tch.CtrCod > 0)
@ -2966,8 +2957,7 @@ void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames)
char Text[Cns_MAX_BYTES_TEXT+1]; char Text[Cns_MAX_BYTES_TEXT+1];
struct Institution Ins; struct Institution Ins;
bool ShowData = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER && UsrDat->Accepted) || bool ShowData = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER && UsrDat->Accepted) ||
Gbl.Usrs.Me.LoggedRole == Rol_DEG_ADM || Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM;
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM;
/***** Start row *****/ /***** Start row *****/
fprintf (Gbl.F.Out,"<tr>"); fprintf (Gbl.F.Out,"<tr>");
@ -2989,13 +2979,14 @@ void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames)
UsrDat->Accepted ? "DAT_SMALL_N" : UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL", "DAT_SMALL",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER)); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>"); fprintf (Gbl.F.Out,"&nbsp;</td>");
/***** Write rest of main student's data *****/ /***** Write rest of main student's data *****/
Ins.InsCod = UsrDat->InsCod; Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],ShowData,NULL,Ins.ShortName,NULL); Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],
Ins.ShortName,NULL);
/***** Write the rest of the data of the student *****/ /***** Write the rest of the data of the student *****/
Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd], Usr_WriteUsrData (Gbl.ColorRows[Gbl.RowEvenOdd],
@ -3073,7 +3064,8 @@ void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames)
/************* Write a row of a table with the data of a teacher *************/ /************* Write a row of a table with the data of a teacher *************/
/*****************************************************************************/ /*****************************************************************************/
static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutCheckBoxToSelectUsr) static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,
bool PutCheckBoxToSelectUsr)
{ {
extern const char *Txt_Enrollment_confirmed; extern const char *Txt_Enrollment_confirmed;
extern const char *Txt_Enrollment_not_confirmed; extern const char *Txt_Enrollment_not_confirmed;
@ -3082,11 +3074,7 @@ static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool
bool ShowPhoto; bool ShowPhoto;
bool UsrIsTheMsgSender = PutCheckBoxToSelectUsr && bool UsrIsTheMsgSender = PutCheckBoxToSelectUsr &&
(UsrDat->UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod); (UsrDat->UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address
struct Institution Ins; struct Institution Ins;
bool ShowEmail = UsrDat->Accepted ||
Gbl.Usrs.Me.LoggedRole == Rol_DEG_ADM ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM;
/***** Start row *****/ /***** Start row *****/
fprintf (Gbl.F.Out,"<tr>"); fprintf (Gbl.F.Out,"<tr>");
@ -3139,27 +3127,22 @@ static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
} }
/***** Prepare data for brief presentation *****/
Usr_RestrictLengthMainData (ShowEmail,UsrDat,MailLink);
/****** Write the user's ID ******/ /****** Write the user's ID ******/
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">", fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">",
UsrDat->Accepted ? "DAT_SMALL_N" : UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL", "DAT_SMALL",
BgColor); BgColor);
ID_WriteUsrIDs (UsrDat,ID_ICanSeeUsrID (UsrDat)); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"&nbsp;"); fprintf (Gbl.F.Out,"&nbsp;");
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
/***** Write rest of main teacher's data *****/ /***** Write rest of main teacher's data *****/
Ins.InsCod = UsrDat->InsCod; Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor,ShowEmail, Usr_RestrictLengthUsrName (UsrDat);
UsrDat->Email[0] ? MailLink : Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor,
NULL, Ins.ShortName,Ins.WWW[0] ? Ins.WWW :
Ins.ShortName, NULL);
Ins.WWW[0] ? Ins.WWW :
NULL);
fprintf (Gbl.F.Out,"</tr>"); fprintf (Gbl.F.Out,"</tr>");
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
@ -3200,13 +3183,14 @@ void Usr_WriteRowTchAllData (struct UsrData *UsrDat)
UsrDat->Accepted ? "DAT_SMALL_N" : UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL", "DAT_SMALL",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,ID_ICanSeeUsrID (UsrDat)); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>"); fprintf (Gbl.F.Out,"&nbsp;</td>");
/***** Write rest of main teacher's data *****/ /***** Write rest of main teacher's data *****/
Ins.InsCod = UsrDat->InsCod; Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],ShowData,NULL,Ins.ShortName,NULL); Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],
Ins.ShortName,NULL);
/***** Write the rest of teacher's data *****/ /***** Write the rest of teacher's data *****/
if (ShowData && UsrDat->Tch.CtrCod > 0) if (ShowData && UsrDat->Tch.CtrCod > 0)
@ -3242,14 +3226,13 @@ void Usr_WriteRowTchAllData (struct UsrData *UsrDat)
} }
/*****************************************************************************/ /*****************************************************************************/
/*** Write a row of a table with the data of a teacher or an administrator ***/ /********** Write a row of a table with the data of an administrator *********/
/*****************************************************************************/ /*****************************************************************************/
void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat) void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat)
{ {
char PhotoURL[PATH_MAX+1]; char PhotoURL[PATH_MAX+1];
bool ShowPhoto; bool ShowPhoto;
char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address
struct Institution Ins; struct Institution Ins;
/***** Start row *****/ /***** Start row *****/
@ -3273,26 +3256,21 @@ void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat)
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
} }
/***** Prepare data for brief presentation *****/
Usr_RestrictLengthMainData (true,UsrDat,MailLink);
/****** Write the user's ID ******/ /****** Write the user's ID ******/
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE COLOR%u\">", fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE COLOR%u\">",
UsrDat->Accepted ? "DAT_SMALL_N" : UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL", "DAT_SMALL",
Gbl.RowEvenOdd); Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)); ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>"); fprintf (Gbl.F.Out,"&nbsp;</td>");
/***** Write rest of main administrator's data *****/ /***** Write rest of main administrator's data *****/
Ins.InsCod = UsrDat->InsCod; Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA); Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],true, Usr_RestrictLengthUsrName (UsrDat);
UsrDat->Email[0] ? MailLink : Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],
NULL, Ins.ShortName,Ins.WWW[0] ? Ins.WWW :
Ins.ShortName, NULL);
Ins.WWW[0] ? Ins.WWW :
NULL);
fprintf (Gbl.F.Out,"</tr>"); fprintf (Gbl.F.Out,"</tr>");
/***** Write degrees which are administrated by this administrator *****/ /***** Write degrees which are administrated by this administrator *****/
@ -3304,29 +3282,28 @@ void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat)
} }
/*****************************************************************************/ /*****************************************************************************/
/************** Restrict the length of the main data of a user ***************/ /***************** Restrict the length of the user's name ********************/
/*****************************************************************************/ /*****************************************************************************/
void Usr_RestrictLengthMainData (bool ShowData,struct UsrData *UsrDat,char *MailLink) static void Usr_RestrictLengthUsrName (struct UsrData *UsrDat)
{ {
Str_LimitLengthHTMLStr (UsrDat->FirstName,10); Str_LimitLengthHTMLStr (UsrDat->FirstName,10);
Str_LimitLengthHTMLStr (UsrDat->Surname1,10); Str_LimitLengthHTMLStr (UsrDat->Surname1,10);
Str_LimitLengthHTMLStr (UsrDat->Surname2,10); Str_LimitLengthHTMLStr (UsrDat->Surname2,10);
if (ShowData && UsrDat->Email[0])
{
sprintf (MailLink,"mailto:%s",UsrDat->Email);
Str_LimitLengthHTMLStr (UsrDat->Email,10);
}
} }
/*****************************************************************************/ /*****************************************************************************/
/************************* Write main data of a user *************************/ /************************* Write main data of a user *************************/
/*****************************************************************************/ /*****************************************************************************/
static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char *BgColor,bool ShowEmail, static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,
const char *MailLink, const char *BgColor,
const char *InstitutionName,const char *InstitutionLink) const char *InstitutionName,
const char *InstitutionLink)
{ {
bool ShowEmail;
char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address
Usr_WriteUsrData (BgColor, Usr_WriteUsrData (BgColor,
UsrDat->Surname1[0] ? UsrDat->Surname1 : UsrDat->Surname1[0] ? UsrDat->Surname1 :
"&nbsp;", "&nbsp;",
@ -3339,6 +3316,14 @@ static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char *
UsrDat->FirstName[0] ? UsrDat->FirstName : UsrDat->FirstName[0] ? UsrDat->FirstName :
"&nbsp;", "&nbsp;",
NULL,true,UsrDat->Accepted); NULL,true,UsrDat->Accepted);
if (UsrDat->Email[0])
{
ShowEmail = Mai_ICanSeeEmail (UsrDat);
sprintf (MailLink,"mailto:%s",UsrDat->Email);
Str_LimitLengthHTMLStr (UsrDat->Email,10);
}
else
ShowEmail = false;
Usr_WriteUsrData (BgColor, Usr_WriteUsrData (BgColor,
UsrDat->Email[0] ? (ShowEmail ? UsrDat->Email : UsrDat->Email[0] ? (ShowEmail ? UsrDat->Email :
"********") : "********") :
@ -3356,7 +3341,9 @@ static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char *
/********************* Write a cell with data of a user **********************/ /********************* Write a cell with data of a user **********************/
/*****************************************************************************/ /*****************************************************************************/
static void Usr_WriteUsrData (const char *BgColor,const char *Data,const char *Link,bool NonBreak,bool Accepted) static void Usr_WriteUsrData (const char *BgColor,
const char *Data,const char *Link,
bool NonBreak,bool Accepted)
{ {
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">", fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">",
Accepted ? (NonBreak ? "DAT_SMALL_NOBR_N" : Accepted ? (NonBreak ? "DAT_SMALL_NOBR_N" :

View File

@ -271,10 +271,10 @@ bool Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (struct UsrData *UsrDat);
void Usr_UpdateMyLastData (void); void Usr_UpdateMyLastData (void);
void Usr_InsertMyLastCrsTabAndTime (void); void Usr_InsertMyLastCrsTabAndTime (void);
void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutCheckboxToSelectUsr); void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,
bool PutCheckboxToSelectUsr);
void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GrpNames); void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GrpNames);
void Usr_WriteRowTchAllData (struct UsrData *UsrDat); void Usr_WriteRowTchAllData (struct UsrData *UsrDat);
void Usr_RestrictLengthMainData (bool ShowData,struct UsrData *UsrDat,char *MailLink);
unsigned Usr_GetNumUsrsInCrs (Rol_Role_t Role,long CrsCod); unsigned Usr_GetNumUsrsInCrs (Rol_Role_t Role,long CrsCod);
unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod); unsigned Usr_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod);