Version 17.21.4

This commit is contained in:
Antonio Cañas Vargas 2017-10-08 02:56:40 +02:00
parent 63410e4c96
commit 790c46c371
4 changed files with 183 additions and 7 deletions

View File

@ -11980,5 +11980,8 @@ AND crs_usr.UsrCod=crs_grp_usr.UsrCod)
) AS available_grp_types; ) AS available_grp_types;
SELECT crs_grp.GrpCod FROM crs_grp,crs_grp_types WHERE crs_grp_types.CrsCod=21 AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod;
DELETE FROM file_view USING file_view,files WHERE files.FileBrowser IN (11,26,5,13) AND files.Cod IN (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp WHERE crs_grp_types.CrsCod=21 AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod) AND files.FilCod=file_view.FilCod;

View File

@ -256,14 +256,17 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 17.21.3 (2017-10-08)" #define Log_PLATFORM_VERSION "SWAD 17.21.4 (2017-10-08)"
#define CSS_FILE "swad17.0.css" #define CSS_FILE "swad17.0.css"
#define JS_FILE "swad17.17.1.js" #define JS_FILE "swad17.17.1.js"
// 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 17.21.3: Oct 08, 2017 Remove project files when removing project. (233169 lines) Version 17.21.4: Oct 08, 2017 Fixed bug: remove group files from database when removing course.
Removed project files from database when removing course.
Fixed bug in project documents. (233330 lines)
Version 17.21.3: Oct 08, 2017 Remove project files from database when removing project. (233169 lines)
Version 17.21.2: Oct 08, 2017 Renamed root folder for project documents. (233115 lines) Version 17.21.2: Oct 08, 2017 Renamed root folder for project documents. (233115 lines)
Version 17.21.1: Oct 08, 2017 Remove project directories when removing project. (233114 lines) Version 17.21.1: Oct 08, 2017 Remove project directories when removing project. (233114 lines)
Version 17.21: Oct 07, 2017 Start and end dates in projects are replaced by time of creation and time of modification. (233106 lines) Version 17.21: Oct 07, 2017 Start and end dates in projects are replaced by time of creation and time of modification. (233106 lines)

View File

@ -2191,6 +2191,12 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
sprintf (Query,"DELETE FROM crs_record_fields WHERE CrsCod=%ld",CrsCod); sprintf (Query,"DELETE FROM crs_record_fields WHERE CrsCod=%ld",CrsCod);
DB_QueryDELETE (Query,"can not remove fields of cards in a course"); DB_QueryDELETE (Query,"can not remove fields of cards in a course");
/***** Remove information related to files in course,
including groups and projects,
so this function must be called
before removing groups and projects *****/
Brw_RemoveCrsFilesFromDB (CrsCod);
/***** Remove assignments of the course *****/ /***** Remove assignments of the course *****/
Asg_RemoveCrsAssignments (CrsCod); Asg_RemoveCrsAssignments (CrsCod);
@ -2258,9 +2264,6 @@ static void Crs_EmptyCourseCompletely (long CrsCod)
CrsCod); CrsCod);
DB_QueryDELETE (Query,"can not remove users from a course"); DB_QueryDELETE (Query,"can not remove users from a course");
/***** Remove information related to files in course *****/
Brw_RemoveCrsFilesFromDB (CrsCod);
/***** Remove directories of the course *****/ /***** Remove directories of the course *****/
sprintf (PathRelCrs,"%s/%s/%ld", sprintf (PathRelCrs,"%s/%s/%ld",
Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod); Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_CRS,CrsCod);

View File

