diff --git a/swad_changelog.h b/swad_changelog.h index c61d5b2f1..c5a095591 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -140,14 +140,15 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.175.1 (2016-04-03)" +#define Log_PLATFORM_VERSION "SWAD 15.175.2 (2016-04-03)" #define CSS_FILE "swad15.173.1.css" #define JS_FILE "swad15.131.3.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 15.175.2: Apr 03, 2016 Check button to remove image when editing one test question. (? lines) + Version 15.175.3: Apr 03, 2016 Check button to remove image when editing one test question. (? lines) + Version 15.175.2: Apr 03, 2016 Code refactoring related to deleting image file. (197773 lines) Version 15.175.1: Apr 03, 2016 Code refactoring related to deleting tests of a course. (197763 lines) Version 15.175: Apr 03, 2016 Fixed bug when editing a test question. Lot of code refactoring related to edition of questions. diff --git a/swad_image.c b/swad_image.c index 2cfc4a9c8..5c607fff2 100644 --- a/swad_image.c +++ b/swad_image.c @@ -265,3 +265,23 @@ void Img_ShowImage (const char *Image,const char *ClassImg) URL,ClassImg); } +/*****************************************************************************/ +/** Remove private file with an image, given the image name (without .jpg) ***/ +/*****************************************************************************/ + +void Img_RemoveImageFile (const char *ImageName) + { + char FullPathImgPriv[PATH_MAX+1]; + + /***** Build path to private file *****/ + sprintf (FullPathImgPriv,"%s/%s/%c%c/%s.jpg", + Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG, + ImageName[0], + ImageName[1], + ImageName); + + /***** Remove private file *****/ + unlink (FullPathImgPriv); + + // Public links are removed automatically after a period + } diff --git a/swad_image.h b/swad_image.h index 258830e28..05fa23b2f 100644 --- a/swad_image.h +++ b/swad_image.h @@ -74,5 +74,6 @@ typedef enum void Img_GetImageFromForm (unsigned Width,unsigned Height,unsigned Quality); void Img_MoveImageToDefinitiveDirectory (void); void Img_ShowImage (const char *Image,const char *ClassImg); +void Img_RemoveImageFile (const char *ImageName); #endif diff --git a/swad_test.c b/swad_test.c index ee8b464a4..ee73e049b 100644 --- a/swad_test.c +++ b/swad_test.c @@ -5476,7 +5476,6 @@ void Tst_RemoveImageFilesFromQstsInCrs (long CrsCod, MYSQL_ROW row; unsigned NumImages; unsigned NumImg; - char FullPathImgPriv[PATH_MAX+1]; /***** Get names of images associated to test questions from database *****/ if (QstCod > 0) // Only one question @@ -5497,17 +5496,8 @@ void Tst_RemoveImageFilesFromQstsInCrs (long CrsCod, /***** Get image name (row[0]) *****/ row = mysql_fetch_row (mysql_res); - /***** Build path to private file *****/ - sprintf (FullPathImgPriv,"%s/%s/%c%c/%s.jpg", - Cfg_PATH_SWAD_PRIVATE,Cfg_FOLDER_IMG, - row[0][0], - row[0][1], - row[0]); - - /***** Remove private file *****/ - unlink (FullPathImgPriv); - - // Public links are removed automatically after a period + /***** Remove image file *****/ + Img_RemoveImageFile (row[0]); } /***** Free structure that stores the query result *****/