Version19.92

This commit is contained in:
Antonio Cañas Vargas 2019-12-14 14:30:34 +01:00
parent 567b992a6d
commit 73a09d5846
23 changed files with 484 additions and 375 deletions

View File

@ -41,7 +41,7 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \
swad_game.o swad_global.o swad_group.o \
swad_help.o swad_hierarchy.o swad_holiday.o swad_HTML.o \
swad_icon.o swad_ID.o swad_indicator.o swad_info.o swad_institution.o \
swad_language.o swad_layout.o swad_link.o swad_logo.o \
swad_language.o swad_layout.o swad_link.o swad_log.o swad_logo.o \
swad_mail.o swad_main.o swad_mark.o swad_match.o swad_match_result.o \
swad_media.o swad_menu.o swad_message.o swad_MFU.o \
swad_network.o swad_nickname.o swad_notice.o swad_notification.o \

View File

@ -53,6 +53,7 @@
#include "swad_ID.h"
#include "swad_indicator.h"
#include "swad_language.h"
#include "swad_log.h"
#include "swad_mail.h"
#include "swad_mark.h"
#include "swad_match.h"
@ -3138,7 +3139,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
[ActSeeAccCrs ] = { 119,-1,TabUnk,ActReqAccGbl ,0x230,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Sta_SeeCrsAccesses ,NULL},
[ActSeeAllStaCrs ] = { 768,-1,TabUnk,ActReqAccGbl ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Ind_ShowIndicatorsCourses ,NULL},
[ActLstClk ] = { 989,-1,TabUnk,ActReqAccGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Sta_ShowLastClicks ,NULL},
[ActLstClk ] = { 989,-1,TabUnk,ActReqAccGbl ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Log_ShowLastClicks ,NULL},
[ActRefLstClk ] = { 994,-1,TabUnk,ActRefLstClk ,0x3F8,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,0x3C7,Act_CONT_NORM,Act_AJAX_RFRESH,NULL ,Lay_RefreshLastClicks ,NULL},
[ActSeeMyUsgRep ] = {1582,-1,TabUnk,ActReqMyUsgRep ,0x3F8,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,0x3C6,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Rep_ShowMyUsageReport ,NULL},

View File

@ -252,7 +252,7 @@ void Ctr_DrawCentreLogoAndNameWithLink (struct Centre *Ctr,Act_Action_t Action,
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
/***** Centre logo and name *****/
Log_DrawLogo (Hie_CTR,Ctr->CtrCod,Ctr->ShrtName,16,ClassLogo,true);
Lgo_DrawLogo (Hie_CTR,Ctr->CtrCod,Ctr->ShrtName,16,ClassLogo,true);
HTM_TxtF (" %s",Ctr->FullName);
/***** End link *****/
@ -343,7 +343,7 @@ static void Ctr_Configuration (bool PrintView)
" class=\"FRAME_TITLE_BIG\" title=\"%s\"",
Gbl.Hierarchy.Ctr.WWW,
Gbl.Hierarchy.Ctr.FullName);
Log_DrawLogo (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,
Lgo_DrawLogo (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,
Gbl.Hierarchy.Ctr.ShrtName,64,NULL,true);
HTM_BR ();
HTM_Txt (Gbl.Hierarchy.Ctr.FullName);
@ -697,7 +697,7 @@ static void Ctr_PutIconsCtrConfig (void)
// have permission to upload logo and photo of the centre
{
/***** Put icon to upload logo of centre *****/
Log_PutIconToChangeLogo (Hie_CTR);
Lgo_PutIconToChangeLogo (Hie_CTR);
/***** Put icon to upload photo of centre *****/
Ctr_PutIconToChangePhoto ();
@ -1500,7 +1500,7 @@ static void Ctr_ListCentresForEdition (void)
/* Centre logo */
HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ctr->FullName);
Log_DrawLogo (Hie_CTR,Ctr->CtrCod,Ctr->ShrtName,20,NULL,true);
Lgo_DrawLogo (Hie_CTR,Ctr->CtrCod,Ctr->ShrtName,20,NULL,true);
HTM_TD_End ();
/* Place */
@ -2244,7 +2244,7 @@ static void Ctr_PutParamGoToCtr (void)
void Ctr_RequestLogo (void)
{
Log_RequestLogo (Hie_CTR);
Lgo_RequestLogo (Hie_CTR);
}
/*****************************************************************************/
@ -2253,7 +2253,7 @@ void Ctr_RequestLogo (void)
void Ctr_ReceiveLogo (void)
{
Log_ReceiveLogo (Hie_CTR);
Lgo_ReceiveLogo (Hie_CTR);
}
/*****************************************************************************/
@ -2262,7 +2262,7 @@ void Ctr_ReceiveLogo (void)
void Ctr_RemoveLogo (void)
{
Log_RemoveLogo (Hie_CTR);
Lgo_RemoveLogo (Hie_CTR);
}
/*****************************************************************************/
@ -2488,7 +2488,7 @@ static void Ctr_PutFormToCreateCentre (void)
/***** Centre logo *****/
HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ctr_EditingCtr->FullName);
Log_DrawLogo (Hie_CTR,-1L,"",20,NULL,true);
Lgo_DrawLogo (Hie_CTR,-1L,"",20,NULL,true);
HTM_TD_End ();
/***** Place *****/

View File

@ -490,13 +490,14 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 19.91.2 (2019-12-14)"
#define Log_PLATFORM_VERSION "SWAD 19.92 (2019-12-14)"
#define CSS_FILE "swad19.90.1.css"
#define JS_FILE "swad19.91.1.js"
/*
// TODO: Hacer un nuevo rol en los TFG: tutor externo (profesor de áreas no vinculadas con el centro, profesionales de empresas, etc.)
// TODO: Impedir la creación y edición de proyectos si no son editables.
Version 19.92: Dec 14, 2019 New module for log database tables. (248625 lines)
Version 19.91.2: Dec 14, 2019 Code refactoring related to doubles. (248538 lines)
Version 19.91.1: Dec 14, 2019 Changes in match layout. (248533 lines)
Version 19.91: Dec 13, 2019 Changes in match countdown.

View File

@ -190,7 +190,7 @@ void Cht_ShowListOfAvailableChatRooms (void)
"%s %s",
Txt_Degree,Deg.ShrtName);
Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShrtName,ThisRoomFullName,1,IsLastItemInLevel);
Log_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true);
Lgo_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true);
Cht_WriteLinkToChat2 (ThisRoomCode,ThisRoomFullName);
/* Get my courses in this degree from database */

View File

