From 08cc0cf4a91a26f786cd8d6a1d63579eeeb2cdc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Mon, 4 Jan 2016 01:02:07 +0100 Subject: [PATCH] Version 15.93.8 --- swad_changelog.h | 5 +- swad_file_browser.c | 16 +++--- swad_file_browser.h | 2 +- swad_notification.c | 128 +++++++++++++++++++++++++++++++++----------- swad_notification.h | 4 +- swad_zip.c | 2 +- 6 files changed, 113 insertions(+), 44 deletions(-) diff --git a/swad_changelog.h b/swad_changelog.h index ac3657288..fd9434311 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -117,14 +117,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.93.7 (2016-01-03)" +#define Log_PLATFORM_VERSION "SWAD 15.93.8 (2016-01-03)" #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.7: Jan 03, 2016 Social note is marked as unavailable when a forum post is removed. (190419 lines) + Version 15.93.8: Jan 03, 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) 6 changes necessary in database: diff --git a/swad_file_browser.c b/swad_file_browser.c index 86b2db74c..0df09104c 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -9787,10 +9787,10 @@ static Brw_License_t Brw_GetParLicense (void) /*****************************************************************************/ /*********************** Get file code using its path ************************/ /*****************************************************************************/ -// Path if the full path in tree +// Path is the full path in tree // Example: descarga/folder/file.pdf -long Brw_GetFilCodByPath (const char *Path) +long Brw_GetFilCodByPath (const char *Path,bool OnlyIfPublic) { long Cod = Brw_GetCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); @@ -9799,13 +9799,15 @@ long Brw_GetFilCodByPath (const char *Path) MYSQL_ROW row; long FilCod; - /***** Get metadata of a file from database *****/ + /***** Get code of a file from database *****/ sprintf (Query,"SELECT FilCod FROM files" " WHERE FileBrowser='%u' AND Cod='%ld' AND ZoneUsrCod='%ld'" - " AND Path='%s'", + " AND Path='%s'%s", (unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type], Cod,ZoneUsrCod, - Path); + Path, + OnlyIfPublic ? " AND Public='Y'" : + ""); if (DB_QuerySELECT (Query,&mysql_res,"can not get file code")) { /* Get row */ @@ -10625,8 +10627,10 @@ static void Brw_RemoveOneFileOrFolderFromDB (const char *Path) Brw_FileBrowser_t FileBrowser = Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type]; /***** Set possible notifications as removed. + Set possible social note as removed. Important: do this before removing from files *****/ - Ntf_SetNotifOneFileAsRemoved (FileBrowser,Cod,Path); + Ntf_SetNotifOneFileAsRemoved (Path); + Ntf_SetSocialNoteOneFileAsRemoved (Path); /***** Remove from database the entries that store the marks properties *****/ if (FileBrowser == Brw_ADMI_MARKS_CRS || diff --git a/swad_file_browser.h b/swad_file_browser.h index bc6eebc0d..654a0abed 100644 --- a/swad_file_browser.h +++ b/swad_file_browser.h @@ -185,7 +185,7 @@ void Brw_ShowFileMetadata (void); void Brw_DownloadFile (void); void Brw_GetLinkToDownloadFile (const char *PathInTree,const char *FileName,char *URL); void Brw_ChgFileMetadata (void); -long Brw_GetFilCodByPath (const char *Path); +long Brw_GetFilCodByPath (const char *Path,bool OnlyIfPublic); void Brw_GetFileMetadataByPath (struct FileMetadata *FileMetadata); void Brw_GetFileMetadataByCod (struct FileMetadata *FileMetadata); bool Brw_GetFileTypeSizeAndDate (struct FileMetadata *FileMetadata); diff --git a/swad_notification.c b/swad_notification.c index ddc26126f..2f7fe9126 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -43,6 +43,7 @@ #include "swad_notice.h" #include "swad_notification.h" #include "swad_parameter.h" +#include "swad_social.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ @@ -906,33 +907,13 @@ void Ntf_SetNotifInCrsAsRemoved (long CrsCod,long ToUsrCod) /************ Set possible notifications of one file as removed **************/ /*****************************************************************************/ -void Ntf_SetNotifOneFileAsRemoved (Brw_FileBrowser_t FileBrowser, - long Cod,const char *Path) +void Ntf_SetNotifOneFileAsRemoved (const char *Path) { - char Query[512]; - char SubQuery[256]; + 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; 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: @@ -941,18 +922,101 @@ void Ntf_SetNotifOneFileAsRemoved (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='%s'", - (unsigned) FileBrowser,Cod,Path); + /***** Get file code *****/ + FilCod = Brw_GetFilCodByPath (Path,false); // Any file, public or not + if (FilCod > 0) + { + /***** 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: + NotifyEvent = Ntf_EVENT_UNKNOWN; // Impossible + break; + } + if (NotifyEvent != Ntf_EVENT_UNKNOWN) // Not necessary + Ntf_SetNotifAsRemoved (NotifyEvent,FilCod); + } + break; + default: + break; + } + } + +/*****************************************************************************/ +/************ Set possible notifications of one file as removed **************/ +/*****************************************************************************/ + +void Ntf_SetSocialNoteOneFileAsRemoved (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; } - 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"); } /*****************************************************************************/ diff --git a/swad_notification.h b/swad_notification.h index d62ff0d16..3af6a5552 100644 --- a/swad_notification.h +++ b/swad_notification.h @@ -107,8 +107,8 @@ 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 (Brw_FileBrowser_t FileBrowser, - long Cod,const char *Path); +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); diff --git a/swad_zip.c b/swad_zip.c index f8e8da136..47acaa2db 100644 --- a/swad_zip.c +++ b/swad_zip.c @@ -540,7 +540,7 @@ static unsigned long long ZIP_CloneDir (const char *Path,const char *PathClone,c Lay_ShowErrorAndExit ("Can not create temporary link for compression."); /***** Update number of my views of this file *****/ - Brw_UpdateMyFileViews (Brw_GetFilCodByPath (PathFileInTree)); + Brw_UpdateMyFileViews (Brw_GetFilCodByPath (PathFileInTree,false)); // Any file, public or not } } }