mirror of https://github.com/acanas/swad-core.git
Version 15.122
This commit is contained in:
parent
bd7b1383c8
commit
14ba86fc0b
|
@ -348,7 +348,7 @@ static void Asg_ShowOneAssignment (long AsgCod)
|
|||
|
||||
/***** Mark possible notification as seen *****/
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_ASSIGNMENT,
|
||||
AsgCod,
|
||||
AsgCod,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -116,20 +116,20 @@
|
|||
// TODO: Enable chat for guests?
|
||||
// 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: Increment one second after each refresh in social timeline?
|
||||
// TODO: Notifications of new followers should go to follower's profile
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.121.9 (2016-01-20)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 15.122 (2016-01-20)"
|
||||
#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.122: Jan 20, 2016 Notifications of new followers go to follower's profile.
|
||||
Changes in notifications. (194008 lines)
|
||||
Version 15.121.9: Jan 20, 2016 Code optimization in social comments. (193952 lines)
|
||||
Version 15.121.8: Jan 20, 2016 Fixed bugs removing favs to social comments. (193960 lines)
|
||||
Version 15.121.7: Jan 20, 2016 Changes in layout of social timeline. (193955 lines)
|
||||
|
|
|
@ -367,7 +367,7 @@ void Enr_ReqAcceptRegisterInCrs (void)
|
|||
/***** Mark possible notification as seen *****/
|
||||
Ntf_MarkNotifAsSeen (Gbl.Usrs.Me.UsrDat.RoleInCurrentCrsDB == Rol_STUDENT ? Ntf_EVENT_ENROLLMENT_STUDENT :
|
||||
Ntf_EVENT_ENROLLMENT_TEACHER,
|
||||
-1L,
|
||||
-1L,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
|
@ -2823,7 +2823,7 @@ void Enr_ShowEnrollmentRequests (void)
|
|||
|
||||
/***** Mark possible notification as seen *****/
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_ENROLLMENT_REQUEST,
|
||||
ReqCod,
|
||||
ReqCod,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
else // User does not exists or user already belongs to course ==> remove pair from crs_usr_requests table
|
||||
|
|
|
@ -405,7 +405,7 @@ void Exa_ListExamAnnouncementsSee (void)
|
|||
|
||||
/***** Mark possible notifications as seen *****/
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_EXAM_ANNOUNCEMENT,
|
||||
-1L,
|
||||
-1L,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
|
|
|
@ -9210,13 +9210,13 @@ void Brw_ShowFileMetadata (void)
|
|||
case Brw_ADMI_DOCUM_CRS:
|
||||
case Brw_ADMI_DOCUM_GRP:
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_DOCUMENT_FILE,
|
||||
FileMetadata.FilCod,
|
||||
FileMetadata.FilCod,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
case Brw_ADMI_SHARE_CRS:
|
||||
case Brw_ADMI_SHARE_GRP:
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_SHARED_FILE,
|
||||
FileMetadata.FilCod,
|
||||
FileMetadata.FilCod,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
case Brw_SHOW_MARKS_CRS:
|
||||
|
@ -9224,7 +9224,7 @@ void Brw_ShowFileMetadata (void)
|
|||
case Brw_ADMI_MARKS_CRS:
|
||||
case Brw_ADMI_MARKS_GRP:
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_MARKS_FILE,
|
||||
FileMetadata.FilCod,
|
||||
FileMetadata.FilCod,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
default:
|
||||
|
@ -9349,13 +9349,13 @@ void Brw_DownloadFile (void)
|
|||
case Brw_ADMI_DOCUM_CRS:
|
||||
case Brw_ADMI_DOCUM_GRP:
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_DOCUMENT_FILE,
|
||||
FileMetadata.FilCod,
|
||||
FileMetadata.FilCod,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
case Brw_ADMI_SHARE_CRS:
|
||||
case Brw_ADMI_SHARE_GRP:
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_SHARED_FILE,
|
||||
FileMetadata.FilCod,
|
||||
FileMetadata.FilCod,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
case Brw_SHOW_MARKS_CRS:
|
||||
|
@ -9363,7 +9363,7 @@ void Brw_DownloadFile (void)
|
|||
case Brw_ADMI_MARKS_CRS:
|
||||
case Brw_ADMI_MARKS_GRP:
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_MARKS_FILE,
|
||||
FileMetadata.FilCod,
|
||||
FileMetadata.FilCod,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -415,8 +415,9 @@ void Fol_ListFollowers (void)
|
|||
|
||||
/***** If it's me, mark possible notification as seen *****/
|
||||
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,-1L,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,
|
||||
-1L,-1L,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
else
|
||||
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
|
||||
|
@ -545,7 +546,7 @@ void Fol_FollowUsr (void)
|
|||
/***** Create notification for this followed.
|
||||
If this followed wants to receive notifications by e-mail, activate the sending of a notification *****/
|
||||
if (CreateNotif)
|
||||
Ntf_StoreNotifyEventToOneUser (Ntf_EVENT_FOLLOWER,&Gbl.Usrs.Other.UsrDat,-1L,
|
||||
Ntf_StoreNotifyEventToOneUser (Ntf_EVENT_FOLLOWER,&Gbl.Usrs.Other.UsrDat,Gbl.Usrs.Me.UsrDat.UsrCod,
|
||||
(Ntf_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL :
|
||||
0));
|
||||
}
|
||||
|
|
|
@ -1030,16 +1030,16 @@ static void For_ShowThreadPosts (long ThrCod,char *LastSubject)
|
|||
case For_FORUM_COURSE_TCHS:
|
||||
case For_FORUM_COURSE_USRS:
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_FORUM_POST_COURSE,
|
||||
PstCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
PstCod,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (Thr.NumMyPosts)
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_FORUM_REPLY,
|
||||
PstCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
PstCod,-1L,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
Lay_EndRoundFrameTable ();
|
||||
|
|
|
@ -1167,7 +1167,7 @@ void Msg_ExpRecMsg (void)
|
|||
|
||||
/***** Mark possible notification as seen *****/
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_MESSAGE,
|
||||
Gbl.Msg.ExpandedMsgCod,
|
||||
Gbl.Msg.ExpandedMsgCod,-1L,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
||||
/***** Show again the messages *****/
|
||||
|
|
|
@ -476,8 +476,8 @@ void Not_ShowNotices (Not_Listing_t TypeNoticesListing,bool ICanEditNotices)
|
|||
|
||||
/***** Mark possible notification as seen *****/
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_NOTICE,
|
||||
-1L,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
-1L,Gbl.CurrentCrs.Crs.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -644,6 +644,7 @@ static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
|
|||
{
|
||||
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;
|
||||
|
@ -693,17 +694,30 @@ static bool Ntf_StartFormGoToAction (Ntf_NotifyEvent_t NotifyEvent,
|
|||
Brw_PutHiddenParamFilCod (FileMetadata.FilCod);
|
||||
}
|
||||
break;
|
||||
case Ntf_EVENT_NOTICE:
|
||||
Act_FormStart (Ntf_DefaultActions[NotifyEvent]);
|
||||
Not_PutHiddenParamNotCod (Cod);
|
||||
case Ntf_EVENT_FOLLOWER:
|
||||
UsrDat.UsrCod = Cod; // Cod is the follower's code
|
||||
Usr_GetEncryptedUsrCodFromUsrCod (&UsrDat);
|
||||
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);
|
||||
}
|
||||
else // No user's code found ==> go to see my followers
|
||||
Act_FormStart (ActSeeFlr);
|
||||
break;
|
||||
case Ntf_EVENT_FORUM_POST_COURSE:
|
||||
case Ntf_EVENT_FORUM_REPLY:
|
||||
Act_FormStart (For_ActionsSeeFor[Gbl.Forum.ForumType]);
|
||||
For_PutAllHiddenParamsForum ();
|
||||
break;
|
||||
case Ntf_EVENT_NOTICE:
|
||||
Act_FormStart (ActShoNot);
|
||||
Not_PutHiddenParamNotCod (Cod);
|
||||
break;
|
||||
case Ntf_EVENT_MESSAGE:
|
||||
Act_FormStart (Ntf_DefaultActions[NotifyEvent]);
|
||||
Act_FormStart (ActExpRcvMsg);
|
||||
Msg_PutHiddenParamMsgCod (Cod);
|
||||
break;
|
||||
default:
|
||||
|
@ -817,23 +831,28 @@ void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr,Ntf_Notif
|
|||
/********************** Set possible notification as seen ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Ntf_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod)
|
||||
void Ntf_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long CrsCod,long ToUsrCod)
|
||||
{
|
||||
char Query[256];
|
||||
|
||||
/***** Set notification as seen by me *****/
|
||||
if (ToUsrCod > 0) // If the user code is specified
|
||||
{
|
||||
if (Cod > 0) // Set only one notification as seen
|
||||
if (Cod > 0) // Set only one notification for the user as seen
|
||||
sprintf (Query,"UPDATE notif SET Status=(Status | %u)"
|
||||
" WHERE ToUsrCod='%ld' AND NotifyEvent='%u' AND Cod='%ld'",
|
||||
(unsigned) Ntf_STATUS_BIT_READ,
|
||||
ToUsrCod,(unsigned) NotifyEvent,Cod);
|
||||
else // Set all notifications of this type, in the current course for the user, as seen
|
||||
else if (CrsCod > 0) // Set all notifications of this type in the current course for the user as seen
|
||||
sprintf (Query,"UPDATE notif SET Status=(Status | %u)"
|
||||
" WHERE ToUsrCod='%ld' AND NotifyEvent='%u' AND CrsCod='%ld'",
|
||||
(unsigned) Ntf_STATUS_BIT_READ,
|
||||
ToUsrCod,(unsigned) NotifyEvent,Gbl.CurrentCrs.Crs.CrsCod);
|
||||
else // Set all notifications of this type for the user as seen
|
||||
sprintf (Query,"UPDATE notif SET Status=(Status | %u)"
|
||||
" WHERE ToUsrCod='%ld' AND NotifyEvent='%u'",
|
||||
(unsigned) Ntf_STATUS_BIT_READ,
|
||||
ToUsrCod,(unsigned) NotifyEvent);
|
||||
DB_QueryUPDATE (Query,"can not set notification(s) as seen");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ void Ntf_ShowMyNotifications (void);
|
|||
Ntf_StatusTxt_t Ntf_GetStatusTxtFromStatusBits (Ntf_Status_t Status);
|
||||
void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr,Ntf_NotifyEvent_t NotifyEvent,
|
||||
long Cod,long CrsCod,long UsrCod,unsigned MaxChars,bool GetContent);
|
||||
void Ntf_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod);
|
||||
void Ntf_MarkNotifAsSeen (Ntf_NotifyEvent_t NotifyEvent,long Cod,long CrsCod,long ToUsrCod);
|
||||
void Ntf_MarkNotifAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod);
|
||||
void Ntf_MarkNotifToOneUsrAsRemoved (Ntf_NotifyEvent_t NotifyEvent,long Cod,long ToUsrCod);
|
||||
void Ntf_MarkNotifInCrsAsRemoved (long CrsCod,long ToUsrCod);
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "swad_global.h"
|
||||
#include "swad_network.h"
|
||||
#include "swad_nickname.h"
|
||||
#include "swad_notification.h"
|
||||
#include "swad_parameter.h"
|
||||
#include "swad_privacy.h"
|
||||
#include "swad_profile.h"
|
||||
|
@ -205,6 +206,12 @@ void Prf_GetUsrDatAndShowUserProfile (void)
|
|||
/* End section */
|
||||
fprintf (Gbl.F.Out,"</section>");
|
||||
}
|
||||
|
||||
/***** If it's not me, mark possible notification as seen *****/
|
||||
if (Gbl.Usrs.Other.UsrDat.UsrCod != Gbl.Usrs.Me.UsrDat.UsrCod)
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_FOLLOWER,
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod,-1L,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -538,7 +538,7 @@ static void Svy_ShowOneSurvey (long SvyCod,struct SurveyQuestion *SvyQst,bool Sh
|
|||
/***** Mark possible notification as seen *****/
|
||||
if (Svy.CrsCod > 0) // Only course surveys are notified
|
||||
Ntf_MarkNotifAsSeen (Ntf_EVENT_SURVEY,
|
||||
SvyCod,
|
||||
SvyCod,Svy.CrsCod,
|
||||
Gbl.Usrs.Me.UsrDat.UsrCod);
|
||||
|
||||
/***** End frame *****/
|
||||
|
|
41
swad_user.c
41
swad_user.c
|
@ -346,7 +346,7 @@ void Usr_FreeListUsrCods (struct ListUsrCods *ListUsrCods)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/** Get user code from user's record in database using encrypted user code ***/
|
||||
/******** Get user's code from database using encrypted user's code **********/
|
||||
/*****************************************************************************/
|
||||
// Input: UsrDat->EncryptedUsrCod must hold user's encrypted code
|
||||
|
||||
|
@ -368,7 +368,7 @@ void Usr_GetUsrCodFromEncryptedUsrCod (struct UsrData *UsrDat)
|
|||
if (NumRows != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting user's code.");
|
||||
|
||||
/***** Get user code *****/
|
||||
/***** Get user's code *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
UsrDat->UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
|
@ -379,6 +379,41 @@ void Usr_GetUsrCodFromEncryptedUsrCod (struct UsrData *UsrDat)
|
|||
UsrDat->UsrCod = -1L;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Get encrypted user's code from database using user's code *********/
|
||||
/*****************************************************************************/
|
||||
// Input: UsrDat->UsrCod must hold user's code
|
||||
|
||||
void Usr_GetEncryptedUsrCodFromUsrCod (struct UsrData *UsrDat)
|
||||
{
|
||||
char Query[512];
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned long NumRows;
|
||||
|
||||
if (UsrDat->UsrCod > 0)
|
||||
{
|
||||
/***** Get encrypted user's code from database *****/
|
||||
sprintf (Query,"SELECT EncryptedUsrCod FROM usr_data"
|
||||
" WHERE UsrCod='%ld'",
|
||||
UsrDat->UsrCod);
|
||||
NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get encrypted user's code");
|
||||
|
||||
if (NumRows != 1)
|
||||
Lay_ShowErrorAndExit ("Error when getting encrypted user's code.");
|
||||
|
||||
/***** Get encrypted user's code *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
strncpy (UsrDat->EncryptedUsrCod,row[0],sizeof (UsrDat->EncryptedUsrCod)-1);
|
||||
UsrDat->EncryptedUsrCod[sizeof (UsrDat->EncryptedUsrCod)-1] = '\0';
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
else
|
||||
UsrDat->EncryptedUsrCod[0] = '\0';
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************ Get user's data from database giving a user's code *************/
|
||||
/*****************************************************************************/
|
||||
|
@ -417,7 +452,7 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
|
|||
/***** Read user's data *****/
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get encrypted user code */
|
||||
/* Get encrypted user's code */
|
||||
strncpy (UsrDat->EncryptedUsrCod,row[0],sizeof (UsrDat->EncryptedUsrCod)-1);
|
||||
UsrDat->EncryptedUsrCod[sizeof (UsrDat->EncryptedUsrCod)-1] = '\0';
|
||||
|
||||
|
|
|
@ -203,6 +203,7 @@ void Usr_GetAllUsrDataFromUsrCod (struct UsrData *UsrDat);
|
|||
void Usr_AllocateListUsrCods (struct ListUsrCods *ListUsrCods);
|
||||
void Usr_FreeListUsrCods (struct ListUsrCods *ListUsrCods);
|
||||
void Usr_GetUsrCodFromEncryptedUsrCod (struct UsrData *UsrDat);
|
||||
void Usr_GetEncryptedUsrCodFromUsrCod (struct UsrData *UsrDat);
|
||||
void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat);
|
||||
|
||||
void Usr_BuildFullName (struct UsrData *UsrDat);
|
||||
|
|
Loading…
Reference in New Issue