Version 15.70.5

This commit is contained in:
Antonio Cañas Vargas 2015-12-21 14:20:01 +01:00
parent e89f26fd49
commit 2db2810842
4 changed files with 80 additions and 41 deletions

View File

@ -118,12 +118,17 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 15.70.5 (2015/12/21)" #define Log_PLATFORM_VERSION "SWAD 15.70.6 (2015/12/21)"
#define CSS_FILE "swad15.65.1.css" #define CSS_FILE "swad15.65.1.css"
// Number of lines (includes comments but not blank lines) has been got with the following command: // 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 // 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.6: Dec 21, 2015 Removing old files in briefcase. Not finished. (187604 lines)
2 changes necessary in database:
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1488','es','N','Solicitar eliminar archivos antiguos maletín');
INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1489','es','N','Eliminar archivos antiguos maletín');
Version 15.70.5: Dec 21, 2015 Code refactoring in file browser. (187569 lines) Version 15.70.5: Dec 21, 2015 Code refactoring in file browser. (187569 lines)
Version 15.70.4: Dec 21, 2015 Code refactoring in file browser. (187527 lines) Version 15.70.4: Dec 21, 2015 Code refactoring in file browser. (187527 lines)
Version 15.70.3: Dec 21, 2015 Code refactoring in file browser. (187490 lines) Version 15.70.3: Dec 21, 2015 Code refactoring in file browser. (187490 lines)

View File

