Version 15.237

This commit is contained in:
Antonio Cañas Vargas 2016-07-01 01:21:34 +02:00
parent 05e9000779
commit 5796cd39fc
4 changed files with 82 additions and 55 deletions

View File

@ -1248,3 +1248,19 @@ function GetNumDaysFebruary (Year) {
function GetIfLeapYear (Year) { function GetIfLeapYear (Year) {
return (Year % 4 == 0) && ((Year % 100 != 0) || (Year % 400 == 0)); 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;
}

View File

@ -125,22 +125,23 @@
// TODO: FIX BUG: Searching messages received gives unordered list // 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: 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 // TODO: Add a new WS function to count the nunmber of users to return in call to function getUsers
/*****************************************************************************/ /*****************************************************************************/
/****************************** Public constants *****************************/ /****************************** 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 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: // 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 // 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) Version 15.235.1: Jun 30, 2015 Minor change in icon to download files. (203206 lines)
Copy icons icon/download64x64.png Copy icons icon/download64x64.png

View File

@ -75,7 +75,7 @@ extern struct Globals Gbl;
/**************************** Internal prototypes ****************************/ /**************************** Internal prototypes ****************************/
/*****************************************************************************/ /*****************************************************************************/
static void Msg_PutFormMsgUsrs (const char *Content); static void Msg_PutFormMsgUsrs (char *Content);
static void Msg_ShowSentOrReceivedMessages (Msg_TypeOfMessages_t TypeOfMessages); static void Msg_ShowSentOrReceivedMessages (Msg_TypeOfMessages_t TypeOfMessages);
static unsigned long Msg_GetNumUsrsBannedByMe (void); static unsigned long Msg_GetNumUsrsBannedByMe (void);
@ -100,7 +100,7 @@ static void Msg_PutLinkToShowMorePotentialRecipients (void);
static void Msg_PutParamsShowMorePotentialRecipients (void); static void Msg_PutParamsShowMorePotentialRecipients (void);
static void Msg_ShowOneUniqueRecipient (void); static void Msg_ShowOneUniqueRecipient (void);
static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (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_ShowNumMsgsDeleted (unsigned NumMsgs);
static void Msg_MakeFilterFromToSubquery (char *FilterFromToSubquery); 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_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_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, bool ThisCrs,bool Replied,
const struct UsrData *UsrDat); const struct UsrData *UsrDat);
static void Msg_WriteMsgFrom (struct UsrData *UsrDat,bool Deleted); 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]; 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); Msg_PutFormMsgUsrs (Content);
} }
@ -280,7 +284,7 @@ void Msg_FormMsgUsrs (void)
/***************** Put a form to write a new message to users ****************/ /***************** 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 *The_ClassForm[The_NUM_THEMES];
extern const char *Txt_Reply_message; extern const char *Txt_Reply_message;
@ -476,8 +480,13 @@ static void Msg_PutParamsShowMorePotentialRecipients (void)
if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) if (Gbl.Usrs.Other.UsrDat.UsrCod > 0)
Usr_PutParamOtherUsrCodEncrypted (); 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,"<input type=\"hidden\" id=\"ShowMoreRecipientsSubject\"" fprintf (Gbl.F.Out,"<input type=\"hidden\" id=\"ShowMoreRecipientsSubject\""
" name=\"Subject\" value=\"\" />"); " name=\"Subject\" value=\"\" />"
"<input type=\"hidden\" id=\"ShowMoreRecipientsContent\""
" name=\"Content\" value=\"\" />");
} }
/*****************************************************************************/ /*****************************************************************************/
@ -567,7 +576,7 @@ static void Msg_WriteFormUsrsIDsOrNicksOtherRecipients (void)
/****** Write form fields with subject and content of a message to users *****/ /****** 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 *The_ClassForm[The_NUM_THEMES];
extern const char *Txt_MSG_Subject; extern const char *Txt_MSG_Subject;
@ -578,14 +587,11 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (const char *Content)
MYSQL_ROW row; MYSQL_ROW row;
unsigned long NumRows; unsigned long NumRows;
long MsgCod; 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) *****/ /***** Get possible code (of original message if it's a reply) *****/
MsgCod = Msg_GetParamMsgCod (); MsgCod = Msg_GetParamMsgCod ();
/***** Get possible subject *****/
Par_GetParToHTML ("Subject",Gbl.Msg.Subject,Cns_MAX_BYTES_SUBJECT);
/***** Subject of new message *****/ /***** Subject of new message *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_TOP\">" "<td class=\"%s RIGHT_TOP\">"
@ -601,43 +607,54 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (const char *Content)
/***** If message is a reply ==> get original message *****/ /***** If message is a reply ==> get original message *****/
if (MsgCod > 0) // It's a reply if (MsgCod > 0) // It's a reply
{ {
/***** Get subject and content of message from database *****/ if (!SubjectAndContentComeFromForm)
sprintf (Query,"SELECT Subject,Content FROM msg_content" {
" WHERE MsgCod='%ld'",MsgCod); /***** Get subject and content of message from database *****/
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get message content"); 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 *****/ /***** Result should have a unique row *****/
if (NumRows != 1) if (NumRows != 1)
Lay_ShowErrorAndExit ("Error when getting message."); Lay_ShowErrorAndExit ("Error when getting message.");
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/***** Subject of new message *****/ /* Get subject */
if (Gbl.Msg.Subject[0]) // Subject comes from form strncpy (Gbl.Msg.Subject,row[0],Cns_MAX_BYTES_SUBJECT);
fprintf (Gbl.F.Out,"%s",Gbl.Msg.Subject); Gbl.Msg.Subject[Cns_MAX_BYTES_SUBJECT] = '\0';
else // Subject comes from database
fprintf (Gbl.F.Out,"Re: %s",row[0]); /* Get content */
fprintf (Gbl.F.Out,"</textarea>" 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"
"</textarea>"
"</td>" "</td>"
"</tr>"); "</tr>",
Gbl.Msg.Subject);
/***** Content of new message *****/ /***** Write content *****/
fprintf (Gbl.F.Out,"<tr>" fprintf (Gbl.F.Out,"<tr>"
"<td class=\"%s RIGHT_TOP\">" "<td class=\"%s RIGHT_TOP\">"
"%s: " "%s: "
"</td>" "</td>"
"<td class=\"LEFT_MIDDLE\">" "<td class=\"LEFT_MIDDLE\">"
"<textarea name=\"Content\" cols=\"72\" rows=\"20\">", "<textarea id=\"MsgContent\" name=\"Content\""
" cols=\"72\" rows=\"20\""
" onblur=\"CopyContentToShowMoreRecipients();\">",
The_ClassForm[Gbl.Prefs.Theme],Txt_MSG_Message); The_ClassForm[Gbl.Prefs.Theme],Txt_MSG_Message);
if (!SubjectAndContentComeFromForm)
fprintf (Gbl.F.Out,"\n\n\n\n\n----- %s -----\n", fprintf (Gbl.F.Out,"\n\n\n\n\n----- %s -----\n",
Txt_Original_message); Txt_Original_message);
strncpy (OriginalTxt,row[1],Cns_MAX_BYTES_LONG_TEXT); Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,false,true);
OriginalTxt[Cns_MAX_BYTES_LONG_TEXT] = '\0';
Msg_WriteMsgContent (OriginalTxt,Cns_MAX_BYTES_LONG_TEXT,false,true);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
} }
else // It's not a reply else // It's not a reply
{ {
@ -653,7 +670,10 @@ static void Msg_WriteFormSubjectAndContentMsgToUsrs (const char *Content)
"%s: " "%s: "
"</td>" "</td>"
"<td class=\"LEFT_MIDDLE\">" "<td class=\"LEFT_MIDDLE\">"
"<textarea name=\"Content\" cols=\"72\" rows=\"20\">%s", "<textarea id=\"MsgContent\" name=\"Content\""
" cols=\"72\" rows=\"20\""
" onblur=\"CopyContentToShowMoreRecipients();\">"
"%s",
The_ClassForm[Gbl.Prefs.Theme], The_ClassForm[Gbl.Prefs.Theme],
Txt_MSG_Message, Txt_MSG_Message,
Content); Content);
@ -2926,9 +2946,7 @@ static void Msg_ShowASentOrReceivedMessage (Msg_TypeOfMessages_t TypeOfMessages,
if (TypeOfMessages == Msg_MESSAGES_RECEIVED && if (TypeOfMessages == Msg_MESSAGES_RECEIVED &&
Gbl.Usrs.Me.LoggedRole >= Rol_VISITOR) Gbl.Usrs.Me.LoggedRole >= Rol_VISITOR)
// Guests (users without courses) can read messages but not reply them // Guests (users without courses) can read messages but not reply them
Msg_WriteFormToReply (MsgCod,CrsCod,Subject, Msg_WriteFormToReply (MsgCod,CrsCod,FromThisCrs,Replied,&UsrDat);
FromThisCrs,Replied,
&UsrDat);
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>" "</tr>"
"</table>" "</table>"
@ -2977,10 +2995,7 @@ static void Msg_ShowASentOrReceivedMessage (Msg_TypeOfMessages_t TypeOfMessages,
/***** Show content and image *****/ /***** Show content and image *****/
fprintf (Gbl.F.Out,"<td colspan=\"2\" class=\"MSG_TXT LEFT_TOP\">"); fprintf (Gbl.F.Out,"<td colspan=\"2\" class=\"MSG_TXT LEFT_TOP\">");
if (Content[0]) if (Content[0])
{
Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false); Msg_WriteMsgContent (Content,Cns_MAX_BYTES_LONG_TEXT,true,false);
// fprintf (Gbl.F.Out,"<br />&nbsp;");
}
Img_ShowImage (&Image,"MSG_IMG_CONTAINER","MSG_IMG"); Img_ShowImage (&Image,"MSG_IMG_CONTAINER","MSG_IMG");
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
"</tr>"); "</tr>");
@ -3213,7 +3228,7 @@ bool Msg_WriteCrsOrgMsg (long CrsCod)
/************************* Write form to reply a message *********************/ /************************* Write form to reply a message *********************/
/*****************************************************************************/ /*****************************************************************************/
static void Msg_WriteFormToReply (long MsgCod,long CrsCod,const char *Subject, static void Msg_WriteFormToReply (long MsgCod,long CrsCod,
bool FromThisCrs,bool Replied, bool FromThisCrs,bool Replied,
const struct UsrData *UsrDat) const struct UsrData *UsrDat)
{ {
@ -3236,9 +3251,6 @@ static void Msg_WriteFormToReply (long MsgCod,long CrsCod,const char *Subject,
Msg_PutHiddenParamMsgCod (MsgCod); Msg_PutHiddenParamMsgCod (MsgCod);
Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod);
Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y'); Par_PutHiddenParamChar ("ShowOnlyOneRecipient",'Y');
fprintf (Gbl.F.Out,"<input type=\"hidden\" name=\"Subject\""
" value=\"Re: %s\" />",
Subject);
/****** Link and form end *****/ /****** Link and form end *****/
Act_LinkFormSubmit (FromThisCrs ? (Replied ? Txt_Reply_again : Act_LinkFormSubmit (FromThisCrs ? (Replied ? Txt_Reply_again :
@ -3537,7 +3549,7 @@ static void Msg_PutFormToDeleteMessage (long MsgCod,Msg_TypeOfMessages_t TypeOfM
} }
/*****************************************************************************/ /*****************************************************************************/
/******************** Write the texto (content) of a message *****************/ /********************* Write the text (content) of a message *****************/
/*****************************************************************************/ /*****************************************************************************/
void Msg_WriteMsgContent (char *Content,unsigned long MaxLength,bool InsertLinks,bool ChangeBRToRet) void Msg_WriteMsgContent (char *Content,unsigned long MaxLength,bool InsertLinks,bool ChangeBRToRet)

View File

@ -922,8 +922,6 @@ unsigned Par_GetParAndChangeFormat (const char *ParamName,char *ParamValue,size_
unsigned NumTimes = Par_GetParameter (Par_PARAM_SINGLE,ParamName, unsigned NumTimes = Par_GetParameter (Par_PARAM_SINGLE,ParamName,
ParamValue,MaxBytes,NULL); ParamValue,MaxBytes,NULL);
// Lay_ShowAlert (Lay_ERROR,ParamValue); !!!!!!!!!!!!
Str_ChangeFormat (Str_FROM_FORM,ChangeTo, Str_ChangeFormat (Str_FROM_FORM,ChangeTo,
ParamValue,MaxBytes,RemoveLeadingAndTrailingSpaces); ParamValue,MaxBytes,RemoveLeadingAndTrailingSpaces);
return NumTimes; return NumTimes;