Version 18.54.1

This commit is contained in:
Antonio Cañas Vargas 2019-02-22 14:04:54 +01:00
parent d0d7ac6209
commit 642324598a
11 changed files with 1417 additions and 1360 deletions

File diff suppressed because it is too large Load Diff

View File

@ -278,8 +278,6 @@
// TODO: A superuser can not see records of teachers? Why?
// TODO: After "Do not show it again" nothing is displayed.
// TODO: Non-editing teachers should can control assistance of students in their groups
// TODO: Enviar correo a todos los profesores de una asignatura, sugerido por Pedro Villar Castro
@ -410,6 +408,8 @@ Antonio
// TODO: Actualizar ayuda en GitHub, por ejemplo Preferencias ahora es Ajustes.
// TODO: Chequear negritas en lista de foros, en color rosa por ej. Habrá que cambiar clases
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
@ -429,11 +429,12 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.54 (2019-02-21)"
#define Log_PLATFORM_VERSION "SWAD 18.54.1 (2019-02-21)"
#define CSS_FILE "swad18.54.css"
#define JS_FILE "swad18.51.js"
/*
Version 18.54: Feb 21, 2019 Selection of users scope in timeline is made with icons. (? lines)
Version 18.54.1: Feb 22, 2019 Following and followers shown in photo zoom. (237586 lines)
Version 18.54: Feb 21, 2019 Selection of users scope in timeline is made with icons. (237534 lines)
Version 18.53: Feb 21, 2019 Last selection of users scope in timeline is saved in database. (237538 lines)
1 change necessary in database:
ALTER TABLE usr_last ADD COLUMN TimelineUsrs TINYINT NOT NULL DEFAULT 0 AFTER LastAccNotif;

View File

@ -453,28 +453,43 @@ bool Fol_CheckUsrIsFollowerOf (long FollowerCod,long FollowedCod)
/*************************** Get number of followed **************************/
/*****************************************************************************/
unsigned Fol_GetNumFollowing (long UsrCod)
void Fol_FlushCacheFollow (void)
{
/***** Check if a user is a follower of another user *****/
return
(unsigned) DB_QueryCOUNT ("can not get number of followed",
"SELECT COUNT(*) FROM usr_follow"
" WHERE FollowerCod=%ld",
UsrCod);
Gbl.Cache.Follow.UsrCod = -1L;
Gbl.Cache.Follow.NumFollowing =
Gbl.Cache.Follow.NumFollowers = 0;
}
/*****************************************************************************/
/************************** Get number of followers **************************/
/*****************************************************************************/
unsigned Fol_GetNumFollowers (long UsrCod)
void Fol_GetNumFollow (long UsrCod,
unsigned *NumFollowing,unsigned *NumFollowers)
{
/***** Check if a user is a follower of another user *****/
return
(unsigned) DB_QueryCOUNT ("can not get number of followers",
"SELECT COUNT(*) FROM usr_follow"
" WHERE FollowedCod=%ld",
UsrCod);
/***** 1. Fast check: trivial cases *****/
if (UsrCod <= 0)
{
*NumFollowing = *NumFollowers = 0;
return;
}
/***** 2. Fast check: Is number of following already calculated? *****/
if (UsrCod == Gbl.Cache.Follow.UsrCod)
{
*NumFollowing = Gbl.Cache.Follow.NumFollowing;
*NumFollowers = Gbl.Cache.Follow.NumFollowers;
return;
}
/***** 3. Slow check: Get number of following/followers from database *****/
Gbl.Cache.Follow.UsrCod = UsrCod;
*NumFollowing = Gbl.Cache.Follow.NumFollowing =
(unsigned) DB_QueryCOUNT ("can not get number of followed",
"SELECT COUNT(*) FROM usr_follow"
" WHERE FollowerCod=%ld",
UsrCod);
*NumFollowers = Gbl.Cache.Follow.NumFollowers =
(unsigned) DB_QueryCOUNT ("can not get number of followers",
"SELECT COUNT(*) FROM usr_follow"
" WHERE FollowedCod=%ld",
UsrCod);
}
/*****************************************************************************/
@ -1019,6 +1034,9 @@ void Fol_FollowUsr1 (void)
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Flush cache *****/
Fol_FlushCacheFollow ();
/***** This follow must be notified by email? *****/
CreateNotif = (Gbl.Usrs.Other.UsrDat.Prefs.NotifNtfEvents & (1 << Ntf_EVENT_FOLLOWER));
NotifyByEmail = CreateNotif &&
@ -1072,12 +1090,17 @@ void Fol_UnfollowUsr1 (void)
// Unfollow only if I follow him/her
if (Fol_CheckUsrIsFollowerOf (Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod))
{
/***** Unfollow user in database *****/
DB_QueryREPLACE ("can not unfollow user",
"DELETE FROM usr_follow"
" WHERE FollowerCod=%ld AND FollowedCod=%ld",
Gbl.Usrs.Me.UsrDat.UsrCod,
Gbl.Usrs.Other.UsrDat.UsrCod);
/***** Flush cache *****/
Fol_FlushCacheFollow ();
}
Gbl.DelayedAlert.Type = Ale_SUCCESS;
}
else
@ -1221,4 +1244,7 @@ void Fol_RemoveUsrFromUsrFollow (long UsrCod)
"DELETE FROM usr_follow"
" WHERE FollowerCod=%ld OR FollowedCod=%ld",
UsrCod,UsrCod);
/***** Flush cache *****/
Fol_FlushCacheFollow ();
}

