diff --git a/swad_assignment.c b/swad_assignment.c index 56913d34..16fb63fd 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -830,8 +830,9 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT /*****************************************************************************/ // This function may be called inside a web service -void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, - long AsgCod,unsigned MaxChars,bool GetContent) +void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long AsgCod,bool GetContent) { char Query[512]; MYSQL_RES *mysql_res; @@ -854,9 +855,7 @@ void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **Cont /***** Get summary *****/ Str_Copy (SummaryStr,row[0], - Cns_MAX_BYTES_TEXT); - if (MaxChars) - Str_LimitLengthHTMLStr (SummaryStr,MaxChars); + Cns_MAX_BYTES_SUMMARY_STRING); /***** Get content *****/ if (GetContent) diff --git a/swad_assignment.h b/swad_assignment.h index 0db00cad..995751fe 100644 --- a/swad_assignment.h +++ b/swad_assignment.h @@ -75,8 +75,9 @@ void Asg_GetDataOfAssignmentByCod (struct Assignment *Asg); void Asg_GetDataOfAssignmentByFolder (struct Assignment *Asg); void Asg_FreeListAssignments (void); -void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, - long AsgCod,unsigned MaxChars,bool GetContent); +void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long AsgCod,bool GetContent); long Asg_GetParamAsgCod (void); void Asg_ReqRemAssignment (void); diff --git a/swad_changelog.h b/swad_changelog.h index c4231370..68cf4d40 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -193,17 +193,23 @@ // TODO: System admin should view link "Visits to course" // TODO: Un administrador de institución, ¿debería poder cambiar la contraseña de un usuario de esa institución? No lo tengo claro. +// TODO: Subject in forum_post should be VARCHAR(255) in order to be copied directly to SummaryStr +// TODO: Add a Subject (VARCHAR(255)) to notices to be used as SummaryStr +// TODO: Subject in msg_content and msg_content_deleted should be VARCHAR(255) in order to be copied directly to SummaryStr +// TODO: Check how to get a summary of a social post or comments + /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.147.11 (2017-03-06)" +#define Log_PLATFORM_VERSION "SWAD 16.148 (2017-03-06)" #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.148: Mar 06, 2017 Code refactoring in notifications. (216393 lines) Version 16.147.11:Mar 06, 2017 Changes in names of zipped files. (216388 lines) Version 16.147.10:Mar 06, 2017 Changes in layout of users' listing. (216394 lines) Version 16.147.9: Mar 06, 2017 Changes in layout of header. (216389 lines) diff --git a/swad_config.h b/swad_config.h index 29cfb9a1..4115b6a6 100644 --- a/swad_config.h +++ b/swad_config.h @@ -268,10 +268,6 @@ /* Courses */ #define Cfg_MIN_NUM_COURSES_TO_CONFIRM_SHOW_BIG_LIST 500 // If the number of courses in a list is greater than this, ask me for confirmation before showing the list -/* Notifications */ -#define Cfg_MAX_CHARS_NOTIF_SUMMARY_SWAD 50 -#define Cfg_MAX_CHARS_NOTIF_SUMMARY_WEB_SERVICE 100 - /*****************************************************************************/ /*********************** Directories, folder and files ***********************/ /*****************************************************************************/ diff --git a/swad_constant.h b/swad_constant.h index 21cf71ec..501793ef 100644 --- a/swad_constant.h +++ b/swad_constant.h @@ -43,6 +43,8 @@ #define Cns_MAX_LENGTH_SUBJECT (256 - 1) #define Cns_MAX_BYTES_SUBJECT (Cns_MAX_LENGTH_SUBJECT * Str_MAX_CHARACTER) +#define Cns_MAX_BYTES_SUMMARY_STRING (256 - 1) + #define Cns_MAX_BYTES_TEXT ( 64 * 1024 - 1) // Used for subjects and other medium texts #define Cns_MAX_BYTES_LONG_TEXT (256 * 1024 - 1) // Used for big contents diff --git a/swad_enrollment.c b/swad_enrollment.c index 69059dac..a0814e67 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -385,9 +385,8 @@ void Enr_ReqAcceptRegisterInCrs (void) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], - long CrsCod,long UsrCod, - unsigned MaxChars) +void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + long CrsCod,long UsrCod) { extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; char Query[256]; @@ -423,9 +422,7 @@ void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], /* Role (row[0]) */ Role = Rol_ConvertUnsignedStrToRole (row[0]); Str_Copy (SummaryStr,Txt_ROLES_SINGUL_Abc[Role][UsrDat.Sex], - Cns_MAX_BYTES_TEXT); - if (MaxChars) - Str_LimitLengthHTMLStr (SummaryStr,MaxChars); + Cns_MAX_BYTES_SUMMARY_STRING); /* Free memory used for user's data */ Usr_UsrDataDestructor (&UsrDat); @@ -1948,8 +1945,9 @@ void Enr_SignUpInCrs (void) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, - long ReqCod,unsigned MaxChars,bool GetContent) +void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long ReqCod,bool GetContent) { extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; char Query[256]; @@ -1985,9 +1983,7 @@ void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char /* Role (row[1]) */ DesiredRole = Rol_ConvertUnsignedStrToRole (row[1]); Str_Copy (SummaryStr,Txt_ROLES_SINGUL_Abc[DesiredRole][UsrDat.Sex], - Cns_MAX_BYTES_TEXT); - if (MaxChars) - Str_LimitLengthHTMLStr (SummaryStr,MaxChars); + Cns_MAX_BYTES_SUMMARY_STRING); if (GetContent) if ((*ContentStr = (char *) malloc (256))) diff --git a/swad_enrollment.h b/swad_enrollment.h index ba55ba8b..48b1bd12 100644 --- a/swad_enrollment.h +++ b/swad_enrollment.h @@ -81,9 +81,8 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole, void Enr_WriteFormToReqAnotherUsrID (Act_Action_t NextAction); void Enr_ReqAcceptRegisterInCrs (void); -void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], - long CrsCod,long UsrCod, - unsigned MaxChars); +void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + long CrsCod,long UsrCod); void Enr_UpdateUsrData (struct UsrData *UsrDat); void Enr_FilterUsrDat (struct UsrData *UsrDat); void Enr_UpdateInstitutionCentreDepartment (void); @@ -106,8 +105,9 @@ void Enr_RemAllStdsThisCrs (void); unsigned Enr_RemAllStdsInCrs (struct Course *Crs); void Enr_ReqSignUpInCrs (void); void Enr_SignUpInCrs (void); -void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, - long ReqCod,unsigned MaxChars,bool GetContent); +void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long ReqCod,bool GetContent); void Enr_AskIfRejectSignUp (void); void Enr_RejectSignUp (void); void Enr_ShowEnrollmentRequests (void); diff --git a/swad_exam.c b/swad_exam.c index 19ca1d7f..c07069b7 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -1605,14 +1605,13 @@ static long Exa_GetParamExaCod (void) /*****************************************************************************/ /************ Get summary and content about an exam announcement *************/ /*****************************************************************************/ -// This function may be called inside a web service, so don't report error -// MaxChars must be > 3 + (2 + Cns_MAX_LENGTH_DATE + 6) -void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], +void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], char **ContentStr, - long ExaCod,unsigned MaxChars,bool GetContent) + long ExaCod,bool GetContent) { extern const char *Txt_hours_ABBREVIATION; + char CrsNameAndDate[Crs_MAX_LENGTH_COURSE_FULL_NAME + (2 + Cns_MAX_LENGTH_DATE + 6) + 1]; /***** Initializations *****/ Gbl.ExamAnns.ExaDat.ExaCod = ExaCod; @@ -1629,19 +1628,16 @@ void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Cns_MAX_BYTES_TEX Exa_GetNotifContentExamAnnouncement (ContentStr); /***** Summary *****/ - /* Name of the course */ - if (MaxChars) - Str_LimitLengthHTMLStr (Gbl.ExamAnns.ExaDat.CrsFullName, - MaxChars - (2 + Cns_MAX_LENGTH_DATE + 6)); - - /* Date of exam */ - sprintf (SummaryStr,"%s, %04u-%02u-%02u %2u:%02u", + /* Name of the course and date of exam */ + sprintf (CrsNameAndDate,"%s, %04u-%02u-%02u %2u:%02u", Gbl.ExamAnns.ExaDat.CrsFullName, Gbl.ExamAnns.ExaDat.ExamDate.Year, Gbl.ExamAnns.ExaDat.ExamDate.Month, Gbl.ExamAnns.ExaDat.ExamDate.Day, Gbl.ExamAnns.ExaDat.StartTime.Hour, Gbl.ExamAnns.ExaDat.StartTime.Minute); + Str_Copy (SummaryStr,CrsNameAndDate, + Cns_MAX_BYTES_SUMMARY_STRING); /***** Free memory of the exam announcement *****/ Exa_FreeMemExamAnnouncement (); diff --git a/swad_exam.h b/swad_exam.h index c92f8332..0753f990 100644 --- a/swad_exam.h +++ b/swad_exam.h @@ -99,8 +99,8 @@ void Exa_GetDateToHighlight (void); void Exa_CreateListDatesOfExamAnnouncements (void); void Exa_PutHiddenParamExaCod (long ExaCod); -void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], +void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], char **ContentStr, - long ExaCod,unsigned MaxChars,bool GetContent); + long ExaCod,bool GetContent); #endif diff --git a/swad_file_browser.c b/swad_file_browser.c index a69473ef..82451d31 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -11141,8 +11141,9 @@ void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat,Cns_QuietOrVerbose_t Qu #define Brw_MAX_BYTES_FILE_CONTENT_STR (100 + NAME_MAX + 100 + PATH_MAX + 100 + (Usr_MAX_BYTES_NAME + 1) * 3 + 100 + Fil_MAX_BYTES_FILE_SIZE_STRING) -void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, - long FilCod,unsigned MaxChars,bool GetContent) +void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long FilCod,bool GetContent) { extern const char *Txt_Filename; extern const char *Txt_Folder; @@ -11163,9 +11164,7 @@ void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],cha /***** Copy file name into summary string *****/ Str_Copy (SummaryStr,FileMetadata.FilFolLnkName, - Cns_MAX_BYTES_TEXT); - if (MaxChars) - Str_LimitLengthHTMLStr (SummaryStr,MaxChars); + Cns_MAX_BYTES_SUMMARY_STRING); /***** Copy some file metadata into content string *****/ if (GetContent && ContentStr) diff --git a/swad_file_browser.h b/swad_file_browser.h index b1c869f2..866f2e18 100644 --- a/swad_file_browser.h +++ b/swad_file_browser.h @@ -247,8 +247,9 @@ void Brw_RemoveGrpZones (long CrsCod,long GrpCod); void Brw_RemoveUsrWorksInCrs (struct UsrData *UsrDat,struct Course *Crs,Cns_QuietOrVerbose_t QuietOrVerbose); void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat,Cns_QuietOrVerbose_t QuietOrVerbose); -void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr, - long FilCod,unsigned MaxChars,bool GetContent); +void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long FilCod,bool GetContent); unsigned Brw_ListDocsFound (const char *Query, const char *TitleSingular,const char *TitlePlural); diff --git a/swad_follow.c b/swad_follow.c index e333ebf7..e779e811 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -1176,10 +1176,10 @@ void Fol_GetAndShowRankingFollowers (void) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Fol_GetNotifFollower (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], +void Fol_GetNotifFollower (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], char **ContentStr) { - SummaryStr[0] = '\0'; + SummaryStr[0] = '\0'; // Return nothing on error if ((*ContentStr = (char *) malloc (1))) *ContentStr[0] = '\0'; diff --git a/swad_follow.h b/swad_follow.h index 2d18a3f1..f2fc7c1c 100644 --- a/swad_follow.h +++ b/swad_follow.h @@ -63,7 +63,7 @@ void Fol_UnfollowUsr2 (void); void Fol_GetAndShowRankingFollowers (void); -void Fol_GetNotifFollower (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], +void Fol_GetNotifFollower (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], char **ContentStr); void Fol_RemoveUsrFromUsrFollow (long UsrCod); diff --git a/swad_forum.c b/swad_forum.c index 5d34efe8..613793a8 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -1401,10 +1401,9 @@ static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC, /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], +void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], char **ContentStr, - long PstCod, - unsigned MaxChars,bool GetContent) + long PstCod,bool GetContent) { char Query[512]; MYSQL_RES *mysql_res; @@ -1426,10 +1425,16 @@ void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], row = mysql_fetch_row (mysql_res); /***** Copy subject *****/ - Str_Copy (SummaryStr,row[0], - Cns_MAX_BYTES_TEXT); - if (MaxChars) - Str_LimitLengthHTMLStr (SummaryStr,MaxChars); + // TODO: Do only direct copy when Subject will be VARCHAR(255) + if (strlen (row[0]) > Cns_MAX_BYTES_SUMMARY_STRING) + { + strncpy (SummaryStr,row[0], + Cns_MAX_BYTES_SUMMARY_STRING); + SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING] = '\0'; + } + else + Str_Copy (SummaryStr,row[0], + Cns_MAX_BYTES_SUMMARY_STRING); /***** Copy content *****/ if (GetContent) diff --git a/swad_forum.h b/swad_forum.h index f65ef6ab..0ccd89c9 100644 --- a/swad_forum.h +++ b/swad_forum.h @@ -101,10 +101,9 @@ unsigned long For_GetNumPostsUsr (long UsrCod); void For_DeleteThrFromReadThrs (long ThrCod); void For_RemoveUsrFromReadThrs (long UsrCod); -void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], +void For_GetSummaryAndContentForumPst (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], char **ContentStr, - long PstCod, - unsigned MaxChars,bool GetContent); + long PstCod,bool GetContent); void For_PutAllHiddenParamsForum (void); void For_SetForumTypeAndRestrictAccess (void); diff --git a/swad_mark.c b/swad_mark.c index f8a4e51a..79c65de3 100644 --- a/swad_mark.c +++ b/swad_mark.c @@ -709,10 +709,9 @@ void Mrk_ShowMyMarks (void) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], +void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], char **ContentStr, - long MrkCod,long UsrCod, - unsigned MaxChars,bool GetContent) + long MrkCod,long UsrCod,bool GetContent) { char Query[512]; MYSQL_RES *mysql_res; @@ -783,8 +782,6 @@ void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], FileName); Str_Copy (SummaryStr,FileName, Cns_MAX_BYTES_TEXT); - if (MaxChars) - Str_LimitLengthHTMLStr (SummaryStr,MaxChars); if (GetContent) { diff --git a/swad_mark.h b/swad_mark.h index d8fc3ee0..303dc60b 100644 --- a/swad_mark.h +++ b/swad_mark.h @@ -52,9 +52,8 @@ void Mrk_ChangeNumRowsFooter (void); bool Mrk_CheckFileOfMarks (const char *Path,struct MarksProperties *Marks); void Mrk_ShowMyMarks (void); -void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], +void Mrk_GetNotifMyMarks (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], char **ContentStr, - long MrkCod,long UsrCod, - unsigned MaxChars,bool GetContent); + long MrkCod,long UsrCod,bool GetContent); #endif diff --git a/swad_message.c b/swad_message.c index 918092f9..cdab5c11 100644 --- a/swad_message.c +++ b/swad_message.c @@ -3004,9 +3004,8 @@ static void Msg_ShowASentOrReceivedMessage (long MsgNum,long MsgCod) /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], - char **ContentStr,long MsgCod, - unsigned MaxChars,bool GetContent) +void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr,long MsgCod,bool GetContent) { extern const char *Txt_MSG_Subject; char Query[128]; @@ -3029,10 +3028,16 @@ void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], row = mysql_fetch_row (mysql_res); /***** Copy subject *****/ - Str_Copy (SummaryStr,row[0], - Cns_MAX_BYTES_TEXT); - if (MaxChars) - Str_LimitLengthHTMLStr (SummaryStr,MaxChars); + // TODO: Do only direct copy when Subject will be VARCHAR(255) + if (strlen (row[0]) > Cns_MAX_BYTES_SUMMARY_STRING) + { + strncpy (SummaryStr,row[0], + Cns_MAX_BYTES_SUMMARY_STRING); + SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING] = '\0'; + } + else + Str_Copy (SummaryStr,row[0], + Cns_MAX_BYTES_SUMMARY_STRING); /***** Copy subject *****/ if (GetContent) diff --git a/swad_message.h b/swad_message.h index 147e2fec..0f9ce879 100644 --- a/swad_message.h +++ b/swad_message.h @@ -94,9 +94,8 @@ void Msg_GetDistinctCoursesInMyMessages (void); void Msg_ShowFormSelectCourseSentOrRecMsgs (void); void Msg_ShowFormToFilterMsgs (void); void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1]); -void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], - char **ContentStr,long MsgCod, - unsigned MaxChars,bool GetContent); +void Msg_GetNotifMessage (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr,long MsgCod,bool GetContent); void Msg_WriteMsgNumber (unsigned long MsgNum,bool NewMsg); void Msg_WriteMsgAuthor (struct UsrData *UsrDat, diff --git a/swad_notice.c b/swad_notice.c index 9c702aad..f503f280 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -745,9 +745,9 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Not_GetSummaryAndContentNotice (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], - char **ContentStr,long NotCod, - unsigned MaxChars,bool GetContent) +void Not_GetSummaryAndContentNotice (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long NotCod,bool GetContent) { char Query[512]; MYSQL_RES *mysql_res; @@ -769,10 +769,16 @@ void Not_GetSummaryAndContentNotice (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], row = mysql_fetch_row (mysql_res); /***** Copy summary *****/ - Str_Copy (SummaryStr,row[0], - Cns_MAX_BYTES_TEXT); - if (MaxChars) - Str_LimitLengthHTMLStr (SummaryStr,MaxChars); + // TODO: Do only direct copy when a Subject of type VARCHAR(255) is available + if (strlen (row[0]) > Cns_MAX_BYTES_SUMMARY_STRING) + { + strncpy (SummaryStr,row[0], + Cns_MAX_BYTES_SUMMARY_STRING); + SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING] = '\0'; + } + else + Str_Copy (SummaryStr,row[0], + Cns_MAX_BYTES_SUMMARY_STRING); /***** Copy content *****/ if (GetContent) diff --git a/swad_notice.h b/swad_notice.h index 826bd789..89816e00 100644 --- a/swad_notice.h +++ b/swad_notice.h @@ -68,9 +68,9 @@ void Not_RemoveNotice (void); void Not_GetNotCodToHighlight (void); void Not_ShowNotices (Not_Listing_t TypeNoticesListing); -void Not_GetSummaryAndContentNotice (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], - char **ContentStr,long NotCod, - unsigned MaxChars,bool GetContent); +void Not_GetSummaryAndContentNotice (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long NotCod,bool GetContent); unsigned Not_GetNumNotices (Sco_Scope_t Scope,Not_Status_t Status,unsigned *NumNotif); unsigned Not_GetNumNoticesDeleted (Sco_Scope_t Scope,unsigned *NumNotif); diff --git a/swad_notification.c b/swad_notification.c index 464f4a69..2f8d313b 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -324,7 +324,7 @@ void Ntf_ShowMyNotifications (void) time_t DateTimeUTC; // Date-time of the event Ntf_Status_t Status; Ntf_StatusTxt_t StatusTxt; - char SummaryStr[Cns_MAX_BYTES_TEXT + 1]; + char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1]; char *ContentStr; const char *ClassBackground; const char *ClassAnchor; @@ -604,7 +604,7 @@ void Ntf_ShowMyNotifications (void) ContentStr = NULL; Ntf_GetNotifSummaryAndContent (SummaryStr,&ContentStr,NotifyEvent, Cod,Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod, - Cfg_MAX_CHARS_NOTIF_SUMMARY_SWAD,false); + false); fprintf (Gbl.F.Out,"" "" "%s",SummaryStr); } @@ -1872,7 +1871,7 @@ static void Soc_PutFormGoToAction (const struct SocialNote *SocNot) /*****************************************************************************/ static void Soc_GetNoteSummary (const struct SocialNote *SocNot, - char SummaryStr[Cns_MAX_BYTES_TEXT + 1],unsigned MaxChars) + char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1]) { SummaryStr[0] = '\0'; @@ -1888,19 +1887,19 @@ static void Soc_GetNoteSummary (const struct SocialNote *SocNot, case Soc_NOTE_DEG_SHA_PUB_FILE: case Soc_NOTE_CRS_DOC_PUB_FILE: case Soc_NOTE_CRS_SHA_PUB_FILE: - Brw_GetSummaryAndContentOfFile (SummaryStr,NULL,SocNot->Cod,MaxChars,false); + Brw_GetSummaryAndContentOfFile (SummaryStr,NULL,SocNot->Cod,false); break; case Soc_NOTE_EXAM_ANNOUNCEMENT: - Exa_GetSummaryAndContentExamAnnouncement (SummaryStr,NULL,SocNot->Cod,MaxChars,false); + Exa_GetSummaryAndContentExamAnnouncement (SummaryStr,NULL,SocNot->Cod,false); break; case Soc_NOTE_SOCIAL_POST: // Not applicable break; case Soc_NOTE_FORUM_POST: - For_GetSummaryAndContentForumPst (SummaryStr,NULL,SocNot->Cod,MaxChars,false); + For_GetSummaryAndContentForumPst (SummaryStr,NULL,SocNot->Cod,false); break; case Soc_NOTE_NOTICE: - Not_GetSummaryAndContentNotice (SummaryStr,NULL,SocNot->Cod,MaxChars,false); + Not_GetSummaryAndContentNotice (SummaryStr,NULL,SocNot->Cod,false); break; } } @@ -4733,9 +4732,9 @@ static void Soc_AddNotesJustRetrievedToTimelineThisSession (void) /******************* Get notification of a new social post *******************/ /*****************************************************************************/ -void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], - char **ContentStr,long PubCod, - unsigned MaxChars,bool GetContent) +void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long PubCod,bool GetContent) { char Query[256]; MYSQL_RES *mysql_res; @@ -4748,7 +4747,7 @@ void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], /***** Return nothing on error *****/ SocPub.PubType = Soc_PUB_UNKNOWN; - SummaryStr[0] = '\0'; + SummaryStr[0] = '\0'; // Return nothing on error Content[0] = '\0'; /***** Get summary and content from social post from database *****/ @@ -4809,12 +4808,12 @@ void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], } /***** Copy summary string *****/ - Str_LimitLengthHTMLStr (Content,MaxChars); + Str_LimitLengthHTMLStr (Content,Cns_MAX_BYTES_SUMMARY_STRING); Str_Copy (SummaryStr,Content, - Cns_MAX_BYTES_TEXT); + Cns_MAX_BYTES_SUMMARY_STRING); } else - Soc_GetNoteSummary (&SocNot,SummaryStr,Soc_MAX_BYTES_SUMMARY); + Soc_GetNoteSummary (&SocNot,SummaryStr); break; case Soc_PUB_COMMENT_TO_NOTE: /***** Get content of social post from database *****/ @@ -4848,9 +4847,9 @@ void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], } /***** Copy summary string *****/ - Str_LimitLengthHTMLStr (Content,MaxChars); + Str_LimitLengthHTMLStr (Content,Cns_MAX_BYTES_SUMMARY_STRING); Str_Copy (SummaryStr,Content, - Cns_MAX_BYTES_TEXT); + Cns_MAX_BYTES_SUMMARY_STRING); break; } diff --git a/swad_social.h b/swad_social.h index df1e6afb..5d9ed09f 100644 --- a/swad_social.h +++ b/swad_social.h @@ -174,8 +174,8 @@ void Soc_RemoveUsrSocialContent (long UsrCod); void Soc_ClearOldTimelinesDB (void); -void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], - char **ContentStr,long PubCod, - unsigned MaxChars,bool GetContent); +void Soc_GetNotifSocialPublishing (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long PubCod,bool GetContent); #endif diff --git a/swad_survey.c b/swad_survey.c index 2a72dfc3..92f9a1ae 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -1400,8 +1400,9 @@ static void Svy_GetSurveyTxtFromDB (long SvyCod,char Txt[Cns_MAX_BYTES_TEXT + 1] /*****************************************************************************/ // This function may be called inside a web service, so don't report error -void Svy_GetNotifSurvey (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], - char **ContentStr,long SvyCod,unsigned MaxChars,bool GetContent) +void Svy_GetNotifSurvey (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long SvyCod,bool GetContent) { char Query[512]; MYSQL_RES *mysql_res; @@ -1424,9 +1425,7 @@ void Svy_GetNotifSurvey (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], /***** Get summary *****/ Str_Copy (SummaryStr,row[0], - Cns_MAX_BYTES_TEXT); - if (MaxChars) - Str_LimitLengthHTMLStr (SummaryStr,MaxChars); + Cns_MAX_BYTES_SUMMARY_STRING); /***** Get content *****/ if (GetContent) diff --git a/swad_survey.h b/swad_survey.h index d1b62f0f..05fc36d4 100644 --- a/swad_survey.h +++ b/swad_survey.h @@ -94,8 +94,9 @@ void Svy_GetListSurveys (void); void Svy_GetDataOfSurveyByCod (struct Survey *Svy); void Svy_GetDataOfSurveyByFolder (struct Survey *Svy); void Svy_FreeListSurveys (void); -void Svy_GetNotifSurvey (char SummaryStr[Cns_MAX_BYTES_TEXT + 1], - char **ContentStr,long SvyCod,unsigned MaxChars,bool GetContent); +void Svy_GetNotifSurvey (char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1], + char **ContentStr, + long SvyCod,bool GetContent); void Svy_AskRemSurvey (void); void Svy_RemoveSurvey (void); void Svy_AskResetSurvey (void); diff --git a/swad_web_service.c b/swad_web_service.c index 383daf41..acc72792 100644 --- a/swad_web_service.c +++ b/swad_web_service.c @@ -2815,7 +2815,7 @@ int swad__getNotifications (struct soap *soap, struct Course Crs; long Cod; char ForumName[For_MAX_BYTES_FORUM_NAME + 1]; - char SummaryStr[Cns_MAX_BYTES_TEXT + 1]; + char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1]; char *ContentStr; Ntf_Status_t Status; size_t Length; @@ -2982,7 +2982,7 @@ int swad__getNotifications (struct soap *soap, ContentStr = NULL; Ntf_GetNotifSummaryAndContent (SummaryStr,&ContentStr,NotifyEvent, Cod,Crs.CrsCod,Gbl.Usrs.Me.UsrDat.UsrCod, - Cfg_MAX_CHARS_NOTIF_SUMMARY_WEB_SERVICE,true); + true); Length = strlen (SummaryStr); getNotificationsOut->notificationsArray.__ptr[NumNotif].summary = (char *) soap_malloc (Gbl.soap,Length + 1); @@ -4682,7 +4682,7 @@ int swad__getMarks (struct soap *soap, { int ReturnCode; struct FileMetadata FileMetadata; - char SummaryStr[NAME_MAX + 1]; // Really not used + char SummaryStr[Cns_MAX_BYTES_SUMMARY_STRING + 1]; // Not used char *ContentStr; size_t Length; @@ -4747,9 +4747,9 @@ int swad__getMarks (struct soap *soap, /***** Get content *****/ ContentStr = NULL; - Mrk_GetNotifMyMarks (SummaryStr,&ContentStr, - FileMetadata.FilCod,Gbl.Usrs.Me.UsrDat.UsrCod, - 0,true); + Mrk_GetNotifMyMarks (SummaryStr, // Not used + &ContentStr, + FileMetadata.FilCod,Gbl.Usrs.Me.UsrDat.UsrCod,true); if (ContentStr != NULL) { Length = strlen (ContentStr);