diff --git a/icon/report64x64.png b/icon/report64x64.png new file mode 100644 index 000000000..364e2edfe Binary files /dev/null and b/icon/report64x64.png differ diff --git a/swad_changelog.h b/swad_changelog.h index 618324bf5..a1f2ef849 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -143,13 +143,16 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.11.3 (2016-10-04)" +#define Log_PLATFORM_VERSION "SWAD 16.12 (2016-10-04)" #define CSS_FILE "swad15.229.css" #define JS_FILE "swad15.238.1.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 16.12: Oct 04, 2016 Code refactoring in user's usage report. (205882 lines) +Copy icon/report64x64.png to icon directory + Version 16.11.3: Oct 04, 2016 Code refactoring in user's usage report. (205834 lines) Version 16.11.2: Oct 04, 2016 Code refactoring in user's usage report. (205829 lines) Version 16.11.1: Oct 04, 2016 Code refactoring in user's usage report. (205824 lines) diff --git a/swad_config.h b/swad_config.h index f80c0d746..213dfc167 100644 --- a/swad_config.h +++ b/swad_config.h @@ -398,9 +398,6 @@ /* Folder for temporary XML files received to import test questions, inside private swad directory */ #define Cfg_FOLDER_TEST "test" // Created automatically the first time it is accessed -/* Folder for reports, inside private swad directory */ -#define Cfg_FOLDER_REP "rep" // Created automatically the first time it is accessed - /* Folder for compression of assignments and works into a zip files, inside private swad directory */ #define Cfg_FOLDER_ZIP "zip" // Created automatically the first time it is accessed @@ -414,6 +411,9 @@ /* Folders for temporary users' photos inside photos directories */ #define Cfg_FOLDER_PHOTO_TMP "tmp" // Created automatically the first time it is accessed +/* Folder for reports, inside public swad directory */ +#define Cfg_FOLDER_REP "rep" // Created automatically the first time it is accessed + /* Folder for banners, inside public swad directory */ #define Cfg_FOLDER_BANNER "banner" // If not exists, it should be created during installation inside swad public directory! diff --git a/swad_file_browser.c b/swad_file_browser.c index de606f1b7..0ef1005ba 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -1508,6 +1508,7 @@ static void Brw_PutIconNewFileOrFolder (void); static void Brw_PutIconFileWithLinkToViewMetadata (unsigned Size, struct FileMetadata *FileMetadata, const char *FileNameToShow); +static void Brw_PutIconFile (unsigned Size,Brw_FileType_t FileType,const char *FileName); static void Brw_WriteFileName (unsigned Level,bool IsPublic,Brw_FileType_t FileType, const char *PathInTree,const char *FileName,const char *FileNameToShow); static void Brw_GetFileNameToShow (Brw_FileBrowser_t FileBrowser,unsigned Level,Brw_FileType_t FileType, @@ -5859,7 +5860,7 @@ static void Brw_PutIconFileWithLinkToViewMetadata (unsigned Size, /***************************** Put icon of a file ****************************/ /*****************************************************************************/ -void Brw_PutIconFile (unsigned Size,Brw_FileType_t FileType,const char *FileName) +static void Brw_PutIconFile (unsigned Size,Brw_FileType_t FileType,const char *FileName) { extern const char *Txt_Link; extern const char *Txt_X_file; @@ -9879,7 +9880,7 @@ static void Brw_WriteBigLinkToDownloadFile (const char *URL, fprintf (Gbl.F.Out," %s " "\"%s\"" + " class=\"ICON40x40\" />" "", FileNameToShow, Gbl.Prefs.IconsURL, diff --git a/swad_file_browser.h b/swad_file_browser.h index 4a73643a2..1785a79cc 100644 --- a/swad_file_browser.h +++ b/swad_file_browser.h @@ -222,8 +222,6 @@ void Brw_CalcSizeOfDir (char *Path); void Brw_SetFullPathInTree (const char *PathInTreeUntilFileOrFolder,const char *FilFolLnkName); -void Brw_PutIconFile (unsigned Size,Brw_FileType_t FileType,const char *FileName); - void Brw_CreateTmpPublicLinkToPrivateFile (const char *FullPathIncludingFile, const char *FileName); diff --git a/swad_report.c b/swad_report.c index 9d24f181f..0c00607b9 100644 --- a/swad_report.c +++ b/swad_report.c @@ -25,6 +25,8 @@ /*********************************** Headers *********************************/ /*****************************************************************************/ +#include // For mkdir +#include // For mkdir #include // For unlink #include "swad_database.h" @@ -179,6 +181,7 @@ static void Rep_CreateMyUsageReport (struct CurrentTimeUTC *CurrentTimeUTC, extern const char *Txt_Report; struct UsrFigures UsrFigures; char PathReports[PATH_MAX+1]; + char PathDirReport[PATH_MAX+1]; char PathFileReport[PATH_MAX+1]; struct tm tm_FirstClickTime; bool GetUsrFiguresAgain; @@ -189,20 +192,36 @@ static void Rep_CreateMyUsageReport (struct CurrentTimeUTC *CurrentTimeUTC, CurrentTimeUTC->StrTime); /***** Path for reports *****/ - sprintf (PathReports,"%s/%s",Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_REP); + sprintf (PathReports,"%s/%s", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_REP); Fil_CreateDirIfNotExists (PathReports); - /***** Create a new empty syllabus *****/ - /* Path of the private directory for the file with the report */ - sprintf (PathFileReport,"%s/%s.html", - PathReports,Gbl.UniqueNameEncrypted); - sprintf (Permalink,"%s/%s/%s.html", - Cfg_URL_SWAD_PUBLIC, - Cfg_FOLDER_REP, - Gbl.UniqueNameEncrypted); + /***** Create a new report directory *****/ + /* Path of the public directory for the file with the report */ + sprintf (PathReports,"%s/%s/%c%c", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_REP, + Gbl.UniqueNameEncrypted[0], + Gbl.UniqueNameEncrypted[1]); + Fil_CreateDirIfNotExists (PathReports); + sprintf (PathDirReport,"%s/%s", + PathReports, + &Gbl.UniqueNameEncrypted[2]); + if (mkdir (PathDirReport,(mode_t) 0xFFF)) + Lay_ShowErrorAndExit ("Can not create directory for report."); + + /* Path of the public file with the report */ + sprintf (PathFileReport,"%s/index.html",PathDirReport); if ((Gbl.F.Rep = fopen (PathFileReport,"wb")) == NULL) Lay_ShowErrorAndExit ("Can not create report file."); + /* Permalink */ + sprintf (Permalink,"%s/%s/%c%c/%s/", + Cfg_URL_SWAD_PUBLIC, + Cfg_FOLDER_REP, + Gbl.UniqueNameEncrypted[0], + Gbl.UniqueNameEncrypted[1], + &Gbl.UniqueNameEncrypted[2]); + /***** Start file *****/ Lay_StartHTMLFile (Gbl.F.Rep,Txt_Report); fprintf (Gbl.F.Rep,""); - fprintf (Gbl.F.Out,"", - Permalink, - Txt_Report); - Brw_PutIconFile (32,Brw_IS_FILE,Permalink); - fprintf (Gbl.F.Out," %s " - "\"%s\"" + fprintf (Gbl.F.Out,"", Permalink, - Gbl.Prefs.IconsURL, - Txt_Download,Txt_Download); + Txt_Report, + Gbl.Prefs.IconsURL, + Txt_Report, + Permalink); /***** End frame *****/ Lay_EndRoundFrame (); @@ -306,22 +322,33 @@ static void Rep_WriteHeader (struct CurrentTimeUTC *CurrentTimeUTC, const char *Permalink) { extern const char *Txt_Report_of_use_of_PLATFORM; + extern const char *Txt_User[Usr_NUM_SEXS]; + extern const char *Txt_Date; + extern const char *Txt_Permalink; /***** Start of header *****/ fprintf (Gbl.F.Rep,"
"); /***** Main title *****/ sprintf (Gbl.Title,Txt_Report_of_use_of_PLATFORM,Cfg_PLATFORM_SHORT_NAME); - fprintf (Gbl.F.Rep,"