@ -37,6 +37,7 @@
#include "swad_global.h"
#include "swad_hierarchy.h"
#include "swad_HTML.h"
#include "swad_log.h"
#include "swad_parameter.h"
#include "swad_photo.h"
#include "swad_role.h"
@ -87,7 +88,7 @@ void Con_ShowConnectedUsrs (void)
if (Gbl.Usrs.Me.Logged)
{
Mnu_ContextMenuBegin ();
Sta_PutLinkToLastClicks (); // Show last clicks in real time
Log_PutLinkToLastClicks (); // Show last clicks in real time
Mnu_ContextMenuEnd ();
}

View File

@ -223,7 +223,7 @@ static void Crs_Configuration (bool PrintView)
" class=\"FRAME_TITLE_BIG\" title=\"%s\"",
Gbl.Hierarchy.Deg.WWW,
Gbl.Hierarchy.Deg.FullName);
Log_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Lgo_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Deg.ShrtName,64,NULL,true);
if (PutLink)
HTM_A_End ();
@ -638,7 +638,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Highlight ? ClassHighlight :
ClassNormal,
NULL);
Log_DrawLogo (Hie_INS,Ins.InsCod,Ins.ShrtName,16,NULL,true);
Lgo_DrawLogo (Hie_INS,Ins.InsCod,Ins.ShrtName,16,NULL,true);
HTM_TxtF (" %s",Ins.ShrtName);
HTM_BUTTON_End ();
Frm_EndForm ();
@ -672,7 +672,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Highlight ? ClassHighlight :
ClassNormal,
NULL);
Log_DrawLogo (Hie_CTR,Ctr.CtrCod,Ctr.ShrtName,16,NULL,true);
Lgo_DrawLogo (Hie_CTR,Ctr.CtrCod,Ctr.ShrtName,16,NULL,true);
HTM_TxtF (" %s",Ctr.ShrtName);
HTM_BUTTON_End ();
Frm_EndForm ();
@ -706,7 +706,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Highlight ? ClassHighlight :
ClassNormal,
NULL);
Log_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true);
Lgo_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,16,NULL,true);
HTM_TxtF (" %s",Deg.ShrtName);
HTM_BUTTON_End ();
Frm_EndForm ();
@ -3183,7 +3183,7 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA
Txt_Go_to_X,
row[2]);
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
Log_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,20,"CT",true);
Lgo_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,20,"CT",true);
HTM_TxtF (" %s (%s)",row[2],row[6]);
HTM_BUTTON_End ();
Frm_EndForm ();

View File

@ -256,7 +256,7 @@ void Deg_DrawDegreeLogoAndNameWithLink (struct Degree *Deg,Act_Action_t Action,
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
/***** Degree logo and name *****/
Log_DrawLogo (Hie_DEG,Deg->DegCod,Deg->ShrtName,16,ClassLogo,true);
Lgo_DrawLogo (Hie_DEG,Deg->DegCod,Deg->ShrtName,16,ClassLogo,true);
HTM_TxtF (" %s",Deg->FullName);
/***** End link *****/
@ -327,7 +327,7 @@ static void Deg_Configuration (bool PrintView)
" class=\"FRAME_TITLE_BIG\" title=\"%s\"",
Gbl.Hierarchy.Deg.WWW,
Gbl.Hierarchy.Deg.FullName);
Log_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Lgo_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Deg.ShrtName,64,NULL,true);
HTM_BR ();
HTM_Txt (Gbl.Hierarchy.Deg.FullName);
@ -549,7 +549,7 @@ static void Deg_PutIconsToPrintAndUpload (void)
// Only degree admins, centre admins, institution admins and system admins
// have permission to upload logo of the degree
/***** Link to upload logo of degree *****/
Log_PutIconToChangeLogo (Hie_DEG);
Lgo_PutIconToChangeLogo (Hie_DEG);
}
/*****************************************************************************/
@ -725,7 +725,7 @@ static void Deg_ListDegreesForEdition (void)
/* Degree logo */
HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Deg->FullName);
Log_DrawLogo (Hie_DEG,Deg->DegCod,Deg->ShrtName,20,NULL,true);
Lgo_DrawLogo (Hie_DEG,Deg->DegCod,Deg->ShrtName,20,NULL,true);
HTM_TD_End ();
/* Degree short name */
@ -943,7 +943,7 @@ static void Deg_PutFormToCreateDegree (void)
/***** Degree logo *****/
HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Deg_EditingDeg->FullName);
Log_DrawLogo (Hie_DEG,-1L,"",20,NULL,true);
Lgo_DrawLogo (Hie_DEG,-1L,"",20,NULL,true);
HTM_TD_End ();
/***** Degree short name *****/
@ -2286,7 +2286,7 @@ static void Deg_PutParamGoToDeg (void)
void Deg_RequestLogo (void)
{
Log_RequestLogo (Hie_DEG);
Lgo_RequestLogo (Hie_DEG);
}
/*****************************************************************************/
@ -2295,7 +2295,7 @@ void Deg_RequestLogo (void)
void Deg_ReceiveLogo (void)
{
Log_ReceiveLogo (Hie_DEG);
Lgo_ReceiveLogo (Hie_DEG);
}
/*****************************************************************************/
@ -2304,7 +2304,7 @@ void Deg_ReceiveLogo (void)
void Deg_RemoveLogo (void)
{
Log_RemoveLogo (Hie_DEG);
Lgo_RemoveLogo (Hie_DEG);
}
/*****************************************************************************/

View File

@ -1047,7 +1047,7 @@ static void Exa_ShowExamAnnouncement (long ExaCod,
else
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"%s\"",
Ins.WWW,StyleTitle);
Log_DrawLogo (Hie_INS,Ins.InsCod,Ins.FullName,64,NULL,true);
Lgo_DrawLogo (Hie_INS,Ins.InsCod,Ins.FullName,64,NULL,true);
HTM_BR ();
HTM_Txt (Ins.FullName);
if (TypeViewExamAnnouncement == Exa_PRINT_VIEW)

View File

