From 20e0683453c89f2381bccfa42aaa14e5e324a29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 15 Mar 2017 11:10:16 +0100 Subject: [PATCH] Version 16.156 --- swad_changelog.h | 3 ++- swad_message.c | 2 +- swad_session.c | 48 +++++++++++++++++++++++++++++++----------------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index d8a33f88..2d5b6230 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -209,13 +209,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.155.35 (2017-03-15)" +#define Log_PLATFORM_VERSION "SWAD 16.156 (2017-03-15)" #define CSS_FILE "swad16.147.css" #define JS_FILE "swad16.144.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 16.156: Mar 15, 2017 Fixed bug in messages, reported by Francisco Ocaņa Lara. (217063 lines) Version 16.155.35:Mar 15, 2017 Some help URLs translated to spanish. (217047 lines) Version 16.155.34:Mar 15, 2017 Changes in keywords. (217046 lines) Version 16.155.33:Mar 14, 2017 Some help URLs translated to spanish. (217042 lines) diff --git a/swad_message.c b/swad_message.c index 3d020f4b..24f01e30 100644 --- a/swad_message.c +++ b/swad_message.c @@ -158,6 +158,7 @@ void Msg_FormMsgUsrs (void) Par_GetParAndChangeFormat ("HiddenContent",Content,Cns_MAX_BYTES_LONG_TEXT, Str_TO_TEXT,false); + /***** Show a form to compose a message to users *****/ Msg_PutFormMsgUsrs (Content); } @@ -198,7 +199,6 @@ static void Msg_PutFormMsgUsrs (char Content[Cns_MAX_BYTES_LONG_TEXT + 1]) GetUsrsInCrs = !Gbl.Msg.ShowOnlyOneRecipient && // Show list of potential recipients (Gbl.Usrs.Me.IBelongToCurrentCrs || // If there is a course selected and I belong to it Gbl.Usrs.Me.LoggedRole == Rol_SYS_ADM); - if (GetUsrsInCrs) { /***** Get and update type of list, diff --git a/swad_session.c b/swad_session.c index 1eb182a9..3b951e64 100644 --- a/swad_session.c +++ b/swad_session.c @@ -347,6 +347,8 @@ bool Ses_GetSessionData (void) void Ses_InsertHiddenParInDB (Act_Action_t Action,const char *ParamName,const char *ParamValue) { char *Query; + size_t LengthParamName; + size_t LengthParamValue; size_t MaxLength; /***** Before of inserting the first hidden parameter passed to the next action, @@ -354,25 +356,37 @@ void Ses_InsertHiddenParInDB (Act_Action_t Action,const char *ParamName,const ch Ses_RemoveHiddenParFromThisSession (); /***** For a unique session-action-parameter, don't insert a parameter more than one time *****/ - if (!Ses_CheckIfHiddenParIsAlreadyInDB (Action,ParamName)) - { - /***** Allocate space for query *****/ - MaxLength = 256 + Ses_BYTES_SESSION_ID + strlen (ParamName) + strlen (ParamValue); - if ((Query = (char *) malloc (MaxLength + 1)) == NULL) - Lay_ShowErrorAndExit ("Not enough memory for query."); + if (ParamName) + if ((LengthParamName = strlen (ParamName))) + if (!Ses_CheckIfHiddenParIsAlreadyInDB (Action,ParamName)) + { + /***** Allocate space for query *****/ + if (ParamValue) + LengthParamValue = strlen (ParamValue); + else + LengthParamValue = 0; + MaxLength = 256 + + Ses_BYTES_SESSION_ID + + LengthParamName + + LengthParamValue; + if ((Query = (char *) malloc (MaxLength + 1)) == NULL) + Lay_ShowErrorAndExit ("Not enough memory for query."); - /***** Insert parameter in the database *****/ - sprintf (Query,"INSERT INTO hidden_params" - " (SessionId,Action,ParamName,ParamValue)" - " VALUES" - " ('%s','%d','%s','%s')", - Gbl.Session.Id,(int) Action,ParamName,ParamValue); - DB_QueryINSERT (Query,"can not create hidden parameter"); - Gbl.HiddenParamsInsertedIntoDB = true; + /***** Insert parameter in the database *****/ + sprintf (Query,"INSERT INTO hidden_params" + " (SessionId,Action,ParamName,ParamValue)" + " VALUES" + " ('%s','%d','%s','%s')", + Gbl.Session.Id,(int) Action, + ParamName, + LengthParamValue ? ParamValue : + ""); + DB_QueryINSERT (Query,"can not create hidden parameter"); + Gbl.HiddenParamsInsertedIntoDB = true; - /***** Free query *****/ - free ((void *) Query); - } + /***** Free query *****/ + free ((void *) Query); + } } /*****************************************************************************/