%s

",Gbl.Title); + fprintf (Gbl.F.Rep,"

%s

" + "
    ", + Gbl.Title); - /***** Subtitle *****/ - fprintf (Gbl.F.Rep,"

    %s",Gbl.Usrs.Me.UsrDat.FullName); - if (CurrentTimeUTC->StrDate[0]) - fprintf (Gbl.F.Rep,", %s",CurrentTimeUTC->StrDate); - fprintf (Gbl.F.Rep,"

    "); + /***** User *****/ + fprintf (Gbl.F.Rep,"
  • %s: %s
  • ", + Txt_User[Gbl.Usrs.Me.UsrDat.Sex], + Gbl.Usrs.Me.UsrDat.FullName); + + /***** Date-time *****/ + fprintf (Gbl.F.Rep,"
  • %s: %s %s UTC
  • ", + Txt_Date, + CurrentTimeUTC->StrDate, + CurrentTimeUTC->StrTime); /***** Permalink *****/ - fprintf (Gbl.F.Rep,"%s\n", + fprintf (Gbl.F.Rep,"
  • %s: %s
  • ", + Txt_Permalink, Permalink,Permalink); /***** End of header *****/ @@ -380,7 +407,7 @@ static void Rep_WriteSectionUsrInfo (void) Txt_Personal_information); /***** User's name *****/ - fprintf (Gbl.F.Rep,"
  • %s: %s
  • ", + fprintf (Gbl.F.Rep,"
  • %s: %s
  • ", Txt_Name, Gbl.Usrs.Me.UsrDat.FullName); @@ -458,7 +485,9 @@ static void Rep_WriteSectionUsrFigures (struct UsrFigures *UsrFigures, tm_FirstClickTime->tm_sec); // seconds if (CurrentTimeUTC->StrDate[0]) fprintf (Gbl.F.Rep," %s %s %s UTC", - Txt_TIME_until,CurrentTimeUTC->StrDate,CurrentTimeUTC->StrTime); + Txt_TIME_until, + CurrentTimeUTC->StrDate, + CurrentTimeUTC->StrTime); if (UsrFigures->NumDays > 0) fprintf (Gbl.F.Rep," (%d %s)", UsrFigures->NumDays, diff --git a/swad_text.c b/swad_text.c index de84a0999..7c2a87e66 100644 --- a/swad_text.c +++ b/swad_text.c @@ -27838,6 +27838,27 @@ const char *Txt_PERCENT_of_users = "% de utilizadores"; #endif +const char *Txt_Permalink = +#if L==1 + "Enllaç permanent"; +#elif L==2 + "Permalink"; +#elif L==3 + "Permalink"; +#elif L==4 + "Permalink"; +#elif L==5 + "Permalien"; +#elif L==6 + "Permalink"; // Okoteve traducción +#elif L==7 + "Permalink"; +#elif L==8 + "Odnośnik bezpośredni"; +#elif L==9 + "Ligação permanente"; +#endif + const char *Txt_Personal_information = #if L==1 "Dades personals";