diff --git a/sql/swad.sql b/sql/swad.sql index dcd8e050e..d3400dc4e 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -917,7 +917,7 @@ CREATE TABLE IF NOT EXISTS sessions ( -- CREATE TABLE IF NOT EXISTS social ( SocCod BIGINT NOT NULL AUTO_INCREMENT, - SocialEvent TINYINT NOT NULL, + SocialNote TINYINT NOT NULL, UsrCod INT NOT NULL, CtyCod INT NOT NULL DEFAULT -1, InsCod INT NOT NULL DEFAULT -1, @@ -925,15 +925,15 @@ CREATE TABLE IF NOT EXISTS social ( DegCod INT NOT NULL DEFAULT -1, CrsCod INT NOT NULL DEFAULT -1, Cod INT NOT NULL DEFAULT -1, - TimeEvent DATETIME NOT NULL, + TimeNote DATETIME NOT NULL, UNIQUE INDEX(SocCod), - INDEX(SocialEvent), + INDEX(SocialNote), INDEX(UsrCod), - INDEX(TimeEvent)); + INDEX(TimeNote)); -- --- Table social_post: stores social posts +-- Table social_posts: stores social posts (public comments written by users) -- -CREATE TABLE IF NOT EXISTS social_post ( +CREATE TABLE IF NOT EXISTS social_posts ( PstCod INT NOT NULL AUTO_INCREMENT, Content LONGTEXT NOT NULL, UNIQUE INDEX(PstCod), diff --git a/swad_action.c b/swad_action.c index 7b75b670c..dc8b5e84d 100644 --- a/swad_action.c +++ b/swad_action.c @@ -1004,8 +1004,8 @@ Social: 839. ActReqSocPst Write a public social post to be displayed in the timeline 840. ActRcvSocPst Receive a public social post to be displayed in the timeline - 841. ActReqRemSocEvn Request the removal of a social event - 842. ActRemSocEvn Remove a social event + 841. ActReqRemSocNot Request the removal of a social note (only if it is a post) + 842. ActRemSocNot Remove a social note (only if it is a post) 843. ActSeePubPrf Show a public user's profile 844. ActCal1stClkTim Calculate first click time from log and store into user's figures 845. ActCalNumClk Calculate number of clicks from log and store into user's figures @@ -2315,8 +2315,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActReqSocPst */{1491,-1,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_FormSocialPost ,NULL}, /* ActRcvSocPst */{1492,-1,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_ReceiveSocialPost ,NULL}, - /* ActReqRemSocEvn */{1494,-1,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_RequestRemovalSocialEvent ,NULL}, - /* ActRemSocEvn */{1493,-1,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_RemoveSocialEvent ,NULL}, + /* ActReqRemSocNot */{1494,-1,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_RequestRemovalSocialNote ,NULL}, + /* ActRemSocNot */{1493,-1,TabSoc,ActSeeSocAct ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Soc_RemoveSocialNote ,NULL}, /* ActSeePubPrf */{1402,-1,TabSoc,ActReqPubPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_GetUsrCodAndShowUserProfile,NULL}, /* ActCal1stClkTim */{1405,-1,TabSoc,ActReqPubPrf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Prf_CalculateFirstClickTime ,NULL}, @@ -4157,8 +4157,8 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActSeeSocAct, // #1490 ActReqSocPst, // #1491 ActRcvSocPst, // #1492 - ActRemSocEvn, // #1493 - ActReqRemSocEvn, // #1494 + ActRemSocNot, // #1493 + ActReqRemSocNot, // #1494 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index e7c45c128..e7ce9e68f 100644 --- a/swad_action.h +++ b/swad_action.h @@ -1043,8 +1043,8 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica // Secondary actions #define ActReqSocPst (ActLstClk+ 5) #define ActRcvSocPst (ActLstClk+ 6) -#define ActReqRemSocEvn (ActLstClk+ 7) -#define ActRemSocEvn (ActLstClk+ 8) +#define ActReqRemSocNot (ActLstClk+ 7) +#define ActRemSocNot (ActLstClk+ 8) #define ActSeePubPrf (ActLstClk+ 9) #define ActCal1stClkTim (ActLstClk+ 10) diff --git a/swad_changelog.h b/swad_changelog.h index 794089665..6af18f848 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -111,18 +111,30 @@ // TODO: Reply to all // TODO: Hour in exam announcement should start at six a.m. // TODO: When a file, notice, etc. is removed, it should be removed from social events? +// TODO: New database table used to store users who write or share social /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.85 (2015-12-30)" +#define Log_PLATFORM_VERSION "SWAD 15.86 (2015-12-30)" #define CSS_FILE "swad15.84.2.css" #define JS_FILE "swad15.77.7.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1 /* + Version 15.86: Dec 30, 2015 Renamed database tables related to social events. (? lines) + 4 changes necessary in database: +RENAME TABLE social_post TO social_posts; +RENAME TABLE social TO social_notes; +ALTER TABLE social_notes CHANGE COLUMN SocialEvent SocialNote TINYINT NOT NULL; +ALTER TABLE social_notes CHANGE COLUMN TimeEvent TimeNote DATETIME NOT NULL; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1492','es','N','Crear comentario social'); +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1493','es','N','Eliminar comentario social'); +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1494','es','N','Solicitar elim. comentario social'); + + Version 15.85.1: Dec 30, 2015 Remove social events when a user is removed. (189439 lines) Version 15.85: Dec 30, 2015 Forums option is moved to social tab. (189439 lines) Version 15.84.5: Dec 30, 2015 Form to update connected users. (189430 lines) Version 15.84.4: Dec 30, 2015 Code refactoring in profile. (189427 lines) diff --git a/swad_database.c b/swad_database.c index 08eb45b68..680439315 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1935,28 +1935,28 @@ mysql> DESCRIBE sessions; "UNIQUE INDEX(SessionId)," "INDEX(UsrCod))"); - /***** Table social *****/ + /***** Table social_notes *****/ /* -mysql> DESCRIBE social; -+-------------+------------+------+-----+---------+----------------+ -| Field | Type | Null | Key | Default | Extra | -+-------------+------------+------+-----+---------+----------------+ -| SocCod | bigint(20) | NO | PRI | NULL | auto_increment | -| SocialEvent | tinyint(4) | NO | MUL | NULL | | -| UsrCod | int(11) | NO | MUL | NULL | | -| CtyCod | int(11) | NO | | -1 | | -| InsCod | int(11) | NO | | -1 | | -| CtrCod | int(11) | NO | | -1 | | -| DegCod | int(11) | NO | | -1 | | -| CrsCod | int(11) | NO | | -1 | | -| Cod | int(11) | NO | | -1 | | -| TimeEvent | datetime | NO | MUL | NULL | | -+-------------+------------+------+-----+---------+----------------+ +mysql> DESCRIBE social_notes; ++------------+------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++------------+------------+------+-----+---------+----------------+ +| SocCod | bigint(20) | NO | PRI | NULL | auto_increment | +| SocialNote | tinyint(4) | NO | MUL | NULL | | +| UsrCod | int(11) | NO | MUL | NULL | | +| CtyCod | int(11) | NO | | -1 | | +| InsCod | int(11) | NO | | -1 | | +| CtrCod | int(11) | NO | | -1 | | +| DegCod | int(11) | NO | | -1 | | +| CrsCod | int(11) | NO | | -1 | | +| Cod | int(11) | NO | | -1 | | +| TimeNote | datetime | NO | MUL | NULL | | ++------------+------------+------+-----+---------+----------------+ 10 rows in set (0.00 sec) */ - DB_CreateTable ("CREATE TABLE IF NOT EXISTS social (" + DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_notes (" "SocCod BIGINT NOT NULL AUTO_INCREMENT," - "SocialEvent TINYINT NOT NULL," + "SocialNote TINYINT NOT NULL," "UsrCod INT NOT NULL," "CtyCod INT NOT NULL DEFAULT -1," "InsCod INT NOT NULL DEFAULT -1," @@ -1964,15 +1964,15 @@ mysql> DESCRIBE social; "DegCod INT NOT NULL DEFAULT -1," "CrsCod INT NOT NULL DEFAULT -1," "Cod INT NOT NULL DEFAULT -1," - "TimeEvent DATETIME NOT NULL," + "TimeNote DATETIME NOT NULL," "UNIQUE INDEX(SocCod)," - "INDEX(SocialEvent)," + "INDEX(SocialNote)," "INDEX(UsrCod)," - "INDEX(TimeEvent))"); + "INDEX(TimeNote))"); - /***** Table social_post *****/ + /***** Table social_posts *****/ /* -mysql> DESCRIBE social_post; +mysql> DESCRIBE social_posts; +---------+----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+----------+------+-----+---------+----------------+ @@ -1981,7 +1981,7 @@ mysql> DESCRIBE social_post; +---------+----------+------+-----+---------+----------------+ 2 rows in set (0.00 sec) */ - DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_post (" + DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_posts (" "PstCod INT NOT NULL AUTO_INCREMENT," "Content LONGTEXT NOT NULL," "UNIQUE INDEX(PstCod)," diff --git a/swad_exam.c b/swad_exam.c index bcc3880a1..4f4b1fe52 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -305,8 +305,8 @@ void Exa_ReceiveExamAnnouncement (void) Exa_UpdateNumUsrsNotifiedByEMailAboutExamAnnouncement (ExaCod,NumUsrsToBeNotifiedByEMail); Ntf_ShowAlertNumUsrsToBeNotifiedByEMail (NumUsrsToBeNotifiedByEMail); - /***** Create a new social event about the new exam announcement *****/ - Soc_StoreSocialEvent (Soc_EVENT_EXAM_ANNOUNCEMENT,ExaCod); + /***** Create a new social note about the new exam announcement *****/ + Soc_StoreSocialNote (Soc_NOTE_EXAM_ANNOUNCEMENT,ExaCod); /***** Show exam announcement *****/ Exa_ListExamAnnouncementsEdit (); diff --git a/swad_file_browser.c b/swad_file_browser.c index 2df3b15ad..4359cba57 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -9684,28 +9684,28 @@ void Brw_ChgFileMetadata (void) switch (Gbl.FileBrowser.Type) { case Brw_ADMI_DOCUM_INS: - Soc_StoreSocialEvent (Soc_EVENT_INS_DOC_PUB_FILE,FileMetadata.FilCod); + Soc_StoreSocialNote (Soc_NOTE_INS_DOC_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_SHARE_INS: - Soc_StoreSocialEvent (Soc_EVENT_INS_SHA_PUB_FILE,FileMetadata.FilCod); + Soc_StoreSocialNote (Soc_NOTE_INS_SHA_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_DOCUM_CTR: - Soc_StoreSocialEvent (Soc_EVENT_CTR_DOC_PUB_FILE,FileMetadata.FilCod); + Soc_StoreSocialNote (Soc_NOTE_CTR_DOC_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_SHARE_CTR: - Soc_StoreSocialEvent (Soc_EVENT_CTR_SHA_PUB_FILE,FileMetadata.FilCod); + Soc_StoreSocialNote (Soc_NOTE_CTR_SHA_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_DOCUM_DEG: - Soc_StoreSocialEvent (Soc_EVENT_DEG_DOC_PUB_FILE,FileMetadata.FilCod); + Soc_StoreSocialNote (Soc_NOTE_DEG_DOC_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_SHARE_DEG: - Soc_StoreSocialEvent (Soc_EVENT_DEG_SHA_PUB_FILE,FileMetadata.FilCod); + Soc_StoreSocialNote (Soc_NOTE_DEG_SHA_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_DOCUM_CRS: - Soc_StoreSocialEvent (Soc_EVENT_CRS_DOC_PUB_FILE,FileMetadata.FilCod); + Soc_StoreSocialNote (Soc_NOTE_CRS_DOC_PUB_FILE,FileMetadata.FilCod); break; case Brw_ADMI_SHARE_CRS: - Soc_StoreSocialEvent (Soc_EVENT_CRS_SHA_PUB_FILE,FileMetadata.FilCod); + Soc_StoreSocialNote (Soc_NOTE_CRS_SHA_PUB_FILE,FileMetadata.FilCod); break; default: break; diff --git a/swad_forum.c b/swad_forum.c index 7033d1d87..82aea9d18 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -3831,12 +3831,12 @@ void For_RecForumPst (void) Ntf_ShowAlertNumUsrsToBeNotifiedByEMail (NumUsrsToBeNotifiedByEMail); } - /***** Insert post into public social activity *****/ + /***** Insert forum post into public social activity *****/ switch (Gbl.Forum.ForumType) // Only if forum is public for any logged user { case For_FORUM_GLOBAL_USRS: case For_FORUM_SWAD_USRS: - Soc_StoreSocialEvent (Soc_EVENT_FORUM_POST,PstCod); + Soc_StoreSocialNote (Soc_NOTE_FORUM_POST,PstCod); break; default: break; diff --git a/swad_notice.c b/swad_notice.c index e6e606a18..086754a6e 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -154,8 +154,8 @@ void Not_ReceiveNotice (void) Not_UpdateNumUsrsNotifiedByEMailAboutNotice (NotCod,NumUsrsToBeNotifiedByEMail); Ntf_ShowAlertNumUsrsToBeNotifiedByEMail (NumUsrsToBeNotifiedByEMail); - /***** Create a new social event about the new notice *****/ - Soc_StoreSocialEvent (Soc_EVENT_NOTICE,NotCod); + /***** Create a new social note about the new notice *****/ + Soc_StoreSocialNote (Soc_NOTE_NOTICE,NotCod); } /*****************************************************************************/ diff --git a/swad_social.c b/swad_social.c index 256d8e057..db332721f 100644 --- a/swad_social.c +++ b/swad_social.c @@ -1,4 +1,4 @@ -// swad_social.c: social networking +// swad_social.c: social networking (timeline) /* SWAD (Shared Workspace At a Distance), @@ -50,37 +50,37 @@ #define Soc_MAX_BYTES_SUMMARY 100 -static const Act_Action_t Soc_DefaultActions[Soc_NUM_SOCIAL_EVENTS] = +static const Act_Action_t Soc_DefaultActions[Soc_NUM_SOCIAL_NOTES] = { - ActUnk, // Soc_EVENT_UNKNOWN + ActUnk, // Soc_NOTE_UNKNOWN /* Institution tab */ - ActSeeDocIns, // Soc_EVENT_INS_DOC_PUB_FILE - ActAdmComIns, // Soc_EVENT_INS_SHA_PUB_FILE + ActSeeDocIns, // Soc_NOTE_INS_DOC_PUB_FILE + ActAdmComIns, // Soc_NOTE_INS_SHA_PUB_FILE /* Centre tab */ - ActSeeDocCtr, // Soc_EVENT_CTR_DOC_PUB_FILE - ActAdmComCtr, // Soc_EVENT_CTR_SHA_PUB_FILE + ActSeeDocCtr, // Soc_NOTE_CTR_DOC_PUB_FILE + ActAdmComCtr, // Soc_NOTE_CTR_SHA_PUB_FILE /* Degree tab */ - ActSeeDocDeg, // Soc_EVENT_DEG_DOC_PUB_FILE - ActAdmComDeg, // Soc_EVENT_DEG_SHA_PUB_FILE + ActSeeDocDeg, // Soc_NOTE_DEG_DOC_PUB_FILE + ActAdmComDeg, // Soc_NOTE_DEG_SHA_PUB_FILE /* Course tab */ - ActSeeDocCrs, // Soc_EVENT_CRS_DOC_PUB_FILE - ActAdmShaCrs, // Soc_EVENT_CRS_SHA_PUB_FILE + ActSeeDocCrs, // Soc_NOTE_CRS_DOC_PUB_FILE + ActAdmShaCrs, // Soc_NOTE_CRS_SHA_PUB_FILE /* Assessment tab */ - ActSeeExaAnn, // Soc_EVENT_EXAM_ANNOUNCEMENT + ActSeeExaAnn, // Soc_NOTE_EXAM_ANNOUNCEMENT /* Users tab */ /* Social tab */ - ActSeeSocAct, // Soc_EVENT_SOCIAL_POST (action not used) - ActSeeFor, // Soc_EVENT_FORUM_POST + ActSeeSocAct, // Soc_NOTE_SOCIAL_POST (action not used) + ActSeeFor, // Soc_NOTE_FORUM_POST /* Messages tab */ - ActShoNot, // Soc_EVENT_NOTICE + ActShoNot, // Soc_NOTE_NOTICE /* Statistics tab */ @@ -92,10 +92,10 @@ static const Act_Action_t Soc_DefaultActions[Soc_NUM_SOCIAL_EVENTS] = /****************************** Internal types *******************************/ /*****************************************************************************/ -struct SocialEvent +struct SocialNote { long SocCod; - Soc_SocialEvent_t SocialEvent; + Soc_SocialNote_t SocialNote; long UsrCod; long CtyCod; long InsCod; @@ -121,24 +121,24 @@ extern struct Globals Gbl; /*****************************************************************************/ static unsigned long Soc_ShowTimeline (const char *Query,Act_Action_t UpdateAction); -static Soc_SocialEvent_t Soc_GetSocialEventFromDB (const char *Str); -static void Soc_WriteSocialEvent (const struct SocialEvent *Soc, +static Soc_SocialNote_t Soc_GetSocialNoteFromDB (const char *Str); +static void Soc_WriteSocialNote (const struct SocialNote *Soc, struct UsrData *UsrDat, bool PutIconRemove); -static void Soc_WriteEventDate (time_t TimeUTC); -static void Soc_StartFormGoToAction (Soc_SocialEvent_t SocialEvent, +static void Soc_WriteNoteDate (time_t TimeUTC); +static void Soc_StartFormGoToAction (Soc_SocialNote_t SocialNote, long CrsCod,long Cod); -static void Soc_GetEventSummary (const struct SocialEvent *Soc, - char *SummaryStr,unsigned MaxChars); +static void Soc_GetNoteSummary (const struct SocialNote *Soc, + char *SummaryStr,unsigned MaxChars); static void Soc_PutLinkToWriteANewPost (void); static void Soc_GetAndWriteSocialPost (long PstCod); -static void Soc_PutFormToRemoveSocialEvent (long SocCod); +static void Soc_PutFormToRemoveSocialNote (long SocCod); static void Soc_PutHiddenParamSocCod (long SocCod); static long Soc_GetParamSocCod (void); -static void Soc_GetDataOfSocialEventByCod (struct SocialEvent *Soc); -static void Soc_GetDataOfSocialEventFromRow (MYSQL_ROW row,struct SocialEvent *Soc); +static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *Soc); +static void Soc_GetDataOfSocialNoteFromRow (MYSQL_ROW row,struct SocialNote *Soc); /*****************************************************************************/ /*********** Show social activity (timeline) of a selected user **************/ @@ -149,10 +149,10 @@ void Soc_ShowUsrTimeline (long UsrCod) char Query[512]; /***** Build query to show timeline including the users I am following *****/ - sprintf (Query,"SELECT SocCod,SocialEvent,UsrCod," + sprintf (Query,"SELECT SocCod,SocialNote,UsrCod," "CtyCod,InsCod,CtrCod,DegCod,CrsCod," - "Cod,UNIX_TIMESTAMP(TimeEvent)" - " FROM social" + "Cod,UNIX_TIMESTAMP(TimeNote)" + " FROM social_notes" " WHERE UsrCod='%ld'" " ORDER BY SocCod DESC LIMIT 10", UsrCod); @@ -169,7 +169,7 @@ void Soc_ShowFollowingTimeline (void) { char Query[512]; - /***** Link to write a new social post *****/ + /***** Link to write a new social post (public comment) *****/ if (Gbl.CurrentAct != ActReqSocPst) Soc_PutLinkToWriteANewPost (); @@ -178,10 +178,10 @@ void Soc_ShowFollowingTimeline (void) Lay_ShowAlert (Lay_INFO,"Usted no sigue a ningún usuario."); // Need translation!!! /***** Build query to show timeline including the users I am following *****/ - sprintf (Query,"SELECT SocCod,SocialEvent,UsrCod," + sprintf (Query,"SELECT SocCod,SocialNote,UsrCod," "CtyCod,InsCod,CtrCod,DegCod,CrsCod," - "Cod,UNIX_TIMESTAMP(TimeEvent)" - " FROM social" + "Cod,UNIX_TIMESTAMP(TimeNote)" + " FROM social_notes" " WHERE UsrCod IN" " (SELECT '%ld'" " UNION" @@ -205,16 +205,16 @@ static unsigned long Soc_ShowTimeline (const char *Query,Act_Action_t UpdateActi extern const char *Txt_Public_activity; MYSQL_RES *mysql_res; MYSQL_ROW row; - unsigned long NumEvents; - unsigned long NumEvent; - struct SocialEvent Soc; + unsigned long NumNotes; + unsigned long NumNote; + struct SocialNote Soc; struct UsrData UsrDat; /***** Get timeline from database *****/ - NumEvents = DB_QuerySELECT (Query,&mysql_res,"can not get social events"); + NumNotes = DB_QuerySELECT (Query,&mysql_res,"can not get social notes"); /***** List my timeline *****/ - if (NumEvents) // Events found + if (NumNotes) // Notes found { /***** Initialize structure with user's data *****/ Usr_UsrDataConstructor (&UsrDat); @@ -229,17 +229,17 @@ static unsigned long Soc_ShowTimeline (const char *Query,Act_Action_t UpdateActi /***** Start list *****/ fprintf (Gbl.F.Out,""); Lay_EndRoundFrame (); @@ -835,35 +835,37 @@ void Soc_RequestRemovalSocialEvent (void) } /*****************************************************************************/ -/************************** Remove a social event ****************************/ +/************************** Remove a social note ****************************/ /*****************************************************************************/ -void Soc_RemoveSocialEvent (void) +void Soc_RemoveSocialNote (void) { extern const char *Txt_Comment_removed; - struct SocialEvent Soc; + struct SocialNote Soc; bool ICanRemove; char Query[128]; - /***** Get the code of the social event to remove *****/ + /***** Get the code of the social note to remove *****/ Soc.SocCod = Soc_GetParamSocCod (); - /***** Get data of social event *****/ - Soc_GetDataOfSocialEventByCod (&Soc); + /***** Get data of social note *****/ + Soc_GetDataOfSocialNoteByCod (&Soc); ICanRemove = (Gbl.Usrs.Me.Logged && Soc.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod && - Soc.SocialEvent == Soc_EVENT_SOCIAL_POST); + Soc.SocialNote == Soc_NOTE_SOCIAL_POST); if (ICanRemove) { - /***** Remove social event *****/ - sprintf (Query,"DELETE FROM social WHERE SocCod='%ld'",Soc.SocCod); - DB_QueryDELETE (Query,"can not remove a social event"); + /***** Remove social note *****/ + sprintf (Query,"DELETE FROM social_notes WHERE SocCod='%ld'", + Soc.SocCod); + DB_QueryDELETE (Query,"can not remove a social note"); /***** Remove social post *****/ - if (Soc.SocialEvent == Soc_EVENT_SOCIAL_POST) + if (Soc.SocialNote == Soc_NOTE_SOCIAL_POST) { - sprintf (Query,"DELETE FROM social_post WHERE PstCod='%ld'",Soc.Cod); + sprintf (Query,"DELETE FROM social_posts WHERE PstCod='%ld'", + Soc.Cod); DB_QueryDELETE (Query,"can not remove a social post"); } @@ -879,29 +881,29 @@ void Soc_RemoveSocialEvent (void) /******************* Get assignment data using its code **********************/ /*****************************************************************************/ -static void Soc_GetDataOfSocialEventByCod (struct SocialEvent *Soc) +static void Soc_GetDataOfSocialNoteByCod (struct SocialNote *Soc) { char Query[256]; MYSQL_RES *mysql_res; MYSQL_ROW row; - /***** Get data of social event from database *****/ - sprintf (Query,"SELECT SocCod,SocialEvent,UsrCod," + /***** Get data of social note from database *****/ + sprintf (Query,"SELECT SocCod,SocialNote,UsrCod," "CtyCod,InsCod,CtrCod,DegCod,CrsCod," - "Cod,UNIX_TIMESTAMP(TimeEvent)" - " FROM social" + "Cod,UNIX_TIMESTAMP(TimeNote)" + " FROM social_notes" " WHERE SocCod='%ld'", Soc->SocCod); - if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social event")) + if (DB_QuerySELECT (Query,&mysql_res,"can not get data of social note")) { - /***** Get social event *****/ + /***** Get social note *****/ row = mysql_fetch_row (mysql_res); - Soc_GetDataOfSocialEventFromRow (row,Soc); + Soc_GetDataOfSocialNoteFromRow (row,Soc); } else { - /***** Reset fields of social event *****/ - Soc->SocialEvent = Soc_EVENT_UNKNOWN; + /***** Reset fields of social note *****/ + Soc->SocialNote = Soc_NOTE_UNKNOWN; Soc->UsrCod = -1L; Soc->CtyCod = Soc->InsCod = @@ -917,13 +919,13 @@ static void Soc_GetDataOfSocialEventByCod (struct SocialEvent *Soc) /******************* Get assignment data using its code **********************/ /*****************************************************************************/ -static void Soc_GetDataOfSocialEventFromRow (MYSQL_ROW row,struct SocialEvent *Soc) +static void Soc_GetDataOfSocialNoteFromRow (MYSQL_ROW row,struct SocialNote *Soc) { /* Get social code (row[0]) */ Soc->SocCod = Str_ConvertStrCodToLongCod (row[0]); - /* Get event type (row[1]) */ - Soc->SocialEvent = Soc_GetSocialEventFromDB ((const char *) row[1]); + /* Get note type (row[1]) */ + Soc->SocialNote = Soc_GetSocialNoteFromDB ((const char *) row[1]); /* Get (from) user code (row[2]) */ Soc->UsrCod = Str_ConvertStrCodToLongCod (row[2]); @@ -946,6 +948,6 @@ static void Soc_GetDataOfSocialEventFromRow (MYSQL_ROW row,struct SocialEvent *S /* Get file/post... code (row[8]) */ Soc->Cod = Str_ConvertStrCodToLongCod (row[8]); - /* Get time of the event (row[9]) */ + /* Get time of the note (row[9]) */ Soc->DateTimeUTC = Dat_GetUNIXTimeFromStr (row[9]); } diff --git a/swad_social.h b/swad_social.h index a02b9242e..2d100577a 100644 --- a/swad_social.h +++ b/swad_social.h @@ -1,4 +1,4 @@ -// swad_social.c: social networking +// swad_social.c: social networking (timeline) #ifndef _SWAD_SOC #define _SWAD_SOC @@ -35,47 +35,47 @@ /******************************** Public types *******************************/ /*****************************************************************************/ -#define Soc_NUM_SOCIAL_EVENTS 13 +#define Soc_NUM_SOCIAL_NOTES 13 // If the numbers assigned to each event type change, -// it is necessary to change old numbers to new ones in database table social +// it is necessary to change old numbers to new ones in database table social_notes typedef enum { - Soc_EVENT_UNKNOWN = 0, + Soc_NOTE_UNKNOWN = 0, /* Institution tab */ - Soc_EVENT_INS_DOC_PUB_FILE = 1, - Soc_EVENT_INS_SHA_PUB_FILE = 2, + Soc_NOTE_INS_DOC_PUB_FILE = 1, + Soc_NOTE_INS_SHA_PUB_FILE = 2, /* Centre tab */ - Soc_EVENT_CTR_DOC_PUB_FILE = 3, - Soc_EVENT_CTR_SHA_PUB_FILE = 4, + Soc_NOTE_CTR_DOC_PUB_FILE = 3, + Soc_NOTE_CTR_SHA_PUB_FILE = 4, /* Degree tab */ - Soc_EVENT_DEG_DOC_PUB_FILE = 5, - Soc_EVENT_DEG_SHA_PUB_FILE = 6, + Soc_NOTE_DEG_DOC_PUB_FILE = 5, + Soc_NOTE_DEG_SHA_PUB_FILE = 6, /* Course tab */ - Soc_EVENT_CRS_DOC_PUB_FILE = 7, - Soc_EVENT_CRS_SHA_PUB_FILE = 8, + Soc_NOTE_CRS_DOC_PUB_FILE = 7, + Soc_NOTE_CRS_SHA_PUB_FILE = 8, /* Assessment tab */ - Soc_EVENT_EXAM_ANNOUNCEMENT = 9, + Soc_NOTE_EXAM_ANNOUNCEMENT = 9, /* Users tab */ /* Social tab */ - Soc_EVENT_SOCIAL_POST = 10, - Soc_EVENT_FORUM_POST = 11, + Soc_NOTE_SOCIAL_POST = 10, + Soc_NOTE_FORUM_POST = 11, /* Messages tab */ - Soc_EVENT_NOTICE = 12, + Soc_NOTE_NOTICE = 12, /* Statistics tab */ /* Profile tab */ - } Soc_SocialEvent_t; + } Soc_SocialNote_t; /*****************************************************************************/ /****************************** Public prototypes ****************************/ @@ -84,12 +84,12 @@ typedef enum void Soc_ShowUsrTimeline (long UsrCod); void Soc_ShowFollowingTimeline (void); -void Soc_StoreSocialEvent (Soc_SocialEvent_t SocialEvent,long Cod); +void Soc_StoreSocialNote (Soc_SocialNote_t SocialNote,long Cod); void Soc_FormSocialPost (void); void Soc_ReceiveSocialPost (void); -void Soc_RequestRemovalSocialEvent (void); -void Soc_RemoveSocialEvent (void); +void Soc_RequestRemovalSocialNote (void); +void Soc_RemoveSocialNote (void); #endif diff --git a/swad_text.c b/swad_text.c index db500c4bf..f66a708d5 100644 --- a/swad_text.c +++ b/swad_text.c @@ -35247,9 +35247,9 @@ const char *Txt_Size_of_photos = "Tamanho das fotos"; #endif -const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = +const char *Txt_SOCIAL_NOTE[Soc_NUM_SOCIAL_NOTES] = { -#if L==1 // Soc_EVENT_UNKNOWN +#if L==1 // Soc_NOTE_UNKNOWN "Esdeveniment desconegut" #elif L==2 "Unbekannt Ereignis" @@ -35269,7 +35269,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Evento desconhecido" #endif , -#if L==1 // Soc_EVENT_INS_DOC_PUB_FILE +#if L==1 // Soc_NOTE_INS_DOC_PUB_FILE "Document públic" #elif L==2 "Öffentliche Dokumentdatei" @@ -35289,7 +35289,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Arquivo de documento público" #endif , -#if L==1 // Soc_EVENT_INS_SHA_PUB_FILE +#if L==1 // Soc_NOTE_INS_SHA_PUB_FILE "Arxiu compartit públic" #elif L==2 "Öffentliche Freigegebene Datei" @@ -35309,7 +35309,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Arquivo compartilhado público" #endif , -#if L==1 // Soc_EVENT_CTR_DOC_PUB_FILE +#if L==1 // Soc_NOTE_CTR_DOC_PUB_FILE "Document públic" #elif L==2 "Öffentliche Dokumentdatei" @@ -35329,7 +35329,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Arquivo de documento público" #endif , -#if L==1 // Soc_EVENT_CTR_SHA_PUB_FILE +#if L==1 // Soc_NOTE_CTR_SHA_PUB_FILE "Arxiu compartit públic" #elif L==2 "Öffentliche Freigegebene Datei" @@ -35349,7 +35349,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Arquivo compartilhado público" #endif , -#if L==1 // Soc_EVENT_DEG_DOC_PUB_FILE +#if L==1 // Soc_NOTE_DEG_DOC_PUB_FILE "Document públic" #elif L==2 "Öffentliche Dokumentdatei" @@ -35369,7 +35369,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Arquivo de documento público" #endif , -#if L==1 // Soc_EVENT_DEG_SHA_PUB_FILE +#if L==1 // Soc_NOTE_DEG_SHA_PUB_FILE "Arxiu compartit públic" #elif L==2 "Öffentliche Freigegebene Datei" @@ -35389,7 +35389,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Arquivo compartilhado público" #endif , -#if L==1 // Soc_EVENT_CRS_DOC_PUB_FILE +#if L==1 // Soc_NOTE_CRS_DOC_PUB_FILE "Document públic" #elif L==2 "Öffentliche Dokumentdatei" @@ -35409,7 +35409,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Arquivo de documento público" #endif , -#if L==1 // Soc_EVENT_CRS_SHA_PUB_FILE +#if L==1 // Soc_NOTE_CRS_SHA_PUB_FILE "Arxiu compartit públic" #elif L==2 "Öffentliche Freigegebene Datei" @@ -35429,7 +35429,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Arquivo compartilhado público" #endif , -#if L==1 // Soc_EVENT_EXAM_ANNOUNCEMENT +#if L==1 // Soc_NOTE_EXAM_ANNOUNCEMENT "Convocatòria d'examen" #elif L==2 "Aufrufe für Prüfung" @@ -35449,7 +35449,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Chamada para exame" #endif , -#if L==1 // Soc_EVENT_SOCIAL_POST (not used) +#if L==1 // Soc_NOTE_SOCIAL_POST (not used) "Comentari" #elif L==2 "Kommentar" @@ -35469,7 +35469,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Comentário" #endif , -#if L==1 // Soc_EVENT_FORUM_POST +#if L==1 // Soc_NOTE_FORUM_POST "Missatge en un fòrum" #elif L==2 "Beiträge in einem Forum" @@ -35489,7 +35489,7 @@ const char *Txt_SOCIAL_EVENT[Soc_NUM_SOCIAL_EVENTS] = "Post em um fórum" #endif , -#if L==1 // Soc_EVENT_NOTICE +#if L==1 // Soc_NOTE_NOTICE "Avís" #elif L==2 "Ankündigungen"