@ -1476,7 +1476,7 @@ static void Fig_ShowInss (MYSQL_RES **mysql_res,unsigned NumInss,
HTM_BUTTON_SUBMIT_Begin (Ins.ShrtName,The_ClassFormLinkInBox[Gbl.Prefs.Theme],NULL);
if (Gbl.Usrs.Listing.WithPhotos)
{
Log_DrawLogo (Hie_INS,Ins.InsCod,Ins.ShrtName,
Lgo_DrawLogo (Hie_INS,Ins.InsCod,Ins.ShrtName,
40,NULL,true);
HTM_NBSP ();
}

View File

@ -11959,7 +11959,7 @@ static void Brw_WriteRowDocData (unsigned long *NumDocsNotHidden,MYSQL_ROW row)
Txt_Go_to_X,
InsShortName);
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK LT DAT",NULL);
Log_DrawLogo (Hie_INS,InsCod,InsShortName,20,"BT_LINK LT",true);
Lgo_DrawLogo (Hie_INS,InsCod,InsShortName,20,"BT_LINK LT",true);
HTM_TxtF (" %s",InsShortName);
HTM_BUTTON_End ();
Frm_EndForm ();
@ -11976,7 +11976,7 @@ static void Brw_WriteRowDocData (unsigned long *NumDocsNotHidden,MYSQL_ROW row)
Txt_Go_to_X,
CtrShortName);
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK LT DAT",NULL);
Log_DrawLogo (Hie_CTR,CtrCod,CtrShortName,20,"LT",true);
Lgo_DrawLogo (Hie_CTR,CtrCod,CtrShortName,20,"LT",true);
HTM_TxtF (" %s",CtrShortName);
HTM_BUTTON_End ();
Frm_EndForm ();
@ -11993,7 +11993,7 @@ static void Brw_WriteRowDocData (unsigned long *NumDocsNotHidden,MYSQL_ROW row)
Txt_Go_to_X,
DegShortName);
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK LT DAT",NULL);
Log_DrawLogo (Hie_DEG,DegCod,DegShortName,20,"LT",true);
Lgo_DrawLogo (Hie_DEG,DegCod,DegShortName,20,"LT",true);
HTM_TxtF (" %s",DegShortName);
HTM_BUTTON_End ();
Frm_EndForm ();

View File

@ -2084,15 +2084,15 @@ static void For_WriteLinkToForum (struct Forum *Forum,
break;
case For_FORUM_INSTIT_USRS:
case For_FORUM_INSTIT_TCHS:
Log_DrawLogo (Hie_INS,Forum->Location,ForumName,16,NULL,true);
Lgo_DrawLogo (Hie_INS,Forum->Location,ForumName,16,NULL,true);
break;
case For_FORUM_CENTRE_USRS:
case For_FORUM_CENTRE_TCHS:
Log_DrawLogo (Hie_CTR,Forum->Location,ForumName,16,NULL,true);
Lgo_DrawLogo (Hie_CTR,Forum->Location,ForumName,16,NULL,true);
break;
case For_FORUM_DEGREE_USRS:
case For_FORUM_DEGREE_TCHS:
Log_DrawLogo (Hie_DEG,Forum->Location,ForumName,16,NULL,true);
Lgo_DrawLogo (Hie_DEG,Forum->Location,ForumName,16,NULL,true);
break;
case For_FORUM_COURSE_USRS:
case For_FORUM_COURSE_TCHS:

View File

@ -439,16 +439,16 @@ void Hie_WriteBigNameCtyInsCtrDegCrs (void)
Cty_DrawCountryMap (&Gbl.Hierarchy.Cty,"COUNTRY_MAP_TITLE");
break;
case Hie_INS: // Institution
Log_DrawLogo (Hie_INS,Gbl.Hierarchy.Ins.InsCod,
Lgo_DrawLogo (Hie_INS,Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ins.ShrtName,40,"TOP_LOGO",false);
break;
case Hie_CTR: // Centre
Log_DrawLogo (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,
Lgo_DrawLogo (Hie_CTR,Gbl.Hierarchy.Ctr.CtrCod,
Gbl.Hierarchy.Ctr.ShrtName,40,"TOP_LOGO",false);
break;
case Hie_DEG: // Degree
case Hie_CRS: // Course
Log_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Lgo_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Deg.ShrtName,40,"TOP_LOGO",false);
break;
default:

View File

@ -237,7 +237,7 @@ void Ins_DrawInstitutionLogoWithLink (struct Instit *Ins,unsigned Size)
Ins_PutParamInsCod (Ins->InsCod);
HTM_BUTTON_SUBMIT_Begin (Ins->FullName,"BT_LINK",NULL);
}
Log_DrawLogo (Hie_INS,Ins->InsCod,Ins->FullName,
Lgo_DrawLogo (Hie_INS,Ins->InsCod,Ins->FullName,
Size,NULL,true);
if (PutLink)
{
@ -266,7 +266,7 @@ void Ins_DrawInstitutionLogoAndNameWithLink (struct Instit *Ins,Act_Action_t Act
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,ClassLink,NULL);
/***** Institution logo and name *****/
Log_DrawLogo (Hie_INS,Ins->InsCod,Ins->ShrtName,16,ClassLogo,true);
Lgo_DrawLogo (Hie_INS,Ins->InsCod,Ins->ShrtName,16,ClassLogo,true);
HTM_TxtF (" %s",Ins->FullName);
/***** End link *****/
@ -340,7 +340,7 @@ static void Ins_Configuration (bool PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"FRAME_TITLE_BIG\" title=\"%s\"",
Gbl.Hierarchy.Ins.WWW,
Gbl.Hierarchy.Ins.FullName);
Log_DrawLogo (Hie_INS,Gbl.Hierarchy.Ins.InsCod,
Lgo_DrawLogo (Hie_INS,Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ins.ShrtName,64,NULL,true);
HTM_BR ();
HTM_Txt (Gbl.Hierarchy.Ins.FullName);
@ -613,7 +613,7 @@ static void Ins_PutIconsToPrintAndUpload (void)
if (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM)
/***** Icon to upload logo of institution *****/
Log_PutIconToChangeLogo (Hie_INS);
Lgo_PutIconToChangeLogo (Hie_INS);
/***** Put icon to view places *****/
Plc_PutIconToViewPlaces ();
@ -1475,7 +1475,7 @@ static void Ins_ListInstitutionsForEdition (void)
/* Institution logo */
HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ins->FullName);
Log_DrawLogo (Hie_INS,Ins->InsCod,Ins->ShrtName,20,NULL,true);
Lgo_DrawLogo (Hie_INS,Ins->InsCod,Ins->ShrtName,20,NULL,true);
HTM_TD_End ();
/* Institution short name */
@ -2141,7 +2141,7 @@ static void Ins_PutParamGoToIns (void)
void Ins_RequestLogo (void)
{
Log_RequestLogo (Hie_INS);
Lgo_RequestLogo (Hie_INS);
}
/*****************************************************************************/
@ -2150,7 +2150,7 @@ void Ins_RequestLogo (void)
void Ins_ReceiveLogo (void)
{
Log_ReceiveLogo (Hie_INS);
Lgo_ReceiveLogo (Hie_INS);
}
/*****************************************************************************/
@ -2159,7 +2159,7 @@ void Ins_ReceiveLogo (void)
void Ins_RemoveLogo (void)
{
Log_RemoveLogo (Hie_INS);
Lgo_RemoveLogo (Hie_INS);
}
/*****************************************************************************/
@ -2198,7 +2198,7 @@ static void Ins_PutFormToCreateInstitution (void)
/***** Institution logo *****/
HTM_TD_Begin ("title=\"%s\" class=\"HIE_LOGO\"",Ins_EditingIns->FullName);
Log_DrawLogo (Hie_INS,-1L,"",20,NULL,true);
Lgo_DrawLogo (Hie_INS,-1L,"",20,NULL,true);
HTM_TD_End ();
/***** Institution short name *****/

View File

@ -46,6 +46,7 @@
#include "swad_hierarchy.h"
#include "swad_HTML.h"
#include "swad_language.h"
#include "swad_log.h"
#include "swad_logo.h"
#include "swad_MFU.h"
#include "swad_notice.h"
@ -1337,7 +1338,7 @@ void Lay_ShowErrorAndExit (const char *Txt)
{
/***** Log access *****/
Gbl.TimeSendInMicroseconds = 0L;
Sta_LogAccess (Txt);
Log_LogAccess (Txt);
}
else
{
@ -1354,7 +1355,7 @@ void Lay_ShowErrorAndExit (const char *Txt)
Sta_ComputeTimeToSendPage ();
/***** Log access *****/
Sta_LogAccess (Txt);
Log_LogAccess (Txt);
/***** Update last data for next time *****/
if (Gbl.Usrs.Me.Logged)
@ -1463,7 +1464,7 @@ void Lay_RefreshNotifsAndConnected (void)
else if (!(Gbl.PID % 103))
Set_RemoveOldSettingsFromIP (); // Remove old settings from IP
else if (!(Gbl.PID % 107))
Sta_RemoveOldEntriesRecentLog (); // Remove old entries in recent log table, it's a slow query
Log_RemoveOldEntriesRecentLog (); // Remove old entries in recent log table, it's a slow query
else if (!(Gbl.PID % 109))
Fil_RemoveOldTmpFiles (Cfg_PATH_OUT_PRIVATE ,Cfg_TIME_TO_DELETE_HTML_OUTPUT ,false);
else if (!(Gbl.PID % 113))
@ -1514,7 +1515,7 @@ void Lay_RefreshLastClicks (void)
HTM_TxtF ("%lu|",Cfg_TIME_TO_REFRESH_LAST_CLICKS);
/***** Get and show last clicks *****/
Sta_GetAndShowLastClicks ();
Log_GetAndShowLastClicks ();
}
}
@ -1572,7 +1573,7 @@ void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto,
{
if (!PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",Ins.WWW);
Log_DrawLogo (Hie_INS,Ins.InsCod,Ins.ShrtName,40,NULL,true);
Lgo_DrawLogo (Hie_INS,Ins.InsCod,Ins.ShrtName,40,NULL,true);
if (!PrintView)
HTM_A_End ();
}
@ -1619,7 +1620,7 @@ void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto,
if (!PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"CLASSPHOTO_TITLE\"",
Deg.WWW);
Log_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,40,NULL,true);
Lgo_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,40,NULL,true);
if (!PrintView)
HTM_A_End ();
}

