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_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 *********************************/
.REC_SHORTCUTS
{

View File

@ -345,26 +345,27 @@ static bool ID_CheckIfUsrIDIsValidUsingMinDigits (const char *UsrID,unsigned Min
/*************************** Write list of user's ID *************************/
/*****************************************************************************/
void ID_WriteUsrIDs (struct UsrData *UsrDat,bool ICanSeeUsrID)
void ID_WriteUsrIDs (struct UsrData *UsrDat)
{
unsigned NumID;
bool ICanSeeUsrID = ID_ICanSeeUsrID (UsrDat);
if (ICanSeeUsrID)
for (NumID = 0;
NumID < UsrDat->IDs.Num;
NumID++)
{
if (NumID)
fprintf (Gbl.F.Out,"<br />");
for (NumID = 0;
NumID < UsrDat->IDs.Num;
NumID++)
{
if (NumID)
fprintf (Gbl.F.Out,"<br />");
if (!UsrDat->IDs.List[NumID].Confirmed)
fprintf (Gbl.F.Out,"<span style=\"color:#804040;\">");
fprintf (Gbl.F.Out,"<span class=\"%s\">",
UsrDat->IDs.List[NumID].Confirmed ? "USR_ID_C" :
"USR_ID_NC");
if (ICanSeeUsrID)
fprintf (Gbl.F.Out,"%s",UsrDat->IDs.List[NumID].ID);
if (!UsrDat->IDs.List[NumID].Confirmed)
fprintf (Gbl.F.Out,"</span>");
}
else
fprintf (Gbl.F.Out,"********");
else
fprintf (Gbl.F.Out,"********");
fprintf (Gbl.F.Out,"</span>");
}
}
/*****************************************************************************/
@ -824,13 +825,19 @@ void ID_ConfirmUsrID (long UsrCod,const char *UsrID)
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->RoleInCurrentCrsDB == Rol_STUDENT);
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 */

View File

@ -64,7 +64,7 @@ void ID_GetParamOtherUsrIDPlain (void);
bool ID_CheckIfUsrIDIsValid (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_ShowFormOthIDs (void);

View File

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

View File

@ -137,13 +137,17 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.201.8 (2016-04-22)"
#define CSS_FILE "swad15.198.css"
#define Log_PLATFORM_VERSION "SWAD 15.202 (2016-04-23)"
#define CSS_FILE "swad15.202.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.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.
Fixed bugs in record cards. (200881 lines)
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);
/***** Show user's ID *****/
ID_WriteUsrIDs (UsrDat,
UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ID_ICanSeeUsrID (UsrDat) :
(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER));
ID_WriteUsrIDs (UsrDat);
/***** Show user's name *****/
fprintf (Gbl.F.Out,"<br />");

View File

@ -1558,3 +1558,47 @@ void Mai_WriteFootNoteEMail (Txt_Language_t Language)
Cfg_PLATFORM_SHORT_NAME,
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_WriteFootNoteEMail (Txt_Language_t Language);
bool Mai_ICanSeeEmail (struct UsrData *UsrDat);
#endif

View File

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

View File

@ -98,10 +98,10 @@ static void Rec_ShowEmail (struct UsrData *UsrDat,
Rec_RecordViewType_t TypeOfView,
bool DataForm,
const char *ClassForm);
static void Rec_ShowUsrIDs (struct UsrData *UsrDat,
Rec_RecordViewType_t TypeOfView,
bool DataForm,
const char *ClassForm);
static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm);
static void Rec_ShowRole (struct UsrData *UsrDat,
Rec_RecordViewType_t TypeOfView,
const char *ClassForm);
static void Rec_WriteLinkToDataProtectionClause (void);
@ -1963,12 +1963,7 @@ void Rec_ShowCommonRecordUnmodifiable (struct UsrData *UsrDat)
void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView,
struct UsrData *UsrDat)
{
extern const char *Usr_StringsSexDB[Usr_NUM_SEXS];
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_2;
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 IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser
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 ||
TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_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_PRINT) &&
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;
struct Institution Ins;
struct Centre Ctr;
@ -2118,195 +2106,10 @@ void Rec_ShowSharedUsrRecord (Rec_RecordViewType_t TypeOfView,
Rec_ShowEmail (UsrDat,TypeOfView,DataForm,ClassForm);
/***** User's ID *****/
Rec_ShowUsrIDs (UsrDat,TypeOfView,DataForm,ClassForm);
Rec_ShowUsrIDs (UsrDat,ClassForm);
/***** User's role or 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]);
Rec_ShowRole (UsrDat,TypeOfView,ClassForm);
/***** Name *****/
/* Surname 1 */
@ -3236,29 +3039,9 @@ static void Rec_ShowEmail (struct UsrData *UsrDat,
/******************************* Show user's IDs *****************************/
/*****************************************************************************/
static void Rec_ShowUsrIDs (struct UsrData *UsrDat,
Rec_RecordViewType_t TypeOfView,
bool DataForm,
const char *ClassForm)
static void Rec_ShowUsrIDs (struct UsrData *UsrDat,const char *ClassForm)
{
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>"
"<td class=\"%s RIGHT_TOP\""
@ -3269,11 +3052,220 @@ static void Rec_ShowUsrIDs (struct UsrData *UsrDat,
" style=\"width:%upx;\">",
ClassForm,Rec_C1_BOTTOM,Txt_ID,
Rec_C2_BOTTOM);
ID_WriteUsrIDs (UsrDat,ShowID);
ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"</td>"
"</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 ********************/
/*****************************************************************************/

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 */
fprintf (Gbl.F.Out,"<td class=\"LOG CENTER_TOP COLOR%u\">",
Gbl.RowEvenOdd);
ID_WriteUsrIDs (&UsrDat,(RoleFromLog == Rol_STUDENT));
ID_WriteUsrIDs (&UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>");
/* 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 */
fprintf (Gbl.F.Out,"<td class=\"LOG CENTER_TOP COLOR%u\">",
Gbl.RowEvenOdd);
ID_WriteUsrIDs (&UsrDat,(UsrDat.RoleInCurrentCrsDB == Rol_STUDENT));
ID_WriteUsrIDs (&UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>");
/* 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");
/***** Show user's ID *****/
ID_WriteUsrIDs (UsrDat,
(UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ID_ICanSeeUsrID (UsrDat) :
(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER)));
ID_WriteUsrIDs (UsrDat);
/***** Show user's name *****/
fprintf (Gbl.F.Out,"<br />%s",UsrDat->Surname1);
@ -7454,7 +7452,7 @@ void Tst_ShowOneTestExam (void)
"</td>"
"<td class=\"DAT LEFT_TOP\">",
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",
Gbl.Usrs.Other.UsrDat.Surname1);
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_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_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char *BgColor,bool ShowEmail,
const char *MailLink,
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_RestrictLengthUsrName (struct UsrData *UsrDat);
static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,
const char *BgColor,
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_GetAdmsLst (Sco_Scope_t Scope);
@ -2686,7 +2691,6 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat)
{
char PhotoURL[PATH_MAX+1];
bool ShowPhoto;
char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address
struct Institution Ins;
/***** Start row *****/
@ -2699,7 +2703,7 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat)
Usr_PutCheckboxToSelectUser (UsrDat,false);
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\">"
"<img src=\"%s/tr16x16.gif\""
" alt=\"\" title=\"\""
@ -2716,7 +2720,7 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat)
if (Gbl.Usrs.Listing.WithPhotos)
{
/***** Show student's photo *****/
/***** Show guest's photo *****/
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE COLOR%u\">",
Gbl.RowEvenOdd);
ShowPhoto = Pho_ShowUsrPhotoIsAllowed (UsrDat,PhotoURL);
@ -2726,26 +2730,21 @@ static void Usr_WriteRowGstMainData (unsigned NumUsr,struct UsrData *UsrDat)
fprintf (Gbl.F.Out,"</td>");
}
/***** Prepare data for brief presentation *****/
Usr_RestrictLengthMainData (true,UsrDat,MailLink);
/****** Write user's IDs ******/
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE COLOR%u\">",
UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL",
Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER));
ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"</td>");
/***** Write rest of main student's data *****/
/***** Write rest of main guest's data *****/
Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],true,
UsrDat->Email[0] ? MailLink :
NULL,
Ins.ShortName,
Ins.WWW[0] ? Ins.WWW :
NULL);
Usr_RestrictLengthUsrName (UsrDat);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],
Ins.ShortName,Ins.WWW[0] ? Ins.WWW :
NULL);
/***** End row *****/
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 **************/
/*****************************************************************************/
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_not_confirmed;
@ -2765,11 +2765,7 @@ void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutChe
char PhotoURL[PATH_MAX+1];
bool ShowPhoto;
bool UsrIsTheMsgSender = false;
char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address
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 *****/
fprintf (Gbl.F.Out,"<tr>");
@ -2828,26 +2824,21 @@ void Usr_WriteRowStdMainData (unsigned NumUsr,struct UsrData *UsrDat,bool PutChe
fprintf (Gbl.F.Out,"</td>");
}
/***** Prepare data for brief presentation *****/
Usr_RestrictLengthMainData (ShowEmail,UsrDat,MailLink);
/****** Write user's ID ******/
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">",
UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL",
BgColor);
ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER));
ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"</td>");
/***** Write rest of main student's data *****/
Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor,ShowEmail,
UsrDat->Email[0] ? MailLink :
NULL,
Ins.ShortName,
Ins.WWW[0] ? Ins.WWW :
NULL);
Usr_RestrictLengthUsrName (UsrDat);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor,
Ins.ShortName,Ins.WWW[0] ? Ins.WWW :
NULL);
/***** End row *****/
fprintf (Gbl.F.Out,"</tr>");
@ -2885,14 +2876,14 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat)
/****** Write user's ID ******/
fprintf (Gbl.F.Out,"<td class=\"DAT_SMALL LEFT_MIDDLE COLOR%u\">",
Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,true);
ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>");
/***** Write rest of guest's main data *****/
Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],true,
NULL,Ins.ShortName,NULL);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],
Ins.ShortName,NULL);
/***** Write the rest of the data of the guest *****/
if (UsrDat->Tch.CtrCod > 0)
@ -2966,8 +2957,7 @@ void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames)
char Text[Cns_MAX_BYTES_TEXT+1];
struct Institution Ins;
bool ShowData = (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER && UsrDat->Accepted) ||
Gbl.Usrs.Me.LoggedRole == Rol_DEG_ADM ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM;
Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM;
/***** Start row *****/
fprintf (Gbl.F.Out,"<tr>");
@ -2989,13 +2979,14 @@ void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames)
UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL",
Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER));
ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>");
/***** Write rest of main student's data *****/
Ins.InsCod = UsrDat->InsCod;
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 *****/
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 *************/
/*****************************************************************************/
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_not_confirmed;
@ -3082,11 +3074,7 @@ static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool
bool ShowPhoto;
bool UsrIsTheMsgSender = PutCheckBoxToSelectUsr &&
(UsrDat->UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod);
char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address
struct Institution Ins;
bool ShowEmail = UsrDat->Accepted ||
Gbl.Usrs.Me.LoggedRole == Rol_DEG_ADM ||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM;
/***** Start row *****/
fprintf (Gbl.F.Out,"<tr>");
@ -3139,27 +3127,22 @@ static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool
fprintf (Gbl.F.Out,"</td>");
}
/***** Prepare data for brief presentation *****/
Usr_RestrictLengthMainData (ShowEmail,UsrDat,MailLink);
/****** Write the user's ID ******/
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE %s\">",
UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL",
BgColor);
ID_WriteUsrIDs (UsrDat,ID_ICanSeeUsrID (UsrDat));
ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"&nbsp;");
fprintf (Gbl.F.Out,"</td>");
/***** Write rest of main teacher's data *****/
Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor,ShowEmail,
UsrDat->Email[0] ? MailLink :
NULL,
Ins.ShortName,
Ins.WWW[0] ? Ins.WWW :
NULL);
Usr_RestrictLengthUsrName (UsrDat);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,BgColor,
Ins.ShortName,Ins.WWW[0] ? Ins.WWW :
NULL);
fprintf (Gbl.F.Out,"</tr>");
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
@ -3200,13 +3183,14 @@ void Usr_WriteRowTchAllData (struct UsrData *UsrDat)
UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL",
Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,ID_ICanSeeUsrID (UsrDat));
ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>");
/***** Write rest of main teacher's data *****/
Ins.InsCod = UsrDat->InsCod;
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 *****/
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)
{
char PhotoURL[PATH_MAX+1];
bool ShowPhoto;
char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address
struct Institution Ins;
/***** Start row *****/
@ -3273,26 +3256,21 @@ void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat)
fprintf (Gbl.F.Out,"</td>");
}
/***** Prepare data for brief presentation *****/
Usr_RestrictLengthMainData (true,UsrDat,MailLink);
/****** Write the user's ID ******/
fprintf (Gbl.F.Out,"<td class=\"%s LEFT_MIDDLE COLOR%u\">",
UsrDat->Accepted ? "DAT_SMALL_N" :
"DAT_SMALL",
Gbl.RowEvenOdd);
ID_WriteUsrIDs (UsrDat,(Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM));
ID_WriteUsrIDs (UsrDat);
fprintf (Gbl.F.Out,"&nbsp;</td>");
/***** Write rest of main administrator's data *****/
Ins.InsCod = UsrDat->InsCod;
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_BASIC_DATA);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],true,
UsrDat->Email[0] ? MailLink :
NULL,
Ins.ShortName,
Ins.WWW[0] ? Ins.WWW :
NULL);
Usr_RestrictLengthUsrName (UsrDat);
Usr_WriteMainUsrDataExceptUsrID (UsrDat,Gbl.ColorRows[Gbl.RowEvenOdd],
Ins.ShortName,Ins.WWW[0] ? Ins.WWW :
NULL);
fprintf (Gbl.F.Out,"</tr>");
/***** 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->Surname1,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 *************************/
/*****************************************************************************/
static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char *BgColor,bool ShowEmail,
const char *MailLink,
const char *InstitutionName,const char *InstitutionLink)
static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,
const char *BgColor,
const char *InstitutionName,
const char *InstitutionLink)
{
bool ShowEmail;
char MailLink[7+Usr_MAX_BYTES_USR_EMAIL+1]; // mailto:mail_address
Usr_WriteUsrData (BgColor,
UsrDat->Surname1[0] ? UsrDat->Surname1 :
"&nbsp;",
@ -3339,6 +3316,14 @@ static void Usr_WriteMainUsrDataExceptUsrID (struct UsrData *UsrDat,const char *
UsrDat->FirstName[0] ? UsrDat->FirstName :
"&nbsp;",
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,
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 **********************/
/*****************************************************************************/
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\">",
Accepted ? (NonBreak ? "DAT_SMALL_NOBR_N" :

View File

@ -271,10 +271,10 @@ bool Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (struct UsrData *UsrDat);
void Usr_UpdateMyLastData (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_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_GetNumUsrsInCrssOfDeg (Rol_Role_t Role,long DegCod);