@ -4547,11 +4547,14 @@ void Brw_RemoveDegFilesFromDB (long DegCod)
/*****************************************************************************/ /*****************************************************************************/
/************ Remove files related to a course from the database *************/ /************ Remove files related to a course from the database *************/
/*****************************************************************************/ /*****************************************************************************/
// This function assumes that all the groups in the course have been removed before /* Remove information related to files in course,
including groups and projects,
so this function must be called
before removing groups and projects */
void Brw_RemoveCrsFilesFromDB (long CrsCod) void Brw_RemoveCrsFilesFromDB (long CrsCod)
{ {
char Query[512]; char Query[1024];
/***** Remove format of files of marks *****/ /***** Remove format of files of marks *****/
sprintf (Query,"DELETE FROM marks_properties USING files,marks_properties" sprintf (Query,"DELETE FROM marks_properties USING files,marks_properties"
@ -4563,6 +4566,7 @@ void Brw_RemoveCrsFilesFromDB (long CrsCod)
DB_QueryDELETE (Query,"can not remove the properties of marks associated to a course"); DB_QueryDELETE (Query,"can not remove the properties of marks associated to a course");
/***** Remove from database the entries that store the file views *****/ /***** Remove from database the entries that store the file views *****/
/* Remove from course file zones */
sprintf (Query,"DELETE FROM file_view USING file_view,files" sprintf (Query,"DELETE FROM file_view USING file_view,files"
" WHERE files.FileBrowser IN (%u,%u,%u,%u,%u,%u)" " WHERE files.FileBrowser IN (%u,%u,%u,%u,%u,%u)"
" AND files.Cod=%ld" " AND files.Cod=%ld"
@ -4576,7 +4580,33 @@ void Brw_RemoveCrsFilesFromDB (long CrsCod)
CrsCod); CrsCod);
DB_QueryDELETE (Query,"can not remove file views to files of a course"); DB_QueryDELETE (Query,"can not remove file views to files of a course");
/* Remove from group file zones */
sprintf (Query,"DELETE FROM file_view USING file_view,files"
" WHERE files.FileBrowser IN (%u,%u,%u,%u)"
" AND files.Cod IN"
" (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp"
" WHERE crs_grp_types.CrsCod=%ld"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod)"
" AND files.FilCod=file_view.FilCod",
(unsigned) Brw_ADMI_DOC_GRP,
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP,
CrsCod);
DB_QueryDELETE (Query,"can not remove file views to files of a course");
/* Remove from project file zones */
sprintf (Query,"DELETE FROM file_view USING file_view,files"
" WHERE files.FileBrowser IN (%u)"
" AND files.Cod IN"
" (SELECT PrjCod FROM projects WHERE CrsCod=%ld)"
" AND files.FilCod=file_view.FilCod",
(unsigned) Brw_ADMI_DOC_PRJ,
CrsCod);
DB_QueryDELETE (Query,"can not remove file views to files of a course");
/***** Remove from database expanded folders *****/ /***** Remove from database expanded folders *****/
/* Remove from course file zones */
sprintf (Query,"DELETE LOW_PRIORITY FROM expanded_folders" sprintf (Query,"DELETE LOW_PRIORITY FROM expanded_folders"
" WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)" " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)"
" AND Cod=%ld", " AND Cod=%ld",
@ -4591,7 +4621,31 @@ void Brw_RemoveCrsFilesFromDB (long CrsCod)
CrsCod); CrsCod);
DB_QueryDELETE (Query,"can not remove expanded folders of a course"); DB_QueryDELETE (Query,"can not remove expanded folders of a course");
/* Remove from group file zones */
sprintf (Query,"DELETE LOW_PRIORITY FROM expanded_folders"
" WHERE FileBrowser IN (%u,%u,%u,%u)"
" AND Cod IN"
" (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp"
" WHERE crs_grp_types.CrsCod=%ld"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod)",
(unsigned) Brw_ADMI_DOC_GRP,
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP,
CrsCod);
DB_QueryDELETE (Query,"can not remove expanded folders of a course");
/* Remove from project file zones */
sprintf (Query,"DELETE LOW_PRIORITY FROM expanded_folders"
" WHERE FileBrowser IN (%u)"
" AND Cod IN"
" (SELECT PrjCod FROM projects WHERE CrsCod=%ld)",
(unsigned) Brw_ADMI_DOC_PRJ,
CrsCod);
DB_QueryDELETE (Query,"can not remove expanded folders of a course");
/***** Remove from database the entries that store clipboards *****/ /***** Remove from database the entries that store clipboards *****/
/* Remove from course file zones */
sprintf (Query,"DELETE FROM clipboard" sprintf (Query,"DELETE FROM clipboard"
" WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)" " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u,%u,%u)"
" AND Cod=%ld", " AND Cod=%ld",
@ -4606,9 +4660,33 @@ void Brw_RemoveCrsFilesFromDB (long CrsCod)
CrsCod); CrsCod);
DB_QueryDELETE (Query,"can not remove clipboards related to files of a course"); DB_QueryDELETE (Query,"can not remove clipboards related to files of a course");
/* Remove from group file zones */
sprintf (Query,"DELETE FROM clipboard"
" WHERE FileBrowser IN (%u,%u,%u,%u)"
" AND Cod IN"
" (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp"
" WHERE crs_grp_types.CrsCod=%ld"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod)",
(unsigned) Brw_ADMI_DOC_GRP,
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP,
CrsCod);
DB_QueryDELETE (Query,"can not remove clipboards related to files of a course");
/* Remove from project file zones */
sprintf (Query,"DELETE FROM clipboard"
" WHERE FileBrowser IN (%u)"
" AND Cod IN"
" (SELECT PrjCod FROM projects WHERE CrsCod=%ld)",
(unsigned) Brw_ADMI_DOC_PRJ,
CrsCod);
DB_QueryDELETE (Query,"can not remove clipboards related to files of a course");
/***** Remove from database the entries that store the last time users visited file zones *****/ /***** Remove from database the entries that store the last time users visited file zones *****/
// Assignments and works are stored as one in file_browser_last... // Assignments and works are stored as one in file_browser_last...
// ...because a user views them at the same time // ...because a user views them at the same time
/* Remove from course file zones */
sprintf (Query,"DELETE FROM file_browser_last" sprintf (Query,"DELETE FROM file_browser_last"
" WHERE FileBrowser IN (%u,%u,%u,%u,%u)" " WHERE FileBrowser IN (%u,%u,%u,%u,%u)"
" AND Cod=%ld", " AND Cod=%ld",
@ -4620,7 +4698,31 @@ void Brw_RemoveCrsFilesFromDB (long CrsCod)
CrsCod); CrsCod);
DB_QueryDELETE (Query,"can not remove file last visits to files of a course"); DB_QueryDELETE (Query,"can not remove file last visits to files of a course");
/* Remove from group file zones */
sprintf (Query,"DELETE FROM file_browser_last"
" WHERE FileBrowser IN (%u,%u,%u,%u)"
" AND Cod IN"
" (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp"
" WHERE crs_grp_types.CrsCod=%ld"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod)",
(unsigned) Brw_ADMI_DOC_GRP,
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP,
CrsCod);
DB_QueryDELETE (Query,"can not remove file last visits to files of a course");
/* Remove from project file zones */
sprintf (Query,"DELETE FROM file_browser_last"
" WHERE FileBrowser IN (%u)"
" AND Cod IN"
" (SELECT PrjCod FROM projects WHERE CrsCod=%ld)",
(unsigned) Brw_ADMI_DOC_PRJ,
CrsCod);
DB_QueryDELETE (Query,"can not remove file last visits to files of a course");
/***** Remove from database the entries that store the sizes of the file zones *****/ /***** Remove from database the entries that store the sizes of the file zones *****/
/* Remove from course file zones */
sprintf (Query,"DELETE FROM file_browser_size" sprintf (Query,"DELETE FROM file_browser_size"
" WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u)" " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u)"
" AND Cod=%ld", " AND Cod=%ld",
@ -4633,7 +4735,31 @@ void Brw_RemoveCrsFilesFromDB (long CrsCod)
CrsCod); CrsCod);
DB_QueryDELETE (Query,"can not remove sizes of file zones of a course"); DB_QueryDELETE (Query,"can not remove sizes of file zones of a course");
/* Remove from group file zones */
sprintf (Query,"DELETE FROM file_browser_size"
" WHERE FileBrowser IN (%u,%u,%u,%u)"
" AND Cod IN"
" (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp"
" WHERE crs_grp_types.CrsCod=%ld"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod)",
(unsigned) Brw_ADMI_DOC_GRP,
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP,
CrsCod);
DB_QueryDELETE (Query,"can not remove sizes of file zones of a course");
/* Remove from project file zones */
sprintf (Query,"DELETE FROM file_browser_size"
" WHERE FileBrowser IN (%u)"
" AND Cod IN"
" (SELECT PrjCod FROM projects WHERE CrsCod=%ld)",
(unsigned) Brw_ADMI_DOC_PRJ,
CrsCod);
DB_QueryDELETE (Query,"can not remove sizes of file zones of a course");
/***** Remove from database the entries that store the data files *****/ /***** Remove from database the entries that store the data files *****/
/* Remove from course file zones */
sprintf (Query,"DELETE FROM files" sprintf (Query,"DELETE FROM files"
" WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u)" " WHERE FileBrowser IN (%u,%u,%u,%u,%u,%u)"
" AND Cod=%ld", " AND Cod=%ld",
@ -4645,6 +4771,29 @@ void Brw_RemoveCrsFilesFromDB (long CrsCod)
(unsigned) Brw_ADMI_MRK_CRS, (unsigned) Brw_ADMI_MRK_CRS,
CrsCod); CrsCod);
DB_QueryDELETE (Query,"can not remove files of a course"); DB_QueryDELETE (Query,"can not remove files of a course");
/* Remove from group file zones */
sprintf (Query,"DELETE FROM files"
" WHERE FileBrowser IN (%u,%u,%u,%u)"
" AND Cod IN"
" (SELECT crs_grp.GrpCod FROM crs_grp_types,crs_grp"
" WHERE crs_grp_types.CrsCod=%ld"
" AND crs_grp_types.GrpTypCod=crs_grp.GrpTypCod)",
(unsigned) Brw_ADMI_DOC_GRP,
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP,
CrsCod);
DB_QueryDELETE (Query,"can not remove files of a course");
/* Remove from project file zones */
sprintf (Query,"DELETE FROM files"
" WHERE FileBrowser IN (%u)"
" AND Cod IN"
" (SELECT PrjCod FROM projects WHERE CrsCod=%ld)",
(unsigned) Brw_ADMI_DOC_PRJ,
CrsCod);
DB_QueryDELETE (Query,"can not remove files of a course");
} }
/*****************************************************************************/ /*****************************************************************************/
@ -11177,6 +11326,8 @@ long Brw_GetCodForFiles (void)
case Brw_ADMI_SHR_GRP: case Brw_ADMI_SHR_GRP:
case Brw_ADMI_MRK_GRP: case Brw_ADMI_MRK_GRP:
return Gbl.CurrentCrs.Grps.GrpCod; return Gbl.CurrentCrs.Grps.GrpCod;
case Brw_ADMI_DOC_PRJ:
return Gbl.CurrentCrs.Prjs.PrjCod;
default: default:
return -1L; return -1L;
} }
@ -11220,6 +11371,7 @@ void Brw_GetCrsGrpFromFileMetadata (Brw_FileBrowser_t FileBrowser,long Cod,
{ {
case Brw_ADMI_DOC_INS: case Brw_ADMI_DOC_INS:
case Brw_ADMI_SHR_INS: case Brw_ADMI_SHR_INS:
/* Cod stores the institution code */
*GrpCod = -1L; *GrpCod = -1L;
*CrsCod = -1L; *CrsCod = -1L;
*DegCod = -1L; *DegCod = -1L;
@ -11228,6 +11380,7 @@ void Brw_GetCrsGrpFromFileMetadata (Brw_FileBrowser_t FileBrowser,long Cod,
break; break;
case Brw_ADMI_DOC_CTR: case Brw_ADMI_DOC_CTR:
case Brw_ADMI_SHR_CTR: case Brw_ADMI_SHR_CTR:
/* Cod stores the centre code */
*GrpCod = -1L; *GrpCod = -1L;
*CrsCod = -1L; *CrsCod = -1L;
*DegCod = -1L; *DegCod = -1L;
@ -11237,6 +11390,7 @@ void Brw_GetCrsGrpFromFileMetadata (Brw_FileBrowser_t FileBrowser,long Cod,
break; break;
case Brw_ADMI_DOC_DEG: case Brw_ADMI_DOC_DEG:
case Brw_ADMI_SHR_DEG: case Brw_ADMI_SHR_DEG:
/* Cod stores the degree code */
*GrpCod = -1L; *GrpCod = -1L;
*CrsCod = -1L; *CrsCod = -1L;
*DegCod = Deg.DegCod = Cod; *DegCod = Deg.DegCod = Cod;
@ -11251,6 +11405,7 @@ void Brw_GetCrsGrpFromFileMetadata (Brw_FileBrowser_t FileBrowser,long Cod,
case Brw_ADMI_ASG_USR: case Brw_ADMI_ASG_USR:
case Brw_ADMI_WRK_USR: case Brw_ADMI_WRK_USR:
case Brw_ADMI_MRK_CRS: case Brw_ADMI_MRK_CRS:
/* Cod stores the course code */
*GrpCod = -1L; *GrpCod = -1L;
*CrsCod = Crs.CrsCod = Cod; *CrsCod = Crs.CrsCod = Cod;
Crs_GetDataOfCourseByCod (&Crs); Crs_GetDataOfCourseByCod (&Crs);
@ -11264,6 +11419,7 @@ void Brw_GetCrsGrpFromFileMetadata (Brw_FileBrowser_t FileBrowser,long Cod,
case Brw_ADMI_TCH_GRP: case Brw_ADMI_TCH_GRP:
case Brw_ADMI_SHR_GRP: case Brw_ADMI_SHR_GRP:
case Brw_ADMI_MRK_GRP: case Brw_ADMI_MRK_GRP:
/* Cod stores the group code */
*GrpCod = GrpDat.GrpCod = Cod; *GrpCod = GrpDat.GrpCod = Cod;
Grp_GetDataOfGroupByCod (&GrpDat); Grp_GetDataOfGroupByCod (&GrpDat);
*CrsCod = Crs.CrsCod = GrpDat.CrsCod; *CrsCod = Crs.CrsCod = GrpDat.CrsCod;
@ -11274,6 +11430,17 @@ void Brw_GetCrsGrpFromFileMetadata (Brw_FileBrowser_t FileBrowser,long Cod,
Ctr_GetDataOfCentreByCod (&Ctr); Ctr_GetDataOfCentreByCod (&Ctr);
*InsCod = Ctr.InsCod; *InsCod = Ctr.InsCod;
break; break;
case Brw_ADMI_DOC_PRJ:
/* Cod stores the project code */
*GrpCod = -1L;
*CrsCod = Crs.CrsCod = Prj_GetCourseOfProject (Cod);
Crs_GetDataOfCourseByCod (&Crs);
*DegCod = Deg.DegCod = Crs.DegCod;
Deg_GetDataOfDegreeByCod (&Deg);
*CtrCod = Ctr.CtrCod = Deg.CtrCod;
Ctr_GetDataOfCentreByCod (&Ctr);
*InsCod = Ctr.InsCod;
break;
default: default:
*GrpCod = -1L; *GrpCod = -1L;
*CrsCod = -1L; *CrsCod = -1L;