diff --git a/swad_changelog.h b/swad_changelog.h index 8ce971b25..33ab6167e 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -117,21 +117,18 @@ // TODO: Go to forum post (or at least to forum thread) from social timeline and notifications? // TODO: Width of column for data in notifications is too short -// TODO: When receiving a new post, create first the publishing, then the post -// TODO: Change PstCod to PubCod in social_posts, removing AUTO_INCREMENT -// TODO: View highlighted social note when clicking in timeline notification - /*****************************************************************************/ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.127.3 (2016-01-25)" +#define Log_PLATFORM_VERSION "SWAD 15.128 (2016-01-25)" #define CSS_FILE "swad15.121.7.css" #define JS_FILE "swad15.121.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.128: Jan 25, 2016 View highlighted social note when clicking in timeline notification. (194980 lines) Version 15.127.3: Jan 25, 2016 Changed ComCod to PubCod in social_comments and social_comments_fav. (194841 lines) 2 changes necessary in database: ALTER TABLE social_comments_fav CHANGE COLUMN ComCod PubCod BIGINT NOT NULL; diff --git a/swad_database.c b/swad_database.c index 88edca7a6..12d92db36 100644 --- a/swad_database.c +++ b/swad_database.c @@ -2036,15 +2036,15 @@ mysql> DESCRIBE social_posts; +---------+----------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +---------+----------+------+-----+---------+----------------+ -| PstCod | int(11) | NO | PRI | NULL | auto_increment | +| PubCod | int(11) | NO | PRI | NULL | auto_increment | | Content | longtext | NO | MUL | NULL | | +---------+----------+------+-----+---------+----------------+ 2 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS social_posts (" - "PstCod INT NOT NULL AUTO_INCREMENT," + "PubCod INT NOT NULL AUTO_INCREMENT," "Content LONGTEXT NOT NULL," - "UNIQUE INDEX(PstCod)," + "UNIQUE INDEX(PubCod)," "FULLTEXT(Content)) ENGINE = MYISAM;"); /***** Table social_pubs *****/ diff --git a/swad_enrollment.c b/swad_enrollment.c index 691ab47ec..90c13f85e 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -2058,7 +2058,7 @@ void Enr_AskIfRejectSignUp (void) Rol_Role_t Role; /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // If user's data exist... { @@ -2115,7 +2115,7 @@ void Enr_RejectSignUp (void) extern const char *Txt_User_not_found_or_you_do_not_have_permission_; /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // If user's data exist... { @@ -3028,7 +3028,7 @@ static void Enr_AskIfRegRemAnotherUsr (Rol_Role_t Role) struct ListUsrCods ListUsrCods; /***** Check if UsrCod is present in parameters *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) { /***** If UsrCod is present in parameters, diff --git a/swad_file_browser.c b/swad_file_browser.c index 6e660dac5..aba4f4e5f 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -2038,7 +2038,7 @@ void Brw_GetParAndInitFileBrowser (void) /* Get lists of the selected users */ Usr_GetListsSelectedUsrs (); /* Get user whose folder will be used to make any operation */ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /* Get whether we must create the zip file or not */ Gbl.FileBrowser.ZIP.CreateZIP = ZIP_GetCreateZIPFromForm (); break; diff --git a/swad_follow.c b/swad_follow.c index a837b34b3..951c40abd 100644 --- a/swad_follow.c +++ b/swad_follow.c @@ -359,7 +359,7 @@ void Fol_ListFollowers (void) struct UsrData UsrDat; /***** Get user to view user he/she follows *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); if (Gbl.Usrs.Other.UsrDat.UsrCod <= 0) // If user not specified, view my profile Gbl.Usrs.Other.UsrDat.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod; diff --git a/swad_layout.c b/swad_layout.c index 15924e1c8..ba6b2c044 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -686,7 +686,7 @@ static void Lay_WriteScriptParamsAJAX (void) /* In all the actions related to view or editing user's timeline ==> put parameters used by AJAX */ if (Gbl.Usrs.Other.UsrDat.UsrCod <= 0) - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); if (!Gbl.Usrs.Other.UsrDat.Nickname[0]) Nck_GetNicknameFromUsrCod (Gbl.Usrs.Other.UsrDat.UsrCod, Gbl.Usrs.Other.UsrDat.Nickname); diff --git a/swad_message.c b/swad_message.c index e34076e3e..0043a5f3b 100644 --- a/swad_message.c +++ b/swad_message.c @@ -704,7 +704,7 @@ void Msg_RecMsgFromUsr (void) OriginalMsgCod = Msg_GetParamMsgCod (); /* Get user's code of possible preselected recipient */ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /* Get lists of selected users */ Usr_GetListsSelectedUsrs (); @@ -3480,7 +3480,7 @@ void Msg_BanSenderWhenShowingMsgs (void) char Query[256]; /***** Get user's code from form *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Get password, user type and user's data from database *****/ if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) @@ -3537,7 +3537,7 @@ static void Msg_UnbanSender (void) char Query[256]; /***** Get user's code from form *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Get password, user type and user's data from database *****/ if (!Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) diff --git a/swad_notification.c b/swad_notification.c index 29f449b9e..1723b6b0e 100644 --- a/swad_notification.c +++ b/swad_notification.c @@ -258,8 +258,11 @@ static const char *Ntf_Icons[Ntf_NUM_NOTIFY_EVENTS] = static void Ntf_WriteFormAllNotifications (bool AllNotifications); static bool Ntf_GetAllNotificationsFromForm (void); + static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent, - long CrsCod,long Cod); + long CrsCod,struct UsrData *UsrDat,long Cod); +static void Ntf_PutHiddenParamNotifyEvent (Ntf_NotifyEvent_t NotifyEvent); + static void Ntf_UpdateMyLastAccessToNotifications (void); static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsigned *NumNotif,unsigned *NumMails); static void Ntf_GetNumNotifSent (long DegCod,long CrsCod, @@ -471,7 +474,7 @@ void Ntf_ShowMyNotifications (void) "", ClassBackground); if (PutLink) - PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,Cod); + PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,&UsrDat,Cod); if (PutLink) { @@ -498,7 +501,7 @@ void Ntf_ShowMyNotifications (void) fprintf (Gbl.F.Out,"", ClassBackground); if (PutLink) - PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,Cod); + PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,&UsrDat,Cod); if (PutLink) { @@ -522,7 +525,7 @@ void Ntf_ShowMyNotifications (void) NotifyEvent == Ntf_EVENT_FORUM_REPLY) { if (PutLink) - PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,Cod); + PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,&UsrDat,Cod); if (PutLink) Act_LinkFormSubmit (Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent],ClassAnchor); @@ -540,7 +543,7 @@ void Ntf_ShowMyNotifications (void) else if (Crs.CrsCod > 0) { if (PutLink) - PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,Cod); + PutLink = Ntf_StartFormGoToAction (NotifyEvent,Crs.CrsCod,&UsrDat,Cod); if (PutLink) Act_LinkFormSubmit (Txt_NOTIFY_EVENTS_SINGULAR[NotifyEvent],ClassAnchor); @@ -671,11 +674,10 @@ static bool Ntf_GetAllNotificationsFromForm (void) // Return the value of Gbl.Form.Inside (true if form is started) static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent, - long CrsCod,long Cod) + long CrsCod,struct UsrData *UsrDat,long Cod) { extern const Act_Action_t For_ActionsSeeFor[For_NUM_TYPES_FORUM]; struct FileMetadata FileMetadata; - struct UsrData UsrDat; long InsCod = -1L; long CtrCod = -1L; long DegCod = -1L; @@ -732,17 +734,17 @@ static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent, case Ntf_EVENT_TIMELINE_MENTION: // Cod is the code of the social publishing Act_FormStart (ActSeeSocTmlGbl); - // Soc_PutHiddenParamPubCod (Cod); // TODO: For future display of selected social note at top + Soc_PutHiddenParamPubCod (Cod); + Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); + Ntf_PutHiddenParamNotifyEvent (NotifyEvent); break; case Ntf_EVENT_FOLLOWER: - UsrDat.UsrCod = Cod; // Cod is the follower's code - Usr_GetEncryptedUsrCodFromUsrCod (&UsrDat); - if (UsrDat.EncryptedUsrCod[0]) // User's code found ==> + if (UsrDat->EncryptedUsrCod[0]) // User's code found ==> // go to user's public profile { Act_FormStart (ActSeePubPrf); /* Put param to go to follower's profile */ - Usr_PutParamUsrCodEncrypted (UsrDat.EncryptedUsrCod); + Usr_PutParamUsrCodEncrypted (UsrDat->EncryptedUsrCod); } else // No user's code found ==> go to see my followers Act_FormStart (ActSeeFlr); @@ -793,6 +795,36 @@ static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent, return Gbl.Form.Inside; } + +/*****************************************************************************/ +/******************* Get parameter with notify event type ********************/ +/*****************************************************************************/ + +static void Ntf_PutHiddenParamNotifyEvent (Ntf_NotifyEvent_t NotifyEvent) + { + Par_PutHiddenParamUnsigned ("NotifyEvent",(unsigned) NotifyEvent); + } + +/*****************************************************************************/ +/******************* Get parameter with notify event type ********************/ +/*****************************************************************************/ + +Ntf_NotifyEvent_t Ntf_GetParamNotifyEvent (void) + { + char UnsignedStr[10+1]; + unsigned UnsignedNum; + + Par_GetParToText ("NotifyEvent",UnsignedStr,10); + if (UnsignedStr[0]) + { + if (sscanf (UnsignedStr,"%u",&UnsignedNum) == 1) + if (UnsignedNum < Ntf_NUM_NOTIFY_EVENTS) + return (Ntf_NotifyEvent_t) UnsignedNum; + } + + return Ntf_EVENT_UNKNOWN; + } + /*****************************************************************************/ /****************** Set StatusTxt depending on status bits *******************/ /*****************************************************************************/ diff --git a/swad_notification.h b/swad_notification.h index 50061f9e9..4405bff4a 100644 --- a/swad_notification.h +++ b/swad_notification.h @@ -102,6 +102,9 @@ typedef enum /*****************************************************************************/ void Ntf_ShowMyNotifications (void); + +Ntf_NotifyEvent_t Ntf_GetParamNotifyEvent (void); + Ntf_StatusTxt_t Ntf_GetStatusTxtFromStatusBits (Ntf_Status_t Status); void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr, Ntf_NotifyEvent_t NotifyEvent, diff --git a/swad_photo.c b/swad_photo.c index 7f1bc2db5..23f7e7548 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -384,7 +384,7 @@ void Pho_RecUsrPhotoDetFaces (void) extern const char *Txt_User_not_found_or_you_do_not_have_permission_; /***** Get user's code from form *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Get password, user type and user's data from database *****/ if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) @@ -425,7 +425,7 @@ void Pho_RemoveUsrPhoto (void) extern const char *Txt_User_not_found_or_you_do_not_have_permission_; /***** Get user's code from form *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Get password, user type and user's data from database *****/ if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) diff --git a/swad_profile.c b/swad_profile.c index f22fd81c2..62dbc46ef 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -179,7 +179,7 @@ void Prf_GetUsrDatAndShowUserProfile (void) /***** Get user's data *****/ if (Gbl.Usrs.Other.UsrDat.UsrCod <= 0) - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); Error = !Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat); /***** Show profile and timeline *****/ @@ -722,7 +722,7 @@ static void Prf_ShowRanking (unsigned long Rank,unsigned long NumUsrs) void Prf_CalculateFirstClickTime (void) { /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Get first click time from log and store as user's figure *****/ Prf_GetFirstClickFromLogAndStoreAsUsrFigure (Gbl.Usrs.Other.UsrDat.UsrCod); @@ -784,7 +784,7 @@ static void Prf_GetFirstClickFromLogAndStoreAsUsrFigure (long UsrCod) void Prf_CalculateNumClicks (void) { /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Get number of clicks and store as user's figure *****/ Prf_GetNumClicksAndStoreAsUsrFigure (Gbl.Usrs.Other.UsrDat.UsrCod); @@ -832,7 +832,7 @@ static void Prf_GetNumClicksAndStoreAsUsrFigure (long UsrCod) void Prf_CalculateNumFileViews (void) { /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Get number of file views and store as user's figure *****/ Prf_GetNumFileViewsAndStoreAsUsrFigure (Gbl.Usrs.Other.UsrDat.UsrCod); @@ -878,7 +878,7 @@ static void Prf_GetNumFileViewsAndStoreAsUsrFigure (long UsrCod) void Prf_CalculateNumForPst (void) { /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Get number of forum posts and store as user's figure *****/ Prf_GetNumForPstAndStoreAsUsrFigure (Gbl.Usrs.Other.UsrDat.UsrCod); @@ -924,7 +924,7 @@ static void Prf_GetNumForPstAndStoreAsUsrFigure (long UsrCod) void Prf_CalculateNumMsgSnt (void) { /***** Get user's code *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Get number of messages sent and store as user's figure *****/ Prf_GetNumMsgSntAndStoreAsUsrFigure (Gbl.Usrs.Other.UsrDat.UsrCod); diff --git a/swad_record.c b/swad_record.c index 3c5c9decd..9e09a1c09 100644 --- a/swad_record.c +++ b/swad_record.c @@ -956,7 +956,7 @@ void Rec_ListRecordsGsts (void) void Rec_GetUsrAndShowRecordOneStdCrs (void) { /***** Get the selected student *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get from the database the data of the student if ((Gbl.Usrs.Other.UsrDat.RoleInCurrentCrsDB = @@ -1140,7 +1140,7 @@ static void Rec_ListRecordsStds (Rec_RecordViewType_t TypeOfView) void Rec_GetUsrAndShowRecordOneTchCrs (void) { /***** Get the selected teacher *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Show the record *****/ if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Get from the database the data of the teacher @@ -1443,7 +1443,7 @@ void Rec_UpdateAndShowOtherCrsRecord (void) extern const char *Txt_Student_record_card_in_this_course_has_been_updated; /***** Get the user whose record we want to modify *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat); /***** Get list of fields of records in current course *****/ diff --git a/swad_social.c b/swad_social.c index 53b8d6f0d..387197b51 100644 --- a/swad_social.c +++ b/swad_social.c @@ -266,7 +266,7 @@ static void Soc_PutFormToUnfavSocialComment (long PubCod); static void Soc_PutFormToRemoveSocialPublishing (long NotCod); -static void Soc_PutHiddenParamPubCod (long PubCod); +static void Soc_PutHiddenParamNotCod (long NotCod); static long Soc_GetParamNotCod (void); static long Soc_GetParamPubCod (void); @@ -328,7 +328,76 @@ static void Str_AnalyzeTxtAndStoreNotifyEventToMentionedUsrs (long PubCod,const void Soc_ShowTimelineGbl (void) { - Soc_ShowTimelineGblHighlightingNot (-1L); + char Query[128]; + MYSQL_RES *mysql_res; + MYSQL_ROW row; + long PubCod; + struct SocialNote SocNot; + struct UsrData UsrDat; + Ntf_NotifyEvent_t NotifyEvent; + Soc_TopMessage_t TopMessage; + + /***** Initialize social note code to -1 ==> no highlighted note *****/ + SocNot.NotCod = -1L; + + /***** Get parameter with the code of a social publishing *****/ + // This parameter is optional. It can be provided by a notification. + // If > 0 ==> the social note is shown highlighted above the timeline + PubCod = Soc_GetParamPubCod (); + if (PubCod > 0) + { + /***** Get code of social note from database *****/ + sprintf (Query,"SELECT NotCod FROM social_pubs WHERE PubCod='%ld'", + PubCod); + if (DB_QuerySELECT (Query,&mysql_res,"can not get code of social note") == 1) // Result should have a unique row + { + /* Get code of social note */ + row = mysql_fetch_row (mysql_res); + SocNot.NotCod = Str_ConvertStrCodToLongCod (row[0]); + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + + if (SocNot.NotCod > 0) + { + /* Get who did the action (publishing, commenting, faving, sharing, mentioning) */ + Usr_GetParamOtherUsrCodEncrypted (&UsrDat); + + /* Get what he/she did */ + NotifyEvent = Ntf_GetParamNotifyEvent (); + switch (NotifyEvent) + { + case Ntf_EVENT_TIMELINE_PUBLISH: + TopMessage = Soc_TOP_MESSAGE_PUBLISHED; + break; + case Ntf_EVENT_TIMELINE_COMMENT: + TopMessage = Soc_TOP_MESSAGE_COMMENTED; + break; + case Ntf_EVENT_TIMELINE_FAV: + TopMessage = Soc_TOP_MESSAGE_FAVED; + break; + case Ntf_EVENT_TIMELINE_SHARE: + TopMessage = Soc_TOP_MESSAGE_SHARED; + break; + case Ntf_EVENT_TIMELINE_MENTION: + TopMessage = Soc_TOP_MESSAGE_MENTIONED; + break; + default: + TopMessage = Soc_TOP_MESSAGE_NONE; + break; + } + + /***** Show the social note highlighted *****/ + Soc_GetDataOfSocialNotByCod (&SocNot); + Soc_WriteSocialNote (&SocNot, + TopMessage,UsrDat.UsrCod, + true,true); + } + + /***** Show timeline with possible highlighted note *****/ + Soc_ShowTimelineGblHighlightingNot (SocNot.NotCod); } static void Soc_ShowTimelineGblHighlightingNot (long NotCod) @@ -670,9 +739,8 @@ static void Soc_BuildQueryToGetTimeline (Soc_TimelineUsrOrGbl_t TimelineUsrOrGbl } if (DB_QuerySELECT (Query,&mysql_res,"can not get publishing") == 1) { + /* Get code of social publishing */ row = mysql_fetch_row (mysql_res); - - /* Get code of social publishing (row[0]) */ PubCod = Str_ConvertStrCodToLongCod (row[0]); } else @@ -1330,11 +1398,13 @@ static void Soc_WriteSocialNote (const struct SocialNote *SocNot, static void Soc_WriteTopMessage (Soc_TopMessage_t TopMessage,long UsrCod) { extern const char *Txt_View_public_profile; - extern const char *Txt_SOCIAL_USER_has_shared; - extern const char *Txt_SOCIAL_USER_has_stopped_sharing; + extern const char *Txt_SOCIAL_USER_has_published; + extern const char *Txt_SOCIAL_USER_has_commented; extern const char *Txt_SOCIAL_USER_has_marked_as_favourite; extern const char *Txt_SOCIAL_USER_has_unmarked_as_favourite; - extern const char *Txt_SOCIAL_USER_has_commented; + extern const char *Txt_SOCIAL_USER_has_shared; + extern const char *Txt_SOCIAL_USER_has_stopped_sharing; + extern const char *Txt_SOCIAL_USER_has_mentioned_you; struct UsrData UsrDat; if (TopMessage != Soc_TOP_MESSAGE_NONE) @@ -1361,20 +1431,26 @@ static void Soc_WriteTopMessage (Soc_TopMessage_t TopMessage,long UsrCod) { case Soc_TOP_MESSAGE_NONE: // Not applicable break; + case Soc_TOP_MESSAGE_PUBLISHED: + fprintf (Gbl.F.Out," %s",Txt_SOCIAL_USER_has_published); + break; + case Soc_TOP_MESSAGE_COMMENTED: + fprintf (Gbl.F.Out," %s",Txt_SOCIAL_USER_has_commented); + break; + case Soc_TOP_MESSAGE_FAVED: + fprintf (Gbl.F.Out," %s",Txt_SOCIAL_USER_has_marked_as_favourite); + break; + case Soc_TOP_MESSAGE_UNFAVED: + fprintf (Gbl.F.Out," %s",Txt_SOCIAL_USER_has_unmarked_as_favourite); + break; case Soc_TOP_MESSAGE_SHARED: fprintf (Gbl.F.Out," %s",Txt_SOCIAL_USER_has_shared); break; case Soc_TOP_MESSAGE_UNSHARED: fprintf (Gbl.F.Out," %s",Txt_SOCIAL_USER_has_stopped_sharing); break; - case Soc_TOP_MESSAGE_FAV: - fprintf (Gbl.F.Out," %s",Txt_SOCIAL_USER_has_marked_as_favourite); - break; - case Soc_TOP_MESSAGE_UNFAV: - fprintf (Gbl.F.Out," %s",Txt_SOCIAL_USER_has_unmarked_as_favourite); - break; - case Soc_TOP_MESSAGE_COMMENTED: - fprintf (Gbl.F.Out," %s",Txt_SOCIAL_USER_has_commented); + case Soc_TOP_MESSAGE_MENTIONED: + fprintf (Gbl.F.Out," %s",Txt_SOCIAL_USER_has_mentioned_you); break; } @@ -2592,7 +2668,7 @@ static void Soc_PutFormToRemoveSocialPublishing (long NotCod) /************** Put parameter with the code of a social note *****************/ /*****************************************************************************/ -void Soc_PutHiddenParamNotCod (long NotCod) +static void Soc_PutHiddenParamNotCod (long NotCod) { Par_PutHiddenParamLong ("NotCod",NotCod); } @@ -2601,7 +2677,7 @@ void Soc_PutHiddenParamNotCod (long NotCod) /*********** Put parameter with the code of a social publishing **************/ /*****************************************************************************/ -static void Soc_PutHiddenParamPubCod (long PubCod) +void Soc_PutHiddenParamPubCod (long PubCod) { Par_PutHiddenParamLong ("PubCod",PubCod); } @@ -2618,7 +2694,7 @@ static long Soc_GetParamNotCod (void) /* Get social note code */ Par_GetParToText ("NotCod",LongStr,1+10); if (sscanf (LongStr,"%ld",&NotCod) != 1) - Lay_ShowErrorAndExit ("Wrong code of social note."); + return -1L; return NotCod; } @@ -2635,7 +2711,7 @@ static long Soc_GetParamPubCod (void) /* Get social comment code */ Par_GetParToText ("PubCod",LongStr,1+10); if (sscanf (LongStr,"%ld",&PubCod) != 1) - Lay_ShowErrorAndExit ("Wrong code of social publishing."); + return -1L; return PubCod; } @@ -2777,10 +2853,8 @@ static long Soc_ShareSocialNote (void) struct SocialNote SocNot; struct SocialPublishing SocPub; - /***** Get the code of the social note to share *****/ - SocNot.NotCod = Soc_GetParamNotCod (); - /***** Get data of social note *****/ + SocNot.NotCod = Soc_GetParamNotCod (); Soc_GetDataOfSocialNotByCod (&SocNot); if (SocNot.NotCod > 0) @@ -2856,10 +2930,8 @@ static long Soc_FavSocialNote (void) struct SocialNote SocNot; long PubCod; - /***** Get the code of the social note to mark as favourite *****/ - SocNot.NotCod = Soc_GetParamNotCod (); - /***** Get data of social note *****/ + SocNot.NotCod = Soc_GetParamNotCod (); Soc_GetDataOfSocialNotByCod (&SocNot); if (SocNot.NotCod > 0) @@ -2899,7 +2971,7 @@ static long Soc_FavSocialNote (void) /***** Show the social note just favourited *****/ Soc_WriteSocialNote (&SocNot, - Soc_TOP_MESSAGE_FAV,Gbl.Usrs.Me.UsrDat.UsrCod, + Soc_TOP_MESSAGE_FAVED,Gbl.Usrs.Me.UsrDat.UsrCod, true,true); } } @@ -2953,10 +3025,8 @@ static long Soc_FavSocialComment (void) struct SocialComment SocCom; char Query[256]; - /***** Get the code of the social publishing to mark as favourite *****/ + /***** Get data of social comment *****/ SocCom.PubCod = Soc_GetParamPubCod (); - - /***** Get data of social note *****/ Soc_GetDataOfSocialComByCod (&SocCom); if (SocCom.PubCod > 0) @@ -2982,7 +3052,7 @@ static long Soc_FavSocialComment (void) /***** Show the social comment just favourited *****/ Soc_WriteSocialComment (&SocCom, - Soc_TOP_MESSAGE_FAV,Gbl.Usrs.Me.UsrDat.UsrCod, + Soc_TOP_MESSAGE_FAVED,Gbl.Usrs.Me.UsrDat.UsrCod, true); } } @@ -3188,7 +3258,7 @@ static long Soc_UnfavSocialNote (void) /***** Show the social note just unfavourited *****/ Soc_WriteSocialNote (&SocNot, - Soc_TOP_MESSAGE_UNFAV,Gbl.Usrs.Me.UsrDat.UsrCod, + Soc_TOP_MESSAGE_UNFAVED,Gbl.Usrs.Me.UsrDat.UsrCod, true,true); } } @@ -3269,7 +3339,7 @@ static long Soc_UnfavSocialComment (void) /***** Show the social comment just unfavourited *****/ Soc_WriteSocialComment (&SocCom, - Soc_TOP_MESSAGE_UNFAV,Gbl.Usrs.Me.UsrDat.UsrCod, + Soc_TOP_MESSAGE_UNFAVED,Gbl.Usrs.Me.UsrDat.UsrCod, true); } } @@ -3585,10 +3655,8 @@ static void Soc_RequestRemovalSocialComment (void) extern const char *Txt_Remove; struct SocialComment SocCom; - /***** Get the code of the social comment to remove *****/ - SocCom.PubCod = Soc_GetParamPubCod (); - /***** Get data of social comment *****/ + SocCom.PubCod = Soc_GetParamPubCod (); Soc_GetDataOfSocialComByCod (&SocCom); if (SocCom.PubCod > 0) @@ -3665,10 +3733,8 @@ static void Soc_RemoveSocialComment (void) extern const char *Txt_Comment_removed; struct SocialComment SocCom; - /***** Get the code of the social comment to remove *****/ - SocCom.PubCod = Soc_GetParamPubCod (); - /***** Get data of social comment *****/ + SocCom.PubCod = Soc_GetParamPubCod (); Soc_GetDataOfSocialComByCod (&SocCom); if (SocCom.PubCod > 0) diff --git a/swad_social.h b/swad_social.h index dff6a8284..c7811ad4e 100644 --- a/swad_social.h +++ b/swad_social.h @@ -90,11 +90,13 @@ typedef enum typedef enum { Soc_TOP_MESSAGE_NONE, + Soc_TOP_MESSAGE_PUBLISHED, + Soc_TOP_MESSAGE_COMMENTED, + Soc_TOP_MESSAGE_FAVED, + Soc_TOP_MESSAGE_UNFAVED, Soc_TOP_MESSAGE_SHARED, Soc_TOP_MESSAGE_UNSHARED, - Soc_TOP_MESSAGE_FAV, - Soc_TOP_MESSAGE_UNFAV, - Soc_TOP_MESSAGE_COMMENTED, + Soc_TOP_MESSAGE_MENTIONED, } Soc_TopMessage_t; struct SocialPublishing @@ -128,7 +130,7 @@ void Soc_MarkSocialNotesChildrenOfFolderAsUnavailable (const char *Path); void Soc_ReceiveSocialPostGbl (void); void Soc_ReceiveSocialPostUsr (void); -void Soc_PutHiddenParamNotCod (long NotCod); +void Soc_PutHiddenParamPubCod (long PubCod); void Soc_ReceiveCommentGbl (void); void Soc_ReceiveCommentUsr (void); diff --git a/swad_text.c b/swad_text.c index 5cd81e4f5..93667e6aa 100644 --- a/swad_text.c +++ b/swad_text.c @@ -36168,7 +36168,7 @@ const char *Txt_SOCIAL_USER_has_commented = #elif L==7 "ha commentato:"; #elif L==8 - "skomentowa&lstroke:"; + "skomentował"; #elif L==9 "comentou:"; #endif @@ -36194,6 +36194,48 @@ const char *Txt_SOCIAL_USER_has_marked_as_favourite = "marcou como favorito:"; #endif +const char *Txt_SOCIAL_USER_has_mentioned_you = +#if L==1 + "li ha esmentat:"; +#elif L==2 + "hat Sie erwähnt:"; +#elif L==3 + "has mentioned you:"; +#elif L==4 + "le ha mencionado:"; +#elif L==5 + "vous a mentionné:"; +#elif L==6 + "le ha mencionado:"; // Okoteve traducción +#elif L==7 + "ti ha menzionato:"; +#elif L==8 + "wspomniał o Tobie"; +#elif L==9 + "mencionou você:"; +#endif + +const char *Txt_SOCIAL_USER_has_published = +#if L==1 + "ha publicat:"; +#elif L==2 + "hat veröffentlicht:"; +#elif L==3 + "has published:"; +#elif L==4 + "ha publicado:"; +#elif L==5 + "a publié:"; +#elif L==6 + "ha publicado:"; // Okoteve traducción +#elif L==7 + "ha pubblicato:"; +#elif L==8 + "opublikował"; +#elif L==9 + "publicou:"; +#endif + const char *Txt_SOCIAL_USER_has_shared = #if L==1 "ha compartit:"; @@ -36210,7 +36252,7 @@ const char *Txt_SOCIAL_USER_has_shared = #elif L==7 "ha condiviso:"; #elif L==8 - "podzieli&lstroke:"; + "podzielił"; #elif L==9 "compartilhou:"; #endif diff --git a/swad_user.c b/swad_user.c index 0e4a8fe4e..48673bea0 100644 --- a/swad_user.c +++ b/swad_user.c @@ -1850,19 +1850,30 @@ void Usr_PutParamUsrCodEncrypted (const char EncryptedUsrCod[Cry_LENGTH_ENCRYPTE /********* Get hidden parameter encrypted user's code of other user **********/ /*****************************************************************************/ -void Usr_GetParamOtherUsrCodEncrypted (void) +void Usr_GetParamOtherUsrCodEncrypted (struct UsrData *UsrDat) { - Par_GetParToText ("OtherUsrCod",Gbl.Usrs.Other.UsrDat.EncryptedUsrCod,Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); - if (Gbl.Usrs.Other.UsrDat.EncryptedUsrCod[0]) // If parameter exists... + Par_GetParToText ("OtherUsrCod",UsrDat->EncryptedUsrCod,Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64); + if (UsrDat->EncryptedUsrCod[0]) // If parameter exists... { - Usr_GetUsrCodFromEncryptedUsrCod (&Gbl.Usrs.Other.UsrDat); - if (Gbl.Usrs.Other.UsrDat.UsrCod < 0) // Check is user's code is valid + Usr_GetUsrCodFromEncryptedUsrCod (UsrDat); + if (UsrDat->UsrCod < 0) // Check is user's code is valid Lay_ShowErrorAndExit ("Wrong user's code."); - ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat); } - else // Parameter does not exist + else + UsrDat->UsrCod = -1L; + } + +/*****************************************************************************/ +/********* Get hidden parameter encrypted user's code of other user **********/ +/*****************************************************************************/ + +void Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (void) + { + Usr_GetParamOtherUsrCodEncrypted (&Gbl.Usrs.Other.UsrDat); + if (Gbl.Usrs.Other.UsrDat.UsrCod > 0) // If parameter exists... + ID_GetListIDsFromUsrCod (&Gbl.Usrs.Other.UsrDat); + else // Parameter does not exist { - Gbl.Usrs.Other.UsrDat.UsrCod = -1L; Gbl.Usrs.Other.UsrDat.UsrIDNickOrEmail[0] = '\0'; Gbl.Usrs.Other.UsrDat.IDs.Num = 0; Gbl.Usrs.Other.UsrDat.IDs.List = NULL; @@ -1877,7 +1888,7 @@ void Usr_GetParamOtherUsrCodEncrypted (void) bool Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (void) { /***** Get parameter with encrypted user's code *****/ - Usr_GetParamOtherUsrCodEncrypted (); + Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (); /***** Check if user exists and get her/his data *****/ if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat)) // Existing user diff --git a/swad_user.h b/swad_user.h index ca9760b79..3102d6d4f 100644 --- a/swad_user.h +++ b/swad_user.h @@ -257,7 +257,8 @@ unsigned Usr_GetParamOtherUsrIDNickOrEMailAndGetUsrCods (struct ListUsrCods *Lis void Usr_PutParamOtherUsrCodEncrypted (void); void Usr_PutParamUsrCodEncrypted (const char EncryptedUsrCod[Cry_LENGTH_ENCRYPTED_STR_SHA256_BASE64+1]); -void Usr_GetParamOtherUsrCodEncrypted (void); +void Usr_GetParamOtherUsrCodEncrypted (struct UsrData *UsrDat); +void Usr_GetParamOtherUsrCodEncryptedAndGetListIDs (void); bool Usr_GetParamOtherUsrCodEncryptedAndGetUsrData (void); void Usr_ChkUsrAndGetUsrData (void);