Version 14.100

This commit is contained in:
Antonio Cañas Vargas 2015-03-24 00:01:40 +01:00
parent e78ecbae0e
commit 195f593f95
8 changed files with 152 additions and 5 deletions

View File

@ -10551,3 +10551,25 @@ CREATE TABLE IF NOT EXISTS usr_follow (FollowerCod INT NOT NULL,FollowedCod NIT
CREATE INDEX UsrCod ON file_view (UsrCod);
SELECT FollowedCod,COUNT(FollowerCod) AS N FROM usr_follow GROUP BY FollowedCod ORDER BY N DESC,FollowedCod LIMIT 100;
----- 2015-03-23, swad14.100
/*
UPDATE notif SET NotifyEvent=13 WHERE NotifyEvent=12;
UPDATE notif SET NotifyEvent=12 WHERE NotifyEvent=11;
UPDATE notif SET NotifyEvent=11 WHERE NotifyEvent=10;
UPDATE notif SET NotifyEvent=10 WHERE NotifyEvent=9;
UPDATE notif SET NotifyEvent=9 WHERE NotifyEvent=8;
UPDATE sta_notif SET NotifyEvent=13 WHERE NotifyEvent=12;
UPDATE sta_notif SET NotifyEvent=12 WHERE NotifyEvent=11;
UPDATE sta_notif SET NotifyEvent=11 WHERE NotifyEvent=10;
UPDATE sta_notif SET NotifyEvent=10 WHERE NotifyEvent=9;
UPDATE sta_notif SET NotifyEvent=9 WHERE NotifyEvent=8;
UPDATE usr_data SET NotifNtfEvents=(((NotifNtfEvents & ~0xFF) << 1) | (NotifNtfEvents & 0xFF) | 0x100);
UPDATE usr_data SET EmailNtfEvent =(((EmailNtfEvent & ~0xFF) << 1) | (EmailNtfEvent & 0xFF));
*/
UPDATE usr_data SET NotifNtfEvents=(NotifNtfEvents | 0x2000);

View File

@ -103,14 +103,18 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 14.99.2 (2015/03/23)"
#define Log_PLATFORM_VERSION "SWAD 14.100 (2015/03/23)"
// 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 14.100: Mar 23, 2015 Notification when a user gets a new follower. (183723 lines)
1 change necessary in database:
UPDATE usr_data SET NotifNtfEvents=(NotifNtfEvents | 0x2000) WHERE NotifNtfEvents<>0;
Version 14.99.2: Mar 23, 2015 Ranking attending to number of followers. (183614 lines)
Version 14.99.1: Mar 21, 2015 Change in file_view to accelerate queries. (183521 lines)
1 change necessary in Makefile:
1 change necessary in database:
CREATE INDEX UsrCod ON file_view (UsrCod);
Version 14.99: Mar 21, 2015 Icons instead of text in user's profile.

View File

@ -26,11 +26,13 @@
/*****************************************************************************/
#include <stdio.h> // For sprintf
#include <string.h> // For string functions
#include "swad_bool.h"
#include "swad_database.h"
#include "swad_follow.h"
#include "swad_global.h"
#include "swad_notification.h"
#include "swad_profile.h"
#include "swad_user.h"
@ -291,7 +293,12 @@ void Fol_ListFollowers (void)
struct UsrData UsrDat;
/***** Get user to view user he/she follows *****/
if (Usr_GetParamOtherUsrCodEncryptedAndGetUsrData ())
Usr_GetParamOtherUsrCodEncrypted ();
if (Gbl.Usrs.Other.UsrDat.UsrCod <= 0) // If user not specified, view my profile
Gbl.Usrs.Other.UsrDat.UsrCod = Gbl.Usrs.Me.UsrDat.UsrCod;
/***** Check if user exists and get his data *****/
if (Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat))
{
/***** Show user's profile *****/
if (Prf_ShowUserProfile ())
@ -339,6 +346,11 @@ void Fol_ListFollowers (void)
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
/***** If it's me, mark possible notification as seen *****/
if (Gbl.Usrs.Other.UsrDat.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod)
Ntf_SetNotifAsSeen (Ntf_EVENT_FOLLOWER,-1L,
Gbl.Usrs.Me.UsrDat.UsrCod);
}
else
Lay_ShowAlert (Lay_WARNING,Txt_User_not_found_or_you_do_not_have_permission_);
@ -435,6 +447,8 @@ void Fol_FollowUsr (void)
{
extern const char *Txt_User_not_found_or_you_do_not_have_permission_;
char Query[256];
bool CreateNotif;
bool NotifyByEmail;
bool Error;
/***** Get user to be followed *****/
@ -453,6 +467,18 @@ void Fol_FollowUsr (void)
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
DB_QueryREPLACE (Query,"can not follow user");
/***** This follow must be notified by e-mail? *****/
CreateNotif = (Gbl.Usrs.Other.UsrDat.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_FOLLOWER));
NotifyByEmail = CreateNotif &&
(Gbl.Usrs.Other.UsrDat.Prefs.EmailNtfEvents & (1 << Ntf_EVENT_FOLLOWER));
/***** 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_Status_t) (NotifyByEmail ? Ntf_STATUS_BIT_EMAIL :
0));
}
/***** Show user's profile again *****/
@ -578,3 +604,16 @@ void Fol_GetAndShowRankingFollowers (void)
}
Prf_ShowRankingFigure (Query);
}
/*****************************************************************************/
/********************* Get notification of a new follower ********************/
/*****************************************************************************/
// This function may be called inside a web service, so don't report error
void Fol_GetNotifFollower (char *SummaryStr,char **ContentStr)
{
SummaryStr[0] = '\0';
if ((*ContentStr = (char *) malloc (1)))
strcpy (*ContentStr,"");
}

