diff --git a/swad_ID.c b/swad_ID.c index 8d2dc4fb8..b2f3e52d2 100644 --- a/swad_ID.c +++ b/swad_ID.c @@ -819,15 +819,18 @@ void ID_ConfirmUsrID (long UsrCod,const char *UsrID) } /*****************************************************************************/ -/*************** Check if I can see the user's ID of a teacher ***************/ +/***************** Check if I can see another user's ID **********************/ /*****************************************************************************/ -bool ID_ICanSeeTeacherID (struct UsrData *UsrDat) +bool ID_ICanSeeUsrID (struct UsrData *UsrDat) { - /* Check if I have permission to see the user's ID of a teacher - Only teachers who have accepted registration in courses are counted */ + /* 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); 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 */ diff --git a/swad_ID.h b/swad_ID.h index 6d233c72c..7c932f3f8 100644 --- a/swad_ID.h +++ b/swad_ID.h @@ -75,6 +75,6 @@ void ID_NewMyUsrID (void); void ID_NewOtherUsrID (void); void ID_ConfirmUsrID (long UsrCod,const char *UsrID); -bool ID_ICanSeeTeacherID (struct UsrData *UsrDat); +bool ID_ICanSeeUsrID (struct UsrData *UsrDat); #endif diff --git a/swad_changelog.h b/swad_changelog.h index 0611f55e1..7058e4575 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -118,13 +118,13 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.72.3 (2015-12-23)" -#define CSS_FILE "swad15.65.1.css" +#define Log_PLATFORM_VERSION "SWAD 15.72.4 (2015-12-23)" +#define CSS_FILE "swad15.72.4.css" // 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.72.4: Dec 23, 2015 Show recipient when writing message to only one recipient. (? lines) + Version 15.72.4: Dec 23, 2015 Show recipient when writing message to only one recipient. (187775 lines) Version 15.72.3: Dec 23, 2015 Message translated. (187733 lines) Version 15.72.2: Dec 23, 2015 Write message only to one recipient. Not finished. Some small icons changed. (187750 lines) diff --git a/swad_file_browser.c b/swad_file_browser.c index 4f2893668..95fcd5330 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -3201,7 +3201,7 @@ static void Brw_ShowDataOwnerAsgWrk (struct UsrData *UsrDat) /***** Show user's ID *****/ ID_WriteUsrIDs (UsrDat, - UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ID_ICanSeeTeacherID (UsrDat) : + UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ID_ICanSeeUsrID (UsrDat) : (Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER)); /***** Show user's name *****/ diff --git a/swad_message.c b/swad_message.c index ccbdc93b6..e94e8fbb3 100644 --- a/swad_message.c +++ b/swad_message.c @@ -38,6 +38,7 @@ #include "swad_forum.h" #include "swad_global.h" #include "swad_group.h" +#include "swad_ID.h" #include "swad_message.h" #include "swad_notification.h" #include "swad_parameter.h" @@ -80,7 +81,9 @@ static void Msg_ShowASentOrReceivedMessage (Msg_TypeOfMessages_t TypeOfMessages, static void Msg_GetStatusOfSentMsg (long MsgCod,bool *Expanded); static void Msg_GetStatusOfReceivedMsg (long MsgCod,bool *Open,bool *Replied,bool *Expanded); static long Msg_GetParamMsgCod (void); +static void Msg_PutLinkToShowMorePotentialRecipients (void); static void Msg_PutParamsShowMorePotentialRecipients (void); +static void Msg_ShowOneUniqueRecipient (void); static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void); static void Msg_WriteFormSubjectAndContentMsgToUsrs (const char *Content); static void Msg_ShowNumMsgsDeleted (unsigned NumMsgs); @@ -263,7 +266,6 @@ static void Msg_PutFormMsgUsrs (const char *Content) extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *Txt_Reply_message; extern const char *Txt_New_message; - extern const char *Txt_Show_more_recipients; extern const char *Txt_MSG_To; extern const char *Txt_Send_message; char YN[1+1]; @@ -278,8 +280,7 @@ static void Msg_PutFormMsgUsrs (const char *Content) Gbl.Msg.Reply.OriginalMsgCod = Msg_GetParamMsgCod (); /***** Get user's code of possible preselected recipient *****/ - Usr_GetParamOtherUsrCodEncrypted (); - if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) // There is a preselected recipient + if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ()) // There is a preselected recipient { /* Get who to show as potential recipients: - only the selected recipient @@ -328,13 +329,7 @@ static void Msg_PutFormMsgUsrs (const char *Content) /***** Form to show several potential recipients *****/ if (Gbl.Msg.ShowOnlyOneRecipient) - { - fprintf (Gbl.F.Out,"
"); - Lay_PutContextualLink (ActReqMsgUsr,Msg_PutParamsShowMorePotentialRecipients, - "usrs64x64.gif", - Txt_Show_more_recipients,Txt_Show_more_recipients); - fprintf (Gbl.F.Out,"
"); - } + Msg_PutLinkToShowMorePotentialRecipients (); /***** Start form to select recipients and write the message *****/ Act_FormStart (ActRcvMsgUsr); @@ -349,7 +344,7 @@ static void Msg_PutFormMsgUsrs (const char *Content) /***** Start table *****/ fprintf (Gbl.F.Out,""); - /***** To (recipients) *****/ + /***** "To:" section (recipients) *****/ fprintf (Gbl.F.Out,"" "" - "" + "" ""); } @@ -387,7 +379,7 @@ static void Msg_PutFormMsgUsrs (const char *Content) "" ""); - /***** Subject and content *****/ + /***** Subject and content sections *****/ Msg_WriteFormSubjectAndContentMsgToUsrs (Content); /***** Help for text editor and send button *****/ @@ -424,6 +416,21 @@ static void Msg_PutFormMsgUsrs (const char *Content) Grp_FreeListCodSelectedGrps (); } +/*****************************************************************************/ +/********** Put contextual link to show more potential recipients ************/ +/*****************************************************************************/ + +static void Msg_PutLinkToShowMorePotentialRecipients (void) + { + extern const char *Txt_Show_more_recipients; + + fprintf (Gbl.F.Out,"
"); + Lay_PutContextualLink (ActReqMsgUsr,Msg_PutParamsShowMorePotentialRecipients, + "usrs64x64.gif", + Txt_Show_more_recipients,Txt_Show_more_recipients); + fprintf (Gbl.F.Out,"
"); + } + /*****************************************************************************/ /************ Put parameters to show more potential recipients ***************/ /*****************************************************************************/ @@ -438,6 +445,36 @@ static void Msg_PutParamsShowMorePotentialRecipients (void) } } +/*****************************************************************************/ +/************ Put parameters to show more potential recipients ***************/ +/*****************************************************************************/ + +static void Msg_ShowOneUniqueRecipient (void) + { + char PhotoURL[PATH_MAX+1]; + bool ShowPhoto; + + /***** Show user's photo *****/ + ShowPhoto = Pho_ShowUsrPhotoIsAllowed (&Gbl.Usrs.Other.UsrDat,PhotoURL); + Pho_ShowUsrPhoto (&Gbl.Usrs.Other.UsrDat,ShowPhoto ? PhotoURL : + NULL, + "PHOTO21x28",Pho_ZOOM); + + /****** Write user's IDs ******/ + fprintf (Gbl.F.Out,"
", + Gbl.Usrs.Other.UsrDat.Accepted ? "DAT_SMALL_NOBR_N" : + "DAT_SMALL_NOBR"); + ID_WriteUsrIDs (&Gbl.Usrs.Other.UsrDat, + ID_ICanSeeUsrID (&Gbl.Usrs.Other.UsrDat)); + fprintf (Gbl.F.Out,"
"); + + /***** Write user's name *****/ + fprintf (Gbl.F.Out,"
%s
", + Gbl.Usrs.Other.UsrDat.Accepted ? "DAT_SMALL_NOBR_N" : + "DAT_SMALL_NOBR", + Gbl.Usrs.Other.UsrDat.FullName); + } + /*****************************************************************************/ /************** Nicknames of recipients of a message to users ****************/ /*****************************************************************************/ diff --git a/swad_test.c b/swad_test.c index 8ddfe022e..522539a63 100644 --- a/swad_test.c +++ b/swad_test.c @@ -6473,7 +6473,7 @@ static void Tst_ShowDataUsr (struct UsrData *UsrDat,unsigned NumExams) /***** Show user's ID *****/ ID_WriteUsrIDs (UsrDat, - (UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ID_ICanSeeTeacherID (UsrDat) : + (UsrDat->RoleInCurrentCrsDB == Rol_TEACHER ? ID_ICanSeeUsrID (UsrDat) : (Gbl.Usrs.Me.LoggedRole >= Rol_TEACHER))); /***** Show user's name *****/ diff --git a/swad_user.c b/swad_user.c index 0213ce884..ee41db3ff 100644 --- a/swad_user.c +++ b/swad_user.c @@ -1847,7 +1847,7 @@ bool Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (void) if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Existing user return true; - Lay_ShowAlert (Lay_ERROR,"User does not exist."); + // Lay_ShowAlert (Lay_ERROR,"User does not exist."); return false; } @@ -3130,7 +3130,7 @@ static void Usr_WriteRowTchMainData (unsigned NumUsr,struct UsrData *UsrDat,bool UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", BgColor); - ID_WriteUsrIDs (UsrDat,ID_ICanSeeTeacherID (UsrDat)); + ID_WriteUsrIDs (UsrDat,ID_ICanSeeUsrID (UsrDat)); fprintf (Gbl.F.Out," "); fprintf (Gbl.F.Out,""); @@ -3183,7 +3183,7 @@ void Usr_WriteRowTchAllData (struct UsrData *UsrDat) UsrDat->Accepted ? "DAT_SMALL_N" : "DAT_SMALL", Gbl.RowEvenOdd); - ID_WriteUsrIDs (UsrDat,ID_ICanSeeTeacherID (UsrDat)); + ID_WriteUsrIDs (UsrDat,ID_ICanSeeUsrID (UsrDat)); fprintf (Gbl.F.Out," "); /***** Write rest of main teacher's data *****/
" "%s:" @@ -359,13 +354,10 @@ static void Msg_PutFormMsgUsrs (const char *Content) The_ClassForm[Gbl.Prefs.Theme],Txt_MSG_To); if (Gbl.Msg.ShowOnlyOneRecipient) { - fprintf (Gbl.F.Out,"
"); - /***** Show only one user as recipient *****/ - sprintf (Gbl.Message,"Gbl.Usrs.Other.UsrDat.UsrCod = %ld",Gbl.Usrs.Other.UsrDat.UsrCod); - Lay_ShowAlert (Lay_INFO,Gbl.Message); - + fprintf (Gbl.F.Out,"
"); + Msg_ShowOneUniqueRecipient (); fprintf (Gbl.F.Out,"