Version 15.241.3

This commit is contained in:
Antonio Cañas Vargas 2016-07-04 17:40:34 +02:00
parent d2df0fb585
commit 3b2d73711c
3 changed files with 49 additions and 42 deletions

View File

@ -136,13 +136,15 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.241.2 (2016-07-04)"
#define Log_PLATFORM_VERSION "SWAD 15.241.3 (2016-07-04)"
#define CSS_FILE "swad15.229.css"
#define JS_FILE "swad15.238.1.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.241.3: Jul 04, 2015 Changes in layout of form to compose message.
Code optimization in list of selected users. (203628 lines)
Version 15.241.2: Jul 04, 2015 Changes in layout of form to compose message. (203619 lines)
Version 15.241.1: Jul 04, 2015 Code refactoring related with forms submit. (203620 lines)
Version 15.241: Jul 04, 2015 When composing a new message, subject and content are shown even if list of users is too big, in order to keep messages that had begun to be written. (203618 lines)

View File

@ -171,6 +171,9 @@ static void Msg_PutFormMsgUsrs (char *Content)
char YN[1+1];
unsigned NumTotalUsrs = 0;
bool ShowUsers = true;
bool GetListUsrs = !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);
Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs =
Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs = 0;
@ -191,35 +194,8 @@ static void Msg_PutFormMsgUsrs (char *Content)
Par_GetParToText ("ShowOnlyOneRecipient",YN,1);
Gbl.Msg.ShowOnlyOneRecipient = (Str_ConvertToUpperLetter (YN[0]) == 'Y');
}
/***** Get list of users' IDs or nicknames written explicitely *****/
Usr_GetListMsgRecipientsWrittenExplicitelyBySender (false);
/***** Get who to show as potential recipients:
- only the selected recipient
- any user (default) *****/
Par_GetParToText ("ShowOnlyOneRecipient",YN,1);
Gbl.Msg.ShowOnlyOneRecipient = (Str_ConvertToUpperLetter (YN[0]) == 'Y');
/***** Get list of users belonging to the current course *****/
if (!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))
{
/***** Get and update type of list,
number of columns in class photo
and preference about view photos *****/
Usr_GetAndUpdatePrefsAboutUsrList ();
/***** Form to select groups *****/
Grp_ShowFormToSelectSeveralGroups (ActReqMsgUsr);
/***** Get and order lists of users from this course *****/
Usr_GetListUsrs (Rol_TEACHER,Sco_SCOPE_CRS);
Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS);
NumTotalUsrs = Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs +
Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs;
}
else
Gbl.Msg.ShowOnlyOneRecipient = false;
/***** Start frame *****/
Lay_StartRoundFrame (NULL,
@ -230,17 +206,40 @@ static void Msg_PutFormMsgUsrs (char *Content)
if (Gbl.Msg.ShowOnlyOneRecipient)
/***** Form to show several potential recipients *****/
Msg_PutLinkToShowMorePotentialRecipients ();
else if (NumTotalUsrs)
else
{
/***** Form to select type of list used for select several users *****/
Usr_ShowFormsToSelectUsrListType (ActReqMsgUsr);
/***** Get list of users belonging to the current course *****/
if (GetListUsrs)
{
/***** Get and update type of list,
number of columns in class photo
and preference about view photos *****/
Usr_GetAndUpdatePrefsAboutUsrList ();
/***** Check if it's a big list *****/
ShowUsers = Usr_GetIfShowBigList (NumTotalUsrs,"CopyMessageToHiddenFields()");
/***** Form to select groups *****/
Grp_ShowFormToSelectSeveralGroups (ActReqMsgUsr);
if (ShowUsers)
/***** Get lists of selected users *****/
Usr_GetListsSelectedUsrsCods ();
/***** Get and order lists of users from this course *****/
Usr_GetListUsrs (Rol_TEACHER,Sco_SCOPE_CRS);
Usr_GetListUsrs (Rol_STUDENT,Sco_SCOPE_CRS);
NumTotalUsrs = Gbl.Usrs.LstUsrs[Rol_TEACHER].NumUsrs +
Gbl.Usrs.LstUsrs[Rol_STUDENT].NumUsrs;
if (NumTotalUsrs)
{
/***** Form to select type of list used for select several users *****/
Usr_ShowFormsToSelectUsrListType (ActReqMsgUsr);
/***** Check if it's a big list *****/
ShowUsers = Usr_GetIfShowBigList (NumTotalUsrs,"CopyMessageToHiddenFields()");
if (ShowUsers)
/***** Get lists of selected users *****/
Usr_GetListsSelectedUsrsCods ();
}
/***** Get list of users' IDs or nicknames written explicitely *****/
Usr_GetListMsgRecipientsWrittenExplicitelyBySender (false);
}
}
/***** Start form to select recipients and write the message *****/

View File

@ -4556,7 +4556,8 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs)
extern const char *Txt_There_are_more_than_one_user_with_the_ID_X_Please_type_a_nick_or_email;
extern const char *Txt_There_is_no_user_with_ID_nick_or_e_mail_X;
extern const char *Txt_The_ID_nickname_or_email_X_is_not_valid;
unsigned Length;
size_t LengthSelectedUsrsCods;
size_t LengthUsrCod;
const char *Ptr;
char UsrIDNickOrEmail[1024+1];
struct UsrData UsrDat;
@ -4565,6 +4566,7 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs)
/***** Allocate memory for the lists of users's IDs *****/
Usr_AllocateListSelectedUsrCodAll ();
LengthSelectedUsrsCods = strlen (Gbl.Usrs.Select.All);
/***** Allocate memory for the lists of recipients written explicetely *****/
Usr_AllocateListOtherRecipients ();
@ -4690,18 +4692,22 @@ bool Usr_GetListMsgRecipientsWrittenExplicitelyBySender (bool WriteErrorMsgs)
if (!Usr_FindUsrCodInListOfSelectedUsrs (UsrDat.EncryptedUsrCod)) // If not in list ==> add it
{
/* Add encrypted user's code to list of users */
if ((Length = strlen (Gbl.Usrs.Select.All)) == 0) // First user in list
if (LengthSelectedUsrsCods == 0) // First user in list
{
if (strlen (UsrDat.EncryptedUsrCod) < Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS)
strcpy (Gbl.Usrs.Select.All,UsrDat.EncryptedUsrCod); // Add first user
}
else // Not first user in list
if (Length < Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS + 1 + strlen (UsrDat.EncryptedUsrCod))
{
LengthUsrCod = strlen (UsrDat.EncryptedUsrCod);
if (LengthSelectedUsrsCods + (1 + LengthUsrCod) < Usr_MAX_BYTES_LIST_ENCRYPTED_USR_CODS)
{
// Add another user
Gbl.Usrs.Select.All[Length] = Par_SEPARATOR_PARAM_MULTIPLE;
Gbl.Usrs.Select.All[LengthSelectedUsrsCods] = Par_SEPARATOR_PARAM_MULTIPLE;
strcat (Gbl.Usrs.Select.All,UsrDat.EncryptedUsrCod);
LengthSelectedUsrsCods += 1 + LengthUsrCod;
}
}
}
}