diff --git a/swad_action.c b/swad_action.c index 1808f261f..ef19a8a89 100644 --- a/swad_action.c +++ b/swad_action.c @@ -2643,7 +2643,7 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActReqDatBrf */{1047,-1,TabPrf,ActAdmBrf ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_ShowFileMetadata ,NULL}, /* ActChgDatBrf */{1048,-1,TabPrf,ActAdmBrf ,0x1FC,0x1FC,0x1FC,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_ChgFileMetadata ,NULL}, /* ActDowBrf */{1123,-1,TabPrf,ActAdmBrf ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_DOWNLD_FILE,Brw_DownloadFile ,NULL ,NULL}, - /* ActAskRemOldBrf */{1488,-1,TabPrf,ActAdmBrf ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_ConfirmRemoveOldFiles ,NULL}, + /* ActAskRemOldBrf */{1488,-1,TabPrf,ActAdmBrf ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_AskRemoveOldFiles ,NULL}, /* ActRemOldBrf */{1489,-1,TabPrf,ActAdmBrf ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Brw_RemoveOldFiles ,NULL}, }; diff --git a/swad_changelog.h b/swad_changelog.h index 2bb78e7f6..d97744b04 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -118,12 +118,13 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.70.1 (2015/12/21)" +#define Log_PLATFORM_VERSION "SWAD 15.70.2 (2015/12/21)" #define CSS_FILE "swad15.65.1.css" // 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.70.2: Dec 21, 2015 Users can selected number of months in form to remove old files in briefcase. Not finished. (187473 lines) Version 15.70.1: Dec 21, 2015 Removing old files in briefcase. Not finished. (187408 lines) Version 15.70: Dec 21, 2015 New action to remove old files in briefcase. Not finished. (187352 lines) Version 15.69: Dec 20, 2015 New option in briefcase to ask for removing old files. (187270 lines) diff --git a/swad_config.h b/swad_config.h index b265b4a78..d3c3314f1 100644 --- a/swad_config.h +++ b/swad_config.h @@ -507,8 +507,6 @@ #define Cfg_TIME_TO_DELETE_BROWSER_CLIPBOARD ((time_t)( 15UL*60UL)) // Paths older than these seconds are removed from clipboard #define Cfg_TIME_TO_DELETE_BROWSER_ZIP_FILES ((time_t)( 2UL*60UL*60UL)) // Temporary zip files are deleted after these seconds -#define Cfg_MONTHS_TO_DELETE_OLD_BRIEFCASE_FILES 24 // Months to remove old files in briefcase - #define Cfg_TIME_TO_DELETE_MARKS_TMP_FILES ((time_t)( 2UL*60UL*60UL)) // Temporary files with students' marks are deleted after these seconds #define Cfg_TIME_TO_DELETE_PARAMS_TO_COMMANDS ((time_t)( 15UL*60UL)) // Temporary files with params to commands are deleted after these seconds diff --git a/swad_enrollment.c b/swad_enrollment.c index 2d211b6f1..3880aa926 100644 --- a/swad_enrollment.c +++ b/swad_enrollment.c @@ -700,7 +700,6 @@ void Enr_AskRemoveOldUsrs (void) extern const char *Txt_Eliminate_all_users_who_are_not_enrolled_on_any_courses_PART_1_OF_2; extern const char *Txt_Eliminate_all_users_who_are_not_enrolled_on_any_courses_PART_2_OF_2; extern const char *Txt_Eliminate; - unsigned MonthsWithoutAccess = Usr_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS; unsigned Months; /***** Start form *****/ @@ -719,7 +718,7 @@ void Enr_AskRemoveOldUsrs (void) Months++) { fprintf (Gbl.F.Out,"%u",Months); } @@ -747,7 +746,7 @@ void Enr_RemoveOldUsrs (void) extern const char *Txt_X_users_have_been_eliminated; char UnsignedStr[10+1]; unsigned MonthsWithoutAccess; - unsigned long SecondsWithoutAccess; + time_t SecondsWithoutAccess; char Query[1024]; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -759,11 +758,11 @@ void Enr_RemoveOldUsrs (void) /***** Get parameter with number of months without access *****/ Par_GetParToText ("Months",UnsignedStr,10); if (sscanf (UnsignedStr,"%u",&MonthsWithoutAccess) != 1) - Lay_ShowErrorAndExit ("Number of months without clicks is missing."); + Lay_ShowErrorAndExit ("Number of months is missing."); if (MonthsWithoutAccess < Usr_MIN_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS || MonthsWithoutAccess > Usr_MAX_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_USRS) - Lay_ShowErrorAndExit ("Wrong number of months without clicks."); - SecondsWithoutAccess = (unsigned long) MonthsWithoutAccess * Dat_SECONDS_IN_ONE_MONTH; + Lay_ShowErrorAndExit ("Wrong number of months."); + SecondsWithoutAccess = (time_t) MonthsWithoutAccess * Dat_SECONDS_IN_ONE_MONTH; /***** Get old users from database *****/ sprintf (Query,"SELECT UsrCod FROM" @@ -775,7 +774,7 @@ void Enr_RemoveOldUsrs (void) " UsrCod NOT IN (SELECT UsrCod FROM usr_last)" ") AS candidate_usrs" " WHERE UsrCod NOT IN (SELECT DISTINCT UsrCod FROM crs_usr)", - SecondsWithoutAccess); + (unsigned long) SecondsWithoutAccess); if ((NumUsrs = DB_QuerySELECT (Query,&mysql_res,"can not get old users"))) { sprintf (Gbl.Message,Txt_Eliminating_X_users_who_were_not_enrolled_in_any_course_and_with_more_than_Y_months_without_access_to_Z, diff --git a/swad_file_browser.c b/swad_file_browser.c index 4380e5788..f22e8668a 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -1454,8 +1454,9 @@ static bool Brw_CheckIfIHavePermissionFileOrFolderCommon (void); static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row); static void Brw_PutFormToAskRemOldFiles (void); -static void Brw_RemoveOldFilesInBrowser (void); -static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path); +static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder); +static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path, + time_t TimeRemoveFilesOlder); /*****************************************************************************/ /***************** Get parameters related to file browser ********************/ @@ -11215,25 +11216,54 @@ static void Brw_PutFormToAskRemOldFiles (void) /************** Write a form fo confirm removing of old files ****************/ /*****************************************************************************/ -void Brw_ConfirmRemoveOldFiles (void) +#define Brw_MIN_MONTHS_TO_REMOVE_OLD_FILES 2 // 2 months +#define Brw_DEF_MONTHS_TO_REMOVE_OLD_FILES 12 // 1 year +#define Brw_MAX_MONTHS_TO_REMOVE_OLD_FILES (10*12) // 10 years + +void Brw_AskRemoveOldFiles (void) { - extern const char *Txt_Do_you_really_want_to_remove_files_older_than_X_months; + extern const char *The_ClassForm[The_NUM_THEMES]; + extern const char *Txt_Remove_old_files; + extern const char *Txt_Remove_files_older_than_PART_1_OF_2; + extern const char *Txt_Remove_files_older_than_PART_2_OF_2; extern const char *Txt_Remove; + unsigned Months; /***** Get parameters related to file browser *****/ Brw_GetParAndInitFileBrowser (); - /***** Form to ask for confirmation to remove old files *****/ + /***** Start form *****/ Act_FormStart (ActRemOldBrf); Brw_PutParamsContextualLink (); - /* Show question */ - sprintf (Gbl.Message,Txt_Do_you_really_want_to_remove_files_older_than_X_months, - Cfg_MONTHS_TO_DELETE_OLD_BRIEFCASE_FILES); - Lay_ShowAlert (Lay_WARNING,Gbl.Message); + /***** Start frame *****/ + Lay_StartRoundFrame (NULL,Txt_Remove_old_files); - Lay_PutRemoveButton (Txt_Remove); + /***** Form to request number of months (to remove files older) *****/ + fprintf (Gbl.F.Out,"%s ", + The_ClassForm[Gbl.Prefs.Theme], + Txt_Remove_files_older_than_PART_1_OF_2); + fprintf (Gbl.F.Out,"" + " ", + The_ClassForm[Gbl.Prefs.Theme]); + fprintf (Gbl.F.Out,Txt_Remove_files_older_than_PART_2_OF_2, + Cfg_PLATFORM_SHORT_NAME); + fprintf (Gbl.F.Out,""); + /***** End frame *****/ + Lay_EndRoundFrameWithButton (Lay_REMOVE_BUTTON,Txt_Remove); + + /***** End form *****/ Act_FormEnd (); /***** Show again the file browser *****/ @@ -11246,14 +11276,26 @@ void Brw_ConfirmRemoveOldFiles (void) void Brw_RemoveOldFiles (void) { - extern const char *Txt_Remove; + char UnsignedStr[10+1]; + unsigned Months; + time_t TimeRemoveFilesOlder; /***** Get parameters related to file browser *****/ Brw_GetParAndInitFileBrowser (); + /***** Get parameter with number of months without access *****/ + Par_GetParToText ("Months",UnsignedStr,10); + if (sscanf (UnsignedStr,"%u",&Months) != 1) + Lay_ShowErrorAndExit ("Number of months is missing."); + if (Months < Brw_MIN_MONTHS_TO_REMOVE_OLD_FILES || + Months > Brw_MAX_MONTHS_TO_REMOVE_OLD_FILES) + Lay_ShowErrorAndExit ("Wrong number of months."); + TimeRemoveFilesOlder = Gbl.StartExecutionTimeUTC - + (time_t) Months * Dat_SECONDS_IN_ONE_MONTH; + /***** Remove old files *****/ if (Gbl.FileBrowser.Type == Brw_ADMI_BRIEF_USR) - Brw_RemoveOldFilesInBrowser (); + Brw_RemoveOldFilesInBrowser (TimeRemoveFilesOlder); /***** Show again the file browser *****/ Brw_ShowAgainFileBrowserOrWorks (); @@ -11263,7 +11305,7 @@ void Brw_RemoveOldFiles (void) /******************************* Remove old files ****************************/ /*****************************************************************************/ -static void Brw_RemoveOldFilesInBrowser (void) +static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder) { extern const char *Txt_Folders_removed; extern const char *Txt_Files_removed; @@ -11271,7 +11313,7 @@ static void Brw_RemoveOldFilesInBrowser (void) /***** Remove old files recursively *****/ Gbl.FileBrowser.Removed.NumFiles = Gbl.FileBrowser.Removed.NumFolders = 0; - Brw_ScanDirRemovingOlfFiles (1,Gbl.FileBrowser.Priv.PathRootFolder); + Brw_ScanDirRemovingOlfFiles (1,Gbl.FileBrowser.Priv.PathRootFolder,TimeRemoveFilesOlder); /***** Success message *****/ sprintf (Gbl.Message,"%s: %u. %s: %u.", @@ -11284,9 +11326,8 @@ static void Brw_RemoveOldFilesInBrowser (void) /************* Scan a directory recursively removing old files ***************/ /*****************************************************************************/ -#define Brw_TIME_TO_DELETE_BROWSER_OLD_FILES ((time_t)(Cfg_MONTHS_TO_DELETE_OLD_BRIEFCASE_FILES*30UL*24UL*60UL*60UL)) - -static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path) +static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path, + time_t TimeRemoveFilesOlder) { struct dirent **DirFileList; struct dirent **SubdirFileList; @@ -11295,8 +11336,6 @@ static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path) int NumFilesInThisSubdir; char PathFileRel[PATH_MAX+1]; struct stat FileStatus; - time_t TimeRemoveFilesOlder = Gbl.StartExecutionTimeUTC - - Brw_TIME_TO_DELETE_BROWSER_OLD_FILES; /***** Scan directory *****/ NumFilesInThisDir = scandir (Path,&DirFileList,NULL,alphasort); @@ -11322,7 +11361,7 @@ static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path) if (NumFilesInThisSubdir > 2) // Not empty directory { /* Scan subtree starting at this this directory recursively */ - Brw_ScanDirRemovingOlfFiles (Level+1,PathFileRel); + Brw_ScanDirRemovingOlfFiles (Level+1,PathFileRel,TimeRemoveFilesOlder); /* Check again number of files after deletion */ NumFilesInThisSubdir = scandir (PathFileRel,&SubdirFileList,NULL,NULL); diff --git a/swad_file_browser.h b/swad_file_browser.h index b113edce5..2b1d309e1 100644 --- a/swad_file_browser.h +++ b/swad_file_browser.h @@ -218,7 +218,7 @@ void Brw_GetNotifDocOrSharedFile (char *SummaryStr,char **ContentStr, unsigned Brw_ListDocsFound (const char *Query,const char *Title); -void Brw_ConfirmRemoveOldFiles (void); +void Brw_AskRemoveOldFiles (void); void Brw_RemoveOldFiles (void); #endif diff --git a/swad_text.c b/swad_text.c index de16732cc..b415b4063 100644 --- a/swad_text.c +++ b/swad_text.c @@ -8358,36 +8358,6 @@ const char *Txt_Do_you_really_want_to_reject_the_enrollment_request_ = // Warnin " in the course %s?"; // Necessita de tradução #endif -const char *Txt_Do_you_really_want_to_remove_files_older_than_X_months = // Warning: it is very important to include %u in the following sentences -#if L==1 - "De veres voleu eliminar els arxius" - " amb més de %u mesos d'antiguitat?"; -#elif L==2 - "Wollen Sie wirklich, um Dateien," - " die älter als %u Monate löschen?"; -#elif L==3 - "Do you really want to remove files" - " older than %u months?"; -#elif L==4 - "¿Realmente desea eliminar los archivos" - " con más de %u meses de antigüedad?"; -#elif L==5 - "Voulez-vous vraiment supprimer les fichiers" - " de plus de %u mois?"; -#elif L==6 - "¿Realmente desea eliminar los archivos" - " con más de %u meses de antigüedad?"; // Okoteve traducción -#elif L==7 - "Vuoi davvero rimuovere i file" - " più vecchi di %u mesi?"; -#elif L==8 - "Czy na pewno chcesz usunąć pliki" - " starsze niż %u miesięcy?"; -#elif L==9 - "Você realmente deseja remover arquivos" - " com mais de %u meses?"; -#endif - const char *Txt_Do_you_really_want_to_remove_the_X_students_from_the_course_Y_ = // Warning: it is very important to include %u and %s in the following sentences #if L==1 "¿Realmente desea eliminar los %u estudiantes de la asignatura %s?
" @@ -9650,23 +9620,41 @@ const char *Txt_Eliminate_all_courses_whithout_users_PART_2_OF_2 = const char *Txt_Eliminate_all_users_who_are_not_enrolled_on_any_courses_PART_1_OF_2 = #if L==1 - "Eliminar todos los usuarios que no estén inscritos en ninguna asignatura y que lleven más de"; // Necessita traduccio + "Eliminar todos los usuarios" + " que no estén inscritos en ninguna asignatura" + " y que lleven más de"; // Necessita traduccio #elif L==2 - "Eliminate all users who are not enrolled on any courses and with more than"; // Need Übersetzung + "Eliminate all users" + " who are not enrolled on any courses" + " and with more than"; // Need Übersetzung #elif L==3 - "Eliminate all users who are not enrolled on any courses and with more than"; + "Eliminate all users" + " who are not enrolled on any courses" + " and with more than"; #elif L==4 - "Eliminar todos los usuarios que no estén inscritos en ninguna asignatura y que lleven más de"; + "Eliminar todos los usuarios" + " que no estén inscritos en ninguna asignatura" + " y que lleven más de"; #elif L==5 - "Eliminate all users who are not enrolled on any courses and with more than"; // Besoin de traduction + "Eliminate all users" + " who are not enrolled on any courses" + " and with more than"; // Besoin de traduction #elif L==6 - "Eliminar todos los usuarios que no estén inscritos en ninguna asignatura y que lleven más de"; // Okoteve traducción + "Eliminar todos los usuarios" + " que no estén inscritos en ninguna asignatura" + " y que lleven más de"; // Okoteve traducción #elif L==7 - "Rimuovere tutti gli utenti che non sono registrati ad alcun corso e con più di"; + "Rimuovere tutti gli utenti" + " che non sono registrati ad alcun corso" + " e con più di"; #elif L==8 - "Wyeliminuj wszystkich uzytkowników, którzy nie sa zarejestrowani na kazdym z kursów"; + "Wyeliminuj wszystkich uzytkowników," + " którzy nie sa zarejestrowani" + " na kazdym z kursów"; #elif L==9 - "Eliminate all users who are not enrolled on any courses and with more than"; // Necessita de tradução + "Eliminate all users" + " who are not enrolled on any courses" + " and with more than"; // Necessita de tradução #endif const char *Txt_Eliminate_all_users_who_are_not_enrolled_on_any_courses_PART_2_OF_2 = // Warning: it is very important to include %s in the following sentences @@ -28782,6 +28770,48 @@ const char *Txt_Remove_FILE_OR_LINK_X = // Warning: it is very important to incl "Remover %s"; #endif +const char *Txt_Remove_files_older_than_PART_1_OF_2 = +#if L==1 + "Eliminar els arxius amb més de"; +#elif L==2 + "Dateien zu entfernen, die älter als"; +#elif L==3 + "Remove files older than"; +#elif L==4 + "Eliminar los archivos con más de"; +#elif L==5 + "Supprimer les fichiers de plus de"; +#elif L==6 + "Eliminar los archivos con más de"; // Okoteve traducción +#elif L==7 + "Rimuovere i file più vecchi di"; +#elif L==8 + "Remove files older than"; // Potrzebujesz tlumaczenie +#elif L==9 + "Remover arquivos com mais de"; +#endif + +const char *Txt_Remove_files_older_than_PART_2_OF_2 = +#if L==1 + "mesos d'antiguitat."; +#elif L==2 + "Monate."; +#elif L==3 + "months."; +#elif L==4 + "meses de antigüedad."; +#elif L==5 + "mois."; +#elif L==6 + "meses de antigüedad."; // Okoteve traducción +#elif L==7 + "mesi."; +#elif L==8 + "months."; // Potrzebujesz tlumaczenie +#elif L==9 + "meses."; +#endif + const char *Txt_Remove_folder = #if L==1 "Eliminar carpeta";