From a11f47b937fa0fd0d4d344014b381ff979ac6e34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 4 Jan 2016 01:56:28 +0100 Subject: [PATCH] Version 15.94 --- swad_assignment.c | 4 +- swad_changelog.h | 5 +- swad_course.c | 2 +- swad_enrollment.c | 16 ++--- swad_exam.c | 4 +- swad_file_browser.c | 34 ++++++----- swad_follow.c | 2 +- swad_forum.c | 8 +-- swad_message.c | 4 +- swad_notice.c | 4 +- swad_notification.c | 146 ++++++++++++-------------------------------- swad_notification.h | 16 +++-- swad_social.c | 130 +++++++++++++++++++++++++++++++++++++++ swad_social.h | 2 + swad_survey.c | 4 +- 15 files changed, 224 insertions(+), 157 deletions(-) diff --git a/swad_assignment.c b/swad_assignment.c index b20c3eb95..09b1f1e8a 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -347,7 +347,7 @@ static void Asg_ShowOneAssignment (long AsgCod) Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd; /***** Mark possible notification as seen *****/ - Ntf_SetNotifAsSeen (Ntf_EVENT_ASSIGNMENT, + Ntf_MarkNotifAsSeen (Ntf_EVENT_ASSIGNMENT, AsgCod, Gbl.Usrs.Me.UsrDat.UsrCod); } @@ -912,7 +912,7 @@ void Asg_RemoveAssignment (void) DB_QueryDELETE (Query,"can not remove assignment"); /***** Mark possible notifications as removed *****/ - Ntf_SetNotifAsRemoved (Ntf_EVENT_ASSIGNMENT,Asg.AsgCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_ASSIGNMENT,Asg.AsgCod); /***** Write message to show the change made *****/ sprintf (Gbl.Message,Txt_Assignment_X_removed, diff --git a/swad_changelog.h b/swad_changelog.h index fd9434311..a9113926f 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -117,14 +117,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.93.8 (2016-01-03)" +#define Log_PLATFORM_VERSION "SWAD 15.94 (2016-01-04)" #define CSS_FILE "swad15.88.1.css" #define JS_FILE "swad15.77.7.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.93.8: Jan 03, 2016 Social note is marked as unavailable when a public file is removed. (190486 lines) + Version 15.94: Jan 04, 2016 Social notes are marked as unavailable when a folder and its children are removed. (190551 lines) + Version 15.93.8: Jan 04, 2016 Social note is marked as unavailable when a public file is removed. (190486 lines) Version 15.93.7: Jan 03, 2016 Social note is marked as unavailable when a public forum post is removed. (190419 lines) Version 15.93.6: Jan 03, 2016 Social note is marked as unavailable when a exam announcement is removed. (190409 lines) Version 15.93.5: Jan 03, 2016 Social note is marked as unavailable when a notice is removed. (190406 lines) diff --git a/swad_course.c b/swad_course.c index 02c091680..545c98ada 100644 --- a/swad_course.c +++ b/swad_course.c @@ -2216,7 +2216,7 @@ static void Crs_EmptyCourseCompletely (long CrsCod) /***** Set all the notifications from the course as removed, except notifications about new messages *****/ - Ntf_SetNotifInCrsAsRemoved (CrsCod,-1L); + Ntf_MarkNotifInCrsAsRemoved (CrsCod,-1L); /***** Remove information of the course ****/ /* Remove timetable of the course */ diff --git a/swad_enrollment.c b/swad_enrollment.c index 52e711677..7464ddef6 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -293,8 +293,8 @@ static void Enr_NotifyAfterEnrollment (struct UsrData *UsrDat,Rol_Role_t NewRole Enr_RemoveEnrollmentRequest (Gbl.CurrentCrs.Crs.CrsCod,UsrDat->UsrCod); /***** Remove old enrollment notifications before inserting the new one ******/ - Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_STUDENT,-1,UsrDat->UsrCod); - Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_TEACHER,-1,UsrDat->UsrCod); + Ntf_MarkNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_STUDENT,-1,UsrDat->UsrCod); + Ntf_MarkNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_TEACHER,-1,UsrDat->UsrCod); /***** Create new notification ******/ CreateNotif = (UsrDat->Prefs.NotifNtfEvents & (1 << NotifyEvent)); @@ -365,7 +365,7 @@ void Enr_ReqAcceptRegisterInCrs (void) fprintf (Gbl.F.Out,""); /***** Mark possible notification as seen *****/ - Ntf_SetNotifAsSeen (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ? Ntf_EVENT_ENROLLMENT_STUDENT : + Ntf_MarkNotifAsSeen (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ? Ntf_EVENT_ENROLLMENT_STUDENT : Ntf_EVENT_ENROLLMENT_TEACHER, -1L, Gbl.Usrs.Me.UsrDat.UsrCod); @@ -2822,7 +2822,7 @@ void Enr_ShowEnrollmentRequests (void) ""); /***** Mark possible notification as seen *****/ - Ntf_SetNotifAsSeen (Ntf_EVENT_ENROLLMENT_REQUEST, + Ntf_MarkNotifAsSeen (Ntf_EVENT_ENROLLMENT_REQUEST, ReqCod, Gbl.Usrs.Me.UsrDat.UsrCod); } @@ -2867,7 +2867,7 @@ static void Enr_RemoveEnrollmentRequest (long CrsCod,long UsrCod) ReqCod = Str_ConvertStrCodToLongCod (row[0]); /* Mark possible notifications as removed */ - Ntf_SetNotifAsRemoved (Ntf_EVENT_ENROLLMENT_REQUEST,ReqCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_ENROLLMENT_REQUEST,ReqCod); } /* Free structure that stores the query result */ DB_FreeMySQLResult (&mysql_res); @@ -3521,9 +3521,9 @@ void Enr_AcceptRegisterMeInCrs (void) /***** Mark all notifications about enrollment (as student or as teacher) in current course as removed *****/ - Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_STUDENT,-1L, + Ntf_MarkNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_STUDENT,-1L, Gbl.Usrs.Me.UsrDat.UsrCod); - Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_TEACHER,-1L, + Ntf_MarkNotifToOneUsrAsRemoved (Ntf_EVENT_ENROLLMENT_TEACHER,-1L, Gbl.Usrs.Me.UsrDat.UsrCod); /***** Confirmation message *****/ @@ -3813,7 +3813,7 @@ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat,struct Course * /***** Set all the notifications for this user in this course as removed, except notifications about new messages *****/ - Ntf_SetNotifInCrsAsRemoved (Crs->CrsCod,UsrDat->UsrCod); + Ntf_MarkNotifInCrsAsRemoved (Crs->CrsCod,UsrDat->UsrCod); /***** Remove user from the table of courses-users *****/ sprintf (Query,"DELETE FROM crs_usr" diff --git a/swad_exam.c b/swad_exam.c index 21ccf51e8..28b92ac86 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -380,7 +380,7 @@ void Exa_RemoveExamAnnouncement (void) DB_QueryUPDATE (Query,"can not remove an exam announcement"); /***** Mark possible notifications as removed *****/ - Ntf_SetNotifAsRemoved (Ntf_EVENT_EXAM_ANNOUNCEMENT,ExaCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_EXAM_ANNOUNCEMENT,ExaCod); /***** Mark possible social note as unavailable *****/ Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (Soc_NOTE_EXAM_ANNOUNCEMENT,ExaCod); @@ -404,7 +404,7 @@ void Exa_ListExamAnnouncementsSee (void) Exa_ListExamAnnouncements (Exa_NORMAL_VIEW); /***** Mark possible notifications as seen *****/ - Ntf_SetNotifAsSeen (Ntf_EVENT_EXAM_ANNOUNCEMENT, + Ntf_MarkNotifAsSeen (Ntf_EVENT_EXAM_ANNOUNCEMENT, -1L, Gbl.Usrs.Me.UsrDat.UsrCod); } diff --git a/swad_file_browser.c b/swad_file_browser.c index 0df09104c..fda852ae5 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -9209,13 +9209,13 @@ void Brw_ShowFileMetadata (void) case Brw_SHOW_DOCUM_GRP: case Brw_ADMI_DOCUM_CRS: case Brw_ADMI_DOCUM_GRP: - Ntf_SetNotifAsSeen (Ntf_EVENT_DOCUMENT_FILE, + Ntf_MarkNotifAsSeen (Ntf_EVENT_DOCUMENT_FILE, FileMetadata.FilCod, Gbl.Usrs.Me.UsrDat.UsrCod); break; case Brw_ADMI_SHARE_CRS: case Brw_ADMI_SHARE_GRP: - Ntf_SetNotifAsSeen (Ntf_EVENT_SHARED_FILE, + Ntf_MarkNotifAsSeen (Ntf_EVENT_SHARED_FILE, FileMetadata.FilCod, Gbl.Usrs.Me.UsrDat.UsrCod); break; @@ -9223,7 +9223,7 @@ void Brw_ShowFileMetadata (void) case Brw_SHOW_MARKS_GRP: case Brw_ADMI_MARKS_CRS: case Brw_ADMI_MARKS_GRP: - Ntf_SetNotifAsSeen (Ntf_EVENT_MARKS_FILE, + Ntf_MarkNotifAsSeen (Ntf_EVENT_MARKS_FILE, FileMetadata.FilCod, Gbl.Usrs.Me.UsrDat.UsrCod); break; @@ -9244,19 +9244,19 @@ void Brw_ShowFileMetadata (void) case Brw_SHOW_DOCUM_GRP: case Brw_ADMI_DOCUM_CRS: case Brw_ADMI_DOCUM_GRP: - Ntf_SetNotifAsRemoved (Ntf_EVENT_DOCUMENT_FILE, + Ntf_MarkNotifAsRemoved (Ntf_EVENT_DOCUMENT_FILE, FileMetadata.FilCod); break; case Brw_ADMI_SHARE_CRS: case Brw_ADMI_SHARE_GRP: - Ntf_SetNotifAsRemoved (Ntf_EVENT_SHARED_FILE, + Ntf_MarkNotifAsRemoved (Ntf_EVENT_SHARED_FILE, FileMetadata.FilCod); break; case Brw_SHOW_MARKS_CRS: case Brw_SHOW_MARKS_GRP: case Brw_ADMI_MARKS_CRS: case Brw_ADMI_MARKS_GRP: - Ntf_SetNotifAsRemoved (Ntf_EVENT_MARKS_FILE, + Ntf_MarkNotifAsRemoved (Ntf_EVENT_MARKS_FILE, FileMetadata.FilCod); break; default: @@ -9348,13 +9348,13 @@ void Brw_DownloadFile (void) case Brw_SHOW_DOCUM_GRP: case Brw_ADMI_DOCUM_CRS: case Brw_ADMI_DOCUM_GRP: - Ntf_SetNotifAsSeen (Ntf_EVENT_DOCUMENT_FILE, + Ntf_MarkNotifAsSeen (Ntf_EVENT_DOCUMENT_FILE, FileMetadata.FilCod, Gbl.Usrs.Me.UsrDat.UsrCod); break; case Brw_ADMI_SHARE_CRS: case Brw_ADMI_SHARE_GRP: - Ntf_SetNotifAsSeen (Ntf_EVENT_SHARED_FILE, + Ntf_MarkNotifAsSeen (Ntf_EVENT_SHARED_FILE, FileMetadata.FilCod, Gbl.Usrs.Me.UsrDat.UsrCod); break; @@ -9362,7 +9362,7 @@ void Brw_DownloadFile (void) case Brw_SHOW_MARKS_GRP: case Brw_ADMI_MARKS_CRS: case Brw_ADMI_MARKS_GRP: - Ntf_SetNotifAsSeen (Ntf_EVENT_MARKS_FILE, + Ntf_MarkNotifAsSeen (Ntf_EVENT_MARKS_FILE, FileMetadata.FilCod, Gbl.Usrs.Me.UsrDat.UsrCod); break; @@ -9392,19 +9392,19 @@ void Brw_DownloadFile (void) case Brw_SHOW_DOCUM_GRP: case Brw_ADMI_DOCUM_CRS: case Brw_ADMI_DOCUM_GRP: - Ntf_SetNotifAsRemoved (Ntf_EVENT_DOCUMENT_FILE, + Ntf_MarkNotifAsRemoved (Ntf_EVENT_DOCUMENT_FILE, FileMetadata.FilCod); break; case Brw_ADMI_SHARE_CRS: case Brw_ADMI_SHARE_GRP: - Ntf_SetNotifAsRemoved (Ntf_EVENT_SHARED_FILE, + Ntf_MarkNotifAsRemoved (Ntf_EVENT_SHARED_FILE, FileMetadata.FilCod); break; case Brw_SHOW_MARKS_CRS: case Brw_SHOW_MARKS_GRP: case Brw_ADMI_MARKS_CRS: case Brw_ADMI_MARKS_GRP: - Ntf_SetNotifAsRemoved (Ntf_EVENT_MARKS_FILE, + Ntf_MarkNotifAsRemoved (Ntf_EVENT_MARKS_FILE, FileMetadata.FilCod); break; default: @@ -10629,8 +10629,8 @@ static void Brw_RemoveOneFileOrFolderFromDB (const char *Path) /***** Set possible notifications as removed. Set possible social note as removed. Important: do this before removing from files *****/ - Ntf_SetNotifOneFileAsRemoved (Path); - Ntf_SetSocialNoteOneFileAsRemoved (Path); + Ntf_MarkNotifOneFileAsRemoved (Path); + Soc_MarkSocialNoteOneFileAsRemoved (Path); /***** Remove from database the entries that store the marks properties *****/ if (FileBrowser == Brw_ADMI_MARKS_CRS || @@ -10672,8 +10672,10 @@ static void Brw_RemoveChildrenOfFolderFromDB (const char *Path) Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type]; /***** Set possible notifications as removed. + Set possible social notes as unavailable. Important: do this before removing from files *****/ - Ntf_SetNotifChildrenOfFolderAsRemoved (FileBrowser,Cod,Path); + Ntf_MarkNotifChildrenOfFolderAsRemoved (Path); + Soc_MarkSocialNotesChildrenOfFolderAsUnavailable (Path); /***** Remove from database the entries that store the marks properties *****/ if (FileBrowser == Brw_ADMI_MARKS_CRS || @@ -10924,7 +10926,7 @@ void Brw_RemoveGrpZones (long CrsCod,long GrpCod) char PathGrpFileZones[PATH_MAX+1]; /***** Set notifications about files in this group zone as removed *****/ - Ntf_SetNotifFilesInGroupAsRemoved (GrpCod); + Ntf_MarkNotifFilesInGroupAsRemoved (GrpCod); /***** Remove files in the group from database *****/ Brw_RemoveGrpFilesFromDB (GrpCod); diff --git a/swad_follow.c b/swad_follow.c index 0ead33a44..41d6d125d 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -415,7 +415,7 @@ void Fol_ListFollowers (void) /***** If it's me, mark possible notification as seen *****/ if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) - Ntf_SetNotifAsSeen (Ntf_EVENT_FOLLOWER,-1L, + Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,-1L, Gbl.Usrs.Me.UsrDat.UsrCod); } else diff --git a/swad_forum.c b/swad_forum.c index 32e92bb43..bceceafe7 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -1029,7 +1029,7 @@ static void For_ShowThreadPosts (long ThrCod,char *LastSubject) { case For_FORUM_COURSE_TCHS: case For_FORUM_COURSE_USRS: - Ntf_SetNotifAsSeen (Ntf_EVENT_FORUM_POST_COURSE, + Ntf_MarkNotifAsSeen (Ntf_EVENT_FORUM_POST_COURSE, PstCod, Gbl.Usrs.Me.UsrDat.UsrCod); break; @@ -1037,7 +1037,7 @@ static void For_ShowThreadPosts (long ThrCod,char *LastSubject) break; } if (Thr.NumMyPosts) - Ntf_SetNotifAsSeen (Ntf_EVENT_FORUM_REPLY, + Ntf_MarkNotifAsSeen (Ntf_EVENT_FORUM_REPLY, PstCod, Gbl.Usrs.Me.UsrDat.UsrCod); } @@ -3904,8 +3904,8 @@ void For_DelPst (void) ThreadDeleted = For_RemoveForumPst (PstCod); /***** Mark possible notifications as removed *****/ - Ntf_SetNotifAsRemoved (Ntf_EVENT_FORUM_POST_COURSE,PstCod); - Ntf_SetNotifAsRemoved (Ntf_EVENT_FORUM_REPLY,PstCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_FORUM_POST_COURSE,PstCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_FORUM_REPLY,PstCod); /***** Mark possible social note as unavailable *****/ switch (Gbl.Forum.ForumType) // Only if forum is public for any logged user diff --git a/swad_message.c b/swad_message.c index ec7e2ae0b..3d953515b 100644 --- a/swad_message.c +++ b/swad_message.c @@ -1166,7 +1166,7 @@ void Msg_ExpRecMsg (void) Msg_ExpandReceivedMsg (Gbl.Msg.ExpandedMsgCod); /***** Mark possible notification as seen *****/ - Ntf_SetNotifAsSeen (Ntf_EVENT_MESSAGE, + Ntf_MarkNotifAsSeen (Ntf_EVENT_MESSAGE, Gbl.Msg.ExpandedMsgCod, Gbl.Usrs.Me.UsrDat.UsrCod); @@ -1460,7 +1460,7 @@ static void Msg_MoveReceivedMsgToDeleted (long MsgCod,long UsrCod) Msg_MoveMsgContentToDeleted (MsgCod); /***** Mark possible notifications as removed *****/ - Ntf_SetNotifToOneUsrAsRemoved (Ntf_EVENT_MESSAGE,MsgCod,UsrCod); + Ntf_MarkNotifToOneUsrAsRemoved (Ntf_EVENT_MESSAGE,MsgCod,UsrCod); } /*****************************************************************************/ diff --git a/swad_notice.c b/swad_notice.c index 17c41a724..0a06ec067 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -330,7 +330,7 @@ void Not_RemoveNotice (void) DB_QueryDELETE (Query,"can not remove notice"); /***** Mark possible notifications as removed *****/ - Ntf_SetNotifAsRemoved (Ntf_EVENT_NOTICE,NotCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_NOTICE,NotCod); /***** Mark possible social note as unavailable *****/ Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (Soc_NOTE_NOTICE,NotCod); @@ -475,7 +475,7 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEditNotices) DB_FreeMySQLResult (&mysql_res); /***** Mark possible notification as seen *****/ - Ntf_SetNotifAsSeen (Ntf_EVENT_NOTICE, + Ntf_MarkNotifAsSeen (Ntf_EVENT_NOTICE, -1L, Gbl.Usrs.Me.UsrDat.UsrCod); } diff --git a/swad_notification.c b/swad_notification.c index 2f7fe9126..6945a90e9 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -817,7 +817,7 @@ void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr,Ntf_Notif /********************** Set possible notification as seen ********************/ /*****************************************************************************/ -void Ntf_SetNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod) +void Ntf_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod) { char Query[256]; @@ -842,7 +842,7 @@ void Ntf_SetNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod) /******************* Set possible notifications as removed *******************/ /*****************************************************************************/ -void Ntf_SetNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod) +void Ntf_MarkNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod) { char Query[512]; @@ -858,7 +858,7 @@ void Ntf_SetNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod) /******************** Set possible notification as removed *******************/ /*****************************************************************************/ -void Ntf_SetNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod) +void Ntf_MarkNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod) { char Query[512]; @@ -884,7 +884,7 @@ void Ntf_SetNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long // However, notifications about new messages should not be removed // because the messages will remain available -void Ntf_SetNotifInCrsAsRemoved (long CrsCod,long ToUsrCod) +void Ntf_MarkNotifInCrsAsRemoved (long CrsCod,long ToUsrCod) { char Query[512]; @@ -904,10 +904,10 @@ void Ntf_SetNotifInCrsAsRemoved (long CrsCod,long ToUsrCod) } /*****************************************************************************/ -/************ Set possible notifications of one file as removed **************/ +/*********** Mark possible notifications of one file as removed **************/ /*****************************************************************************/ -void Ntf_SetNotifOneFileAsRemoved (const char *Path) +void Ntf_MarkNotifOneFileAsRemoved (const char *Path) { extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER]; Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type]; @@ -942,11 +942,9 @@ void Ntf_SetNotifOneFileAsRemoved (const char *Path) NotifyEvent = Ntf_EVENT_MARKS_FILE; break; default: - NotifyEvent = Ntf_EVENT_UNKNOWN; // Impossible - break; + return; } - if (NotifyEvent != Ntf_EVENT_UNKNOWN) // Not necessary - Ntf_SetNotifAsRemoved (NotifyEvent,FilCod); + Ntf_MarkNotifAsRemoved (NotifyEvent,FilCod); } break; default: @@ -955,101 +953,17 @@ void Ntf_SetNotifOneFileAsRemoved (const char *Path) } /*****************************************************************************/ -/************ Set possible notifications of one file as removed **************/ +/*** Mark possible notifications involving children of a folder as removed ***/ /*****************************************************************************/ -void Ntf_SetSocialNoteOneFileAsRemoved (const char *Path) +void Ntf_MarkNotifChildrenOfFolderAsRemoved (const char *Path) { extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER]; Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type]; - long FilCod; - Soc_NoteType_t NoteType; - - switch (FileBrowser) - { - case Brw_ADMI_DOCUM_INS: - case Brw_ADMI_SHARE_INS: - case Brw_ADMI_DOCUM_CTR: - case Brw_ADMI_SHARE_CTR: - case Brw_ADMI_DOCUM_DEG: - case Brw_ADMI_SHARE_DEG: - case Brw_ADMI_DOCUM_CRS: - case Brw_ADMI_SHARE_CRS: - /***** Get file code *****/ - FilCod = Brw_GetFilCodByPath (Path,true); // Only if file is public - if (FilCod > 0) - { - /***** Mark possible social note as unavailable *****/ - switch (FileBrowser) - { - case Brw_ADMI_DOCUM_INS: - NoteType = Soc_NOTE_INS_DOC_PUB_FILE; - break; - case Brw_ADMI_SHARE_INS: - NoteType = Soc_NOTE_INS_SHA_PUB_FILE; - break; - case Brw_ADMI_DOCUM_CTR: - NoteType = Soc_NOTE_CTR_DOC_PUB_FILE; - break; - case Brw_ADMI_SHARE_CTR: - NoteType = Soc_NOTE_CTR_SHA_PUB_FILE; - break; - case Brw_ADMI_DOCUM_DEG: - NoteType = Soc_NOTE_DEG_DOC_PUB_FILE; - break; - case Brw_ADMI_SHARE_DEG: - NoteType = Soc_NOTE_DEG_SHA_PUB_FILE; - break; - case Brw_ADMI_DOCUM_CRS: - NoteType = Soc_NOTE_CRS_DOC_PUB_FILE; - break; - case Brw_ADMI_SHARE_CRS: - NoteType = Soc_NOTE_CRS_SHA_PUB_FILE; - break; - default: - NoteType = Soc_NOTE_UNKNOWN; // Impossible - break; - } - if (NoteType != Soc_NOTE_UNKNOWN) // Not necessary - Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (NoteType,FilCod); - } - break; - default: - break; - } - } - -/*****************************************************************************/ -/************** Set possible notifications of marks as removed ***************/ -/*****************************************************************************/ - -void Ntf_SetNotifChildrenOfFolderAsRemoved (Brw_FileBrowser_t FileBrowser, - long Cod,const char *Path) - { + long Cod = Brw_GetCodForFiles (); char Query[512]; - char SubQuery[256]; Ntf_NotifyEvent_t NotifyEvent; - /***** Set notify event depending on browser zone *****/ - switch (FileBrowser) - { - case Brw_ADMI_DOCUM_CRS: - case Brw_ADMI_DOCUM_GRP: - NotifyEvent = Ntf_EVENT_DOCUMENT_FILE; - break; - case Brw_ADMI_SHARE_CRS: - case Brw_ADMI_SHARE_GRP: - NotifyEvent = Ntf_EVENT_SHARED_FILE; - break; - case Brw_ADMI_MARKS_CRS: - case Brw_ADMI_MARKS_GRP: - NotifyEvent = Ntf_EVENT_MARKS_FILE; - break; - default: - return; - } - - /***** Set notification as removed *****/ switch (FileBrowser) { case Brw_ADMI_DOCUM_CRS: @@ -1058,25 +972,45 @@ void Ntf_SetNotifChildrenOfFolderAsRemoved (Brw_FileBrowser_t FileBrowser, case Brw_ADMI_SHARE_GRP: case Brw_ADMI_MARKS_CRS: case Brw_ADMI_MARKS_GRP: - sprintf (SubQuery,"SELECT FilCod FROM files" - " WHERE FileBrowser='%u' AND Cod='%ld' AND Path LIKE '%s/%%'", - (unsigned) FileBrowser,Cod,Path); + /***** Set notification as removed *****/ + switch (FileBrowser) + { + case Brw_ADMI_DOCUM_CRS: + case Brw_ADMI_DOCUM_GRP: + NotifyEvent = Ntf_EVENT_DOCUMENT_FILE; + break; + case Brw_ADMI_SHARE_CRS: + case Brw_ADMI_SHARE_GRP: + NotifyEvent = Ntf_EVENT_SHARED_FILE; + break; + case Brw_ADMI_MARKS_CRS: + case Brw_ADMI_MARKS_GRP: + NotifyEvent = Ntf_EVENT_MARKS_FILE; + break; + default: + return; + } + sprintf (Query,"UPDATE notif SET Status=(Status | %u)" + " WHERE NotifyEvent='%u' AND Cod IN" + " (SELECT FilCod FROM files" + " WHERE FileBrowser='%u' AND Cod='%ld'" + " AND Path LIKE '%s/%%')", + (unsigned) Ntf_STATUS_BIT_REMOVED, + (unsigned) NotifyEvent, + (unsigned) FileBrowser,Cod, + Path); + DB_QueryUPDATE (Query,"can not set notification(s) as removed"); break; default: break; } - sprintf (Query,"UPDATE notif SET Status=(Status | %u)" - " WHERE NotifyEvent='%u' AND Cod IN (%s)", - (unsigned) Ntf_STATUS_BIT_REMOVED, - (unsigned) NotifyEvent,SubQuery); - DB_QueryUPDATE (Query,"can not set notification(s) as removed"); } /*****************************************************************************/ /******* Set all possible notifications of files in a group as removed *******/ /*****************************************************************************/ -void Ntf_SetNotifFilesInGroupAsRemoved (long GrpCod) +void Ntf_MarkNotifFilesInGroupAsRemoved (long GrpCod) { char Query[512]; diff --git a/swad_notification.h b/swad_notification.h index 3af6a5552..71724dbbe 100644 --- a/swad_notification.h +++ b/swad_notification.h @@ -103,15 +103,13 @@ void Ntf_ShowMyNotifications (void); Ntf_StatusTxt_t Ntf_GetStatusTxtFromStatusBits (Ntf_Status_t Status); void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr,Ntf_NotifyEvent_t NotifyEvent, long Cod,long CrsCod,long UsrCod,unsigned MaxChars,bool GetContent); -void Ntf_SetNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod); -void Ntf_SetNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod); -void Ntf_SetNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod); -void Ntf_SetNotifInCrsAsRemoved (long CrsCod,long ToUsrCod); -void Ntf_SetNotifOneFileAsRemoved (const char *Path); -void Ntf_SetSocialNoteOneFileAsRemoved (const char *Path); -void Ntf_SetNotifChildrenOfFolderAsRemoved (Brw_FileBrowser_t FileBrowser, - long Cod,const char *Path); -void Ntf_SetNotifFilesInGroupAsRemoved (long GrpCod); +void Ntf_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod); +void Ntf_MarkNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod); +void Ntf_MarkNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod); +void Ntf_MarkNotifInCrsAsRemoved (long CrsCod,long ToUsrCod); +void Ntf_MarkNotifOneFileAsRemoved (const char *Path); +void Ntf_MarkNotifChildrenOfFolderAsRemoved (const char *Path); +void Ntf_MarkNotifFilesInGroupAsRemoved (long GrpCod); unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod); void Ntf_StoreNotifyEventToOneUser (Ntf_NotifyEvent_t NotifyEvent, struct UsrData *UsrDat, diff --git a/swad_social.c b/swad_social.c index d6636f75a..c7adb2be3 100644 --- a/swad_social.c +++ b/swad_social.c @@ -823,6 +823,136 @@ void Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (Soc_NoteType_t NoteType DB_QueryUPDATE (Query,"can not mark social note as unavailable"); } +/*****************************************************************************/ +/*********** Mark possible notifications of one file as removed **************/ +/*****************************************************************************/ + +void Soc_MarkSocialNoteOneFileAsRemoved (const char *Path) + { + extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER]; + Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type]; + long FilCod; + Soc_NoteType_t NoteType; + + switch (FileBrowser) + { + case Brw_ADMI_DOCUM_INS: + case Brw_ADMI_SHARE_INS: + case Brw_ADMI_DOCUM_CTR: + case Brw_ADMI_SHARE_CTR: + case Brw_ADMI_DOCUM_DEG: + case Brw_ADMI_SHARE_DEG: + case Brw_ADMI_DOCUM_CRS: + case Brw_ADMI_SHARE_CRS: + /***** Get file code *****/ + FilCod = Brw_GetFilCodByPath (Path,true); // Only if file is public + if (FilCod > 0) + { + /***** Mark possible social note as unavailable *****/ + switch (FileBrowser) + { + case Brw_ADMI_DOCUM_INS: + NoteType = Soc_NOTE_INS_DOC_PUB_FILE; + break; + case Brw_ADMI_SHARE_INS: + NoteType = Soc_NOTE_INS_SHA_PUB_FILE; + break; + case Brw_ADMI_DOCUM_CTR: + NoteType = Soc_NOTE_CTR_DOC_PUB_FILE; + break; + case Brw_ADMI_SHARE_CTR: + NoteType = Soc_NOTE_CTR_SHA_PUB_FILE; + break; + case Brw_ADMI_DOCUM_DEG: + NoteType = Soc_NOTE_DEG_DOC_PUB_FILE; + break; + case Brw_ADMI_SHARE_DEG: + NoteType = Soc_NOTE_DEG_SHA_PUB_FILE; + break; + case Brw_ADMI_DOCUM_CRS: + NoteType = Soc_NOTE_CRS_DOC_PUB_FILE; + break; + case Brw_ADMI_SHARE_CRS: + NoteType = Soc_NOTE_CRS_SHA_PUB_FILE; + break; + default: + return; + } + Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (NoteType,FilCod); + } + break; + default: + break; + } + } + +/*****************************************************************************/ +/** Mark possible social notes involving children of a folder as unavailable */ +/*****************************************************************************/ + +void Soc_MarkSocialNotesChildrenOfFolderAsUnavailable (const char *Path) + { + extern const Brw_FileBrowser_t Brw_FileBrowserForDB_files[Brw_NUM_TYPES_FILE_BROWSER]; + Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type]; + long Cod = Brw_GetCodForFiles (); + char Query[512]; + Soc_NoteType_t NoteType; + + switch (FileBrowser) + { + case Brw_ADMI_DOCUM_INS: + case Brw_ADMI_SHARE_INS: + case Brw_ADMI_DOCUM_CTR: + case Brw_ADMI_SHARE_CTR: + case Brw_ADMI_DOCUM_DEG: + case Brw_ADMI_SHARE_DEG: + case Brw_ADMI_DOCUM_CRS: + case Brw_ADMI_SHARE_CRS: + /***** Mark possible social note as unavailable *****/ + switch (FileBrowser) + { + case Brw_ADMI_DOCUM_INS: + NoteType = Soc_NOTE_INS_DOC_PUB_FILE; + break; + case Brw_ADMI_SHARE_INS: + NoteType = Soc_NOTE_INS_SHA_PUB_FILE; + break; + case Brw_ADMI_DOCUM_CTR: + NoteType = Soc_NOTE_CTR_DOC_PUB_FILE; + break; + case Brw_ADMI_SHARE_CTR: + NoteType = Soc_NOTE_CTR_SHA_PUB_FILE; + break; + case Brw_ADMI_DOCUM_DEG: + NoteType = Soc_NOTE_DEG_DOC_PUB_FILE; + break; + case Brw_ADMI_SHARE_DEG: + NoteType = Soc_NOTE_DEG_SHA_PUB_FILE; + break; + case Brw_ADMI_DOCUM_CRS: + NoteType = Soc_NOTE_CRS_DOC_PUB_FILE; + break; + case Brw_ADMI_SHARE_CRS: + NoteType = Soc_NOTE_CRS_SHA_PUB_FILE; + break; + default: + return; + } + sprintf (Query,"UPDATE social_notes SET Unavailable='Y'" + " WHERE NoteType='%u' AND Cod IN" + " (SELECT FilCod FROM files" + " WHERE FileBrowser='%u' AND Cod='%ld'" + " AND Path LIKE '%s/%%' AND Public='Y')", // Only public files + (unsigned) NoteType, + (unsigned) FileBrowser,Cod, + Path); + DB_QueryUPDATE (Query,"can not mark social notes as unavailable"); + break; + default: + break; + } + } + /*****************************************************************************/ /***************** Put contextual link to write a new post *******************/ /*****************************************************************************/ diff --git a/swad_social.h b/swad_social.h index 133b608bc..6080ab5ad 100644 --- a/swad_social.h +++ b/swad_social.h @@ -87,6 +87,8 @@ void Soc_ShowTimelineGbl (void); void Soc_StoreAndPublishSocialNote (Soc_NoteType_t NoteType,long Cod); void Soc_MarkSocialNoteAsUnavailableUsingNotCod (long NotCod); void Soc_MarkSocialNoteAsUnavailableUsingNoteTypeAndCod (Soc_NoteType_t NoteType,long Cod); +void Soc_MarkSocialNoteOneFileAsRemoved (const char *Path); +void Soc_MarkSocialNotesChildrenOfFolderAsUnavailable (const char *Path); void Soc_FormSocialPostGbl (void); void Soc_FormSocialPostUsr (void); diff --git a/swad_survey.c b/swad_survey.c index da364f7a5..185713013 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -537,7 +537,7 @@ static void Svy_ShowOneSurvey (long SvyCod,struct SurveyQuestion *SvyQst,bool Sh /***** Mark possible notification as seen *****/ if (Svy.CrsCod > 0) // Only course surveys are notified - Ntf_SetNotifAsSeen (Ntf_EVENT_SURVEY, + Ntf_MarkNotifAsSeen (Ntf_EVENT_SURVEY, SvyCod, Gbl.Usrs.Me.UsrDat.UsrCod); @@ -1260,7 +1260,7 @@ void Svy_RemoveSurvey (void) DB_QueryDELETE (Query,"can not remove survey"); /***** Mark possible notifications as removed *****/ - Ntf_SetNotifAsRemoved (Ntf_EVENT_SURVEY,Svy.SvyCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_SURVEY,Svy.SvyCod); /***** Write message to show the change made *****/ sprintf (Gbl.Message,Txt_Survey_X_removed,