357
swad_log.c Normal file
View File

@ -0,0 +1,357 @@
// swad_log.c: access log stored in database
/*
SWAD (Shared Workspace At a Distance),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2019 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/*********************************** Headers *********************************/
/*****************************************************************************/
#include "swad_action.h"
#include "swad_config.h"
#include "swad_database.h"
#include "swad_global.h"
#include "swad_HTML.h"
#include "swad_log.h"
#include "swad_profile.h"
#include "swad_role.h"
#include "swad_statistic.h"
/*****************************************************************************/
/****************************** Public constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
#define Log_SECONDS_IN_RECENT_LOG ((time_t) (Cfg_DAYS_IN_RECENT_LOG * 24UL * 60UL * 60UL)) // Remove entries in recent log oldest than this time
/*****************************************************************************/
/****************************** Private types ********************************/
/*****************************************************************************/
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
extern struct Globals Gbl;
/*****************************************************************************/
/************************* Private global variables **************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
/*****************************************************************************/
/**************************** Log access in database *************************/
/*****************************************************************************/
void Log_LogAccess (const char *Comments)
{
long LogCod;
long ActCod = Act_GetActCod (Gbl.Action.Act);
Rol_Role_t RoleToStore = (Gbl.Action.Act == ActLogOut) ? Gbl.Usrs.Me.Role.LoggedBeforeCloseSession :
Gbl.Usrs.Me.Role.Logged;
/***** Insert access into database *****/
/* Log access in historical log (log_full) */
LogCod =
DB_QueryINSERTandReturnCode ("can not log access (full)",
"INSERT INTO log_full "
"(ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod,"
"Role,ClickTime,TimeToGenerate,TimeToSend,IP)"
" VALUES "
"(%ld,%ld,%ld,%ld,%ld,%ld,%ld,"
"%u,NOW(),%ld,%ld,'%s')",
ActCod,
Gbl.Hierarchy.Cty.CtyCod,
Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ctr.CtrCod,
Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) RoleToStore,
Gbl.TimeGenerationInMicroseconds,
Gbl.TimeSendInMicroseconds,
Gbl.IP);
/* Log access in recent log (log_recent) */
DB_QueryINSERT ("can not log access (recent)",
"INSERT INTO log_recent "
"(LogCod,ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod,"
"Role,ClickTime,TimeToGenerate,TimeToSend,IP)"
" VALUES "
"(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,"
"%u,NOW(),%ld,%ld,'%s')",
LogCod,ActCod,
Gbl.Hierarchy.Cty.CtyCod,
Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ctr.CtrCod,
Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) RoleToStore,
Gbl.TimeGenerationInMicroseconds,
Gbl.TimeSendInMicroseconds,
Gbl.IP);
/* Log comments */
if (Comments)
DB_QueryINSERT ("can not log access (comments)",
"INSERT INTO log_comments"
" (LogCod,Comments)"
" VALUES"
" (%ld,'%s')",
LogCod,Comments);
/* Log search string */
if (Gbl.Search.LogSearch && Gbl.Search.Str[0])
DB_QueryINSERT ("can not log access (search)",
"INSERT INTO log_search"
" (LogCod,SearchStr)"
" VALUES"
" (%ld,'%s')",
LogCod,Gbl.Search.Str);
if (Gbl.WebService.IsWebService)
/* Log web service plugin and function */
DB_QueryINSERT ("can not log access (comments)",
"INSERT INTO log_ws"
" (LogCod,PlgCod,FunCod)"
" VALUES"
" (%ld,%ld,%u)",
LogCod,Gbl.WebService.PlgCod,
(unsigned) Gbl.WebService.Function);
else if (Gbl.Banners.BanCodClicked > 0)
/* Log banner clicked */
DB_QueryINSERT ("can not log banner clicked",
"INSERT INTO log_banners"
" (LogCod,BanCod)"
" VALUES"
" (%ld,%ld)",
LogCod,Gbl.Banners.BanCodClicked);
/***** Increment my number of clicks *****/
if (Gbl.Usrs.Me.Logged)
Prf_IncrementNumClicksUsr (Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/
/************ Sometimes, we delete old entries in recent log table ***********/
/*****************************************************************************/
void Log_RemoveOldEntriesRecentLog (void)
{
/***** Remove all expired clipboards *****/
DB_QueryDELETE ("can not remove old entries from recent log",
"DELETE LOW_PRIORITY FROM log_recent"
" WHERE ClickTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
Log_SECONDS_IN_RECENT_LOG);
}
/*****************************************************************************/
/*************** Put a link to show last clicks in real time *****************/
/*****************************************************************************/
void Log_PutLinkToLastClicks (void)
{
extern const char *Txt_Last_clicks;
Lay_PutContextualLinkIconText (ActLstClk,NULL,NULL,
"mouse-pointer.svg",
Txt_Last_clicks);
}
/*****************************************************************************/
/****************************** Show last clicks *****************************/
/*****************************************************************************/
void Log_ShowLastClicks (void)
{
extern const char *Hlp_USERS_Connected_last_clicks;
extern const char *Txt_Last_clicks_in_real_time;
/***** Contextual menu *****/
Mnu_ContextMenuBegin ();
Sta_PutLinkToGlobalHits (); // Global hits
Sta_PutLinkToCourseHits (); // Course hits
Mnu_ContextMenuEnd ();
/***** Begin box *****/
Box_BoxBegin (NULL,Txt_Last_clicks_in_real_time,NULL,
Hlp_USERS_Connected_last_clicks,Box_NOT_CLOSABLE);
/***** Get and show last clicks *****/
HTM_DIV_Begin ("id=\"lastclicks\" class=\"CM\""); // Used for AJAX based refresh
Log_GetAndShowLastClicks ();
HTM_DIV_End (); // Used for AJAX based refresh
/***** End box *****/
Box_BoxEnd ();
}
/*****************************************************************************/
/**************** Get last clicks from database and show them ****************/
/*****************************************************************************/
void Log_GetAndShowLastClicks (void)
{
extern const char *Txt_Click;
extern const char *Txt_ELAPSED_TIME;
extern const char *Txt_Role;
extern const char *Txt_Country;
extern const char *Txt_Institution;
extern const char *Txt_Centre;
extern const char *Txt_Degree;
extern const char *Txt_Action;
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow;
unsigned long NumRows;
long ActCod;
const char *ClassRow;
time_t TimeDiff;
struct Country Cty;
struct Instit Ins;
struct Centre Ctr;
struct Degree Deg;
/***** Get last clicks from database *****/
/* Important for maximum performance:
do the LIMIT in the big log table before the JOIN */
NumRows = DB_QuerySELECT (&mysql_res,"can not get last clicks",
"SELECT last_logs.LogCod,last_logs.ActCod,"
"last_logs.Dif,last_logs.Role,"
"last_logs.CtyCod,last_logs.InsCod,"
"last_logs.CtrCod,last_logs.DegCod,"
"actions.Txt"
" FROM"
" (SELECT LogCod,ActCod,"
"UNIX_TIMESTAMP()-UNIX_TIMESTAMP(ClickTime) AS Dif,"
"Role,CtyCod,InsCod,CtrCod,DegCod"
" FROM log_recent ORDER BY LogCod DESC LIMIT 20)"
" AS last_logs LEFT JOIN actions" // LEFT JOIN because action may be not present in table of actions
" ON last_logs.ActCod=actions.ActCod"
" WHERE actions.Language='es'" // TODO: Change to user's language
" OR actions.Language IS NULL"); // When action is not present in table of actions
/***** Write list of connected users *****/
HTM_TABLE_BeginCenterPadding (1);
HTM_TR_Begin (NULL);
HTM_TH (1,1,"LC_CLK",Txt_Click); // Click
HTM_TH (1,1,"LC_TIM",Txt_ELAPSED_TIME); // Elapsed time
HTM_TH (1,1,"LC_ROL",Txt_Role); // Role
HTM_TH (1,1,"LC_CTY",Txt_Country); // Country
HTM_TH (1,1,"LC_INS",Txt_Institution); // Institution
HTM_TH (1,1,"LC_CTR",Txt_Centre); // Centre
HTM_TH (1,1,"LC_DEG",Txt_Degree); // Degree
HTM_TH (1,1,"LC_ACT",Txt_Action); // Action
HTM_TR_End ();
for (NumRow = 0;
NumRow < NumRows;
NumRow++)
{
row = mysql_fetch_row (mysql_res);
/* Get action code (row[1]) */
ActCod = Str_ConvertStrCodToLongCod (row[1]);
/* Use a special color for this row depending on the action */
ClassRow = (Act_GetBrowserTab (Act_GetActionFromActCod (ActCod)) == Act_DOWNLD_FILE) ? "DAT_SMALL_YELLOW" :
(ActCod == Act_GetActCod (ActLogIn ) ||
ActCod == Act_GetActCod (ActLogInNew)) ? "DAT_SMALL_GREEN" :
(ActCod == Act_GetActCod (ActLogOut )) ? "DAT_SMALL_RED" :
(ActCod == Act_GetActCod (ActWebSvc )) ? "DAT_SMALL_BLUE" :
"DAT_SMALL_GREY";
/* Compute elapsed time from last access */
if (sscanf (row[2],"%ld",&TimeDiff) != 1)
TimeDiff = (time_t) 0;
/* Get country code (row[4]) */
Cty.CtyCod = Str_ConvertStrCodToLongCod (row[4]);
Cty_GetCountryName (Cty.CtyCod,Cty.Name[Gbl.Prefs.Language]);
/* Get institution code (row[5]) */
Ins.InsCod = Str_ConvertStrCodToLongCod (row[5]);
Ins_GetShortNameOfInstitution (&Ins);
/* Get centre code (row[6]) */
Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[6]);
Ctr_GetShortNameOfCentreByCod (&Ctr);
/* Get degree code (row[7]) */
Deg.DegCod = Str_ConvertStrCodToLongCod (row[7]);
Deg_GetShortNameOfDegreeByCod (&Deg);
/* Print table row */
HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"LC_CLK %s\"",ClassRow);
HTM_Txt (row[0]); // Click
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_TIM %s\"",ClassRow); // Elapsed time
Dat_WriteHoursMinutesSecondsFromSeconds (TimeDiff);
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_ROL %s\"",ClassRow);
HTM_Txt ( // Role
Txt_ROLES_SINGUL_Abc[Rol_ConvertUnsignedStrToRole (row[3])][Usr_SEX_UNKNOWN]);
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_CTY %s\"",ClassRow);
HTM_Txt (Cty.Name[Gbl.Prefs.Language]); // Country
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_INS %s\"",ClassRow);
HTM_Txt (Ins.ShrtName); // Institution
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_CTR %s\"",ClassRow);
HTM_Txt (Ctr.ShrtName); // Centre
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_DEG %s\"",ClassRow);
HTM_Txt (Deg.ShrtName); // Degree
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_ACT %s\"",ClassRow);
if (row[8])
if (row[8][0])
HTM_Txt (row[8]); // Action
HTM_TD_End ();
HTM_TR_End ();
}
HTM_TABLE_End ();
/***** Free structure that stores the query result *****/
mysql_free_result (mysql_res);
}

