diff --git a/swad_changelog.h b/swad_changelog.h index 24ca74228..ed04c3ee8 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -103,11 +103,12 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.76.2 (2015/03/02)" +#define Log_PLATFORM_VERSION "SWAD 14.76.3 (2015/03/03)" // 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 | tail -1 /* + Version 14.76.3: Mar 03, 2015 Fixed bug while sending a message to a guest. (178274 lines) Version 14.76.2: Mar 02, 2015 Button in student record to view student's attendance. (178242 lines) Version 14.76.1: Mar 02, 2015 Button in student record to view student's test exams. (178225 lines) Version 14.76: Mar 02, 2015 Button in student record to view student's works. (178197 lines) diff --git a/swad_global.c b/swad_global.c index e1cd895fc..b768594fa 100644 --- a/swad_global.c +++ b/swad_global.c @@ -196,7 +196,10 @@ void Gbl_InitializeGlobals (void) Gbl.LstExamAnnouncements.NumExamAnnounc = 0; Gbl.LstExamAnnouncements.Lst = NULL; - Gbl.Usrs.Select.All = Gbl.Usrs.Select.Std = Gbl.Usrs.Select.Tch = Gbl.Usrs.ListOtherRecipients = NULL; + Gbl.Usrs.Select.All = + Gbl.Usrs.Select.Std = + Gbl.Usrs.Select.Tch = + Gbl.Usrs.ListOtherRecipients = NULL; Gbl.Msg.Subject[0] = '\0'; Gbl.Msg.ShowOnlyUnreadMsgs = false; diff --git a/swad_message.c b/swad_message.c index 2171bde9f..319f12ad1 100644 --- a/swad_message.c +++ b/swad_message.c @@ -257,7 +257,8 @@ static void Msg_PutFormMsgUsrs (const char *Content) extern const char *Txt_Send_message; char YN[1+1]; - Gbl.Usrs.LstTchs.NumUsrs = Gbl.Usrs.LstStds.NumUsrs = 0; + Gbl.Usrs.LstTchs.NumUsrs = + Gbl.Usrs.LstStds.NumUsrs = 0; /***** Get parameter that indicates if the message is a reply to another message *****/ Par_GetParToText ("IsReply",YN,1); @@ -268,6 +269,9 @@ static void Msg_PutFormMsgUsrs (const char *Content) /***** Get user's code of possible preselected recipient *****/ Usr_GetParamOtherUsrCodEncrypted (); + /***** Get list of users' IDs or nicknames written explicitely *****/ + Usr_GetListMsgRecipientsWrittenExplicitelyBySender (false); + /***** Get list of users belonging to the current course *****/ if (Gbl.Usrs.Me.IBelongToCurrentCrs || // If there is a course selected and I belong to it Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SYS_ADM) @@ -290,13 +294,8 @@ static void Msg_PutFormMsgUsrs (const char *Content) Gbl.Usrs.LstStds.NumUsrs) /***** Get list of selected users *****/ Usr_GetListSelectedUsrs (); - else - Usr_ShowWarningNoUsersFound (Rol_ROLE_UNKNOWN); } - /***** Get list of users' IDs or nicknames written explicitely *****/ - Usr_GetListMsgRecipientsWrittenExplicitelyBySender (false); - if (Usr_GetIfShowBigList (Gbl.Usrs.LstTchs.NumUsrs + Gbl.Usrs.LstStds.NumUsrs)) { @@ -497,6 +496,29 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (const char *Content) ""); } +/*****************************************************************************/ +/********* Put hidden parameter for another recipient (one nickname) *********/ +/*****************************************************************************/ + +void Msg_PutHiddenParamAnotherRecipient (const struct UsrData *UsrDat) + { + char NicknameWithArroba[Nck_MAX_BYTES_NICKNAME_WITH_ARROBA+1]; + + sprintf (NicknameWithArroba,"@%s",UsrDat->Nickname); + Par_PutHiddenParamString ("OtherRecipients",NicknameWithArroba); + } + +/*****************************************************************************/ +/********* Put hidden parameter for another recipient (one nickname) *********/ +/*****************************************************************************/ + +void Msg_PutHiddenParamOtherRecipients (void) + { + if (Gbl.Usrs.ListOtherRecipients) + if (Gbl.Usrs.ListOtherRecipients[0]) + Par_PutHiddenParamString ("OtherRecipients",Gbl.Usrs.ListOtherRecipients); + } + /*****************************************************************************/ /********************** Receive a new message from a user ********************/ /*****************************************************************************/ diff --git a/swad_message.h b/swad_message.h index d66162a21..ce2d6a7cc 100644 --- a/swad_message.h +++ b/swad_message.h @@ -60,6 +60,8 @@ void Msg_ListEMails (void); // Creates an e-mail message to students void Msg_FormMsgUsrs (void); void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (bool IsReply); +void Msg_PutHiddenParamAnotherRecipient (const struct UsrData *UsrDat); +void Msg_PutHiddenParamOtherRecipients (void); void Msg_RecMsgFromUsr (void); void Msg_ReqDelAllRecMsgs (void); diff --git a/swad_record.c b/swad_record.c index 005f36496..f246c6633 100644 --- a/swad_record.c +++ b/swad_record.c @@ -2030,6 +2030,8 @@ void Rec_ShowCommonRecord (Rec_RecordViewType_t TypeOfView, bool IAmDegAdmin = (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_DEG_ADM); // My current role is degree administrator bool IAmSuperuser = (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SYS_ADM); // My current role is superuser bool HeIsTeacher = (UsrDat->Roles & (1 << Rol_ROLE_TEACHER)); // He/she already is a teacher in any course + bool HeBelongsToCurrentCrs = (UsrDat->RoleInCurrentCrsDB == Rol_ROLE_STUDENT || + UsrDat->RoleInCurrentCrsDB == Rol_ROLE_TEACHER); bool RoleForm = (TypeOfView == Rec_FORM_SIGN_UP || TypeOfView == Rec_FORM_MY_SHARE_RECORD || TypeOfView == Rec_FORM_NEW_RECORD_OTHER_NEW_USR || @@ -2251,7 +2253,10 @@ void Rec_ShowCommonRecord (Rec_RecordViewType_t TypeOfView, /***** Button to send a message *****/ Act_FormStart (ActReqMsgUsr); Grp_PutParamAllGroups (); - Usr_PutParamOtherUsrCodEncrypted (UsrDat->EncryptedUsrCod); + if (HeBelongsToCurrentCrs) + Usr_PutParamOtherUsrCodEncrypted (UsrDat->EncryptedUsrCod); + else + Msg_PutHiddenParamAnotherRecipient (UsrDat); sprintf (Gbl.Title,Txt_Write_a_message_to_X,UsrDat->FullName); Act_LinkFormSubmit (Gbl.Title,ClassData); fprintf (Gbl.F.Out,"
" @@ -2331,9 +2336,11 @@ void Rec_ShowCommonRecord (Rec_RecordViewType_t TypeOfView, /* Put form to send a message */ Act_FormStart (ActReqMsgUsr); Grp_PutParamAllGroups (); - Usr_PutParamOtherUsrCodEncrypted (UsrDat->EncryptedUsrCod); - // Par_PutHiddenParamString ("UsrCodAll",UsrDat->EncryptedUsrCod); - sprintf (Gbl.Title,Txt_Write_a_message_to_X,UsrDat->FullName); + if (HeBelongsToCurrentCrs) + Usr_PutParamOtherUsrCodEncrypted (UsrDat->EncryptedUsrCod); + else + Msg_PutHiddenParamAnotherRecipient (UsrDat); + sprintf (Gbl.Title,Txt_Write_a_message_to_X,UsrDat->FullName); Act_LinkFormSubmit (Gbl.Title,"HEAD_REC_BIG"); } fprintf (Gbl.F.Out,"@%s",UsrDat->Nickname); diff --git a/swad_user.c b/swad_user.c index f65c1c76c..7ecfa2eea 100644 --- a/swad_user.c +++ b/swad_user.c @@ -4728,6 +4728,7 @@ void Usr_PutExtraParamsUsrList (Act_Action_t NextAction) break; case ActReqMsgUsr: Usr_PutHiddenParUsrCodAll (NextAction,Gbl.Usrs.Select.All); + Msg_PutHiddenParamOtherRecipients (); if (Gbl.Msg.IsReply) { Par_PutHiddenParamChar ("IsReply",'Y');