@ -73,6 +73,13 @@ typedef enum
Brw_ADMIN, Brw_ADMIN,
} Brw_ShowOrAdmin_t; } Brw_ShowOrAdmin_t;
struct Brw_NumObjects
{
unsigned NumFiles;
unsigned NumFolds;
unsigned NumLinks;
};
/*****************************************************************************/ /*****************************************************************************/
/**************************** Internal constants *****************************/ /**************************** Internal constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
@ -1411,9 +1418,7 @@ static void Brw_RemoveAffectedClipboards (Brw_FileBrowser_t FileBrowser,long MyU
static void Brw_PasteClipboard (void); static void Brw_PasteClipboard (void);
static unsigned Brw_NumLevelsInPath (const char *Path); static unsigned Brw_NumLevelsInPath (const char *Path);
static bool Brw_PasteTreeIntoFolder (const char *PathOrg,const char *PathDstInTree, static bool Brw_PasteTreeIntoFolder (const char *PathOrg,const char *PathDstInTree,
unsigned *NumFilesPasted, struct Brw_NumObjects *Pasted,
unsigned *NumFoldsPasted,
unsigned *NumLinksPasted,
long *FirstFilCod); long *FirstFilCod);
static void Brw_PutFormToCreateAFolder (const char *FileNameToShow); static void Brw_PutFormToCreateAFolder (const char *FileNameToShow);
static void Brw_PutFormToUploadFilesUsingDropzone (const char *FileNameToShow); static void Brw_PutFormToUploadFilesUsingDropzone (const char *FileNameToShow);
@ -1456,7 +1461,8 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row);
static void Brw_PutFormToAskRemOldFiles (void); static void Brw_PutFormToAskRemOldFiles (void);
static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder); static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder);
static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path, static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path,
time_t TimeRemoveFilesOlder); time_t TimeRemoveFilesOlder,
struct Brw_NumObjects *Removed);
/*****************************************************************************/ /*****************************************************************************/
/***************** Get parameters related to file browser ********************/ /***************** Get parameters related to file browser ********************/
@ -7267,8 +7273,8 @@ static void Brw_PasteClipboard (void)
{ {
extern const char *Txt_The_copy_has_been_successful; extern const char *Txt_The_copy_has_been_successful;
extern const char *Txt_Files_copied; extern const char *Txt_Files_copied;
extern const char *Txt_Folders_copied;
extern const char *Txt_Links_copied; extern const char *Txt_Links_copied;
extern const char *Txt_Folders_copied;
extern const char *Txt_You_can_not_paste_file_or_folder_here; extern const char *Txt_You_can_not_paste_file_or_folder_here;
struct Institution Ins; struct Institution Ins;
struct Centre Ctr; struct Centre Ctr;
@ -7276,13 +7282,15 @@ static void Brw_PasteClipboard (void)
struct Course Crs; struct Course Crs;
struct GroupData GrpDat; struct GroupData GrpDat;
char PathOrg[PATH_MAX+1]; char PathOrg[PATH_MAX+1];
unsigned NumFilesPasted = 0; struct Brw_NumObjects Pasted;
unsigned NumFoldsPasted = 0;
unsigned NumLinksPasted = 0;
long FirstFilCod = -1L; // First file code of the first file or link pasted. Important: initialize here to -1L long FirstFilCod = -1L; // First file code of the first file or link pasted. Important: initialize here to -1L
struct FileMetadata FileMetadata; struct FileMetadata FileMetadata;
unsigned NumUsrsToBeNotifiedByEMail; unsigned NumUsrsToBeNotifiedByEMail;
Pasted.NumFiles =
Pasted.NumLinks =
Pasted.NumFolds = 0;
Gbl.FileBrowser.Clipboard.IsThisTree = Brw_CheckIfClipboardIsInThisTree (); Gbl.FileBrowser.Clipboard.IsThisTree = Brw_CheckIfClipboardIsInThisTree ();
if (Brw_CheckIfCanPasteIn (Gbl.FileBrowser.Level)) if (Brw_CheckIfCanPasteIn (Gbl.FileBrowser.Level))
{ {
@ -7388,7 +7396,7 @@ static void Brw_PasteClipboard (void)
Brw_CalcSizeOfDir (Gbl.FileBrowser.Priv.PathRootFolder); Brw_CalcSizeOfDir (Gbl.FileBrowser.Priv.PathRootFolder);
Brw_SetMaxQuota (); Brw_SetMaxQuota ();
if (Brw_PasteTreeIntoFolder (PathOrg,Gbl.FileBrowser.Priv.FullPathInTree, if (Brw_PasteTreeIntoFolder (PathOrg,Gbl.FileBrowser.Priv.FullPathInTree,
&NumFilesPasted,&NumFoldsPasted,&NumLinksPasted, &Pasted,
&FirstFilCod)) &FirstFilCod))
{ {
/***** Write message of success *****/ /***** Write message of success *****/
@ -7397,14 +7405,14 @@ static void Brw_PasteClipboard (void)
"%s: %u<br />" "%s: %u<br />"
"%s: %u", "%s: %u",
Txt_The_copy_has_been_successful, Txt_The_copy_has_been_successful,
Txt_Files_copied ,NumFilesPasted, Txt_Files_copied ,Pasted.NumFiles,
Txt_Folders_copied,NumFoldsPasted, Txt_Links_copied ,Pasted.NumLinks,
Txt_Links_copied ,NumLinksPasted); Txt_Folders_copied,Pasted.NumFolds);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
/***** Notify new files *****/ /***** Notify new files *****/
if (NumFilesPasted || if (Pasted.NumFiles ||
NumLinksPasted) Pasted.NumLinks)
{ {
FileMetadata.FilCod = FirstFilCod; FileMetadata.FilCod = FirstFilCod;
Brw_GetFileMetadataByCod (&FileMetadata); Brw_GetFileMetadataByCod (&FileMetadata);
@ -7462,9 +7470,7 @@ static unsigned Brw_NumLevelsInPath (const char *Path)
// Return true if the copy has been made successfully, and false if not // Return true if the copy has been made successfully, and false if not
static bool Brw_PasteTreeIntoFolder (const char *PathOrg,const char *PathDstInTree, static bool Brw_PasteTreeIntoFolder (const char *PathOrg,const char *PathDstInTree,
unsigned *NumFilesPasted, struct Brw_NumObjects *Pasted,
unsigned *NumFoldsPasted,
unsigned *NumLinksPasted,
long *FirstFilCod) long *FirstFilCod)
{ {
extern const char *Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_it_would_exceed_the_disk_quota; extern const char *Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_it_would_exceed_the_disk_quota;
@ -7611,9 +7617,9 @@ static bool Brw_PasteTreeIntoFolder (const char *PathOrg,const char *PathDstInTr
Mrk_AddMarksToDB (FilCod,&Marks); Mrk_AddMarksToDB (FilCod,&Marks);
if (FileType == Brw_IS_FILE) if (FileType == Brw_IS_FILE)
(*NumFilesPasted)++; (Pasted->NumFiles)++;
else // FileType == Brw_IS_LINK else // FileType == Brw_IS_LINK
(*NumLinksPasted)++; (Pasted->NumLinks)++;
} }
} }
} }
@ -7660,7 +7666,7 @@ static bool Brw_PasteTreeIntoFolder (const char *PathOrg,const char *PathDstInTr
{ {
sprintf (PathInFolderOrg,"%s/%s",PathOrg,FileList[NumFile]->d_name); sprintf (PathInFolderOrg,"%s/%s",PathOrg,FileList[NumFile]->d_name);
if (!Brw_PasteTreeIntoFolder (PathInFolderOrg,PathDstInTreeWithFile, if (!Brw_PasteTreeIntoFolder (PathInFolderOrg,PathDstInTreeWithFile,
NumFilesPasted,NumFoldsPasted,NumLinksPasted, Pasted,
FirstFilCod)) FirstFilCod))
CopyIsGoingSuccessful = false; CopyIsGoingSuccessful = false;
} }
@ -7672,7 +7678,7 @@ static bool Brw_PasteTreeIntoFolder (const char *PathOrg,const char *PathDstInTr
Lay_ShowErrorAndExit ("Error while scanning directory."); Lay_ShowErrorAndExit ("Error while scanning directory.");
if (CopyIsGoingSuccessful) if (CopyIsGoingSuccessful)
(*NumFoldsPasted)++; (Pasted->NumFolds)++;
} }
} }
@ -11362,18 +11368,23 @@ void Brw_RemoveOldFiles (void)
static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder) static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder)
{ {
extern const char *Txt_Files_removed; extern const char *Txt_Files_removed;
extern const char *Txt_Links_removed;
extern const char *Txt_Folders_removed; extern const char *Txt_Folders_removed;
struct Brw_NumObjects Removed;
/***** Remove old files recursively *****/ /***** Remove old files recursively *****/
Gbl.FileBrowser.Removed.NumFiles = Removed.NumFiles =
Gbl.FileBrowser.Removed.NumFolders = 0; Removed.NumLinks =
Brw_ScanDirRemovingOlfFiles (1,Gbl.FileBrowser.Priv.PathRootFolder,TimeRemoveFilesOlder); Removed.NumFolds = 0;
Brw_ScanDirRemovingOlfFiles (1,Gbl.FileBrowser.Priv.PathRootFolder,TimeRemoveFilesOlder,&Removed);
/***** Success message *****/ /***** Success message *****/
sprintf (Gbl.Message,"%s: %u.<br />" sprintf (Gbl.Message,"%s: %u<br />"
"%s: %u.", "%s: %u<br />"
Txt_Files_removed ,Gbl.FileBrowser.Removed.NumFiles, "%s: %u",
Txt_Folders_removed,Gbl.FileBrowser.Removed.NumFolders); Txt_Files_removed ,Removed.NumFiles,
Txt_Links_removed ,Removed.NumLinks,
Txt_Folders_removed,Removed.NumFolds);
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
} }
@ -11382,7 +11393,8 @@ static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder)
/*****************************************************************************/ /*****************************************************************************/
static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path, static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path,
time_t TimeRemoveFilesOlder) time_t TimeRemoveFilesOlder,
struct Brw_NumObjects *Removed)
{ {
struct dirent **FileList; struct dirent **FileList;
int NumFile; int NumFile;
@ -11411,13 +11423,19 @@ static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path,
if (S_ISDIR (FileStatus.st_mode)) // It's a directory if (S_ISDIR (FileStatus.st_mode)) // It's a directory
/* Scan subtree starting at this this directory recursively */ /* Scan subtree starting at this this directory recursively */
Brw_ScanDirRemovingOlfFiles (Level + 1,PathFileRel,TimeRemoveFilesOlder); Brw_ScanDirRemovingOlfFiles (Level + 1,PathFileRel,
TimeRemoveFilesOlder,Removed);
else if (S_ISREG (FileStatus.st_mode) && // It's a regular file else if (S_ISREG (FileStatus.st_mode) && // It's a regular file
FileStatus.st_mtime < TimeRemoveFilesOlder) // ..and it's old FileStatus.st_mtime < TimeRemoveFilesOlder) // ..and it's old
{ {
/* Remove file */ /* Remove file */
Lay_ShowAlert (Lay_SUCCESS,PathFileRel); // if (unlink (PathFileRel))
Gbl.FileBrowser.Removed.NumFiles++; // Lay_ShowErrorAndExit ("Can not remove file / link.");
if (Str_FileIs (PathFileRel,"url"))
(Removed->NumLinks)++; // It's a link (URL inside a .url file)
else
(Removed->NumFiles)++; // It's a file
} }
} }
free ((void *) FileList[NumFile]); free ((void *) FileList[NumFile]);
@ -11448,8 +11466,9 @@ static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path,
if (FileStatus.st_mtime < TimeRemoveFilesOlder) if (FileStatus.st_mtime < TimeRemoveFilesOlder)
{ {
/* Remove folder */ /* Remove folder */
Lay_ShowAlert (Lay_SUCCESS,Path); // if (rmdir (Path))
Gbl.FileBrowser.Removed.NumFolders++; // Lay_ShowErrorAndExit ("Can not remove folder.");
(Removed->NumFolds)++;
} }
} }
} }

