diff --git a/Makefile b/Makefile index 649c10a9..8f1e7756 100644 --- a/Makefile +++ b/Makefile @@ -61,8 +61,8 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \ swad_system_config.o \ swad_tab.o swad_tag.o swad_test.o swad_test_config.o \ swad_test_import.o swad_test_print.o swad_test_visibility.o \ - swad_theme.o \ - swad_timeline.o swad_timeline_favourite.o swad_timeline_share.o \ + swad_theme.o swad_timeline.o swad_timeline_comment.o \ + swad_timeline_favourite.o swad_timeline_note.o swad_timeline_share.o \ swad_timetable.o \ swad_user.o \ swad_xml.o \ diff --git a/swad_API.c b/swad_API.c index 76b17b18..43801a3f 100644 --- a/swad_API.c +++ b/swad_API.c @@ -3336,10 +3336,10 @@ int swad__getNotifications (struct soap *soap, Ntf_NotifyEvent_t NotifyEvent; long EventTime; char PhotoURL[Cns_MAX_BYTES_WWW + 1]; - struct Instit Ins; - struct Centre Ctr; - struct Degree Deg; - struct Course Crs; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; + struct Crs_Course Crs; long Cod; struct For_Forum ForumSelected; char ForumName[For_MAX_BYTES_FORUM_NAME + 1]; diff --git a/swad_RSS.c b/swad_RSS.c index a93c3842..b557737e 100644 --- a/swad_RSS.c +++ b/swad_RSS.c @@ -50,14 +50,14 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs); -static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Course *Crs); +static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs); +static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Crs_Course *Crs); /*****************************************************************************/ /******* Update RSS archive with active notices in the current course ********/ /*****************************************************************************/ -void RSS_UpdateRSSFileForACrs (struct Course *Crs) +void RSS_UpdateRSSFileForACrs (struct Crs_Course *Crs) { char PathRelPublRSSDir[PATH_MAX + 1]; char PathRelPublRSSFile[PATH_MAX + 1 + NAME_MAX + 1]; @@ -147,7 +147,7 @@ void RSS_UpdateRSSFileForACrs (struct Course *Crs) /************* Write notices of a course as items of RSS file ****************/ /*****************************************************************************/ -static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs) +static void RSS_WriteNotices (FILE *FileRSS,struct Crs_Course *Crs) { extern const char *Txt_Notice; MYSQL_RES *mysql_res; @@ -243,7 +243,7 @@ static void RSS_WriteNotices (FILE *FileRSS,struct Course *Crs) /******** Write exam announcements of a course as items of RSS file **********/ /*****************************************************************************/ -static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Course *Crs) +static void RSS_WriteExamAnnouncements (FILE *FileRSS,struct Crs_Course *Crs) { extern const char *Txt_Exam; MYSQL_RES *mysql_res; diff --git a/swad_RSS.h b/swad_RSS.h index 9236eb3e..5e63d1e4 100644 --- a/swad_RSS.h +++ b/swad_RSS.h @@ -39,7 +39,7 @@ /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void RSS_UpdateRSSFileForACrs (struct Course *Crs); +void RSS_UpdateRSSFileForACrs (struct Crs_Course *Crs); void RSS_BuildRSSLink (char RSSLink[Cns_MAX_BYTES_WWW + 1],long CrsCod); #endif diff --git a/swad_action.c b/swad_action.c index 5b14263a..c17c4bef 100644 --- a/swad_action.c +++ b/swad_action.c @@ -95,6 +95,7 @@ #include "swad_tag.h" #include "swad_test_import.h" #include "swad_timeline.h" +#include "swad_timeline_comment.h" #include "swad_timeline_favourite.h" #include "swad_timeline_share.h" #include "swad_timetable.h" @@ -143,8 +144,8 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActRefNewTL_PubGbl ] = {1509,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_AJAX_RFRESH,TL_GetParamWho ,TL_RefreshNewTimelineGbl ,NULL}, [ActRefOldTL_PubGbl ] = {1510,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,TL_GetParamWho ,TL_RefreshOldTimelineGbl ,NULL}, [ActRcvTL_PstGbl ] = {1492,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_DATA,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_ReceivePostGbl ,NULL}, - [ActRcvTL_ComGbl ] = {1503,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_DATA,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_ReceiveCommentGbl ,NULL}, - [ActShoHidTL_ComGbl ] = {1806,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_ShowHiddenCommentsGbl ,NULL}, + [ActRcvTL_ComGbl ] = {1503,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_DATA,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_Com_ReceiveCommentGbl ,NULL}, + [ActShoHidTL_ComGbl ] = {1806,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Com_ShowHiddenCommentsGbl ,NULL}, [ActAllShaTL_NotGbl ] = {1766,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Sha_ShowAllSharersNoteGbl ,NULL}, [ActAllFavTL_NotGbl ] = {1767,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Fav_ShowAllFaversNoteGbl ,NULL}, [ActAllFavTL_ComGbl ] = {1768,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Fav_ShowAllFaversComGbl ,NULL}, @@ -154,17 +155,17 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActUnfTL_NotGbl ] = {1513,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Fav_UnfNoteGbl ,NULL}, [ActFavTL_ComGbl ] = {1516,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Fav_FavCommentGbl ,NULL}, [ActUnfTL_ComGbl ] = {1517,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Fav_UnfCommentGbl ,NULL}, - [ActReqRemTL_PubGbl ] = {1494,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_RequestRemNoteGbl ,NULL}, - [ActRemTL_PubGbl ] = {1493,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_RemoveNoteGbl ,NULL}, - [ActReqRemTL_ComGbl ] = {1505,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_RequestRemComGbl ,NULL}, - [ActRemTL_ComGbl ] = {1507,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_RemoveComGbl ,NULL}, + [ActReqRemTL_PubGbl ] = {1494,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_Not_RequestRemNoteGbl ,NULL}, + [ActRemTL_PubGbl ] = {1493,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_Not_RemoveNoteGbl ,NULL}, + [ActReqRemTL_ComGbl ] = {1505,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_Com_RequestRemComGbl ,NULL}, + [ActRemTL_ComGbl ] = {1507,-1,TabUnk,ActSeeTmlGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,TL_GetParamWho ,TL_Com_RemoveComGbl ,NULL}, [ActReqOthPubPrf ] = {1401,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prf_RequestUserProfile ,NULL}, [ActRefOldTL_PubUsr ] = {1511,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_RefreshOldTimelineUsr ,NULL}, [ActRcvTL_PstUsr ] = {1498,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,TL_ReceivePostUsr ,NULL}, - [ActRcvTL_ComUsr ] = {1504,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,TL_ReceiveCommentUsr ,NULL}, - [ActShoHidTL_ComUsr ] = {1807,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_ShowHiddenCommentsUsr ,NULL}, + [ActRcvTL_ComUsr ] = {1504,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,TL_Com_ReceiveCommentUsr ,NULL}, + [ActShoHidTL_ComUsr ] = {1807,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Com_ShowHiddenCommentsUsr ,NULL}, [ActAllShaTL_NotUsr ] = {1769,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Sha_ShowAllSharersNoteUsr ,NULL}, [ActAllFavTL_NotUsr ] = {1770,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Fav_ShowAllFaversNoteUsr ,NULL}, [ActAllFavTL_ComUsr ] = {1771,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Fav_ShowAllFaversComUsr ,NULL}, @@ -174,10 +175,10 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActUnfTL_NotUsr ] = {1515,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Fav_UnfNoteUsr ,NULL}, [ActFavTL_ComUsr ] = {1518,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Fav_FavCommentUsr ,NULL}, [ActUnfTL_ComUsr ] = {1519,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_AJAX_NORMAL,NULL ,TL_Fav_UnfCommentUsr ,NULL}, - [ActReqRemTL_PubUsr ] = {1501,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TL_RequestRemNoteUsr ,NULL}, - [ActRemTL_PubUsr ] = {1502,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TL_RemoveNoteUsr ,NULL}, - [ActReqRemTL_ComUsr ] = {1506,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TL_RequestRemComUsr ,NULL}, - [ActRemTL_ComUsr ] = {1508,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TL_RemoveComUsr ,NULL}, + [ActReqRemTL_PubUsr ] = {1501,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TL_Not_RequestRemNoteUsr ,NULL}, + [ActRemTL_PubUsr ] = {1502,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TL_Not_RemoveNoteUsr ,NULL}, + [ActReqRemTL_ComUsr ] = {1506,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TL_Com_RequestRemComUsr ,NULL}, + [ActRemTL_ComUsr ] = {1508,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TL_Com_RemoveComUsr ,NULL}, [ActSeeOthPubPrf ] = {1402,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prf_GetUsrDatAndShowUserProfile,NULL}, [ActCalFig ] = {1405,-1,TabUnk,ActSeeSocPrf ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Prf_CalculateFigures ,NULL}, diff --git a/swad_centre.c b/swad_centre.c index 8c89f86e..8c8be3c3 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -62,7 +62,7 @@ extern struct Globals Gbl; /***************************** Private variables *****************************/ /*****************************************************************************/ -static struct Centre *Ctr_EditingCtr = NULL; // Static variable to keep the centre being edited +static struct Ctr_Centre *Ctr_EditingCtr = NULL; // Static variable to keep the centre being edited /*****************************************************************************/ /***************************** Private prototypes ****************************/ @@ -72,16 +72,16 @@ static void Ctr_ListCentres (void); static bool Ctr_CheckIfICanCreateCentres (void); static void Ctr_PutIconsListingCentres (__attribute__((unused)) void *Args); static void Ctr_PutIconToEditCentres (void); -static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr); +static void Ctr_ListOneCentreForSeeing (struct Ctr_Centre *Ctr,unsigned NumCtr); static void Ctr_GetParamCtrOrder (void); static void Ctr_EditCentresInternal (void); static void Ctr_PutIconsEditingCentres (__attribute__((unused)) void *Args); -static void Ctr_GetDataOfCentreFromRow (struct Centre *Ctr,MYSQL_ROW row); +static void Ctr_GetDataOfCentreFromRow (struct Ctr_Centre *Ctr,MYSQL_ROW row); static void Ctr_ListCentresForEdition (const struct Plc_Places *Places); -static bool Ctr_CheckIfICanEditACentre (struct Centre *Ctr); +static bool Ctr_CheckIfICanEditACentre (struct Ctr_Centre *Ctr); static Ctr_StatusTxt_t Ctr_GetStatusTxtFromStatusBits (Ctr_Status_t Status); static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt); @@ -103,7 +103,7 @@ static unsigned Ctr_GetNumCtrsInCty (long CtyCod); static void Ctr_EditingCentreConstructor (void); static void Ctr_EditingCentreDestructor (void); -static void Ctr_FormToGoToMap (struct Centre *Ctr); +static void Ctr_FormToGoToMap (struct Ctr_Centre *Ctr); /*****************************************************************************/ /******************* List centres with pending degrees ***********************/ @@ -120,7 +120,7 @@ void Ctr_SeeCtrWithPendingDegs (void) MYSQL_ROW row; unsigned NumCtrs; unsigned NumCtr; - struct Centre Ctr; + struct Ctr_Centre Ctr; const char *BgColor; /***** Get centres with pending degrees *****/ @@ -214,7 +214,7 @@ void Ctr_SeeCtrWithPendingDegs (void) /******************** Draw centre logo and name with link ********************/ /*****************************************************************************/ -void Ctr_DrawCentreLogoAndNameWithLink (struct Centre *Ctr,Act_Action_t Action, +void Ctr_DrawCentreLogoAndNameWithLink (struct Ctr_Centre *Ctr,Act_Action_t Action, const char *ClassLink,const char *ClassLogo) { /***** Begin form *****/ @@ -356,7 +356,7 @@ static void Ctr_PutIconToEditCentres (void) /************************* List one centre for seeing ************************/ /*****************************************************************************/ -static void Ctr_ListOneCentreForSeeing (struct Centre *Ctr,unsigned NumCtr) +static void Ctr_ListOneCentreForSeeing (struct Ctr_Centre *Ctr,unsigned NumCtr) { extern const char *Txt_CENTRE_STATUS[Ctr_NUM_STATUS_TXT]; struct Plc_Place Plc; @@ -544,7 +544,7 @@ void Ctr_GetBasicListOfCentres (long InsCod) MYSQL_ROW row; unsigned long NumRows; unsigned NumCtr; - struct Centre *Ctr; + struct Ctr_Centre *Ctr; /***** Get centres from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get centres", @@ -570,8 +570,8 @@ void Ctr_GetBasicListOfCentres (long InsCod) Gbl.Hierarchy.Ctrs.Num = (unsigned) NumRows; /***** Create list with courses in degree *****/ - if ((Gbl.Hierarchy.Ctrs.Lst = (struct Centre *) calloc (NumRows, - sizeof (struct Centre))) == NULL) + if ((Gbl.Hierarchy.Ctrs.Lst = (struct Ctr_Centre *) calloc (NumRows, + sizeof (struct Ctr_Centre))) == NULL) Lay_NotEnoughMemoryExit (); /***** Get the centres *****/ @@ -612,7 +612,7 @@ void Ctr_GetFullListOfCentres (long InsCod) MYSQL_ROW row; unsigned long NumRows; unsigned NumCtr; - struct Centre *Ctr; + struct Ctr_Centre *Ctr; /***** Get centres from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get centres", @@ -659,8 +659,8 @@ void Ctr_GetFullListOfCentres (long InsCod) Gbl.Hierarchy.Ctrs.Num = (unsigned) NumRows; /***** Create list with courses in degree *****/ - if ((Gbl.Hierarchy.Ctrs.Lst = (struct Centre *) calloc (NumRows, - sizeof (struct Centre))) == NULL) + if ((Gbl.Hierarchy.Ctrs.Lst = (struct Ctr_Centre *) calloc (NumRows, + sizeof (struct Ctr_Centre))) == NULL) Lay_NotEnoughMemoryExit (); /***** Get the centres *****/ @@ -691,7 +691,7 @@ void Ctr_GetFullListOfCentres (long InsCod) /************************ Get data of centre by code *************************/ /*****************************************************************************/ -bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr) +bool Ctr_GetDataOfCentreByCod (struct Ctr_Centre *Ctr) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -748,7 +748,7 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr) /********** Get data of a centre from a row resulting of a query *************/ /*****************************************************************************/ -static void Ctr_GetDataOfCentreFromRow (struct Centre *Ctr,MYSQL_ROW row) +static void Ctr_GetDataOfCentreFromRow (struct Ctr_Centre *Ctr,MYSQL_ROW row) { /***** Get centre code (row[0]) *****/ if ((Ctr->CtrCod = Str_ConvertStrCodToLongCod (row[0])) <= 0) @@ -822,7 +822,7 @@ long Ctr_GetInsCodOfCentreByCod (long CtrCod) /*************** Get the short name of a centre from its code ****************/ /*****************************************************************************/ -void Ctr_GetShortNameOfCentreByCod (struct Centre *Ctr) +void Ctr_GetShortNameOfCentreByCod (struct Ctr_Centre *Ctr) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -937,7 +937,7 @@ static void Ctr_ListCentresForEdition (const struct Plc_Places *Places) extern const char *Txt_Another_place; extern const char *Txt_CENTRE_STATUS[Ctr_NUM_STATUS_TXT]; unsigned NumCtr; - struct Centre *Ctr; + struct Ctr_Centre *Ctr; unsigned NumPlc; char WWW[Cns_MAX_BYTES_WWW + 1]; struct UsrData UsrDat; @@ -1135,7 +1135,7 @@ static void Ctr_ListCentresForEdition (const struct Plc_Places *Places) /************** Check if I can edit, remove, etc. a centre *******************/ /*****************************************************************************/ -static bool Ctr_CheckIfICanEditACentre (struct Centre *Ctr) +static bool Ctr_CheckIfICanEditACentre (struct Ctr_Centre *Ctr) { return (bool) (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM || // I am an institution administrator or higher ((Ctr->Status & Ctr_STATUS_BIT_PENDING) != 0 && // Centre is not yet activated @@ -1361,7 +1361,7 @@ void Ctr_RenameCentreFull (void) /************************ Change the name of a centre ************************/ /*****************************************************************************/ -void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName) +void Ctr_RenameCentre (struct Ctr_Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName) { extern const char *Txt_The_centre_X_already_exists; extern const char *Txt_The_centre_X_has_been_renamed_as_Y; @@ -2224,7 +2224,7 @@ void Ctr_ListCtrsFound (MYSQL_RES **mysql_res,unsigned NumCtrs) extern const char *Txt_centres; MYSQL_ROW row; unsigned NumCtr; - struct Centre Ctr; + struct Ctr_Centre Ctr; /***** Query database *****/ if (NumCtrs) @@ -2278,7 +2278,7 @@ static void Ctr_EditingCentreConstructor (void) Lay_ShowErrorAndExit ("Error initializing centre."); /***** Allocate memory for centre *****/ - if ((Ctr_EditingCtr = (struct Centre *) malloc (sizeof (struct Centre))) == NULL) + if ((Ctr_EditingCtr = (struct Ctr_Centre *) malloc (sizeof (struct Ctr_Centre))) == NULL) Lay_ShowErrorAndExit ("Error allocating memory for centre."); /***** Reset centre *****/ @@ -2306,7 +2306,7 @@ static void Ctr_EditingCentreDestructor (void) /************************ Form to go to centre map ***************************/ /*****************************************************************************/ -static void Ctr_FormToGoToMap (struct Centre *Ctr) +static void Ctr_FormToGoToMap (struct Ctr_Centre *Ctr) { extern const char *Txt_Map; @@ -2324,7 +2324,7 @@ static void Ctr_FormToGoToMap (struct Centre *Ctr) /************************ Check if a centre has map **************************/ /*****************************************************************************/ -bool Ctr_GetIfMapIsAvailable (const struct Centre *Ctr) +bool Ctr_GetIfMapIsAvailable (const struct Ctr_Centre *Ctr) { /***** Coordinates 0, 0 means not set ==> don't show map *****/ return (bool) (Ctr->Coord.Latitude || diff --git a/swad_centre.h b/swad_centre.h index 83666789..415862b3 100644 --- a/swad_centre.h +++ b/swad_centre.h @@ -60,7 +60,7 @@ typedef enum #define Ctr_MAX_CENTRES_PER_USR 10 // Used in list of my centres -struct Centre +struct Ctr_Centre { long CtrCod; // Centre code long InsCod; // Institution code @@ -89,7 +89,7 @@ typedef enum struct ListCentres { unsigned Num; // Number of centres - struct Centre *Lst; // List of centres + struct Ctr_Centre *Lst; // List of centres Ctr_Order_t SelectedOrder; // Order of centres }; @@ -99,7 +99,7 @@ struct ListCentres void Ctr_SeeCtrWithPendingDegs (void); -void Ctr_DrawCentreLogoAndNameWithLink (struct Centre *Ctr,Act_Action_t Action, +void Ctr_DrawCentreLogoAndNameWithLink (struct Ctr_Centre *Ctr,Act_Action_t Action, const char *ClassLink,const char *ClassLogo); void Ctr_ShowCtrsOfCurrentIns (void); @@ -109,9 +109,9 @@ void Ctr_PutIconToViewCentres (void); void Ctr_GetBasicListOfCentres (long InsCod); void Ctr_GetFullListOfCentres (long InsCod); -bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr); +bool Ctr_GetDataOfCentreByCod (struct Ctr_Centre *Ctr); long Ctr_GetInsCodOfCentreByCod (long CtrCod); -void Ctr_GetShortNameOfCentreByCod (struct Centre *Ctr); +void Ctr_GetShortNameOfCentreByCod (struct Ctr_Centre *Ctr); void Ctr_FreeListCentres (void); void Ctr_WriteSelectorOfCentre (void); void Ctr_PutParamCtrCod (long CtrCod); @@ -121,7 +121,7 @@ void Ctr_ChangeCtrPlc (void); void Ctr_UpdateCtrPlcDB (long CtrCod,long NewPlcCod); void Ctr_RenameCentreShort (void); void Ctr_RenameCentreFull (void); -void Ctr_RenameCentre (struct Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName); +void Ctr_RenameCentre (struct Ctr_Centre *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName); bool Ctr_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name, long CtrCod,long InsCod); void Ctr_ChangeCtrWWW (void); @@ -156,6 +156,6 @@ unsigned Ctr_GetCachedNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery, void Ctr_ListCtrsFound (MYSQL_RES **mysql_res,unsigned NumCtrs); -bool Ctr_GetIfMapIsAvailable (const struct Centre *Ctr); +bool Ctr_GetIfMapIsAvailable (const struct Ctr_Centre *Ctr); #endif diff --git a/swad_centre_config.c b/swad_centre_config.c index e00271e6..fbf84f60 100644 --- a/swad_centre_config.c +++ b/swad_centre_config.c @@ -1027,7 +1027,7 @@ void CtrCfg_ChangeCtrIns (void) { extern const char *Txt_The_centre_X_already_exists; extern const char *Txt_The_centre_X_has_been_moved_to_the_institution_Y; - struct Instit NewIns; + struct Ins_Instit NewIns; /***** Get parameter with institution code *****/ NewIns.InsCod = Ins_GetAndCheckParamOtherInsCod (1); diff --git a/swad_changelog.h b/swad_changelog.h index 2242c9fd..2282a3f4 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 20.22 (2021-02-10)" +#define Log_PLATFORM_VERSION "SWAD 20.23 (2021-02-11)" #define CSS_FILE "swad20.8.css" #define JS_FILE "swad20.6.2.js" /* @@ -601,6 +601,7 @@ TODO: DNI de un estudiante sale err TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede. TODO: Salvador Romero Cortés: @acanas opción para editar posts + Version 20.23: Feb 11, 2021 New modules swad_timeline_comment and swad_timeline_note. (305319 lines) Version 20.22: Feb 10, 2021 Code refactoring in timeline. (305137 lines) Version 20.21.4: Feb 10, 2021 Code refactoring in timeline. (305136 lines) Version 20.21.3: Feb 10, 2021 Code refactoring in timeline. (305122 lines) diff --git a/swad_chat.c b/swad_chat.c index c4bf6b64..de482b13 100644 --- a/swad_chat.c +++ b/swad_chat.c @@ -110,8 +110,8 @@ void Cht_ShowListOfAvailableChatRooms (void) extern const char *Txt_Course; bool IsLastItemInLevel[1 + Cht_CHAT_MAX_LEVELS]; unsigned NumMyDeg; - struct Degree Deg; - struct Course Crs; + struct Deg_Degree Deg; + struct Crs_Course Crs; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned long NumRow; @@ -400,8 +400,8 @@ void Cht_OpenChatWindow (void) char UsrName[Usr_MAX_BYTES_FULL_NAME + 1]; unsigned NumMyDeg; unsigned NumMyCrs; - struct Degree Deg; - struct Course Crs; + struct Deg_Degree Deg; + struct Crs_Course Crs; char ThisRoomCode[Cht_MAX_BYTES_ROOM_CODE + 1]; char ThisRoomShortName[Cht_MAX_BYTES_ROOM_SHRT_NAME + 1]; char ThisRoomFullName [Cht_MAX_BYTES_ROOM_FULL_NAME + 1]; diff --git a/swad_country_config.c b/swad_country_config.c index fbdb5101..2d35223a 100644 --- a/swad_country_config.c +++ b/swad_country_config.c @@ -274,8 +274,8 @@ static void CtyCfg_Map (void) unsigned Zoom; unsigned NumCtrs; unsigned NumCtr; - struct Centre Ctr; - struct Instit Ins; + struct Ctr_Centre Ctr; + struct Ins_Instit Ins; /***** Leaflet CSS *****/ Map_LeafletCSS (); diff --git a/swad_course.c b/swad_course.c index 938f5467..32421df3 100644 --- a/swad_course.c +++ b/swad_course.c @@ -70,7 +70,7 @@ extern struct Globals Gbl; /**************************** Private variables ******************************/ /*****************************************************************************/ -static struct Course *Crs_EditingCrs = NULL; // Static variable to keep the course being edited +static struct Crs_Course *Crs_EditingCrs = NULL; // Static variable to keep the course being edited /*****************************************************************************/ /**************************** Private prototypes *****************************/ @@ -90,17 +90,17 @@ static void Crs_PutIconsEditingCourses (__attribute__((unused)) void *Args); static void Crs_PutIconToViewCourses (void); static void Crs_ListCoursesForEdition (void); static void Crs_ListCoursesOfAYearForEdition (unsigned Year); -static bool Crs_CheckIfICanEdit (struct Course *Crs); +static bool Crs_CheckIfICanEdit (struct Crs_Course *Crs); static Crs_StatusTxt_t Crs_GetStatusTxtFromStatusBits (Crs_Status_t Status); static Crs_Status_t Crs_GetStatusBitsFromStatusTxt (Crs_StatusTxt_t StatusTxt); static void Crs_PutFormToCreateCourse (void); static void Crs_PutHeadCoursesForSeeing (void); static void Crs_PutHeadCoursesForEdition (void); static void Crs_ReceiveFormRequestOrCreateCrs (unsigned Status); -static void Crs_GetParamsNewCourse (struct Course *Crs); +static void Crs_GetParamsNewCourse (struct Crs_Course *Crs); static void Crs_CreateCourse (unsigned Status); -static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row); +static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row); static void Crs_GetShortNamesByCod (long CrsCod, char CrsShortName[Hie_MAX_BYTES_SHRT_NAME + 1], @@ -155,10 +155,10 @@ static void Crs_WriteListMyCoursesToSelectOne (void) extern const char *Txt_My_courses; extern const char *Txt_System; struct Country Cty; - struct Instit Ins; - struct Centre Ctr; - struct Degree Deg; - struct Course Crs; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; + struct Crs_Course Crs; bool IsLastItemInLevel[1 + 5]; bool Highlight; // Highlight because degree, course, etc. is selected MYSQL_RES *mysql_resCty; @@ -750,7 +750,7 @@ static void Crs_GetListCrssInCurrentDeg (Crs_WhatCourses_t WhatCourses) MYSQL_ROW row; unsigned NumCrss; unsigned NumCrs; - struct Course *Crs; + struct Crs_Course *Crs; /***** Get courses of a degree from database *****/ switch (WhatCourses) @@ -778,8 +778,8 @@ static void Crs_GetListCrssInCurrentDeg (Crs_WhatCourses_t WhatCourses) if (NumCrss) // Courses found... { /***** Create list with courses in degree *****/ - if ((Gbl.Hierarchy.Crss.Lst = (struct Course *) calloc ((size_t) NumCrss, - sizeof (struct Course))) == NULL) + if ((Gbl.Hierarchy.Crss.Lst = (struct Crs_Course *) calloc ((size_t) NumCrss, + sizeof (struct Crs_Course))) == NULL) Lay_NotEnoughMemoryExit (); /***** Get the courses in degree *****/ @@ -985,7 +985,7 @@ static bool Crs_ListCoursesOfAYearForSeeing (unsigned Year) extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; extern const char *Txt_COURSE_STATUS[Crs_NUM_STATUS_TXT]; unsigned NumCrs; - struct Course *Crs; + struct Crs_Course *Crs; const char *TxtClassNormal; const char *TxtClassStrong; const char *BgColor; @@ -1195,7 +1195,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) { extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; extern const char *Txt_COURSE_STATUS[Crs_NUM_STATUS_TXT]; - struct Course *Crs; + struct Crs_Course *Crs; unsigned YearAux; unsigned NumCrs; struct UsrData UsrDat; @@ -1364,7 +1364,7 @@ static void Crs_ListCoursesOfAYearForEdition (unsigned Year) /************** Check if I can edit, remove, etc. a course *******************/ /*****************************************************************************/ -static bool Crs_CheckIfICanEdit (struct Course *Crs) +static bool Crs_CheckIfICanEdit (struct Crs_Course *Crs) { return (bool) (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM || // I am a degree administrator or higher ((Crs->Status & Crs_STATUS_BIT_PENDING) != 0 && // Course is not yet activated @@ -1655,7 +1655,7 @@ static void Crs_ReceiveFormRequestOrCreateCrs (unsigned Status) /************** Get the parameters of a new course from form *****************/ /*****************************************************************************/ -static void Crs_GetParamsNewCourse (struct Course *Crs) +static void Crs_GetParamsNewCourse (struct Crs_Course *Crs) { char YearStr[2 + 1]; @@ -1744,7 +1744,7 @@ void Crs_RemoveCourse (void) /********************* Get data of a course from its code ********************/ /*****************************************************************************/ -bool Crs_GetDataOfCourseByCod (struct Course *Crs) +bool Crs_GetDataOfCourseByCod (struct Crs_Course *Crs) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1793,7 +1793,7 @@ bool Crs_GetDataOfCourseByCod (struct Course *Crs) /********** Get data of a course from a row resulting of a query *************/ /*****************************************************************************/ -static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row) +static void Crs_GetDataOfCourseFromRow (struct Crs_Course *Crs,MYSQL_ROW row) { /***** Get course code (row[0]) *****/ if ((Crs->CrsCod = Str_ConvertStrCodToLongCod (row[0])) < 0) @@ -1893,7 +1893,7 @@ void Crs_RemoveCourseCompletely (long CrsCod) static void Crs_EmptyCourseCompletely (long CrsCod) { - struct Course Crs; + struct Crs_Course Crs; char PathRelCrs[PATH_MAX + 1]; if (CrsCod > 0) @@ -2148,7 +2148,7 @@ void Crs_ChangeCrsYear (void) /****************** Change the year/semester of a course *********************/ /*****************************************************************************/ -void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear) +void Crs_UpdateCrsYear (struct Crs_Course *Crs,unsigned NewYear) { /***** Update year/semester in table of courses *****/ DB_QueryUPDATE ("can not update the year of a course", @@ -2163,7 +2163,7 @@ void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear) /************* Change the institutional course code of a course **************/ /*****************************************************************************/ -void Crs_UpdateInstitutionalCrsCod (struct Course *Crs,const char *NewInstitutionalCrsCod) +void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,const char *NewInstitutionalCrsCod) { /***** Update institutional course code in table of courses *****/ DB_QueryUPDATE ("can not update the institutional code" @@ -2204,7 +2204,7 @@ void Crs_RenameCourseFull (void) /************************ Change the name of a course ************************/ /*****************************************************************************/ -void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName) +void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName) { extern const char *Txt_The_course_X_already_exists; extern const char *Txt_The_name_of_the_course_X_has_changed_to_Y; @@ -2722,7 +2722,7 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA extern const char *Txt_Enrolment_confirmed; extern const char *Txt_Enrolment_not_confirmed; extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; - struct Degree Deg; + struct Deg_Degree Deg; long CrsCod; unsigned NumStds; unsigned NumNETs; @@ -2990,7 +2990,7 @@ static void Crs_EditingCourseConstructor (void) Lay_ShowErrorAndExit ("Error initializing course."); /***** Allocate memory for course *****/ - if ((Crs_EditingCrs = (struct Course *) malloc (sizeof (struct Course))) == NULL) + if ((Crs_EditingCrs = (struct Crs_Course *) malloc (sizeof (struct Crs_Course))) == NULL) Lay_ShowErrorAndExit ("Error allocating memory for course."); /***** Reset course *****/ diff --git a/swad_course.h b/swad_course.h index 5a0ebe06..3f5fffde 100644 --- a/swad_course.h +++ b/swad_course.h @@ -75,7 +75,7 @@ typedef enum Crs_ALL_COURSES_EXCEPT_REMOVED = 1, // Courses with Status bit Crs_STATUS_BIT_REMOVED == 0 } Crs_WhatCourses_t; -struct Course +struct Crs_Course { long CrsCod; char InstitutionalCrsCod[Crs_MAX_BYTES_INSTITUTIONAL_CRS_COD + 1]; // Institutional code of the course @@ -90,7 +90,7 @@ struct Course struct ListCourses { unsigned Num; // Number of courses - struct Course *Lst; // List of courses + struct Crs_Course *Lst; // List of courses }; /*****************************************************************************/ @@ -131,15 +131,15 @@ void Crs_ReceiveFormReqCrs (void); void Crs_ReceiveFormNewCrs (void); void Crs_RemoveCourse (void); -bool Crs_GetDataOfCourseByCod (struct Course *Crs); +bool Crs_GetDataOfCourseByCod (struct Crs_Course *Crs); void Crs_RemoveCourseCompletely (long CrsCod); void Crs_ChangeInsCrsCod (void); void Crs_ChangeCrsYear (void); -void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear); -void Crs_UpdateInstitutionalCrsCod (struct Course *Crs,const char *NewInstitutionalCrsCod); +void Crs_UpdateCrsYear (struct Crs_Course *Crs,unsigned NewYear); +void Crs_UpdateInstitutionalCrsCod (struct Crs_Course *Crs,const char *NewInstitutionalCrsCod); void Crs_RenameCourseShort (void); void Crs_RenameCourseFull (void); -void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName); +void Crs_RenameCourse (struct Crs_Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName); bool Crs_CheckIfCrsNameExistsInYearOfDeg (const char *FieldName,const char *Name,long CrsCod, long DegCod,unsigned Year); void Crs_ChangeCrsStatus (void); diff --git a/swad_course_config.c b/swad_course_config.c index 92e7d073..4f64eb9b 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -467,7 +467,7 @@ void CrsCfg_ChangeCrsDeg (void) extern const char *Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z; extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; extern const char *Txt_The_course_X_has_been_moved_to_the_degree_Y; - struct Degree NewDeg; + struct Deg_Degree NewDeg; /***** Get parameter with degree code *****/ NewDeg.DegCod = Deg_GetAndCheckParamOtherDegCod (1); diff --git a/swad_degree.c b/swad_degree.c index b9e90191..7ee63a4e 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -67,14 +67,14 @@ typedef enum /**************************** Private variables ******************************/ /*****************************************************************************/ -static struct Degree *Deg_EditingDeg = NULL; // Static variable to keep the degree being edited +static struct Deg_Degree *Deg_EditingDeg = NULL; // Static variable to keep the degree being edited /*****************************************************************************/ /**************************** Private prototypes *****************************/ /*****************************************************************************/ static void Deg_ListDegreesForEdition (void); -static bool Deg_CheckIfICanEditADegree (struct Degree *Deg); +static bool Deg_CheckIfICanEditADegree (struct Deg_Degree *Deg); static Deg_StatusTxt_t Deg_GetStatusTxtFromStatusBits (Deg_Status_t Status); static Deg_Status_t Deg_GetStatusBitsFromStatusTxt (Deg_StatusTxt_t StatusTxt); static void Deg_PutFormToCreateDegree (void); @@ -86,7 +86,7 @@ static void Deg_ListDegrees (void); static bool Deg_CheckIfICanCreateDegrees (void); static void Deg_PutIconsListingDegrees (__attribute__((unused)) void *Args); static void Deg_PutIconToEditDegrees (void); -static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg); +static void Deg_ListOneDegreeForSeeing (struct Deg_Degree *Deg,unsigned NumDeg); static void Deg_EditDegreesInternal (void); static void Deg_PutIconsEditingDegrees (__attribute__((unused)) void *Args); @@ -94,7 +94,7 @@ static void Deg_PutIconsEditingDegrees (__attribute__((unused)) void *Args); static void Deg_ReceiveFormRequestOrCreateDeg (unsigned Status); static void Deg_PutParamOtherDegCod (void *DegCod); -static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row); +static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row); static void Deg_UpdateDegNameDB (long DegCod,const char *FieldName,const char *NewDegName); @@ -119,7 +119,7 @@ void Deg_SeeDegWithPendingCrss (void) MYSQL_ROW row; unsigned NumDegs; unsigned NumDeg; - struct Degree Deg; + struct Deg_Degree Deg; const char *BgColor; /***** Get degrees with pending courses *****/ @@ -217,7 +217,7 @@ void Deg_SeeDegWithPendingCrss (void) /******************** Draw degree logo and name with link ********************/ /*****************************************************************************/ -void Deg_DrawDegreeLogoAndNameWithLink (struct Degree *Deg,Act_Action_t Action, +void Deg_DrawDegreeLogoAndNameWithLink (struct Deg_Degree *Deg,Act_Action_t Action, const char *ClassLink,const char *ClassLogo) { /***** Begin form *****/ @@ -338,7 +338,7 @@ static void Deg_ListDegreesForEdition (void) extern const char *Txt_DEGREE_STATUS[Deg_NUM_STATUS_TXT]; unsigned NumDeg; struct DegreeType *DegTyp; - struct Degree *Deg; + struct Deg_Degree *Deg; unsigned NumDegTyp; char WWW[Cns_MAX_BYTES_WWW + 1]; struct UsrData UsrDat; @@ -527,7 +527,7 @@ static void Deg_ListDegreesForEdition (void) /************** Check if I can edit, remove, etc. a degree *******************/ /*****************************************************************************/ -static bool Deg_CheckIfICanEditADegree (struct Degree *Deg) +static bool Deg_CheckIfICanEditADegree (struct Deg_Degree *Deg) { return (bool) (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM || // I am a centre administrator or higher ((Deg->Status & Deg_STATUS_BIT_PENDING) != 0 && // Degree is not yet activated @@ -875,7 +875,7 @@ static void Deg_PutIconToEditDegrees (void) /************************ List one degree for seeing *************************/ /*****************************************************************************/ -static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg) +static void Deg_ListOneDegreeForSeeing (struct Deg_Degree *Deg,unsigned NumDeg) { extern const char *Txt_DEGREE_With_courses; extern const char *Txt_DEGREE_Without_courses; @@ -1080,7 +1080,7 @@ void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs) if (Degs->Num) // Degrees found... { /***** Create list with degrees *****/ - if ((Degs->Lst = (struct Degree *) calloc (Degs->Num,sizeof (struct Degree))) == NULL) + if ((Degs->Lst = (struct Deg_Degree *) calloc (Degs->Num,sizeof (struct Deg_Degree))) == NULL) Lay_NotEnoughMemoryExit (); /***** Get the degrees *****/ @@ -1110,7 +1110,7 @@ void Deg_GetListDegsInCurrentCtr (void) MYSQL_ROW row; unsigned long NumRows; unsigned NumDeg; - struct Degree *Deg; + struct Deg_Degree *Deg; /***** Get degrees of the current centre from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get degrees of a centre", @@ -1125,8 +1125,8 @@ void Deg_GetListDegsInCurrentCtr (void) Gbl.Hierarchy.Degs.Num = (unsigned) NumRows; /***** Create list with degrees of this centre *****/ - if ((Gbl.Hierarchy.Degs.Lst = (struct Degree *) calloc (Gbl.Hierarchy.Degs.Num, - sizeof (struct Degree))) == NULL) + if ((Gbl.Hierarchy.Degs.Lst = (struct Deg_Degree *) calloc (Gbl.Hierarchy.Degs.Num, + sizeof (struct Deg_Degree))) == NULL) Lay_NotEnoughMemoryExit (); /***** Get the degrees of this centre *****/ @@ -1323,7 +1323,7 @@ long Deg_GetAndCheckParamOtherDegCod (long MinCodAllowed) /*****************************************************************************/ // Returns true if degree found -bool Deg_GetDataOfDegreeByCod (struct Degree *Deg) +bool Deg_GetDataOfDegreeByCod (struct Deg_Degree *Deg) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1367,7 +1367,7 @@ bool Deg_GetDataOfDegreeByCod (struct Degree *Deg) /********** Get data of a degree from a row resulting of a query *************/ /*****************************************************************************/ -static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row) +static void Deg_GetDataOfDegreeFromRow (struct Deg_Degree *Deg,MYSQL_ROW row) { /***** Get degree code (row[0]) *****/ if ((Deg->DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0) @@ -1403,7 +1403,7 @@ static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row) /************* Get the short name of a degree from its code ******************/ /*****************************************************************************/ -void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg) +void Deg_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1588,7 +1588,7 @@ void Deg_RenameDegreeFull (void) /************************ Change the name of a degree ************************/ /*****************************************************************************/ -void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullName) +void Deg_RenameDegree (struct Deg_Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullName) { extern const char *Txt_The_degree_X_already_exists; extern const char *Txt_The_name_of_the_degree_X_has_changed_to_Y; @@ -2124,7 +2124,7 @@ void Deg_ListDegsFound (MYSQL_RES **mysql_res,unsigned NumDegs) extern const char *Txt_degrees; MYSQL_ROW row; unsigned NumDeg; - struct Degree Deg; + struct Deg_Degree Deg; /***** Query database *****/ if (NumDegs) @@ -2178,7 +2178,7 @@ static void Deg_EditingDegreeConstructor (void) Lay_ShowErrorAndExit ("Error initializing degree."); /***** Allocate memory for degree *****/ - if ((Deg_EditingDeg = (struct Degree *) malloc (sizeof (struct Degree))) == NULL) + if ((Deg_EditingDeg = (struct Deg_Degree *) malloc (sizeof (struct Deg_Degree))) == NULL) Lay_ShowErrorAndExit ("Error allocating memory for degree."); /***** Reset degree *****/ diff --git a/swad_degree.h b/swad_degree.h index 3b5c2bba..56d663d5 100644 --- a/swad_degree.h +++ b/swad_degree.h @@ -66,7 +66,7 @@ typedef enum Deg_STATUS_REMOVED = 3, // 1- (Status & Deg_STATUS_BIT_REMOVED) } Deg_StatusTxt_t; -struct Degree +struct Deg_Degree { long DegCod; // Degree code long DegTypCod; // Degree type code @@ -81,7 +81,7 @@ struct Degree struct ListDegrees { unsigned Num; // Number of degrees - struct Degree *Lst; // List of degrees + struct Deg_Degree *Lst; // List of degrees }; /*****************************************************************************/ @@ -90,7 +90,7 @@ struct ListDegrees void Deg_SeeDegWithPendingCrss (void); -void Deg_DrawDegreeLogoAndNameWithLink (struct Degree *Deg,Act_Action_t Action, +void Deg_DrawDegreeLogoAndNameWithLink (struct Deg_Degree *Deg,Act_Action_t Action, const char *ClassLink,const char *ClassLogo); void Deg_WriteSelectorOfDegree (void); @@ -114,14 +114,14 @@ void Deg_RemoveDegree (void); void Deg_PutParamDegCod (long DegCod); long Deg_GetAndCheckParamOtherDegCod (long MinCodAllowed); -bool Deg_GetDataOfDegreeByCod (struct Degree *Deg); -void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg); +bool Deg_GetDataOfDegreeByCod (struct Deg_Degree *Deg); +void Deg_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg); long Deg_GetCtrCodOfDegreeByCod (long DegCod); long Deg_GetInsCodOfDegreeByCod (long DegCod); void Deg_RemoveDegreeCompletely (long DegCod); void Deg_RenameDegreeShort (void); void Deg_RenameDegreeFull (void); -void Deg_RenameDegree (struct Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullName); +void Deg_RenameDegree (struct Deg_Degree *Deg,Cns_ShrtOrFullName_t ShrtOrFullName); bool Deg_CheckIfDegNameExistsInCtr (const char *FieldName,const char *Name, long DegCod,long CtrCod); void Deg_ChangeDegreeType (void); diff --git a/swad_degree_config.c b/swad_degree_config.c index 8fcd86a4..3dbd5e89 100644 --- a/swad_degree_config.c +++ b/swad_degree_config.c @@ -356,7 +356,7 @@ void DegCfg_ChangeDegCtr (void) { extern const char *Txt_The_degree_X_already_exists; extern const char *Txt_The_degree_X_has_been_moved_to_the_centre_Y; - struct Centre NewCtr; + struct Ctr_Centre NewCtr; /***** Get parameter with centre code *****/ NewCtr.CtrCod = Ctr_GetAndCheckParamOtherCtrCod (1); diff --git a/swad_department.c b/swad_department.c index ca3063a9..b8916c7c 100644 --- a/swad_department.c +++ b/swad_department.c @@ -530,7 +530,7 @@ static void Dpt_ListDepartmentsForEdition (const struct Dpt_Departments *Departm extern const char *Txt_Another_institution; unsigned NumDpt; struct Dpt_Department *Dpt; - struct Instit Ins; + struct Ins_Instit Ins; unsigned NumIns; /***** Begin table *****/ diff --git a/swad_enrolment.c b/swad_enrolment.c index 9d2de093..9f348ede 100644 --- a/swad_enrolment.c +++ b/swad_enrolment.c @@ -172,7 +172,7 @@ static void Enr_ReqRemOrRemAdm (Enr_ReqDelOrDelUsr_t ReqDelOrDelUsr,Hie_Level_t static void Enr_ReqAddAdm (Hie_Level_t Scope,long Cod,const char *InsCtrDegName); static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat); static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat, - struct Course *Crs, + struct Crs_Course *Crs, Enr_RemoveUsrProduction_t RemoveUsrWorks, Cns_QuietOrVerbose_t QuietOrVerbose); @@ -1907,7 +1907,7 @@ void Enr_RemAllStdsThisCrs (void) /*****************************************************************************/ // Returns the numbers of students in the course before deletion -unsigned Enr_RemAllStdsInCrs (struct Course *Crs) +unsigned Enr_RemAllStdsInCrs (struct Crs_Course *Crs) { unsigned NumStdsInCrs; unsigned NumUsr; @@ -2257,8 +2257,8 @@ static void Enr_ShowEnrolmentRequestsGivenRoles (unsigned RolesSelected) unsigned long NumReqs = 0; // Initialized to avoid warning unsigned long NumReq; long ReqCod; - struct Degree Deg; - struct Course Crs; + struct Deg_Degree Deg; + struct Crs_Course Crs; struct UsrData UsrDat; bool UsrExists; bool UsrBelongsToCrs; @@ -4094,7 +4094,7 @@ static void Enr_AskIfRemoveUsrFromCrs (struct UsrData *UsrDat) /*****************************************************************************/ static void Enr_EffectivelyRemUsrFromCrs (struct UsrData *UsrDat, - struct Course *Crs, + struct Crs_Course *Crs, Enr_RemoveUsrProduction_t RemoveUsrWorks, Cns_QuietOrVerbose_t QuietOrVerbose) { diff --git a/swad_enrolment.h b/swad_enrolment.h index 96894898..209d11c8 100644 --- a/swad_enrolment.h +++ b/swad_enrolment.h @@ -106,7 +106,7 @@ bool Enr_PutActionsRegRemOneUsr (bool ItsMe); void Enr_PutLinkToAdminSeveralUsrs (Rol_Role_t Role); void Enr_AskRemAllStdsThisCrs (void); void Enr_RemAllStdsThisCrs (void); -unsigned Enr_RemAllStdsInCrs (struct Course *Crs); +unsigned Enr_RemAllStdsInCrs (struct Crs_Course *Crs); void Enr_ReqSignUpInCrs (void); void Enr_SignUpInCrs (void); void Enr_GetNotifEnrolmentRequest (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], diff --git a/swad_exam_announcement.c b/swad_exam_announcement.c index 29eb6211..f25fc9df 100644 --- a/swad_exam_announcement.c +++ b/swad_exam_announcement.c @@ -45,6 +45,7 @@ #include "swad_RSS.h" #include "swad_string.h" #include "swad_timeline.h" +#include "swad_timeline_note.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ @@ -378,7 +379,7 @@ void ExaAnn_ReceiveExamAnn2 (void) ExaAnn_UpdateNumUsrsNotifiedByEMailAboutExamAnn (ExamAnns->HighlightExaCod,NumUsrsToBeNotifiedByEMail); /***** Create a new social note about the new exam announcement *****/ - TL_StoreAndPublishNote (TL_NOTE_EXAM_ANNOUNCEMENT,ExamAnns->HighlightExaCod); + TL_Not_StoreAndPublishNote (TL_NOTE_EXAM_ANNOUNCEMENT,ExamAnns->HighlightExaCod); /***** Update RSS of current course *****/ RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Crs); @@ -496,7 +497,7 @@ void ExaAnn_RemoveExamAnn1 (void) Ntf_MarkNotifAsRemoved (Ntf_EVENT_EXAM_ANNOUNCEMENT,ExaCod); /***** Mark possible social note as unavailable *****/ - TL_MarkNoteAsUnavailable (TL_NOTE_EXAM_ANNOUNCEMENT,ExaCod); + TL_Not_MarkNoteAsUnavailable (TL_NOTE_EXAM_ANNOUNCEMENT,ExaCod); /***** Update RSS of current course *****/ RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Crs); @@ -1085,7 +1086,7 @@ static void ExaAnn_ShowExamAnn (struct ExaAnn_ExamAnnouncements *ExamAnns, extern const char *Txt_minute; extern const char *Txt_minutes; extern const char *Txt_Publish_announcement_OF_EXAM; - struct Instit Ins; + struct Ins_Instit Ins; char StrExamDate[Cns_MAX_BYTES_DATE + 1]; unsigned Year; unsigned Hour; @@ -1761,9 +1762,9 @@ static void ExaAnn_GetNotifContentExamAnn (const struct ExaAnn_ExamAnnouncements extern const char *Txt_EXAM_ANNOUNCEMENT_Material_allowed; extern const char *Txt_EXAM_ANNOUNCEMENT_Other_information; extern const char *Txt_hours_ABBREVIATION; - struct Course Crs; - struct Degree Deg; - struct Instit Ins; + struct Crs_Course Crs; + struct Deg_Degree Deg; + struct Ins_Instit Ins; char StrExamDate[Cns_MAX_BYTES_DATE + 1]; /***** Get data of course *****/ diff --git a/swad_figure.c b/swad_figure.c index f4e1c172..1acad273 100644 --- a/swad_figure.c +++ b/swad_figure.c @@ -55,6 +55,7 @@ #include "swad_survey.h" #include "swad_test.h" #include "swad_timeline.h" +#include "swad_timeline_note.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ @@ -127,7 +128,7 @@ static void Fig_GetAndShowInssOrderedByNumUsrsInCrss (void); static void Fig_GetAndShowInssOrderedByNumUsrsWhoClaimToBelongToThem (void); static void Fig_ShowInss (MYSQL_RES **mysql_res,unsigned NumInss, const char *TxtFigure); -static unsigned Fig_GetInsAndStat (struct Instit *Ins,MYSQL_RES *mysql_res); +static unsigned Fig_GetInsAndStat (struct Ins_Instit *Ins,MYSQL_RES *mysql_res); static void Fig_GetAndShowDegreeTypesStats (void); @@ -1415,7 +1416,7 @@ static void Fig_ShowInss (MYSQL_RES **mysql_res,unsigned NumInss, unsigned NumOrder; unsigned NumberLastRow; unsigned NumberThisRow; - struct Instit Ins; + struct Ins_Instit Ins; bool TRIsOpen = false; /***** Query database *****/ @@ -1520,7 +1521,7 @@ static void Fig_ShowInss (MYSQL_RES **mysql_res,unsigned NumInss, /******************** Get institution data and statistic *********************/ /*****************************************************************************/ -static unsigned Fig_GetInsAndStat (struct Instit *Ins,MYSQL_RES *mysql_res) +static unsigned Fig_GetInsAndStat (struct Ins_Instit *Ins,MYSQL_RES *mysql_res) { MYSQL_ROW row; unsigned NumberThisRow; @@ -3392,11 +3393,11 @@ static void Fig_GetAndShowTimelineActivityStats (void) extern const char *Txt_Number_of_users; extern const char *Txt_PERCENT_of_users; extern const char *Txt_Number_of_posts_BR_per_user; - extern const char *Txt_TIMELINE_NOTE[TL_NUM_NOTE_TYPES]; + extern const char *Txt_TIMELINE_NOTE[TL_NOT_NUM_NOTE_TYPES]; extern const char *Txt_Total; MYSQL_RES *mysql_res; MYSQL_ROW row; - TL_NoteType_t NoteType; + TL_Not_NoteType_t NoteType; unsigned long NumNotes; unsigned long NumRows; unsigned NumUsrs; @@ -3433,8 +3434,8 @@ static void Fig_GetAndShowTimelineActivityStats (void) 1 << Rol_TCH); /***** Get total number of following/followers from database *****/ - for (NoteType = (TL_NoteType_t) 0; - NoteType <= (TL_NoteType_t) (TL_NUM_NOTE_TYPES - 1); + for (NoteType = (TL_Not_NoteType_t) 0; + NoteType <= (TL_Not_NoteType_t) (TL_NOT_NUM_NOTE_TYPES - 1); NoteType++) { switch (Gbl.Scope.Current) diff --git a/swad_file_browser.c b/swad_file_browser.c index 4532f00e..85517bfb 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -59,6 +59,7 @@ #include "swad_role.h" #include "swad_string.h" #include "swad_timeline.h" +#include "swad_timeline_note.h" #include "swad_zip.h" /*****************************************************************************/ @@ -6846,10 +6847,10 @@ static void Brw_WriteCurrentClipboard (void) extern const char *Txt_folder; extern const char *Txt_link; extern const char *Txt_all_files_inside_the_root_folder; - struct Instit Ins; - struct Centre Ctr; - struct Degree Deg; - struct Course Crs; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; + struct Crs_Course Crs; struct GroupData GrpDat; struct Prj_Project Prj; struct UsrData UsrDat; @@ -7862,10 +7863,10 @@ static void Brw_PasteClipboard (void) extern const char *Txt_Links_copied; extern const char *Txt_Folders_copied; extern const char *Txt_You_can_not_paste_file_or_folder_here; - struct Instit Ins; - struct Centre Ctr; - struct Degree Deg; - struct Course Crs; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; + struct Crs_Course Crs; struct GroupData GrpDat; struct UsrData UsrDat; long PrjCod; @@ -10277,28 +10278,28 @@ void Brw_ChgFileMetadata (void) switch (Gbl.FileBrowser.Type) { case Brw_ADMI_DOC_INS: - TL_StoreAndPublishNote (TL_NOTE_INS_DOC_PUB_FILE,FileMetadata.FilCod); + TL_Not_StoreAndPublishNote (TL_NOTE_INS_DOC_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_SHR_INS: - TL_StoreAndPublishNote (TL_NOTE_INS_SHA_PUB_FILE,FileMetadata.FilCod); + TL_Not_StoreAndPublishNote (TL_NOTE_INS_SHA_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_DOC_CTR: - TL_StoreAndPublishNote (TL_NOTE_CTR_DOC_PUB_FILE,FileMetadata.FilCod); + TL_Not_StoreAndPublishNote (TL_NOTE_CTR_DOC_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_SHR_CTR: - TL_StoreAndPublishNote (TL_NOTE_CTR_SHA_PUB_FILE,FileMetadata.FilCod); + TL_Not_StoreAndPublishNote (TL_NOTE_CTR_SHA_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_DOC_DEG: - TL_StoreAndPublishNote (TL_NOTE_DEG_DOC_PUB_FILE,FileMetadata.FilCod); + TL_Not_StoreAndPublishNote (TL_NOTE_DEG_DOC_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_SHR_DEG: - TL_StoreAndPublishNote (TL_NOTE_DEG_SHA_PUB_FILE,FileMetadata.FilCod); + TL_Not_StoreAndPublishNote (TL_NOTE_DEG_SHA_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_DOC_CRS: - TL_StoreAndPublishNote (TL_NOTE_CRS_DOC_PUB_FILE,FileMetadata.FilCod); + TL_Not_StoreAndPublishNote (TL_NOTE_CRS_DOC_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_SHR_CRS: - TL_StoreAndPublishNote (TL_NOTE_CRS_SHA_PUB_FILE,FileMetadata.FilCod); + TL_Not_StoreAndPublishNote (TL_NOTE_CRS_SHA_PUB_FILE,FileMetadata.FilCod); break; default: break; @@ -11067,9 +11068,9 @@ void Brw_GetCrsGrpFromFileMetadata (Brw_FileBrowser_t FileBrowser,long Cod, long *CrsCod, long *GrpCod) { - struct Centre Ctr; - struct Degree Deg; - struct Course Crs; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; + struct Crs_Course Crs; struct GroupData GrpDat; switch (FileBrowser) @@ -11200,7 +11201,7 @@ static void Brw_RemoveOneFileOrFolderFromDB (const char Path[PATH_MAX + 1]) Set possible social note as unavailable. Important: do this before removing from files *****/ Ntf_MarkNotifOneFileAsRemoved (Path); - TL_MarkNoteOneFileAsUnavailable (Path); + TL_Not_MarkNoteOneFileAsUnavailable (Path); /***** Remove from database the entries that store the marks properties *****/ if (FileBrowser == Brw_ADMI_MRK_CRS || @@ -11244,7 +11245,7 @@ static void Brw_RemoveChildrenOfFolderFromDB (const char Path[PATH_MAX + 1]) Set possible social notes as unavailable. Important: do this before removing from files *****/ Ntf_MarkNotifChildrenOfFolderAsRemoved (Path); - TL_MarkNotesChildrenOfFolderAsUnavailable (Path); + TL_Not_MarkNotesChildrenOfFolderAsUnavailable (Path); /***** Remove from database the entries that store the marks properties *****/ if (FileBrowser == Brw_ADMI_MRK_CRS || @@ -11745,7 +11746,7 @@ void Brw_RemoveGrpZones (long CrsCod,long GrpCod) /***************** Remove the works of a user in a course ********************/ /*****************************************************************************/ -void Brw_RemoveUsrWorksInCrs (struct UsrData *UsrDat,struct Course *Crs) +void Brw_RemoveUsrWorksInCrs (struct UsrData *UsrDat,struct Crs_Course *Crs) { char PathUsrInCrs[PATH_MAX + 1]; @@ -11772,7 +11773,7 @@ void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat) unsigned long NumRows; unsigned long NumRow; unsigned NumCrssWorksRemoved = 0; - struct Course Crs; + struct Crs_Course Crs; /***** Query database *****/ if ((NumRows = Usr_GetCrssFromUsr (UsrDat->UsrCod,-1L,&mysql_res)) > 0) // If courses found diff --git a/swad_file_browser.h b/swad_file_browser.h index a950ce6e..37e3307e 100644 --- a/swad_file_browser.h +++ b/swad_file_browser.h @@ -260,7 +260,7 @@ void Brw_PutImplicitParamsFileBrowser (void *FilFolLnk); void Brw_RemoveZonesOfGroupsOfType (long GrpTypCod); void Brw_RemoveGrpZones (long CrsCod,long GrpCod); -void Brw_RemoveUsrWorksInCrs (struct UsrData *UsrDat,struct Course *Crs); +void Brw_RemoveUsrWorksInCrs (struct UsrData *UsrDat,struct Crs_Course *Crs); void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat); void Brw_GetSummaryAndContentOfFile (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], diff --git a/swad_forum.c b/swad_forum.c index 64cc4115..7d75ab48 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -51,6 +51,7 @@ #include "swad_profile.h" #include "swad_role.h" #include "swad_timeline.h" +#include "swad_timeline_note.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ @@ -303,7 +304,7 @@ static void For_InsertPstIntoBannedPstTable (long PstCod); static long For_InsertForumPst (long ThrCod,long UsrCod, const char *Subject,const char *Content, - struct Media *Media); + struct Med_Media *Media); static bool For_RemoveForumPst (long PstCod,long MedCod); static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod); @@ -337,7 +338,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums, static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC, char Subject[Cns_MAX_BYTES_SUBJECT + 1], char Content[Cns_MAX_BYTES_LONG_TEXT + 1], - struct Media *Media); + struct Med_Media *Media); static void For_WriteNumberOfPosts (const struct For_Forums *Forums,long UsrCod); static void For_PutParamsForum (void *Forums); @@ -553,7 +554,7 @@ static void For_InsertPstIntoBannedPstTable (long PstCod) static long For_InsertForumPst (long ThrCod,long UsrCod, const char *Subject,const char *Content, - struct Media *Media) + struct Med_Media *Media) { long PstCod; @@ -1212,7 +1213,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums, char OriginalContent[Cns_MAX_BYTES_LONG_TEXT + 1]; char Subject[Cns_MAX_BYTES_SUBJECT + 1]; char Content[Cns_MAX_BYTES_LONG_TEXT + 1]; - struct Media Media; + struct Med_Media Media; bool Enabled; /***** Initialize structure with user's data *****/ @@ -1345,7 +1346,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums, static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC, char Subject[Cns_MAX_BYTES_SUBJECT + 1], char Content[Cns_MAX_BYTES_LONG_TEXT + 1], - struct Media *Media) + struct Med_Media *Media) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -2168,10 +2169,10 @@ void For_SetForumName (const struct For_Forum *Forum, extern const char *Txt_only_teachers; extern const char *Txt_only_teachers_NO_HTML[1 + Lan_NUM_LANGUAGES]; extern const char *Txt_Unknown_FORUM; - struct Instit Ins; - struct Centre Ctr; - struct Degree Deg; - struct Course Crs; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; + struct Crs_Course Crs; switch (Forum->Type) { @@ -3933,7 +3934,7 @@ void For_ReceiveForumPost (void) unsigned NumUsrsToBeNotifiedByEMail; char Subject[Cns_MAX_BYTES_SUBJECT + 1]; char Content[Cns_MAX_BYTES_LONG_TEXT + 1]; - struct Media Media; + struct Med_Media Media; /***** Reset forum *****/ For_ResetForums (&Forums); @@ -4021,7 +4022,7 @@ void For_ReceiveForumPost (void) { case For_FORUM_GLOBAL_USRS: case For_FORUM__SWAD__USRS: - TL_StoreAndPublishNote (TL_NOTE_FORUM_POST,PstCod); + TL_Not_StoreAndPublishNote (TL_NOTE_FORUM_POST,PstCod); break; default: break; @@ -4063,7 +4064,7 @@ void For_RemovePost (void) time_t CreatTimeUTC; // Creation time of a message char Subject[Cns_MAX_BYTES_SUBJECT + 1]; char OriginalContent[Cns_MAX_BYTES_LONG_TEXT + 1]; - struct Media Media; + struct Med_Media Media; bool ItsMe; bool ThreadDeleted = false; @@ -4109,7 +4110,7 @@ void For_RemovePost (void) { case For_FORUM_GLOBAL_USRS: case For_FORUM__SWAD__USRS: - TL_MarkNoteAsUnavailable (TL_NOTE_FORUM_POST,Forums.PstCod); + TL_Not_MarkNoteAsUnavailable (TL_NOTE_FORUM_POST,Forums.PstCod); break; default: break; diff --git a/swad_global.h b/swad_global.h index a8732dc2..fff083e1 100644 --- a/swad_global.h +++ b/swad_global.h @@ -192,13 +192,13 @@ struct Globals struct ListCountries Ctys;// List of countries struct Country Cty; // Current country struct ListInstits Inss; // List of institutions in current country - struct Instit Ins; // Current institution + struct Ins_Instit Ins; // Current institution struct ListCentres Ctrs; // List of centres in current institution - struct Centre Ctr; // Current centre + struct Ctr_Centre Ctr; // Current centre struct ListDegrees Degs; // List of degrees in current centre - struct Degree Deg; // Current degree + struct Deg_Degree Deg; // Current degree struct ListCourses Crss; // List of courses in current degree - struct Course Crs; // Current course. Aditional info about course is stored in Gbl.Crs. + struct Crs_Course Crs; // Current course. Aditional info about course is stored in Gbl.Crs. } Hierarchy; struct { diff --git a/swad_hierarchy.c b/swad_hierarchy.c index 0520410f..412af743 100644 --- a/swad_hierarchy.c +++ b/swad_hierarchy.c @@ -659,9 +659,9 @@ void Hie_GetAndWriteInsCtrDegAdminBy (long UsrCod,unsigned ColSpan) MYSQL_ROW row; unsigned NumRow; unsigned NumRows; - struct Instit Ins; - struct Centre Ctr; - struct Degree Deg; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; /***** Get institutions, centres, degrees admin by user from database *****/ NumRows = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions," diff --git a/swad_institution.c b/swad_institution.c index c59b4af5..076cbecb 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -62,7 +62,7 @@ extern struct Globals Gbl; /***************************** Private variables *****************************/ /*****************************************************************************/ -static struct Instit *Ins_EditingIns = NULL; // Static variable to keep the institution being edited +static struct Ins_Instit *Ins_EditingIns = NULL; // Static variable to keep the institution being edited /*****************************************************************************/ /***************************** Private prototypes ****************************/ @@ -72,7 +72,7 @@ static void Ins_ListInstitutions (void); static bool Ins_CheckIfICanCreateInstitutions (void); static void Ins_PutIconsListingInstitutions (__attribute__((unused)) void *Args); static void Ins_PutIconToEditInstitutions (void); -static void Ins_ListOneInstitutionForSeeing (struct Instit *Ins,unsigned NumIns); +static void Ins_ListOneInstitutionForSeeing (struct Ins_Instit *Ins,unsigned NumIns); static void Ins_PutHeadInstitutionsForSeeing (bool OrderSelectable); static void Ins_GetParamInsOrder (void); @@ -80,13 +80,13 @@ static void Ins_EditInstitutionsInternal (void); static void Ins_PutIconsEditingInstitutions (__attribute__((unused)) void *Args); static void Ins_PutIconToViewInstitutions (void); -static void Ins_GetDataOfInstitFromRow (struct Instit *Ins,MYSQL_ROW row); +static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row); -static void Ins_GetShrtNameAndCtyOfInstitution (struct Instit *Ins, +static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins, char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]); static void Ins_ListInstitutionsForEdition (void); -static bool Ins_CheckIfICanEdit (struct Instit *Ins); +static bool Ins_CheckIfICanEdit (struct Ins_Instit *Ins); static Ins_StatusTxt_t Ins_GetStatusTxtFromStatusBits (Ins_Status_t Status); static Ins_Status_t Ins_GetStatusBitsFromStatusTxt (Ins_StatusTxt_t StatusTxt); @@ -106,7 +106,7 @@ static void Ins_CreateInstitution (unsigned Status); static void Ins_EditingInstitutionConstructor (); static void Ins_EditingInstitutionDestructor (); -static void Ins_FormToGoToMap (struct Instit *Ins); +static void Ins_FormToGoToMap (struct Ins_Instit *Ins); /*****************************************************************************/ /***************** List institutions with pending centres ********************/ @@ -123,7 +123,7 @@ void Ins_SeeInsWithPendingCtrs (void) MYSQL_ROW row; unsigned NumInss; unsigned NumIns; - struct Instit Ins; + struct Ins_Instit Ins; const char *BgColor; /***** Get institutions with pending centres *****/ @@ -220,7 +220,7 @@ void Ins_SeeInsWithPendingCtrs (void) /********************** Draw institution logo with link **********************/ /*****************************************************************************/ -void Ins_DrawInstitutionLogoWithLink (struct Instit *Ins,unsigned Size) +void Ins_DrawInstitutionLogoWithLink (struct Ins_Instit *Ins,unsigned Size) { bool PutLink = !Gbl.Form.Inside; // Don't put link to institution if already inside a form @@ -243,7 +243,7 @@ void Ins_DrawInstitutionLogoWithLink (struct Instit *Ins,unsigned Size) /****************** Draw institution logo and name with link *****************/ /*****************************************************************************/ -void Ins_DrawInstitutionLogoAndNameWithLink (struct Instit *Ins,Act_Action_t Action, +void Ins_DrawInstitutionLogoAndNameWithLink (struct Ins_Instit *Ins,Act_Action_t Action, const char *ClassLink,const char *ClassLogo) { /***** Begin form *****/ @@ -380,7 +380,7 @@ static void Ins_PutIconToEditInstitutions (void) /********************** List one institution for seeing **********************/ /*****************************************************************************/ -static void Ins_ListOneInstitutionForSeeing (struct Instit *Ins,unsigned NumIns) +static void Ins_ListOneInstitutionForSeeing (struct Ins_Instit *Ins,unsigned NumIns) { extern const char *Txt_INSTITUTION_STATUS[Ins_NUM_STATUS_TXT]; const char *TxtClassNormal; @@ -623,7 +623,7 @@ void Ins_GetBasicListOfInstitutions (long CtyCod) MYSQL_ROW row; unsigned long NumRows = 0; // Initialized to avoid warning unsigned NumIns; - struct Instit *Ins; + struct Ins_Instit *Ins; /***** Get institutions from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get institutions", @@ -645,8 +645,8 @@ void Ins_GetBasicListOfInstitutions (long CtyCod) Gbl.Hierarchy.Inss.Num = (unsigned) NumRows; /***** Create list with institutions *****/ - if ((Gbl.Hierarchy.Inss.Lst = (struct Instit *) - calloc (NumRows,sizeof (struct Instit))) == NULL) + if ((Gbl.Hierarchy.Inss.Lst = (struct Ins_Instit *) + calloc (NumRows,sizeof (struct Ins_Instit))) == NULL) Lay_NotEnoughMemoryExit (); /***** Get the institutions *****/ @@ -690,7 +690,7 @@ void Ins_GetFullListOfInstitutions (long CtyCod) MYSQL_ROW row; unsigned long NumRows = 0; // Initialized to avoid warning unsigned NumIns; - struct Instit *Ins; + struct Ins_Instit *Ins; /***** Get institutions from database *****/ /* Query database */ @@ -729,8 +729,8 @@ void Ins_GetFullListOfInstitutions (long CtyCod) Gbl.Hierarchy.Inss.Num = (unsigned) NumRows; /***** Create list with institutions *****/ - if ((Gbl.Hierarchy.Inss.Lst = (struct Instit *) - calloc (NumRows,sizeof (struct Instit))) == NULL) + if ((Gbl.Hierarchy.Inss.Lst = (struct Ins_Instit *) + calloc (NumRows,sizeof (struct Ins_Instit))) == NULL) Lay_NotEnoughMemoryExit (); /***** Get the institutions *****/ @@ -767,7 +767,7 @@ void Ins_GetFullListOfInstitutions (long CtyCod) void Ins_WriteInstitutionNameAndCty (long InsCod) { - struct Instit Ins; + struct Ins_Instit Ins; char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]; /***** Get institution short name and country name *****/ @@ -782,7 +782,7 @@ void Ins_WriteInstitutionNameAndCty (long InsCod) /************************* Get data of an institution ************************/ /*****************************************************************************/ -bool Ins_GetDataOfInstitutionByCod (struct Instit *Ins) +bool Ins_GetDataOfInstitutionByCod (struct Ins_Instit *Ins) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -831,7 +831,7 @@ bool Ins_GetDataOfInstitutionByCod (struct Instit *Ins) /********** Get data of a centre from a row resulting of a query *************/ /*****************************************************************************/ -static void Ins_GetDataOfInstitFromRow (struct Instit *Ins,MYSQL_ROW row) +static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row) { /***** Get institution code (row[0]) *****/ if ((Ins->InsCod = Str_ConvertStrCodToLongCod (row[0])) < 0) @@ -870,7 +870,7 @@ void Ins_FlushCacheShortNameOfInstitution (void) Gbl.Cache.InstitutionShrtName.ShrtName[0] = '\0'; } -void Ins_GetShortNameOfInstitution (struct Instit *Ins) +void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -926,7 +926,7 @@ void Ins_FlushCacheFullNameAndCtyOfInstitution (void) Gbl.Cache.InstitutionShrtNameAndCty.CtyName[0] = '\0'; } -static void Ins_GetShrtNameAndCtyOfInstitution (struct Instit *Ins, +static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins, char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]) { extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES]; @@ -1076,7 +1076,7 @@ static void Ins_ListInstitutionsForEdition (void) { extern const char *Txt_INSTITUTION_STATUS[Ins_NUM_STATUS_TXT]; unsigned NumIns; - struct Instit *Ins; + struct Ins_Instit *Ins; char WWW[Cns_MAX_BYTES_WWW + 1]; struct UsrData UsrDat; bool ICanEdit; @@ -1244,7 +1244,7 @@ static void Ins_ListInstitutionsForEdition (void) /************ Check if I can edit, remove, etc. an institution ***************/ /*****************************************************************************/ -static bool Ins_CheckIfICanEdit (struct Instit *Ins) +static bool Ins_CheckIfICanEdit (struct Ins_Instit *Ins) { return (bool) (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM || // I am a superuser ((Ins->Status & Ins_STATUS_BIT_PENDING) != 0 && // Institution is not yet activated @@ -1450,7 +1450,7 @@ void Ins_RenameInsFull (void) /******************** Change the name of an institution **********************/ /*****************************************************************************/ -void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFullName) +void Ins_RenameInstitution (struct Ins_Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFullName) { extern const char *Txt_The_institution_X_already_exists; extern const char *Txt_The_institution_X_has_been_renamed_as_Y; @@ -2123,7 +2123,7 @@ void Ins_ListInssFound (MYSQL_RES **mysql_res,unsigned NumInss) extern const char *Txt_institutions; MYSQL_ROW row; unsigned NumIns; - struct Instit Ins; + struct Ins_Instit Ins; /***** List the institutions (one row per institution) *****/ if (NumInss) @@ -2177,7 +2177,7 @@ static void Ins_EditingInstitutionConstructor (void) Lay_ShowErrorAndExit ("Error initializing institution."); /***** Allocate memory for institution *****/ - if ((Ins_EditingIns = (struct Instit *) malloc (sizeof (struct Instit))) == NULL) + if ((Ins_EditingIns = (struct Ins_Instit *) malloc (sizeof (struct Ins_Instit))) == NULL) Lay_ShowErrorAndExit ("Error allocating memory for institution."); /***** Reset institution *****/ @@ -2202,7 +2202,7 @@ static void Ins_EditingInstitutionDestructor (void) /********************* Form to go to institution map *************************/ /*****************************************************************************/ -static void Ins_FormToGoToMap (struct Instit *Ins) +static void Ins_FormToGoToMap (struct Ins_Instit *Ins) { extern const char *Txt_Map; diff --git a/swad_institution.h b/swad_institution.h index d5c2f673..a4ef6a2a 100644 --- a/swad_institution.h +++ b/swad_institution.h @@ -56,7 +56,7 @@ typedef enum #define Ins_MAX_INSTITS_PER_USR 10 // Used in list of my institutions -struct Instit +struct Ins_Instit { long InsCod; long CtyCod; @@ -83,7 +83,7 @@ typedef enum struct ListInstits { unsigned Num; // Number of institutions - struct Instit *Lst; // List of institutions + struct Ins_Instit *Lst; // List of institutions Ins_Order_t SelectedOrder; // Order of institutions }; @@ -93,8 +93,8 @@ struct ListInstits void Ins_SeeInsWithPendingCtrs (void); -void Ins_DrawInstitutionLogoWithLink (struct Instit *Ins,unsigned Size); -void Ins_DrawInstitutionLogoAndNameWithLink (struct Instit *Ins,Act_Action_t Action, +void Ins_DrawInstitutionLogoWithLink (struct Ins_Instit *Ins,unsigned Size); +void Ins_DrawInstitutionLogoAndNameWithLink (struct Ins_Instit *Ins,Act_Action_t Action, const char *ClassLink,const char *ClassLogo); void Ins_ShowInssOfCurrentCty (void); @@ -103,9 +103,9 @@ void Ins_GetBasicListOfInstitutions (long CtyCod); void Ins_GetFullListOfInstitutions (long CtyCod); void Ins_WriteInstitutionNameAndCty (long InsCod); -bool Ins_GetDataOfInstitutionByCod (struct Instit *Ins); +bool Ins_GetDataOfInstitutionByCod (struct Ins_Instit *Ins); void Ins_FlushCacheShortNameOfInstitution (void); -void Ins_GetShortNameOfInstitution (struct Instit *Ins); +void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins); void Ins_FlushCacheFullNameAndCtyOfInstitution (void); void Ins_FreeListInstitutions (void); @@ -116,7 +116,7 @@ long Ins_GetAndCheckParamOtherInsCod (long MinCodAllowed); void Ins_RemoveInstitution (void); void Ins_RenameInsShort (void); void Ins_RenameInsFull (void); -void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFullName); +void Ins_RenameInstitution (struct Ins_Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFullName); bool Ins_CheckIfInsNameExistsInCty (const char *FieldName, const char *Name, long InsCod, diff --git a/swad_institution_config.c b/swad_institution_config.c index af2b3c48..67809e46 100644 --- a/swad_institution_config.c +++ b/swad_institution_config.c @@ -282,7 +282,7 @@ static void InsCfg_Map (void) unsigned Zoom; unsigned NumCtrs; unsigned NumCtr; - struct Centre Ctr; + struct Ctr_Centre Ctr; /***** Leaflet CSS *****/ Map_LeafletCSS (); diff --git a/swad_layout.c b/swad_layout.c index 562c7437..bca9a7dc 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1711,9 +1711,9 @@ static void Lay_WriteFootFromHTMLFile (void) void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto, long InsCod,long DegCod,long CrsCod) { - struct Instit Ins; - struct Degree Deg; - struct Course Crs; + struct Ins_Instit Ins; + struct Deg_Degree Deg; + struct Crs_Course Crs; /***** Get data of institution *****/ Ins.InsCod = InsCod; diff --git a/swad_log.c b/swad_log.c index dcedff32..3158fe2d 100644 --- a/swad_log.c +++ b/swad_log.c @@ -263,9 +263,9 @@ void Log_GetAndShowLastClicks (void) const char *ClassRow; time_t TimeDiff; struct Country Cty; - struct Instit Ins; - struct Centre Ctr; - struct Degree Deg; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; /***** Get last clicks from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get last clicks", diff --git a/swad_media.c b/swad_media.c index 77f06383..e4878ffa 100644 --- a/swad_media.c +++ b/swad_media.c @@ -120,9 +120,9 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void Med_ResetMediaExceptURLAndTitle (struct Media *Media); -static void Med_FreeMediaURL (struct Media *Media); -static void Med_FreeMediaTitle (struct Media *Media); +static void Med_ResetMediaExceptURLAndTitle (struct Med_Media *Media); +static void Med_FreeMediaURL (struct Med_Media *Media); +static void Med_FreeMediaTitle (struct Med_Media *Media); static void Med_PutIconMediaUploader (const char UniqueId[Frm_MAX_BYTES_ID + 1], struct MediaUploader *MediaUploader); @@ -132,46 +132,46 @@ static void Med_PutHiddenFormTypeMediaUploader (const char UniqueId[Frm_MAX_BYTE static Med_Action_t Med_GetMediaActionFromForm (const char *ParamAction); static Med_FormType_t Usr_GetFormTypeFromForm (struct ParamUploadMedia *ParamUploadMedia); -static void Usr_GetURLFromForm (const char *ParamName,struct Media *Media); -static void Usr_GetTitleFromForm (const char *ParamName,struct Media *Media); +static void Usr_GetURLFromForm (const char *ParamName,struct Med_Media *Media); +static void Usr_GetTitleFromForm (const char *ParamName,struct Med_Media *Media); static void Med_GetAndProcessFileFromForm (const char *ParamFile, - struct Media *Media); -static bool Med_DetectIfAnimated (struct Media *Media, + struct Med_Media *Media); +static bool Med_DetectIfAnimated (struct Med_Media *Media, const char PathFileOrg[PATH_MAX + 1]); -static void Med_ProcessJPG (struct Media *Media, +static void Med_ProcessJPG (struct Med_Media *Media, const char PathFileOrg[PATH_MAX + 1]); -static void Med_ProcessGIF (struct Media *Media, +static void Med_ProcessGIF (struct Med_Media *Media, const char PathFileOrg[PATH_MAX + 1]); -static void Med_ProcessVideo (struct Media *Media, +static void Med_ProcessVideo (struct Med_Media *Media, const char PathFileOrg[PATH_MAX + 1]); -static int Med_ResizeImage (struct Media *Media, +static int Med_ResizeImage (struct Med_Media *Media, const char PathFileOriginal[PATH_MAX + 1], const char PathFileProcessed[PATH_MAX + 1]); static int Med_GetFirstFrame (const char PathFileOriginal[PATH_MAX + 1], const char PathFileProcessed[PATH_MAX + 1]); static void Med_GetAndProcessYouTubeFromForm (const char *ParamURL, - struct Media *Media); + struct Med_Media *Media); static void Med_GetAndProcessEmbedFromForm (const char *ParamURL, - struct Media *Media); + struct Med_Media *Media); -static bool Med_MoveTmpFileToDefDir (struct Media *Media, +static bool Med_MoveTmpFileToDefDir (struct Med_Media *Media, const char PathMedPriv[PATH_MAX + 1], const char *Extension); -static void Med_ShowJPG (const struct Media *Media, +static void Med_ShowJPG (const struct Med_Media *Media, const char PathMedPriv[PATH_MAX + 1], const char *ClassMedia); -static void Med_ShowGIF (const struct Media *Media, +static void Med_ShowGIF (const struct Med_Media *Media, const char PathMedPriv[PATH_MAX + 1], const char *ClassMedia); -static void Med_ShowVideo (const struct Media *Media, +static void Med_ShowVideo (const struct Med_Media *Media, const char PathMedPriv[PATH_MAX + 1], const char *ClassMedia); -static void Med_ShowYoutube (const struct Media *Media,const char *ClassMedia); -static void Med_ShowEmbed (const struct Media *Media,const char *ClassMedia); +static void Med_ShowYoutube (const struct Med_Media *Media,const char *ClassMedia); +static void Med_ShowEmbed (const struct Med_Media *Media,const char *ClassMedia); static void Med_AlertThirdPartyCookies (void); static Med_Type_t Med_GetTypeFromStrInDB (const char *Str); @@ -182,10 +182,10 @@ static const char *Med_GetStringTypeForDB (Med_Type_t Type); /*****************************************************************************/ /********************** Media (image/video) constructor **********************/ /*****************************************************************************/ -// Every struct Media must be initialized with this constructor function after it is declared +// Every struct Med_Media must be initialized with this constructor function after it is declared // Every call to constructor must have a call to destructor -void Med_MediaConstructor (struct Media *Media) +void Med_MediaConstructor (struct Med_Media *Media) { Med_ResetMediaExceptURLAndTitle (Media); Media->URL = NULL; @@ -197,7 +197,7 @@ void Med_MediaConstructor (struct Media *Media) /*****************************************************************************/ // Every call to constructor must have a call to destructor -void Med_MediaDestructor (struct Media *Media) +void Med_MediaDestructor (struct Med_Media *Media) { Med_ResetMedia (Media); } @@ -207,7 +207,7 @@ void Med_MediaDestructor (struct Media *Media) /*****************************************************************************/ // Media must be constructed before calling this function -void Med_ResetMedia (struct Media *Media) +void Med_ResetMedia (struct Med_Media *Media) { Med_ResetMediaExceptURLAndTitle (Media); Med_FreeMediaURL (Media); @@ -218,7 +218,7 @@ void Med_ResetMedia (struct Media *Media) /***************** Reset media fields except URL and title *******************/ /*****************************************************************************/ -static void Med_ResetMediaExceptURLAndTitle (struct Media *Media) +static void Med_ResetMediaExceptURLAndTitle (struct Med_Media *Media) { Media->MedCod = -1L; Media->Action = Med_ACTION_NO_MEDIA; @@ -231,7 +231,7 @@ static void Med_ResetMediaExceptURLAndTitle (struct Media *Media) /******************************* Free image URL ******************************/ /*****************************************************************************/ -static void Med_FreeMediaURL (struct Media *Media) +static void Med_FreeMediaURL (struct Med_Media *Media) { // Media->URL is initialized to NULL in constructor if (Media->URL) @@ -245,7 +245,7 @@ static void Med_FreeMediaURL (struct Media *Media) /****************************** Free image title *****************************/ /*****************************************************************************/ -static void Med_FreeMediaTitle (struct Media *Media) +static void Med_FreeMediaTitle (struct Med_Media *Media) { // Media->Title is initialized to NULL in constructor if (Media->Title) @@ -259,7 +259,7 @@ static void Med_FreeMediaTitle (struct Media *Media) /**** Get media name, title and URL from a query result and copy to struct ***/ /*****************************************************************************/ -void Med_GetMediaDataByCod (struct Media *Media) +void Med_GetMediaDataByCod (struct Med_Media *Media) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -510,8 +510,8 @@ static void Med_PutHiddenFormTypeMediaUploader (const char UniqueId[Frm_MAX_BYTE // If NumMediaInForm < 0, params have no suffix // If NumMediaInForm >= 0, the number is a suffix of the params -void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Media *Media, - void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMediaInForm,struct Media *Media), +void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media, + void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media), const char *SectionForAlerts) { extern const char *Txt_Error_sending_or_processing_image_video; @@ -663,7 +663,7 @@ static Med_FormType_t Usr_GetFormTypeFromForm (struct ParamUploadMedia *ParamUpl /********************* Get from form the type of form ************************/ /*****************************************************************************/ -static void Usr_GetURLFromForm (const char *ParamName,struct Media *Media) +static void Usr_GetURLFromForm (const char *ParamName,struct Med_Media *Media) { char URL[Cns_MAX_BYTES_WWW + 1]; size_t Length; @@ -688,7 +688,7 @@ static void Usr_GetURLFromForm (const char *ParamName,struct Media *Media) /********************* Get from form the type of form ************************/ /*****************************************************************************/ -static void Usr_GetTitleFromForm (const char *ParamName,struct Media *Media) +static void Usr_GetTitleFromForm (const char *ParamName,struct Med_Media *Media) { char Title[Med_MAX_BYTES_TITLE + 1]; size_t Length; @@ -714,7 +714,7 @@ static void Usr_GetTitleFromForm (const char *ParamName,struct Media *Media) /*****************************************************************************/ static void Med_GetAndProcessFileFromForm (const char *ParamFile, - struct Media *Media) + struct Med_Media *Media) { struct Param *Param; char FileNameImgSrc[PATH_MAX + 1]; @@ -803,7 +803,7 @@ static void Med_GetAndProcessFileFromForm (const char *ParamFile, // Return true if animated // Return false if static or error -static bool Med_DetectIfAnimated (struct Media *Media, +static bool Med_DetectIfAnimated (struct Med_Media *Media, const char PathFileOrg[PATH_MAX + 1]) { char PathFileTxtTmp[PATH_MAX + 1]; @@ -845,7 +845,7 @@ static bool Med_DetectIfAnimated (struct Media *Media, /************* Process original image generating processed JPG ***************/ /*****************************************************************************/ -static void Med_ProcessJPG (struct Media *Media, +static void Med_ProcessJPG (struct Med_Media *Media, const char PathFileOrg[PATH_MAX + 1]) { extern const char *Txt_The_file_could_not_be_processed_successfully; @@ -874,7 +874,7 @@ static void Med_ProcessJPG (struct Media *Media, /******* Process original GIF image generating processed PNG and GIF *********/ /*****************************************************************************/ -static void Med_ProcessGIF (struct Media *Media, +static void Med_ProcessGIF (struct Med_Media *Media, const char PathFileOrg[PATH_MAX + 1]) { extern const char *Txt_The_file_could_not_be_processed_successfully; @@ -943,7 +943,7 @@ static void Med_ProcessGIF (struct Media *Media, /*********** Process original MP4 video generating processed MP4 *************/ /*****************************************************************************/ -static void Med_ProcessVideo (struct Media *Media, +static void Med_ProcessVideo (struct Med_Media *Media, const char PathFileOrg[PATH_MAX + 1]) { extern const char *Txt_The_file_could_not_be_processed_successfully; @@ -989,7 +989,7 @@ static void Med_ProcessVideo (struct Media *Media, // Return 0 on success // Return != 0 on error -static int Med_ResizeImage (struct Media *Media, +static int Med_ResizeImage (struct Med_Media *Media, const char PathFileOriginal[PATH_MAX + 1], const char PathFileProcessed[PATH_MAX + 1]) { @@ -1041,7 +1041,7 @@ static int Med_GetFirstFrame (const char PathFileOriginal[PATH_MAX + 1], /*****************************************************************************/ static void Med_GetAndProcessYouTubeFromForm (const char *ParamURL, - struct Media *Media) + struct Med_Media *Media) { extern const char Str_BIN_TO_BASE64URL[64 + 1]; char *PtrHost = NULL; @@ -1206,7 +1206,7 @@ static void Med_GetAndProcessYouTubeFromForm (const char *ParamURL, /*****************************************************************************/ static void Med_GetAndProcessEmbedFromForm (const char *ParamURL, - struct Media *Media) + struct Med_Media *Media) { extern const char Str_BIN_TO_BASE64URL[64 + 1]; char *PtrHost = NULL; @@ -1255,7 +1255,7 @@ static void Med_GetAndProcessEmbedFromForm (const char *ParamURL, /**** Remove media, keep media or store media, depending on media action *****/ /*****************************************************************************/ -void Med_RemoveKeepOrStoreMedia (long CurrentMedCodInDB,struct Media *Media) +void Med_RemoveKeepOrStoreMedia (long CurrentMedCodInDB,struct Med_Media *Media) { switch (Media->Action) { @@ -1299,7 +1299,7 @@ void Med_RemoveKeepOrStoreMedia (long CurrentMedCodInDB,struct Media *Media) /**** Move temporary processed media file to definitive private directory ****/ /*****************************************************************************/ -void Med_MoveMediaToDefinitiveDir (struct Media *Media) +void Med_MoveMediaToDefinitiveDir (struct Med_Media *Media) { char PathMedPriv[PATH_MAX + 1]; @@ -1372,7 +1372,7 @@ void Med_MoveMediaToDefinitiveDir (struct Media *Media) // Return true on success // Return false on error -static bool Med_MoveTmpFileToDefDir (struct Media *Media, +static bool Med_MoveTmpFileToDefDir (struct Med_Media *Media, const char PathMedPriv[PATH_MAX + 1], const char *Extension) { @@ -1403,7 +1403,7 @@ static bool Med_MoveTmpFileToDefDir (struct Media *Media, /************************ Store media into database **************************/ /*****************************************************************************/ -void Med_StoreMediaInDB (struct Media *Media) +void Med_StoreMediaInDB (struct Med_Media *Media) { /***** Insert media into database *****/ Media->MedCod = DB_QueryINSERTandReturnCode ("can not create media", @@ -1422,7 +1422,7 @@ void Med_StoreMediaInDB (struct Media *Media) /****** Show a user uploaded media (in a test question, timeline, etc.) ******/ /*****************************************************************************/ -void Med_ShowMedia (const struct Media *Media, +void Med_ShowMedia (const struct Med_Media *Media, const char *ClassContainer,const char *ClassMedia) { bool PutLink; @@ -1507,7 +1507,7 @@ void Med_ShowMedia (const struct Media *Media, /************************** Show a user uploaded JPG *************************/ /*****************************************************************************/ -static void Med_ShowJPG (const struct Media *Media, +static void Med_ShowJPG (const struct Med_Media *Media, const char PathMedPriv[PATH_MAX + 1], const char *ClassMedia) { @@ -1563,7 +1563,7 @@ static void Med_ShowJPG (const struct Media *Media, /************************** Show a user uploaded GIF *************************/ /*****************************************************************************/ -static void Med_ShowGIF (const struct Media *Media, +static void Med_ShowGIF (const struct Med_Media *Media, const char PathMedPriv[PATH_MAX + 1], const char *ClassMedia) { @@ -1663,7 +1663,7 @@ static void Med_ShowGIF (const struct Media *Media, /************************ Show a user uploaded video *************************/ /*****************************************************************************/ -static void Med_ShowVideo (const struct Media *Media, +static void Med_ShowVideo (const struct Med_Media *Media, const char PathMedPriv[PATH_MAX + 1], const char *ClassMedia) { @@ -1729,7 +1729,7 @@ static void Med_ShowVideo (const struct Media *Media, /*********************** Show an embed YouTube video *************************/ /*****************************************************************************/ -static void Med_ShowYoutube (const struct Media *Media,const char *ClassMedia) +static void Med_ShowYoutube (const struct Med_Media *Media,const char *ClassMedia) { /***** Check if YouTube code exists *****/ if (Media->Name[0]) // YouTube code @@ -1769,7 +1769,7 @@ static void Med_ShowYoutube (const struct Media *Media,const char *ClassMedia) /*************************** Show an embed media *****************************/ /*****************************************************************************/ -static void Med_ShowEmbed (const struct Media *Media,const char *ClassMedia) +static void Med_ShowEmbed (const struct Med_Media *Media,const char *ClassMedia) { /***** Check if embed URL exists *****/ if (Media->URL[0]) // Embed URL @@ -1838,10 +1838,10 @@ static void Med_AlertThirdPartyCookies (void) #define Med_SRC 0 #define Med_DST 1 -long Med_CloneMedia (const struct Media *MediaSrc) +long Med_CloneMedia (const struct Med_Media *MediaSrc) { long MedCod = -1L; - struct Media MediaDst; + struct Med_Media MediaDst; struct { char Path[PATH_MAX + 1]; @@ -1990,7 +1990,7 @@ void Med_RemoveMedia (long MedCod) { char PathMedPriv[PATH_MAX + 1]; char *FullPathMediaPriv; - struct Media Media; + struct Med_Media Media; /***** Trivial case *****/ if (MedCod <= 0) diff --git a/swad_media.h b/swad_media.h index ec36ddc7..8a6f2701 100644 --- a/swad_media.h +++ b/swad_media.h @@ -104,7 +104,7 @@ typedef enum } Med_Type_t; /***** Struct used to get images/videos from forms *****/ -struct Media +struct Med_Media { long MedCod; Med_Action_t Action; @@ -138,26 +138,26 @@ struct ParamUploadMedia /***************************** Public prototypes *****************************/ /*****************************************************************************/ -void Med_MediaConstructor (struct Media *Media); -void Med_MediaDestructor (struct Media *Media); -void Med_ResetMedia (struct Media *Media); +void Med_MediaConstructor (struct Med_Media *Media); +void Med_MediaDestructor (struct Med_Media *Media); +void Med_ResetMedia (struct Med_Media *Media); -void Med_GetMediaDataByCod (struct Media *Media); +void Med_GetMediaDataByCod (struct Med_Media *Media); void Med_PutMediaUploader (int NumMediaInForm,const char *ClassInput); -void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Media *Media, - void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMediaInForm,struct Media *Media), +void Med_GetMediaFromForm (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media, + void (*GetMediaFromDB) (long CrsCod,long QstCod,int NumMediaInForm,struct Med_Media *Media), const char *SectionForAlerts); void Med_SetParamNames (struct ParamUploadMedia *ParamUploadMedia,int NumMediaInForm); -void Med_RemoveKeepOrStoreMedia (long CurrentMedCodInDB,struct Media *Media); -void Med_MoveMediaToDefinitiveDir (struct Media *Media); -void Med_StoreMediaInDB (struct Media *Media); +void Med_RemoveKeepOrStoreMedia (long CurrentMedCodInDB,struct Med_Media *Media); +void Med_MoveMediaToDefinitiveDir (struct Med_Media *Media); +void Med_StoreMediaInDB (struct Med_Media *Media); -void Med_ShowMedia (const struct Media *Media, +void Med_ShowMedia (const struct Med_Media *Media, const char *ClassContainer,const char *ClassMedia); -long Med_CloneMedia (const struct Media *MediaSrc); +long Med_CloneMedia (const struct Med_Media *MediaSrc); void Med_RemoveMediaFromAllRows (unsigned NumMedia,MYSQL_RES *mysql_res); void Med_RemoveMedia (long MedCod); diff --git a/swad_message.c b/swad_message.c index 5c627b6f..886e865d 100644 --- a/swad_message.c +++ b/swad_message.c @@ -145,7 +145,7 @@ static void Msg_ContractSentMsg (long MsgCod); static void Msg_ContractReceivedMsg (long MsgCod); static long Msg_InsertNewMsg (const char *Subject,const char *Content, - struct Media *Media); + struct Med_Media *Media); static unsigned long Msg_DelSomeRecOrSntMsgsUsr (const struct Msg_Messages *Messages, long UsrCod, @@ -166,7 +166,7 @@ static void Msg_GetMsgSntData (long MsgCod,long *CrsCod,long *UsrCod, bool *Deleted); static void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + 1]); static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT + 1], - struct Media *Media); + struct Med_Media *Media); static void Msg_WriteSentOrReceivedMsgSubject (struct Msg_Messages *Messages, long MsgCod,const char *Subject, @@ -760,7 +760,7 @@ void Msg_RecMsgFromUsr (void) bool CreateNotif; bool NotifyByEmail; char Content[Cns_MAX_BYTES_LONG_TEXT + 1]; - struct Media Media; + struct Med_Media Media; bool Error = false; /***** Reset messages context *****/ @@ -1122,7 +1122,7 @@ static void Msg_ShowNumMsgsDeleted (unsigned NumMsgs) static void Msg_GetParamMsgsCrsCod (struct Msg_Messages *Messages) { extern const char *Txt_any_course; - struct Course Crs; + struct Crs_Course Crs; if ((Messages->FilterCrsCod = Par_GetParToLong ("FilterCrsCod")) > 0) // If origin course specified { @@ -1409,7 +1409,7 @@ void Msg_SetReceivedMsgAsOpen (long MsgCod,long UsrCod) // Return the code of the new inserted message static long Msg_InsertNewMsg (const char *Subject,const char *Content, - struct Media *Media) + struct Med_Media *Media) { long MsgCod; @@ -2752,7 +2752,7 @@ static void Msg_GetDistinctCoursesInMyMessages (struct Msg_Messages *Messages) MYSQL_ROW row; unsigned long NumRow; unsigned long NumRows = 0; // Initialized to avoid warning - struct Course Crs; + struct Crs_Course Crs; /***** Get distinct courses in my messages from database *****/ switch (Messages->TypeOfMessages) @@ -3006,7 +3006,7 @@ static void Msg_GetMsgSubject (long MsgCod,char Subject[Cns_MAX_BYTES_SUBJECT + /*****************************************************************************/ static void Msg_GetMsgContent (long MsgCod,char Content[Cns_MAX_BYTES_LONG_TEXT + 1], - struct Media *Media) + struct Med_Media *Media) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -3133,7 +3133,7 @@ static void Msg_ShowASentOrReceivedMessage (struct Msg_Messages *Messages, long CrsCod; char Subject[Cns_MAX_BYTES_SUBJECT + 1]; char Content[Cns_MAX_BYTES_LONG_TEXT + 1]; - struct Media Media; + struct Med_Media Media; bool Deleted; bool Open = true; bool Replied = false; // Initialized to avoid warning @@ -3474,7 +3474,7 @@ static bool Msg_WriteCrsOrgMsg (long CrsCod) { extern const char *Txt_from_this_course; extern const char *Txt_no_course_of_origin; - struct Course Crs; + struct Crs_Course Crs; bool FromThisCrs = true; bool ThereIsOrgCrs = false; diff --git a/swad_notice.c b/swad_notice.c index 5e2d03c4..83cb1f7a 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -43,6 +43,7 @@ #include "swad_parameter.h" #include "swad_RSS.h" #include "swad_timeline.h" +#include "swad_timeline_note.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ @@ -156,7 +157,7 @@ void Not_ReceiveNotice (void) Not_UpdateNumUsrsNotifiedByEMailAboutNotice (NotCod,NumUsrsToBeNotifiedByEMail); /***** Create a new social note about the new notice *****/ - TL_StoreAndPublishNote (TL_NOTE_NOTICE,NotCod); + TL_Not_StoreAndPublishNote (TL_NOTE_NOTICE,NotCod); /***** Set notice to be highlighted *****/ Gbl.Crs.Notices.HighlightNotCod = NotCod; @@ -340,7 +341,7 @@ void Not_RemoveNotice (void) Ntf_MarkNotifAsRemoved (Ntf_EVENT_NOTICE,NotCod); /***** Mark possible social note as unavailable *****/ - TL_MarkNoteAsUnavailable (TL_NOTE_NOTICE,NotCod); + TL_Not_MarkNoteAsUnavailable (TL_NOTE_NOTICE,NotCod); /***** Update RSS of current course *****/ RSS_UpdateRSSFileForACrs (&Gbl.Hierarchy.Crs); diff --git a/swad_notification.c b/swad_notification.c index 26f96a64..fb616564 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -321,10 +321,10 @@ void Ntf_ShowMyNotifications (void) bool AllNotifications; Ntf_NotifyEvent_t NotifyEvent = (Ntf_NotifyEvent_t) 0; // Initialized to avoid warning struct UsrData UsrDat; - struct Instit Ins; - struct Centre Ctr; - struct Degree Deg; - struct Course Crs; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; + struct Crs_Course Crs; long Cod; struct For_Forums Forums; char ForumName[For_MAX_BYTES_FORUM_NAME + 1]; @@ -1584,10 +1584,10 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign Lan_Language_t ToUsrLanguage; struct UsrData FromUsrDat; Ntf_NotifyEvent_t NotifyEvent = (Ntf_NotifyEvent_t) 0; // Initialized to avoid warning - struct Instit Ins; - struct Centre Ctr; - struct Degree Deg; - struct Course Crs; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; + struct Crs_Course Crs; long Cod; struct For_Forum ForumSelected; char ForumName[For_MAX_BYTES_FORUM_NAME + 1]; diff --git a/swad_photo.c b/swad_photo.c index e480d711..8194a2fa 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -133,7 +133,7 @@ static unsigned long Pho_BuildQueryOfDegrees (Pho_HowOrderDegrees_t HowOrderDegr static void Pho_GetNumStdsInDegree (long DegCod,Usr_Sex_t Sex,int *NumStds,int *NumStdsWithPhoto); static void Pho_UpdateDegStats (long DegCod,Usr_Sex_t Sex,unsigned NumStds,unsigned NumStdsWithPhoto,long TimeToComputeAvgPhoto); static void Pho_ShowDegreeStat (int NumStds,int NumStdsWithPhoto); -static void Pho_ShowDegreeAvgPhotoAndStat (const struct Degree *Deg, +static void Pho_ShowDegreeAvgPhotoAndStat (const struct Deg_Degree *Deg, const struct Pho_DegPhotos *DegPhotos, Pho_AvgPhotoSeeOrPrint_t SeeOrPrint, Usr_Sex_t Sex, @@ -2017,7 +2017,7 @@ static void Pho_PutLinkToCalculateDegreeStats (const struct Pho_DegPhotos *DegPh extern const char *Txt_time; struct ListDegrees Degs; unsigned NumDeg; - struct Degree Deg; + struct Deg_Degree Deg; long EstimatedTimeToComputeAvgPhotoInMicroseconds; char StrEstimatedTimeToComputeAvgPhoto[Dat_MAX_BYTES_TIME + 1]; bool Selected; @@ -2144,7 +2144,7 @@ static void Pho_ShowOrPrintClassPhotoDegrees (struct Pho_DegPhotos *DegPhotos, MYSQL_ROW row; unsigned long NumDeg; unsigned long NumDegs; - struct Degree Deg; + struct Deg_Degree Deg; unsigned NumDegsNotEmpty; int NumStds; int NumStdsWithPhoto; @@ -2231,7 +2231,7 @@ static void Pho_ShowOrPrintListDegrees (struct Pho_DegPhotos *DegPhotos, unsigned NumDegsNotEmpty; int NumStds; int NumStdsWithPhoto; - struct Degree Deg; + struct Deg_Degree Deg; Usr_Sex_t Sex; /***** Get degrees from database *****/ @@ -2455,7 +2455,7 @@ static void Pho_ShowDegreeStat (int NumStds,int NumStdsWithPhoto) /******************* Show the average photo of a degree **********************/ /*****************************************************************************/ -static void Pho_ShowDegreeAvgPhotoAndStat (const struct Degree *Deg, +static void Pho_ShowDegreeAvgPhotoAndStat (const struct Deg_Degree *Deg, const struct Pho_DegPhotos *DegPhotos, Pho_AvgPhotoSeeOrPrint_t SeeOrPrint, Usr_Sex_t Sex, diff --git a/swad_record.c b/swad_record.c index c7bd95b0..dc9cd70b 100644 --- a/swad_record.c +++ b/swad_record.c @@ -114,7 +114,7 @@ static void Rec_PutParamsStdTsts (__attribute__((unused)) void *Args); static void Rec_PutParamsWorks (__attribute__((unused)) void *Args); static void Rec_PutParamsStudent (__attribute__((unused)) void *Args); static void Rec_PutParamsMsgUsr (__attribute__((unused)) void *Args); -static void Rec_ShowInstitutionInHead (struct Instit *Ins,bool PutFormLinks); +static void Rec_ShowInstitutionInHead (struct Ins_Instit *Ins,bool PutFormLinks); static void Rec_ShowPhoto (struct UsrData *UsrDat); static void Rec_ShowFullName (struct UsrData *UsrDat); static void Rec_ShowNickname (struct UsrData *UsrDat,bool PutFormLinks); @@ -133,9 +133,9 @@ static void Rec_ShowDateOfBirth (struct UsrData *UsrDat,bool ShowData,bool PutFo static void Rec_ShowPhone (struct UsrData *UsrDat,bool ShowData,bool PutForm, unsigned NumPhone); static void Rec_ShowComments (struct UsrData *UsrDat,bool ShowData,bool PutForm); -static void Rec_ShowTeacherRows (struct UsrData *UsrDat,struct Instit *Ins, +static void Rec_ShowTeacherRows (struct UsrData *UsrDat,struct Ins_Instit *Ins, bool ShowData); -static void Rec_ShowInstitution (struct Instit *Ins,bool ShowData); +static void Rec_ShowInstitution (struct Ins_Instit *Ins,bool ShowData); static void Rec_ShowCentre (struct UsrData *UsrDat,bool ShowData); static void Rec_ShowDepartment (struct UsrData *UsrDat,bool ShowData); static void Rec_ShowOffice (struct UsrData *UsrDat,bool ShowData); @@ -1941,7 +1941,7 @@ void Rec_UpdateCrsRecord (long UsrCod) /************ Remove fields of record of a user in current course ************/ /*****************************************************************************/ -void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Course *Crs) +void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Crs_Course *Crs) { /***** Remove text of the field of record course *****/ DB_QueryDELETE ("can not remove user's record in a course", @@ -2165,7 +2165,7 @@ void Rec_ShowSharedUsrRecord (Rec_SharedRecordViewType_t TypeOfView, bool StudentInCurrentCrs; bool TeacherInCurrentCrs; bool ShowTeacherRows; - struct Instit Ins; + struct Ins_Instit Ins; Act_Action_t NextAction; /***** Initializations *****/ @@ -2676,7 +2676,7 @@ static void Rec_PutParamsMsgUsr (__attribute__((unused)) void *Args) /*********************** Show institution in record card *********************/ /*****************************************************************************/ -static void Rec_ShowInstitutionInHead (struct Instit *Ins,bool PutFormLinks) +static void Rec_ShowInstitutionInHead (struct Ins_Instit *Ins,bool PutFormLinks) { /***** Institution logo *****/ HTM_TD_Begin ("rowspan=\"4\" class=\"REC_C1_TOP CM\""); @@ -3430,7 +3430,7 @@ static void Rec_ShowComments (struct UsrData *UsrDat,bool ShowData,bool PutForm) /************************** Show user's institution **************************/ /*****************************************************************************/ -static void Rec_ShowTeacherRows (struct UsrData *UsrDat,struct Instit *Ins, +static void Rec_ShowTeacherRows (struct UsrData *UsrDat,struct Ins_Instit *Ins, bool ShowData) { /***** Institution *****/ @@ -3453,7 +3453,7 @@ static void Rec_ShowTeacherRows (struct UsrData *UsrDat,struct Instit *Ins, /************************** Show user's institution **************************/ /*****************************************************************************/ -static void Rec_ShowInstitution (struct Instit *Ins,bool ShowData) +static void Rec_ShowInstitution (struct Ins_Instit *Ins,bool ShowData) { extern const char *Txt_Institution; @@ -3487,7 +3487,7 @@ static void Rec_ShowInstitution (struct Instit *Ins,bool ShowData) static void Rec_ShowCentre (struct UsrData *UsrDat,bool ShowData) { extern const char *Txt_Centre; - struct Centre Ctr; + struct Ctr_Centre Ctr; /***** Centre *****/ HTM_TR_Begin (NULL); @@ -4083,7 +4083,7 @@ void Rec_ChgCountryOfMyInstitution (void) void Rec_UpdateMyInstitution (void) { - struct Instit Ins; + struct Ins_Instit Ins; unsigned NumCtrs; unsigned NumDpts; @@ -4121,7 +4121,7 @@ void Rec_UpdateMyInstitution (void) void Rec_UpdateMyCentre (void) { - struct Centre Ctr; + struct Ctr_Centre Ctr; /***** Get my centre *****/ /* Get centre code */ diff --git a/swad_record.h b/swad_record.h index 0394e7c3..dc37bddc 100644 --- a/swad_record.h +++ b/swad_record.h @@ -154,7 +154,7 @@ void Rec_UpdateAndShowOtherCrsRecord (void); unsigned long Rec_GetFieldFromCrsRecord (long UsrCod,long FieldCod,MYSQL_RES **mysql_res); void Rec_GetFieldsCrsRecordFromForm (void); void Rec_UpdateCrsRecord (long UsrCod); -void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Course *Crs); +void Rec_RemoveFieldsCrsRecordInCrs (long UsrCod,struct Crs_Course *Crs); void Rec_RemoveFieldsCrsRecordAll (long UsrCod); void Rec_AllocMemFieldsRecordsCrs (void); void Rec_FreeMemFieldsRecordsCrs (void); diff --git a/swad_report.c b/swad_report.c index b93b8bec..f8f4963a 100644 --- a/swad_report.c +++ b/swad_report.c @@ -539,7 +539,7 @@ static void Rep_WriteSectionUsrInfo (void) extern const char *Txt_Country; extern const char *Txt_Institution; char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]; - struct Instit Ins; + struct Ins_Instit Ins; /***** Start section *****/ fprintf (Gbl.F.Rep,"
" @@ -1160,8 +1160,8 @@ static void Rep_WriteRowCrsData (long CrsCod,Rol_Role_t Role, extern const char *Txt_students_ABBREVIATION; extern const char *Txt_unknown_removed_course; extern const char *Txt_no_course_selected; - struct Course Crs; - struct Degree Deg; + struct Crs_Course Crs; + struct Deg_Degree Deg; /***** Get course data *****/ Crs.CrsCod = CrsCod; diff --git a/swad_statistic.c b/swad_statistic.c index 9daad7c7..9432f906 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -3467,7 +3467,7 @@ static void Sta_ShowNumHitsPerInstitution (Sta_CountType_t CountType, static void Sta_WriteInstit (long InsCod) { - struct Instit Ins; + struct Ins_Instit Ins; /***** Start cell *****/ if (InsCod > 0) // Hit with an institution selected @@ -3560,7 +3560,7 @@ static void Sta_ShowNumHitsPerCentre (Sta_CountType_t CountType, static void Sta_WriteCentre (long CtrCod) { - struct Centre Ctr; + struct Ctr_Centre Ctr; /***** Start cell *****/ if (CtrCod > 0) // Hit with a centre selected @@ -3653,7 +3653,7 @@ static void Sta_ShowNumHitsPerDegree (Sta_CountType_t CountType, static void Sta_WriteDegree (long DegCod) { - struct Degree Deg; + struct Deg_Degree Deg; /***** Start cell *****/ if (DegCod > 0) // Hit with a degree selected @@ -3699,7 +3699,7 @@ static void Sta_ShowNumHitsPerCourse (Sta_CountType_t CountType, struct Sta_Hits Hits; MYSQL_ROW row; bool CrsOK; - struct Course Crs; + struct Crs_Course Crs; /***** Write heading *****/ HTM_TR_Begin (NULL); diff --git a/swad_system_config.c b/swad_system_config.c index 50c0126f..e97284f1 100644 --- a/swad_system_config.c +++ b/swad_system_config.c @@ -229,8 +229,8 @@ static void SysCfg_Map (void) unsigned Zoom; unsigned NumCtrs; unsigned NumCtr; - struct Centre Ctr; - struct Instit Ins; + struct Ctr_Centre Ctr; + struct Ins_Instit Ins; /***** Leaflet CSS *****/ Map_LeafletCSS (); diff --git a/swad_test.c b/swad_test.c index 9c5f83a3..fbc95a76 100644 --- a/swad_test.c +++ b/swad_test.c @@ -124,7 +124,7 @@ static void TstPrn_GetAnswersFromForm (struct TstPrn_Print *Print); static bool Tst_CheckIfNextTstAllowed (void); static unsigned Tst_GetNumExamsGeneratedByMe (void); -static void Tst_PutFormToEditQstMedia (const struct Media *Media,int NumMediaInForm, +static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMediaInForm, bool OptionsDisabled); static void Tst_IncreaseMyNumAccessTst (void); static void Tst_UpdateLastAccTst (unsigned NumQsts); @@ -204,7 +204,7 @@ static void Tst_FreeMediaOfQuestion (struct Tst_Question *Question); static long Tst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt); static void Tst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt, - struct Media *Media); + struct Med_Media *Media); static Tst_AnswerType_t Tst_ConvertFromUnsignedStrToAnsTyp (const char *UnsignedStr); static void Tst_GetQstFromForm (struct Tst_Question *Question); @@ -842,7 +842,7 @@ void Tst_WriteQstStem (const char *Stem,const char *ClassStem,bool Visible) /************* Put form to upload a new image for a test question ************/ /*****************************************************************************/ -static void Tst_PutFormToEditQstMedia (const struct Media *Media,int NumMediaInForm, +static void Tst_PutFormToEditQstMedia (const struct Med_Media *Media,int NumMediaInForm, bool OptionsDisabled) { extern const char *The_ClassFormInBox[The_NUM_THEMES]; @@ -4100,7 +4100,7 @@ static long Tst_GetMedCodFromDB (long CrsCod,long QstCod,int NumOpt) // NumOpt >= 0 ==> media associated to an answer option static void Tst_GetMediaFromDB (long CrsCod,long QstCod,int NumOpt, - struct Media *Media) + struct Med_Media *Media) { /***** Get media *****/ Media->MedCod = Tst_GetMedCodFromDB (CrsCod,QstCod,NumOpt); diff --git a/swad_test_type.h b/swad_test_type.h index c7662033..7c1ba0f6 100644 --- a/swad_test_type.h +++ b/swad_test_type.h @@ -76,7 +76,7 @@ struct Tst_Question time_t EditTime; char *Stem; char *Feedback; - struct Media Media; + struct Med_Media Media; struct { Tst_AnswerType_t Type; @@ -88,7 +88,7 @@ struct Tst_Question bool Correct; char *Text; char *Feedback; - struct Media Media; + struct Med_Media Media; } Options[Tst_MAX_OPTIONS_PER_QUESTION]; long Integer; double FloatingPoint[2]; diff --git a/swad_text.c b/swad_text.c index 7e9e0837..5802a77d 100644 --- a/swad_text.c +++ b/swad_text.c @@ -92,6 +92,7 @@ #include "swad_test.h" #include "swad_test_visibility.h" #include "swad_timeline.h" +#include "swad_timeline_note.h" #include "swad_timetable.h" #include "swad_user.h" @@ -52546,7 +52547,7 @@ const char *Txt_Timeline_OF_A_USER = // Warning: it is very important to include #endif -const char *Txt_TIMELINE_NOTE[TL_NUM_NOTE_TYPES] = +const char *Txt_TIMELINE_NOTE[TL_NOT_NUM_NOTE_TYPES] = { [TL_NOTE_UNKNOWN] = #if L==1 // ca diff --git a/swad_timeline.c b/swad_timeline.c index 4a6d4674..7f2d0c4d 100644 --- a/swad_timeline.c +++ b/swad_timeline.c @@ -46,6 +46,7 @@ #include "swad_setting.h" #include "swad_timeline.h" #include "swad_timeline_favourite.h" +#include "swad_timeline_note.h" #include "swad_timeline_share.h" /*****************************************************************************/ @@ -62,23 +63,10 @@ #define TL_MAX_NEW_PUBS_TO_GET_AND_SHOW 100 // New publishings retrieved #define TL_MAX_OLD_PUBS_TO_GET_AND_SHOW 20 // Old publishings are retrieved in packs of this size -#define TL_NUM_VISIBLE_COMMENTS 3 // Maximum number of comments visible before expanding them - #define TL_MAX_CHARS_IN_POST 1000 // Maximum number of characters in a post #define TL_MAX_BYTES_SUBQUERY (128 - 1) -/* - Timeline images will be saved with: - · maximum width of TL_IMAGE_SAVED_MAX_HEIGHT - · maximum height of TL_IMAGE_SAVED_MAX_HEIGHT - · maintaining the original aspect ratio (aspect ratio recommended: 3:2) -*/ -#define TL_IMAGE_SAVED_MAX_WIDTH 768 -#define TL_IMAGE_SAVED_MAX_HEIGHT 768 -#define TL_IMAGE_SAVED_QUALITY 90 // 1 to 100 -// in timeline posts, the quality should not be high in order to speed up the loading of images - /* mysql> SHOW TABLES LIKE 'tl_%'; +-----------------------+ @@ -176,6 +164,7 @@ mysql> SHOW TABLES LIKE 'tl_%'; |______________| */ + struct TL_SubQueries { char *TablePublishers; @@ -191,18 +180,6 @@ struct TL_RangePubsToGet long Bottom; }; -typedef enum - { - TL_DONT_HIGHLIGHT_NOTE, - TL_HIGHLIGHT_NOTE, - } TL_HighlightNote_t; - -typedef enum - { - TL_DONT_SHOW_NOTE_ALONE, - TL_SHOW_NOTE_ALONE, - } TL_ShowNoteAlone_t; - /*****************************************************************************/ /************** External global variables from others modules ****************/ /*****************************************************************************/ @@ -221,16 +198,6 @@ Usr_Who_t TL_GlobalWho; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void TL_InitTimelineGbl (struct TL_Timeline *Timeline); -static void TL_ShowHighlightedNote (struct TL_Timeline *Timeline, - struct TL_Note *Not); -static void TL_ShowNoteAndTimelineGbl (struct TL_Timeline *Timeline); - -static void TL_ShowTimelineGblHighlightingNot (struct TL_Timeline *Timeline, - long NotCod); -static void TL_ShowTimelineUsrHighlightingNot (struct TL_Timeline *Timeline, - long NotCod); - static void TL_GetAndShowOldTimeline (struct TL_Timeline *Timeline); static void TL_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline); @@ -253,20 +220,14 @@ static void TL_AllocateListPubs (struct TL_Timeline *Timeline, static void TL_FreeListPubs (const struct TL_Timeline *Timeline); static void TL_SelectTheMostRecentPub (const struct TL_SubQueries *SubQueries, struct TL_Publication *Pub); -static void TL_InsertNoteInJustRetrievedNotes (long NotCod); -static void TL_InsertNoteInVisibleTimeline (long NotCod); static void TL_ShowTimeline (struct TL_Timeline *Timeline, const char *Title,long NotCodToHighlight); static void TL_PutIconsTimeline (__attribute__((unused)) void *Args); -static void TL_FormStart (const struct TL_Timeline *Timeline, - Act_Action_t ActionGbl, - Act_Action_t ActionUsr); - static void TL_PutFormWho (struct TL_Timeline *Timeline); static Usr_Who_t TL_GetWhoFromDB (void); -static void Set_GlobalWho (Usr_Who_t Who); +static void TL_SetGlobalWho (Usr_Who_t Who); static void TL_SaveWhoInDB (struct TL_Timeline *Timeline); @@ -278,98 +239,25 @@ static void TL_ShowOldPubsInTimeline (struct TL_Timeline *Timeline); static void TL_PutLinkToViewNewPublications (void); static void TL_PutLinkToViewOldPublications (void); -static void TL_WriteNote (struct TL_Timeline *Timeline, - const struct TL_Note *Not, - TL_TopMessage_t TopMessage, - long PublisherCod, // Who did the action (publication, commenting, faving, sharing, mentioning) - TL_HighlightNote_t HighlightNote, // Highlight note - TL_ShowNoteAlone_t ShowNoteAlone); // Note is shown alone, not in a list -static void TL_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod); -static void TL_WriteAuthorNote (const struct UsrData *UsrDat); -static void TL_WriteDateTime (time_t TimeUTC); -static void TL_GetAndWritePost (long PstCod); -static void TL_PutFormGoToAction (const struct TL_Note *Not, - const struct For_Forums *Forums); -static void TL_GetNoteSummary (const struct TL_Note *Not, - char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]); -static void TL_StoreAndPublishNoteInternal (TL_NoteType_t NoteType,long Cod,struct TL_Publication *Pub); - static void TL_PutFormToWriteNewPost (struct TL_Timeline *Timeline); -static void TL_PutTextarea (const char *Placeholder,const char *ClassTextArea); static long TL_ReceivePost (void); -static void TL_PutIconToToggleCommentNote (const char UniqueId[Frm_MAX_BYTES_ID + 1]); -static void TL_PutIconCommentDisabled (void); -static void TL_PutHiddenFormToWriteNewCommentToNote (const struct TL_Timeline *Timeline, - long NotCod, - const char IdNewComment[Frm_MAX_BYTES_ID + 1]); -static unsigned long TL_GetNumCommentsInNote (long NotCod); -static void TL_WriteCommentsInNote (struct TL_Timeline *Timeline, - const struct TL_Note *Not, - unsigned NumComments); -static void TL_FormToShowHiddenComments (Act_Action_t ActionGbl,Act_Action_t ActionUsr, - long NotCod, - char IdComments[Frm_MAX_BYTES_ID + 1], - unsigned NumInitialComments); -static unsigned TL_WriteHiddenComments (struct TL_Timeline *Timeline, - long NotCod, - char IdComments[Frm_MAX_BYTES_ID + 1], - unsigned NumInitialCommentsToGet); -static void TL_WriteOneCommentInList (struct TL_Timeline *Timeline, - MYSQL_RES *mysql_res); -static void TL_LinkToShowOnlyLatestComments (const char IdComments[Frm_MAX_BYTES_ID + 1]); -static void TL_LinkToShowPreviousComments (const char IdComments[Frm_MAX_BYTES_ID + 1], - unsigned NumInitialComments); -static void TL_PutIconToToggleComments (const char *UniqueId, - const char *Icon,const char *Text); -static void TL_WriteComment (struct TL_Timeline *Timeline, - struct TL_Comment *Com, - TL_TopMessage_t TopMessage,long UsrCod, - bool ShowCommentAlone); // Comment is shown alone, not in a list -static void TL_WriteAuthorComment (struct UsrData *UsrDat); - -static void TL_PutFormToRemoveComment (const struct TL_Timeline *Timeline, - long PubCod); - -static void TL_PutFormToRemovePublication (const struct TL_Timeline *Timeline, - long NotCod); - -static void TL_PutHiddenParamNotCod (long NotCod); - -static long TL_ReceiveComment (void); - -static void TL_RequestRemovalNote (struct TL_Timeline *Timeline); -static void TL_PutParamsRemoveNote (void *Timeline); -static void TL_RemoveNote (void); -static void TL_RemoveNoteMediaAndDBEntries (struct TL_Note *Not); - -static long TL_GetNotCodFromPubCod (long PubCod); - -static void TL_RequestRemovalComment (struct TL_Timeline *Timeline); -static void TL_PutParamsRemoveComment (void *Timeline); -static void TL_RemoveComment (void); -static void TL_RemoveCommentMediaAndDBEntries (long PubCod); +static long TL_Pub_GetNotCodFromPubCod (long PubCod); static void TL_GetDataOfPublicationFromNextRow (MYSQL_RES *mysql_res, struct TL_Publication *Pub); -static void TL_GetDataOfNoteFromRow (MYSQL_ROW row,struct TL_Note *Not); static TL_PubType_t TL_GetPubTypeFromStr (const char *Str); -static TL_NoteType_t TL_GetNoteTypeFromStr (const char *Str); -static void TL_GetDataOfCommentFromRow (MYSQL_ROW row,struct TL_Comment *Com); -static void TL_ResetPublication (struct TL_Publication *Pub); -static void TL_ResetNote (struct TL_Note *Not); -static void TL_ResetComment (struct TL_Comment *Com); +static void TL_Pub_ResetPublication (struct TL_Publication *Pub); static void TL_ClearTimelineThisSession (void); -static void TL_AddNotesJustRetrievedToTimelineThisSession (void); /*****************************************************************************/ /************************ Initialize global timeline *************************/ /*****************************************************************************/ -static void TL_InitTimelineGbl (struct TL_Timeline *Timeline) +void TL_InitTimelineGbl (struct TL_Timeline *Timeline) { /***** Reset timeline context *****/ TL_ResetTimeline (Timeline); @@ -418,10 +306,10 @@ void TL_ShowTimelineGbl (void) /**************** Show highlighted note and global timeline ******************/ /*****************************************************************************/ -static void TL_ShowNoteAndTimelineGbl (struct TL_Timeline *Timeline) +void TL_ShowNoteAndTimelineGbl (struct TL_Timeline *Timeline) { long PubCod; - struct TL_Note Not; + struct TL_Not_Note Not; /***** Initialize note code to -1 ==> no highlighted note *****/ Not.NotCod = -1L; @@ -433,86 +321,23 @@ static void TL_ShowNoteAndTimelineGbl (struct TL_Timeline *Timeline) /***** If a note should be highlighted ==> get code of note from database *****/ if (PubCod > 0) - Not.NotCod = TL_GetNotCodFromPubCod (PubCod); + Not.NotCod = TL_Pub_GetNotCodFromPubCod (PubCod); /***** If a note should be highlighted ==> show it above the timeline *****/ if (Not.NotCod > 0) /***** Show the note highlighted above the timeline *****/ - TL_ShowHighlightedNote (Timeline,&Not); + TL_Not_ShowHighlightedNote (Timeline,&Not); /***** Show timeline with possible highlighted note *****/ TL_ShowTimelineGblHighlightingNot (Timeline,Not.NotCod); } -/*****************************************************************************/ -/****************** Show highlighted note above timeline *********************/ -/*****************************************************************************/ - -static void TL_ShowHighlightedNote (struct TL_Timeline *Timeline, - struct TL_Note *Not) - { - struct UsrData PublisherDat; - Ntf_NotifyEvent_t NotifyEvent; - static const TL_TopMessage_t TopMessages[Ntf_NUM_NOTIFY_EVENTS] = - { - [Ntf_EVENT_UNKNOWN ] = TL_TOP_MESSAGE_NONE, - /* Start tab */ - [Ntf_EVENT_TIMELINE_COMMENT ] = TL_TOP_MESSAGE_COMMENTED, - [Ntf_EVENT_TIMELINE_FAV ] = TL_TOP_MESSAGE_FAVED, - [Ntf_EVENT_TIMELINE_SHARE ] = TL_TOP_MESSAGE_SHARED, - [Ntf_EVENT_TIMELINE_MENTION ] = TL_TOP_MESSAGE_MENTIONED, - [Ntf_EVENT_FOLLOWER ] = TL_TOP_MESSAGE_NONE, - /* System tab */ - /* Country tab */ - /* Institution tab */ - /* Centre tab */ - /* Degree tab */ - /* Course tab */ - /* Assessment tab */ - [Ntf_EVENT_ASSIGNMENT ] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_SURVEY ] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_EXAM_ANNOUNCEMENT] = TL_TOP_MESSAGE_NONE, - /* Files tab */ - [Ntf_EVENT_DOCUMENT_FILE ] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_TEACHERS_FILE ] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_SHARED_FILE ] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_MARKS_FILE ] = TL_TOP_MESSAGE_NONE, - /* Users tab */ - [Ntf_EVENT_ENROLMENT_STD ] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_ENROLMENT_NET ] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_ENROLMENT_TCH ] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_ENROLMENT_REQUEST] = TL_TOP_MESSAGE_NONE, - /* Messages tab */ - [Ntf_EVENT_NOTICE ] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_FORUM_POST_COURSE] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_FORUM_REPLY ] = TL_TOP_MESSAGE_NONE, - [Ntf_EVENT_MESSAGE ] = TL_TOP_MESSAGE_NONE, - /* Analytics tab */ - /* Profile tab */ - }; - - /***** Get other parameters *****/ - /* Get the publisher who did the action - (publishing, commenting, faving, sharing, mentioning) */ - Usr_GetParamOtherUsrCodEncrypted (&PublisherDat); - - /* Get what he/she did */ - NotifyEvent = Ntf_GetParamNotifyEvent (); - - /***** Show the note highlighted *****/ - TL_GetDataOfNoteByCod (Not); - TL_WriteNote (Timeline,Not, - TopMessages[NotifyEvent],PublisherDat.UsrCod, - TL_HIGHLIGHT_NOTE, - TL_SHOW_NOTE_ALONE); - } - /*****************************************************************************/ /******************* Show global timeline highlighting a note ****************/ /*****************************************************************************/ -static void TL_ShowTimelineGblHighlightingNot (struct TL_Timeline *Timeline, - long NotCod) +void TL_ShowTimelineGblHighlightingNot (struct TL_Timeline *Timeline, + long NotCod) { extern const char *Txt_Timeline; @@ -541,8 +366,8 @@ void TL_ShowTimelineUsr (struct TL_Timeline *Timeline) /************ Show timeline of a selected user highlighting a note ***********/ /*****************************************************************************/ -static void TL_ShowTimelineUsrHighlightingNot (struct TL_Timeline *Timeline, - long NotCod) +void TL_ShowTimelineUsrHighlightingNot (struct TL_Timeline *Timeline, + long NotCod) { extern const char *Txt_Timeline_OF_A_USER; @@ -758,9 +583,9 @@ static void TL_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline) /* Insert note in temporary tables with just retrieved notes. These tables will be used to not get notes already shown */ - TL_InsertNoteInJustRetrievedNotes (Timeline->Pubs.Lst[NumPub].NotCod); + TL_Not_InsertNoteInJustRetrievedNotes (Timeline->Pubs.Lst[NumPub].NotCod); if (Timeline->WhatToGet == TL_GET_ONLY_OLD_PUBS) - TL_InsertNoteInVisibleTimeline (Timeline->Pubs.Lst[NumPub].NotCod); + TL_Not_InsertNoteInVisibleTimeline (Timeline->Pubs.Lst[NumPub].NotCod); RangePubsToGet.Top = Timeline->Pubs.Lst[NumPub].PubCod; // Narrow the range for the next iteration } @@ -771,7 +596,7 @@ static void TL_GetListPubsToShowInTimeline (struct TL_Timeline *Timeline) TL_UpdateFirstLastPubCodesIntoSession (Timeline); /***** Add notes just retrieved to current timeline for this session *****/ - TL_AddNotesJustRetrievedToTimelineThisSession (); + TL_Not_AddNotesJustRetrievedToTimelineThisSession (); /***** Drop temporary tables *****/ TL_DropTmpTablesUsedToQueryTimeline (); @@ -1071,36 +896,12 @@ static void TL_SelectTheMostRecentPub (const struct TL_SubQueries *SubQueries, TL_GetDataOfPublicationFromNextRow (mysql_res,Pub); else /* Reset data of publication */ - TL_ResetPublication (Pub); + TL_Pub_ResetPublication (Pub); /***** Free structure that stores the query result *****/ DB_FreeMySQLResult (&mysql_res); } -/*****************************************************************************/ -/**** Insert note in temporary tables used to not get notes already shown ****/ -/*****************************************************************************/ - -static void TL_InsertNoteInJustRetrievedNotes (long NotCod) - { - /* Insert note in temporary table with just retrieved notes. - This table will be used to not get notes already shown */ - DB_QueryINSERT ("can not store note code", - "INSERT IGNORE INTO tl_tmp_just_retrieved_notes" - " SET NotCod=%ld", - NotCod); - } - -static void TL_InsertNoteInVisibleTimeline (long NotCod) - { - /* Insert note in temporary table with visible timeline. - This table will be used to not get notes already shown */ - DB_QueryINSERT ("can not store note code", - "INSERT IGNORE INTO tl_tmp_visible_timeline" - " SET NotCod=%ld", - NotCod); - } - /*****************************************************************************/ /******************************* Show timeline *******************************/ /*****************************************************************************/ @@ -1138,7 +939,7 @@ static void TL_ShowTimeline (struct TL_Timeline *Timeline, { extern const char *Hlp_START_Timeline; unsigned long NumPub; - struct TL_Note Not; + struct TL_Not_Note Not; bool GlobalTimeline = (Gbl.Usrs.Other.UsrDat.UsrCod <= 0); bool ItsMe = Usr_ItsMe (Gbl.Usrs.Other.UsrDat.UsrCod); @@ -1178,15 +979,15 @@ static void TL_ShowTimeline (struct TL_Timeline *Timeline, { /* Get data of note */ Not.NotCod = Timeline->Pubs.Lst[NumPub].NotCod; - TL_GetDataOfNoteByCod (&Not); + TL_Not_GetDataOfNoteByCod (&Not); /* Write note */ - TL_WriteNote (Timeline,&Not, - Timeline->Pubs.Lst[NumPub].TopMessage, - Timeline->Pubs.Lst[NumPub].PublisherCod, - Not.NotCod == NotCodToHighlight ? TL_HIGHLIGHT_NOTE : - TL_DONT_HIGHLIGHT_NOTE, - TL_DONT_SHOW_NOTE_ALONE); + TL_Not_WriteNote (Timeline,&Not, + Timeline->Pubs.Lst[NumPub].TopMessage, + Timeline->Pubs.Lst[NumPub].PublisherCod, + Not.NotCod == NotCodToHighlight ? TL_HIGHLIGHT : + TL_DONT_HIGHLIGHT, + TL_DONT_SHOW_ALONE); } HTM_UL_End (); @@ -1218,9 +1019,9 @@ static void TL_PutIconsTimeline (__attribute__((unused)) void *Args) /***************** Start a form in global or user timeline *******************/ /*****************************************************************************/ -static void TL_FormStart (const struct TL_Timeline *Timeline, - Act_Action_t ActionGbl, - Act_Action_t ActionUsr) +void TL_FormStart (const struct TL_Timeline *Timeline, + Act_Action_t ActionGbl, + Act_Action_t ActionUsr) { if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) { @@ -1290,7 +1091,7 @@ void TL_GetParamWho (void) Who = TL_DEFAULT_WHO; /***** Set global variable *****/ - Set_GlobalWho (Who); + TL_SetGlobalWho (Who); } /*****************************************************************************/ @@ -1349,7 +1150,7 @@ static void TL_SaveWhoInDB (struct TL_Timeline *Timeline) /**** Set/get global variable with which users to view in global timeline ****/ /*****************************************************************************/ -static void Set_GlobalWho (Usr_Who_t Who) +static void TL_SetGlobalWho (Usr_Who_t Who) { TL_GlobalWho = Who; } @@ -1391,7 +1192,7 @@ static void TL_ShowWarningYouDontFollowAnyUser (void) static void TL_InsertNewPubsInTimeline (struct TL_Timeline *Timeline) { unsigned long NumPub; - struct TL_Note Not; + struct TL_Not_Note Not; /***** List new publications timeline *****/ for (NumPub = 0; @@ -1400,14 +1201,14 @@ static void TL_InsertNewPubsInTimeline (struct TL_Timeline *Timeline) { /* Get data of note */ Not.NotCod = Timeline->Pubs.Lst[NumPub].NotCod; - TL_GetDataOfNoteByCod (&Not); + TL_Not_GetDataOfNoteByCod (&Not); /* Write note */ - TL_WriteNote (Timeline,&Not, + TL_Not_WriteNote (Timeline,&Not, Timeline->Pubs.Lst[NumPub].TopMessage, Timeline->Pubs.Lst[NumPub].PublisherCod, - TL_DONT_HIGHLIGHT_NOTE, - TL_DONT_SHOW_NOTE_ALONE); + TL_DONT_HIGHLIGHT, + TL_DONT_SHOW_ALONE); } } @@ -1419,7 +1220,7 @@ static void TL_InsertNewPubsInTimeline (struct TL_Timeline *Timeline) static void TL_ShowOldPubsInTimeline (struct TL_Timeline *Timeline) { unsigned long NumPub; - struct TL_Note Not; + struct TL_Not_Note Not; /***** List old publications in timeline *****/ for (NumPub = 0; @@ -1428,14 +1229,14 @@ static void TL_ShowOldPubsInTimeline (struct TL_Timeline *Timeline) { /* Get data of note */ Not.NotCod = Timeline->Pubs.Lst[NumPub].NotCod; - TL_GetDataOfNoteByCod (&Not); + TL_Not_GetDataOfNoteByCod (&Not); /* Write note */ - TL_WriteNote (Timeline,&Not, + TL_Not_WriteNote (Timeline,&Not, Timeline->Pubs.Lst[NumPub].TopMessage, Timeline->Pubs.Lst[NumPub].PublisherCod, - TL_DONT_HIGHLIGHT_NOTE, - TL_DONT_SHOW_NOTE_ALONE); + TL_DONT_HIGHLIGHT, + TL_DONT_SHOW_ALONE); } } @@ -1494,274 +1295,11 @@ static void TL_PutLinkToViewOldPublications (void) HTM_DIV_End (); } -/*****************************************************************************/ -/******************************** Write note *********************************/ -/*****************************************************************************/ - -static void TL_WriteNote (struct TL_Timeline *Timeline, - const struct TL_Note *Not, - TL_TopMessage_t TopMessage, - long PublisherCod, // Who did the action (publication, commenting, faving, sharing, mentioning) - TL_HighlightNote_t HighlightNote, // Highlight note - TL_ShowNoteAlone_t ShowNoteAlone) // Note is shown alone, not in a list - { - extern const char *Txt_Forum; - extern const char *Txt_Course; - extern const char *Txt_Degree; - extern const char *Txt_Centre; - extern const char *Txt_Institution; - struct UsrData AuthorDat; - bool IAmTheAuthor; - struct Instit Ins; - struct Centre Ctr; - struct Degree Deg; - struct Course Crs; - bool ShowPhoto = false; - char PhotoURL[PATH_MAX + 1]; - struct For_Forums Forums; - char ForumName[For_MAX_BYTES_FORUM_NAME + 1]; - char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]; - unsigned NumComments; - char IdNewComment[Frm_MAX_BYTES_ID + 1]; - static unsigned NumDiv = 0; // Used to create unique div id for fav and shared - - NumDiv++; - - /***** Begin box ****/ - if (ShowNoteAlone == TL_SHOW_NOTE_ALONE) - { - Box_BoxBegin (NULL,NULL, - NULL,NULL, - NULL,Box_CLOSABLE); - HTM_UL_Begin ("class=\"TL_LIST\""); - } - - /***** Start list item *****/ - HTM_LI_Begin ("class=\"%s\"", - ShowNoteAlone == TL_SHOW_NOTE_ALONE ? - (HighlightNote == TL_HIGHLIGHT_NOTE ? "TL_WIDTH TL_NEW_PUB" : - "TL_WIDTH") : - (HighlightNote == TL_HIGHLIGHT_NOTE ? "TL_WIDTH TL_SEP TL_NEW_PUB" : - "TL_WIDTH TL_SEP")); - - if (Not->NotCod <= 0 || - Not->NoteType == TL_NOTE_UNKNOWN || - Not->UsrCod <= 0) - Ale_ShowAlert (Ale_ERROR,"Error in note."); - else - { - /***** Initialize location in hierarchy *****/ - Ins.InsCod = -1L; - Ctr.CtrCod = -1L; - Deg.DegCod = -1L; - Crs.CrsCod = -1L; - - /***** Write sharer/commenter if distinct to author *****/ - TL_WriteTopMessage (TopMessage,PublisherCod); - - /***** Initialize structure with user's data *****/ - Usr_UsrDataConstructor (&AuthorDat); - - /***** Get author data *****/ - AuthorDat.UsrCod = Not->UsrCod; - Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&AuthorDat,Usr_DONT_GET_PREFS); - IAmTheAuthor = Usr_ItsMe (AuthorDat.UsrCod); - - /***** Left: write author's photo *****/ - HTM_DIV_Begin ("class=\"TL_LEFT_PHOTO\""); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&AuthorDat,PhotoURL); - Pho_ShowUsrPhoto (&AuthorDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO45x60",Pho_ZOOM,true); // Use unique id - HTM_DIV_End (); - - /***** Right: author's name, time, summary and buttons *****/ - /* Begin right container */ - HTM_DIV_Begin ("class=\"TL_RIGHT_CONT TL_RIGHT_WIDTH\""); - - /* Write author's full name and date-time */ - TL_WriteAuthorNote (&AuthorDat); - TL_WriteDateTime (Not->DateTimeUTC); - - /* Write content of the note */ - if (Not->NoteType == TL_NOTE_POST) - /* Write post content */ - TL_GetAndWritePost (Not->Cod); - else - { - /* Reset forums */ - For_ResetForums (&Forums); - - /* Get location in hierarchy */ - if (!Not->Unavailable) - switch (Not->NoteType) - { - case TL_NOTE_INS_DOC_PUB_FILE: - case TL_NOTE_INS_SHA_PUB_FILE: - /* Get institution data */ - Ins.InsCod = Not->HieCod; - Ins_GetDataOfInstitutionByCod (&Ins); - break; - case TL_NOTE_CTR_DOC_PUB_FILE: - case TL_NOTE_CTR_SHA_PUB_FILE: - /* Get centre data */ - Ctr.CtrCod = Not->HieCod; - Ctr_GetDataOfCentreByCod (&Ctr); - break; - case TL_NOTE_DEG_DOC_PUB_FILE: - case TL_NOTE_DEG_SHA_PUB_FILE: - /* Get degree data */ - Deg.DegCod = Not->HieCod; - Deg_GetDataOfDegreeByCod (&Deg); - break; - case TL_NOTE_CRS_DOC_PUB_FILE: - case TL_NOTE_CRS_SHA_PUB_FILE: - case TL_NOTE_EXAM_ANNOUNCEMENT: - case TL_NOTE_NOTICE: - /* Get course data */ - Crs.CrsCod = Not->HieCod; - Crs_GetDataOfCourseByCod (&Crs); - break; - case TL_NOTE_FORUM_POST: - /* Get forum type of the post */ - For_GetForumTypeAndLocationOfAPost (Not->Cod,&Forums.Forum); - For_SetForumName (&Forums.Forum,ForumName,Gbl.Prefs.Language,false); // Set forum name in recipient's language - break; - default: - break; - } - - /* Write note type */ - TL_PutFormGoToAction (Not,&Forums); - - /* Write location in hierarchy */ - if (!Not->Unavailable) - switch (Not->NoteType) - { - case TL_NOTE_INS_DOC_PUB_FILE: - case TL_NOTE_INS_SHA_PUB_FILE: - /* Write location (institution) in hierarchy */ - HTM_DIV_Begin ("class=\"TL_LOC\""); - HTM_TxtF ("%s: %s",Txt_Institution,Ins.ShrtName); - HTM_DIV_End (); - break; - case TL_NOTE_CTR_DOC_PUB_FILE: - case TL_NOTE_CTR_SHA_PUB_FILE: - /* Write location (centre) in hierarchy */ - HTM_DIV_Begin ("class=\"TL_LOC\""); - HTM_TxtF ("%s: %s",Txt_Centre,Ctr.ShrtName); - HTM_DIV_End (); - break; - case TL_NOTE_DEG_DOC_PUB_FILE: - case TL_NOTE_DEG_SHA_PUB_FILE: - /* Write location (degree) in hierarchy */ - HTM_DIV_Begin ("class=\"TL_LOC\""); - HTM_TxtF ("%s: %s",Txt_Degree,Deg.ShrtName); - HTM_DIV_End (); - break; - case TL_NOTE_CRS_DOC_PUB_FILE: - case TL_NOTE_CRS_SHA_PUB_FILE: - case TL_NOTE_EXAM_ANNOUNCEMENT: - case TL_NOTE_NOTICE: - /* Write location (course) in hierarchy */ - HTM_DIV_Begin ("class=\"TL_LOC\""); - HTM_TxtF ("%s: %s",Txt_Course,Crs.ShrtName); - HTM_DIV_End (); - break; - case TL_NOTE_FORUM_POST: - /* Write forum name */ - HTM_DIV_Begin ("class=\"TL_LOC\""); - HTM_TxtF ("%s: %s",Txt_Forum,ForumName); - HTM_DIV_End (); - break; - default: - break; - } - - /* Write note summary */ - TL_GetNoteSummary (Not,SummaryStr); - HTM_DIV_Begin ("class=\"TL_TXT\""); - HTM_Txt (SummaryStr); - HTM_DIV_End (); - } - - /* End right container */ - HTM_DIV_End (); - - /***** Buttons and comments *****/ - /* Create unique id for new comment */ - Frm_SetUniqueId (IdNewComment); - - /* Get number of comments in this note */ - NumComments = TL_GetNumCommentsInNote (Not->NotCod); - - /* Put icon to add a comment */ - HTM_DIV_Begin ("class=\"TL_BOTTOM_LEFT\""); - if (Not->Unavailable) // Unavailable notes can not be commented - TL_PutIconCommentDisabled (); - else - TL_PutIconToToggleCommentNote (IdNewComment); - HTM_DIV_End (); - - /* Start container for buttons and comments */ - HTM_DIV_Begin ("class=\"TL_BOTTOM_RIGHT TL_RIGHT_WIDTH\""); - - /* Start foot container */ - HTM_DIV_Begin ("class=\"TL_FOOT TL_RIGHT_WIDTH\""); - - /* Foot column 1: Fav zone */ - HTM_DIV_Begin ("id=\"fav_not_%s_%u\" class=\"TL_FAV_NOT TL_FAV_NOT_WIDTH\"", - Gbl.UniqueNameEncrypted,NumDiv); - TL_Fav_PutFormToFavUnfNote (Not,TL_SHOW_FEW_USRS); - HTM_DIV_End (); - - /* Foot column 2: Share zone */ - HTM_DIV_Begin ("id=\"sha_not_%s_%u\" class=\"TL_SHA_NOT TL_SHA_NOT_WIDTH\"", - Gbl.UniqueNameEncrypted,NumDiv); - TL_Sha_PutFormToShaUnsNote (Not,TL_SHOW_FEW_USRS); - HTM_DIV_End (); - - /* Foot column 3: Icon to remove this note */ - HTM_DIV_Begin ("class=\"TL_REM\""); - if (IAmTheAuthor) - TL_PutFormToRemovePublication (Timeline, - Not->NotCod); - HTM_DIV_End (); - - /* End foot container */ - HTM_DIV_End (); - - /* Comments */ - if (NumComments) - TL_WriteCommentsInNote (Timeline,Not,NumComments); - - /* End container for buttons and comments */ - HTM_DIV_End (); - - /* Put hidden form to write a new comment */ - TL_PutHiddenFormToWriteNewCommentToNote (Timeline, - Not->NotCod,IdNewComment); - - /***** Free memory used for author's data *****/ - Usr_UsrDataDestructor (&AuthorDat); - } - - /***** End list item *****/ - HTM_LI_End (); - - /***** End box ****/ - if (ShowNoteAlone == TL_SHOW_NOTE_ALONE) - { - HTM_UL_End (); - Box_BoxEnd (); - } - } - /*****************************************************************************/ /*************** Write sharer/commenter if distinct to author ****************/ /*****************************************************************************/ -static void TL_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod) +void TL_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod) { extern const char *Txt_My_public_profile; extern const char *Txt_Another_user_s_profile; @@ -1801,34 +1339,12 @@ static void TL_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod) } } -/*****************************************************************************/ -/*************** Write name and nickname of author of a note *****************/ -/*****************************************************************************/ - -static void TL_WriteAuthorNote (const struct UsrData *UsrDat) - { - extern const char *Txt_My_public_profile; - extern const char *Txt_Another_user_s_profile; - bool ItsMe = Usr_ItsMe (UsrDat->UsrCod); - - /***** Show user's name inside form to go to user's public profile *****/ - Frm_StartFormUnique (ActSeeOthPubPrf); - Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); - HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile : - Txt_Another_user_s_profile, - "BT_LINK TL_RIGHT_AUTHOR TL_RIGHT_AUTHOR_WIDTH DAT_N_BOLD", - NULL); - HTM_Txt (UsrDat->FullName); - HTM_BUTTON_End (); - Frm_EndForm (); - } - /*****************************************************************************/ /******************* Write the date of creation of a note ********************/ /*****************************************************************************/ // TimeUTC holds UTC date and time in UNIX format (seconds since 1970) -static void TL_WriteDateTime (time_t TimeUTC) +void TL_WriteDateTime (time_t TimeUTC) { char IdDateTime[Frm_MAX_BYTES_ID + 1]; @@ -1851,7 +1367,7 @@ static void TL_WriteDateTime (time_t TimeUTC) /***************** Get from database and write public post *******************/ /*****************************************************************************/ -static void TL_GetAndWritePost (long PstCod) +void TL_GetAndWritePost (long PstCod) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1906,414 +1422,15 @@ static void TL_GetAndWritePost (long PstCod) } /*****************************************************************************/ -/************* Put form to go to an action depending on the note *************/ -/*****************************************************************************/ - -static void TL_PutFormGoToAction (const struct TL_Note *Not, - const struct For_Forums *Forums) - { - extern const Act_Action_t For_ActionsSeeFor[For_NUM_TYPES_FORUM]; - extern const char *The_ClassFormInBoxBold[The_NUM_THEMES]; - extern const char *Txt_TIMELINE_NOTE[TL_NUM_NOTE_TYPES]; - extern const char *Txt_not_available; - char *Anchor = NULL; - static const Act_Action_t TL_DefaultActions[TL_NUM_NOTE_TYPES] = - { - [TL_NOTE_UNKNOWN ] = ActUnk, - /* Start tab */ - [TL_NOTE_POST ] = ActUnk, // action not used - /* Institution tab */ - [TL_NOTE_INS_DOC_PUB_FILE ] = ActReqDatSeeDocIns, - [TL_NOTE_INS_SHA_PUB_FILE ] = ActReqDatShaIns, - /* Centre tab */ - [TL_NOTE_CTR_DOC_PUB_FILE ] = ActReqDatSeeDocCtr, - [TL_NOTE_CTR_SHA_PUB_FILE ] = ActReqDatShaCtr, - /* Degree tab */ - [TL_NOTE_DEG_DOC_PUB_FILE ] = ActReqDatSeeDocDeg, - [TL_NOTE_DEG_SHA_PUB_FILE ] = ActReqDatShaDeg, - /* Course tab */ - [TL_NOTE_CRS_DOC_PUB_FILE ] = ActReqDatSeeDocCrs, - [TL_NOTE_CRS_SHA_PUB_FILE ] = ActReqDatShaCrs, - /* Assessment tab */ - [TL_NOTE_EXAM_ANNOUNCEMENT] = ActSeeOneExaAnn, - /* Users tab */ - /* Messages tab */ - [TL_NOTE_NOTICE ] = ActSeeOneNot, - [TL_NOTE_FORUM_POST ] = ActSeeFor, - /* Analytics tab */ - /* Profile tab */ - }; - static const char *TL_Icons[TL_NUM_NOTE_TYPES] = - { - [TL_NOTE_UNKNOWN ] = NULL, - /* Start tab */ - [TL_NOTE_POST ] = NULL, // icon not used - /* Institution tab */ - [TL_NOTE_INS_DOC_PUB_FILE ] = "file.svg", - [TL_NOTE_INS_SHA_PUB_FILE ] = "file.svg", - /* Centre tab */ - [TL_NOTE_CTR_DOC_PUB_FILE ] = "file.svg", - [TL_NOTE_CTR_SHA_PUB_FILE ] = "file.svg", - /* Degree tab */ - [TL_NOTE_DEG_DOC_PUB_FILE ] = "file.svg", - [TL_NOTE_DEG_SHA_PUB_FILE ] = "file.svg", - /* Course tab */ - [TL_NOTE_CRS_DOC_PUB_FILE ] = "file.svg", - [TL_NOTE_CRS_SHA_PUB_FILE ] = "file.svg", - /* Assessment tab */ - [TL_NOTE_EXAM_ANNOUNCEMENT] = "bullhorn.svg", - /* Users tab */ - /* Messages tab */ - [TL_NOTE_NOTICE ] = "sticky-note.svg", - [TL_NOTE_FORUM_POST ] = "comments.svg", - /* Analytics tab */ - /* Profile tab */ - }; - - if (Not->Unavailable || // File/notice... pointed by this note is unavailable - Gbl.Form.Inside) // Inside another form - { - /***** Do not put form *****/ - HTM_DIV_Begin ("class=\"TL_FORM_OFF\""); - HTM_Txt (Txt_TIMELINE_NOTE[Not->NoteType]); - if (Not->Unavailable) - HTM_TxtF (" (%s)",Txt_not_available); - HTM_DIV_End (); - } - else // Not inside another form - { - HTM_DIV_Begin ("class=\"TL_FORM\""); - - /***** Begin form with parameters depending on the type of note *****/ - switch (Not->NoteType) - { - case TL_NOTE_INS_DOC_PUB_FILE: - case TL_NOTE_INS_SHA_PUB_FILE: - Frm_StartFormUnique (TL_DefaultActions[Not->NoteType]); - Brw_PutHiddenParamFilCod (Not->Cod); - if (Not->HieCod != Gbl.Hierarchy.Ins.InsCod) // Not the current institution - Ins_PutParamInsCod (Not->HieCod); // Go to another institution - break; - case TL_NOTE_CTR_DOC_PUB_FILE: - case TL_NOTE_CTR_SHA_PUB_FILE: - Frm_StartFormUnique (TL_DefaultActions[Not->NoteType]); - Brw_PutHiddenParamFilCod (Not->Cod); - if (Not->HieCod != Gbl.Hierarchy.Ctr.CtrCod) // Not the current centre - Ctr_PutParamCtrCod (Not->HieCod); // Go to another centre - break; - case TL_NOTE_DEG_DOC_PUB_FILE: - case TL_NOTE_DEG_SHA_PUB_FILE: - Frm_StartFormUnique (TL_DefaultActions[Not->NoteType]); - Brw_PutHiddenParamFilCod (Not->Cod); - if (Not->HieCod != Gbl.Hierarchy.Deg.DegCod) // Not the current degree - Deg_PutParamDegCod (Not->HieCod); // Go to another degree - break; - case TL_NOTE_CRS_DOC_PUB_FILE: - case TL_NOTE_CRS_SHA_PUB_FILE: - Frm_StartFormUnique (TL_DefaultActions[Not->NoteType]); - Brw_PutHiddenParamFilCod (Not->Cod); - if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course - Crs_PutParamCrsCod (Not->HieCod); // Go to another course - break; - case TL_NOTE_EXAM_ANNOUNCEMENT: - Frm_SetAnchorStr (Not->Cod,&Anchor); - Frm_StartFormUniqueAnchor (TL_DefaultActions[Not->NoteType], - Anchor); // Locate on this specific exam - Frm_FreeAnchorStr (Anchor); - ExaAnn_PutHiddenParamExaCod (Not->Cod); - if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course - Crs_PutParamCrsCod (Not->HieCod); // Go to another course - break; - case TL_NOTE_POST: // Not applicable - return; - case TL_NOTE_FORUM_POST: - Frm_StartFormUnique (For_ActionsSeeFor[Forums->Forum.Type]); - For_PutAllHiddenParamsForum (1, // Page of threads = first - 1, // Page of posts = first - Forums->ForumSet, - Forums->ThreadsOrder, - Forums->Forum.Location, - Forums->Thread.Selected, - -1L); - if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course - Crs_PutParamCrsCod (Not->HieCod); // Go to another course - break; - case TL_NOTE_NOTICE: - Frm_SetAnchorStr (Not->Cod,&Anchor); - Frm_StartFormUniqueAnchor (TL_DefaultActions[Not->NoteType], - Anchor); - Frm_FreeAnchorStr (Anchor); - Not_PutHiddenParamNotCod (Not->Cod); - if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course - Crs_PutParamCrsCod (Not->HieCod); // Go to another course - break; - default: // Not applicable - return; - } - - /***** Icon and link to go to action *****/ - HTM_BUTTON_SUBMIT_Begin (Txt_TIMELINE_NOTE[Not->NoteType], - Str_BuildStringStr ("BT_LINK %s ICO_HIGHLIGHT", - The_ClassFormInBoxBold[Gbl.Prefs.Theme]), - NULL); - Ico_PutIcon (TL_Icons[Not->NoteType],Txt_TIMELINE_NOTE[Not->NoteType],"CONTEXT_ICO_x16"); - HTM_TxtF (" %s",Txt_TIMELINE_NOTE[Not->NoteType]); - HTM_BUTTON_End (); - Str_FreeString (); - - /***** End form *****/ - Frm_EndForm (); - - HTM_DIV_End (); - } - } - -/*****************************************************************************/ -/********************** Get note summary and content *************************/ -/*****************************************************************************/ - -static void TL_GetNoteSummary (const struct TL_Note *Not, - char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]) - { - SummaryStr[0] = '\0'; - - switch (Not->NoteType) - { - case TL_NOTE_UNKNOWN: - break; - case TL_NOTE_INS_DOC_PUB_FILE: - case TL_NOTE_INS_SHA_PUB_FILE: - case TL_NOTE_CTR_DOC_PUB_FILE: - case TL_NOTE_CTR_SHA_PUB_FILE: - case TL_NOTE_DEG_DOC_PUB_FILE: - case TL_NOTE_DEG_SHA_PUB_FILE: - case TL_NOTE_CRS_DOC_PUB_FILE: - case TL_NOTE_CRS_SHA_PUB_FILE: - Brw_GetSummaryAndContentOfFile (SummaryStr,NULL,Not->Cod,false); - break; - case TL_NOTE_EXAM_ANNOUNCEMENT: - ExaAnn_GetSummaryAndContentExamAnn (SummaryStr,NULL,Not->Cod,false); - break; - case TL_NOTE_POST: - // Not applicable - break; - case TL_NOTE_FORUM_POST: - For_GetSummaryAndContentForumPst (SummaryStr,NULL,Not->Cod,false); - break; - case TL_NOTE_NOTICE: - Not_GetSummaryAndContentNotice (SummaryStr,NULL,Not->Cod,false); - break; - } - } - -/*****************************************************************************/ -/***************** Store and publish a note into database ********************/ -/*****************************************************************************/ - -void TL_StoreAndPublishNote (TL_NoteType_t NoteType,long Cod) - { - struct TL_Publication Pub; - - TL_StoreAndPublishNoteInternal (NoteType,Cod,&Pub); - } - -static void TL_StoreAndPublishNoteInternal (TL_NoteType_t NoteType,long Cod,struct TL_Publication *Pub) - { - long HieCod; // Hierarchy code (institution/centre/degree/course) - - switch (NoteType) - { - case TL_NOTE_INS_DOC_PUB_FILE: - case TL_NOTE_INS_SHA_PUB_FILE: - HieCod = Gbl.Hierarchy.Ins.InsCod; - break; - case TL_NOTE_CTR_DOC_PUB_FILE: - case TL_NOTE_CTR_SHA_PUB_FILE: - HieCod = Gbl.Hierarchy.Ctr.CtrCod; - break; - case TL_NOTE_DEG_DOC_PUB_FILE: - case TL_NOTE_DEG_SHA_PUB_FILE: - HieCod = Gbl.Hierarchy.Deg.DegCod; - break; - case TL_NOTE_CRS_DOC_PUB_FILE: - case TL_NOTE_CRS_SHA_PUB_FILE: - case TL_NOTE_EXAM_ANNOUNCEMENT: - case TL_NOTE_NOTICE: - HieCod = Gbl.Hierarchy.Crs.CrsCod; - break; - default: - HieCod = -1L; - break; - } - - /***** Store note *****/ - Pub->NotCod = - DB_QueryINSERTandReturnCode ("can not create new note", - "INSERT INTO tl_notes" - " (NoteType,Cod,UsrCod,HieCod,Unavailable,TimeNote)" - " VALUES" - " (%u,%ld,%ld,%ld,'N',NOW())", - (unsigned) NoteType, - Cod,Gbl.Usrs.Me.UsrDat.UsrCod,HieCod); - - /***** Publish note in timeline *****/ - Pub->PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod; - Pub->PubType = TL_PUB_ORIGINAL_NOTE; - TL_PublishNoteInTimeline (Pub); - } - -/*****************************************************************************/ -/************************* Mark a note as unavailable ************************/ -/*****************************************************************************/ - -void TL_MarkNoteAsUnavailable (TL_NoteType_t NoteType,long Cod) - { - /***** Mark the note as unavailable *****/ - DB_QueryUPDATE ("can not mark note as unavailable", - "UPDATE tl_notes SET Unavailable='Y'" - " WHERE NoteType=%u AND Cod=%ld", - (unsigned) NoteType,Cod); - } - -/*****************************************************************************/ -/****************** Mark notes of one file as unavailable ********************/ -/*****************************************************************************/ - -void TL_MarkNoteOneFileAsUnavailable (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; - TL_NoteType_t NoteType; - - switch (FileBrowser) - { - case Brw_ADMI_DOC_INS: - case Brw_ADMI_SHR_INS: - case Brw_ADMI_DOC_CTR: - case Brw_ADMI_SHR_CTR: - case Brw_ADMI_DOC_DEG: - case Brw_ADMI_SHR_DEG: - case Brw_ADMI_DOC_CRS: - case Brw_ADMI_SHR_CRS: - /***** Get file code *****/ - FilCod = Brw_GetFilCodByPath (Path,true); // Only if file is public - if (FilCod > 0) - { - /***** Mark possible note as unavailable *****/ - switch (FileBrowser) - { - case Brw_ADMI_DOC_INS: - NoteType = TL_NOTE_INS_DOC_PUB_FILE; - break; - case Brw_ADMI_SHR_INS: - NoteType = TL_NOTE_INS_SHA_PUB_FILE; - break; - case Brw_ADMI_DOC_CTR: - NoteType = TL_NOTE_CTR_DOC_PUB_FILE; - break; - case Brw_ADMI_SHR_CTR: - NoteType = TL_NOTE_CTR_SHA_PUB_FILE; - break; - case Brw_ADMI_DOC_DEG: - NoteType = TL_NOTE_DEG_DOC_PUB_FILE; - break; - case Brw_ADMI_SHR_DEG: - NoteType = TL_NOTE_DEG_SHA_PUB_FILE; - break; - case Brw_ADMI_DOC_CRS: - NoteType = TL_NOTE_CRS_DOC_PUB_FILE; - break; - case Brw_ADMI_SHR_CRS: - NoteType = TL_NOTE_CRS_SHA_PUB_FILE; - break; - default: - return; - } - TL_MarkNoteAsUnavailable (NoteType,FilCod); - } - break; - default: - break; - } - } - -/*****************************************************************************/ -/***** Mark possible notes involving children of a folder as unavailable *****/ -/*****************************************************************************/ - -void TL_MarkNotesChildrenOfFolderAsUnavailable (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 (); - TL_NoteType_t NoteType; - - switch (FileBrowser) - { - case Brw_ADMI_DOC_INS: - case Brw_ADMI_SHR_INS: - case Brw_ADMI_DOC_CTR: - case Brw_ADMI_SHR_CTR: - case Brw_ADMI_DOC_DEG: - case Brw_ADMI_SHR_DEG: - case Brw_ADMI_DOC_CRS: - case Brw_ADMI_SHR_CRS: - /***** Mark possible note as unavailable *****/ - switch (FileBrowser) - { - case Brw_ADMI_DOC_INS: - NoteType = TL_NOTE_INS_DOC_PUB_FILE; - break; - case Brw_ADMI_SHR_INS: - NoteType = TL_NOTE_INS_SHA_PUB_FILE; - break; - case Brw_ADMI_DOC_CTR: - NoteType = TL_NOTE_CTR_DOC_PUB_FILE; - break; - case Brw_ADMI_SHR_CTR: - NoteType = TL_NOTE_CTR_SHA_PUB_FILE; - break; - case Brw_ADMI_DOC_DEG: - NoteType = TL_NOTE_DEG_DOC_PUB_FILE; - break; - case Brw_ADMI_SHR_DEG: - NoteType = TL_NOTE_DEG_SHA_PUB_FILE; - break; - case Brw_ADMI_DOC_CRS: - NoteType = TL_NOTE_CRS_DOC_PUB_FILE; - break; - case Brw_ADMI_SHR_CRS: - NoteType = TL_NOTE_CRS_SHA_PUB_FILE; - break; - default: - return; - } - DB_QueryUPDATE ("can not mark notes as unavailable", - "UPDATE tl_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); - break; - default: - break; - } - } - -/*****************************************************************************/ -/************************* Publish note in timeline **************************/ +/********************* Publish note/comment in timeline **********************/ /*****************************************************************************/ // Pub->PubCod is set by the function -void TL_PublishNoteInTimeline (struct TL_Publication *Pub) +void TL_PublishPubInTimeline (struct TL_Publication *Pub) { /***** Publish note in timeline *****/ Pub->PubCod = - DB_QueryINSERTandReturnCode ("can not publish note", + DB_QueryINSERTandReturnCode ("can not publish note/comment", "INSERT INTO tl_pubs" " (NotCod,PublisherCod,PubType,TimePublish)" " VALUES" @@ -2352,7 +1469,7 @@ static void TL_PutFormToWriteNewPost (struct TL_Timeline *Timeline) HTM_DIV_Begin ("class=\"TL_RIGHT_CONT TL_RIGHT_WIDTH\""); /* Author name */ - TL_WriteAuthorNote (&Gbl.Usrs.Me.UsrDat); + TL_Not_WriteAuthorNote (&Gbl.Usrs.Me.UsrDat); /* Form to write the post */ HTM_DIV_Begin ("class=\"TL_FORM_NEW_PST TL_RIGHT_WIDTH\""); @@ -2372,7 +1489,7 @@ static void TL_PutFormToWriteNewPost (struct TL_Timeline *Timeline) /*** Put textarea and button inside a form to submit a new post or comment ***/ /*****************************************************************************/ -static void TL_PutTextarea (const char *Placeholder,const char *ClassTextArea) +void TL_PutTextarea (const char *Placeholder,const char *ClassTextArea) { extern const char *Txt_Post; char IdDivImgButton[Frm_MAX_BYTES_ID + 1]; @@ -2491,7 +1608,7 @@ static long TL_ReceivePost (void) Content.Media.MedCod); /* Insert post in notes */ - TL_StoreAndPublishNoteInternal (TL_NOTE_POST,PstCod,&Pub); + TL_Not_StoreAndPublishNoteInternal (TL_NOTE_POST,PstCod,&Pub); /***** Analyze content and store notifications about mentions *****/ Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (Pub.PubCod,Content.Txt); @@ -2505,643 +1622,6 @@ static long TL_ReceivePost (void) return Pub.NotCod; } -/*****************************************************************************/ -/********* Put an icon to toggle on/off the form to comment a note ***********/ -/*****************************************************************************/ - -static void TL_PutIconToToggleCommentNote (const char UniqueId[Frm_MAX_BYTES_ID + 1]) - { - extern const char *Txt_Comment; - - /***** Link to toggle on/off the form to comment a note *****/ - HTM_DIV_Begin ("id=\"%s_ico\" class=\"TL_ICO_COM_OFF\"",UniqueId); - HTM_A_Begin ("href=\"\" onclick=\"toggleNewComment ('%s');return false;\"", - UniqueId); - Ico_PutIcon ("comment-regular.svg",Txt_Comment,"CONTEXT_ICO_16x16"); - HTM_A_End (); - HTM_DIV_End (); - } - -/*****************************************************************************/ -/********** Put an icon to toggle on/off the form to comment a note **********/ -/*****************************************************************************/ - -static void TL_PutIconCommentDisabled (void) - { - extern const char *Txt_Comment; - - /***** Disabled icon to comment a note *****/ - HTM_DIV_Begin ("class=\"TL_ICO_COM_OFF TL_ICO_DISABLED\""); - Ico_PutIcon ("edit.svg",Txt_Comment,"ICO16x16"); - HTM_DIV_End (); - } - -/*****************************************************************************/ -/********************** Form to comment a publication ************************/ -/*****************************************************************************/ - -static void TL_PutHiddenFormToWriteNewCommentToNote (const struct TL_Timeline *Timeline, - long NotCod, - const char IdNewComment[Frm_MAX_BYTES_ID + 1]) - { - extern const char *Txt_New_TIMELINE_comment; - bool ShowPhoto = false; - char PhotoURL[PATH_MAX + 1]; - - /***** Start container *****/ - HTM_DIV_Begin ("id=\"%s\" class=\"TL_FORM_NEW_COM TL_RIGHT_WIDTH\"" - " style=\"display:none;\"", - IdNewComment); - - /***** Left: write author's photo (my photo) *****/ - HTM_DIV_Begin ("class=\"TL_COM_PHOTO\""); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Me.UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&Gbl.Usrs.Me.UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO30x40",Pho_ZOOM,true); // Use unique id - HTM_DIV_End (); - - /***** Right: form to write the comment *****/ - /* Start right container */ - HTM_DIV_Begin ("class=\"TL_COM_CONT TL_COMM_WIDTH\""); - - /* Begin form to write the post */ - TL_FormStart (Timeline,ActRcvTL_ComGbl,ActRcvTL_ComUsr); - TL_PutHiddenParamNotCod (NotCod); - - /* Textarea and button */ - TL_PutTextarea (Txt_New_TIMELINE_comment, - "TL_COM_TEXTAREA TL_COMM_WIDTH"); - - /* End form */ - Frm_EndForm (); - - /* End right container */ - HTM_DIV_End (); - - /***** End container *****/ - HTM_DIV_End (); - } - -/*****************************************************************************/ -/********************* Get number of comments in a note **********************/ -/*****************************************************************************/ - -static unsigned long TL_GetNumCommentsInNote (long NotCod) - { - return DB_QueryCOUNT ("can not get number of comments in a note", - "SELECT COUNT(*) FROM tl_pubs" - " WHERE NotCod=%ld AND PubType=%u", - NotCod,(unsigned) TL_PUB_COMMENT_TO_NOTE); - } - -/*****************************************************************************/ -/*********************** Write comments in a note ****************************/ -/*****************************************************************************/ - -static void TL_WriteCommentsInNote (struct TL_Timeline *Timeline, - const struct TL_Note *Not, - unsigned NumComments) - { - MYSQL_RES *mysql_res; - unsigned NumInitialComments; - unsigned NumFinalCommentsToGet; - unsigned NumFinalCommentsGot; - unsigned NumCom; - char IdComments[Frm_MAX_BYTES_ID + 1]; - - /***** Compute how many initial comments will be hidden - and how many final comments will be visible *****/ - // Never hide only one comment - // So, the number of comments initially hidden must be 0 or >= 2 - if (NumComments <= TL_NUM_VISIBLE_COMMENTS + 1) - { - NumInitialComments = 0; - NumFinalCommentsToGet = NumComments; - } - else - { - NumInitialComments = NumComments - TL_NUM_VISIBLE_COMMENTS; - NumFinalCommentsToGet = TL_NUM_VISIBLE_COMMENTS; - } - - /***** Get last comments of this note from database *****/ - NumFinalCommentsGot = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get comments", - "SELECT * FROM " - "(" - "SELECT tl_pubs.PubCod," // row[0] - "tl_pubs.PublisherCod," // row[1] - "tl_pubs.NotCod," // row[2] - "UNIX_TIMESTAMP(" - "tl_pubs.TimePublish)," // row[3] - "tl_comments.Txt," // row[4] - "tl_comments.MedCod" // row[5] - " FROM tl_pubs,tl_comments" - " WHERE tl_pubs.NotCod=%ld" - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments.PubCod" - " ORDER BY tl_pubs.PubCod DESC LIMIT %u" - ") AS comments" - " ORDER BY PubCod", - Not->NotCod,(unsigned) TL_PUB_COMMENT_TO_NOTE, - NumFinalCommentsToGet); - - /* - Before clicking "See prev..." --> After clicking "See prev..." - _________________________________ _________________________________ - | div con_ | | div con_ | - | (hidden) | | (visible) | - | _____________________________ | | _____________________________ | - | | v See only the latest | | | | v See only the latest | | - | |_____________________________| | | |_____________________________| | - |_________________________________| |_________________________________| - _________________________________ _________________________________ - | div | | div updated | - | which content | | _____________________________ | - | will be updated via AJAX | | | ul com_ | | - | (parent of parent of form) | | | _________________________ | | - | | | | | li (comment 1) | | | - | | | | |_________________________| | | - | | | | | ... | | | - | | | | |_________________________| | | - | | | | | li (comment n) | | | - | | --> | | |_________________________| | | - | | | |_____________________________| | - | _____________________________ | | _____________________________ | - | | div exp_ | | | | div exp_ | | - | | _________________________ | | | | (hidden) | | - | | | form | | | | | | | - | | | _____________________ | | | | | _____________________ | | - | | | | ^ See prev.comments | | | | | | | ^ See prev.comments | | | - | | | |_____________________| | | | | | |_____________________| | | - | | |_________________________| | | | | | | - | |_____________________________| | | |_____________________________| | - |_________________________________| |_________________________________| - _________________________________ _________________________________ - | ul com_ | | ul com_ | - | _________________________ | | _________________________ | - | | li (comment 1) | | | | li (comment 1) | | - | |_________________________| | | |_________________________| | - | | ... | | | | ... | | - | |_________________________| | | |_________________________| | - | | li (comment n) | | | | li (comment n) | | - | |_________________________| | | |_________________________| | - |_________________________________| |_________________________________| - */ - /***** Link to show initial hidden comments *****/ - if (NumInitialComments) - { - /***** Create unique id for list of hidden comments *****/ - Frm_SetUniqueId (IdComments); - - /***** Link (initially hidden) to show only the latest comments *****/ - TL_LinkToShowOnlyLatestComments (IdComments); - - /***** Div which content will be updated via AJAX *****/ - HTM_DIV_Begin ("id=\"%s\" class=\"TL_RIGHT_WIDTH\"",IdComments); - TL_FormToShowHiddenComments (ActShoHidTL_ComGbl,ActShoHidTL_ComUsr, - Not->NotCod, - IdComments, - NumInitialComments); - HTM_DIV_End (); - } - - /***** List final visible comments *****/ - if (NumFinalCommentsGot) - { - HTM_UL_Begin ("class=\"TL_LIST\""); - for (NumCom = 0; - NumCom < NumFinalCommentsGot; - NumCom++) - TL_WriteOneCommentInList (Timeline,mysql_res); - HTM_UL_End (); - } - - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - } - -/*****************************************************************************/ -/********** Form to show hidden coments in global or user timeline ***********/ -/*****************************************************************************/ - -static void TL_FormToShowHiddenComments (Act_Action_t ActionGbl,Act_Action_t ActionUsr, - long NotCod, - char IdComments[Frm_MAX_BYTES_ID + 1], - unsigned NumInitialComments) - { - extern const char *The_ClassFormLinkInBox[The_NUM_THEMES]; - extern const char *Txt_See_the_previous_X_COMMENTS; - char *OnSubmit; - - HTM_DIV_Begin ("id=\"exp_%s\" class=\"TL_EXPAND_COM TL_RIGHT_WIDTH\"", - IdComments); - - /***** Form and icon-text to show hidden comments *****/ - /* Begin form */ - if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) - { - if (asprintf (&OnSubmit,"toggleComments('%s');" - "updateDivHiddenComments(this," - "'act=%ld&ses=%s&NotCod=%ld&IdComments=%s&NumHidCom=%u&OtherUsrCod=%s');" - " return false;", // return false is necessary to not submit form - IdComments, - Act_GetActCod (ActionUsr), - Gbl.Session.Id, - NotCod, - IdComments, - NumInitialComments, - Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0) - Lay_NotEnoughMemoryExit (); - Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit); - } - else - { - if (asprintf (&OnSubmit,"toggleComments('%s');" - "updateDivHiddenComments(this," - "'act=%ld&ses=%s&NotCod=%ld&IdComments=%s&NumHidCom=%u');" - " return false;", // return false is necessary to not submit form - IdComments, - Act_GetActCod (ActionGbl), - Gbl.Session.Id, - NotCod, - IdComments, - NumInitialComments) < 0) - Lay_NotEnoughMemoryExit (); - Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit); - } - - /* Put icon and text with link to show the first hidden comments */ - HTM_BUTTON_SUBMIT_Begin (NULL,The_ClassFormLinkInBox[Gbl.Prefs.Theme],NULL); - Ico_PutIconTextLink ("angle-up.svg", - Str_BuildStringLong (Txt_See_the_previous_X_COMMENTS, - (long) NumInitialComments)); - Str_FreeString (); - HTM_BUTTON_End (); - - /* End form */ - Frm_EndForm (); - - /* Free allocated memory */ - free (OnSubmit); - - HTM_DIV_End (); - } - -/*****************************************************************************/ -/********************** Write hidden comments via AJAX ***********************/ -/*****************************************************************************/ - -void TL_ShowHiddenCommentsUsr (void) - { - /***** Get user whom profile is displayed *****/ - Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); - - /***** Show hidden comments *****/ - TL_ShowHiddenCommentsGbl (); - } - -void TL_ShowHiddenCommentsGbl (void) - { - struct TL_Timeline Timeline; - long NotCod; - char IdComments[Frm_MAX_BYTES_ID + 1]; - unsigned NumInitialCommentsToGet; - unsigned NumInitialCommentsGot; - - /***** Reset timeline context *****/ - TL_ResetTimeline (&Timeline); - - /***** Get parameters *****/ - /* Get note code */ - NotCod = TL_GetParamNotCod (); - - /* Get identifier */ - Par_GetParToText ("IdComments",IdComments,Frm_MAX_BYTES_ID); - - /* Get number of comments to get */ - NumInitialCommentsToGet = (unsigned) Par_GetParToLong ("NumHidCom"); - - /***** Write HTML inside DIV with hidden comments *****/ - NumInitialCommentsGot = TL_WriteHiddenComments (&Timeline, - NotCod,IdComments,NumInitialCommentsToGet); - - /***** Link to show the first comments *****/ - TL_LinkToShowPreviousComments (IdComments,NumInitialCommentsGot); - } - -/*****************************************************************************/ -/**************************** Write hidden comments **************************/ -/*****************************************************************************/ -// Returns the number of comments got - -static unsigned TL_WriteHiddenComments (struct TL_Timeline *Timeline, - long NotCod, - char IdComments[Frm_MAX_BYTES_ID + 1], - unsigned NumInitialCommentsToGet) - { - MYSQL_RES *mysql_res; - unsigned long NumInitialCommentsGot; - unsigned long NumCom; - - /***** Get comments of this note from database *****/ - NumInitialCommentsGot = (unsigned) - DB_QuerySELECT (&mysql_res,"can not get comments", - "SELECT tl_pubs.PubCod," // row[0] - "tl_pubs.PublisherCod," // row[1] - "tl_pubs.NotCod," // row[2] - "UNIX_TIMESTAMP(" - "tl_pubs.TimePublish)," // row[3] - "tl_comments.Txt," // row[4] - "tl_comments.MedCod" // row[5] - " FROM tl_pubs,tl_comments" - " WHERE tl_pubs.NotCod=%ld" - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments.PubCod" - " ORDER BY tl_pubs.PubCod" - " LIMIT %lu", - NotCod,(unsigned) TL_PUB_COMMENT_TO_NOTE, - NumInitialCommentsToGet); - - /***** List with comments *****/ - HTM_UL_Begin ("id=\"com_%s\" class=\"TL_LIST\"",IdComments); - for (NumCom = 0; - NumCom < NumInitialCommentsGot; - NumCom++) - TL_WriteOneCommentInList (Timeline,mysql_res); - HTM_UL_End (); - - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - - return NumInitialCommentsGot; - } - -/*****************************************************************************/ -/************************* Write a comment in list ***************************/ -/*****************************************************************************/ - -static void TL_WriteOneCommentInList (struct TL_Timeline *Timeline, - MYSQL_RES *mysql_res) - { - MYSQL_ROW row; - struct TL_Comment Com; - - /***** Initialize image *****/ - Med_MediaConstructor (&Com.Content.Media); - - /***** Get data of comment *****/ - row = mysql_fetch_row (mysql_res); - TL_GetDataOfCommentFromRow (row,&Com); - - /***** Write comment *****/ - TL_WriteComment (Timeline,&Com, - TL_TOP_MESSAGE_NONE,-1L, - false); // Not alone - - /***** Free image *****/ - Med_MediaDestructor (&Com.Content.Media); - } - -/*****************************************************************************/ -/****************** Link to show only the latest comments ********************/ -/*****************************************************************************/ - -static void TL_LinkToShowOnlyLatestComments (const char IdComments[Frm_MAX_BYTES_ID + 1]) - { - extern const char *Txt_See_only_the_latest_COMMENTS; - - /***** Icon and text to show only the latest comments ****/ - HTM_DIV_Begin ("id=\"con_%s\" class=\"TL_EXPAND_COM TL_RIGHT_WIDTH\"" - " style=\"display:none;\"", // Hidden - IdComments); - TL_PutIconToToggleComments (IdComments,"angle-down.svg", - Txt_See_only_the_latest_COMMENTS); - HTM_DIV_End (); - } - -/*****************************************************************************/ -/********************* Link to show the first comments ***********************/ -/*****************************************************************************/ - -static void TL_LinkToShowPreviousComments (const char IdComments[Frm_MAX_BYTES_ID + 1], - unsigned NumInitialComments) - { - extern const char *Txt_See_the_previous_X_COMMENTS; - - /***** Icon and text to show only the latest comments ****/ - HTM_DIV_Begin ("id=\"exp_%s\" class=\"TL_EXPAND_COM TL_RIGHT_WIDTH\"" - " style=\"display:none;\"", // Hidden - IdComments); - TL_PutIconToToggleComments (IdComments,"angle-up.svg", - Str_BuildStringLong (Txt_See_the_previous_X_COMMENTS, - (long) NumInitialComments)); - Str_FreeString (); - HTM_DIV_End (); - } - -/*****************************************************************************/ -/********** Put an icon to toggle on/off comments in a publication ***********/ -/*****************************************************************************/ - -static void TL_PutIconToToggleComments (const char *UniqueId, - const char *Icon,const char *Text) - { - extern const char *The_ClassFormLinkInBox[The_NUM_THEMES]; - char *OnClick; - - if (asprintf (&OnClick,"toggleComments('%s')",UniqueId) < 0) - Lay_NotEnoughMemoryExit (); - - /***** Link to toggle on/off some divs *****/ - HTM_BUTTON_BUTTON_Begin (Text,The_ClassFormLinkInBox[Gbl.Prefs.Theme],OnClick); - Ico_PutIconTextLink (Icon,Text); - HTM_BUTTON_End (); - - free (OnClick); - } - -/*****************************************************************************/ -/******************************** Write comment ******************************/ -/*****************************************************************************/ - -static void TL_WriteComment (struct TL_Timeline *Timeline, - struct TL_Comment *Com, - TL_TopMessage_t TopMessage,long UsrCod, - bool ShowCommentAlone) // Comment is shown alone, not in a list - { - extern const char *Txt_Forum; - extern const char *Txt_Course; - extern const char *Txt_Degree; - extern const char *Txt_Centre; - extern const char *Txt_Institution; - struct UsrData UsrDat; - bool IAmTheAuthor; - bool ShowPhoto = false; - char PhotoURL[PATH_MAX + 1]; - static unsigned NumDiv = 0; // Used to create unique div id for fav - - NumDiv++; - - if (ShowCommentAlone) - { - Box_BoxBegin (NULL,NULL, - NULL,NULL, - NULL,Box_NOT_CLOSABLE); - - /***** Write sharer/commenter if distinct to author *****/ - TL_WriteTopMessage (TopMessage,UsrCod); - - HTM_DIV_Begin ("class=\"TL_LEFT_PHOTO\""); - HTM_DIV_End (); - - HTM_DIV_Begin ("class=\"TL_RIGHT_CONT TL_RIGHT_WIDTH\""); - HTM_UL_Begin ("class=\"LIST_LEFT\""); - } - - /***** Start list item *****/ - if (ShowCommentAlone) - HTM_LI_Begin (NULL); - else - HTM_LI_Begin ("class=\"TL_COM\""); - - if (Com->PubCod <= 0 || - Com->NotCod <= 0 || - Com->UsrCod <= 0) - Ale_ShowAlert (Ale_ERROR,"Error in comment."); - else - { - /***** Get author's data *****/ - Usr_UsrDataConstructor (&UsrDat); - UsrDat.UsrCod = Com->UsrCod; - Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS); - IAmTheAuthor = Usr_ItsMe (UsrDat.UsrCod); - - /***** Left: write author's photo *****/ - HTM_DIV_Begin ("class=\"TL_COM_PHOTO\""); - ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); - Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : - NULL, - "PHOTO30x40",Pho_ZOOM,true); // Use unique id - HTM_DIV_End (); - - /***** Right: author's name, time, content, image and buttons *****/ - HTM_DIV_Begin ("class=\"TL_COM_CONT TL_COMM_WIDTH\""); - - /* Write author's full name and nickname */ - TL_WriteAuthorComment (&UsrDat); - - /* Write date and time */ - TL_WriteDateTime (Com->DateTimeUTC); - - /* Write content of the comment */ - if (Com->Content.Txt[0]) - { - HTM_DIV_Begin ("class=\"TL_TXT\""); - Msg_WriteMsgContent (Com->Content.Txt,Cns_MAX_BYTES_LONG_TEXT,true,false); - HTM_DIV_End (); - } - - /* Show image */ - Med_ShowMedia (&Com->Content.Media,"TL_COM_MED_CONT TL_COMM_WIDTH", - "TL_COM_MED TL_COMM_WIDTH"); - - /* Start foot container */ - HTM_DIV_Begin ("class=\"TL_FOOT TL_COMM_WIDTH\""); - - /* Fav zone */ - HTM_DIV_Begin ("id=\"fav_com_%s_%u\" class=\"TL_FAV_COM TL_FAV_WIDTH\"", - Gbl.UniqueNameEncrypted,NumDiv); - TL_Fav_PutFormToFavUnfComment (Com,TL_SHOW_FEW_USRS); - HTM_DIV_End (); - - /* Put icon to remove this comment */ - HTM_DIV_Begin ("class=\"TL_REM\""); - if (IAmTheAuthor && !ShowCommentAlone) - TL_PutFormToRemoveComment (Timeline,Com->PubCod); - HTM_DIV_End (); - - /* End foot container */ - HTM_DIV_End (); - - /***** Free memory used for user's data *****/ - Usr_UsrDataDestructor (&UsrDat); - } - - /***** End list item *****/ - HTM_LI_End (); - - if (ShowCommentAlone) - { - HTM_UL_End (); - HTM_DIV_End (); - Box_BoxEnd (); - } - } - -/*****************************************************************************/ -/********* Write name and nickname of author of a comment to a note **********/ -/*****************************************************************************/ - -static void TL_WriteAuthorComment (struct UsrData *UsrDat) - { - extern const char *Txt_My_public_profile; - extern const char *Txt_Another_user_s_profile; - bool ItsMe = Usr_ItsMe (UsrDat->UsrCod); - - /***** Show user's name inside form to go to user's public profile *****/ - Frm_StartFormUnique (ActSeeOthPubPrf); - Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); - HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile : - Txt_Another_user_s_profile, - "BT_LINK TL_COM_AUTHOR TL_COMM_AUTHOR_WIDTH DAT_BOLD",NULL); - HTM_Txt (UsrDat->FullName); - HTM_BUTTON_End (); - Frm_EndForm (); - } - -/*****************************************************************************/ -/************************* Form to remove comment ****************************/ -/*****************************************************************************/ - -static void TL_PutFormToRemoveComment (const struct TL_Timeline *Timeline, - long PubCod) - { - extern const char *Txt_Remove; - - /***** Form to remove publication *****/ - TL_FormStart (Timeline,ActReqRemTL_ComGbl,ActReqRemTL_ComUsr); - TL_PutHiddenParamPubCod (PubCod); - Ico_PutIconLink ("trash.svg",Txt_Remove); - Frm_EndForm (); - } - -/*****************************************************************************/ -/************************ Form to remove publication *************************/ -/*****************************************************************************/ - -static void TL_PutFormToRemovePublication (const struct TL_Timeline *Timeline, - long NotCod) - { - extern const char *Txt_Remove; - - /***** Form to remove publication *****/ - TL_FormStart (Timeline,ActReqRemTL_PubGbl,ActReqRemTL_PubUsr); - TL_PutHiddenParamNotCod (NotCod); - Ico_PutIconLink ("trash.svg",Txt_Remove); - Frm_EndForm (); - } - -/*****************************************************************************/ -/****************** Put parameter with the code of a note ********************/ -/*****************************************************************************/ - -static void TL_PutHiddenParamNotCod (long NotCod) - { - Par_PutHiddenParamLong (NULL,"NotCod",NotCod); - } - /*****************************************************************************/ /*************** Put parameter with the code of a publication ****************/ /*****************************************************************************/ @@ -3151,16 +1631,6 @@ void TL_PutHiddenParamPubCod (long PubCod) Par_PutHiddenParamLong (NULL,"PubCod",PubCod); } -/*****************************************************************************/ -/****************** Get parameter with the code of a note ********************/ -/*****************************************************************************/ - -long TL_GetParamNotCod (void) - { - /***** Get note code *****/ - return Par_GetParToLong ("NotCod"); - } - /*****************************************************************************/ /**************** Get parameter with the code of a publication ***************/ /*****************************************************************************/ @@ -3171,117 +1641,6 @@ long TL_GetParamPubCod (void) return Par_GetParToLong ("PubCod"); } -/*****************************************************************************/ -/******************************* Comment a note ******************************/ -/*****************************************************************************/ - -void TL_ReceiveCommentUsr (void) - { - struct TL_Timeline Timeline; - long NotCod; - - /***** Reset timeline context *****/ - TL_ResetTimeline (&Timeline); - - /***** Get user whom profile is displayed *****/ - Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); - - /***** Show user's profile *****/ - Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat); - - /***** Start section *****/ - HTM_SECTION_Begin (TL_TIMELINE_SECTION_ID); - - /***** Receive comment in a note - and write updated timeline after commenting (user) *****/ - NotCod = TL_ReceiveComment (); - TL_ShowTimelineUsrHighlightingNot (&Timeline,NotCod); - - /***** End section *****/ - HTM_SECTION_End (); - } - -void TL_ReceiveCommentGbl (void) - { - struct TL_Timeline Timeline; - long NotCod; - - /***** Initialize timeline *****/ - TL_InitTimelineGbl (&Timeline); - - /***** Receive comment in a note *****/ - NotCod = TL_ReceiveComment (); - - /***** Write updated timeline after commenting (global) *****/ - TL_ShowTimelineGblHighlightingNot (&Timeline,NotCod); - } - -static long TL_ReceiveComment (void) - { - extern const char *Txt_The_original_post_no_longer_exists; - struct TL_PostContent Content; - struct TL_Note Not; - struct TL_Publication Pub; - - /***** Get data of note *****/ - Not.NotCod = TL_GetParamNotCod (); - TL_GetDataOfNoteByCod (&Not); - - if (Not.NotCod > 0) - { - /***** Get the content of the comment *****/ - Par_GetParAndChangeFormat ("Txt",Content.Txt,Cns_MAX_BYTES_LONG_TEXT, - Str_TO_RIGOROUS_HTML,true); - - /***** Initialize image *****/ - Med_MediaConstructor (&Content.Media); - - /***** Get attached image (action, file and title) *****/ - Content.Media.Width = TL_IMAGE_SAVED_MAX_WIDTH; - Content.Media.Height = TL_IMAGE_SAVED_MAX_HEIGHT; - Content.Media.Quality = TL_IMAGE_SAVED_QUALITY; - Med_GetMediaFromForm (-1L,-1L,-1,&Content.Media,NULL,NULL); - Ale_ShowAlerts (NULL); - - if (Content.Txt[0] || // Text not empty - Content.Media.Status == Med_PROCESSED) // A media is attached - { - /***** Store media in filesystem and database *****/ - Med_RemoveKeepOrStoreMedia (-1L,&Content.Media); - - /***** Publish *****/ - /* Insert into publications */ - Pub.NotCod = Not.NotCod; - Pub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod; - Pub.PubType = TL_PUB_COMMENT_TO_NOTE; - TL_PublishNoteInTimeline (&Pub); // Set Pub.PubCod - - /* Insert comment content in the database */ - DB_QueryINSERT ("can not store comment content", - "INSERT INTO tl_comments" - " (PubCod,Txt,MedCod)" - " VALUES" - " (%ld,'%s',%ld)", - Pub.PubCod, - Content.Txt, - Content.Media.MedCod); - - /***** Store notifications about the new comment *****/ - Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_TIMELINE_COMMENT,Pub.PubCod); - - /***** Analyze content and store notifications about mentions *****/ - Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (Pub.PubCod,Content.Txt); - } - - /***** Free image *****/ - Med_MediaDestructor (&Content.Media); - } - else - Ale_ShowAlert (Ale_WARNING,Txt_The_original_post_no_longer_exists); - - return Not.NotCod; - } - /*****************************************************************************/ /*********** Create a notification for the author of a post/comment **********/ /*****************************************************************************/ @@ -3321,288 +1680,11 @@ void TL_CreateNotifToAuthor (long AuthorCod,long PubCod, Usr_UsrDataDestructor (&UsrDat); } -/*****************************************************************************/ -/*********************** Request the removal of a note ***********************/ -/*****************************************************************************/ - -void TL_RequestRemNoteUsr (void) - { - struct TL_Timeline Timeline; - - /***** Reset timeline context *****/ - TL_ResetTimeline (&Timeline); - - /***** Get user whom profile is displayed *****/ - Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); - - /***** Show user's profile *****/ - Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat); - - /***** Start section *****/ - HTM_SECTION_Begin (TL_TIMELINE_SECTION_ID); - - /***** Request the removal of note *****/ - TL_RequestRemovalNote (&Timeline); - - /***** Write timeline again (user) *****/ - TL_ShowTimelineUsr (&Timeline); - - /***** End section *****/ - HTM_SECTION_End (); - } - -void TL_RequestRemNoteGbl (void) - { - struct TL_Timeline Timeline; - - /***** Initialize timeline *****/ - TL_InitTimelineGbl (&Timeline); - - /***** Request the removal of note *****/ - TL_RequestRemovalNote (&Timeline); - - /***** Write timeline again (global) *****/ - TL_ShowNoteAndTimelineGbl (&Timeline); - } - -static void TL_RequestRemovalNote (struct TL_Timeline *Timeline) - { - extern const char *Txt_The_original_post_no_longer_exists; - extern const char *Txt_Do_you_really_want_to_remove_the_following_post; - extern const char *Txt_Remove; - struct TL_Note Not; - bool ItsMe; - - /***** Get data of note *****/ - Not.NotCod = TL_GetParamNotCod (); - TL_GetDataOfNoteByCod (&Not); - - if (Not.NotCod > 0) - { - ItsMe = Usr_ItsMe (Not.UsrCod); - if (ItsMe) // I am the author of this note - { - /***** Show question and button to remove note *****/ - /* Start alert */ - Ale_ShowAlertAndButton1 (Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_following_post); - - /* Show note */ - TL_WriteNote (Timeline,&Not, - TL_TOP_MESSAGE_NONE,-1L, - TL_DONT_HIGHLIGHT_NOTE, - TL_SHOW_NOTE_ALONE); - - /* End alert */ - Timeline->NotCod = Not.NotCod; // Note to be removed - if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) - Ale_ShowAlertAndButton2 (ActRemTL_PubUsr,"timeline",NULL, - TL_PutParamsRemoveNote,Timeline, - Btn_REMOVE_BUTTON,Txt_Remove); - else - Ale_ShowAlertAndButton2 (ActRemTL_PubGbl,NULL,NULL, - TL_PutParamsRemoveNote,Timeline, - Btn_REMOVE_BUTTON,Txt_Remove); - } - } - else - Ale_ShowAlert (Ale_WARNING,Txt_The_original_post_no_longer_exists); - } - -/*****************************************************************************/ -/********************* Put parameters to remove a note ***********************/ -/*****************************************************************************/ - -static void TL_PutParamsRemoveNote (void *Timeline) - { - if (Timeline) - { - if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) - Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod); - else - Usr_PutHiddenParamWho (((struct TL_Timeline *) Timeline)->Who); - TL_PutHiddenParamNotCod (((struct TL_Timeline *) Timeline)->NotCod); - } - } - -/*****************************************************************************/ -/******************************* Remove a note *******************************/ -/*****************************************************************************/ - -void TL_RemoveNoteUsr (void) - { - struct TL_Timeline Timeline; - - /***** Reset timeline context *****/ - TL_ResetTimeline (&Timeline); - - /***** Get user whom profile is displayed *****/ - Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); - - /***** Show user's profile *****/ - Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat); - - /***** Start section *****/ - HTM_SECTION_Begin (TL_TIMELINE_SECTION_ID); - - /***** Remove a note *****/ - TL_RemoveNote (); - - /***** Write updated timeline after removing (user) *****/ - TL_ShowTimelineUsr (&Timeline); - - /***** End section *****/ - HTM_SECTION_End (); - } - -void TL_RemoveNoteGbl (void) - { - struct TL_Timeline Timeline; - - /***** Initialize timeline *****/ - TL_InitTimelineGbl (&Timeline); - - /***** Remove a note *****/ - TL_RemoveNote (); - - /***** Write updated timeline after removing (global) *****/ - TL_ShowNoteAndTimelineGbl (&Timeline); - } - -static void TL_RemoveNote (void) - { - extern const char *Txt_The_original_post_no_longer_exists; - extern const char *Txt_TIMELINE_Post_removed; - struct TL_Note Not; - bool ItsMe; - - /***** Get data of note *****/ - Not.NotCod = TL_GetParamNotCod (); - TL_GetDataOfNoteByCod (&Not); - - if (Not.NotCod > 0) - { - ItsMe = Usr_ItsMe (Not.UsrCod); - if (ItsMe) // I am the author of this note - { - /***** Delete note from database *****/ - TL_RemoveNoteMediaAndDBEntries (&Not); - - /***** Reset note *****/ - TL_ResetNote (&Not); - - /***** Message of success *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_TIMELINE_Post_removed); - } - } - else - Ale_ShowAlert (Ale_WARNING,Txt_The_original_post_no_longer_exists); - } - -/*****************************************************************************/ -/*********************** Remove a note from database *************************/ -/*****************************************************************************/ - -static void TL_RemoveNoteMediaAndDBEntries (struct TL_Note *Not) - { - MYSQL_RES *mysql_res; - MYSQL_ROW row; - long PubCod; - unsigned long NumComments; - unsigned long NumCom; - long MedCod; - - /***** Remove comments associated to this note *****/ - /* Get comments of this note */ - NumComments = DB_QuerySELECT (&mysql_res,"can not get comments", - "SELECT PubCod" - " FROM tl_pubs" - " WHERE NotCod=%ld AND PubType=%u", - Not->NotCod, - (unsigned) TL_PUB_COMMENT_TO_NOTE); - - /* For each comment... */ - for (NumCom = 0; - NumCom < NumComments; - NumCom++) - { - /* Get code of comment **/ - row = mysql_fetch_row (mysql_res); - PubCod = Str_ConvertStrCodToLongCod (row[0]); - - /* Remove media associated to comment - and delete comment from database */ - TL_RemoveCommentMediaAndDBEntries (PubCod); - } - - /* Free structure that stores the query result */ - DB_FreeMySQLResult (&mysql_res); - - /***** Remove media associated to post *****/ - if (Not->NoteType == TL_NOTE_POST) - { - /* Remove media associated to a post from database */ - if (DB_QuerySELECT (&mysql_res,"can not get media", - "SELECT MedCod" // row[0] - " FROM tl_posts" - " WHERE PstCod=%ld", - Not->Cod) == 1) // Result should have a unique row - { - /* Get media code */ - row = mysql_fetch_row (mysql_res); - MedCod = Str_ConvertStrCodToLongCod (row[0]); - - /* Remove media */ - Med_RemoveMedia (MedCod); - } - - /* Free structure that stores the query result */ - DB_FreeMySQLResult (&mysql_res); - } - - /***** Mark possible notifications on the publications - of this note as removed *****/ - /* Mark notifications of the original note as removed */ - PubCod = TL_GetPubCodOfOriginalNote (Not->NotCod); - if (PubCod > 0) - { - Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,PubCod); - Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE ,PubCod); - Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,PubCod); - } - - /***** Remove favs for this note *****/ - DB_QueryDELETE ("can not remove favs for note", - "DELETE FROM tl_notes_fav" - " WHERE NotCod=%ld", - Not->NotCod); - - /***** Remove all the publications of this note *****/ - DB_QueryDELETE ("can not remove a publication", - "DELETE FROM tl_pubs" - " WHERE NotCod=%ld", - Not->NotCod); - - /***** Remove note *****/ - DB_QueryDELETE ("can not remove a note", - "DELETE FROM tl_notes" - " WHERE NotCod=%ld" - " AND UsrCod=%ld", // Extra check: I am the author - Not->NotCod, - Gbl.Usrs.Me.UsrDat.UsrCod); - - if (Not->NoteType == TL_NOTE_POST) - /***** Remove post *****/ - DB_QueryDELETE ("can not remove a post", - "DELETE FROM tl_posts" - " WHERE PstCod=%ld", - Not->Cod); - } - /*****************************************************************************/ /*********************** Get code of note of a publication *******************/ /*****************************************************************************/ -static long TL_GetNotCodFromPubCod (long PubCod) +static long TL_Pub_GetNotCodFromPubCod (long PubCod) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -3629,7 +1711,7 @@ static long TL_GetNotCodFromPubCod (long PubCod) /*************** Get code of publication of the original note ****************/ /*****************************************************************************/ -long TL_GetPubCodOfOriginalNote (long NotCod) +long TL_Not_GetPubCodOfOriginalNote (long NotCod) { MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -3652,251 +1734,6 @@ long TL_GetPubCodOfOriginalNote (long NotCod) return OriginalPubCod; } -/*****************************************************************************/ -/**************** Request the removal of a comment in a note *****************/ -/*****************************************************************************/ - -void TL_RequestRemComUsr (void) - { - struct TL_Timeline Timeline; - - /***** Reset timeline context *****/ - TL_ResetTimeline (&Timeline); - - /***** Get user whom profile is displayed *****/ - Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); - - /***** Show user's profile *****/ - Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat); - - /***** Start section *****/ - HTM_SECTION_Begin (TL_TIMELINE_SECTION_ID); - - /***** Request the removal of comment in note *****/ - TL_RequestRemovalComment (&Timeline); - - /***** Write timeline again (user) *****/ - TL_ShowTimelineUsr (&Timeline); - - /***** End section *****/ - HTM_SECTION_End (); - } - -void TL_RequestRemComGbl (void) - { - struct TL_Timeline Timeline; - - /***** Initialize timeline *****/ - TL_InitTimelineGbl (&Timeline); - - /***** Request the removal of comment in note *****/ - TL_RequestRemovalComment (&Timeline); - - /***** Write timeline again (global) *****/ - TL_ShowNoteAndTimelineGbl (&Timeline); - } - -static void TL_RequestRemovalComment (struct TL_Timeline *Timeline) - { - extern const char *Txt_The_comment_no_longer_exists; - extern const char *Txt_Do_you_really_want_to_remove_the_following_comment; - extern const char *Txt_Remove; - struct TL_Comment Com; - bool ItsMe; - - /***** Initialize image *****/ - Med_MediaConstructor (&Com.Content.Media); - - /***** Get data of comment *****/ - Com.PubCod = TL_GetParamPubCod (); - TL_GetDataOfCommByCod (&Com); - - if (Com.PubCod > 0) - { - ItsMe = Usr_ItsMe (Com.UsrCod); - if (ItsMe) // I am the author of this comment - { - /***** Show question and button to remove comment *****/ - /* Start alert */ - Ale_ShowAlertAndButton1 (Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_following_comment); - - /* Show comment */ - TL_WriteComment (Timeline,&Com, - TL_TOP_MESSAGE_NONE,-1L, - true); // Alone - - /* End alert */ - Timeline->PubCod = Com.PubCod; // Publication to be removed - if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) - Ale_ShowAlertAndButton2 (ActRemTL_ComUsr,"timeline",NULL, - TL_PutParamsRemoveComment,Timeline, - Btn_REMOVE_BUTTON,Txt_Remove); - else - Ale_ShowAlertAndButton2 (ActRemTL_ComGbl,NULL,NULL, - TL_PutParamsRemoveComment,Timeline, - Btn_REMOVE_BUTTON,Txt_Remove); - } - } - else - Ale_ShowAlert (Ale_WARNING,Txt_The_comment_no_longer_exists); - - /***** Free image *****/ - Med_MediaDestructor (&Com.Content.Media); - } - -/*****************************************************************************/ -/******************** Put parameters to remove a comment *********************/ -/*****************************************************************************/ - -static void TL_PutParamsRemoveComment (void *Timeline) - { - if (Timeline) - { - if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) - Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod); - else - Usr_PutHiddenParamWho (((struct TL_Timeline *) Timeline)->Who); - TL_PutHiddenParamPubCod (((struct TL_Timeline *) Timeline)->PubCod); - } - } - -/*****************************************************************************/ -/***************************** Remove a comment ******************************/ -/*****************************************************************************/ - -void TL_RemoveComUsr (void) - { - struct TL_Timeline Timeline; - - /***** Reset timeline context *****/ - TL_ResetTimeline (&Timeline); - - /***** Get user whom profile is displayed *****/ - Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); - - /***** Show user's profile *****/ - Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat); - - /***** Start section *****/ - HTM_SECTION_Begin (TL_TIMELINE_SECTION_ID); - - /***** Remove a comment *****/ - TL_RemoveComment (); - - /***** Write updated timeline after removing (user) *****/ - TL_ShowTimelineUsr (&Timeline); - - /***** End section *****/ - HTM_SECTION_End (); - } - -void TL_RemoveComGbl (void) - { - struct TL_Timeline Timeline; - - /***** Initialize timeline *****/ - TL_InitTimelineGbl (&Timeline); - - /***** Remove a comment *****/ - TL_RemoveComment (); - - /***** Write updated timeline after removing (global) *****/ - TL_ShowNoteAndTimelineGbl (&Timeline); - } - -static void TL_RemoveComment (void) - { - extern const char *Txt_The_comment_no_longer_exists; - extern const char *Txt_Comment_removed; - struct TL_Comment Com; - bool ItsMe; - - /***** Initialize image *****/ - Med_MediaConstructor (&Com.Content.Media); - - /***** Get data of comment *****/ - Com.PubCod = TL_GetParamPubCod (); - TL_GetDataOfCommByCod (&Com); - - if (Com.PubCod > 0) - { - ItsMe = Usr_ItsMe (Com.UsrCod); - if (ItsMe) // I am the author of this comment - { - /***** Remove media associated to comment - and delete comment from database *****/ - TL_RemoveCommentMediaAndDBEntries (Com.PubCod); - - /***** Reset fields of comment *****/ - TL_ResetComment (&Com); - - /***** Message of success *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_Comment_removed); - } - } - else - Ale_ShowAlert (Ale_WARNING,Txt_The_comment_no_longer_exists); - - /***** Free image *****/ - Med_MediaDestructor (&Com.Content.Media); - } - -/*****************************************************************************/ -/*************** Remove comment media and database entries *******************/ -/*****************************************************************************/ - -static void TL_RemoveCommentMediaAndDBEntries (long PubCod) - { - MYSQL_RES *mysql_res; - MYSQL_ROW row; - long MedCod; - - /***** Remove media associated to comment *****/ - if (DB_QuerySELECT (&mysql_res,"can not get media", - "SELECT MedCod" // row[0] - " FROM tl_comments" - " WHERE PubCod=%ld", - PubCod) == 1) // Result should have a unique row - { - /* Get media code */ - row = mysql_fetch_row (mysql_res); - MedCod = Str_ConvertStrCodToLongCod (row[0]); - - /* Remove media */ - Med_RemoveMedia (MedCod); - } - - /* Free structure that stores the query result */ - DB_FreeMySQLResult (&mysql_res); - - /***** Mark possible notifications on this comment as removed *****/ - Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,PubCod); - Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,PubCod); - Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,PubCod); - - /***** Remove favs for this comment *****/ - DB_QueryDELETE ("can not remove favs for comment", - "DELETE FROM tl_comments_fav" - " WHERE PubCod=%ld", - PubCod); - - /***** Remove content of this comment *****/ - DB_QueryDELETE ("can not remove a comment", - "DELETE FROM tl_comments" - " WHERE PubCod=%ld", - PubCod); - - /***** Remove this comment *****/ - DB_QueryDELETE ("can not remove a comment", - "DELETE FROM tl_pubs" - " WHERE PubCod=%ld" - " AND PublisherCod=%ld" // Extra check: I am the author - " AND PubType=%u", // Extra check: it's a comment - PubCod, - Gbl.Usrs.Me.UsrDat.UsrCod, - (unsigned) TL_PUB_COMMENT_TO_NOTE); - } - /*****************************************************************************/ /************* Remove all the content of a user from database ****************/ /*****************************************************************************/ @@ -4147,87 +1984,6 @@ void TL_FormFavSha (Act_Action_t ActionGbl,Act_Action_t ActionUsr, free (OnSubmit); } -/*****************************************************************************/ -/******************** Get data of note using its code ************************/ -/*****************************************************************************/ - -void TL_GetDataOfNoteByCod (struct TL_Note *Not) - { - MYSQL_RES *mysql_res; - MYSQL_ROW row; - - if (Not->NotCod > 0) - { - /***** Get data of note from database *****/ - if (DB_QuerySELECT (&mysql_res,"can not get data of note", - "SELECT NotCod," // row[0] - "NoteType," // row[1] - "Cod," // row[2] - "UsrCod," // row[3] - "HieCod," // row[4] - "Unavailable," // row[5] - "UNIX_TIMESTAMP(TimeNote)" // row[6] - " FROM tl_notes" - " WHERE NotCod=%ld", - Not->NotCod)) - { - /***** Get data of note *****/ - row = mysql_fetch_row (mysql_res); - TL_GetDataOfNoteFromRow (row,Not); - } - else - /***** Reset fields of note *****/ - TL_ResetNote (Not); - - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - } - else - /***** Reset fields of note *****/ - TL_ResetNote (Not); - } - -/*****************************************************************************/ -/******************* Get data of comment using its code **********************/ -/*****************************************************************************/ - -void TL_GetDataOfCommByCod (struct TL_Comment *Com) - { - MYSQL_RES *mysql_res; - MYSQL_ROW row; - - if (Com->PubCod > 0) - { - /***** Get data of comment from database *****/ - if (DB_QuerySELECT (&mysql_res,"can not get data of comment", - "SELECT tl_pubs.PubCod," // row[0] - "tl_pubs.PublisherCod," // row[1] - "tl_pubs.NotCod," // row[2] - "UNIX_TIMESTAMP(tl_pubs.TimePublish)," // row[3] - "tl_comments.Txt," // row[4] - "tl_comments.MedCod" // row[5] - " FROM tl_pubs,tl_comments" - " WHERE tl_pubs.PubCod=%ld" - " AND tl_pubs.PubType=%u" - " AND tl_pubs.PubCod=tl_comments.PubCod", - Com->PubCod,(unsigned) TL_PUB_COMMENT_TO_NOTE)) - { - /***** Get data of comment *****/ - row = mysql_fetch_row (mysql_res); - TL_GetDataOfCommentFromRow (row,Com); - } - else - /***** Reset fields of comment *****/ - TL_ResetComment (Com); - - /***** Free structure that stores the query result *****/ - DB_FreeMySQLResult (&mysql_res); - } - else - /***** Reset fields of comment *****/ - TL_ResetComment (Com); - } - /*****************************************************************************/ /***************** Get data of publication using its code ********************/ /*****************************************************************************/ @@ -4267,49 +2023,6 @@ static void TL_GetDataOfPublicationFromNextRow (MYSQL_RES *mysql_res, Pub->TopMessage = TopMessages[Pub->PubType]; } -/*****************************************************************************/ -/************************ Get data of note from row **************************/ -/*****************************************************************************/ - -static void TL_GetDataOfNoteFromRow (MYSQL_ROW row,struct TL_Note *Not) - { - /* - row[0]: NotCod - row[1]: NoteType - row[2]: Cod - row[3]: UsrCod - row[4]: HieCod - row[5]: Unavailable - row[5]: UNIX_TIMESTAMP(TimeNote) - */ - /***** Get code (row[0]) *****/ - Not->NotCod = Str_ConvertStrCodToLongCod (row[0]); - - /***** Get note type (row[1]) *****/ - Not->NoteType = TL_GetNoteTypeFromStr ((const char *) row[1]); - - /***** Get file/post... code (row[2]) *****/ - Not->Cod = Str_ConvertStrCodToLongCod (row[2]); - - /***** Get (from) user code (row[3]) *****/ - Not->UsrCod = Str_ConvertStrCodToLongCod (row[3]); - - /***** Get hierarchy code (row[4]) *****/ - Not->HieCod = Str_ConvertStrCodToLongCod (row[4]); - - /***** File/post... unavailable (row[5]) *****/ - Not->Unavailable = (row[5][0] == 'Y'); - - /***** Get time of the note (row[6]) *****/ - Not->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[6]); - - /***** Get number of times this note has been shared *****/ - TL_Sha_UpdateNumTimesANoteHasBeenShared (Not); - - /***** Get number of times this note has been favourited *****/ - TL_Fav_GetNumTimesANoteHasBeenFav (Not); - } - /*****************************************************************************/ /******* Get publication type from string number coming from database ********/ /*****************************************************************************/ @@ -4325,64 +2038,11 @@ static TL_PubType_t TL_GetPubTypeFromStr (const char *Str) return TL_PUB_UNKNOWN; } -/*****************************************************************************/ -/********* Get note type from string number coming from database *************/ -/*****************************************************************************/ - -static TL_NoteType_t TL_GetNoteTypeFromStr (const char *Str) - { - unsigned UnsignedNum; - - if (sscanf (Str,"%u",&UnsignedNum) == 1) - if (UnsignedNum < TL_NUM_NOTE_TYPES) - return (TL_NoteType_t) UnsignedNum; - - return TL_NOTE_UNKNOWN; - } - -/*****************************************************************************/ -/********************** Get data of comment from row *************************/ -/*****************************************************************************/ - -static void TL_GetDataOfCommentFromRow (MYSQL_ROW row,struct TL_Comment *Com) - { - /* - row[0]: PubCod - row[1]: PublisherCod - row[2]: NotCod - row[3]: TimePublish - row[4]: Txt - row[5]: MedCod - */ - /***** Get code of comment (row[0]) *****/ - Com->PubCod = Str_ConvertStrCodToLongCod (row[0]); - - /***** Get (from) user code (row[1]) *****/ - Com->UsrCod = Str_ConvertStrCodToLongCod (row[1]); - - /***** Get code of note (row[2]) *****/ - Com->NotCod = Str_ConvertStrCodToLongCod (row[2]); - - /***** Get time of the note (row[3]) *****/ - Com->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]); - - /***** Get text content (row[4]) *****/ - Str_Copy (Com->Content.Txt,row[4], - Cns_MAX_BYTES_LONG_TEXT); - - /***** Get number of times this comment has been favourited *****/ - TL_Fav_GetNumTimesACommHasBeenFav (Com); - - /***** Get media content (row[5]) *****/ - Com->Content.Media.MedCod = Str_ConvertStrCodToLongCod (row[5]); - Med_GetMediaDataByCod (&Com->Content.Media); - } - /*****************************************************************************/ /************************ Reset fields of publication ************************/ /*****************************************************************************/ -static void TL_ResetPublication (struct TL_Publication *Pub) +static void TL_Pub_ResetPublication (struct TL_Publication *Pub) { Pub->PubCod = -1L; Pub->NotCod = -1L; @@ -4391,35 +2051,6 @@ static void TL_ResetPublication (struct TL_Publication *Pub) Pub->TopMessage = TL_TOP_MESSAGE_NONE; } -/*****************************************************************************/ -/*************************** Reset fields of note ****************************/ -/*****************************************************************************/ - -static void TL_ResetNote (struct TL_Note *Not) - { - Not->NotCod = -1L; - Not->NoteType = TL_NOTE_UNKNOWN; - Not->UsrCod = -1L; - Not->HieCod = -1L; - Not->Cod = -1L; - Not->Unavailable = false; - Not->DateTimeUTC = (time_t) 0; - Not->NumShared = 0; - } - -/*****************************************************************************/ -/************************** Reset fields of comment **************************/ -/*****************************************************************************/ - -static void TL_ResetComment (struct TL_Comment *Com) - { - Com->PubCod = -1L; - Com->UsrCod = -1L; - Com->NotCod = -1L; - Com->DateTimeUTC = (time_t) 0; - Com->Content.Txt[0] = '\0'; - } - /*****************************************************************************/ /******************* Clear unused old timelines in database ******************/ /*****************************************************************************/ @@ -4445,37 +2076,6 @@ static void TL_ClearTimelineThisSession (void) Gbl.Session.Id); } -/*****************************************************************************/ -/****** Add just retrieved notes to current timeline for this session ********/ -/*****************************************************************************/ - -static void TL_AddNotesJustRetrievedToTimelineThisSession (void) - { - /* tl_timelines contains the distinct notes in timeline of each open session: -mysql> SELECT SessionId,COUNT(*) FROM tl_timelines GROUP BY SessionId; -+---------------------------------------------+----------+ -| SessionId | COUNT(*) | -+---------------------------------------------+----------+ -| u-X-R3gKki7eKMXrNCP8bGhwOAZuVngRy7FNGZFMKzI | 52 | --> 52 distinct notes -| u1CoqL1YWl3_hR4wk4bI7vhnc-uRcCmIDyKYAgBB6kk | 10 | -| u8xqamzkorHfY4BvYRMXjNhzHvQyigZUZemO0YiMn48 | 10 | -| u_n2V_L3KrFjnd4SqZk0gxMFwZHRuWZ8_EIVTU9sdpI | 10 | -| V6pGe1kGGS_uO5i__waqXKnuDkPYaDZHNAYr-Zv-GJQ | 2 | -| vqDRz-iiM8v10Dl8ThwqIqmDRIklz8szJaqflwXZucs | 10 | -| w11juqKPx6lg-f_pL2ZBYqlagU1mEepSvvk9L3gDGac | 10 | --> 10 distinct notes -| wLg4e8KQljCcVuFWIkJjNeti89kAiwOZ3iyXdzm_eDk | 10 | -| wnU85YrwJHhZGWIZhd7LQfQTPrclIWHfMF3DcB-Rcgw | 4 | -| wRzRJFnHfzW61fZYnvMIaMRlkuWUeEyqXVQ6JeWA32k | 11 | -+---------------------------------------------+----------+ -10 rows in set (0,01 sec) - */ - DB_QueryINSERT ("can not insert notes in timeline", - "INSERT IGNORE INTO tl_timelines" - " (SessionId,NotCod)" - " SELECT '%s',NotCod FROM tl_tmp_just_retrieved_notes", - Gbl.Session.Id); - } - /*****************************************************************************/ /***************** Get notification of a new publication *********************/ /*****************************************************************************/ @@ -4487,7 +2087,7 @@ void TL_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], MYSQL_RES *mysql_res; MYSQL_ROW row; struct TL_Publication Pub; - struct TL_Note Not; + struct TL_Not_Note Not; struct TL_PostContent Content; size_t Length; bool ContentCopied = false; @@ -4520,7 +2120,7 @@ void TL_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], case TL_PUB_SHARED_NOTE: /* Get data of note */ Not.NotCod = Pub.NotCod; - TL_GetDataOfNoteByCod (&Not); + TL_Not_GetDataOfNoteByCod (&Not); if (Not.NoteType == TL_NOTE_POST) { @@ -4560,7 +2160,7 @@ void TL_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], Ntf_MAX_BYTES_SUMMARY); } else - TL_GetNoteSummary (&Not,SummaryStr); + TL_Not_GetNoteSummary (&Not,SummaryStr); break; case TL_PUB_COMMENT_TO_NOTE: /***** Get content of post from database *****/ diff --git a/swad_timeline.h b/swad_timeline.h index f70471af..e2dfd422 100644 --- a/swad_timeline.h +++ b/swad_timeline.h @@ -27,6 +27,11 @@ /********************************** Headers **********************************/ /*****************************************************************************/ +#include "swad_form.h" +#include "swad_media.h" +#include "swad_notification.h" +#include "swad_user.h" + /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ @@ -38,40 +43,21 @@ #define TL_DEF_USRS_SHOWN 5 // Default maximum number of users shown who have share/fav a note #define TL_MAX_USRS_SHOWN 1000 // Top maximum number of users shown who have share/fav a note +/* + Timeline images will be saved with: + · maximum width of TL_IMAGE_SAVED_MAX_HEIGHT + · maximum height of TL_IMAGE_SAVED_MAX_HEIGHT + · maintaining the original aspect ratio (aspect ratio recommended: 3:2) +*/ +#define TL_IMAGE_SAVED_MAX_WIDTH 768 +#define TL_IMAGE_SAVED_MAX_HEIGHT 768 +#define TL_IMAGE_SAVED_QUALITY 90 // 1 to 100 +// in timeline posts, the quality should not be high in order to speed up the loading of images + /*****************************************************************************/ /******************************** Public types *******************************/ /*****************************************************************************/ -#define TL_NUM_NOTE_TYPES 13 -// If the numbers assigned to each event type change, -// it is necessary to change old numbers to new ones in database table tl_notes -typedef enum - { - TL_NOTE_UNKNOWN = 0, - /* Start tab */ - TL_NOTE_POST = 10, // Post written directly in timeline - /* Institution tab */ - TL_NOTE_INS_DOC_PUB_FILE = 1, // Public file in documents of institution - TL_NOTE_INS_SHA_PUB_FILE = 2, // Public file in shared files of institution - /* Centre tab */ - TL_NOTE_CTR_DOC_PUB_FILE = 3, // Public file in documents of centre - TL_NOTE_CTR_SHA_PUB_FILE = 4, // Public file in shared files of centre - /* Degree tab */ - TL_NOTE_DEG_DOC_PUB_FILE = 5, // Public file in documents of degree - TL_NOTE_DEG_SHA_PUB_FILE = 6, // Public file in shared files of degree - /* Course tab */ - TL_NOTE_CRS_DOC_PUB_FILE = 7, // Public file in documents of course - TL_NOTE_CRS_SHA_PUB_FILE = 8, // Public file in shared files of course - /* Assessment tab */ - TL_NOTE_EXAM_ANNOUNCEMENT = 9, // Exam announcement in a course - /* Users tab */ - /* Messages tab */ - TL_NOTE_NOTICE = 12, // A public notice in a course - TL_NOTE_FORUM_POST = 11, // Post in global/swad forums - /* Analytics tab */ - /* Profile tab */ - } TL_NoteType_t; - #define TL_NUM_TOP_MESSAGES (1 + 6) typedef enum { @@ -144,40 +130,37 @@ struct TL_Publication struct TL_PostContent { char Txt[Cns_MAX_BYTES_LONG_TEXT + 1]; - struct Media Media; + struct Med_Media Media; }; -struct TL_Note +typedef enum { - long NotCod; // Unique code/identifier for each note - TL_NoteType_t NoteType; // Timeline post, public file, exam announcement, notice, forum post... - long UsrCod; // Publisher - long HieCod; // Hierarchy code (institution/centre/degree/course) - long Cod; // Code of file, forum post, notice, timeline post... - bool Unavailable; // File, forum post, notice,... unavailable (removed) - time_t DateTimeUTC; // Date-time of publication in UTC time - unsigned NumShared; // Number of times (users) this note has been shared - unsigned NumFavs; // Number of times (users) this note has been favourited - }; + TL_DONT_HIGHLIGHT, + TL_HIGHLIGHT, + } TL_Highlight_t; -struct TL_Comment +typedef enum { - long PubCod; // Unique code/identifier for each publication - long UsrCod; // Publisher - long NotCod; // Note code to which this comment belongs - time_t DateTimeUTC; // Date-time of publication in UTC time - unsigned NumFavs; // Number of times (users) this comment has been favourited - struct TL_PostContent Content; - }; + TL_DONT_SHOW_ALONE, + TL_SHOW_ALONE, + } TL_ShowAlone_t; /*****************************************************************************/ /****************************** Public prototypes ****************************/ /*****************************************************************************/ +void TL_InitTimelineGbl (struct TL_Timeline *Timeline); + void TL_ResetTimeline (struct TL_Timeline *Timeline); + void TL_ShowTimelineGbl (void); +void TL_ShowNoteAndTimelineGbl (struct TL_Timeline *Timeline); +void TL_ShowTimelineGblHighlightingNot (struct TL_Timeline *Timeline, + long NotCod); void TL_ShowTimelineUsr (struct TL_Timeline *Timeline); +void TL_ShowTimelineUsrHighlightingNot (struct TL_Timeline *Timeline, + long NotCod); void TL_RefreshNewTimelineGbl (void); @@ -186,44 +169,35 @@ void TL_RefreshOldTimelineUsr (void); void TL_MarkMyNotifAsSeen (void); +void TL_FormStart (const struct TL_Timeline *Timeline, + Act_Action_t ActionGbl, + Act_Action_t ActionUsr); + void TL_GetParamWho (void); Usr_Who_t TL_GetGlobalWho (void); -void TL_StoreAndPublishNote (TL_NoteType_t NoteType,long Cod); -void TL_MarkNoteAsUnavailable (TL_NoteType_t NoteType,long Cod); -void TL_MarkNoteOneFileAsUnavailable (const char *Path); -void TL_MarkNotesChildrenOfFolderAsUnavailable (const char *Path); +void TL_WriteTopMessage (TL_TopMessage_t TopMessage,long PublisherCod); -void TL_PublishNoteInTimeline (struct TL_Publication *Pub); +void TL_WriteDateTime (time_t TimeUTC); + +void TL_GetAndWritePost (long PstCod); + +void TL_PublishPubInTimeline (struct TL_Publication *Pub); + +void TL_PutTextarea (const char *Placeholder,const char *ClassTextArea); void TL_ReceivePostUsr (void); void TL_ReceivePostGbl (void); -void TL_ShowHiddenCommentsUsr (void); -void TL_ShowHiddenCommentsGbl (void); +void TL_Com_ShowHiddenCommentsUsr (void); +void TL_Com_ShowHiddenCommentsGbl (void); void TL_PutHiddenParamPubCod (long PubCod); -long TL_GetParamNotCod (void); long TL_GetParamPubCod (void); -void TL_ReceiveCommentUsr (void); -void TL_ReceiveCommentGbl (void); - void TL_CreateNotifToAuthor (long AuthorCod,long PubCod, Ntf_NotifyEvent_t NotifyEvent); -void TL_RequestRemNoteUsr (void); -void TL_RequestRemNoteGbl (void); -void TL_RemoveNoteUsr (void); -void TL_RemoveNoteGbl (void); - -long TL_GetPubCodOfOriginalNote (long NotCod); - -void TL_RequestRemComUsr (void); -void TL_RequestRemComGbl (void); -void TL_RemoveComUsr (void); -void TL_RemoveComGbl (void); - void TL_RemoveUsrContent (long UsrCod); void TL_ShowNumSharersOrFavers (unsigned NumUsrs); @@ -236,9 +210,6 @@ void TL_FormFavSha (Act_Action_t ActionGbl,Act_Action_t ActionUsr, const char *ParamFormat,long ParamCod, const char *Icon,const char *Title); -void TL_GetDataOfNoteByCod (struct TL_Note *Not); -void TL_GetDataOfCommByCod (struct TL_Comment *Com); - void TL_ClearOldTimelinesDB (void); void TL_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1], diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c new file mode 100644 index 00000000..ad7a7aaf --- /dev/null +++ b/swad_timeline_comment.c @@ -0,0 +1,1154 @@ +// swad_timeline_comment.c: social timeline comments + +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 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 + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/*********************************** Headers *********************************/ +/*****************************************************************************/ + +#define _GNU_SOURCE // For asprintf +#include // For PATH_MAX +#include // For asprintf + +#include "swad_database.h" +#include "swad_forum.h" +#include "swad_global.h" +#include "swad_message.h" +#include "swad_photo.h" +#include "swad_profile.h" +#include "swad_timeline.h" +#include "swad_timeline_favourite.h" +#include "swad_timeline_note.h" +#include "swad_timeline_share.h" + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************************* Private constants and types ***********************/ +/*****************************************************************************/ + +#define TL_COM_NUM_VISIBLE_COMMENTS 3 // Maximum number of comments visible before expanding them + +/*****************************************************************************/ +/************** External global variables from others modules ****************/ +/*****************************************************************************/ + +extern struct Globals Gbl; + +/*****************************************************************************/ +/************************* Private global variables **************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private prototypes ****************************/ +/*****************************************************************************/ + +static void TL_Com_FormToShowHiddenComments (Act_Action_t ActionGbl,Act_Action_t ActionUsr, + long NotCod, + char IdComments[Frm_MAX_BYTES_ID + 1], + unsigned NumInitialComments); +static unsigned TL_Com_WriteHiddenComments (struct TL_Timeline *Timeline, + long NotCod, + char IdComments[Frm_MAX_BYTES_ID + 1], + unsigned NumInitialCommentsToGet); +static void TL_Com_WriteOneCommentInList (struct TL_Timeline *Timeline, + MYSQL_RES *mysql_res); +static void TL_Com_LinkToShowOnlyLatestComments (const char IdComments[Frm_MAX_BYTES_ID + 1]); +static void TL_Com_LinkToShowPreviousComments (const char IdComments[Frm_MAX_BYTES_ID + 1], + unsigned NumInitialComments); +static void TL_Com_PutIconToToggleComments (const char *UniqueId, + const char *Icon,const char *Text); +static void TL_Com_WriteComment (struct TL_Timeline *Timeline, + struct TL_Com_Comment *Com, + TL_TopMessage_t TopMessage,long UsrCod, + TL_ShowAlone_t ShowCommentAlone); // Comment is shown alone, not in a list +static void TL_Com_WriteAuthorComment (struct UsrData *UsrDat); + +static void TL_Com_PutFormToRemoveComment (const struct TL_Timeline *Timeline, + long PubCod); + +static long TL_Com_ReceiveComment (void); + +static void TL_Com_RequestRemovalComment (struct TL_Timeline *Timeline); +static void TL_Com_PutParamsRemoveComment (void *Timeline); +static void TL_Com_RemoveComment (void); + +static void TL_Com_GetDataOfCommentFromRow (MYSQL_ROW row,struct TL_Com_Comment *Com); + +static void TL_Com_ResetComment (struct TL_Com_Comment *Com); + +/*****************************************************************************/ +/********* Put an icon to toggle on/off the form to comment a note ***********/ +/*****************************************************************************/ + +void TL_Com_PutIconToToggleComment (const char UniqueId[Frm_MAX_BYTES_ID + 1]) + { + extern const char *Txt_Comment; + + /***** Link to toggle on/off the form to comment a note *****/ + HTM_DIV_Begin ("id=\"%s_ico\" class=\"TL_ICO_COM_OFF\"",UniqueId); + HTM_A_Begin ("href=\"\" onclick=\"toggleNewComment ('%s');return false;\"", + UniqueId); + Ico_PutIcon ("comment-regular.svg",Txt_Comment,"CONTEXT_ICO_16x16"); + HTM_A_End (); + HTM_DIV_End (); + } + +/*****************************************************************************/ +/********** Put an icon to toggle on/off the form to comment a note **********/ +/*****************************************************************************/ + +void TL_Com_PutIconCommentDisabled (void) + { + extern const char *Txt_Comment; + + /***** Disabled icon to comment a note *****/ + HTM_DIV_Begin ("class=\"TL_ICO_COM_OFF TL_ICO_DISABLED\""); + Ico_PutIcon ("edit.svg",Txt_Comment,"ICO16x16"); + HTM_DIV_End (); + } + +/*****************************************************************************/ +/************************* Form to comment a note ****************************/ +/*****************************************************************************/ + +void TL_Com_PutHiddenFormToWriteNewComment (const struct TL_Timeline *Timeline, + long NotCod, + const char IdNewComment[Frm_MAX_BYTES_ID + 1]) + { + extern const char *Txt_New_TIMELINE_comment; + bool ShowPhoto = false; + char PhotoURL[PATH_MAX + 1]; + + /***** Start container *****/ + HTM_DIV_Begin ("id=\"%s\" class=\"TL_FORM_NEW_COM TL_RIGHT_WIDTH\"" + " style=\"display:none;\"", + IdNewComment); + + /***** Left: write author's photo (my photo) *****/ + HTM_DIV_Begin ("class=\"TL_COM_PHOTO\""); + ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&Gbl.Usrs.Me.UsrDat,PhotoURL); + Pho_ShowUsrPhoto (&Gbl.Usrs.Me.UsrDat,ShowPhoto ? PhotoURL : + NULL, + "PHOTO30x40",Pho_ZOOM,true); // Use unique id + HTM_DIV_End (); + + /***** Right: form to write the comment *****/ + /* Start right container */ + HTM_DIV_Begin ("class=\"TL_COM_CONT TL_COMM_WIDTH\""); + + /* Begin form to write the post */ + TL_FormStart (Timeline,ActRcvTL_ComGbl,ActRcvTL_ComUsr); + TL_Not_PutHiddenParamNotCod (NotCod); + + /* Textarea and button */ + TL_PutTextarea (Txt_New_TIMELINE_comment, + "TL_COM_TEXTAREA TL_COMM_WIDTH"); + + /* End form */ + Frm_EndForm (); + + /* End right container */ + HTM_DIV_End (); + + /***** End container *****/ + HTM_DIV_End (); + } + +/*****************************************************************************/ +/********************* Get number of comments in a note **********************/ +/*****************************************************************************/ + +unsigned long TL_Com_GetNumCommentsInNote (long NotCod) + { + return DB_QueryCOUNT ("can not get number of comments in a note", + "SELECT COUNT(*) FROM tl_pubs" + " WHERE NotCod=%ld AND PubType=%u", + NotCod,(unsigned) TL_PUB_COMMENT_TO_NOTE); + } + +/*****************************************************************************/ +/*********************** Write comments in a note ****************************/ +/*****************************************************************************/ + +void TL_Com_WriteCommentsInNote (struct TL_Timeline *Timeline, + const struct TL_Not_Note *Not, + unsigned NumComments) + { + MYSQL_RES *mysql_res; + unsigned NumInitialComments; + unsigned NumFinalCommentsToGet; + unsigned NumFinalCommentsGot; + unsigned NumCom; + char IdComments[Frm_MAX_BYTES_ID + 1]; + + /***** Compute how many initial comments will be hidden + and how many final comments will be visible *****/ + // Never hide only one comment + // So, the number of comments initially hidden must be 0 or >= 2 + if (NumComments <= TL_COM_NUM_VISIBLE_COMMENTS + 1) + { + NumInitialComments = 0; + NumFinalCommentsToGet = NumComments; + } + else + { + NumInitialComments = NumComments - TL_COM_NUM_VISIBLE_COMMENTS; + NumFinalCommentsToGet = TL_COM_NUM_VISIBLE_COMMENTS; + } + + /***** Get last comments of this note from database *****/ + NumFinalCommentsGot = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get comments", + "SELECT * FROM " + "(" + "SELECT tl_pubs.PubCod," // row[0] + "tl_pubs.PublisherCod," // row[1] + "tl_pubs.NotCod," // row[2] + "UNIX_TIMESTAMP(" + "tl_pubs.TimePublish)," // row[3] + "tl_comments.Txt," // row[4] + "tl_comments.MedCod" // row[5] + " FROM tl_pubs,tl_comments" + " WHERE tl_pubs.NotCod=%ld" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments.PubCod" + " ORDER BY tl_pubs.PubCod DESC LIMIT %u" + ") AS comments" + " ORDER BY PubCod", + Not->NotCod,(unsigned) TL_PUB_COMMENT_TO_NOTE, + NumFinalCommentsToGet); + + /* + Before clicking "See prev..." --> After clicking "See prev..." + _________________________________ _________________________________ + | div con_ | | div con_ | + | (hidden) | | (visible) | + | _____________________________ | | _____________________________ | + | | v See only the latest | | | | v See only the latest | | + | |_____________________________| | | |_____________________________| | + |_________________________________| |_________________________________| + _________________________________ _________________________________ + | div | | div updated | + | which content | | _____________________________ | + | will be updated via AJAX | | | ul com_ | | + | (parent of parent of form) | | | _________________________ | | + | | | | | li (comment 1) | | | + | | | | |_________________________| | | + | | | | | ... | | | + | | | | |_________________________| | | + | | | | | li (comment n) | | | + | | --> | | |_________________________| | | + | | | |_____________________________| | + | _____________________________ | | _____________________________ | + | | div exp_ | | | | div exp_ | | + | | _________________________ | | | | (hidden) | | + | | | form | | | | | | | + | | | _____________________ | | | | | _____________________ | | + | | | | ^ See prev.comments | | | | | | | ^ See prev.comments | | | + | | | |_____________________| | | | | | |_____________________| | | + | | |_________________________| | | | | | | + | |_____________________________| | | |_____________________________| | + |_________________________________| |_________________________________| + _________________________________ _________________________________ + | ul com_ | | ul com_ | + | _________________________ | | _________________________ | + | | li (comment 1) | | | | li (comment 1) | | + | |_________________________| | | |_________________________| | + | | ... | | | | ... | | + | |_________________________| | | |_________________________| | + | | li (comment n) | | | | li (comment n) | | + | |_________________________| | | |_________________________| | + |_________________________________| |_________________________________| + */ + /***** Link to show initial hidden comments *****/ + if (NumInitialComments) + { + /***** Create unique id for list of hidden comments *****/ + Frm_SetUniqueId (IdComments); + + /***** Link (initially hidden) to show only the latest comments *****/ + TL_Com_LinkToShowOnlyLatestComments (IdComments); + + /***** Div which content will be updated via AJAX *****/ + HTM_DIV_Begin ("id=\"%s\" class=\"TL_RIGHT_WIDTH\"",IdComments); + TL_Com_FormToShowHiddenComments (ActShoHidTL_ComGbl,ActShoHidTL_ComUsr, + Not->NotCod, + IdComments, + NumInitialComments); + HTM_DIV_End (); + } + + /***** List final visible comments *****/ + if (NumFinalCommentsGot) + { + HTM_UL_Begin ("class=\"TL_LIST\""); + for (NumCom = 0; + NumCom < NumFinalCommentsGot; + NumCom++) + TL_Com_WriteOneCommentInList (Timeline,mysql_res); + HTM_UL_End (); + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + +/*****************************************************************************/ +/********** Form to show hidden coments in global or user timeline ***********/ +/*****************************************************************************/ + +static void TL_Com_FormToShowHiddenComments (Act_Action_t ActionGbl,Act_Action_t ActionUsr, + long NotCod, + char IdComments[Frm_MAX_BYTES_ID + 1], + unsigned NumInitialComments) + { + extern const char *The_ClassFormLinkInBox[The_NUM_THEMES]; + extern const char *Txt_See_the_previous_X_COMMENTS; + char *OnSubmit; + + HTM_DIV_Begin ("id=\"exp_%s\" class=\"TL_EXPAND_COM TL_RIGHT_WIDTH\"", + IdComments); + + /***** Form and icon-text to show hidden comments *****/ + /* Begin form */ + if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) + { + if (asprintf (&OnSubmit,"toggleComments('%s');" + "updateDivHiddenComments(this," + "'act=%ld&ses=%s&NotCod=%ld&IdComments=%s&NumHidCom=%u&OtherUsrCod=%s');" + " return false;", // return false is necessary to not submit form + IdComments, + Act_GetActCod (ActionUsr), + Gbl.Session.Id, + NotCod, + IdComments, + NumInitialComments, + Gbl.Usrs.Other.UsrDat.EncryptedUsrCod) < 0) + Lay_NotEnoughMemoryExit (); + Frm_StartFormUniqueAnchorOnSubmit (ActUnk,"timeline",OnSubmit); + } + else + { + if (asprintf (&OnSubmit,"toggleComments('%s');" + "updateDivHiddenComments(this," + "'act=%ld&ses=%s&NotCod=%ld&IdComments=%s&NumHidCom=%u');" + " return false;", // return false is necessary to not submit form + IdComments, + Act_GetActCod (ActionGbl), + Gbl.Session.Id, + NotCod, + IdComments, + NumInitialComments) < 0) + Lay_NotEnoughMemoryExit (); + Frm_StartFormUniqueAnchorOnSubmit (ActUnk,NULL,OnSubmit); + } + + /* Put icon and text with link to show the first hidden comments */ + HTM_BUTTON_SUBMIT_Begin (NULL,The_ClassFormLinkInBox[Gbl.Prefs.Theme],NULL); + Ico_PutIconTextLink ("angle-up.svg", + Str_BuildStringLong (Txt_See_the_previous_X_COMMENTS, + (long) NumInitialComments)); + Str_FreeString (); + HTM_BUTTON_End (); + + /* End form */ + Frm_EndForm (); + + /* Free allocated memory */ + free (OnSubmit); + + HTM_DIV_End (); + } + +/*****************************************************************************/ +/********************** Write hidden comments via AJAX ***********************/ +/*****************************************************************************/ + +void TL_Com_ShowHiddenCommentsUsr (void) + { + /***** Get user whom profile is displayed *****/ + Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); + + /***** Show hidden comments *****/ + TL_Com_ShowHiddenCommentsGbl (); + } + +void TL_Com_ShowHiddenCommentsGbl (void) + { + struct TL_Timeline Timeline; + long NotCod; + char IdComments[Frm_MAX_BYTES_ID + 1]; + unsigned NumInitialCommentsToGet; + unsigned NumInitialCommentsGot; + + /***** Reset timeline context *****/ + TL_ResetTimeline (&Timeline); + + /***** Get parameters *****/ + /* Get note code */ + NotCod = TL_Not_GetParamNotCod (); + + /* Get identifier */ + Par_GetParToText ("IdComments",IdComments,Frm_MAX_BYTES_ID); + + /* Get number of comments to get */ + NumInitialCommentsToGet = (unsigned) Par_GetParToLong ("NumHidCom"); + + /***** Write HTML inside DIV with hidden comments *****/ + NumInitialCommentsGot = TL_Com_WriteHiddenComments (&Timeline, + NotCod,IdComments,NumInitialCommentsToGet); + + /***** Link to show the first comments *****/ + TL_Com_LinkToShowPreviousComments (IdComments,NumInitialCommentsGot); + } + +/*****************************************************************************/ +/**************************** Write hidden comments **************************/ +/*****************************************************************************/ +// Returns the number of comments got + +static unsigned TL_Com_WriteHiddenComments (struct TL_Timeline *Timeline, + long NotCod, + char IdComments[Frm_MAX_BYTES_ID + 1], + unsigned NumInitialCommentsToGet) + { + MYSQL_RES *mysql_res; + unsigned long NumInitialCommentsGot; + unsigned long NumCom; + + /***** Get comments of this note from database *****/ + NumInitialCommentsGot = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get comments", + "SELECT tl_pubs.PubCod," // row[0] + "tl_pubs.PublisherCod," // row[1] + "tl_pubs.NotCod," // row[2] + "UNIX_TIMESTAMP(" + "tl_pubs.TimePublish)," // row[3] + "tl_comments.Txt," // row[4] + "tl_comments.MedCod" // row[5] + " FROM tl_pubs,tl_comments" + " WHERE tl_pubs.NotCod=%ld" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments.PubCod" + " ORDER BY tl_pubs.PubCod" + " LIMIT %lu", + NotCod,(unsigned) TL_PUB_COMMENT_TO_NOTE, + NumInitialCommentsToGet); + + /***** List with comments *****/ + HTM_UL_Begin ("id=\"com_%s\" class=\"TL_LIST\"",IdComments); + for (NumCom = 0; + NumCom < NumInitialCommentsGot; + NumCom++) + TL_Com_WriteOneCommentInList (Timeline,mysql_res); + HTM_UL_End (); + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + + return NumInitialCommentsGot; + } + +/*****************************************************************************/ +/************************* Write a comment in list ***************************/ +/*****************************************************************************/ + +static void TL_Com_WriteOneCommentInList (struct TL_Timeline *Timeline, + MYSQL_RES *mysql_res) + { + MYSQL_ROW row; + struct TL_Com_Comment Com; + + /***** Initialize image *****/ + Med_MediaConstructor (&Com.Content.Media); + + /***** Get data of comment *****/ + row = mysql_fetch_row (mysql_res); + TL_Com_GetDataOfCommentFromRow (row,&Com); + + /***** Write comment *****/ + TL_Com_WriteComment (Timeline,&Com, + TL_TOP_MESSAGE_NONE,-1L, + TL_DONT_SHOW_ALONE); + + /***** Free image *****/ + Med_MediaDestructor (&Com.Content.Media); + } + +/*****************************************************************************/ +/****************** Link to show only the latest comments ********************/ +/*****************************************************************************/ + +static void TL_Com_LinkToShowOnlyLatestComments (const char IdComments[Frm_MAX_BYTES_ID + 1]) + { + extern const char *Txt_See_only_the_latest_COMMENTS; + + /***** Icon and text to show only the latest comments ****/ + HTM_DIV_Begin ("id=\"con_%s\" class=\"TL_EXPAND_COM TL_RIGHT_WIDTH\"" + " style=\"display:none;\"", // Hidden + IdComments); + TL_Com_PutIconToToggleComments (IdComments,"angle-down.svg", + Txt_See_only_the_latest_COMMENTS); + HTM_DIV_End (); + } + +/*****************************************************************************/ +/********************* Link to show the first comments ***********************/ +/*****************************************************************************/ + +static void TL_Com_LinkToShowPreviousComments (const char IdComments[Frm_MAX_BYTES_ID + 1], + unsigned NumInitialComments) + { + extern const char *Txt_See_the_previous_X_COMMENTS; + + /***** Icon and text to show only the latest comments ****/ + HTM_DIV_Begin ("id=\"exp_%s\" class=\"TL_EXPAND_COM TL_RIGHT_WIDTH\"" + " style=\"display:none;\"", // Hidden + IdComments); + TL_Com_PutIconToToggleComments (IdComments,"angle-up.svg", + Str_BuildStringLong (Txt_See_the_previous_X_COMMENTS, + (long) NumInitialComments)); + Str_FreeString (); + HTM_DIV_End (); + } + +/*****************************************************************************/ +/********** Put an icon to toggle on/off comments in a publication ***********/ +/*****************************************************************************/ + +static void TL_Com_PutIconToToggleComments (const char *UniqueId, + const char *Icon,const char *Text) + { + extern const char *The_ClassFormLinkInBox[The_NUM_THEMES]; + char *OnClick; + + if (asprintf (&OnClick,"toggleComments('%s')",UniqueId) < 0) + Lay_NotEnoughMemoryExit (); + + /***** Link to toggle on/off some divs *****/ + HTM_BUTTON_BUTTON_Begin (Text,The_ClassFormLinkInBox[Gbl.Prefs.Theme],OnClick); + Ico_PutIconTextLink (Icon,Text); + HTM_BUTTON_End (); + + free (OnClick); + } + +/*****************************************************************************/ +/******************************** Write comment ******************************/ +/*****************************************************************************/ + +static void TL_Com_WriteComment (struct TL_Timeline *Timeline, + struct TL_Com_Comment *Com, + TL_TopMessage_t TopMessage,long UsrCod, + TL_ShowAlone_t ShowCommentAlone) // Comment is shown alone, not in a list + { + struct UsrData UsrDat; + bool IAmTheAuthor; + bool ShowPhoto = false; + char PhotoURL[PATH_MAX + 1]; + static unsigned NumDiv = 0; // Used to create unique div id for fav + + NumDiv++; + + if (ShowCommentAlone == TL_SHOW_ALONE) + { + Box_BoxBegin (NULL,NULL, + NULL,NULL, + NULL,Box_NOT_CLOSABLE); + + /***** Write sharer/commenter if distinct to author *****/ + TL_WriteTopMessage (TopMessage,UsrCod); + + HTM_DIV_Begin ("class=\"TL_LEFT_PHOTO\""); + HTM_DIV_End (); + + HTM_DIV_Begin ("class=\"TL_RIGHT_CONT TL_RIGHT_WIDTH\""); + HTM_UL_Begin ("class=\"LIST_LEFT\""); + } + + /***** Start list item *****/ + HTM_LI_Begin (ShowCommentAlone == TL_SHOW_ALONE ? NULL : + "class=\"TL_COM\""); + + if (Com->PubCod <= 0 || + Com->NotCod <= 0 || + Com->UsrCod <= 0) + Ale_ShowAlert (Ale_ERROR,"Error in comment."); + else + { + /***** Get author's data *****/ + Usr_UsrDataConstructor (&UsrDat); + UsrDat.UsrCod = Com->UsrCod; + Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,Usr_DONT_GET_PREFS); + IAmTheAuthor = Usr_ItsMe (UsrDat.UsrCod); + + /***** Left: write author's photo *****/ + HTM_DIV_Begin ("class=\"TL_COM_PHOTO\""); + ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&UsrDat,PhotoURL); + Pho_ShowUsrPhoto (&UsrDat,ShowPhoto ? PhotoURL : + NULL, + "PHOTO30x40",Pho_ZOOM,true); // Use unique id + HTM_DIV_End (); + + /***** Right: author's name, time, content, image and buttons *****/ + HTM_DIV_Begin ("class=\"TL_COM_CONT TL_COMM_WIDTH\""); + + /* Write author's full name and nickname */ + TL_Com_WriteAuthorComment (&UsrDat); + + /* Write date and time */ + TL_WriteDateTime (Com->DateTimeUTC); + + /* Write content of the comment */ + if (Com->Content.Txt[0]) + { + HTM_DIV_Begin ("class=\"TL_TXT\""); + Msg_WriteMsgContent (Com->Content.Txt,Cns_MAX_BYTES_LONG_TEXT,true,false); + HTM_DIV_End (); + } + + /* Show image */ + Med_ShowMedia (&Com->Content.Media,"TL_COM_MED_CONT TL_COMM_WIDTH", + "TL_COM_MED TL_COMM_WIDTH"); + + /* Start foot container */ + HTM_DIV_Begin ("class=\"TL_FOOT TL_COMM_WIDTH\""); + + /* Fav zone */ + HTM_DIV_Begin ("id=\"fav_com_%s_%u\" class=\"TL_FAV_COM TL_FAV_WIDTH\"", + Gbl.UniqueNameEncrypted,NumDiv); + TL_Fav_PutFormToFavUnfComment (Com,TL_SHOW_FEW_USRS); + HTM_DIV_End (); + + /* Put icon to remove this comment */ + HTM_DIV_Begin ("class=\"TL_REM\""); + if (IAmTheAuthor && + ShowCommentAlone == TL_DONT_SHOW_ALONE) + TL_Com_PutFormToRemoveComment (Timeline,Com->PubCod); + HTM_DIV_End (); + + /* End foot container */ + HTM_DIV_End (); + + /***** Free memory used for user's data *****/ + Usr_UsrDataDestructor (&UsrDat); + } + + /***** End list item *****/ + HTM_LI_End (); + + if (ShowCommentAlone == TL_SHOW_ALONE) + { + HTM_UL_End (); + HTM_DIV_End (); + Box_BoxEnd (); + } + } + +/*****************************************************************************/ +/********* Write name and nickname of author of a comment to a note **********/ +/*****************************************************************************/ + +static void TL_Com_WriteAuthorComment (struct UsrData *UsrDat) + { + extern const char *Txt_My_public_profile; + extern const char *Txt_Another_user_s_profile; + bool ItsMe = Usr_ItsMe (UsrDat->UsrCod); + + /***** Show user's name inside form to go to user's public profile *****/ + Frm_StartFormUnique (ActSeeOthPubPrf); + Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); + HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile : + Txt_Another_user_s_profile, + "BT_LINK TL_COM_AUTHOR TL_COMM_AUTHOR_WIDTH DAT_BOLD",NULL); + HTM_Txt (UsrDat->FullName); + HTM_BUTTON_End (); + Frm_EndForm (); + } + +/*****************************************************************************/ +/************************* Form to remove comment ****************************/ +/*****************************************************************************/ + +static void TL_Com_PutFormToRemoveComment (const struct TL_Timeline *Timeline, + long PubCod) + { + extern const char *Txt_Remove; + + /***** Form to remove publication *****/ + TL_FormStart (Timeline,ActReqRemTL_ComGbl,ActReqRemTL_ComUsr); + TL_PutHiddenParamPubCod (PubCod); + Ico_PutIconLink ("trash.svg",Txt_Remove); + Frm_EndForm (); + } + +/*****************************************************************************/ +/******************************* Comment a note ******************************/ +/*****************************************************************************/ + +void TL_Com_ReceiveCommentUsr (void) + { + struct TL_Timeline Timeline; + long NotCod; + + /***** Reset timeline context *****/ + TL_ResetTimeline (&Timeline); + + /***** Get user whom profile is displayed *****/ + Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); + + /***** Show user's profile *****/ + Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat); + + /***** Start section *****/ + HTM_SECTION_Begin (TL_TIMELINE_SECTION_ID); + + /***** Receive comment in a note + and write updated timeline after commenting (user) *****/ + NotCod = TL_Com_ReceiveComment (); + TL_ShowTimelineUsrHighlightingNot (&Timeline,NotCod); + + /***** End section *****/ + HTM_SECTION_End (); + } + +void TL_Com_ReceiveCommentGbl (void) + { + struct TL_Timeline Timeline; + long NotCod; + + /***** Initialize timeline *****/ + TL_InitTimelineGbl (&Timeline); + + /***** Receive comment in a note *****/ + NotCod = TL_Com_ReceiveComment (); + + /***** Write updated timeline after commenting (global) *****/ + TL_ShowTimelineGblHighlightingNot (&Timeline,NotCod); + } + +static long TL_Com_ReceiveComment (void) + { + extern const char *Txt_The_original_post_no_longer_exists; + struct TL_PostContent Content; + struct TL_Not_Note Not; + struct TL_Publication Pub; + + /***** Get data of note *****/ + Not.NotCod = TL_Not_GetParamNotCod (); + TL_Not_GetDataOfNoteByCod (&Not); + + if (Not.NotCod > 0) + { + /***** Get the content of the comment *****/ + Par_GetParAndChangeFormat ("Txt",Content.Txt,Cns_MAX_BYTES_LONG_TEXT, + Str_TO_RIGOROUS_HTML,true); + + /***** Initialize image *****/ + Med_MediaConstructor (&Content.Media); + + /***** Get attached image (action, file and title) *****/ + Content.Media.Width = TL_IMAGE_SAVED_MAX_WIDTH; + Content.Media.Height = TL_IMAGE_SAVED_MAX_HEIGHT; + Content.Media.Quality = TL_IMAGE_SAVED_QUALITY; + Med_GetMediaFromForm (-1L,-1L,-1,&Content.Media,NULL,NULL); + Ale_ShowAlerts (NULL); + + if (Content.Txt[0] || // Text not empty + Content.Media.Status == Med_PROCESSED) // A media is attached + { + /***** Store media in filesystem and database *****/ + Med_RemoveKeepOrStoreMedia (-1L,&Content.Media); + + /***** Publish *****/ + /* Insert into publications */ + Pub.NotCod = Not.NotCod; + Pub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod; + Pub.PubType = TL_PUB_COMMENT_TO_NOTE; + TL_PublishPubInTimeline (&Pub); // Set Pub.PubCod + + /* Insert comment content in the database */ + DB_QueryINSERT ("can not store comment content", + "INSERT INTO tl_comments" + " (PubCod,Txt,MedCod)" + " VALUES" + " (%ld,'%s',%ld)", + Pub.PubCod, + Content.Txt, + Content.Media.MedCod); + + /***** Store notifications about the new comment *****/ + Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_TIMELINE_COMMENT,Pub.PubCod); + + /***** Analyze content and store notifications about mentions *****/ + Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (Pub.PubCod,Content.Txt); + } + + /***** Free image *****/ + Med_MediaDestructor (&Content.Media); + } + else + Ale_ShowAlert (Ale_WARNING,Txt_The_original_post_no_longer_exists); + + return Not.NotCod; + } + + +/*****************************************************************************/ +/**************** Request the removal of a comment in a note *****************/ +/*****************************************************************************/ + +void TL_Com_RequestRemComUsr (void) + { + struct TL_Timeline Timeline; + + /***** Reset timeline context *****/ + TL_ResetTimeline (&Timeline); + + /***** Get user whom profile is displayed *****/ + Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); + + /***** Show user's profile *****/ + Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat); + + /***** Start section *****/ + HTM_SECTION_Begin (TL_TIMELINE_SECTION_ID); + + /***** Request the removal of comment in note *****/ + TL_Com_RequestRemovalComment (&Timeline); + + /***** Write timeline again (user) *****/ + TL_ShowTimelineUsr (&Timeline); + + /***** End section *****/ + HTM_SECTION_End (); + } + +void TL_Com_RequestRemComGbl (void) + { + struct TL_Timeline Timeline; + + /***** Initialize timeline *****/ + TL_InitTimelineGbl (&Timeline); + + /***** Request the removal of comment in note *****/ + TL_Com_RequestRemovalComment (&Timeline); + + /***** Write timeline again (global) *****/ + TL_ShowNoteAndTimelineGbl (&Timeline); + } + +static void TL_Com_RequestRemovalComment (struct TL_Timeline *Timeline) + { + extern const char *Txt_The_comment_no_longer_exists; + extern const char *Txt_Do_you_really_want_to_remove_the_following_comment; + extern const char *Txt_Remove; + struct TL_Com_Comment Com; + bool ItsMe; + + /***** Initialize image *****/ + Med_MediaConstructor (&Com.Content.Media); + + /***** Get data of comment *****/ + Com.PubCod = TL_GetParamPubCod (); + TL_Com_GetDataOfCommByCod (&Com); + + if (Com.PubCod > 0) + { + ItsMe = Usr_ItsMe (Com.UsrCod); + if (ItsMe) // I am the author of this comment + { + /***** Show question and button to remove comment *****/ + /* Start alert */ + Ale_ShowAlertAndButton1 (Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_following_comment); + + /* Show comment */ + TL_Com_WriteComment (Timeline,&Com, + TL_TOP_MESSAGE_NONE,-1L, + TL_SHOW_ALONE); + + /* End alert */ + Timeline->PubCod = Com.PubCod; // Publication to be removed + if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) + Ale_ShowAlertAndButton2 (ActRemTL_ComUsr,"timeline",NULL, + TL_Com_PutParamsRemoveComment,Timeline, + Btn_REMOVE_BUTTON,Txt_Remove); + else + Ale_ShowAlertAndButton2 (ActRemTL_ComGbl,NULL,NULL, + TL_Com_PutParamsRemoveComment,Timeline, + Btn_REMOVE_BUTTON,Txt_Remove); + } + } + else + Ale_ShowAlert (Ale_WARNING,Txt_The_comment_no_longer_exists); + + /***** Free image *****/ + Med_MediaDestructor (&Com.Content.Media); + } + +/*****************************************************************************/ +/******************** Put parameters to remove a comment *********************/ +/*****************************************************************************/ + +static void TL_Com_PutParamsRemoveComment (void *Timeline) + { + if (Timeline) + { + if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) + Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod); + else + Usr_PutHiddenParamWho (((struct TL_Timeline *) Timeline)->Who); + TL_PutHiddenParamPubCod (((struct TL_Timeline *) Timeline)->PubCod); + } + } + +/*****************************************************************************/ +/***************************** Remove a comment ******************************/ +/*****************************************************************************/ + +void TL_Com_RemoveComUsr (void) + { + struct TL_Timeline Timeline; + + /***** Reset timeline context *****/ + TL_ResetTimeline (&Timeline); + + /***** Get user whom profile is displayed *****/ + Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); + + /***** Show user's profile *****/ + Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat); + + /***** Start section *****/ + HTM_SECTION_Begin (TL_TIMELINE_SECTION_ID); + + /***** Remove a comment *****/ + TL_Com_RemoveComment (); + + /***** Write updated timeline after removing (user) *****/ + TL_ShowTimelineUsr (&Timeline); + + /***** End section *****/ + HTM_SECTION_End (); + } + +void TL_Com_RemoveComGbl (void) + { + struct TL_Timeline Timeline; + + /***** Initialize timeline *****/ + TL_InitTimelineGbl (&Timeline); + + /***** Remove a comment *****/ + TL_Com_RemoveComment (); + + /***** Write updated timeline after removing (global) *****/ + TL_ShowNoteAndTimelineGbl (&Timeline); + } + +static void TL_Com_RemoveComment (void) + { + extern const char *Txt_The_comment_no_longer_exists; + extern const char *Txt_Comment_removed; + struct TL_Com_Comment Com; + bool ItsMe; + + /***** Initialize image *****/ + Med_MediaConstructor (&Com.Content.Media); + + /***** Get data of comment *****/ + Com.PubCod = TL_GetParamPubCod (); + TL_Com_GetDataOfCommByCod (&Com); + + if (Com.PubCod > 0) + { + ItsMe = Usr_ItsMe (Com.UsrCod); + if (ItsMe) // I am the author of this comment + { + /***** Remove media associated to comment + and delete comment from database *****/ + TL_Com_RemoveCommentMediaAndDBEntries (Com.PubCod); + + /***** Reset fields of comment *****/ + TL_Com_ResetComment (&Com); + + /***** Message of success *****/ + Ale_ShowAlert (Ale_SUCCESS,Txt_Comment_removed); + } + } + else + Ale_ShowAlert (Ale_WARNING,Txt_The_comment_no_longer_exists); + + /***** Free image *****/ + Med_MediaDestructor (&Com.Content.Media); + } + +/*****************************************************************************/ +/*************** Remove comment media and database entries *******************/ +/*****************************************************************************/ + +void TL_Com_RemoveCommentMediaAndDBEntries (long PubCod) + { + MYSQL_RES *mysql_res; + MYSQL_ROW row; + long MedCod; + + /***** Remove media associated to comment *****/ + if (DB_QuerySELECT (&mysql_res,"can not get media", + "SELECT MedCod" // row[0] + " FROM tl_comments" + " WHERE PubCod=%ld", + PubCod) == 1) // Result should have a unique row + { + /* Get media code */ + row = mysql_fetch_row (mysql_res); + MedCod = Str_ConvertStrCodToLongCod (row[0]); + + /* Remove media */ + Med_RemoveMedia (MedCod); + } + + /* Free structure that stores the query result */ + DB_FreeMySQLResult (&mysql_res); + + /***** Mark possible notifications on this comment as removed *****/ + Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_COMMENT,PubCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,PubCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,PubCod); + + /***** Remove favs for this comment *****/ + DB_QueryDELETE ("can not remove favs for comment", + "DELETE FROM tl_comments_fav" + " WHERE PubCod=%ld", + PubCod); + + /***** Remove content of this comment *****/ + DB_QueryDELETE ("can not remove a comment", + "DELETE FROM tl_comments" + " WHERE PubCod=%ld", + PubCod); + + /***** Remove this comment *****/ + DB_QueryDELETE ("can not remove a comment", + "DELETE FROM tl_pubs" + " WHERE PubCod=%ld" + " AND PublisherCod=%ld" // Extra check: I am the author + " AND PubType=%u", // Extra check: it's a comment + PubCod, + Gbl.Usrs.Me.UsrDat.UsrCod, + (unsigned) TL_PUB_COMMENT_TO_NOTE); + } + +/*****************************************************************************/ +/******************* Get data of comment using its code **********************/ +/*****************************************************************************/ + +void TL_Com_GetDataOfCommByCod (struct TL_Com_Comment *Com) + { + MYSQL_RES *mysql_res; + MYSQL_ROW row; + + if (Com->PubCod > 0) + { + /***** Get data of comment from database *****/ + if (DB_QuerySELECT (&mysql_res,"can not get data of comment", + "SELECT tl_pubs.PubCod," // row[0] + "tl_pubs.PublisherCod," // row[1] + "tl_pubs.NotCod," // row[2] + "UNIX_TIMESTAMP(tl_pubs.TimePublish)," // row[3] + "tl_comments.Txt," // row[4] + "tl_comments.MedCod" // row[5] + " FROM tl_pubs,tl_comments" + " WHERE tl_pubs.PubCod=%ld" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments.PubCod", + Com->PubCod,(unsigned) TL_PUB_COMMENT_TO_NOTE)) + { + /***** Get data of comment *****/ + row = mysql_fetch_row (mysql_res); + TL_Com_GetDataOfCommentFromRow (row,Com); + } + else + /***** Reset fields of comment *****/ + TL_Com_ResetComment (Com); + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + else + /***** Reset fields of comment *****/ + TL_Com_ResetComment (Com); + } + +/*****************************************************************************/ +/********************** Get data of comment from row *************************/ +/*****************************************************************************/ + +static void TL_Com_GetDataOfCommentFromRow (MYSQL_ROW row,struct TL_Com_Comment *Com) + { + /* + row[0]: PubCod + row[1]: PublisherCod + row[2]: NotCod + row[3]: TimePublish + row[4]: Txt + row[5]: MedCod + */ + /***** Get code of comment (row[0]) *****/ + Com->PubCod = Str_ConvertStrCodToLongCod (row[0]); + + /***** Get (from) user code (row[1]) *****/ + Com->UsrCod = Str_ConvertStrCodToLongCod (row[1]); + + /***** Get code of note (row[2]) *****/ + Com->NotCod = Str_ConvertStrCodToLongCod (row[2]); + + /***** Get time of the note (row[3]) *****/ + Com->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[3]); + + /***** Get text content (row[4]) *****/ + Str_Copy (Com->Content.Txt,row[4], + Cns_MAX_BYTES_LONG_TEXT); + + /***** Get number of times this comment has been favourited *****/ + TL_Fav_GetNumTimesACommHasBeenFav (Com); + + /***** Get media content (row[5]) *****/ + Com->Content.Media.MedCod = Str_ConvertStrCodToLongCod (row[5]); + Med_GetMediaDataByCod (&Com->Content.Media); + } + +/*****************************************************************************/ +/************************** Reset fields of comment **************************/ +/*****************************************************************************/ + +static void TL_Com_ResetComment (struct TL_Com_Comment *Com) + { + Com->PubCod = -1L; + Com->UsrCod = -1L; + Com->NotCod = -1L; + Com->DateTimeUTC = (time_t) 0; + Com->Content.Txt[0] = '\0'; + } diff --git a/swad_timeline_comment.h b/swad_timeline_comment.h new file mode 100644 index 00000000..4897473c --- /dev/null +++ b/swad_timeline_comment.h @@ -0,0 +1,81 @@ +// swad_timeline.h: social timeline + +#ifndef _SWAD_TL_COM +#define _SWAD_TL_COM +/* + SWAD (Shared Workspace At a Distance in Spanish), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 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 Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************** Headers **********************************/ +/*****************************************************************************/ + +#include "swad_timeline_note.h" + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/******************************** Public types *******************************/ +/*****************************************************************************/ + +struct TL_Com_Comment + { + long PubCod; // Unique code/identifier for each publication + long UsrCod; // Publisher + long NotCod; // Note code to which this comment belongs + time_t DateTimeUTC; // Date-time of publication in UTC time + unsigned NumFavs; // Number of times (users) this comment has been favourited + struct TL_PostContent Content; + }; + +/*****************************************************************************/ +/****************************** Public prototypes ****************************/ +/*****************************************************************************/ + +void TL_Com_PutIconToToggleComment (const char UniqueId[Frm_MAX_BYTES_ID + 1]); +void TL_Com_PutIconCommentDisabled (void); + +void TL_Com_PutHiddenFormToWriteNewComment (const struct TL_Timeline *Timeline, + long NotCod, + const char IdNewComment[Frm_MAX_BYTES_ID + 1]); +unsigned long TL_Com_GetNumCommentsInNote (long NotCod); + +void TL_Com_WriteCommentsInNote (struct TL_Timeline *Timeline, + const struct TL_Not_Note *Not, + unsigned NumComments); + +void TL_Com_ShowHiddenCommentsUsr (void); +void TL_Com_ShowHiddenCommentsGbl (void); + +void TL_Com_ReceiveCommentUsr (void); +void TL_Com_ReceiveCommentGbl (void); + +void TL_Com_RequestRemComUsr (void); +void TL_Com_RequestRemComGbl (void); +void TL_Com_RemoveComUsr (void); +void TL_Com_RemoveComGbl (void); + +void TL_Com_RemoveCommentMediaAndDBEntries (long PubCod); + +void TL_Com_GetDataOfCommByCod (struct TL_Com_Comment *Com); + +#endif diff --git a/swad_timeline_favourite.c b/swad_timeline_favourite.c index 1eb63aad..eb534934 100644 --- a/swad_timeline_favourite.c +++ b/swad_timeline_favourite.c @@ -63,18 +63,18 @@ static void TL_Fav_PutFormToUnfNote (long ParamCod); static void TL_Fav_PutFormToFavComment (long ParamCod); static void TL_Fav_PutFormToUnfComment (long ParamCod); -static void TL_Fav_FavNote (struct TL_Note *Not); -static void TL_Fav_UnfNote (struct TL_Note *Not); +static void TL_Fav_FavNote (struct TL_Not_Note *Not); +static void TL_Fav_UnfNote (struct TL_Not_Note *Not); -static void TL_Fav_FavComment (struct TL_Comment *Com); -static void TL_Fav_UnfComment (struct TL_Comment *Com); +static void TL_Fav_FavComment (struct TL_Com_Comment *Com); +static void TL_Fav_UnfComment (struct TL_Com_Comment *Com); static bool TL_Fav_CheckIfNoteIsFavedByUsr (long NotCod,long UsrCod); static bool TL_Fav_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod); -static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Note *Not, +static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not, TL_HowManyUsrs_t HowManyUsrs); -static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Comment *Com, +static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com, TL_HowManyUsrs_t HowManyUsrs); /*****************************************************************************/ @@ -162,11 +162,11 @@ void TL_Fav_ShowAllFaversNoteUsr (void) void TL_Fav_ShowAllFaversNoteGbl (void) { - struct TL_Note Not; + struct TL_Not_Note Not; /***** Get data of note *****/ - Not.NotCod = TL_GetParamNotCod (); - TL_GetDataOfNoteByCod (&Not); + Not.NotCod = TL_Not_GetParamNotCod (); + TL_Not_GetDataOfNoteByCod (&Not); /***** Write HTML inside DIV with form to fav/unfav *****/ TL_Fav_PutFormToFavUnfNote (&Not,TL_SHOW_ALL_USRS); @@ -183,7 +183,7 @@ void TL_Fav_FavNoteUsr (void) void TL_Fav_FavNoteGbl (void) { - struct TL_Note Not; + struct TL_Not_Note Not; /***** Mark note as favourite *****/ TL_Fav_FavNote (&Not); @@ -203,7 +203,7 @@ void TL_Fav_UnfNoteUsr (void) void TL_Fav_UnfNoteGbl (void) { - struct TL_Note Not; + struct TL_Not_Note Not; /***** Stop marking as favourite a previously favourited note *****/ TL_Fav_UnfNote (&Not); @@ -212,7 +212,7 @@ void TL_Fav_UnfNoteGbl (void) TL_Fav_PutFormToFavUnfNote (&Not,TL_SHOW_FEW_USRS); } -void TL_Fav_PutFormToFavUnfNote (const struct TL_Note *Not, +void TL_Fav_PutFormToFavUnfNote (const struct TL_Not_Note *Not, TL_HowManyUsrs_t HowManyUsrs) { bool IAmTheAuthor; @@ -241,14 +241,14 @@ void TL_Fav_PutFormToFavUnfNote (const struct TL_Note *Not, TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (Not,HowManyUsrs); } -static void TL_Fav_FavNote (struct TL_Note *Not) +static void TL_Fav_FavNote (struct TL_Not_Note *Not) { bool ItsMe; long OriginalPubCod; /***** Get data of note *****/ - Not->NotCod = TL_GetParamNotCod (); - TL_GetDataOfNoteByCod (Not); + Not->NotCod = TL_Not_GetParamNotCod (); + TL_Not_GetDataOfNoteByCod (Not); if (Not->NotCod > 0) { @@ -271,21 +271,21 @@ static void TL_Fav_FavNote (struct TL_Note *Not) /***** Create notification about favourite post for the author of the post *****/ - OriginalPubCod = TL_GetPubCodOfOriginalNote (Not->NotCod); + OriginalPubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod); if (OriginalPubCod > 0) TL_CreateNotifToAuthor (Not->UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_FAV); } } } -static void TL_Fav_UnfNote (struct TL_Note *Not) +static void TL_Fav_UnfNote (struct TL_Not_Note *Not) { long OriginalPubCod; bool ItsMe; /***** Get data of note *****/ - Not->NotCod = TL_GetParamNotCod (); - TL_GetDataOfNoteByCod (Not); + Not->NotCod = TL_Not_GetParamNotCod (); + TL_Not_GetDataOfNoteByCod (Not); if (Not->NotCod > 0) { @@ -306,7 +306,7 @@ static void TL_Fav_UnfNote (struct TL_Note *Not) TL_Fav_GetNumTimesANoteHasBeenFav (Not); /***** Mark possible notifications on this note as removed *****/ - OriginalPubCod = TL_GetPubCodOfOriginalNote (Not->NotCod); + OriginalPubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod); if (OriginalPubCod > 0) Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV,OriginalPubCod); } @@ -328,12 +328,12 @@ void TL_Fav_ShowAllFaversComUsr (void) void TL_Fav_ShowAllFaversComGbl (void) { - struct TL_Comment Com; + struct TL_Com_Comment Com; /***** Get data of comment *****/ Med_MediaConstructor (&Com.Content.Media); Com.PubCod = TL_GetParamPubCod (); - TL_GetDataOfCommByCod (&Com); + TL_Com_GetDataOfCommByCod (&Com); Med_MediaDestructor (&Com.Content.Media); /***** Write HTML inside DIV with form to fav/unfav *****/ @@ -351,7 +351,7 @@ void TL_Fav_FavCommentUsr (void) void TL_Fav_FavCommentGbl (void) { - struct TL_Comment Com; + struct TL_Com_Comment Com; /***** Mark comment as favourite *****/ TL_Fav_FavComment (&Com); @@ -371,7 +371,7 @@ void TL_Fav_UnfCommentUsr (void) void TL_Fav_UnfCommentGbl (void) { - struct TL_Comment Com; + struct TL_Com_Comment Com; /***** Stop marking as favourite a previously favourited comment *****/ TL_Fav_UnfComment (&Com); @@ -380,7 +380,7 @@ void TL_Fav_UnfCommentGbl (void) TL_Fav_PutFormToFavUnfComment (&Com,TL_SHOW_FEW_USRS); } -void TL_Fav_PutFormToFavUnfComment (const struct TL_Comment *Com, +void TL_Fav_PutFormToFavUnfComment (const struct TL_Com_Comment *Com, TL_HowManyUsrs_t HowManyUsrs) { bool IAmTheAuthor; @@ -410,7 +410,7 @@ void TL_Fav_PutFormToFavUnfComment (const struct TL_Comment *Com, TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (Com,HowManyUsrs); } -static void TL_Fav_FavComment (struct TL_Comment *Com) +static void TL_Fav_FavComment (struct TL_Com_Comment *Com) { bool IAmTheAuthor; @@ -419,7 +419,7 @@ static void TL_Fav_FavComment (struct TL_Comment *Com) /***** Get data of comment *****/ Com->PubCod = TL_GetParamPubCod (); - TL_GetDataOfCommByCod (Com); + TL_Com_GetDataOfCommByCod (Com); if (Com->PubCod > 0) { @@ -450,7 +450,7 @@ static void TL_Fav_FavComment (struct TL_Comment *Com) Med_MediaDestructor (&Com->Content.Media); } -static void TL_Fav_UnfComment (struct TL_Comment *Com) +static void TL_Fav_UnfComment (struct TL_Com_Comment *Com) { bool IAmTheAuthor; @@ -459,7 +459,7 @@ static void TL_Fav_UnfComment (struct TL_Comment *Com) /***** Get data of comment *****/ Com->PubCod = TL_GetParamPubCod (); - TL_GetDataOfCommByCod (Com); + TL_Com_GetDataOfCommByCod (Com); if (Com->PubCod > 0) { @@ -518,7 +518,7 @@ static bool TL_Fav_CheckIfCommIsFavedByUsr (long PubCod,long UsrCod) /*************** Get number of times a note has been favourited **************/ /*****************************************************************************/ -void TL_Fav_GetNumTimesANoteHasBeenFav (struct TL_Note *Not) +void TL_Fav_GetNumTimesANoteHasBeenFav (struct TL_Not_Note *Not) { /***** Get number of times (users) this note has been favourited *****/ Not->NumFavs = @@ -535,7 +535,7 @@ void TL_Fav_GetNumTimesANoteHasBeenFav (struct TL_Note *Not) /************ Get number of times a comment has been favourited **************/ /*****************************************************************************/ -void TL_Fav_GetNumTimesACommHasBeenFav (struct TL_Comment *Com) +void TL_Fav_GetNumTimesACommHasBeenFav (struct TL_Com_Comment *Com) { /***** Get number of times (users) this comment has been favourited *****/ Com->NumFavs = @@ -552,7 +552,7 @@ void TL_Fav_GetNumTimesACommHasBeenFav (struct TL_Comment *Com) /************ Show users who have marked this note as favourite **************/ /*****************************************************************************/ -static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Note *Not, +static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Not_Note *Not, TL_HowManyUsrs_t HowManyUsrs) { MYSQL_RES *mysql_res; @@ -599,7 +599,7 @@ static void TL_Fav_ShowUsrsWhoHaveMarkedNoteAsFav (const struct TL_Note *Not, /************ Show users who have marked this note as favourite **************/ /*****************************************************************************/ -static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Comment *Com, +static void TL_Fav_ShowUsrsWhoHaveMarkedCommAsFav (const struct TL_Com_Comment *Com, TL_HowManyUsrs_t HowManyUsrs) { MYSQL_RES *mysql_res; diff --git a/swad_timeline_favourite.h b/swad_timeline_favourite.h index 0634cbb1..5188f022 100644 --- a/swad_timeline_favourite.h +++ b/swad_timeline_favourite.h @@ -27,6 +27,9 @@ /********************************** Headers **********************************/ /*****************************************************************************/ +#include "swad_timeline_comment.h" +#include "swad_timeline_note.h" + /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ @@ -50,7 +53,7 @@ void TL_Fav_FavNoteUsr (void); void TL_Fav_FavNoteGbl (void); void TL_Fav_UnfNoteUsr (void); void TL_Fav_UnfNoteGbl (void); -void TL_Fav_PutFormToFavUnfNote (const struct TL_Note *Not, +void TL_Fav_PutFormToFavUnfNote (const struct TL_Not_Note *Not, TL_HowManyUsrs_t HowManyUsrs); void TL_Fav_ShowAllFaversComUsr (void); @@ -59,10 +62,10 @@ void TL_Fav_FavCommentUsr (void); void TL_Fav_FavCommentGbl (void); void TL_Fav_UnfCommentUsr (void); void TL_Fav_UnfCommentGbl (void); -void TL_Fav_PutFormToFavUnfComment (const struct TL_Comment *Com, +void TL_Fav_PutFormToFavUnfComment (const struct TL_Com_Comment *Com, TL_HowManyUsrs_t HowManyUsrs); -void TL_Fav_GetNumTimesANoteHasBeenFav (struct TL_Note *Not); -void TL_Fav_GetNumTimesACommHasBeenFav (struct TL_Comment *Com); +void TL_Fav_GetNumTimesANoteHasBeenFav (struct TL_Not_Note *Not); +void TL_Fav_GetNumTimesACommHasBeenFav (struct TL_Com_Comment *Com); #endif diff --git a/swad_timeline_note.c b/swad_timeline_note.c new file mode 100644 index 00000000..f913bf2c --- /dev/null +++ b/swad_timeline_note.c @@ -0,0 +1,1311 @@ +// swad_timeline_note.c: social timeline notes + +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 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 + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/*********************************** Headers *********************************/ +/*****************************************************************************/ + +#define _GNU_SOURCE // For asprintf +#include // For PATH_MAX +#include // For asprintf + +#include "swad_alert.h" +#include "swad_box.h" +#include "swad_course.h" +#include "swad_database.h" +#include "swad_exam_announcement.h" +#include "swad_forum.h" +#include "swad_global.h" +#include "swad_notice.h" +#include "swad_photo.h" +#include "swad_profile.h" +#include "swad_timeline.h" +#include "swad_timeline_favourite.h" +#include "swad_timeline_share.h" + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************************* Private constants and types ***********************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************** External global variables from others modules ****************/ +/*****************************************************************************/ + +extern struct Globals Gbl; + +/*****************************************************************************/ +/************************* Private global variables **************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private prototypes ****************************/ +/*****************************************************************************/ + +static void TL_Not_PutFormGoToAction (const struct TL_Not_Note *Not, + const struct For_Forums *Forums); + +static void TL_Not_PutFormToRemoveNote (const struct TL_Timeline *Timeline, + long NotCod); + +static void TL_Not_RequestRemovalNote (struct TL_Timeline *Timeline); +static void TL_Not_PutParamsRemoveNote (void *Timeline); +static void TL_Not_RemoveNote (void); +static void TL_Not_RemoveNoteMediaAndDBEntries (struct TL_Not_Note *Not); + +static void TL_Not_GetDataOfNoteFromRow (MYSQL_ROW row,struct TL_Not_Note *Not); + +static TL_Not_NoteType_t TL_Not_GetNoteTypeFromStr (const char *Str); + +static void TL_Not_ResetNote (struct TL_Not_Note *Not); + +/*****************************************************************************/ +/****************** Show highlighted note above timeline *********************/ +/*****************************************************************************/ + +void TL_Not_ShowHighlightedNote (struct TL_Timeline *Timeline, + struct TL_Not_Note *Not) + { + struct UsrData PublisherDat; + Ntf_NotifyEvent_t NotifyEvent; + static const TL_TopMessage_t TopMessages[Ntf_NUM_NOTIFY_EVENTS] = + { + [Ntf_EVENT_UNKNOWN ] = TL_TOP_MESSAGE_NONE, + /* Start tab */ + [Ntf_EVENT_TIMELINE_COMMENT ] = TL_TOP_MESSAGE_COMMENTED, + [Ntf_EVENT_TIMELINE_FAV ] = TL_TOP_MESSAGE_FAVED, + [Ntf_EVENT_TIMELINE_SHARE ] = TL_TOP_MESSAGE_SHARED, + [Ntf_EVENT_TIMELINE_MENTION ] = TL_TOP_MESSAGE_MENTIONED, + [Ntf_EVENT_FOLLOWER ] = TL_TOP_MESSAGE_NONE, + /* System tab */ + /* Country tab */ + /* Institution tab */ + /* Centre tab */ + /* Degree tab */ + /* Course tab */ + /* Assessment tab */ + [Ntf_EVENT_ASSIGNMENT ] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_SURVEY ] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_EXAM_ANNOUNCEMENT] = TL_TOP_MESSAGE_NONE, + /* Files tab */ + [Ntf_EVENT_DOCUMENT_FILE ] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_TEACHERS_FILE ] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_SHARED_FILE ] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_MARKS_FILE ] = TL_TOP_MESSAGE_NONE, + /* Users tab */ + [Ntf_EVENT_ENROLMENT_STD ] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_ENROLMENT_NET ] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_ENROLMENT_TCH ] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_ENROLMENT_REQUEST] = TL_TOP_MESSAGE_NONE, + /* Messages tab */ + [Ntf_EVENT_NOTICE ] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_FORUM_POST_COURSE] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_FORUM_REPLY ] = TL_TOP_MESSAGE_NONE, + [Ntf_EVENT_MESSAGE ] = TL_TOP_MESSAGE_NONE, + /* Analytics tab */ + /* Profile tab */ + }; + + /***** Get other parameters *****/ + /* Get the publisher who did the action + (publishing, commenting, faving, sharing, mentioning) */ + Usr_GetParamOtherUsrCodEncrypted (&PublisherDat); + + /* Get what he/she did */ + NotifyEvent = Ntf_GetParamNotifyEvent (); + + /***** Show the note highlighted *****/ + TL_Not_GetDataOfNoteByCod (Not); + TL_Not_WriteNote (Timeline,Not, + TopMessages[NotifyEvent],PublisherDat.UsrCod, + TL_HIGHLIGHT, + TL_SHOW_ALONE); + } + +/*****************************************************************************/ +/**** Insert note in temporary tables used to not get notes already shown ****/ +/*****************************************************************************/ + +void TL_Not_InsertNoteInJustRetrievedNotes (long NotCod) + { + /* Insert note in temporary table with just retrieved notes. + This table will be used to not get notes already shown */ + DB_QueryINSERT ("can not store note code", + "INSERT IGNORE INTO tl_tmp_just_retrieved_notes" + " SET NotCod=%ld", + NotCod); + } + +void TL_Not_InsertNoteInVisibleTimeline (long NotCod) + { + /* Insert note in temporary table with visible timeline. + This table will be used to not get notes already shown */ + DB_QueryINSERT ("can not store note code", + "INSERT IGNORE INTO tl_tmp_visible_timeline" + " SET NotCod=%ld", + NotCod); + } + +/*****************************************************************************/ +/******************************** Write note *********************************/ +/*****************************************************************************/ + +void TL_Not_WriteNote (struct TL_Timeline *Timeline, + const struct TL_Not_Note *Not, + TL_TopMessage_t TopMessage, + long PublisherCod, // Who did the action (publication, commenting, faving, sharing, mentioning) + TL_Highlight_t Highlight, // Highlight note + TL_ShowAlone_t ShowNoteAlone) // Note is shown alone, not in a list + { + extern const char *Txt_Forum; + extern const char *Txt_Course; + extern const char *Txt_Degree; + extern const char *Txt_Centre; + extern const char *Txt_Institution; + struct UsrData AuthorDat; + bool IAmTheAuthor; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; + struct Deg_Degree Deg; + struct Crs_Course Crs; + bool ShowPhoto = false; + char PhotoURL[PATH_MAX + 1]; + struct For_Forums Forums; + char ForumName[For_MAX_BYTES_FORUM_NAME + 1]; + char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]; + unsigned NumComments; + char IdNewComment[Frm_MAX_BYTES_ID + 1]; + static unsigned NumDiv = 0; // Used to create unique div id for fav and shared + + NumDiv++; + + /***** Begin box ****/ + if (ShowNoteAlone == TL_SHOW_ALONE) + { + Box_BoxBegin (NULL,NULL, + NULL,NULL, + NULL,Box_CLOSABLE); + HTM_UL_Begin ("class=\"TL_LIST\""); + } + + /***** Start list item *****/ + HTM_LI_Begin ("class=\"%s\"", + ShowNoteAlone == TL_SHOW_ALONE ? + (Highlight == TL_HIGHLIGHT ? "TL_WIDTH TL_NEW_PUB" : + "TL_WIDTH") : + (Highlight == TL_HIGHLIGHT ? "TL_WIDTH TL_SEP TL_NEW_PUB" : + "TL_WIDTH TL_SEP")); + + if (Not->NotCod <= 0 || + Not->NoteType == TL_NOTE_UNKNOWN || + Not->UsrCod <= 0) + Ale_ShowAlert (Ale_ERROR,"Error in note."); + else + { + /***** Initialize location in hierarchy *****/ + Ins.InsCod = -1L; + Ctr.CtrCod = -1L; + Deg.DegCod = -1L; + Crs.CrsCod = -1L; + + /***** Write sharer/commenter if distinct to author *****/ + TL_WriteTopMessage (TopMessage,PublisherCod); + + /***** Initialize structure with user's data *****/ + Usr_UsrDataConstructor (&AuthorDat); + + /***** Get author data *****/ + AuthorDat.UsrCod = Not->UsrCod; + Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&AuthorDat,Usr_DONT_GET_PREFS); + IAmTheAuthor = Usr_ItsMe (AuthorDat.UsrCod); + + /***** Left: write author's photo *****/ + HTM_DIV_Begin ("class=\"TL_LEFT_PHOTO\""); + ShowPhoto = Pho_ShowingUsrPhotoIsAllowed (&AuthorDat,PhotoURL); + Pho_ShowUsrPhoto (&AuthorDat,ShowPhoto ? PhotoURL : + NULL, + "PHOTO45x60",Pho_ZOOM,true); // Use unique id + HTM_DIV_End (); + + /***** Right: author's name, time, summary and buttons *****/ + /* Begin right container */ + HTM_DIV_Begin ("class=\"TL_RIGHT_CONT TL_RIGHT_WIDTH\""); + + /* Write author's full name and date-time */ + TL_Not_WriteAuthorNote (&AuthorDat); + TL_WriteDateTime (Not->DateTimeUTC); + + /* Write content of the note */ + if (Not->NoteType == TL_NOTE_POST) + /* Write post content */ + TL_GetAndWritePost (Not->Cod); + else + { + /* Reset forums */ + For_ResetForums (&Forums); + + /* Get location in hierarchy */ + if (!Not->Unavailable) + switch (Not->NoteType) + { + case TL_NOTE_INS_DOC_PUB_FILE: + case TL_NOTE_INS_SHA_PUB_FILE: + /* Get institution data */ + Ins.InsCod = Not->HieCod; + Ins_GetDataOfInstitutionByCod (&Ins); + break; + case TL_NOTE_CTR_DOC_PUB_FILE: + case TL_NOTE_CTR_SHA_PUB_FILE: + /* Get centre data */ + Ctr.CtrCod = Not->HieCod; + Ctr_GetDataOfCentreByCod (&Ctr); + break; + case TL_NOTE_DEG_DOC_PUB_FILE: + case TL_NOTE_DEG_SHA_PUB_FILE: + /* Get degree data */ + Deg.DegCod = Not->HieCod; + Deg_GetDataOfDegreeByCod (&Deg); + break; + case TL_NOTE_CRS_DOC_PUB_FILE: + case TL_NOTE_CRS_SHA_PUB_FILE: + case TL_NOTE_EXAM_ANNOUNCEMENT: + case TL_NOTE_NOTICE: + /* Get course data */ + Crs.CrsCod = Not->HieCod; + Crs_GetDataOfCourseByCod (&Crs); + break; + case TL_NOTE_FORUM_POST: + /* Get forum type of the post */ + For_GetForumTypeAndLocationOfAPost (Not->Cod,&Forums.Forum); + For_SetForumName (&Forums.Forum,ForumName,Gbl.Prefs.Language,false); // Set forum name in recipient's language + break; + default: + break; + } + + /* Write note type */ + TL_Not_PutFormGoToAction (Not,&Forums); + + /* Write location in hierarchy */ + if (!Not->Unavailable) + switch (Not->NoteType) + { + case TL_NOTE_INS_DOC_PUB_FILE: + case TL_NOTE_INS_SHA_PUB_FILE: + /* Write location (institution) in hierarchy */ + HTM_DIV_Begin ("class=\"TL_LOC\""); + HTM_TxtF ("%s: %s",Txt_Institution,Ins.ShrtName); + HTM_DIV_End (); + break; + case TL_NOTE_CTR_DOC_PUB_FILE: + case TL_NOTE_CTR_SHA_PUB_FILE: + /* Write location (centre) in hierarchy */ + HTM_DIV_Begin ("class=\"TL_LOC\""); + HTM_TxtF ("%s: %s",Txt_Centre,Ctr.ShrtName); + HTM_DIV_End (); + break; + case TL_NOTE_DEG_DOC_PUB_FILE: + case TL_NOTE_DEG_SHA_PUB_FILE: + /* Write location (degree) in hierarchy */ + HTM_DIV_Begin ("class=\"TL_LOC\""); + HTM_TxtF ("%s: %s",Txt_Degree,Deg.ShrtName); + HTM_DIV_End (); + break; + case TL_NOTE_CRS_DOC_PUB_FILE: + case TL_NOTE_CRS_SHA_PUB_FILE: + case TL_NOTE_EXAM_ANNOUNCEMENT: + case TL_NOTE_NOTICE: + /* Write location (course) in hierarchy */ + HTM_DIV_Begin ("class=\"TL_LOC\""); + HTM_TxtF ("%s: %s",Txt_Course,Crs.ShrtName); + HTM_DIV_End (); + break; + case TL_NOTE_FORUM_POST: + /* Write forum name */ + HTM_DIV_Begin ("class=\"TL_LOC\""); + HTM_TxtF ("%s: %s",Txt_Forum,ForumName); + HTM_DIV_End (); + break; + default: + break; + } + + /* Write note summary */ + TL_Not_GetNoteSummary (Not,SummaryStr); + HTM_DIV_Begin ("class=\"TL_TXT\""); + HTM_Txt (SummaryStr); + HTM_DIV_End (); + } + + /* End right container */ + HTM_DIV_End (); + + /***** Buttons and comments *****/ + /* Create unique id for new comment */ + Frm_SetUniqueId (IdNewComment); + + /* Get number of comments in this note */ + NumComments = TL_Com_GetNumCommentsInNote (Not->NotCod); + + /* Put icon to add a comment */ + HTM_DIV_Begin ("class=\"TL_BOTTOM_LEFT\""); + if (Not->Unavailable) // Unavailable notes can not be commented + TL_Com_PutIconCommentDisabled (); + else + TL_Com_PutIconToToggleComment (IdNewComment); + HTM_DIV_End (); + + /* Start container for buttons and comments */ + HTM_DIV_Begin ("class=\"TL_BOTTOM_RIGHT TL_RIGHT_WIDTH\""); + + /* Start foot container */ + HTM_DIV_Begin ("class=\"TL_FOOT TL_RIGHT_WIDTH\""); + + /* Foot column 1: Fav zone */ + HTM_DIV_Begin ("id=\"fav_not_%s_%u\" class=\"TL_FAV_NOT TL_FAV_NOT_WIDTH\"", + Gbl.UniqueNameEncrypted,NumDiv); + TL_Fav_PutFormToFavUnfNote (Not,TL_SHOW_FEW_USRS); + HTM_DIV_End (); + + /* Foot column 2: Share zone */ + HTM_DIV_Begin ("id=\"sha_not_%s_%u\" class=\"TL_SHA_NOT TL_SHA_NOT_WIDTH\"", + Gbl.UniqueNameEncrypted,NumDiv); + TL_Sha_PutFormToShaUnsNote (Not,TL_SHOW_FEW_USRS); + HTM_DIV_End (); + + /* Foot column 3: Icon to remove this note */ + HTM_DIV_Begin ("class=\"TL_REM\""); + if (IAmTheAuthor) + TL_Not_PutFormToRemoveNote (Timeline,Not->NotCod); + HTM_DIV_End (); + + /* End foot container */ + HTM_DIV_End (); + + /* Comments */ + if (NumComments) + TL_Com_WriteCommentsInNote (Timeline,Not,NumComments); + + /* End container for buttons and comments */ + HTM_DIV_End (); + + /* Put hidden form to write a new comment */ + TL_Com_PutHiddenFormToWriteNewComment (Timeline, + Not->NotCod,IdNewComment); + + /***** Free memory used for author's data *****/ + Usr_UsrDataDestructor (&AuthorDat); + } + + /***** End list item *****/ + HTM_LI_End (); + + /***** End box ****/ + if (ShowNoteAlone == TL_SHOW_ALONE) + { + HTM_UL_End (); + Box_BoxEnd (); + } + } + +/*****************************************************************************/ +/*************** Write name and nickname of author of a note *****************/ +/*****************************************************************************/ + +void TL_Not_WriteAuthorNote (const struct UsrData *UsrDat) + { + extern const char *Txt_My_public_profile; + extern const char *Txt_Another_user_s_profile; + bool ItsMe = Usr_ItsMe (UsrDat->UsrCod); + + /***** Show user's name inside form to go to user's public profile *****/ + Frm_StartFormUnique (ActSeeOthPubPrf); + Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); + HTM_BUTTON_SUBMIT_Begin (ItsMe ? Txt_My_public_profile : + Txt_Another_user_s_profile, + "BT_LINK TL_RIGHT_AUTHOR TL_RIGHT_AUTHOR_WIDTH DAT_N_BOLD", + NULL); + HTM_Txt (UsrDat->FullName); + HTM_BUTTON_End (); + Frm_EndForm (); + } + +/*****************************************************************************/ +/************* Put form to go to an action depending on the note *************/ +/*****************************************************************************/ + +static void TL_Not_PutFormGoToAction (const struct TL_Not_Note *Not, + const struct For_Forums *Forums) + { + extern const Act_Action_t For_ActionsSeeFor[For_NUM_TYPES_FORUM]; + extern const char *The_ClassFormInBoxBold[The_NUM_THEMES]; + extern const char *Txt_TIMELINE_NOTE[TL_NOT_NUM_NOTE_TYPES]; + extern const char *Txt_not_available; + char *Anchor = NULL; + static const Act_Action_t TL_DefaultActions[TL_NOT_NUM_NOTE_TYPES] = + { + [TL_NOTE_UNKNOWN ] = ActUnk, + /* Start tab */ + [TL_NOTE_POST ] = ActUnk, // action not used + /* Institution tab */ + [TL_NOTE_INS_DOC_PUB_FILE ] = ActReqDatSeeDocIns, + [TL_NOTE_INS_SHA_PUB_FILE ] = ActReqDatShaIns, + /* Centre tab */ + [TL_NOTE_CTR_DOC_PUB_FILE ] = ActReqDatSeeDocCtr, + [TL_NOTE_CTR_SHA_PUB_FILE ] = ActReqDatShaCtr, + /* Degree tab */ + [TL_NOTE_DEG_DOC_PUB_FILE ] = ActReqDatSeeDocDeg, + [TL_NOTE_DEG_SHA_PUB_FILE ] = ActReqDatShaDeg, + /* Course tab */ + [TL_NOTE_CRS_DOC_PUB_FILE ] = ActReqDatSeeDocCrs, + [TL_NOTE_CRS_SHA_PUB_FILE ] = ActReqDatShaCrs, + /* Assessment tab */ + [TL_NOTE_EXAM_ANNOUNCEMENT] = ActSeeOneExaAnn, + /* Users tab */ + /* Messages tab */ + [TL_NOTE_NOTICE ] = ActSeeOneNot, + [TL_NOTE_FORUM_POST ] = ActSeeFor, + /* Analytics tab */ + /* Profile tab */ + }; + static const char *TL_Icons[TL_NOT_NUM_NOTE_TYPES] = + { + [TL_NOTE_UNKNOWN ] = NULL, + /* Start tab */ + [TL_NOTE_POST ] = NULL, // icon not used + /* Institution tab */ + [TL_NOTE_INS_DOC_PUB_FILE ] = "file.svg", + [TL_NOTE_INS_SHA_PUB_FILE ] = "file.svg", + /* Centre tab */ + [TL_NOTE_CTR_DOC_PUB_FILE ] = "file.svg", + [TL_NOTE_CTR_SHA_PUB_FILE ] = "file.svg", + /* Degree tab */ + [TL_NOTE_DEG_DOC_PUB_FILE ] = "file.svg", + [TL_NOTE_DEG_SHA_PUB_FILE ] = "file.svg", + /* Course tab */ + [TL_NOTE_CRS_DOC_PUB_FILE ] = "file.svg", + [TL_NOTE_CRS_SHA_PUB_FILE ] = "file.svg", + /* Assessment tab */ + [TL_NOTE_EXAM_ANNOUNCEMENT] = "bullhorn.svg", + /* Users tab */ + /* Messages tab */ + [TL_NOTE_NOTICE ] = "sticky-note.svg", + [TL_NOTE_FORUM_POST ] = "comments.svg", + /* Analytics tab */ + /* Profile tab */ + }; + + if (Not->Unavailable || // File/notice... pointed by this note is unavailable + Gbl.Form.Inside) // Inside another form + { + /***** Do not put form *****/ + HTM_DIV_Begin ("class=\"TL_FORM_OFF\""); + HTM_Txt (Txt_TIMELINE_NOTE[Not->NoteType]); + if (Not->Unavailable) + HTM_TxtF (" (%s)",Txt_not_available); + HTM_DIV_End (); + } + else // Not inside another form + { + HTM_DIV_Begin ("class=\"TL_FORM\""); + + /***** Begin form with parameters depending on the type of note *****/ + switch (Not->NoteType) + { + case TL_NOTE_INS_DOC_PUB_FILE: + case TL_NOTE_INS_SHA_PUB_FILE: + Frm_StartFormUnique (TL_DefaultActions[Not->NoteType]); + Brw_PutHiddenParamFilCod (Not->Cod); + if (Not->HieCod != Gbl.Hierarchy.Ins.InsCod) // Not the current institution + Ins_PutParamInsCod (Not->HieCod); // Go to another institution + break; + case TL_NOTE_CTR_DOC_PUB_FILE: + case TL_NOTE_CTR_SHA_PUB_FILE: + Frm_StartFormUnique (TL_DefaultActions[Not->NoteType]); + Brw_PutHiddenParamFilCod (Not->Cod); + if (Not->HieCod != Gbl.Hierarchy.Ctr.CtrCod) // Not the current centre + Ctr_PutParamCtrCod (Not->HieCod); // Go to another centre + break; + case TL_NOTE_DEG_DOC_PUB_FILE: + case TL_NOTE_DEG_SHA_PUB_FILE: + Frm_StartFormUnique (TL_DefaultActions[Not->NoteType]); + Brw_PutHiddenParamFilCod (Not->Cod); + if (Not->HieCod != Gbl.Hierarchy.Deg.DegCod) // Not the current degree + Deg_PutParamDegCod (Not->HieCod); // Go to another degree + break; + case TL_NOTE_CRS_DOC_PUB_FILE: + case TL_NOTE_CRS_SHA_PUB_FILE: + Frm_StartFormUnique (TL_DefaultActions[Not->NoteType]); + Brw_PutHiddenParamFilCod (Not->Cod); + if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course + Crs_PutParamCrsCod (Not->HieCod); // Go to another course + break; + case TL_NOTE_EXAM_ANNOUNCEMENT: + Frm_SetAnchorStr (Not->Cod,&Anchor); + Frm_StartFormUniqueAnchor (TL_DefaultActions[Not->NoteType], + Anchor); // Locate on this specific exam + Frm_FreeAnchorStr (Anchor); + ExaAnn_PutHiddenParamExaCod (Not->Cod); + if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course + Crs_PutParamCrsCod (Not->HieCod); // Go to another course + break; + case TL_NOTE_POST: // Not applicable + return; + case TL_NOTE_FORUM_POST: + Frm_StartFormUnique (For_ActionsSeeFor[Forums->Forum.Type]); + For_PutAllHiddenParamsForum (1, // Page of threads = first + 1, // Page of posts = first + Forums->ForumSet, + Forums->ThreadsOrder, + Forums->Forum.Location, + Forums->Thread.Selected, + -1L); + if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course + Crs_PutParamCrsCod (Not->HieCod); // Go to another course + break; + case TL_NOTE_NOTICE: + Frm_SetAnchorStr (Not->Cod,&Anchor); + Frm_StartFormUniqueAnchor (TL_DefaultActions[Not->NoteType], + Anchor); + Frm_FreeAnchorStr (Anchor); + Not_PutHiddenParamNotCod (Not->Cod); + if (Not->HieCod != Gbl.Hierarchy.Crs.CrsCod) // Not the current course + Crs_PutParamCrsCod (Not->HieCod); // Go to another course + break; + default: // Not applicable + return; + } + + /***** Icon and link to go to action *****/ + HTM_BUTTON_SUBMIT_Begin (Txt_TIMELINE_NOTE[Not->NoteType], + Str_BuildStringStr ("BT_LINK %s ICO_HIGHLIGHT", + The_ClassFormInBoxBold[Gbl.Prefs.Theme]), + NULL); + Ico_PutIcon (TL_Icons[Not->NoteType],Txt_TIMELINE_NOTE[Not->NoteType],"CONTEXT_ICO_x16"); + HTM_TxtF (" %s",Txt_TIMELINE_NOTE[Not->NoteType]); + HTM_BUTTON_End (); + Str_FreeString (); + + /***** End form *****/ + Frm_EndForm (); + + HTM_DIV_End (); + } + } + +/*****************************************************************************/ +/********************** Get note summary and content *************************/ +/*****************************************************************************/ + +void TL_Not_GetNoteSummary (const struct TL_Not_Note *Not, + char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]) + { + SummaryStr[0] = '\0'; + + switch (Not->NoteType) + { + case TL_NOTE_UNKNOWN: + break; + case TL_NOTE_INS_DOC_PUB_FILE: + case TL_NOTE_INS_SHA_PUB_FILE: + case TL_NOTE_CTR_DOC_PUB_FILE: + case TL_NOTE_CTR_SHA_PUB_FILE: + case TL_NOTE_DEG_DOC_PUB_FILE: + case TL_NOTE_DEG_SHA_PUB_FILE: + case TL_NOTE_CRS_DOC_PUB_FILE: + case TL_NOTE_CRS_SHA_PUB_FILE: + Brw_GetSummaryAndContentOfFile (SummaryStr,NULL,Not->Cod,false); + break; + case TL_NOTE_EXAM_ANNOUNCEMENT: + ExaAnn_GetSummaryAndContentExamAnn (SummaryStr,NULL,Not->Cod,false); + break; + case TL_NOTE_POST: + // Not applicable + break; + case TL_NOTE_FORUM_POST: + For_GetSummaryAndContentForumPst (SummaryStr,NULL,Not->Cod,false); + break; + case TL_NOTE_NOTICE: + Not_GetSummaryAndContentNotice (SummaryStr,NULL,Not->Cod,false); + break; + } + } + +/*****************************************************************************/ +/***************** Store and publish a note into database ********************/ +/*****************************************************************************/ + +void TL_Not_StoreAndPublishNote (TL_Not_NoteType_t NoteType,long Cod) + { + struct TL_Publication Pub; + + TL_Not_StoreAndPublishNoteInternal (NoteType,Cod,&Pub); + } + +void TL_Not_StoreAndPublishNoteInternal (TL_Not_NoteType_t NoteType,long Cod,struct TL_Publication *Pub) + { + long HieCod; // Hierarchy code (institution/centre/degree/course) + + switch (NoteType) + { + case TL_NOTE_INS_DOC_PUB_FILE: + case TL_NOTE_INS_SHA_PUB_FILE: + HieCod = Gbl.Hierarchy.Ins.InsCod; + break; + case TL_NOTE_CTR_DOC_PUB_FILE: + case TL_NOTE_CTR_SHA_PUB_FILE: + HieCod = Gbl.Hierarchy.Ctr.CtrCod; + break; + case TL_NOTE_DEG_DOC_PUB_FILE: + case TL_NOTE_DEG_SHA_PUB_FILE: + HieCod = Gbl.Hierarchy.Deg.DegCod; + break; + case TL_NOTE_CRS_DOC_PUB_FILE: + case TL_NOTE_CRS_SHA_PUB_FILE: + case TL_NOTE_EXAM_ANNOUNCEMENT: + case TL_NOTE_NOTICE: + HieCod = Gbl.Hierarchy.Crs.CrsCod; + break; + default: + HieCod = -1L; + break; + } + + /***** Store note *****/ + Pub->NotCod = + DB_QueryINSERTandReturnCode ("can not create new note", + "INSERT INTO tl_notes" + " (NoteType,Cod,UsrCod,HieCod,Unavailable,TimeNote)" + " VALUES" + " (%u,%ld,%ld,%ld,'N',NOW())", + (unsigned) NoteType, + Cod,Gbl.Usrs.Me.UsrDat.UsrCod,HieCod); + + /***** Publish note in timeline *****/ + Pub->PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod; + Pub->PubType = TL_PUB_ORIGINAL_NOTE; + TL_PublishPubInTimeline (Pub); + } + +/*****************************************************************************/ +/************************* Mark a note as unavailable ************************/ +/*****************************************************************************/ + +void TL_Not_MarkNoteAsUnavailable (TL_Not_NoteType_t NoteType,long Cod) + { + /***** Mark the note as unavailable *****/ + DB_QueryUPDATE ("can not mark note as unavailable", + "UPDATE tl_notes SET Unavailable='Y'" + " WHERE NoteType=%u AND Cod=%ld", + (unsigned) NoteType,Cod); + } + +/*****************************************************************************/ +/****************** Mark notes of one file as unavailable ********************/ +/*****************************************************************************/ + +void TL_Not_MarkNoteOneFileAsUnavailable (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; + TL_Not_NoteType_t NoteType; + + switch (FileBrowser) + { + case Brw_ADMI_DOC_INS: + case Brw_ADMI_SHR_INS: + case Brw_ADMI_DOC_CTR: + case Brw_ADMI_SHR_CTR: + case Brw_ADMI_DOC_DEG: + case Brw_ADMI_SHR_DEG: + case Brw_ADMI_DOC_CRS: + case Brw_ADMI_SHR_CRS: + /***** Get file code *****/ + FilCod = Brw_GetFilCodByPath (Path,true); // Only if file is public + if (FilCod > 0) + { + /***** Mark possible note as unavailable *****/ + switch (FileBrowser) + { + case Brw_ADMI_DOC_INS: + NoteType = TL_NOTE_INS_DOC_PUB_FILE; + break; + case Brw_ADMI_SHR_INS: + NoteType = TL_NOTE_INS_SHA_PUB_FILE; + break; + case Brw_ADMI_DOC_CTR: + NoteType = TL_NOTE_CTR_DOC_PUB_FILE; + break; + case Brw_ADMI_SHR_CTR: + NoteType = TL_NOTE_CTR_SHA_PUB_FILE; + break; + case Brw_ADMI_DOC_DEG: + NoteType = TL_NOTE_DEG_DOC_PUB_FILE; + break; + case Brw_ADMI_SHR_DEG: + NoteType = TL_NOTE_DEG_SHA_PUB_FILE; + break; + case Brw_ADMI_DOC_CRS: + NoteType = TL_NOTE_CRS_DOC_PUB_FILE; + break; + case Brw_ADMI_SHR_CRS: + NoteType = TL_NOTE_CRS_SHA_PUB_FILE; + break; + default: + return; + } + TL_Not_MarkNoteAsUnavailable (NoteType,FilCod); + } + break; + default: + break; + } + } + +/*****************************************************************************/ +/***** Mark possible notes involving children of a folder as unavailable *****/ +/*****************************************************************************/ + +void TL_Not_MarkNotesChildrenOfFolderAsUnavailable (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 (); + TL_Not_NoteType_t NoteType; + + switch (FileBrowser) + { + case Brw_ADMI_DOC_INS: + case Brw_ADMI_SHR_INS: + case Brw_ADMI_DOC_CTR: + case Brw_ADMI_SHR_CTR: + case Brw_ADMI_DOC_DEG: + case Brw_ADMI_SHR_DEG: + case Brw_ADMI_DOC_CRS: + case Brw_ADMI_SHR_CRS: + /***** Mark possible note as unavailable *****/ + switch (FileBrowser) + { + case Brw_ADMI_DOC_INS: + NoteType = TL_NOTE_INS_DOC_PUB_FILE; + break; + case Brw_ADMI_SHR_INS: + NoteType = TL_NOTE_INS_SHA_PUB_FILE; + break; + case Brw_ADMI_DOC_CTR: + NoteType = TL_NOTE_CTR_DOC_PUB_FILE; + break; + case Brw_ADMI_SHR_CTR: + NoteType = TL_NOTE_CTR_SHA_PUB_FILE; + break; + case Brw_ADMI_DOC_DEG: + NoteType = TL_NOTE_DEG_DOC_PUB_FILE; + break; + case Brw_ADMI_SHR_DEG: + NoteType = TL_NOTE_DEG_SHA_PUB_FILE; + break; + case Brw_ADMI_DOC_CRS: + NoteType = TL_NOTE_CRS_DOC_PUB_FILE; + break; + case Brw_ADMI_SHR_CRS: + NoteType = TL_NOTE_CRS_SHA_PUB_FILE; + break; + default: + return; + } + DB_QueryUPDATE ("can not mark notes as unavailable", + "UPDATE tl_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); + break; + default: + break; + } + } + +/*****************************************************************************/ +/************************ Form to remove publication *************************/ +/*****************************************************************************/ + +static void TL_Not_PutFormToRemoveNote (const struct TL_Timeline *Timeline, + long NotCod) + { + extern const char *Txt_Remove; + + /***** Form to remove publication *****/ + TL_FormStart (Timeline,ActReqRemTL_PubGbl,ActReqRemTL_PubUsr); + TL_Not_PutHiddenParamNotCod (NotCod); + Ico_PutIconLink ("trash.svg",Txt_Remove); + Frm_EndForm (); + } + +/*****************************************************************************/ +/****************** Put parameter with the code of a note ********************/ +/*****************************************************************************/ + +void TL_Not_PutHiddenParamNotCod (long NotCod) + { + Par_PutHiddenParamLong (NULL,"NotCod",NotCod); + } + +/*****************************************************************************/ +/****************** Get parameter with the code of a note ********************/ +/*****************************************************************************/ + +long TL_Not_GetParamNotCod (void) + { + /***** Get note code *****/ + return Par_GetParToLong ("NotCod"); + } + +/*****************************************************************************/ +/*********************** Request the removal of a note ***********************/ +/*****************************************************************************/ + +void TL_Not_RequestRemNoteUsr (void) + { + struct TL_Timeline Timeline; + + /***** Reset timeline context *****/ + TL_ResetTimeline (&Timeline); + + /***** Get user whom profile is displayed *****/ + Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); + + /***** Show user's profile *****/ + Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat); + + /***** Start section *****/ + HTM_SECTION_Begin (TL_TIMELINE_SECTION_ID); + + /***** Request the removal of note *****/ + TL_Not_RequestRemovalNote (&Timeline); + + /***** Write timeline again (user) *****/ + TL_ShowTimelineUsr (&Timeline); + + /***** End section *****/ + HTM_SECTION_End (); + } + +void TL_Not_RequestRemNoteGbl (void) + { + struct TL_Timeline Timeline; + + /***** Initialize timeline *****/ + TL_InitTimelineGbl (&Timeline); + + /***** Request the removal of note *****/ + TL_Not_RequestRemovalNote (&Timeline); + + /***** Write timeline again (global) *****/ + TL_ShowNoteAndTimelineGbl (&Timeline); + } + +static void TL_Not_RequestRemovalNote (struct TL_Timeline *Timeline) + { + extern const char *Txt_The_original_post_no_longer_exists; + extern const char *Txt_Do_you_really_want_to_remove_the_following_post; + extern const char *Txt_Remove; + struct TL_Not_Note Not; + bool ItsMe; + + /***** Get data of note *****/ + Not.NotCod = TL_Not_GetParamNotCod (); + TL_Not_GetDataOfNoteByCod (&Not); + + if (Not.NotCod > 0) + { + ItsMe = Usr_ItsMe (Not.UsrCod); + if (ItsMe) // I am the author of this note + { + /***** Show question and button to remove note *****/ + /* Start alert */ + Ale_ShowAlertAndButton1 (Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_following_post); + + /* Show note */ + TL_Not_WriteNote (Timeline,&Not, + TL_TOP_MESSAGE_NONE,-1L, + TL_DONT_HIGHLIGHT, + TL_SHOW_ALONE); + + /* End alert */ + Timeline->NotCod = Not.NotCod; // Note to be removed + if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) + Ale_ShowAlertAndButton2 (ActRemTL_PubUsr,"timeline",NULL, + TL_Not_PutParamsRemoveNote,Timeline, + Btn_REMOVE_BUTTON,Txt_Remove); + else + Ale_ShowAlertAndButton2 (ActRemTL_PubGbl,NULL,NULL, + TL_Not_PutParamsRemoveNote,Timeline, + Btn_REMOVE_BUTTON,Txt_Remove); + } + } + else + Ale_ShowAlert (Ale_WARNING,Txt_The_original_post_no_longer_exists); + } + +/*****************************************************************************/ +/********************* Put parameters to remove a note ***********************/ +/*****************************************************************************/ + +static void TL_Not_PutParamsRemoveNote (void *Timeline) + { + if (Timeline) + { + if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) + Usr_PutParamOtherUsrCodEncrypted (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod); + else + Usr_PutHiddenParamWho (((struct TL_Timeline *) Timeline)->Who); + TL_Not_PutHiddenParamNotCod (((struct TL_Timeline *) Timeline)->NotCod); + } + } + +/*****************************************************************************/ +/******************************* Remove a note *******************************/ +/*****************************************************************************/ + +void TL_Not_RemoveNoteUsr (void) + { + struct TL_Timeline Timeline; + + /***** Reset timeline context *****/ + TL_ResetTimeline (&Timeline); + + /***** Get user whom profile is displayed *****/ + Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (); + + /***** Show user's profile *****/ + Prf_ShowUserProfile (&Gbl.Usrs.Other.UsrDat); + + /***** Start section *****/ + HTM_SECTION_Begin (TL_TIMELINE_SECTION_ID); + + /***** Remove a note *****/ + TL_Not_RemoveNote (); + + /***** Write updated timeline after removing (user) *****/ + TL_ShowTimelineUsr (&Timeline); + + /***** End section *****/ + HTM_SECTION_End (); + } + +void TL_Not_RemoveNoteGbl (void) + { + struct TL_Timeline Timeline; + + /***** Initialize timeline *****/ + TL_InitTimelineGbl (&Timeline); + + /***** Remove a note *****/ + TL_Not_RemoveNote (); + + /***** Write updated timeline after removing (global) *****/ + TL_ShowNoteAndTimelineGbl (&Timeline); + } + +static void TL_Not_RemoveNote (void) + { + extern const char *Txt_The_original_post_no_longer_exists; + extern const char *Txt_TIMELINE_Post_removed; + struct TL_Not_Note Not; + bool ItsMe; + + /***** Get data of note *****/ + Not.NotCod = TL_Not_GetParamNotCod (); + TL_Not_GetDataOfNoteByCod (&Not); + + if (Not.NotCod > 0) + { + ItsMe = Usr_ItsMe (Not.UsrCod); + if (ItsMe) // I am the author of this note + { + /***** Delete note from database *****/ + TL_Not_RemoveNoteMediaAndDBEntries (&Not); + + /***** Reset note *****/ + TL_Not_ResetNote (&Not); + + /***** Message of success *****/ + Ale_ShowAlert (Ale_SUCCESS,Txt_TIMELINE_Post_removed); + } + } + else + Ale_ShowAlert (Ale_WARNING,Txt_The_original_post_no_longer_exists); + } + +/*****************************************************************************/ +/*********************** Remove a note from database *************************/ +/*****************************************************************************/ + +static void TL_Not_RemoveNoteMediaAndDBEntries (struct TL_Not_Note *Not) + { + MYSQL_RES *mysql_res; + MYSQL_ROW row; + long PubCod; + unsigned long NumComments; + unsigned long NumCom; + long MedCod; + + /***** Remove comments associated to this note *****/ + /* Get comments of this note */ + NumComments = DB_QuerySELECT (&mysql_res,"can not get comments", + "SELECT PubCod" + " FROM tl_pubs" + " WHERE NotCod=%ld AND PubType=%u", + Not->NotCod, + (unsigned) TL_PUB_COMMENT_TO_NOTE); + + /* For each comment... */ + for (NumCom = 0; + NumCom < NumComments; + NumCom++) + { + /* Get code of comment **/ + row = mysql_fetch_row (mysql_res); + PubCod = Str_ConvertStrCodToLongCod (row[0]); + + /* Remove media associated to comment + and delete comment from database */ + TL_Com_RemoveCommentMediaAndDBEntries (PubCod); + } + + /* Free structure that stores the query result */ + DB_FreeMySQLResult (&mysql_res); + + /***** Remove media associated to post *****/ + if (Not->NoteType == TL_NOTE_POST) + { + /* Remove media associated to a post from database */ + if (DB_QuerySELECT (&mysql_res,"can not get media", + "SELECT MedCod" // row[0] + " FROM tl_posts" + " WHERE PstCod=%ld", + Not->Cod) == 1) // Result should have a unique row + { + /* Get media code */ + row = mysql_fetch_row (mysql_res); + MedCod = Str_ConvertStrCodToLongCod (row[0]); + + /* Remove media */ + Med_RemoveMedia (MedCod); + } + + /* Free structure that stores the query result */ + DB_FreeMySQLResult (&mysql_res); + } + + /***** Mark possible notifications on the publications + of this note as removed *****/ + /* Mark notifications of the original note as removed */ + PubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod); + if (PubCod > 0) + { + Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_FAV ,PubCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE ,PubCod); + Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_MENTION,PubCod); + } + + /***** Remove favs for this note *****/ + DB_QueryDELETE ("can not remove favs for note", + "DELETE FROM tl_notes_fav" + " WHERE NotCod=%ld", + Not->NotCod); + + /***** Remove all the publications of this note *****/ + DB_QueryDELETE ("can not remove a publication", + "DELETE FROM tl_pubs" + " WHERE NotCod=%ld", + Not->NotCod); + + /***** Remove note *****/ + DB_QueryDELETE ("can not remove a note", + "DELETE FROM tl_notes" + " WHERE NotCod=%ld" + " AND UsrCod=%ld", // Extra check: I am the author + Not->NotCod, + Gbl.Usrs.Me.UsrDat.UsrCod); + + if (Not->NoteType == TL_NOTE_POST) + /***** Remove post *****/ + DB_QueryDELETE ("can not remove a post", + "DELETE FROM tl_posts" + " WHERE PstCod=%ld", + Not->Cod); + } + +/*****************************************************************************/ +/************************ Get data of note from row **************************/ +/*****************************************************************************/ + +static void TL_Not_GetDataOfNoteFromRow (MYSQL_ROW row,struct TL_Not_Note *Not) + { + /* + row[0]: NotCod + row[1]: NoteType + row[2]: Cod + row[3]: UsrCod + row[4]: HieCod + row[5]: Unavailable + row[5]: UNIX_TIMESTAMP(TimeNote) + */ + /***** Get code (row[0]) *****/ + Not->NotCod = Str_ConvertStrCodToLongCod (row[0]); + + /***** Get note type (row[1]) *****/ + Not->NoteType = TL_Not_GetNoteTypeFromStr ((const char *) row[1]); + + /***** Get file/post... code (row[2]) *****/ + Not->Cod = Str_ConvertStrCodToLongCod (row[2]); + + /***** Get (from) user code (row[3]) *****/ + Not->UsrCod = Str_ConvertStrCodToLongCod (row[3]); + + /***** Get hierarchy code (row[4]) *****/ + Not->HieCod = Str_ConvertStrCodToLongCod (row[4]); + + /***** File/post... unavailable (row[5]) *****/ + Not->Unavailable = (row[5][0] == 'Y'); + + /***** Get time of the note (row[6]) *****/ + Not->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[6]); + + /***** Get number of times this note has been shared *****/ + TL_Sha_UpdateNumTimesANoteHasBeenShared (Not); + + /***** Get number of times this note has been favourited *****/ + TL_Fav_GetNumTimesANoteHasBeenFav (Not); + } + +/*****************************************************************************/ +/********* Get note type from string number coming from database *************/ +/*****************************************************************************/ + +static TL_Not_NoteType_t TL_Not_GetNoteTypeFromStr (const char *Str) + { + unsigned UnsignedNum; + + if (sscanf (Str,"%u",&UnsignedNum) == 1) + if (UnsignedNum < TL_NOT_NUM_NOTE_TYPES) + return (TL_Not_NoteType_t) UnsignedNum; + + return TL_NOTE_UNKNOWN; + } + +/*****************************************************************************/ +/*************************** Reset fields of note ****************************/ +/*****************************************************************************/ + +static void TL_Not_ResetNote (struct TL_Not_Note *Not) + { + Not->NotCod = -1L; + Not->NoteType = TL_NOTE_UNKNOWN; + Not->UsrCod = -1L; + Not->HieCod = -1L; + Not->Cod = -1L; + Not->Unavailable = false; + Not->DateTimeUTC = (time_t) 0; + Not->NumShared = 0; + } + +/*****************************************************************************/ +/****** Add just retrieved notes to current timeline for this session ********/ +/*****************************************************************************/ + +void TL_Not_AddNotesJustRetrievedToTimelineThisSession (void) + { + /* tl_timelines contains the distinct notes in timeline of each open session: +mysql> SELECT SessionId,COUNT(*) FROM tl_timelines GROUP BY SessionId; ++---------------------------------------------+----------+ +| SessionId | COUNT(*) | ++---------------------------------------------+----------+ +| u-X-R3gKki7eKMXrNCP8bGhwOAZuVngRy7FNGZFMKzI | 52 | --> 52 distinct notes +| u1CoqL1YWl3_hR4wk4bI7vhnc-uRcCmIDyKYAgBB6kk | 10 | +| u8xqamzkorHfY4BvYRMXjNhzHvQyigZUZemO0YiMn48 | 10 | +| u_n2V_L3KrFjnd4SqZk0gxMFwZHRuWZ8_EIVTU9sdpI | 10 | +| V6pGe1kGGS_uO5i__waqXKnuDkPYaDZHNAYr-Zv-GJQ | 2 | +| vqDRz-iiM8v10Dl8ThwqIqmDRIklz8szJaqflwXZucs | 10 | +| w11juqKPx6lg-f_pL2ZBYqlagU1mEepSvvk9L3gDGac | 10 | --> 10 distinct notes +| wLg4e8KQljCcVuFWIkJjNeti89kAiwOZ3iyXdzm_eDk | 10 | +| wnU85YrwJHhZGWIZhd7LQfQTPrclIWHfMF3DcB-Rcgw | 4 | +| wRzRJFnHfzW61fZYnvMIaMRlkuWUeEyqXVQ6JeWA32k | 11 | ++---------------------------------------------+----------+ +10 rows in set (0,01 sec) + */ + DB_QueryINSERT ("can not insert notes in timeline", + "INSERT IGNORE INTO tl_timelines" + " (SessionId,NotCod)" + " SELECT '%s',NotCod FROM tl_tmp_just_retrieved_notes", + Gbl.Session.Id); + } + +/*****************************************************************************/ +/******************** Get data of note using its code ************************/ +/*****************************************************************************/ + +void TL_Not_GetDataOfNoteByCod (struct TL_Not_Note *Not) + { + MYSQL_RES *mysql_res; + MYSQL_ROW row; + + if (Not->NotCod > 0) + { + /***** Get data of note from database *****/ + if (DB_QuerySELECT (&mysql_res,"can not get data of note", + "SELECT NotCod," // row[0] + "NoteType," // row[1] + "Cod," // row[2] + "UsrCod," // row[3] + "HieCod," // row[4] + "Unavailable," // row[5] + "UNIX_TIMESTAMP(TimeNote)" // row[6] + " FROM tl_notes" + " WHERE NotCod=%ld", + Not->NotCod)) + { + /***** Get data of note *****/ + row = mysql_fetch_row (mysql_res); + TL_Not_GetDataOfNoteFromRow (row,Not); + } + else + /***** Reset fields of note *****/ + TL_Not_ResetNote (Not); + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + else + /***** Reset fields of note *****/ + TL_Not_ResetNote (Not); + } + diff --git a/swad_timeline_note.h b/swad_timeline_note.h new file mode 100644 index 00000000..ddf5bcd0 --- /dev/null +++ b/swad_timeline_note.h @@ -0,0 +1,124 @@ +// swad_timeline_note.h: social timeline notes + +#ifndef _SWAD_TL_NOT +#define _SWAD_TL_NOT +/* + SWAD (Shared Workspace At a Distance in Spanish), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 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 Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************** Headers **********************************/ +/*****************************************************************************/ + +#include "swad_timeline.h" + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/******************************** Public types *******************************/ +/*****************************************************************************/ + +#define TL_NOT_NUM_NOTE_TYPES 13 +// If the numbers assigned to each event type change, +// it is necessary to change old numbers to new ones in database table tl_notes +typedef enum + { + TL_NOTE_UNKNOWN = 0, + /* Start tab */ + TL_NOTE_POST = 10, // Post written directly in timeline + /* Institution tab */ + TL_NOTE_INS_DOC_PUB_FILE = 1, // Public file in documents of institution + TL_NOTE_INS_SHA_PUB_FILE = 2, // Public file in shared files of institution + /* Centre tab */ + TL_NOTE_CTR_DOC_PUB_FILE = 3, // Public file in documents of centre + TL_NOTE_CTR_SHA_PUB_FILE = 4, // Public file in shared files of centre + /* Degree tab */ + TL_NOTE_DEG_DOC_PUB_FILE = 5, // Public file in documents of degree + TL_NOTE_DEG_SHA_PUB_FILE = 6, // Public file in shared files of degree + /* Course tab */ + TL_NOTE_CRS_DOC_PUB_FILE = 7, // Public file in documents of course + TL_NOTE_CRS_SHA_PUB_FILE = 8, // Public file in shared files of course + /* Assessment tab */ + TL_NOTE_EXAM_ANNOUNCEMENT = 9, // Exam announcement in a course + /* Users tab */ + /* Messages tab */ + TL_NOTE_NOTICE = 12, // A public notice in a course + TL_NOTE_FORUM_POST = 11, // Post in global/swad forums + /* Analytics tab */ + /* Profile tab */ + } TL_Not_NoteType_t; + +struct TL_Not_Note + { + long NotCod; // Unique code/identifier for each note + TL_Not_NoteType_t NoteType; // Timeline post, public file, exam announcement, notice, forum post... + long UsrCod; // Publisher + long HieCod; // Hierarchy code (institution/centre/degree/course) + long Cod; // Code of file, forum post, notice, timeline post... + bool Unavailable; // File, forum post, notice,... unavailable (removed) + time_t DateTimeUTC; // Date-time of publication in UTC time + unsigned NumShared; // Number of times (users) this note has been shared + unsigned NumFavs; // Number of times (users) this note has been favourited + }; + +/*****************************************************************************/ +/****************************** Public prototypes ****************************/ +/*****************************************************************************/ + +void TL_Not_ShowHighlightedNote (struct TL_Timeline *Timeline, + struct TL_Not_Note *Not); + +void TL_Not_InsertNoteInJustRetrievedNotes (long NotCod); +void TL_Not_InsertNoteInVisibleTimeline (long NotCod); + +void TL_Not_WriteNote (struct TL_Timeline *Timeline, + const struct TL_Not_Note *Not, + TL_TopMessage_t TopMessage, + long PublisherCod, // Who did the action (publication, commenting, faving, sharing, mentioning) + TL_Highlight_t Highlight, // Highlight note + TL_ShowAlone_t ShowNoteAlone); // Note is shown alone, not in a list +void TL_Not_WriteAuthorNote (const struct UsrData *UsrDat); + +void TL_Not_GetNoteSummary (const struct TL_Not_Note *Not, + char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1]); + +void TL_Not_StoreAndPublishNote (TL_Not_NoteType_t NoteType,long Cod); +void TL_Not_StoreAndPublishNoteInternal (TL_Not_NoteType_t NoteType,long Cod,struct TL_Publication *Pub); +void TL_Not_MarkNoteAsUnavailable (TL_Not_NoteType_t NoteType,long Cod); +void TL_Not_MarkNoteOneFileAsUnavailable (const char *Path); +void TL_Not_MarkNotesChildrenOfFolderAsUnavailable (const char *Path); + +void TL_Not_PutHiddenParamNotCod (long NotCod); +long TL_Not_GetParamNotCod (void); + +void TL_Not_RequestRemNoteUsr (void); +void TL_Not_RequestRemNoteGbl (void); +void TL_Not_RemoveNoteUsr (void); +void TL_Not_RemoveNoteGbl (void); + +void TL_Not_AddNotesJustRetrievedToTimelineThisSession (void); + +long TL_Not_GetPubCodOfOriginalNote (long NotCod); + +void TL_Not_GetDataOfNoteByCod (struct TL_Not_Note *Not); + +#endif diff --git a/swad_timeline_share.c b/swad_timeline_share.c index 28cb4674..dda26cf8 100644 --- a/swad_timeline_share.c +++ b/swad_timeline_share.c @@ -60,12 +60,12 @@ static void TL_Sha_PutDisabledIconShare (unsigned NumShared); static void TL_Sha_PutFormToShaNote (long ParamCod); static void TL_Sha_PutFormToUnsNote (long ParamCod); -static void TL_Sha_ShaNote (struct TL_Note *Not); -static void TL_Sha_UnsNote (struct TL_Note *Not); +static void TL_Sha_ShaNote (struct TL_Not_Note *Not); +static void TL_Sha_UnsNote (struct TL_Not_Note *Not); static bool TL_Sha_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod); -static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Note *Not, +static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not, TL_HowManyUsrs_t HowManyUsrs); /*****************************************************************************/ @@ -129,11 +129,11 @@ void TL_Sha_ShowAllSharersNoteUsr (void) void TL_Sha_ShowAllSharersNoteGbl (void) { - struct TL_Note Not; + struct TL_Not_Note Not; /***** Get data of note *****/ - Not.NotCod = TL_GetParamNotCod (); - TL_GetDataOfNoteByCod (&Not); + Not.NotCod = TL_Not_GetParamNotCod (); + TL_Not_GetDataOfNoteByCod (&Not); /***** Write HTML inside DIV with form to share/unshare *****/ TL_Sha_PutFormToShaUnsNote (&Not,TL_SHOW_ALL_USRS); @@ -150,7 +150,7 @@ void TL_Sha_ShaNoteUsr (void) void TL_Sha_ShaNoteGbl (void) { - struct TL_Note Not; + struct TL_Not_Note Not; /***** Share note *****/ TL_Sha_ShaNote (&Not); @@ -159,7 +159,7 @@ void TL_Sha_ShaNoteGbl (void) TL_Sha_PutFormToShaUnsNote (&Not,TL_SHOW_FEW_USRS); } -static void TL_Sha_ShaNote (struct TL_Note *Not) +static void TL_Sha_ShaNote (struct TL_Not_Note *Not) { // extern const char *Txt_The_original_post_no_longer_exists; struct TL_Publication Pub; @@ -167,28 +167,28 @@ static void TL_Sha_ShaNote (struct TL_Note *Not) long OriginalPubCod; /***** Get data of note *****/ - Not->NotCod = TL_GetParamNotCod (); - TL_GetDataOfNoteByCod (Not); + Not->NotCod = TL_Not_GetParamNotCod (); + TL_Not_GetDataOfNoteByCod (Not); if (Not->NotCod > 0) { ItsMe = Usr_ItsMe (Not->UsrCod); if (Gbl.Usrs.Me.Logged && !ItsMe) // I am not the author if (!TL_Sha_CheckIfNoteIsSharedByUsr (Not->NotCod, - Gbl.Usrs.Me.UsrDat.UsrCod)) // Not yet shared by me + Gbl.Usrs.Me.UsrDat.UsrCod)) // Not yet shared by me { /***** Share (publish note in timeline) *****/ Pub.NotCod = Not->NotCod; Pub.PublisherCod = Gbl.Usrs.Me.UsrDat.UsrCod; Pub.PubType = TL_PUB_SHARED_NOTE; - TL_PublishNoteInTimeline (&Pub); // Set Pub.PubCod + TL_PublishPubInTimeline (&Pub); // Set Pub.PubCod /* Update number of times this note is shared */ TL_Sha_UpdateNumTimesANoteHasBeenShared (Not); /**** Create notification about shared post for the author of the post ***/ - OriginalPubCod = TL_GetPubCodOfOriginalNote (Not->NotCod); + OriginalPubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod); if (OriginalPubCod > 0) TL_CreateNotifToAuthor (Not->UsrCod,OriginalPubCod,Ntf_EVENT_TIMELINE_SHARE); } @@ -210,7 +210,7 @@ void TL_Sha_UnsNoteUsr (void) void TL_Sha_UnsNoteGbl (void) { - struct TL_Note Not; + struct TL_Not_Note Not; /***** Unshare note *****/ TL_Sha_UnsNote (&Not); @@ -219,15 +219,15 @@ void TL_Sha_UnsNoteGbl (void) TL_Sha_PutFormToShaUnsNote (&Not,TL_SHOW_FEW_USRS); } -static void TL_Sha_UnsNote (struct TL_Note *Not) +static void TL_Sha_UnsNote (struct TL_Not_Note *Not) { // extern const char *Txt_The_original_post_no_longer_exists; long OriginalPubCod; bool ItsMe; /***** Get data of note *****/ - Not->NotCod = TL_GetParamNotCod (); - TL_GetDataOfNoteByCod (Not); + Not->NotCod = TL_Not_GetParamNotCod (); + TL_Not_GetDataOfNoteByCod (Not); if (Not->NotCod > 0) { @@ -251,14 +251,14 @@ static void TL_Sha_UnsNote (struct TL_Note *Not) TL_Sha_UpdateNumTimesANoteHasBeenShared (Not); /***** Mark possible notifications on this note as removed *****/ - OriginalPubCod = TL_GetPubCodOfOriginalNote (Not->NotCod); + OriginalPubCod = TL_Not_GetPubCodOfOriginalNote (Not->NotCod); if (OriginalPubCod > 0) Ntf_MarkNotifAsRemoved (Ntf_EVENT_TIMELINE_SHARE,OriginalPubCod); } } } -void TL_Sha_PutFormToShaUnsNote (const struct TL_Note *Not, +void TL_Sha_PutFormToShaUnsNote (const struct TL_Not_Note *Not, TL_HowManyUsrs_t HowManyUsrs) { bool IAmTheAuthor; @@ -307,7 +307,7 @@ static bool TL_Sha_CheckIfNoteIsSharedByUsr (long NotCod,long UsrCod) /********** Get number of times a note has been shared in timeline ***********/ /*****************************************************************************/ -void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Note *Not) +void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Not_Note *Not) { /***** Get number of times (users) this note has been shared *****/ Not->NumShared = @@ -326,7 +326,7 @@ void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Note *Not) /******************* Show users who have shared this note ********************/ /*****************************************************************************/ -static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Note *Not, +static void TL_Sha_ShowUsrsWhoHaveSharedNote (const struct TL_Not_Note *Not, TL_HowManyUsrs_t HowManyUsrs) { MYSQL_RES *mysql_res; diff --git a/swad_timeline_share.h b/swad_timeline_share.h index 7cd632e9..c3309cdb 100644 --- a/swad_timeline_share.h +++ b/swad_timeline_share.h @@ -27,6 +27,8 @@ /********************************** Headers **********************************/ /*****************************************************************************/ +#include "swad_timeline_note.h" + /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ @@ -45,9 +47,9 @@ void TL_Sha_ShaNoteUsr (void); void TL_Sha_ShaNoteGbl (void); void TL_Sha_UnsNoteUsr (void); void TL_Sha_UnsNoteGbl (void); -void TL_Sha_PutFormToShaUnsNote (const struct TL_Note *Not, +void TL_Sha_PutFormToShaUnsNote (const struct TL_Not_Note *Not, TL_HowManyUsrs_t HowManyUsrs); -void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Note *Not); +void TL_Sha_UpdateNumTimesANoteHasBeenShared (struct TL_Not_Note *Not); #endif diff --git a/swad_timetable.c b/swad_timetable.c index 70ab18f6..d3c5232d 100644 --- a/swad_timetable.c +++ b/swad_timetable.c @@ -1492,7 +1492,7 @@ static void TT_TimeTableDrawCell (const struct TT_Timetable *Timetable, char *ColSpanStr; char *ClassStr; TT_ClassType_t CT; - struct Course Crs; + struct Crs_Course Crs; struct GroupType *GrpTyp; struct Group *Grp; char *Room; diff --git a/swad_user.c b/swad_user.c index feb34b8f..28180cae 100644 --- a/swad_user.c +++ b/swad_user.c @@ -3585,7 +3585,7 @@ void Usr_WriteRowUsrMainData (unsigned NumUsr,struct UsrData *UsrDat, bool ShowPhoto; bool UsrIsTheMsgSender = PutCheckBoxToSelectUsr && (UsrDat->UsrCod == Gbl.Usrs.Other.UsrDat.UsrCod); - struct Instit Ins; + struct Ins_Instit Ins; /***** Start row *****/ HTM_TR_Begin (NULL); @@ -3673,8 +3673,8 @@ static void Usr_WriteRowGstAllData (struct UsrData *UsrDat) { char PhotoURL[PATH_MAX + 1]; bool ShowPhoto; - struct Instit Ins; - struct Centre Ctr; + struct Ins_Instit Ins; + struct Ctr_Centre Ctr; struct Dpt_Department Dpt; /***** Start row *****/ @@ -3762,7 +3762,7 @@ static void Usr_WriteRowStdAllData (struct UsrData *UsrDat,char *GroupNames) MYSQL_RES *mysql_res; MYSQL_ROW row; char Text[Cns_MAX_BYTES_TEXT + 1]; - struct Instit Ins; + struct Ins_Instit Ins; bool ShowData = (Gbl.Usrs.Me.Role.Logged == Rol_TCH && UsrDat->Accepted) || Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM; @@ -3863,12 +3863,12 @@ static void Usr_WriteRowTchAllData (struct UsrData *UsrDat) { char PhotoURL[PATH_MAX + 1]; bool ShowPhoto; - struct Instit Ins; + struct Ins_Instit Ins; bool ItsMe = Usr_ItsMe (UsrDat->UsrCod); bool ShowData = (ItsMe || UsrDat->Accepted || Gbl.Usrs.Me.Role.Logged == Rol_DEG_ADM || Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); - struct Centre Ctr; + struct Ctr_Centre Ctr; struct Dpt_Department Dpt; /***** Start row *****/ @@ -3941,7 +3941,7 @@ static void Usr_WriteRowAdmData (unsigned NumUsr,struct UsrData *UsrDat) { char PhotoURL[PATH_MAX + 1]; bool ShowPhoto; - struct Instit Ins; + struct Ins_Instit Ins; /***** Start row *****/ HTM_TR_Begin (NULL); @@ -4307,7 +4307,7 @@ void Usr_FlushCacheNumUsrsWhoClaimToBelongToIns (void) Gbl.Cache.NumUsrsWhoClaimToBelongToIns.NumUsrs = 0; } -unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Instit *Ins) +unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Ins_Instit *Ins) { /***** 1. Fast check: Trivial case *****/ if (Ins->InsCod <= 0) @@ -4340,7 +4340,7 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Instit *Ins) return Ins->NumUsrsWhoClaimToBelongToIns.NumUsrs; } -unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToIns (struct Instit *Ins) +unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToIns (struct Ins_Instit *Ins) { unsigned NumUsrsIns; @@ -4363,7 +4363,7 @@ void Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr (void) Gbl.Cache.NumUsrsWhoClaimToBelongToCtr.NumUsrs = 0; } -unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr) +unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Ctr_Centre *Ctr) { /***** 1. Fast check: Trivial case *****/ if (Ctr->CtrCod <= 0) @@ -4395,7 +4395,7 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr) return Ctr->NumUsrsWhoClaimToBelongToCtr.NumUsrs; } -unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr) +unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (struct Ctr_Centre *Ctr) { unsigned NumUsrsCtr; diff --git a/swad_user.h b/swad_user.h index 2c4c0ddf..d49f2cff 100644 --- a/swad_user.h +++ b/swad_user.h @@ -421,12 +421,12 @@ unsigned Usr_GetNumUsrsWhoClaimToBelongToCty (struct Country *Cty); unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCty (struct Country *Cty); void Usr_FlushCacheNumUsrsWhoClaimToBelongToIns (void); -unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Instit *Ins); -unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToIns (struct Instit *Ins); +unsigned Usr_GetNumUsrsWhoClaimToBelongToIns (struct Ins_Instit *Ins); +unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToIns (struct Ins_Instit *Ins); void Usr_FlushCacheNumUsrsWhoClaimToBelongToCtr (void); -unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr); -unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (struct Centre *Ctr); +unsigned Usr_GetNumUsrsWhoClaimToBelongToCtr (struct Ctr_Centre *Ctr); +unsigned Usr_GetCachedNumUsrsWhoClaimToBelongToCtr (struct Ctr_Centre *Ctr); void Usr_GetListUsrs (Hie_Level_t Scope,Rol_Role_t Role);