49
swad_log.h Normal file
View File

@ -0,0 +1,49 @@
// swad_log.h: access log stored in database
#ifndef _SWAD_LOG
#define _SWAD_LOG
/*
SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2019 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Public constants ******************************/
/*****************************************************************************/
/*****************************************************************************/
/******************************* Public types ********************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
void Log_LogAccess (const char *Comments);
void Log_RemoveOldEntriesRecentLog (void);
void Log_PutLinkToLastClicks (void);
void Log_ShowLastClicks (void);
void Log_GetAndShowLastClicks (void);
#endif

View File

@ -68,7 +68,7 @@ extern struct Globals Gbl;
/****************************** Draw degree logo *****************************/
/*****************************************************************************/
void Log_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText,
void Lgo_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText,
unsigned Size,const char *Class,bool PutIconIfNotExists)
{
static const char *HieIcon[Hie_NUM_LEVELS] =
@ -195,7 +195,7 @@ void Log_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText,
/************* the logo of institution, centre or degree ***************/
/*****************************************************************************/
void Log_PutIconToChangeLogo (Hie_Level_t Scope)
void Lgo_PutIconToChangeLogo (Hie_Level_t Scope)
{
extern const char *Txt_Change_logo;
extern const char *Txt_Upload_logo;
@ -247,7 +247,7 @@ void Log_PutIconToChangeLogo (Hie_Level_t Scope)
/**** Show a form for sending a logo of the institution, centre or degree ****/
/*****************************************************************************/
void Log_RequestLogo (Hie_Level_t Scope)
void Lgo_RequestLogo (Hie_Level_t Scope)
{
extern const char *The_ClassFormInBox[The_NUM_THEMES];
extern const char *Txt_Remove_logo;
@ -330,7 +330,7 @@ void Log_RequestLogo (Hie_Level_t Scope)
/******* Receive the logo of the current institution, centre or degree *******/
/*****************************************************************************/
void Log_ReceiveLogo (Hie_Level_t Scope)
void Lgo_ReceiveLogo (Hie_Level_t Scope)
{
extern const char *Txt_The_file_is_not_X;
long Cod;
@ -416,7 +416,7 @@ void Log_ReceiveLogo (Hie_Level_t Scope)
/******* Remove the logo of the current institution, centre or degree ********/
/*****************************************************************************/
void Log_RemoveLogo (Hie_Level_t Scope)
void Lgo_RemoveLogo (Hie_Level_t Scope)
{
long Cod;
const char *Folder;

View File

@ -1,7 +1,7 @@
// swad_logo.h: logo of institution, centre or degree
#ifndef _SWAD_LOG
#define _SWAD_LOG
#ifndef _SWAD_LGO
#define _SWAD_LGO
/*
SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain),
@ -39,11 +39,11 @@
/***************************** Public prototypes *****************************/
/*****************************************************************************/
void Log_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText,
void Lgo_DrawLogo (Hie_Level_t Scope,long Cod,const char *AltText,
unsigned Size,const char *Class,bool PutIconIfNotExists);
void Log_PutIconToChangeLogo (Hie_Level_t Scope);
void Log_RequestLogo (Hie_Level_t Scope);
void Log_ReceiveLogo (Hie_Level_t Scope);
void Log_RemoveLogo (Hie_Level_t Scope);
void Lgo_PutIconToChangeLogo (Hie_Level_t Scope);
void Lgo_RequestLogo (Hie_Level_t Scope);
void Lgo_ReceiveLogo (Hie_Level_t Scope);
void Lgo_RemoveLogo (Hie_Level_t Scope);
#endif

View File

@ -2266,7 +2266,7 @@ static void Pho_ShowOrPrintListDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint)
"BT_LINK DAT","CT");
else // Pho_DEGREES_PRINT
{
Log_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,20,"CT",true);
Lgo_DrawLogo (Hie_DEG,Deg.DegCod,Deg.ShrtName,20,"CT",true);
HTM_TxtF ("&nbsp;%s",Deg.FullName);
}
HTM_TD_End ();

View File

@ -1750,7 +1750,7 @@ static void Rec_ShowCrsRecord (Rec_CourseRecordViewType_t TypeOfView,
HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"LM\" style=\"width:%upx;\"",Rec_DEGREE_LOGO_SIZE);
Log_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Lgo_DrawLogo (Hie_DEG,Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Deg.ShrtName,Rec_DEGREE_LOGO_SIZE,NULL,true);
HTM_TD_End ();
@ -2699,7 +2699,7 @@ static void Rec_ShowInstitutionInHead (struct Instit *Ins,bool PutFormLinks)
Ins_PutParamInsCod (Ins->InsCod);
HTM_BUTTON_SUBMIT_Begin (Ins->FullName,"BT_LINK",NULL);
}
Log_DrawLogo (Hie_INS,Ins->InsCod,Ins->ShrtName,
Lgo_DrawLogo (Hie_INS,Ins->InsCod,Ins->ShrtName,
Rec_INSTITUTION_LOGO_SIZE,NULL,true);
if (PutFormLinks)
{

View File

@ -37,6 +37,7 @@
#include "swad_global.h"
#include "swad_HTML.h"
#include "swad_ID.h"
#include "swad_log.h"
#include "swad_profile.h"
#include "swad_role.h"
#include "swad_statistic.h"
@ -51,8 +52,6 @@ extern struct Globals Gbl;
/***************************** Private constants *****************************/
/*****************************************************************************/
#define Sta_SECONDS_IN_RECENT_LOG ((time_t) (Cfg_DAYS_IN_RECENT_LOG * 24UL * 60UL * 60UL)) // Remove entries in recent log oldest than this time
static const unsigned Sta_CellPadding[Sta_NUM_CLICKS_GROUPED_BY] =
{
[Sta_CLICKS_CRS_DETAILED_LIST ] = 2,
@ -101,9 +100,6 @@ typedef enum
/***************************** Private prototypes ****************************/
/*****************************************************************************/
static void Sta_PutLinkToCourseHits (void);
static void Sta_PutLinkToGlobalHits (void);
static void Sta_WriteSelectorCountType (void);
static void Sta_WriteSelectorAction (void);
static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse);
@ -174,113 +170,6 @@ void Sta_GetRemoteAddr (void)
Gbl.IP[0] = '\0';
}
/*****************************************************************************/
/**************************** Log access in database *************************/
/*****************************************************************************/
void Sta_LogAccess (const char *Comments)
{
long LogCod;
long ActCod = Act_GetActCod (Gbl.Action.Act);
Rol_Role_t RoleToStore = (Gbl.Action.Act == ActLogOut) ? Gbl.Usrs.Me.Role.LoggedBeforeCloseSession :
Gbl.Usrs.Me.Role.Logged;
/***** Insert access into database *****/
/* Log access in historical log (log_full) */
LogCod =
DB_QueryINSERTandReturnCode ("can not log access (full)",
"INSERT INTO log_full "
"(ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod,"
"Role,ClickTime,TimeToGenerate,TimeToSend,IP)"
" VALUES "
"(%ld,%ld,%ld,%ld,%ld,%ld,%ld,"
"%u,NOW(),%ld,%ld,'%s')",
ActCod,
Gbl.Hierarchy.Cty.CtyCod,
Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ctr.CtrCod,
Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) RoleToStore,
Gbl.TimeGenerationInMicroseconds,
Gbl.TimeSendInMicroseconds,
Gbl.IP);
/* Log access in recent log (log_recent) */
DB_QueryINSERT ("can not log access (recent)",
"INSERT INTO log_recent "
"(LogCod,ActCod,CtyCod,InsCod,CtrCod,DegCod,CrsCod,UsrCod,"
"Role,ClickTime,TimeToGenerate,TimeToSend,IP)"
" VALUES "
"(%ld,%ld,%ld,%ld,%ld,%ld,%ld,%ld,"
"%u,NOW(),%ld,%ld,'%s')",
LogCod,ActCod,
Gbl.Hierarchy.Cty.CtyCod,
Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ctr.CtrCod,
Gbl.Hierarchy.Deg.DegCod,
Gbl.Hierarchy.Crs.CrsCod,
Gbl.Usrs.Me.UsrDat.UsrCod,
(unsigned) RoleToStore,
Gbl.TimeGenerationInMicroseconds,
Gbl.TimeSendInMicroseconds,
Gbl.IP);
/* Log comments */
if (Comments)
DB_QueryINSERT ("can not log access (comments)",
"INSERT INTO log_comments"
" (LogCod,Comments)"
" VALUES"
" (%ld,'%s')",
LogCod,Comments);
/* Log search string */
if (Gbl.Search.LogSearch && Gbl.Search.Str[0])
DB_QueryINSERT ("can not log access (search)",
"INSERT INTO log_search"
" (LogCod,SearchStr)"
" VALUES"
" (%ld,'%s')",
LogCod,Gbl.Search.Str);
if (Gbl.WebService.IsWebService)
/* Log web service plugin and function */
DB_QueryINSERT ("can not log access (comments)",
"INSERT INTO log_ws"
" (LogCod,PlgCod,FunCod)"
" VALUES"
" (%ld,%ld,%u)",
LogCod,Gbl.WebService.PlgCod,
(unsigned) Gbl.WebService.Function);
else if (Gbl.Banners.BanCodClicked > 0)
/* Log banner clicked */
DB_QueryINSERT ("can not log banner clicked",
"INSERT INTO log_banners"
" (LogCod,BanCod)"
" VALUES"
" (%ld,%ld)",
LogCod,Gbl.Banners.BanCodClicked);
/***** Increment my number of clicks *****/
if (Gbl.Usrs.Me.Logged)
Prf_IncrementNumClicksUsr (Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/
/************ Sometimes, we delete old entries in recent log table ***********/
/*****************************************************************************/
void Sta_RemoveOldEntriesRecentLog (void)
{
/***** Remove all expired clipboards *****/
DB_QueryDELETE ("can not remove old entries from recent log",
"DELETE LOW_PRIORITY FROM log_recent"
" WHERE ClickTime<FROM_UNIXTIME(UNIX_TIMESTAMP()-%lu)",
Sta_SECONDS_IN_RECENT_LOG);
}
/*****************************************************************************/
/******************** Show a form to make a query of clicks ******************/
/*****************************************************************************/
@ -321,7 +210,7 @@ void Sta_AskShowCrsHits (void)
/***** Contextual menu *****/
Mnu_ContextMenuBegin ();
Sta_PutLinkToGlobalHits (); // Global hits
Sta_PutLinkToLastClicks (); // Last clicks in real time
Log_PutLinkToLastClicks (); // Last clicks in real time
Mnu_ContextMenuEnd ();
/***** Get and update type of list,
@ -522,7 +411,7 @@ void Sta_AskShowGblHits (void)
/***** Contextual menu *****/
Mnu_ContextMenuBegin ();
Sta_PutLinkToCourseHits (); // Course hits
Sta_PutLinkToLastClicks (); // Last clicks in real time
Log_PutLinkToLastClicks (); // Last clicks in real time
Mnu_ContextMenuEnd ();
/***** Begin form *****/
@ -641,7 +530,7 @@ void Sta_AskShowGblHits (void)
/*************** Put a link to show visits to current course *****************/
/*****************************************************************************/
static void Sta_PutLinkToCourseHits (void)
void Sta_PutLinkToCourseHits (void)
{
extern const char *Txt_Visits_to_course;
@ -664,7 +553,7 @@ static void Sta_PutLinkToCourseHits (void)
/********************* Put a link to show global visits **********************/
/*****************************************************************************/
static void Sta_PutLinkToGlobalHits (void)
void Sta_PutLinkToGlobalHits (void)
{
extern const char *Txt_Global_visits;
@ -3957,189 +3846,3 @@ void Sta_WriteTime (char Str[Dat_MAX_BYTES_TIME],long TimeInMicroseconds)
TimeInMicroseconds / (60 * 1000000L),
(TimeInMicroseconds / 1000000L) % 60);
}
/*****************************************************************************/
/*************** Put a link to show last clicks in real time *****************/
/*****************************************************************************/
void Sta_PutLinkToLastClicks (void)
{
extern const char *Txt_Last_clicks;
Lay_PutContextualLinkIconText (ActLstClk,NULL,NULL,
"mouse-pointer.svg",
Txt_Last_clicks);
}
/*****************************************************************************/
/****************************** Show last clicks *****************************/
/*****************************************************************************/
void Sta_ShowLastClicks (void)
{
extern const char *Hlp_USERS_Connected_last_clicks;
extern const char *Txt_Last_clicks_in_real_time;
/***** Contextual menu *****/
Mnu_ContextMenuBegin ();
Sta_PutLinkToGlobalHits (); // Global hits
Sta_PutLinkToCourseHits (); // Course hits
Mnu_ContextMenuEnd ();
/***** Begin box *****/
Box_BoxBegin (NULL,Txt_Last_clicks_in_real_time,NULL,
Hlp_USERS_Connected_last_clicks,Box_NOT_CLOSABLE);
/***** Get and show last clicks *****/
HTM_DIV_Begin ("id=\"lastclicks\" class=\"CM\""); // Used for AJAX based refresh
Sta_GetAndShowLastClicks ();
HTM_DIV_End (); // Used for AJAX based refresh
/***** End box *****/
Box_BoxEnd ();
}
/*****************************************************************************/
/**************** Get last clicks from database and show them ****************/
/*****************************************************************************/
void Sta_GetAndShowLastClicks (void)
{
extern const char *Txt_Click;
extern const char *Txt_ELAPSED_TIME;
extern const char *Txt_Role;
extern const char *Txt_Country;
extern const char *Txt_Institution;
extern const char *Txt_Centre;
extern const char *Txt_Degree;
extern const char *Txt_Action;
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned long NumRow;
unsigned long NumRows;
long ActCod;
const char *ClassRow;
time_t TimeDiff;
struct Country Cty;
struct Instit Ins;
struct Centre Ctr;
struct Degree Deg;
/***** Get last clicks from database *****/
/* Important for maximum performance:
do the LIMIT in the big log table before the JOIN */
NumRows = DB_QuerySELECT (&mysql_res,"can not get last clicks",
"SELECT last_logs.LogCod,last_logs.ActCod,"
"last_logs.Dif,last_logs.Role,"
"last_logs.CtyCod,last_logs.InsCod,"
"last_logs.CtrCod,last_logs.DegCod,"
"actions.Txt"
" FROM"
" (SELECT LogCod,ActCod,"
"UNIX_TIMESTAMP()-UNIX_TIMESTAMP(ClickTime) AS Dif,"
"Role,CtyCod,InsCod,CtrCod,DegCod"
" FROM log_recent ORDER BY LogCod DESC LIMIT 20)"
" AS last_logs LEFT JOIN actions" // LEFT JOIN because action may be not present in table of actions
" ON last_logs.ActCod=actions.ActCod"
" WHERE actions.Language='es'" // TODO: Change to user's language
" OR actions.Language IS NULL"); // When action is not present in table of actions
/***** Write list of connected users *****/
HTM_TABLE_BeginCenterPadding (1);
HTM_TR_Begin (NULL);
HTM_TH (1,1,"LC_CLK",Txt_Click); // Click
HTM_TH (1,1,"LC_TIM",Txt_ELAPSED_TIME); // Elapsed time
HTM_TH (1,1,"LC_ROL",Txt_Role); // Role
HTM_TH (1,1,"LC_CTY",Txt_Country); // Country
HTM_TH (1,1,"LC_INS",Txt_Institution); // Institution
HTM_TH (1,1,"LC_CTR",Txt_Centre); // Centre
HTM_TH (1,1,"LC_DEG",Txt_Degree); // Degree
HTM_TH (1,1,"LC_ACT",Txt_Action); // Action
HTM_TR_End ();
for (NumRow = 0;
NumRow < NumRows;
NumRow++)
{
row = mysql_fetch_row (mysql_res);
/* Get action code (row[1]) */
ActCod = Str_ConvertStrCodToLongCod (row[1]);
/* Use a special color for this row depending on the action */
ClassRow = (Act_GetBrowserTab (Act_GetActionFromActCod (ActCod)) == Act_DOWNLD_FILE) ? "DAT_SMALL_YELLOW" :
(ActCod == Act_GetActCod (ActLogIn ) ||
ActCod == Act_GetActCod (ActLogInNew)) ? "DAT_SMALL_GREEN" :
(ActCod == Act_GetActCod (ActLogOut )) ? "DAT_SMALL_RED" :
(ActCod == Act_GetActCod (ActWebSvc )) ? "DAT_SMALL_BLUE" :
"DAT_SMALL_GREY";
/* Compute elapsed time from last access */
if (sscanf (row[2],"%ld",&TimeDiff) != 1)
TimeDiff = (time_t) 0;
/* Get country code (row[4]) */
Cty.CtyCod = Str_ConvertStrCodToLongCod (row[4]);
Cty_GetCountryName (Cty.CtyCod,Cty.Name[Gbl.Prefs.Language]);
/* Get institution code (row[5]) */
Ins.InsCod = Str_ConvertStrCodToLongCod (row[5]);
Ins_GetShortNameOfInstitution (&Ins);
/* Get centre code (row[6]) */
Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[6]);
Ctr_GetShortNameOfCentreByCod (&Ctr);
/* Get degree code (row[7]) */
Deg.DegCod = Str_ConvertStrCodToLongCod (row[7]);
Deg_GetShortNameOfDegreeByCod (&Deg);
/* Print table row */
HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"LC_CLK %s\"",ClassRow);
HTM_Txt (row[0]); // Click
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_TIM %s\"",ClassRow); // Elapsed time
Dat_WriteHoursMinutesSecondsFromSeconds (TimeDiff);
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_ROL %s\"",ClassRow);
HTM_Txt ( // Role
Txt_ROLES_SINGUL_Abc[Rol_ConvertUnsignedStrToRole (row[3])][Usr_SEX_UNKNOWN]);
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_CTY %s\"",ClassRow);
HTM_Txt (Cty.Name[Gbl.Prefs.Language]); // Country
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_INS %s\"",ClassRow);
HTM_Txt (Ins.ShrtName); // Institution
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_CTR %s\"",ClassRow);
HTM_Txt (Ctr.ShrtName); // Centre
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_DEG %s\"",ClassRow);
HTM_Txt (Deg.ShrtName); // Degree
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_ACT %s\"",ClassRow);
if (row[8])
if (row[8][0])
HTM_Txt (row[8]); // Action
HTM_TD_End ();
HTM_TR_End ();
}
HTM_TABLE_End ();
/***** Free structure that stores the query result *****/
mysql_free_result (mysql_res);
}

View File

@ -131,10 +131,10 @@ struct Sta_Hits
/*****************************************************************************/
void Sta_GetRemoteAddr (void);
void Sta_LogAccess (const char *Comments);
void Sta_RemoveOldEntriesRecentLog (void);
void Sta_AskShowCrsHits (void);
void Sta_AskShowGblHits (void);
void Sta_PutLinkToCourseHits (void);
void Sta_PutLinkToGlobalHits (void);
void Sta_SetIniEndDates (void);
void Sta_SeeGblAccesses (void);
void Sta_SeeCrsAccesses (void);
@ -149,8 +149,4 @@ void Sta_ComputeTimeToSendPage (void);
void Sta_WriteTimeToGenerateAndSendPage (void);
void Sta_WriteTime (char Str[Dat_MAX_BYTES_TIME],long TimeInMicroseconds);
void Sta_PutLinkToLastClicks (void);
void Sta_ShowLastClicks (void);
void Sta_GetAndShowLastClicks (void);
#endif