diff --git a/swad_changelog.h b/swad_changelog.h index 13b3dff8c..313610c4a 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -207,14 +207,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.155.11 (2017-03-11)" +#define Log_PLATFORM_VERSION "SWAD 16.155.12 (2017-03-12)" #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.155.11:Mar 11, 2017 Adjusting size of database fields. (? lines) + Version 16.155.12:Mar 12, 2017 Fixed bug while sending a message to several users, reported by Javier Fernández Baldomero. (216721 lines) + Version 16.155.11:Mar 11, 2017 Adjusting size of database fields. (216711 lines) 1 change necessary in database: ALTER TABLE forum_post CHANGE COLUMN ImageTitle ImageTitle VARCHAR(2047) NOT NULL; diff --git a/swad_database.c b/swad_database.c index 78165a0f4..e6cd75929 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1182,11 +1182,11 @@ mysql> DESCRIBE forum_thr_clip; 3 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS forum_thr_clip (" - "ThrCod INT NOT NULL," - "UsrCod INT NOT NULL," - "TimeInsert TIMESTAMP NOT NULL," - "UNIQUE INDEX(ThrCod)," - "UNIQUE INDEX(UsrCod))"); + "ThrCod INT NOT NULL," + "UsrCod INT NOT NULL," + "TimeInsert TIMESTAMP NOT NULL," + "UNIQUE INDEX(ThrCod)," + "UNIQUE INDEX(UsrCod))"); /***** Table forum_thr_read *****/ /* @@ -1201,10 +1201,10 @@ mysql> DESCRIBE forum_thr_read; 3 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS forum_thr_read (" - "ThrCod INT NOT NULL," - "UsrCod INT NOT NULL," - "ReadTime DATETIME NOT NULL," - "UNIQUE INDEX(ThrCod,UsrCod))"); + "ThrCod INT NOT NULL," + "UsrCod INT NOT NULL," + "ReadTime DATETIME NOT NULL," + "UNIQUE INDEX(ThrCod,UsrCod))"); /***** Table forum_thread *****/ /* @@ -1221,16 +1221,16 @@ mysql> DESCRIBE forum_thread; 5 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS forum_thread (" - "ThrCod INT NOT NULL AUTO_INCREMENT," - "ForumType TINYINT NOT NULL," - "Location INT NOT NULL DEFAULT -1," - "FirstPstCod INT NOT NULL," - "LastPstCod INT NOT NULL," - "UNIQUE INDEX(ThrCod)," - "INDEX(ForumType)," - "INDEX(Location)," - "UNIQUE INDEX(FirstPstCod)," - "UNIQUE INDEX(LastPstCod))"); + "ThrCod INT NOT NULL AUTO_INCREMENT," + "ForumType TINYINT NOT NULL," + "Location INT NOT NULL DEFAULT -1," + "FirstPstCod INT NOT NULL," + "LastPstCod INT NOT NULL," + "UNIQUE INDEX(ThrCod)," + "INDEX(ForumType)," + "INDEX(Location)," + "UNIQUE INDEX(FirstPstCod)," + "UNIQUE INDEX(LastPstCod))"); /***** Table hidden_params *****/ /* diff --git a/swad_message.c b/swad_message.c index be80d060a..301ca6d24 100644 --- a/swad_message.c +++ b/swad_message.c @@ -718,7 +718,6 @@ void Msg_RecMsgFromUsr (void) Content,Cns_MAX_BYTES_LONG_TEXT,false); Ptr = Gbl.Usrs.Select.All; NumRecipients = 0; - while (*Ptr) { Par_GetNextStrUntilSeparParamMult (&Ptr,UsrDstData.EncryptedUsrCod,Cry_BYTES_ENCRYPTED_STR_SHA256_BASE64); diff --git a/swad_user.c b/swad_user.c index 6c9e9afba..9e23b40a3 100644 --- a/swad_user.c +++ b/swad_user.c @@ -5248,7 +5248,7 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs) { ListUsrCods.NumUsrs = 1; Usr_AllocateListUsrCods (&ListUsrCods); - ListUsrCods.Lst[0] = Gbl.Usrs.Other.UsrDat.UsrCod; + ListUsrCods.Lst[0] = UsrDat.UsrCod; } else { @@ -5339,23 +5339,34 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs) /* Find if encrypted user's code is already in list */ if (!Usr_FindUsrCodInListOfSelectedUsrs (UsrDat.EncryptedUsrCod)) // If not in list ==> add it { + LengthUsrCod = strlen (UsrDat.EncryptedUsrCod); + /* Add encrypted user's code to list of users */ - if (LengthSelectedUsrsCods == 0) // First user in list + if (LengthSelectedUsrsCods == 0) // First user in list { - if (strlen (UsrDat.EncryptedUsrCod) < Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS) - Str_Copy (Gbl.Usrs.Select.All,UsrDat.EncryptedUsrCod, - Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); // Add first user - } - else // Not first user in list - { - LengthUsrCod = strlen (UsrDat.EncryptedUsrCod); - if (LengthSelectedUsrsCods + (1 + LengthUsrCod) < Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS) + if (LengthUsrCod < Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS) { - // Add another user + /* Add user */ + Str_Copy (Gbl.Usrs.Select.All, + UsrDat.EncryptedUsrCod, + Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); + LengthSelectedUsrsCods = LengthUsrCod; + } + } + else // Not first user in list + { + if (LengthSelectedUsrsCods + (1 + LengthUsrCod) < + Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS) + { + /* Add separator */ Gbl.Usrs.Select.All[LengthSelectedUsrsCods] = Par_SEPARATOR_PARAM_MULTIPLE; - Str_Concat (Gbl.Usrs.Select.All,UsrDat.EncryptedUsrCod, - Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); - LengthSelectedUsrsCods += 1 + LengthUsrCod; + LengthSelectedUsrsCods++; + + /* Add user */ + Str_Copy (Gbl.Usrs.Select.All + LengthSelectedUsrsCods, + UsrDat.EncryptedUsrCod, + Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS); + LengthSelectedUsrsCods += LengthUsrCod; } } }