diff --git a/css/swad15.190.1.css b/css/swad15.190.1.css index 4a79e70f5..ef241f0f4 100644 --- a/css/swad15.190.1.css +++ b/css/swad15.190.1.css @@ -6,7 +6,7 @@ and used to support university teaching. This file is part of SWAD core. - Copyright (C) 1999-2015 Antonio Caņas Vargas + Copyright (C) 1999-2016 Antonio Caņas Vargas This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General 3 License as @@ -2071,6 +2071,14 @@ a:hover img.CENTRE_PHOTO_SHOW margin-bottom:10px; } +/************************************ Forum **********************************/ +.FOR_IMG + { + width:480px; + border-radius:4px; + margin:10px 0; + } + /*********************************** Messages ********************************/ .MSG_TO_ONE_RCP { @@ -2079,6 +2087,12 @@ a:hover img.CENTRE_PHOTO_SHOW text-align:left; vertical-align:middle; } +.MSG_IMG + { + width:480px; + border-radius:4px; + margin:10px 0; + } .MSG_TXT {color:#404040; font-size:13pt;} .MSG_TIT {color:#4D88A1; font-size:13pt;} .MSG_TIT_NEW {color:#4D88A1; font-size:13pt; font-weight:bold;} diff --git a/swad_changelog.h b/swad_changelog.h index 8429ae73f..d83650daf 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -133,14 +133,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.190.6 (2016-04-09)" +#define Log_PLATFORM_VERSION "SWAD 15.191 (2016-04-10)" #define CSS_FILE "swad15.190.1.css" #define JS_FILE "swad15.190.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.191: Apr 09, 2016 Form to attach an image to a forum post. Not finished. (? lines) + Version 15.191: Apr 10, 2016 Forms to attach an image to a forum posts and messages. Not finished. (? lines) Version 15.190.6: Apr 09, 2016 Changes in layout of form to write a new message. (199152 lines) Version 15.190.5: Apr 09, 2016 Changes in layout of form to write a new forum post. (199156 lines) Version 15.190.4: Apr 09, 2016 Changes in layout of form to write a new forum post. (199152 lines) diff --git a/swad_forum.c b/swad_forum.c index 1c5ca4687..543bb26fc 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -238,6 +238,14 @@ const Act_Action_t For_ActionsDisPstFor[For_NUM_TYPES_FORUM] = ActDisPstForSWATch, }; +// Forum images will be saved with: +// - maximum width of For_IMAGE_SAVED_MAX_HEIGHT +// - maximum height of For_IMAGE_SAVED_MAX_HEIGHT +// - maintaining the original aspect ratio (aspect ratio recommended: 3:2) +#define For_IMAGE_SAVED_MAX_WIDTH 768 +#define For_IMAGE_SAVED_MAX_HEIGHT 512 +#define For_IMAGE_SAVED_QUALITY 75 // 1 to 100 + /*****************************************************************************/ /***************************** Private prototypes ***************************/ /*****************************************************************************/ @@ -3701,6 +3709,9 @@ static void For_WriteFormForumPst (bool IsReply,long ThrCod,const char *Subject) extern const char *Txt_New_thread; extern const char *Txt_MSG_Subject; extern const char *Txt_MSG_Message; + extern const char *Txt_Image; + extern const char *Txt_optional; + extern const char *Txt_Image_title_attribution; extern const char *Txt_Send_message; /***** Start frame *****/ @@ -3757,6 +3768,29 @@ static void For_WriteFormForumPst (bool IsReply,long ThrCod,const char *Subject) /***** Help for text editor *****/ Lay_HelpPlainEditor (); + /***** Attached image (optional) *****/ + /* Action to perform on image */ + Par_PutHiddenParamUnsigned ("ImgAct",(unsigned) Img_ACTION_NEW_IMAGE); + + /* Image file */ + fprintf (Gbl.F.Out,"" + "" + "
", + Gbl.Prefs.IconsURL, + Txt_Image,Txt_Image,Txt_optional); + + /* Image title/attribution */ + fprintf (Gbl.F.Out,"", + Txt_Image_title_attribution,Txt_optional, + Img_MAX_BYTES_TITLE); + /***** Send button *****/ Lay_PutCreateButton (Txt_Send_message); @@ -3781,6 +3815,7 @@ void For_RecForumPst (void) unsigned NumUsrsToBeNotifiedByEMail; struct SocialPublishing SocPub; char Content[Cns_MAX_BYTES_LONG_TEXT+1]; + struct Image Image; /***** Get order type, degree and course of the forum *****/ For_GetParamsForum (); @@ -3812,6 +3847,16 @@ void For_RecForumPst (void) Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_LONG_TEXT, Str_TO_RIGOROUS_HTML,false); + /***** Initialize image *****/ + Img_ImageConstructor (&Image); + + /***** Get attached image (action, file and title) *****/ + Img_GetImageFromForm (0,&Image,NULL, + "ImgAct","ImgFil","ImgTit", + For_IMAGE_SAVED_MAX_WIDTH, + For_IMAGE_SAVED_MAX_HEIGHT, + For_IMAGE_SAVED_QUALITY); + /***** Create a new message *****/ if (PstIsAReply) { @@ -3835,6 +3880,9 @@ void For_RecForumPst (void) For_UpdateThrFirstAndLastPst (ThrCod,PstCod,PstCod); } + /***** Free image *****/ + Img_ImageDestructor (&Image); + /***** Increment number of forum posts in my user's figures *****/ Prf_IncrementNumForPstUsr (Gbl.Usrs.Me.UsrDat.UsrCod); diff --git a/swad_message.c b/swad_message.c index 731857ffc..4979b8093 100644 --- a/swad_message.c +++ b/swad_message.c @@ -60,6 +60,14 @@ extern struct Act_Actions Act_Actions[Act_NUM_ACTIONS]; #define Msg_MAX_LENGTH_MESSAGES_QUERY 4096 #define Msg_MAX_LENGTH_STR_ADDR (32*5000) +// Forum images will be saved with: +// - maximum width of Msg_IMAGE_SAVED_MAX_HEIGHT +// - maximum height of Msg_IMAGE_SAVED_MAX_HEIGHT +// - maintaining the original aspect ratio (aspect ratio recommended: 3:2) +#define Msg_IMAGE_SAVED_MAX_WIDTH 768 +#define Msg_IMAGE_SAVED_MAX_HEIGHT 512 +#define Msg_IMAGE_SAVED_QUALITY 75 // 1 to 100 + /*****************************************************************************/ /******************************** Private types ******************************/ /*****************************************************************************/ @@ -275,6 +283,9 @@ static void Msg_PutFormMsgUsrs (const char *Content) extern const char *Txt_Reply_message; extern const char *Txt_New_message; extern const char *Txt_MSG_To; + extern const char *Txt_Image; + extern const char *Txt_optional; + extern const char *Txt_Image_title_attribution; extern const char *Txt_Send_message; char YN[1+1]; @@ -408,6 +419,29 @@ static void Msg_PutFormMsgUsrs (const char *Content) /***** Help for text editor and send button *****/ Lay_HelpPlainEditor (); + /***** Attached image (optional) *****/ + /* Action to perform on image */ + Par_PutHiddenParamUnsigned ("ImgAct",(unsigned) Img_ACTION_NEW_IMAGE); + + /* Image file */ + fprintf (Gbl.F.Out,"" + "" + "
", + Gbl.Prefs.IconsURL, + Txt_Image,Txt_Image,Txt_optional); + + /* Image title/attribution */ + fprintf (Gbl.F.Out,"", + Txt_Image_title_attribution,Txt_optional, + Img_MAX_BYTES_TITLE); + /***** Send button *****/ Lay_PutCreateButton (Txt_Send_message); @@ -693,6 +727,7 @@ void Msg_RecMsgFromUsr (void) bool CreateNotif; bool NotifyByEmail; char Content[Cns_MAX_BYTES_LONG_TEXT+1]; + struct Image Image; bool Error = false; /***** Get data from form *****/ @@ -755,6 +790,16 @@ void Msg_RecMsgFromUsr (void) /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDstData); + /***** Initialize image *****/ + Img_ImageConstructor (&Image); + + /***** Get attached image (action, file and title) *****/ + Img_GetImageFromForm (0,&Image,NULL, + "ImgAct","ImgFil","ImgTit", + Msg_IMAGE_SAVED_MAX_WIDTH, + Msg_IMAGE_SAVED_MAX_HEIGHT, + Msg_IMAGE_SAVED_QUALITY); + /***** Loop over the list Gbl.Usrs.Select.All, that holds the list of the recipients, creating a received message for each recipient *****/ Str_ChangeFormat (Str_FROM_FORM,Str_TO_RIGOROUS_HTML, @@ -827,6 +872,9 @@ void Msg_RecMsgFromUsr (void) } } + /***** Free image *****/ + Img_ImageDestructor (&Image); + /***** Free memory used for user's data *****/ Usr_UsrDataDestructor (&UsrDstData); diff --git a/swad_social.c b/swad_social.c index f7e4695cb..435ebdd68 100644 --- a/swad_social.c +++ b/swad_social.c @@ -51,11 +51,11 @@ /***************************** Private constants *****************************/ /*****************************************************************************/ -#define Soc_WIDTH_TIMELINE "560px" -#define Soc_MAX_SHARERS_FAVERS_SHOWN 7 // Maximum number of users shown who have share/fav a social note +#define Soc_WIDTH_TIMELINE "560px" +#define Soc_MAX_SHARERS_FAVERS_SHOWN 7 // Maximum number of users shown who have share/fav a social note -#define Soc_MAX_BYTES_SUMMARY 1000 -#define Soc_MAX_CHARS_IN_POST 1000 +#define Soc_MAX_BYTES_SUMMARY 1000 +#define Soc_MAX_CHARS_IN_POST 1000 // Number of recent publishings got and shown the first time, before refreshing #define Soc_MAX_NEW_PUBS_TO_GET_AND_SHOW 10000 // Unlimited