From 5796cd39fcc840d04399229c5d4c9973bedc83d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 1 Jul 2016 01:21:34 +0200 Subject: [PATCH] Version 15.237 --- js/{swad15.226.js => swad15.237.js} | 16 ++++ swad_changelog.h | 9 ++- swad_message.c | 110 +++++++++++++++------------- swad_parameter.c | 2 - 4 files changed, 82 insertions(+), 55 deletions(-) rename js/{swad15.226.js => swad15.237.js} (98%) diff --git a/js/swad15.226.js b/js/swad15.237.js similarity index 98% rename from js/swad15.226.js rename to js/swad15.237.js index 8b50ddecb..7e223e19f 100644 --- a/js/swad15.226.js +++ b/js/swad15.237.js @@ -1248,3 +1248,19 @@ function GetNumDaysFebruary (Year) { function GetIfLeapYear (Year) { return (Year % 4 == 0) && ((Year % 100 != 0) || (Year % 400 == 0)); } + +/*****************************************************************************/ +/*********** Copy message subject to form "Show more recipients" *************/ +/*****************************************************************************/ + +function CopySubjectToShowMoreRecipients () { + document.getElementById ('ShowMoreRecipientsSubject').value = document.getElementById ('MsgSubject').value; +} + +/*****************************************************************************/ +/*********** Copy message content to form "Show more recipients" *************/ +/*****************************************************************************/ + +function CopyContentToShowMoreRecipients () { + document.getElementById ('ShowMoreRecipientsContent').value = document.getElementById ('MsgContent').value; +} diff --git a/swad_changelog.h b/swad_changelog.h index 219736736..3f847fc08 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -125,22 +125,23 @@ // TODO: FIX BUG: Searching messages received gives unordered list // TODO: Put Raśl Hinojosa (iSWAD developer) in a row of marks file of EC (B,C) and publish file +// TODO: Check if white lines are correct when composing a message and clicking in "Show more recipients" -// TODO: Modify WS function getUsers changing: userRole to indicate all users, and a new parameter filter (search string (name, @nickname, mail)) to restring number of users // TODO: Add a new WS function to count the nunmber of users to return in call to function getUsers /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.236 (2016-06-30)" +#define Log_PLATFORM_VERSION "SWAD 15.237 (2016-07-01)" #define CSS_FILE "swad15.229.css" -#define JS_FILE "swad15.236.js" +#define JS_FILE "swad15.237.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.236: Jun 30, 2015 The form "Show more recipients" now have a hidden field with the subject. (204343 lines) + Version 15.237: Jul 01, 2015 The form "Show more recipients" now have a hidden field with the content. (203243 lines) + Version 15.236: Jun 30, 2015 The form "Show more recipients" now have a hidden field with the subject. (? lines) Version 15.235.1: Jun 30, 2015 Minor change in icon to download files. (203206 lines) Copy icons icon/download64x64.png diff --git a/swad_message.c b/swad_message.c index 2b29903a6..5634325d4 100644 --- a/swad_message.c +++ b/swad_message.c @@ -75,7 +75,7 @@ extern struct Globals Gbl; /**************************** Internal prototypes ****************************/ /*****************************************************************************/ -static void Msg_PutFormMsgUsrs (const char *Content); +static void Msg_PutFormMsgUsrs (char *Content); static void Msg_ShowSentOrReceivedMessages (Msg_TypeOfMessages_t TypeOfMessages); static unsigned long Msg_GetNumUsrsBannedByMe (void); @@ -100,7 +100,7 @@ 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_WriteFormSubjectAndContentMsgToUsrs (char *Content); static void Msg_ShowNumMsgsDeleted (unsigned NumMsgs); static void Msg_MakeFilterFromToSubquery (char *FilterFromToSubquery); @@ -129,7 +129,7 @@ static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod, static void Msg_GetMsgContent (long MsgCod,char *Content,struct Image *Image); static void Msg_WriteSentOrReceivedMsgSubject (Msg_TypeOfMessages_t TypeOfMessages,long MsgCod,const char *Subject,bool Open,bool Expanded); -static void Msg_WriteFormToReply (long MsgCod,long CrsCod,const char *Subject, +static void Msg_WriteFormToReply (long MsgCod,long CrsCod, bool ThisCrs,bool Replied, const struct UsrData *UsrDat); static void Msg_WriteMsgFrom (struct UsrData *UsrDat,bool Deleted); @@ -272,7 +272,11 @@ void Msg_FormMsgUsrs (void) { char Content[Cns_MAX_BYTES_LONG_TEXT+1]; - Content[0] = '\0'; + /***** Get possible subject and body of the message *****/ + Par_GetParToHTML ("Subject",Gbl.Msg.Subject,Cns_MAX_BYTES_SUBJECT); + Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_LONG_TEXT, + Str_TO_TEXT,false); + Msg_PutFormMsgUsrs (Content); } @@ -280,7 +284,7 @@ void Msg_FormMsgUsrs (void) /***************** Put a form to write a new message to users ****************/ /*****************************************************************************/ -static void Msg_PutFormMsgUsrs (const char *Content) +static void Msg_PutFormMsgUsrs (char *Content) { extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *Txt_Reply_message; @@ -476,8 +480,13 @@ static void Msg_PutParamsShowMorePotentialRecipients (void) if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) Usr_PutParamOtherUsrCodEncrypted (); + /***** Hidden params to send subject and content. + When the user edit the subject or the content, + they are copied here. *****/ fprintf (Gbl.F.Out,""); + " name=\"Subject\" value=\"\" />" + ""); } /*****************************************************************************/ @@ -567,7 +576,7 @@ static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void) /****** Write form fields with subject and content of a message to users *****/ /*****************************************************************************/ -static void Msg_WriteFormSubjectAndContentMsgToUsrs (const char *Content) +static void Msg_WriteFormSubjectAndContentMsgToUsrs (char *Content) { extern const char *The_ClassForm[The_NUM_THEMES]; extern const char *Txt_MSG_Subject; @@ -578,14 +587,11 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (const char *Content) MYSQL_ROW row; unsigned long NumRows; long MsgCod; - char OriginalTxt[Cns_MAX_BYTES_LONG_TEXT+1]; + bool SubjectAndContentComeFromForm = (Gbl.Msg.Subject[0] || Content[0]); /***** Get possible code (of original message if it's a reply) *****/ MsgCod = Msg_GetParamMsgCod (); - /***** Get possible subject *****/ - Par_GetParToHTML ("Subject",Gbl.Msg.Subject,Cns_MAX_BYTES_SUBJECT); - /***** Subject of new message *****/ fprintf (Gbl.F.Out,"" "" @@ -601,43 +607,54 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (const char *Content) /***** If message is a reply ==> get original message *****/ if (MsgCod > 0) // It's a reply { - /***** Get subject and content of message from database *****/ - sprintf (Query,"SELECT Subject,Content FROM msg_content" - " WHERE MsgCod='%ld'",MsgCod); - NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get message content"); + if (!SubjectAndContentComeFromForm) + { + /***** Get subject and content of message from database *****/ + sprintf (Query,"SELECT Subject,Content FROM msg_content" + " WHERE MsgCod='%ld'",MsgCod); + NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get message content"); - /***** Result should have a unique row *****/ - if (NumRows != 1) - Lay_ShowErrorAndExit ("Error when getting message."); + /***** Result should have a unique row *****/ + if (NumRows != 1) + Lay_ShowErrorAndExit ("Error when getting message."); - row = mysql_fetch_row (mysql_res); + row = mysql_fetch_row (mysql_res); - /***** Subject of new message *****/ - if (Gbl.Msg.Subject[0]) // Subject comes from form - fprintf (Gbl.F.Out,"%s",Gbl.Msg.Subject); - else // Subject comes from database - fprintf (Gbl.F.Out,"Re: %s",row[0]); - fprintf (Gbl.F.Out,"" + /* Get subject */ + strncpy (Gbl.Msg.Subject,row[0],Cns_MAX_BYTES_SUBJECT); + Gbl.Msg.Subject[Cns_MAX_BYTES_SUBJECT] = '\0'; + + /* Get content */ + strncpy (Content,row[1],Cns_MAX_BYTES_LONG_TEXT); + Content[Cns_MAX_BYTES_LONG_TEXT] = '\0'; + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + + /***** Write subject *****/ + if (!SubjectAndContentComeFromForm) + fprintf (Gbl.F.Out,"Re: "); + fprintf (Gbl.F.Out,"%s" + "" "" - ""); + "", + Gbl.Msg.Subject); - /***** Content of new message *****/ + /***** Write content *****/ fprintf (Gbl.F.Out,"" "" "%s: " "" "" - "