View File

@ -49,7 +49,9 @@ void Fol_SuggestUsrsToFollowMainZone (void);
void Fol_SuggestUsrsToFollowMainZoneOnRightColumn (void);
bool Fol_CheckUsrIsFollowerOf (long FollowerCod,long FollowedCod);
unsigned Fol_GetNumFollowing (long UsrCod);
void Fol_FlushCacheFollow (void);
void Fol_GetNumFollow (long UsrCod,
unsigned *NumFollowing,unsigned *NumFollowers);
unsigned Fol_GetNumFollowers (long UsrCod);
void Fol_ShowFollowingAndFollowers (const struct UsrData *UsrDat,
unsigned NumFollowing,unsigned NumFollowers,

View File

@ -39,6 +39,7 @@
#include "swad_config.h"
#include "swad_constant.h"
#include "swad_exam.h"
#include "swad_follow.h"
#include "swad_global.h"
#include "swad_icon.h"
#include "swad_parameter.h"
@ -486,6 +487,7 @@ void Gbl_InitializeGlobals (void)
Prj_FlushCacheMyRoleInProject ();
Grp_FlushCacheIBelongToGrp ();
Grp_FlushCacheUsrSharesAnyOfMyGrpsInCurrentCrs ();
Fol_FlushCacheFollow ();
}
/*****************************************************************************/

View File

@ -870,6 +870,12 @@ struct Globals
long PrjCod;
Prj_RoleInProject_t RoleInProject;
} MyRoleInProject;
struct
{
long UsrCod;
unsigned NumFollowing;
unsigned NumFollowers;
} Follow;
} Cache;
};

View File

