mirror of https://github.com/acanas/swad-core.git
Version 16.220.11
This commit is contained in:
parent
f266182842
commit
a49cf929dc
|
@ -461,7 +461,7 @@ static void ID_PutLinkToConfirmID (struct UsrData *UsrDat,unsigned NumID,
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
NextAction = ActCnfID_Tch;
|
NextAction = ActCnfID_Tch;
|
||||||
break;
|
break;
|
||||||
default: // Guest, visitor or admin
|
default: // Guest, user or admin
|
||||||
NextAction = ActCnfID_Oth;
|
NextAction = ActCnfID_Oth;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -521,7 +521,7 @@ void ID_PutLinkToChangeUsrIDs (void)
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
NextAction = ActFrmIDsTch;
|
NextAction = ActFrmIDsTch;
|
||||||
break;
|
break;
|
||||||
default: // Guest, visitor or admin
|
default: // Guest, user or admin
|
||||||
NextAction = ActFrmIDsOth;
|
NextAction = ActFrmIDsOth;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -623,7 +623,7 @@ void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,bool ItsMe)
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
NextAction = ActRemID_Tch;
|
NextAction = ActRemID_Tch;
|
||||||
break;
|
break;
|
||||||
default: // Guest, visitor or admin
|
default: // Guest, user or admin
|
||||||
NextAction = ActRemID_Oth;
|
NextAction = ActRemID_Oth;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -688,7 +688,7 @@ void ID_ShowFormChangeUsrID (const struct UsrData *UsrDat,bool ItsMe)
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
NextAction = ActNewID_Tch;
|
NextAction = ActNewID_Tch;
|
||||||
break;
|
break;
|
||||||
default: // Guest, visitor or admin
|
default: // Guest, user or admin
|
||||||
NextAction = ActNewID_Oth;
|
NextAction = ActNewID_Oth;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -233,13 +233,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 16.220.10 (2017-05-22)"
|
#define Log_PLATFORM_VERSION "SWAD 16.220.11 (2017-05-22)"
|
||||||
#define CSS_FILE "swad16.209.3.css"
|
#define CSS_FILE "swad16.209.3.css"
|
||||||
#define JS_FILE "swad16.206.3.js"
|
#define JS_FILE "swad16.206.3.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 16.220.11:May 22, 2017 Changes related with new role. Not finished. (220019 lines)
|
||||||
Version 16.220.10:May 22, 2017 Changes related with new role. Not finished. (219775 lines)
|
Version 16.220.10:May 22, 2017 Changes related with new role. Not finished. (219775 lines)
|
||||||
Version 16.220.9: May 22, 2017 Changes related with new role. Not finished. (219720 lines)
|
Version 16.220.9: May 22, 2017 Changes related with new role. Not finished. (219720 lines)
|
||||||
Version 16.220.8: May 22, 2017 Changes related with new role. Not finished. (219663 lines)
|
Version 16.220.8: May 22, 2017 Changes related with new role. Not finished. (219663 lines)
|
||||||
|
|
|
@ -55,7 +55,7 @@ static const bool Enr_ICanAdminOtherUsrs[Rol_NUM_ROLES] =
|
||||||
false, // Rol_GST
|
false, // Rol_GST
|
||||||
false, // Rol_USR
|
false, // Rol_USR
|
||||||
false, // Rol_STD
|
false, // Rol_STD
|
||||||
false, // Rol_NED_TCH
|
false, // Rol_NET
|
||||||
|
|
||||||
/* Users who can admin */
|
/* Users who can admin */
|
||||||
true, // Rol_TCH
|
true, // Rol_TCH
|
||||||
|
|
|
@ -1115,7 +1115,7 @@ const unsigned long long Brw_MAX_QUOTA_BRIEF[Rol_NUM_ROLES] = // MaxRole is used
|
||||||
0, // Rol_GST
|
0, // Rol_GST
|
||||||
0, // Rol_USR
|
0, // Rol_USR
|
||||||
32ULL*Brw_GiB, // Rol_STD
|
32ULL*Brw_GiB, // Rol_STD
|
||||||
32ULL*Brw_GiB, // Rol_NED_TCH
|
32ULL*Brw_GiB, // Rol_NET
|
||||||
64ULL*Brw_GiB, // Rol_TCH
|
64ULL*Brw_GiB, // Rol_TCH
|
||||||
0, // Rol_DEG_ADM
|
0, // Rol_DEG_ADM
|
||||||
0, // Rol_CTR_ADM
|
0, // Rol_CTR_ADM
|
||||||
|
|
83
swad_mail.c
83
swad_mail.c
|
@ -1127,6 +1127,7 @@ long Mai_GetUsrCodFromEmail (const char Email[Cns_MAX_BYTES_EMAIL_ADDRESS + 1])
|
||||||
void Mai_PutLinkToChangeOtherUsrEmails (void)
|
void Mai_PutLinkToChangeOtherUsrEmails (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Change_email;
|
extern const char *Txt_Change_email;
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Link for changing the password *****/
|
/***** Link for changing the password *****/
|
||||||
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
|
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
|
||||||
|
@ -1135,13 +1136,26 @@ void Mai_PutLinkToChangeOtherUsrEmails (void)
|
||||||
Txt_Change_email,Txt_Change_email,
|
Txt_Change_email,Txt_Change_email,
|
||||||
NULL);
|
NULL);
|
||||||
else // Not me
|
else // Not me
|
||||||
Lay_PutContextualLink ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActFrmMaiStd :
|
{
|
||||||
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActFrmMaiTch :
|
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
|
||||||
ActFrmMaiOth),
|
{
|
||||||
NULL,Usr_PutParamOtherUsrCodEncrypted,
|
case Rol_STD:
|
||||||
|
NextAction = ActFrmMaiStd;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActFrmMaiTch;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActFrmMaiOth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Lay_PutContextualLink (NextAction,NULL,
|
||||||
|
Usr_PutParamOtherUsrCodEncrypted,
|
||||||
"msg64x64.gif",
|
"msg64x64.gif",
|
||||||
Txt_Change_email,Txt_Change_email,
|
Txt_Change_email,Txt_Change_email,
|
||||||
NULL);
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -1203,6 +1217,7 @@ void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe)
|
||||||
unsigned NumEmails;
|
unsigned NumEmails;
|
||||||
unsigned NumEmail;
|
unsigned NumEmail;
|
||||||
bool Confirmed;
|
bool Confirmed;
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Get my emails *****/
|
/***** Get my emails *****/
|
||||||
sprintf (Query,"SELECT E_mail,Confirmed FROM usr_emails"
|
sprintf (Query,"SELECT E_mail,Confirmed FROM usr_emails"
|
||||||
|
@ -1248,9 +1263,20 @@ void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe)
|
||||||
Act_FormStart (ActRemMaiMe);
|
Act_FormStart (ActRemMaiMe);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActRemMaiStd :
|
switch (UsrDat->RoleInCurrentCrsDB)
|
||||||
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActRemMaiTch :
|
{
|
||||||
ActRemMaiOth)); // Guest, visitor or admin
|
case Rol_STD:
|
||||||
|
NextAction = ActRemMaiStd;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActRemMaiTch;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActRemMaiOth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Act_FormStart (NextAction);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
||||||
}
|
}
|
||||||
fprintf (Gbl.F.Out,"<input type=\"hidden\" name=\"Email\" value=\"%s\" />",
|
fprintf (Gbl.F.Out,"<input type=\"hidden\" name=\"Email\" value=\"%s\" />",
|
||||||
|
@ -1284,9 +1310,20 @@ void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe)
|
||||||
Act_FormStart (ActNewMaiMe);
|
Act_FormStart (ActNewMaiMe);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActNewMaiStd :
|
switch (UsrDat->RoleInCurrentCrsDB)
|
||||||
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActNewMaiTch :
|
{
|
||||||
ActNewMaiOth)); // Guest, visitor or admin
|
case Rol_STD:
|
||||||
|
NextAction = ActNewMaiStd;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActNewMaiTch;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActNewMaiOth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Act_FormStart (NextAction);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
||||||
}
|
}
|
||||||
fprintf (Gbl.F.Out,"<input type=\"hidden\" name=\"NewEmail\" value=\"%s\" />",
|
fprintf (Gbl.F.Out,"<input type=\"hidden\" name=\"NewEmail\" value=\"%s\" />",
|
||||||
|
@ -1314,9 +1351,20 @@ void Mai_ShowFormChangeUsrEmail (const struct UsrData *UsrDat,bool ItsMe)
|
||||||
Act_FormStart (ActNewMaiMe);
|
Act_FormStart (ActNewMaiMe);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActNewMaiStd :
|
switch (UsrDat->RoleInCurrentCrsDB)
|
||||||
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActNewMaiTch :
|
{
|
||||||
ActNewMaiOth)); // Guest, visitor or admin
|
case Rol_STD:
|
||||||
|
NextAction = ActNewMaiStd;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActNewMaiTch;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActNewMaiOth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Act_FormStart (NextAction);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
||||||
}
|
}
|
||||||
fprintf (Gbl.F.Out,"<div class=\"FORM_ACCOUNT\">"
|
fprintf (Gbl.F.Out,"<div class=\"FORM_ACCOUNT\">"
|
||||||
|
@ -1832,18 +1880,21 @@ bool Mai_ICanSeeOtherUsrEmail (const struct UsrData *UsrDat)
|
||||||
if (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
|
if (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* Check if I have permission to see another user's email */
|
/***** Check if I have permission to see another user's email *****/
|
||||||
switch (Gbl.Usrs.Me.LoggedRole)
|
switch (Gbl.Usrs.Me.LoggedRole)
|
||||||
{
|
{
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
/* If I am a student in the current course,
|
/* If I am a student in the current course,
|
||||||
I can see the email of confirmed teachers */
|
I can see the email of confirmed teachers */
|
||||||
return (UsrDat->RoleInCurrentCrsDB == Rol_TCH && // A teacher
|
return (UsrDat->RoleInCurrentCrsDB == Rol_NET || // A non-editing teacher
|
||||||
UsrDat->Accepted); // who accepted registration
|
UsrDat->RoleInCurrentCrsDB == Rol_TCH) && // or a teacher
|
||||||
|
UsrDat->Accepted; // who accepted registration
|
||||||
|
case Rol_NET:
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
/* If I am a teacher in the current course,
|
/* If I am a teacher in the current course,
|
||||||
I can see the email of confirmed students and teachers */
|
I can see the email of confirmed students and teachers */
|
||||||
return (UsrDat->RoleInCurrentCrsDB == Rol_STD || // A student
|
return (UsrDat->RoleInCurrentCrsDB == Rol_STD || // A student
|
||||||
|
UsrDat->RoleInCurrentCrsDB == Rol_NET || // or a non-editing teacher
|
||||||
UsrDat->RoleInCurrentCrsDB == Rol_TCH) && // or a teacher
|
UsrDat->RoleInCurrentCrsDB == Rol_TCH) && // or a teacher
|
||||||
UsrDat->Accepted; // who accepted registration
|
UsrDat->Accepted; // who accepted registration
|
||||||
case Rol_DEG_ADM:
|
case Rol_DEG_ADM:
|
||||||
|
|
|
@ -624,7 +624,7 @@ void Mrk_ShowMyMarks (void)
|
||||||
/***** Set the student whose marks will be shown *****/
|
/***** Set the student whose marks will be shown *****/
|
||||||
if (Gbl.Usrs.Me.LoggedRole == Rol_STD) // If I am logged as student...
|
if (Gbl.Usrs.Me.LoggedRole == Rol_STD) // If I am logged as student...
|
||||||
UsrDat = &Gbl.Usrs.Me.UsrDat; // ...use my list of IDs
|
UsrDat = &Gbl.Usrs.Me.UsrDat; // ...use my list of IDs
|
||||||
else // If I am logged as teacher, administrator, superuser...
|
else // If I am logged as non-editing teacher, teacher or admin
|
||||||
{
|
{
|
||||||
/* Select a random student from the course */
|
/* Select a random student from the course */
|
||||||
if (Gbl.CurrentCrs.Grps.GrpCod > 0) // Group zone
|
if (Gbl.CurrentCrs.Grps.GrpCod > 0) // Group zone
|
||||||
|
|
|
@ -181,8 +181,9 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
|
||||||
bool ShowUsrsInCrs = false;
|
bool ShowUsrsInCrs = false;
|
||||||
bool GetUsrsInCrs;
|
bool GetUsrsInCrs;
|
||||||
|
|
||||||
Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs =
|
Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs =
|
||||||
Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs = 0;
|
Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs =
|
||||||
|
Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs = 0;
|
||||||
|
|
||||||
/***** Get parameter that indicates if the message is a reply to another message *****/
|
/***** Get parameter that indicates if the message is a reply to another message *****/
|
||||||
if ((Gbl.Msg.Reply.IsReply = Par_GetParToBool ("IsReply")))
|
if ((Gbl.Msg.Reply.IsReply = Par_GetParToBool ("IsReply")))
|
||||||
|
@ -213,10 +214,12 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
|
||||||
Grp_GetParCodsSeveralGrpsToShowUsrs ();
|
Grp_GetParCodsSeveralGrpsToShowUsrs ();
|
||||||
|
|
||||||
/***** Get and order lists of users from this course *****/
|
/***** Get and order lists of users from this course *****/
|
||||||
Usr_GetListUsrs (Rol_TCH,Sco_SCOPE_CRS);
|
|
||||||
Usr_GetListUsrs (Rol_STD,Sco_SCOPE_CRS);
|
Usr_GetListUsrs (Rol_STD,Sco_SCOPE_CRS);
|
||||||
NumUsrsInCrs = Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs +
|
Usr_GetListUsrs (Rol_NET,Sco_SCOPE_CRS);
|
||||||
Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs;
|
Usr_GetListUsrs (Rol_TCH,Sco_SCOPE_CRS);
|
||||||
|
NumUsrsInCrs = Gbl.Usrs.LstUsrs[Rol_STD].NumUsrs + // Students
|
||||||
|
Gbl.Usrs.LstUsrs[Rol_NET].NumUsrs + // Non-editing teachers
|
||||||
|
Gbl.Usrs.LstUsrs[Rol_TCH].NumUsrs; // Teachers
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Start frame *****/
|
/***** Start frame *****/
|
||||||
|
@ -288,6 +291,7 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
|
||||||
if (ShowUsrsInCrs)
|
if (ShowUsrsInCrs)
|
||||||
{
|
{
|
||||||
Usr_ListUsersToSelect (Rol_TCH); // All teachers in course
|
Usr_ListUsersToSelect (Rol_TCH); // All teachers in course
|
||||||
|
Usr_ListUsersToSelect (Rol_NET); // All non-editing teachers in course
|
||||||
Usr_ListUsersToSelect (Rol_STD); // All students in selected groups
|
Usr_ListUsersToSelect (Rol_STD); // All students in selected groups
|
||||||
}
|
}
|
||||||
Msg_WriteFormUsrsIDsOrNicksOtherRecipients (); // Other users (nicknames)
|
Msg_WriteFormUsrsIDsOrNicksOtherRecipients (); // Other users (nicknames)
|
||||||
|
@ -325,6 +329,7 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1])
|
||||||
if (GetUsrsInCrs)
|
if (GetUsrsInCrs)
|
||||||
{
|
{
|
||||||
Usr_FreeUsrsList (Rol_TCH);
|
Usr_FreeUsrsList (Rol_TCH);
|
||||||
|
Usr_FreeUsrsList (Rol_NET);
|
||||||
Usr_FreeUsrsList (Rol_STD);
|
Usr_FreeUsrsList (Rol_STD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -813,6 +813,7 @@ void Pwd_ShowFormOthPwd (void)
|
||||||
extern const char *Txt_Password;
|
extern const char *Txt_Password;
|
||||||
extern const char *Txt_Change_password;
|
extern const char *Txt_Change_password;
|
||||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Get user whose password must be changed *****/
|
/***** Get user whose password must be changed *****/
|
||||||
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
|
||||||
|
@ -828,9 +829,20 @@ void Pwd_ShowFormOthPwd (void)
|
||||||
|
|
||||||
/***** Form to change password *****/
|
/***** Form to change password *****/
|
||||||
/* Start form */
|
/* Start form */
|
||||||
Act_FormStart ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActChgPwdStd :
|
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
|
||||||
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActChgPwdTch :
|
{
|
||||||
ActChgPwdOth));
|
case Rol_STD:
|
||||||
|
NextAction = ActChgPwdStd;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActChgPwdTch;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActChgPwdOth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Act_FormStart (NextAction);
|
||||||
Usr_PutParamOtherUsrCodEncrypted ();
|
Usr_PutParamOtherUsrCodEncrypted ();
|
||||||
|
|
||||||
/* New password */
|
/* New password */
|
||||||
|
@ -874,18 +886,32 @@ void Pwd_PutLinkToChangeMyPassword (void)
|
||||||
void Pwd_PutLinkToChangeOtherUsrPassword (void)
|
void Pwd_PutLinkToChangeOtherUsrPassword (void)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Change_password;
|
extern const char *Txt_Change_password;
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Link for changing the password *****/
|
/***** Link for changing the password *****/
|
||||||
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
|
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
|
||||||
Pwd_PutLinkToChangeMyPassword ();
|
Pwd_PutLinkToChangeMyPassword ();
|
||||||
else // Not me
|
else // Not me
|
||||||
Lay_PutContextualLink ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActFrmPwdStd :
|
{
|
||||||
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActFrmPwdTch :
|
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
|
||||||
ActFrmPwdOth),
|
{
|
||||||
NULL,Usr_PutParamOtherUsrCodEncrypted,
|
case Rol_STD:
|
||||||
|
NextAction = ActFrmPwdStd;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActFrmPwdTch;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActFrmPwdOth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Lay_PutContextualLink (NextAction,NULL,
|
||||||
|
Usr_PutParamOtherUsrCodEncrypted,
|
||||||
"key64x64.gif",
|
"key64x64.gif",
|
||||||
Txt_Change_password,Txt_Change_password,
|
Txt_Change_password,Txt_Change_password,
|
||||||
NULL);
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
109
swad_photo.c
109
swad_photo.c
|
@ -140,9 +140,9 @@ bool Pho_ICanChangeOtherUsrPhoto (const struct UsrData *UsrDat)
|
||||||
switch (Gbl.Usrs.Me.LoggedRole)
|
switch (Gbl.Usrs.Me.LoggedRole)
|
||||||
{
|
{
|
||||||
case Rol_TCH:
|
case Rol_TCH:
|
||||||
/* Check 1: I can change the photo of confirmed students */
|
/* A teacher can change the photo of confirmed students */
|
||||||
if (UsrDat->RoleInCurrentCrsDB == Rol_STD && // A student
|
if (UsrDat->RoleInCurrentCrsDB == Rol_STD && // A student
|
||||||
UsrDat->Accepted) // who accepted registration
|
UsrDat->Accepted) // who accepted registration
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -185,6 +185,7 @@ void Pho_PutLinkToChangeOtherUsrPhoto (void)
|
||||||
bool PhotoExists;
|
bool PhotoExists;
|
||||||
char PhotoURL[PATH_MAX + 1];
|
char PhotoURL[PATH_MAX + 1];
|
||||||
const char *TitleText;
|
const char *TitleText;
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Link for changing / uploading the photo *****/
|
/***** Link for changing / uploading the photo *****/
|
||||||
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
|
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // It's me
|
||||||
|
@ -195,10 +196,21 @@ void Pho_PutLinkToChangeOtherUsrPhoto (void)
|
||||||
PhotoExists = Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
PhotoExists = Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
||||||
TitleText = PhotoExists ? Txt_Change_photo :
|
TitleText = PhotoExists ? Txt_Change_photo :
|
||||||
Txt_Upload_photo;
|
Txt_Upload_photo;
|
||||||
Lay_PutContextualLink ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActReqStdPho :
|
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
|
||||||
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActReqTchPho :
|
{
|
||||||
ActReqOthPho), // Guest, visitor or admin
|
case Rol_STD:
|
||||||
NULL,Usr_PutParamOtherUsrCodEncrypted,
|
NextAction = ActReqStdPho;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActReqTchPho;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActReqOthPho;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Lay_PutContextualLink (NextAction,NULL,
|
||||||
|
Usr_PutParamOtherUsrCodEncrypted,
|
||||||
"photo64x64.gif",
|
"photo64x64.gif",
|
||||||
TitleText,TitleText,
|
TitleText,TitleText,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -230,17 +242,31 @@ static void Pho_PutIconToRequestRemoveOtherUsrPhoto (void)
|
||||||
extern const char *Txt_Remove_photo;
|
extern const char *Txt_Remove_photo;
|
||||||
char PhotoURL[PATH_MAX + 1];
|
char PhotoURL[PATH_MAX + 1];
|
||||||
bool PhotoExists;
|
bool PhotoExists;
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Link to request the removal of another user's photo *****/
|
/***** Link to request the removal of another user's photo *****/
|
||||||
PhotoExists = Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
PhotoExists = Pho_BuildLinkToPhoto (&Gbl.Usrs.Other.UsrDat,PhotoURL);
|
||||||
if (PhotoExists)
|
if (PhotoExists)
|
||||||
Lay_PutContextualLink ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActReqRemStdPho :
|
{
|
||||||
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActReqRemTchPho :
|
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
|
||||||
ActReqRemOthPho), // Guest, visitor or admin
|
{
|
||||||
NULL,Usr_PutParamOtherUsrCodEncrypted,
|
case Rol_STD:
|
||||||
|
NextAction = ActReqRemStdPho;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActReqRemTchPho;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActReqRemOthPho;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Lay_PutContextualLink (NextAction,NULL,
|
||||||
|
Usr_PutParamOtherUsrCodEncrypted,
|
||||||
"remove-on64x64.png",
|
"remove-on64x64.png",
|
||||||
Txt_Remove_photo,NULL,
|
Txt_Remove_photo,NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -295,6 +321,7 @@ static void Pho_ReqPhoto (const struct UsrData *UsrDat,const char *PhotoURL)
|
||||||
extern const char *Txt_File_with_the_photo;
|
extern const char *Txt_File_with_the_photo;
|
||||||
extern const char *Txt_Upload_photo;
|
extern const char *Txt_Upload_photo;
|
||||||
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
bool ItsMe = (UsrDat->UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Start frame *****/
|
/***** Start frame *****/
|
||||||
Lay_StartRoundFrame (NULL,Txt_Photo,
|
Lay_StartRoundFrame (NULL,Txt_Photo,
|
||||||
|
@ -307,9 +334,20 @@ static void Pho_ReqPhoto (const struct UsrData *UsrDat,const char *PhotoURL)
|
||||||
Act_FormStart (ActDetMyPho);
|
Act_FormStart (ActDetMyPho);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActDetStdPho :
|
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
|
||||||
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActDetTchPho :
|
{
|
||||||
ActDetOthPho)); // Guest, visitor or admin
|
case Rol_STD:
|
||||||
|
NextAction = ActDetStdPho;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActDetTchPho;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActDetOthPho;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Act_FormStart (NextAction);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,6 +497,7 @@ void Pho_ReqRemoveUsrPhoto (void)
|
||||||
extern const char *Txt_The_photo_no_longer_exists;
|
extern const char *Txt_The_photo_no_longer_exists;
|
||||||
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
|
||||||
char PhotoURL[PATH_MAX + 1];
|
char PhotoURL[PATH_MAX + 1];
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Get user's code from form *****/
|
/***** Get user's code from form *****/
|
||||||
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
|
Usr_GetParamOtherUsrCodEncryptedAndGetListIDs ();
|
||||||
|
@ -482,10 +521,21 @@ void Pho_ReqRemoveUsrPhoto (void)
|
||||||
"PHOTO186x248",Pho_NO_ZOOM,false);
|
"PHOTO186x248",Pho_NO_ZOOM,false);
|
||||||
|
|
||||||
/* End alert */
|
/* End alert */
|
||||||
Ale_ShowAlertAndButton2 ( Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_STD ? ActRemStdPho :
|
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
|
||||||
(Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB == Rol_TCH ? ActRemTchPho :
|
{
|
||||||
ActRemOthPho), // Guest, visitor or admin
|
case Rol_STD:
|
||||||
NULL,Usr_PutParamOtherUsrCodEncrypted,
|
NextAction = ActRemStdPho;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActRemTchPho;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActRemOthPho;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Ale_ShowAlertAndButton2 (NextAction,NULL,
|
||||||
|
Usr_PutParamOtherUsrCodEncrypted,
|
||||||
Lay_REMOVE_BUTTON,Txt_Remove_photo);
|
Lay_REMOVE_BUTTON,Txt_Remove_photo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -560,6 +610,7 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
||||||
unsigned Radius;
|
unsigned Radius;
|
||||||
unsigned BackgroundCode;
|
unsigned BackgroundCode;
|
||||||
char StrFileName[NAME_MAX + 1];
|
char StrFileName[NAME_MAX + 1];
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Creates directories if not exist *****/
|
/***** Creates directories if not exist *****/
|
||||||
sprintf (PathPhotosPriv,"%s/%s",
|
sprintf (PathPhotosPriv,"%s/%s",
|
||||||
|
@ -648,12 +699,26 @@ static bool Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *Usr
|
||||||
if (BackgroundCode == 1)
|
if (BackgroundCode == 1)
|
||||||
{
|
{
|
||||||
NumFacesGreen++;
|
NumFacesGreen++;
|
||||||
Act_FormStart (ItsMe ? ActUpdMyPho :
|
if (ItsMe)
|
||||||
(UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActUpdStdPho :
|
Act_FormStart (ActUpdMyPho);
|
||||||
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActUpdTchPho :
|
else
|
||||||
ActUpdOthPho))); // Guest, visitor or admin
|
{
|
||||||
if (!ItsMe)
|
switch (Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB)
|
||||||
|
{
|
||||||
|
case Rol_STD:
|
||||||
|
NextAction = ActUpdStdPho;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActUpdTchPho;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActUpdOthPho;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Act_FormStart (NextAction);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
|
||||||
|
}
|
||||||
Par_PutHiddenParamString ("FileName",StrFileName);
|
Par_PutHiddenParamString ("FileName",StrFileName);
|
||||||
Act_FormEnd ();
|
Act_FormEnd ();
|
||||||
}
|
}
|
||||||
|
|
184
swad_record.c
184
swad_record.c
|
@ -95,6 +95,7 @@ static bool Rec_GetParamShowOfficeHours (void);
|
||||||
static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
struct UsrData *UsrDat,const char *Anchor);
|
struct UsrData *UsrDat,const char *Anchor);
|
||||||
static void Rec_ShowMyCrsRecordUpdated (void);
|
static void Rec_ShowMyCrsRecordUpdated (void);
|
||||||
|
static bool Rec_CheckIfICanEditField (Rec_VisibilityRecordFields_t Visibility);
|
||||||
|
|
||||||
static void Rec_PutIconsCommands (void);
|
static void Rec_PutIconsCommands (void);
|
||||||
static void Rec_PutParamUsrCodEncrypted (void);
|
static void Rec_PutParamUsrCodEncrypted (void);
|
||||||
|
@ -1135,7 +1136,8 @@ static void Rec_ShowRecordOneStdCrs (void)
|
||||||
/***** Record of the student in the course *****/
|
/***** Record of the student in the course *****/
|
||||||
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
|
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
|
||||||
{
|
{
|
||||||
if (Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
|
if (Gbl.Usrs.Me.LoggedRole == Rol_NET ||
|
||||||
|
Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
|
||||||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
|
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
|
||||||
{
|
{
|
||||||
fprintf (Gbl.F.Out,"<section class=\"REC_CRS\">");
|
fprintf (Gbl.F.Out,"<section class=\"REC_CRS\">");
|
||||||
|
@ -1264,7 +1266,8 @@ static void Rec_ListRecordsStds (Rec_SharedRecordViewType_t ShaTypeOfView,
|
||||||
|
|
||||||
/* Record of the student in the course */
|
/* Record of the student in the course */
|
||||||
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
|
if (Gbl.CurrentCrs.Records.LstFields.Num) // There are fields in the record
|
||||||
if ( Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
|
if ( Gbl.Usrs.Me.LoggedRole == Rol_NET ||
|
||||||
|
Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
|
||||||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
|
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
|
||||||
(Gbl.Usrs.Me.LoggedRole == Rol_STD && // I am student in this course...
|
(Gbl.Usrs.Me.LoggedRole == Rol_STD && // I am student in this course...
|
||||||
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)) // ...and it's me
|
UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)) // ...and it's me
|
||||||
|
@ -1736,7 +1739,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
|
||||||
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
|
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else // It's not me ==> i am a student trying to do something forbidden
|
else // It's not me ==> I am a student trying to do something forbidden
|
||||||
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
|
Lay_ShowErrorAndExit (Txt_You_dont_have_permission_to_perform_this_action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1913,8 +1916,7 @@ void Rec_GetFieldsCrsRecordFromForm (void)
|
||||||
for (NumField = 0;
|
for (NumField = 0;
|
||||||
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
|
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
|
||||||
NumField++)
|
NumField++)
|
||||||
if (Gbl.Usrs.Me.LoggedRole > Rol_STD ||
|
if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility))
|
||||||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
|
|
||||||
{
|
{
|
||||||
/* Get text of the form */
|
/* Get text of the form */
|
||||||
sprintf (FieldParamName,"Field%ld",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
|
sprintf (FieldParamName,"Field%ld",Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod);
|
||||||
|
@ -1936,8 +1938,7 @@ void Rec_UpdateCrsRecord (long UsrCod)
|
||||||
for (NumField = 0;
|
for (NumField = 0;
|
||||||
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
|
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
|
||||||
NumField++)
|
NumField++)
|
||||||
if (Gbl.Usrs.Me.LoggedRole > Rol_STD ||
|
if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility))
|
||||||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
|
|
||||||
{
|
{
|
||||||
/***** Check if already exists this field for this user in database *****/
|
/***** Check if already exists this field for this user in database *****/
|
||||||
FieldAlreadyExists = (Rec_GetFieldFromCrsRecord (UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res) != 0);
|
FieldAlreadyExists = (Rec_GetFieldFromCrsRecord (UsrCod,Gbl.CurrentCrs.Records.LstFields.Lst[NumField].FieldCod,&mysql_res) != 0);
|
||||||
|
@ -2049,8 +2050,7 @@ void Rec_AllocMemFieldsRecordsCrs (void)
|
||||||
for (NumField = 0;
|
for (NumField = 0;
|
||||||
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
|
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
|
||||||
NumField++)
|
NumField++)
|
||||||
if (Gbl.Usrs.Me.LoggedRole > Rol_STD ||
|
if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility))
|
||||||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
|
|
||||||
/* Allocate memory for the texts of the fields */
|
/* Allocate memory for the texts of the fields */
|
||||||
if ((Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
if ((Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text = malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
|
||||||
Lay_ShowErrorAndExit ("Not enough memory to store records of the course.");
|
Lay_ShowErrorAndExit ("Not enough memory to store records of the course.");
|
||||||
|
@ -2067,8 +2067,7 @@ void Rec_FreeMemFieldsRecordsCrs (void)
|
||||||
for (NumField = 0;
|
for (NumField = 0;
|
||||||
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
|
NumField < Gbl.CurrentCrs.Records.LstFields.Num;
|
||||||
NumField++)
|
NumField++)
|
||||||
if (Gbl.Usrs.Me.LoggedRole > Rol_STD ||
|
if (Rec_CheckIfICanEditField (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility))
|
||||||
Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Visibility == Rec_EDITABLE_FIELD)
|
|
||||||
/* Free memory of the text of the field */
|
/* Free memory of the text of the field */
|
||||||
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text)
|
if (Gbl.CurrentCrs.Records.LstFields.Lst[NumField].Text)
|
||||||
{
|
{
|
||||||
|
@ -2077,6 +2076,19 @@ void Rec_FreeMemFieldsRecordsCrs (void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/* Check if I can edit a field depending on my role and the field visibility */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static bool Rec_CheckIfICanEditField (Rec_VisibilityRecordFields_t Visibility)
|
||||||
|
{
|
||||||
|
// Non-editing teachers can not edit fields
|
||||||
|
return Gbl.Usrs.Me.LoggedRole == Rol_TCH ||
|
||||||
|
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM ||
|
||||||
|
(Gbl.Usrs.Me.LoggedRole == Rol_STD &&
|
||||||
|
Visibility == Rec_EDITABLE_FIELD);
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*********** Show form to sign up and edit my shared record card *************/
|
/*********** Show form to sign up and edit my shared record card *************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -2212,7 +2224,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
|
||||||
Hlp_USERS_Guests, // Rol_GST
|
Hlp_USERS_Guests, // Rol_GST
|
||||||
NULL, // Rol_USR
|
NULL, // Rol_USR
|
||||||
Hlp_USERS_Students_shared_record_card, // Rol_STD
|
Hlp_USERS_Students_shared_record_card, // Rol_STD
|
||||||
Hlp_USERS_Teachers_shared_record_card, // Rol_NED_TCH
|
Hlp_USERS_Teachers_shared_record_card, // Rol_NET
|
||||||
Hlp_USERS_Teachers_shared_record_card, // Rol_TCH
|
Hlp_USERS_Teachers_shared_record_card, // Rol_TCH
|
||||||
NULL, // Rol_DEG_ADM
|
NULL, // Rol_DEG_ADM
|
||||||
NULL, // Rol_CTR_ADM
|
NULL, // Rol_CTR_ADM
|
||||||
|
@ -2222,39 +2234,50 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
|
||||||
char StrRecordWidth[10 + 1];
|
char StrRecordWidth[10 + 1];
|
||||||
const char *ClassForm = "REC_DAT";
|
const char *ClassForm = "REC_DAT";
|
||||||
bool ItsMe;
|
bool ItsMe;
|
||||||
bool IAmLoggedAsTeacher;
|
bool IAmLoggedAsTeacherOrSysAdm;
|
||||||
bool IAmLoggedAsSysAdm;
|
|
||||||
bool CountryForm;
|
bool CountryForm;
|
||||||
bool ICanEdit;
|
bool ICanEdit;
|
||||||
bool PutFormLinks; // Put links (forms) inside record card
|
bool PutFormLinks; // Put links (forms) inside record card
|
||||||
bool ShowData;
|
bool ShowData;
|
||||||
bool ShowIDRows;
|
bool ShowIDRows;
|
||||||
bool ShowAddressRows;
|
bool ShowAddressRows;
|
||||||
|
bool StudentInCurrentCrs;
|
||||||
|
bool TeacherInCurrentCrs;
|
||||||
|
bool TeacherInAnyCrs;
|
||||||
bool ShowTeacherRows;
|
bool ShowTeacherRows;
|
||||||
struct Instit Ins;
|
struct Instit Ins;
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Initializations *****/
|
/***** Initializations *****/
|
||||||
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
|
ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == UsrDat->UsrCod);
|
||||||
IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TCH); // My current role is teacher
|
IAmLoggedAsTeacherOrSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_NET || // My current role is non-editing teacher
|
||||||
IAmLoggedAsSysAdm = (Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is superuser
|
Gbl.Usrs.Me.LoggedRole == Rol_TCH || // My current role is teacher
|
||||||
|
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); // My current role is system admin
|
||||||
CountryForm = (TypeOfView == Rec_SHA_MY_RECORD_FORM);
|
CountryForm = (TypeOfView == Rec_SHA_MY_RECORD_FORM);
|
||||||
ShowData = (ItsMe ||
|
ShowData = (ItsMe ||
|
||||||
Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM ||
|
Gbl.Usrs.Me.LoggedRole >= Rol_DEG_ADM ||
|
||||||
UsrDat->Accepted);
|
UsrDat->Accepted);
|
||||||
ShowIDRows = (TypeOfView != Rec_SHA_RECORD_PUBLIC);
|
ShowIDRows = (TypeOfView != Rec_SHA_RECORD_PUBLIC);
|
||||||
|
|
||||||
|
StudentInCurrentCrs = UsrDat->RoleInCurrentCrsDB == Rol_STD;
|
||||||
|
TeacherInCurrentCrs = UsrDat->RoleInCurrentCrsDB == Rol_NET ||
|
||||||
|
UsrDat->RoleInCurrentCrsDB == Rol_TCH;
|
||||||
|
TeacherInAnyCrs = UsrDat->Roles & ((1 << Rol_NET) |
|
||||||
|
(1 << Rol_TCH));
|
||||||
|
|
||||||
ShowAddressRows = (TypeOfView == Rec_SHA_MY_RECORD_FORM ||
|
ShowAddressRows = (TypeOfView == Rec_SHA_MY_RECORD_FORM ||
|
||||||
TypeOfView == Rec_SHA_MY_RECORD_CHECK ||
|
TypeOfView == Rec_SHA_MY_RECORD_CHECK ||
|
||||||
((TypeOfView == Rec_SHA_RECORD_LIST ||
|
((TypeOfView == Rec_SHA_RECORD_LIST ||
|
||||||
TypeOfView == Rec_SHA_RECORD_PRINT) &&
|
TypeOfView == Rec_SHA_RECORD_PRINT) &&
|
||||||
(IAmLoggedAsTeacher || IAmLoggedAsSysAdm) &&
|
IAmLoggedAsTeacherOrSysAdm &&
|
||||||
UsrDat->RoleInCurrentCrsDB == Rol_STD));
|
StudentInCurrentCrs)); // He/she is a student in the current course
|
||||||
Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get user's roles if not got
|
Rol_GetRolesInAllCrssIfNotYetGot (UsrDat); // Get user's roles if not got
|
||||||
ShowTeacherRows = (((TypeOfView == Rec_SHA_MY_RECORD_FORM ||
|
ShowTeacherRows = (((TypeOfView == Rec_SHA_MY_RECORD_FORM ||
|
||||||
TypeOfView == Rec_SHA_MY_RECORD_CHECK) &&
|
TypeOfView == Rec_SHA_MY_RECORD_CHECK) &&
|
||||||
(UsrDat->Roles & (1 << Rol_TCH))) || // He/she (me, really) is a teacher in any course
|
TeacherInAnyCrs) || // He/she (me, really) is a teacher in any course
|
||||||
((TypeOfView == Rec_SHA_RECORD_LIST ||
|
((TypeOfView == Rec_SHA_RECORD_LIST ||
|
||||||
TypeOfView == Rec_SHA_RECORD_PRINT) &&
|
TypeOfView == Rec_SHA_RECORD_PRINT) &&
|
||||||
UsrDat->RoleInCurrentCrsDB == Rol_TCH)); // He/she is a teacher in the current course
|
TeacherInCurrentCrs)); // He/she is a teacher in the current course
|
||||||
|
|
||||||
/* Data form = I can edit fields like surnames and name */
|
/* Data form = I can edit fields like surnames and name */
|
||||||
switch (TypeOfView)
|
switch (TypeOfView)
|
||||||
|
@ -2358,15 +2381,41 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView,
|
||||||
Act_FormStart (ActChgMyData);
|
Act_FormStart (ActChgMyData);
|
||||||
break;
|
break;
|
||||||
case Rec_SHA_OTHER_NEW_USR_FORM:
|
case Rec_SHA_OTHER_NEW_USR_FORM:
|
||||||
Act_FormStart ( Gbl.Action.Act == ActReqMdfStd ? ActCreStd :
|
switch (Gbl.Action.Act)
|
||||||
(Gbl.Action.Act == ActReqMdfTch ? ActCreTch :
|
{
|
||||||
ActCreOth));
|
case ActReqMdfStd:
|
||||||
|
NextAction = ActCreStd;
|
||||||
|
break;
|
||||||
|
case ActReqMdfNET:
|
||||||
|
NextAction = ActCreNET;
|
||||||
|
break;
|
||||||
|
case ActReqMdfTch:
|
||||||
|
NextAction = ActCreTch;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
NextAction = ActCreOth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Act_FormStart (NextAction);
|
||||||
ID_PutParamOtherUsrIDPlain (); // New user
|
ID_PutParamOtherUsrIDPlain (); // New user
|
||||||
break;
|
break;
|
||||||
case Rec_SHA_OTHER_EXISTING_USR_FORM:
|
case Rec_SHA_OTHER_EXISTING_USR_FORM:
|
||||||
Act_FormStart ( UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActUpdStd :
|
switch (UsrDat->RoleInCurrentCrsDB)
|
||||||
(UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActUpdTch :
|
{
|
||||||
ActUpdOth));
|
case Rol_STD:
|
||||||
|
NextAction = ActUpdStd;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
NextAction = ActUpdNET;
|
||||||
|
break;
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActUpdTch;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActUpdOth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Act_FormStart (NextAction);
|
||||||
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); // Existing user
|
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); // Existing user
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -2502,9 +2551,11 @@ static void Rec_PutIconsCommands (void)
|
||||||
extern const char *Txt_Follow;
|
extern const char *Txt_Follow;
|
||||||
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Record.UsrDat->UsrCod);
|
bool ItsMe = (Gbl.Usrs.Me.UsrDat.UsrCod == Gbl.Record.UsrDat->UsrCod);
|
||||||
bool IAmLoggedAsStudent = (Gbl.Usrs.Me.LoggedRole == Rol_STD); // My current role is student
|
bool IAmLoggedAsStudent = (Gbl.Usrs.Me.LoggedRole == Rol_STD); // My current role is student
|
||||||
bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_TCH); // My current role is teacher
|
bool IAmLoggedAsTeacher = (Gbl.Usrs.Me.LoggedRole == Rol_NET || // My current role is non-editing teacher
|
||||||
|
Gbl.Usrs.Me.LoggedRole == Rol_TCH); // 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 ICanViewUsrProfile;
|
bool ICanViewUsrProfile;
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
if (!Gbl.Form.Inside && // Only if not inside another form
|
if (!Gbl.Form.Inside && // Only if not inside another form
|
||||||
Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW && // Only in main window
|
Act_Actions[Gbl.Action.Act].BrowserWindow == Act_THIS_WINDOW && // Only in main window
|
||||||
|
@ -2565,17 +2616,32 @@ static void Rec_PutIconsCommands (void)
|
||||||
(Gbl.CurrentCtr.Ctr.CtrCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_CTR_ADM) ||
|
(Gbl.CurrentCtr.Ctr.CtrCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_CTR_ADM) ||
|
||||||
(Gbl.CurrentIns.Ins.InsCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_INS_ADM) ||
|
(Gbl.CurrentIns.Ins.InsCod > 0 && Gbl.Usrs.Me.LoggedRole == Rol_INS_ADM) ||
|
||||||
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
|
Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM)
|
||||||
Lay_PutContextualLink ( Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STD ? ActReqMdfStd :
|
{
|
||||||
(Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_TCH ? ActReqMdfTch :
|
switch (Gbl.Record.UsrDat->RoleInCurrentCrsDB)
|
||||||
ActReqMdfOth),
|
{
|
||||||
NULL,Rec_PutParamUsrCodEncrypted,
|
case Rol_STD:
|
||||||
|
NextAction = ActReqMdfStd;
|
||||||
|
break;
|
||||||
|
case Rol_NET:
|
||||||
|
NextAction = ActReqMdfNET;
|
||||||
|
break;
|
||||||
|
case Rol_TCH:
|
||||||
|
NextAction = ActReqMdfTch;
|
||||||
|
break;
|
||||||
|
default: // Guest, user or admin
|
||||||
|
NextAction = ActReqMdfOth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Lay_PutContextualLink (NextAction,NULL,
|
||||||
|
Rec_PutParamUsrCodEncrypted,
|
||||||
"config64x64.gif",
|
"config64x64.gif",
|
||||||
Txt_Administer_user,NULL,
|
Txt_Administer_user,NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
|
if (Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
|
||||||
Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STD && // He/she is a student in the current course
|
Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STD && // He/she is a student in the current course
|
||||||
(ItsMe || IAmLoggedAsTeacher || IAmLoggedAsSysAdm)) // I can view
|
(ItsMe || IAmLoggedAsTeacher || IAmLoggedAsSysAdm)) // I can view
|
||||||
{
|
{
|
||||||
/***** Button to view user's assignments and works *****/
|
/***** Button to view user's assignments and works *****/
|
||||||
if (ItsMe) // I am a student
|
if (ItsMe) // I am a student
|
||||||
|
@ -2618,9 +2684,9 @@ static void Rec_PutIconsCommands (void)
|
||||||
|
|
||||||
/***** Button to print QR code *****/
|
/***** Button to print QR code *****/
|
||||||
if (ItsMe || IAmLoggedAsSysAdm ||
|
if (ItsMe || IAmLoggedAsSysAdm ||
|
||||||
(Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
|
(Gbl.CurrentCrs.Crs.CrsCod > 0 && // A course is selected
|
||||||
Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STD && // He/she is a student in the current course
|
Gbl.Record.UsrDat->RoleInCurrentCrsDB == Rol_STD && // He/she is a student in the current course
|
||||||
IAmLoggedAsTeacher)) // I am a teacher in the current course
|
IAmLoggedAsTeacher)) // I am a teacher in the current course
|
||||||
Lay_PutContextualLink (ActPrnUsrQR,NULL,Rec_PutParamUsrCodEncrypted,
|
Lay_PutContextualLink (ActPrnUsrQR,NULL,Rec_PutParamUsrCodEncrypted,
|
||||||
"qr64x64.gif",
|
"qr64x64.gif",
|
||||||
Txt_QR_code,NULL,
|
Txt_QR_code,NULL,
|
||||||
|
@ -2914,10 +2980,13 @@ static void Rec_ShowRole (struct UsrData *UsrDat,
|
||||||
switch (TypeOfView)
|
switch (TypeOfView)
|
||||||
{
|
{
|
||||||
case Rec_SHA_SIGN_UP_FORM: // I want to apply for enrolment
|
case Rec_SHA_SIGN_UP_FORM: // I want to apply for enrolment
|
||||||
DefaultRoleInCurrentCrs = ((UsrDat->Roles & (1 << Rol_TCH)) || // I am teacher in other courses
|
if (UsrDat->UsrCod == Gbl.CurrentCrs.Crs.RequesterUsrCod || // Creator of the course
|
||||||
UsrDat->UsrCod == Gbl.CurrentCrs.Crs.RequesterUsrCod) ? // I am the creator of the course
|
(UsrDat->Roles & (1 << Rol_TCH))) // Teacher in other courses
|
||||||
Rol_TCH :
|
DefaultRoleInCurrentCrs = Rol_TCH;
|
||||||
Rol_STD;
|
else if ((UsrDat->Roles & (1 << Rol_NET))) // Non-editing teacher in other courses
|
||||||
|
DefaultRoleInCurrentCrs = Rol_NET;
|
||||||
|
else
|
||||||
|
DefaultRoleInCurrentCrs = Rol_STD;
|
||||||
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">");
|
fprintf (Gbl.F.Out,"<select id=\"Role\" name=\"Role\">");
|
||||||
for (Role = Rol_STD;
|
for (Role = Rol_STD;
|
||||||
Role <= Rol_TCH;
|
Role <= Rol_TCH;
|
||||||
|
@ -2939,8 +3008,14 @@ static void Rec_ShowRole (struct UsrData *UsrDat,
|
||||||
{
|
{
|
||||||
/* If there is a request of this user, default role is the requested role */
|
/* If there is a request of this user, default role is the requested role */
|
||||||
if ((DefaultRoleInCurrentCrs = Rol_GetRequestedRole (UsrDat->UsrCod)) == Rol_UNK)
|
if ((DefaultRoleInCurrentCrs = Rol_GetRequestedRole (UsrDat->UsrCod)) == Rol_UNK)
|
||||||
DefaultRoleInCurrentCrs = (UsrDat->Roles & (1 << Rol_TCH)) ? Rol_TCH :
|
{
|
||||||
Rol_STD;
|
if ((UsrDat->Roles & (1 << Rol_TCH))) // Teacher in other courses
|
||||||
|
DefaultRoleInCurrentCrs = Rol_TCH;
|
||||||
|
else if ((UsrDat->Roles & (1 << Rol_NET))) // Non-editing teacher in other courses
|
||||||
|
DefaultRoleInCurrentCrs = Rol_NET;
|
||||||
|
else
|
||||||
|
DefaultRoleInCurrentCrs = Rol_STD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DefaultRoleInCurrentCrs = UsrDat->RoleInCurrentCrsDB;
|
DefaultRoleInCurrentCrs = UsrDat->RoleInCurrentCrsDB;
|
||||||
|
@ -2950,6 +3025,7 @@ static void Rec_ShowRole (struct UsrData *UsrDat,
|
||||||
case Rol_GST:
|
case Rol_GST:
|
||||||
case Rol_USR:
|
case Rol_USR:
|
||||||
case Rol_STD:
|
case Rol_STD:
|
||||||
|
case Rol_NET:
|
||||||
fprintf (Gbl.F.Out,"<option value=\"%u\""
|
fprintf (Gbl.F.Out,"<option value=\"%u\""
|
||||||
" selected=\"selected\""
|
" selected=\"selected\""
|
||||||
" disabled=\"disabled\">"
|
" disabled=\"disabled\">"
|
||||||
|
@ -2981,8 +3057,9 @@ static void Rec_ShowRole (struct UsrData *UsrDat,
|
||||||
else // No course selected
|
else // No course selected
|
||||||
{
|
{
|
||||||
DefaultRoleInCurrentCrs = (UsrDat->Roles & ((1 << Rol_STD) |
|
DefaultRoleInCurrentCrs = (UsrDat->Roles & ((1 << Rol_STD) |
|
||||||
(1 << Rol_TCH))) ? Rol_USR :
|
(1 << Rol_NET) |
|
||||||
Rol_GST;
|
(1 << Rol_TCH))) ? Rol_USR : // If user belongs to any course
|
||||||
|
Rol_GST; // If user don't belong to any course
|
||||||
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\""
|
fprintf (Gbl.F.Out,"<option value=\"%u\" selected=\"selected\""
|
||||||
" disabled=\"disabled\">%s</option>",
|
" disabled=\"disabled\">%s</option>",
|
||||||
(unsigned) DefaultRoleInCurrentCrs,
|
(unsigned) DefaultRoleInCurrentCrs,
|
||||||
|
@ -3672,7 +3749,7 @@ void Rec_UpdateMyRecord (void)
|
||||||
Rol_Role_t Rec_GetRoleFromRecordForm (void)
|
Rol_Role_t Rec_GetRoleFromRecordForm (void)
|
||||||
{
|
{
|
||||||
Rol_Role_t Role;
|
Rol_Role_t Role;
|
||||||
bool RoleOK = false;
|
bool RoleOK;
|
||||||
|
|
||||||
/***** Get role as a parameter from form *****/
|
/***** Get role as a parameter from form *****/
|
||||||
Role = (Rol_Role_t)
|
Role = (Rol_Role_t)
|
||||||
|
@ -3684,36 +3761,27 @@ Rol_Role_t Rec_GetRoleFromRecordForm (void)
|
||||||
/***** Check if I can register a user
|
/***** Check if I can register a user
|
||||||
with the received role in current course *****/
|
with the received role in current course *****/
|
||||||
/* Check for other possible errors */
|
/* Check for other possible errors */
|
||||||
|
RoleOK = false;
|
||||||
switch (Gbl.Usrs.Me.LoggedRole)
|
switch (Gbl.Usrs.Me.LoggedRole)
|
||||||
{
|
{
|
||||||
case Rol_STD: // I am logged as student
|
case Rol_STD: // I am logged as student
|
||||||
/* A student can only change his/her data, but not his/her role */
|
case Rol_NET: // I am logged as non-editing teacher
|
||||||
if (Role == Rol_STD)
|
/* A student or a non-editing teacher can only change his/her data, but not his/her role */
|
||||||
|
if (Role == Gbl.Usrs.Me.LoggedRole)
|
||||||
RoleOK = true;
|
RoleOK = true;
|
||||||
break;
|
break;
|
||||||
/*
|
|
||||||
case Rol_TCH: // I am logged as teacher
|
|
||||||
// A teacher can only register another user as teacher
|
|
||||||
// if the other is already teacher in any course.
|
|
||||||
// That is, a teacher can not upgrade a student
|
|
||||||
// (in all other courses) to teacher
|
|
||||||
Rol_GetRolesInAllCrssIfNotYetGot (&Gbl.Usrs.Other.UsrDat);
|
|
||||||
if ( Role == Rol_STD ||
|
|
||||||
(Role == Rol_TCH && // He/she will be a teacher in current course
|
|
||||||
(Gbl.Usrs.Other.UsrDat.Roles & (1 << Rol_TCH)))) // He/she was a teacher in some courses
|
|
||||||
RoleOK = true;
|
|
||||||
break;
|
|
||||||
*/
|
|
||||||
case Rol_TCH: // I am logged as teacher
|
case Rol_TCH: // I am logged as teacher
|
||||||
case Rol_DEG_ADM: // I am logged as degree admin
|
case Rol_DEG_ADM: // I am logged as degree admin
|
||||||
case Rol_CTR_ADM: // I am logged as centre admin
|
case Rol_CTR_ADM: // I am logged as centre admin
|
||||||
case Rol_INS_ADM: // I am logged as institution admin
|
case Rol_INS_ADM: // I am logged as institution admin
|
||||||
if (Role == Rol_STD ||
|
if (Role == Rol_STD ||
|
||||||
|
Role == Rol_NET ||
|
||||||
Role == Rol_TCH)
|
Role == Rol_TCH)
|
||||||
RoleOK = true;
|
RoleOK = true;
|
||||||
break;
|
break;
|
||||||
case Rol_SYS_ADM:
|
case Rol_SYS_ADM:
|
||||||
if ( Role == Rol_STD ||
|
if ( Role == Rol_STD ||
|
||||||
|
Role == Rol_NET ||
|
||||||
Role == Rol_TCH ||
|
Role == Rol_TCH ||
|
||||||
(Role == Rol_GST && Gbl.CurrentCrs.Crs.CrsCod <= 0))
|
(Role == Rol_GST && Gbl.CurrentCrs.Crs.CrsCod <= 0))
|
||||||
RoleOK = true;
|
RoleOK = true;
|
||||||
|
|
34
swad_text.c
34
swad_text.c
|
@ -25607,7 +25607,7 @@ const char *Txt_No_users_found[Rol_NUM_ROLES] =
|
||||||
"Nenhum estudante encontrado."
|
"Nenhum estudante encontrado."
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH
|
#if L==1 // Rol_NET
|
||||||
"No hi ha professors."
|
"No hi ha professors."
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"Keine Lehrkräften gefunden."
|
"Keine Lehrkräften gefunden."
|
||||||
|
@ -32437,7 +32437,7 @@ const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_UNKNOWN
|
#if L==1 // Rol_NET - Usr_SEX_UNKNOWN
|
||||||
"Professor/a no editor/a"
|
"Professor/a no editor/a"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"Nicht bearbeiteter Lehrkraft"
|
"Nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -32457,7 +32457,7 @@ const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"Professor/a não editor/a"
|
"Professor/a não editor/a"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_FEMALE
|
#if L==1 // Rol_NET - Usr_SEX_FEMALE
|
||||||
"Professora no editora"
|
"Professora no editora"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"Nicht bearbeiteter Lehrkraft"
|
"Nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -32477,7 +32477,7 @@ const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"Professora não editora"
|
"Professora não editora"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_MALE
|
#if L==1 // Rol_NET - Usr_SEX_MALE
|
||||||
"Professor no editor"
|
"Professor no editor"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"Nicht bearbeiteter Lehrkraft"
|
"Nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -32497,7 +32497,7 @@ const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"Professor não editor"
|
"Professor não editor"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_ALL
|
#if L==1 // Rol_NET - Usr_SEX_ALL
|
||||||
"Professor/a no editor/a"
|
"Professor/a no editor/a"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"Nicht bearbeiteter Lehrkraft"
|
"Nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -33250,7 +33250,7 @@ const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_UNKNOWN
|
#if L==1 // Rol_NET - Usr_SEX_UNKNOWN
|
||||||
"professor/a no editor/a"
|
"professor/a no editor/a"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"nicht bearbeiteter Lehrkraft"
|
"nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -33270,7 +33270,7 @@ const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"professor/a não editor/a"
|
"professor/a não editor/a"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_FEMALE
|
#if L==1 // Rol_NET - Usr_SEX_FEMALE
|
||||||
"professora no editora"
|
"professora no editora"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"nicht bearbeiteter Lehrkraft"
|
"nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -33290,7 +33290,7 @@ const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"professora não editora"
|
"professora não editora"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_MALE
|
#if L==1 // Rol_NET - Usr_SEX_MALE
|
||||||
"professor no editor"
|
"professor no editor"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"nicht bearbeiteter Lehrkraft"
|
"nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -33310,7 +33310,7 @@ const char *Txt_ROLES_SINGUL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"professor não editor"
|
"professor não editor"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_ALL
|
#if L==1 // Rol_NET - Usr_SEX_ALL
|
||||||
"professor/a no editor/a"
|
"professor/a no editor/a"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"nicht bearbeiteter Lehrkraft"
|
"nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -34064,7 +34064,7 @@ const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_UNKNOWN
|
#if L==1 // Rol_NET - Usr_SEX_UNKNOWN
|
||||||
"Professors no editors"
|
"Professors no editors"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"Nicht bearbeiteter Lehrkraft"
|
"Nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -34084,7 +34084,7 @@ const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"Professores não editores"
|
"Professores não editores"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_FEMALE
|
#if L==1 // Rol_NET - Usr_SEX_FEMALE
|
||||||
"Professores no editores"
|
"Professores no editores"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"Nicht bearbeiteter Lehrkraft"
|
"Nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -34104,7 +34104,7 @@ const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"Professoras não editoras"
|
"Professoras não editoras"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_MALE
|
#if L==1 // Rol_NET - Usr_SEX_MALE
|
||||||
"Professors no editors"
|
"Professors no editors"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"Nicht bearbeiteter Lehrkraft"
|
"Nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -34124,7 +34124,7 @@ const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"Professores não editores"
|
"Professores não editores"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_ALL
|
#if L==1 // Rol_NET - Usr_SEX_ALL
|
||||||
"Professors no editors"
|
"Professors no editors"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"Nicht bearbeiteter Lehrkraft"
|
"Nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -34877,7 +34877,7 @@ const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
#endif
|
#endif
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_UNKNOWN
|
#if L==1 // Rol_NET - Usr_SEX_UNKNOWN
|
||||||
"professors no editors"
|
"professors no editors"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"nicht bearbeiteter Lehrkraft"
|
"nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -34897,7 +34897,7 @@ const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"professores não editores"
|
"professores não editores"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_FEMALE
|
#if L==1 // Rol_NET - Usr_SEX_FEMALE
|
||||||
"professores no editores"
|
"professores no editores"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"nicht bearbeiteter Lehrkraft"
|
"nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -34917,7 +34917,7 @@ const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"professoras não editoras"
|
"professoras não editoras"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_MALE
|
#if L==1 // Rol_NET - Usr_SEX_MALE
|
||||||
"professors no editors"
|
"professors no editors"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"nicht bearbeiteter Lehrkraft"
|
"nicht bearbeiteter Lehrkraft"
|
||||||
|
@ -34937,7 +34937,7 @@ const char *Txt_ROLES_PLURAL_abc[Rol_NUM_ROLES][Usr_NUM_SEXS] =
|
||||||
"professores não editores"
|
"professores não editores"
|
||||||
#endif
|
#endif
|
||||||
,
|
,
|
||||||
#if L==1 // Rol_NED_TCH - Usr_SEX_ALL
|
#if L==1 // Rol_NET - Usr_SEX_ALL
|
||||||
"professors no editors"
|
"professors no editors"
|
||||||
#elif L==2
|
#elif L==2
|
||||||
"nicht bearbeiteter Lehrkraft"
|
"nicht bearbeiteter Lehrkraft"
|
||||||
|
|
46
swad_user.c
46
swad_user.c
|
@ -946,6 +946,7 @@ unsigned Usr_GetNumCrssOfUsrWithARoleNotAccepted (long UsrCod,Rol_Role_t Role)
|
||||||
unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
||||||
Rol_Role_t OthersRole)
|
Rol_Role_t OthersRole)
|
||||||
{
|
{
|
||||||
|
char SubQueryRole[64];
|
||||||
char Query[512];
|
char Query[512];
|
||||||
unsigned NumUsrs;
|
unsigned NumUsrs;
|
||||||
// This query can be made in a unique, but slower, query
|
// This query can be made in a unique, but slower, query
|
||||||
|
@ -956,22 +957,53 @@ unsigned Usr_GetNumUsrsInCrssOfAUsr (long UsrCod,Rol_Role_t UsrRole,
|
||||||
if (mysql_query (&Gbl.mysql,Query))
|
if (mysql_query (&Gbl.mysql,Query))
|
||||||
DB_ExitOnMySQLError ("can not remove temporary tables");
|
DB_ExitOnMySQLError ("can not remove temporary tables");
|
||||||
|
|
||||||
/***** Create temporary table with all user's courses for a role *****/
|
/***** Create temporary table with all user's courses as student/teacher *****/
|
||||||
|
switch (UsrRole)
|
||||||
|
{
|
||||||
|
case Rol_STD: // Student
|
||||||
|
sprintf (SubQueryRole,"Role=%u",
|
||||||
|
(unsigned) Rol_STD);
|
||||||
|
break;
|
||||||
|
case Rol_NET: // Non-editing teacher
|
||||||
|
case Rol_TCH: // or teacher
|
||||||
|
sprintf (SubQueryRole,"(Role=%u OR Role=%u)",
|
||||||
|
(unsigned) Rol_NET,(unsigned) Rol_TCH);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SubQueryRole[0] = '\0';
|
||||||
|
Lay_ShowErrorAndExit ("Wrong role.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
sprintf (Query,"CREATE TEMPORARY TABLE IF NOT EXISTS usr_courses_tmp"
|
sprintf (Query,"CREATE TEMPORARY TABLE IF NOT EXISTS usr_courses_tmp"
|
||||||
" (CrsCod INT NOT NULL,UNIQUE INDEX (CrsCod))"
|
" (CrsCod INT NOT NULL,UNIQUE INDEX (CrsCod))"
|
||||||
" ENGINE=MEMORY"
|
" ENGINE=MEMORY"
|
||||||
" SELECT CrsCod FROM crs_usr"
|
" SELECT CrsCod FROM crs_usr"
|
||||||
" WHERE UsrCod=%ld AND Role=%u",
|
" WHERE UsrCod=%ld AND %s",
|
||||||
UsrCod,(unsigned) UsrRole);
|
UsrCod,SubQueryRole);
|
||||||
if (mysql_query (&Gbl.mysql,Query))
|
if (mysql_query (&Gbl.mysql,Query))
|
||||||
DB_ExitOnMySQLError ("can not create temporary table");
|
DB_ExitOnMySQLError ("can not create temporary table");
|
||||||
|
|
||||||
/***** Get the number of teachers in a course from database ******/
|
/***** Get the number of students/teachers in a course from database ******/
|
||||||
|
switch (OthersRole)
|
||||||
|
{
|
||||||
|
case Rol_STD: // Student
|
||||||
|
sprintf (SubQueryRole,"crs_usr.Role=%u",
|
||||||
|
(unsigned) Rol_STD);
|
||||||
|
break;
|
||||||
|
case Rol_NET: // Non-editing teacher
|
||||||
|
case Rol_TCH: // or teacher
|
||||||
|
sprintf (SubQueryRole,"(crs_usr.Role=%u OR crs_usr.Role=%u)",
|
||||||
|
(unsigned) Rol_NET,(unsigned) Rol_TCH);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
SubQueryRole[0] = '\0';
|
||||||
|
Lay_ShowErrorAndExit ("Wrong role.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
sprintf (Query,"SELECT COUNT(DISTINCT crs_usr.UsrCod)"
|
||||||
" FROM crs_usr,usr_courses_tmp"
|
" FROM crs_usr,usr_courses_tmp"
|
||||||
" WHERE crs_usr.CrsCod=usr_courses_tmp.CrsCod"
|
" WHERE crs_usr.CrsCod=usr_courses_tmp.CrsCod AND %s",
|
||||||
" AND crs_usr.Role=%u",
|
SubQueryRole);
|
||||||
(unsigned) OthersRole);
|
|
||||||
NumUsrs = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users");
|
NumUsrs = (unsigned) DB_QueryCOUNT (Query,"can not get the number of users");
|
||||||
|
|
||||||
/***** Remove temporary table *****/
|
/***** Remove temporary table *****/
|
||||||
|
|
|
@ -185,7 +185,7 @@ Svc_Role_t Svc_RolRole_to_SvcRole[Rol_NUM_ROLES] =
|
||||||
Svc_ROLE__GUEST_, // Rol_GST
|
Svc_ROLE__GUEST_, // Rol_GST
|
||||||
Svc_ROLE_UNKNOWN, // Rol_USR
|
Svc_ROLE_UNKNOWN, // Rol_USR
|
||||||
Svc_ROLE_STUDENT, // Rol_STD
|
Svc_ROLE_STUDENT, // Rol_STD
|
||||||
Svc_ROLE_TEACHER, // Rol_NED_TCH // TODO: Create new web service role for non-editing teachers
|
Svc_ROLE_TEACHER, // Rol_NET // TODO: Create new web service role for non-editing teachers
|
||||||
Svc_ROLE_TEACHER, // Rol_TCH
|
Svc_ROLE_TEACHER, // Rol_TCH
|
||||||
Svc_ROLE_UNKNOWN, // Rol_DEG_ADM
|
Svc_ROLE_UNKNOWN, // Rol_DEG_ADM
|
||||||
Svc_ROLE_UNKNOWN, // Rol_CTR_ADM
|
Svc_ROLE_UNKNOWN, // Rol_CTR_ADM
|
||||||
|
|
Loading…
Reference in New Issue