View File

@ -532,11 +532,6 @@ struct Globals
bool CreateZIP; bool CreateZIP;
char TmpDir[NAME_MAX+1]; char TmpDir[NAME_MAX+1];
} ZIP; } ZIP;
struct
{
unsigned NumFiles;
unsigned NumFolders;
} Removed; // Number of old folders and files removed
} FileBrowser; // Struct used for a file browser } FileBrowser; // Struct used for a file browser
struct struct
{ {

View File

@ -15846,7 +15846,7 @@ const char *Txt_Links_copied =
#elif L==4 #elif L==4
"Enlaces copiados"; "Enlaces copiados";
#elif L==5 #elif L==5
"Fichiers copi&eacute;s"; "Liens copi&eacute;s";
#elif L==6 #elif L==6
"Enlaces copiados"; // Okoteve traducción "Enlaces copiados"; // Okoteve traducción
#elif L==7 #elif L==7
@ -15857,6 +15857,26 @@ const char *Txt_Links_copied =
"Liga&ccedil;&otilde;es copiadas"; "Liga&ccedil;&otilde;es copiadas";
#endif #endif
const char *Txt_Links_removed =
#if L==1
"Enlla&ccedil;os eliminats";
#elif L==2
"Links entfernt";
#elif L==3
"Links removed";
#elif L==4
"Enlaces eliminados";
#elif L==5
"Liens supprim&eacute;s";
#elif L==6
"Enlaces eliminados"; // Okoteve traducción
#elif L==7
"Link rimossi";
#elif L==8
"Linki usuni&eogon;te";
#elif L==9
"Liga&ccedil;&otilde;es removidas";
#endif
const char *Txt_Local_address = const char *Txt_Local_address =
#if L==1 #if L==1