View File

@ -27,6 +27,8 @@
/********************************** Headers **********************************/
/*****************************************************************************/
#include <stdlib.h> // For malloc
#include "swad_user.h"
/*****************************************************************************/
@ -51,4 +53,6 @@ void Fol_UnfollowUsr (void);
void Fol_GetAndShowRankingFollowers (void);
void Fol_GetNotifFollower (char *SummaryStr,char **ContentStr);
#endif

View File

@ -37,6 +37,7 @@
#include "swad_database.h"
#include "swad_enrollment.h"
#include "swad_exam.h"
#include "swad_follow.h"
#include "swad_global.h"
#include "swad_mark.h"
#include "swad_notice.h"
@ -78,6 +79,9 @@ const char *Ntf_WSNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] =
/* Statistics tab */
"survey",
/* Profile tab */
"follower",
};
static const Act_Action_t Ntf_DefaultActions[Ntf_NUM_NOTIFY_EVENTS] =
@ -105,6 +109,9 @@ static const Act_Action_t Ntf_DefaultActions[Ntf_NUM_NOTIFY_EVENTS] =
/* Statistics tab */
ActSeeAllSvy, // Ntf_EVENT_SURVEY
/* Profile tab */
ActSeeFlr, // Ntf_EVENT_FOLLOWER
};
/*****************************************************************************/
@ -137,6 +144,9 @@ static const char *Ntf_ParamNotifMeAboutNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] =
/* Statistics tab */
"NotifyNtfEventSurvey",
/* Profile tab */
"NotifyNtfEventFollower",
};
// Email me about notification events
@ -165,6 +175,9 @@ static const char *Ntf_ParamEmailMeAboutNotifyEvents[Ntf_NUM_NOTIFY_EVENTS] =
/* Statistics tab */
"EmailNtfEventSurvey",
/* Profile tab */
"EmailNtfEventFollower",
};
// Icons for notification events
@ -193,6 +206,9 @@ static const char *Ntf_Icons[Ntf_NUM_NOTIFY_EVENTS] =
/* Statistics tab */
"survey", // Ntf_EVENT_SURVEY
/* Profile tab */
"follow", // Ntf_EVENT_FOLLOWER
};
/*****************************************************************************/
@ -750,6 +766,9 @@ void Ntf_GetNotifSummaryAndContent (char *SummaryStr,char **ContentStr,Ntf_Notif
case Ntf_EVENT_SURVEY:
Svy_GetNotifSurvey (SummaryStr,ContentStr,Cod,MaxChars,GetContent);
break;
case Ntf_EVENT_FOLLOWER:
Fol_GetNotifFollower (SummaryStr,ContentStr);
break;
}
//if (Gbl.WebService.IsWebService)
@ -1135,6 +1154,8 @@ unsigned Ntf_StoreNotifyEventsToAllUsrs (Ntf_NotifyEvent_t NotifyEvent,long Cod)
Cod,Cod,Gbl.Usrs.Me.UsrDat.UsrCod,
Cod,Gbl.Usrs.Me.UsrDat.UsrCod);
break;
case Ntf_EVENT_FOLLOWER: // This function should not be called in this case
return 0;
}
if ((NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get users to be notified"))) // Users found
@ -1421,6 +1442,7 @@ static void Ntf_SendPendingNotifByEMailToOneUsr (struct UsrData *ToUsrDat,unsign
switch (NotifyEvent)
{
case Ntf_EVENT_UNKNOWN:
case Ntf_EVENT_FOLLOWER:
break;
case Ntf_EVENT_DOCUMENT_FILE:
case Ntf_EVENT_SHARED_FILE:

View File

@ -37,7 +37,7 @@
/******************************** Public types *******************************/
/*****************************************************************************/
#define Ntf_NUM_NOTIFY_EVENTS 13
#define Ntf_NUM_NOTIFY_EVENTS 14
// If the numbers assigned to each event type change,
// it is necessary to change old numbers to new ones in database tables notif and sta_notif
typedef enum
@ -66,6 +66,9 @@ typedef enum
/* Statistics tab */
Ntf_EVENT_SURVEY = 12,
/* Profile tab */
Ntf_EVENT_FOLLOWER = 13,
} Ntf_NotifyEvent_t;
typedef enum

View File

@ -681,6 +681,18 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR_NO_HTML[Ntf_NUM_NOTIFY_EVENTS][Txt_NUM_LA
"Nowe badania",
"Novo inqu&eacute;rito",
},
{
// Ntf_EVENT_FOLLOWER
"Nou seguidor",
"Neue Anh&auml;nger",
"New follower",
"Nuevo seguidor",
"Nouveau suiveur",
"Nuevo seguidor", // Okoteve traducción
"Nuovo follower",
"Nowy obserwuj&aogon;",
"Novo seguidor",
},
};
const char *Txt_NOTIFY_EVENTS_There_is_a_new_event_NO_HTML[Txt_NUM_LANGUAGES] = // Warning: it is very important to include %s in the following sentences
@ -24818,6 +24830,26 @@ const char *Txt_NOTIFY_EVENTS_PLURAL[Ntf_NUM_NOTIFY_EVENTS] =
"Nowe badania"
#elif L==8
"Novos inqu&eacute;ritos"
#endif
,
#if L==0 // Ntf_EVENT_FOLLOWER
"Nous seguidors"
#elif L==1
"Neue Anh&auml;nger"
#elif L==2
"New followers"
#elif L==3
"Nuevos seguidores"
#elif L==4
"Nouveaux suiveurs"
#elif L==5
"Nuevos seguidores" // Okoteve traducción
#elif L==6
"Nuovi followers"
#elif L==7
"Nowe obserwuj&aogon;"
#elif L==8
"Novos seguidores"
#endif
};
@ -25081,6 +25113,26 @@ const char *Txt_NOTIFY_EVENTS_SINGULAR[Ntf_NUM_NOTIFY_EVENTS] =
"Badania"
#elif L==8
"Inqu&eacute;rito"
#endif
,
#if L==0 // Ntf_EVENT_FOLLOWER
"Seguidor"
#elif L==1
"Anh&auml;nger"
#elif L==2
"Follower"
#elif L==3
"Seguidor"
#elif L==4
"Suiveur"
#elif L==5
"Seguidor" // Okoteve traducción
#elif L==6
"Follower"
#elif L==7
"Obserwuj&aogon;"
#elif L==8
"Seguidor"
#endif
};

View File

@ -507,10 +507,11 @@ void Usr_GetUsrDataFromUsrCod (struct UsrData *UsrDat)
else
UsrDat->Prefs.SideCols = Cfg_DEFAULT_COLUMNS;
/* Get on which events I want to be notified by e-mail */
/* Get on which events I want to be notified inside the platform */
if (sscanf (row[29],"%u",&UsrDat->Prefs.NotifNtfEvents) != 1)
UsrDat->Prefs.NotifNtfEvents = (unsigned) -1; // 0xFF..FF
/* Get on which events I want to be notified by e-mail */
if (sscanf (row[30],"%u",&UsrDat->Prefs.EmailNtfEvents) != 1)
UsrDat->Prefs.EmailNtfEvents = 0;
if (UsrDat->Prefs.EmailNtfEvents >= (1 << Ntf_NUM_NOTIFY_EVENTS)) // Maximum binary value for NotifyEvents is 000...0011...11