@ -40,6 +40,7 @@
#include "swad_enrolment.h"
#include "swad_file.h"
#include "swad_file_browser.h"
#include "swad_follow.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_logo.h"
@ -1183,6 +1184,10 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
const char *ClassPhoto,Pho_Zoom_t Zoom,
bool FormUnique)
{
extern const char *Txt_Following;
extern const char *Txt_Followers;
unsigned NumFollowing;
unsigned NumFollowers;
bool PhotoExists;
bool BrowserTabIs1stTab = Act_GetBrowserTab (Gbl.Action.Act) == Act_BRW_1ST_TAB;
bool PutLinkToPublicProfile = !Gbl.Form.Inside && // Only if not inside another form
@ -1220,7 +1225,7 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
Usr_WriteFirstNameBRSurnames (UsrDat);
fprintf (Gbl.F.Out,"</div>");
/* Institution full name and institution country */
/* Institution full name and institution country */
if (UsrDat->InsCod > 0)
{
fprintf (Gbl.F.Out,"<div class=\"ZOOM_TXT_LINE DAT_SMALL\">");
@ -1236,6 +1241,17 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
fprintf (Gbl.F.Out,"</div>");
}
/* Following and followers */
Fol_GetNumFollow (UsrDat->UsrCod,&NumFollowing,&NumFollowers);
fprintf (Gbl.F.Out,"<div class=\"ZOOM_TXT_LINE\">"
"<span class=\"DAT_N_BOLD\">%u</span>"
"<span class=\"DAT_SMALL\">&nbsp;%s&nbsp;&nbsp;</span>"
"<span class=\"DAT_N_BOLD\">%u</span>"
"<span class=\"DAT_SMALL\">&nbsp;%s</span>"
"</div>",
NumFollowing,Txt_Following,
NumFollowers,Txt_Followers);
fprintf (Gbl.F.Out,"</div>");
}

View File

@ -301,8 +301,7 @@ bool Prf_ShowUserProfile (struct UsrData *UsrDat)
Prf_ShowDetailsUserProfile (UsrDat);
/***** Count following and followers *****/
NumFollowing = Fol_GetNumFollowing (UsrDat->UsrCod);
NumFollowers = Fol_GetNumFollowers (UsrDat->UsrCod);
Fol_GetNumFollow (UsrDat->UsrCod,&NumFollowing,&NumFollowers);
UsrFollowsMe = false;
if (NumFollowing)
UsrFollowsMe = Fol_CheckUsrIsFollowerOf (UsrDat->UsrCod,

View File

@ -344,7 +344,7 @@ Rol_Role_t Rol_GetRoleUsrInCrs (long UsrCod,long CrsCod)
CrsCod <= 0)
return Rol_UNK;
/***** 2. Fast check: Is role in course already calculated *****/
/***** 2. Fast check: Is role in course already calculated? *****/
if (UsrCod == Gbl.Cache.RoleUsrInCrs.UsrCod &&
CrsCod == Gbl.Cache.RoleUsrInCrs.CrsCod )
return Gbl.Cache.RoleUsrInCrs.Role;

View File

@ -1184,9 +1184,12 @@ static void Soc_SaveWhichUsersInDB (void)
static void Soc_ShowWarningYouDontFollowAnyUser (void)
{
extern const char *Txt_You_dont_follow_any_user;
unsigned NumFollowing;
unsigned NumFollowers;
/***** Check if I follow someone *****/
if (!Fol_GetNumFollowing (Gbl.Usrs.Me.UsrDat.UsrCod))
Fol_GetNumFollow (Gbl.Usrs.Me.UsrDat.UsrCod,&NumFollowing,&NumFollowers);
if (!NumFollowing)
{
/***** Show warning if I do not follow anyone *****/
Ale_ShowAlert (Ale_WARNING,Txt_You_dont_follow_any_user);

View File

@ -44,6 +44,7 @@
#include "swad_database.h"
#include "swad_duplicate.h"
#include "swad_enrolment.h"
#include "swad_follow.h"
#include "swad_form.h"
#include "swad_global.h"
#include "swad_group.h"
@ -830,6 +831,7 @@ void Usr_FlushCachesUsr (void)
Rol_FlushCacheRoleUsrInCrs ();
Grp_FlushCacheUsrSharesAnyOfMyGrpsInCurrentCrs ();
Grp_FlushCacheIBelongToGrp ();
Fol_FlushCacheFollow ();
}
/*****************************************************************************/