mirror of https://github.com/acanas/swad-core.git
Version18.120
This commit is contained in:
parent
cf59d464d9
commit
c5c50eed37
|
@ -514,9 +514,12 @@ static void Asg_WriteAssignmentFolder (struct Assignment *Asg,bool PrintView)
|
|||
Lay_ShowErrorAndExit ("Wrong role.");
|
||||
break;
|
||||
}
|
||||
Brw_PutParamsFileBrowser (Brw_INTERNAL_NAME_ROOT_FOLDER_ASSIGNMENTS,
|
||||
Asg->Folder,
|
||||
Brw_IS_FOLDER,-1L);
|
||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_INTERNAL_NAME_ROOT_FOLDER_ASSIGNMENTS,
|
||||
PATH_MAX);
|
||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,Asg->Folder,
|
||||
NAME_MAX);
|
||||
Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_FOLDER;
|
||||
Brw_PutImplicitParamsFileBrowser ();
|
||||
Ico_PutIconLink ("folder-open-yellow-plus.png",
|
||||
Txt_Upload_file_or_create_folder);
|
||||
Frm_EndForm ();
|
||||
|
|
|
@ -448,10 +448,11 @@ En OpenSWAD:
|
|||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.119 (2019-04-25)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 18.120 (2019-04-25)"
|
||||
#define CSS_FILE "swad18.112.1.css"
|
||||
#define JS_FILE "swad18.116.5.js"
|
||||
/*
|
||||
Version 18.120: Apr 25, 2019 Code refactoring related to file browser. (242466 lines)
|
||||
Version 18.119: Apr 25, 2019 Code refactoring related to selected users. (242536 lines)
|
||||
Version 18.118.5: Apr 23, 2019 Code refactoring in file browser. (242497 lines)
|
||||
Version 18.118.4: Apr 23, 2019 Changes in file browser. (242518 lines)
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -242,13 +242,12 @@ void Brw_RemoveExpiredExpandedFolders (void);
|
|||
|
||||
void Brw_CalcSizeOfDir (char *Path);
|
||||
|
||||
void Brw_SetFullPathInTree (const char *PathInTreeUntilFileOrFolder,const char *FilFolLnkName);
|
||||
void Brw_SetFullPathInTree (void);
|
||||
|
||||
void Brw_CreateTmpPublicLinkToPrivateFile (const char *FullPathIncludingFile,
|
||||
const char *FileName);
|
||||
|
||||
void Brw_PutParamsFileBrowser (const char *PathInTree,const char *FileFolderName,
|
||||
Brw_FileType_t FileType,long FilCod);
|
||||
void Brw_PutImplicitParamsFileBrowser (void);
|
||||
|
||||
void Brw_RemoveZonesOfGroupsOfType (long GrpTypCod);
|
||||
void Brw_RemoveGrpZones (long CrsCod,long GrpCod);
|
||||
|
|
|
@ -382,7 +382,7 @@ void Gbl_InitializeGlobals (void)
|
|||
/* File browser */
|
||||
Gbl.FileBrowser.Id = 0;
|
||||
Gbl.FileBrowser.Type = Brw_UNKNOWN;
|
||||
Gbl.FileBrowser.FileType = Brw_IS_UNKNOWN;
|
||||
Gbl.FileBrowser.FilFolLnk.Type = Brw_IS_UNKNOWN;
|
||||
Gbl.FileBrowser.UploadingWithDropzone = false;
|
||||
|
||||
/* Agenda */
|
||||
|
|
|
@ -507,12 +507,15 @@ struct Globals
|
|||
{
|
||||
char PathAboveRootFolder[PATH_MAX + 1];
|
||||
char PathRootFolder[PATH_MAX + 1];
|
||||
char PathInTreeUntilFilFolLnk[PATH_MAX + 1];
|
||||
char FullPathInTree[PATH_MAX + 1];
|
||||
} Priv;
|
||||
char NewFilFolLnkName[NAME_MAX + 1];
|
||||
char FilFolLnkName[NAME_MAX + 1];
|
||||
Brw_FileType_t FileType;
|
||||
struct
|
||||
{
|
||||
char Full[PATH_MAX + 1]; // Full path in tree, including filename
|
||||
char Path[PATH_MAX + 1]; // Path in tree above filename
|
||||
char Name[NAME_MAX + 1]; // Filename
|
||||
Brw_FileType_t Type;
|
||||
} FilFolLnk;
|
||||
unsigned Level;
|
||||
bool ICanEditFileOrFolder; // Can I modify (remove, rename, create inside, etc.) a file or folder?
|
||||
Brw_IconViewEdit_t IconViewEdit;
|
||||
|
|
39
swad_mark.c
39
swad_mark.c
|
@ -105,16 +105,14 @@ void Mrk_AddMarksToDB (long FilCod,struct MarksProperties *Marks)
|
|||
/********* Write number of header and footer rows of a file of marks *********/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Mrk_GetAndWriteNumRowsHeaderAndFooter (Brw_FileType_t FileType,
|
||||
const char *PathInTree,
|
||||
const char *FileName)
|
||||
void Mrk_GetAndWriteNumRowsHeaderAndFooter (void)
|
||||
{
|
||||
extern const char *The_ClassFormInBoxNoWrap[The_NUM_THEMES];
|
||||
extern const char *Txt_TABLE_Header;
|
||||
extern const char *Txt_TABLE_Footer;
|
||||
struct MarksProperties Marks;
|
||||
|
||||
if (FileType == Brw_IS_FOLDER)
|
||||
if (Gbl.FileBrowser.FilFolLnk.Type == Brw_IS_FOLDER)
|
||||
fprintf (Gbl.F.Out,"<td class=\"COLOR%u\"></td>"
|
||||
"<td class=\"COLOR%u\"></td>",
|
||||
Gbl.RowEvenOdd,
|
||||
|
@ -128,13 +126,9 @@ void Mrk_GetAndWriteNumRowsHeaderAndFooter (Brw_FileType_t FileType,
|
|||
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_TOP COLOR%u\">",
|
||||
The_ClassFormInBoxNoWrap[Gbl.Prefs.Theme],
|
||||
Gbl.RowEvenOdd);
|
||||
if (Gbl.Crs.Grps.GrpCod > 0) // Group zone
|
||||
{
|
||||
Frm_StartForm (ActChgNumRowHeaGrp);
|
||||
Grp_PutParamGrpCod (Gbl.Crs.Grps.GrpCod);
|
||||
}
|
||||
else // Course zone
|
||||
Frm_StartForm (ActChgNumRowHeaCrs);
|
||||
Frm_StartForm (Gbl.Crs.Grps.GrpCod > 0 ? ActChgNumRowHeaGrp : // Group zone
|
||||
ActChgNumRowHeaCrs); // Course zone
|
||||
Brw_PutImplicitParamsFileBrowser ();
|
||||
fprintf (Gbl.F.Out,"<label> %s: "
|
||||
"<input type=\"text\" name=\"%s\""
|
||||
" size=\"1\" maxlength=\"5\" value=\"%u\""
|
||||
|
@ -145,8 +139,6 @@ void Mrk_GetAndWriteNumRowsHeaderAndFooter (Brw_FileType_t FileType,
|
|||
Mrk_HeadOrFootStr[Brw_HEADER],Marks.Header,
|
||||
Gbl.RowEvenOdd,
|
||||
Gbl.Form.Id);
|
||||
Brw_PutParamsFileBrowser (PathInTree,FileName,
|
||||
FileType,-1L);
|
||||
Frm_EndForm ();
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
|
||||
|
@ -154,13 +146,9 @@ void Mrk_GetAndWriteNumRowsHeaderAndFooter (Brw_FileType_t FileType,
|
|||
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_TOP COLOR%u\">",
|
||||
The_ClassFormInBoxNoWrap[Gbl.Prefs.Theme],
|
||||
Gbl.RowEvenOdd);
|
||||
if (Gbl.Crs.Grps.GrpCod > 0) // Group zone
|
||||
{
|
||||
Frm_StartForm (ActChgNumRowFooGrp);
|
||||
Grp_PutParamGrpCod (Gbl.Crs.Grps.GrpCod);
|
||||
}
|
||||
else // Course zone
|
||||
Frm_StartForm (ActChgNumRowFooCrs);
|
||||
Frm_StartForm (Gbl.Crs.Grps.GrpCod > 0 ? ActChgNumRowFooGrp : // Group zone
|
||||
ActChgNumRowFooCrs); // Course zone
|
||||
Brw_PutImplicitParamsFileBrowser ();
|
||||
fprintf (Gbl.F.Out,"<label> %s: "
|
||||
"<input type=\"text\" name=\"%s\""
|
||||
" size=\"1\" maxlength=\"5\" value=\"%u\""
|
||||
|
@ -171,8 +159,6 @@ void Mrk_GetAndWriteNumRowsHeaderAndFooter (Brw_FileType_t FileType,
|
|||
Mrk_HeadOrFootStr[Brw_FOOTER],Marks.Footer,
|
||||
Gbl.RowEvenOdd,
|
||||
Gbl.Form.Id);
|
||||
Brw_PutParamsFileBrowser (PathInTree,FileName,
|
||||
FileType,-1L);
|
||||
Frm_EndForm ();
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
}
|
||||
|
@ -207,7 +193,7 @@ static void Mrk_GetNumRowsHeaderAndFooter (struct MarksProperties *Marks)
|
|||
Mrk_HeadOrFootStr[Brw_FOOTER],
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree);
|
||||
Gbl.FileBrowser.FilFolLnk.Full);
|
||||
|
||||
/***** The result of the query must have only one row *****/
|
||||
if (NumRows == 1)
|
||||
|
@ -278,7 +264,7 @@ static void Mrk_ChangeNumRowsHeaderOrFooter (Brw_HeadOrFoot_t HeaderOrFooter)
|
|||
Mrk_HeadOrFootStr[HeaderOrFooter],NumRows,
|
||||
(unsigned) Brw_FileBrowserForDB_files[Gbl.FileBrowser.Type],
|
||||
Cod,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree);
|
||||
Gbl.FileBrowser.FilFolLnk.Full);
|
||||
|
||||
/***** Write message of success *****/
|
||||
Ale_ShowAlert (Ale_SUCCESS,Txt_The_number_of_rows_is_now_X,
|
||||
|
@ -613,12 +599,11 @@ void Mrk_ShowMyMarks (void)
|
|||
Brw_GetParAndInitFileBrowser ();
|
||||
|
||||
/***** Get the path of the file of marks *****/
|
||||
Brw_SetFullPathInTree (Gbl.FileBrowser.Priv.PathInTreeUntilFilFolLnk,
|
||||
Gbl.FileBrowser.FilFolLnkName);
|
||||
Brw_SetFullPathInTree ();
|
||||
snprintf (PathPrivate,sizeof (PathPrivate),
|
||||
"%s/%s",
|
||||
Gbl.FileBrowser.Priv.PathAboveRootFolder,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree);
|
||||
Gbl.FileBrowser.FilFolLnk.Full);
|
||||
|
||||
/***** Get number of rows of header or footer *****/
|
||||
Mrk_GetNumRowsHeaderAndFooter (&Marks);
|
||||
|
|
|
@ -46,7 +46,7 @@ struct MarksProperties
|
|||
/*****************************************************************************/
|
||||
|
||||
void Mrk_AddMarksToDB (long FilCod,struct MarksProperties *Marks);
|
||||
void Mrk_GetAndWriteNumRowsHeaderAndFooter (Brw_FileType_t FileType,const char *PathInTree,const char *FileName);
|
||||
void Mrk_GetAndWriteNumRowsHeaderAndFooter (void);
|
||||
void Mrk_ChangeNumRowsHeader (void);
|
||||
void Mrk_ChangeNumRowsFooter (void);
|
||||
|
||||
|
|
|
@ -4420,7 +4420,11 @@ int swad__getDirectoryTree (struct soap *soap,
|
|||
"%s/%ld",
|
||||
Cfg_PATH_CRS_PRIVATE,Gbl.Hierarchy.Crs.CrsCod);
|
||||
Brw_InitializeFileBrowser ();
|
||||
Brw_SetFullPathInTree (Brw_RootFolderInternalNames[Gbl.FileBrowser.Type],".");
|
||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,Brw_RootFolderInternalNames[Gbl.FileBrowser.Type],
|
||||
PATH_MAX);
|
||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,".",
|
||||
NAME_MAX);
|
||||
Brw_SetFullPathInTree ();
|
||||
|
||||
/* Check if exists the directory for HTML output. If not exists, create it */
|
||||
Fil_CreateDirIfNotExists (Cfg_PATH_OUT_PRIVATE);
|
||||
|
@ -4439,7 +4443,7 @@ int swad__getDirectoryTree (struct soap *soap,
|
|||
/* Get directory tree into XML file */
|
||||
XML_WriteStartFile (Gbl.F.XML,"tree",false);
|
||||
if (!Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (Brw_IS_FOLDER,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree)) // If root folder is visible
|
||||
Gbl.FileBrowser.FilFolLnk.Full)) // If root folder is visible
|
||||
Svc_ListDir (1,Gbl.FileBrowser.Priv.PathRootFolder,Brw_RootFolderInternalNames[Gbl.FileBrowser.Type]);
|
||||
XML_WriteEndFile (Gbl.F.XML,"tree");
|
||||
|
||||
|
@ -4492,10 +4496,15 @@ static void Svc_ListDir (unsigned Level,const char *Path,const char *PathInTree)
|
|||
"%s/%s",
|
||||
PathInTree,FileList[NumFile]->d_name);
|
||||
|
||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,PathInTree,
|
||||
PATH_MAX);
|
||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,FileList[NumFile]->d_name,
|
||||
NAME_MAX);
|
||||
|
||||
if (!lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
|
||||
{
|
||||
/***** Construct the full path of the file or folder *****/
|
||||
Brw_SetFullPathInTree (PathInTree,FileList[NumFile]->d_name);
|
||||
Brw_SetFullPathInTree ();
|
||||
|
||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||
{
|
||||
|
@ -4542,7 +4551,7 @@ static bool Svc_WriteRowFileBrowser (unsigned Level,Brw_FileType_t FileType,cons
|
|||
if (Gbl.FileBrowser.Type == Brw_SHOW_DOC_CRS ||
|
||||
Gbl.FileBrowser.Type == Brw_SHOW_DOC_GRP)
|
||||
if (Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (FileType,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree))
|
||||
Gbl.FileBrowser.FilFolLnk.Full))
|
||||
return false;
|
||||
|
||||
/***** XML row *****/
|
||||
|
@ -4562,7 +4571,7 @@ static bool Svc_WriteRowFileBrowser (unsigned Level,Brw_FileType_t FileType,cons
|
|||
if (FileMetadata.FilCod <= 0) // No entry for this file in database table of files
|
||||
/* Add entry to the table of files/folders */
|
||||
FileMetadata.FilCod = Brw_AddPathToDB (-1L,FileMetadata.FileType,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree,false,Brw_LICENSE_DEFAULT);
|
||||
Gbl.FileBrowser.FilFolLnk.Full,false,Brw_LICENSE_DEFAULT);
|
||||
|
||||
Gbl.Usrs.Other.UsrDat.UsrCod = FileMetadata.PublisherUsrCod;
|
||||
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&Gbl.Usrs.Other.UsrDat,Usr_DONT_GET_PREFS);
|
||||
|
@ -4692,7 +4701,8 @@ int swad__getFile (struct soap *soap,
|
|||
"Requester must belong to group");
|
||||
|
||||
/***** Check if file is in a valid zone *****/
|
||||
switch ((Gbl.FileBrowser.Type = FileMetadata.FileBrowser))
|
||||
Gbl.FileBrowser.Type = FileMetadata.FileBrowser;
|
||||
switch (Gbl.FileBrowser.Type)
|
||||
{
|
||||
case Brw_ADMI_DOC_CRS:
|
||||
case Brw_ADMI_DOC_GRP:
|
||||
|
@ -4704,8 +4714,8 @@ int swad__getFile (struct soap *soap,
|
|||
// Downloading a file of marks is only allowed for teachers
|
||||
if (Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role != Rol_TCH)
|
||||
return soap_receiver_fault (Gbl.soap,
|
||||
"Wrong tree",
|
||||
"Wrong file zone");
|
||||
"Wrong tree",
|
||||
"Wrong file zone");
|
||||
break;
|
||||
default:
|
||||
return soap_sender_fault (Gbl.soap,
|
||||
|
@ -4715,9 +4725,12 @@ int swad__getFile (struct soap *soap,
|
|||
|
||||
/***** Set paths *****/
|
||||
Hie_InitHierarchy ();
|
||||
Brw_SetFullPathInTree (FileMetadata.PathInTreeUntilFilFolLnk,
|
||||
FileMetadata.FilFolLnkName);
|
||||
Brw_InitializeFileBrowser ();
|
||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Path,FileMetadata.PathInTreeUntilFilFolLnk,
|
||||
PATH_MAX);
|
||||
Str_Copy (Gbl.FileBrowser.FilFolLnk.Name,FileMetadata.FilFolLnkName,
|
||||
NAME_MAX);
|
||||
Brw_SetFullPathInTree ();
|
||||
|
||||
/***** Get file size and date *****/
|
||||
Brw_GetFileTypeSizeAndDate (&FileMetadata);
|
||||
|
|
|
@ -374,13 +374,13 @@ static void ZIP_CompressFolderIntoZIP (void)
|
|||
snprintf (Path,sizeof (Path),
|
||||
"%s/%s",
|
||||
Gbl.FileBrowser.Priv.PathAboveRootFolder,
|
||||
Gbl.FileBrowser.Priv.FullPathInTree);
|
||||
Gbl.FileBrowser.FilFolLnk.Full);
|
||||
snprintf (PathCompression,sizeof (PathCompression),
|
||||
"%s/%s",
|
||||
Cfg_PATH_ZIP_PRIVATE,
|
||||
Gbl.FileBrowser.ZIP.TmpDir); // Example: /var/www/swad/zip/<temporary_dir>
|
||||
|
||||
UncompressedSize = ZIP_CloneDir (Path,PathCompression,Gbl.FileBrowser.Priv.FullPathInTree);
|
||||
UncompressedSize = ZIP_CloneDir (Path,PathCompression,Gbl.FileBrowser.FilFolLnk.Full);
|
||||
|
||||
if (UncompressedSize == 0) // Nothing to compress
|
||||
Ale_ShowAlert (Ale_WARNING,Txt_The_folder_is_empty);
|
||||
|
@ -396,7 +396,7 @@ static void ZIP_CompressFolderIntoZIP (void)
|
|||
/***** Create public zip file with the assignment and works *****/
|
||||
snprintf (FileNameZIP,sizeof (FileNameZIP),
|
||||
"%s.zip",
|
||||
strcmp (Gbl.FileBrowser.FilFolLnkName,".") ? Gbl.FileBrowser.FilFolLnkName :
|
||||
strcmp (Gbl.FileBrowser.FilFolLnk.Name,".") ? Gbl.FileBrowser.FilFolLnk.Name :
|
||||
Txt_ROOT_FOLDER_EXTERNAL_NAMES[Gbl.FileBrowser.Type]);
|
||||
snprintf (PathFileZIP,sizeof (PathFileZIP),
|
||||
"%s/%s/%s/%s",
|
||||
|
|
Loading…
Reference in New Issue