Version18.81.1

This commit is contained in:
Antonio Cañas Vargas 2019-03-18 19:35:23 +01:00
parent 12b56ef03c
commit eec09b697d
5 changed files with 79 additions and 94 deletions

View File

@ -459,7 +459,7 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.81 (2019-03-18)"
#define Log_PLATFORM_VERSION "SWAD 18.81.1 (2019-03-18)"
#define CSS_FILE "swad18.80.css"
#define JS_FILE "swad18.80.js"
/*
@ -473,6 +473,7 @@ TODO: Remove unused fields MediaName,MediaType,MediaTitle,MediaURL,Media from ta
// ALTER TABLE tst_questions DROP COLUMN MediaName,DROP COLUMN MediaType,DROP COLUMN MediaTitle,DROP COLUMN MediaURL;
// ALTER TABLE media DROP COLUMN T,DROP COLUMN Cod;
Version 18.81.1: Mar 18, 2019 Code refactoring related to media. (240691 lines)
Version 18.81: Mar 18, 2019 New database table media to store images and videos.
Fixed bugs in removal of publications in timeline. (240704 lines)
1 change necessary in database:

View File

@ -1596,32 +1596,32 @@ static void Med_ShowYoutube (struct Media *Media,const char *ClassMedia)
}
/*****************************************************************************/
/**************** Remove media files and entries in database *****************/
/********** Remove several media files and entries in database ***************/
/*****************************************************************************/
void Med_RemoveMediaFromAllRows (unsigned NumMedia,MYSQL_RES *mysql_res)
{
MYSQL_ROW row;
unsigned NumMed;
long MedCod;
/***** Go over result removing media files *****/
for (NumMed = 0;
NumMed < NumMedia;
NumMed++)
Med_RemoveMediaFromRow (mysql_res);
{
/***** Get media code (row[0]) *****/
row = mysql_fetch_row (mysql_res);
MedCod = Str_ConvertStrCodToLongCod (row[0]);
/***** Remove media files *****/
Med_RemoveMedia (MedCod);
}
}
void Med_RemoveMediaFromRow (MYSQL_RES *mysql_res)
{
MYSQL_ROW row;
long MedCod;
/***** Get media code (row[0]) *****/
row = mysql_fetch_row (mysql_res);
MedCod = Str_ConvertStrCodToLongCod (row[0]);
/***** Remove media files *****/
Med_RemoveMedia (MedCod);
}
/*****************************************************************************/
/********** Remove one media from filesystem and from database ***************/
/*****************************************************************************/
void Med_RemoveMedia (long MedCod)
{
@ -1636,11 +1636,11 @@ void Med_RemoveMedia (long MedCod)
/***** Initialize media *****/
Med_MediaConstructor (&Media);
/***** Get media *****/
/***** Get media data *****/
Media.MedCod = MedCod;
Med_GetMediaDataByCod (&Media);
/***** Step 1. Remove files *****/
/***** Step 1. Remove media files from filesystem *****/
if (Media.Type != Med_TYPE_NONE &&
Media.Type != Med_YOUTUBE &&
Media.Name[0])

View File

@ -152,7 +152,6 @@ void Med_ShowMedia (struct Media *Media,
const char *ClassContainer,const char *ClassMedia);
void Med_RemoveMediaFromAllRows (unsigned NumMedia,MYSQL_RES *mysql_res);
void Med_RemoveMediaFromRow (MYSQL_RES *mysql_res);
void Med_RemoveMedia (long MedCod);
#endif

View File

@ -281,9 +281,9 @@ static void Tst_RemAnsFromQst (void);
static void Tst_RemTagsFromQst (void);
static void Tst_RemoveUnusedTagsFromCurrentCrs (void);
static void Tst_RemoveMedFileFromStemOfQst (long CrsCod,long QstCod);
static void Tst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod);
static void Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod);
static void Tst_RemoveMedFileFromAnsOfQst (long CrsCod,long QstCod,unsigned AnsInd);
static void Tst_RemoveMediaFromAnsOfQst (long CrsCod,long QstCod,unsigned AnsInd);
static void Tst_RemoveAllMedFilesFromAnsOfQst (long CrsCod,long QstCod);
static void Tst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod);
@ -6142,7 +6142,7 @@ static void Tst_MoveMediaToDefinitiveDirectories (void)
/* Remove possible file with the old image
(the new image file is already processed
and moved to the definitive directory) */
Tst_RemoveMedFileFromStemOfQst (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod);
Tst_RemoveMediaFromStemOfQst (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod);
Gbl.Test.Media.MedCod = -1L;
if (Gbl.Test.Media.Action == Med_ACTION_NEW_MEDIA && // New media
@ -6168,7 +6168,7 @@ static void Tst_MoveMediaToDefinitiveDirectories (void)
/* Remove possible file with the old image
(the new image file is already processed
and moved to the definitive directory) */
Tst_RemoveMedFileFromAnsOfQst (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod,NumOpt);
Tst_RemoveMediaFromAnsOfQst (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod,NumOpt);
Gbl.Test.Answer.Options[NumOpt].Media.MedCod = -1L;
if (Gbl.Test.Answer.Options[NumOpt].Media.Action == Med_ACTION_NEW_MEDIA && // New media
@ -6393,7 +6393,7 @@ void Tst_RemoveQst (void)
/***** Remove images associated to question *****/
Tst_RemoveAllMedFilesFromAnsOfQst (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod);
Tst_RemoveMedFileFromStemOfQst (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod);
Tst_RemoveMediaFromStemOfQst (Gbl.CurrentCrs.Crs.CrsCod,Gbl.Test.QstCod);
/***** Remove the question from all the tables *****/
/* Remove answers and tags from this test question */
@ -6699,29 +6699,31 @@ static void Tst_RemoveUnusedTagsFromCurrentCrs (void)
}
/*****************************************************************************/
/******** Remove one file associated to one stem of one test question ********/
/********** Remove media associated to one stem of one test question *********/
/*****************************************************************************/
static void Tst_RemoveMedFileFromStemOfQst (long CrsCod,long QstCod)
static void Tst_RemoveMediaFromStemOfQst (long CrsCod,long QstCod)
{
MYSQL_RES *mysql_res;
unsigned NumMedia;
/***** Get names of media files associated to stems of test questions from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get image",
"SELECT MedCod" // row[0]
" FROM tst_questions"
" WHERE QstCod=%ld AND CrsCod=%ld",
QstCod,CrsCod))
/***** Remove media file *****/
Med_RemoveMediaFromRow (mysql_res);
/***** Get media codes associated to stem of a test question from database *****/
NumMedia =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
"SELECT MedCod" // row[0]
" FROM tst_questions"
" WHERE QstCod=%ld AND CrsCod=%ld",
QstCod,CrsCod);
/***** Remove media *****/
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/****** Remove all image files associated to stems of all test questions *****/
/****** in a course *****/
/** Remove all media associated to stems of all test questions in a course ***/
/*****************************************************************************/
static void Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod)
@ -6729,7 +6731,7 @@ static void Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod)
MYSQL_RES *mysql_res;
unsigned NumMedia;
/***** Get names of images associated to stems of test questions from database *****/
/***** Get media codes associated to stems of test questions from database *****/
NumMedia =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
"SELECT MedCod" // row[0]
@ -6745,32 +6747,35 @@ static void Tst_RemoveAllMedFilesFromStemOfAllQstsInCrs (long CrsCod)
}
/*****************************************************************************/
/**** Remove one image file associated to one answer of one test question ****/
/********* Remove media associated to one answer of a test question **********/
/*****************************************************************************/
static void Tst_RemoveMedFileFromAnsOfQst (long CrsCod,long QstCod,unsigned AnsInd)
static void Tst_RemoveMediaFromAnsOfQst (long CrsCod,long QstCod,unsigned AnsInd)
{
MYSQL_RES *mysql_res;
unsigned NumMedia;
/***** Get names of media files associated to answers of test questions from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get images",
"SELECT tst_answers.MedCod" // row[0]
" FROM tst_questions,tst_answers"
" WHERE tst_questions.CrsCod=%ld"// Extra check
" AND tst_questions.QstCod=%ld" // Extra check
" AND tst_questions.QstCod=tst_answers.QstCod"
" AND tst_answers.QstCod=%ld"
" AND tst_answers.AnsInd=%u",
CrsCod,QstCod,QstCod,AnsInd))
/***** Remove media file *****/
Med_RemoveMediaFromRow (mysql_res);
/***** Get media codes associated to an answer of a test question from database *****/
NumMedia =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
"SELECT tst_answers.MedCod" // row[0]
" FROM tst_questions,tst_answers"
" WHERE tst_questions.CrsCod=%ld"// Extra check
" AND tst_questions.QstCod=%ld" // Extra check
" AND tst_questions.QstCod=tst_answers.QstCod"
" AND tst_answers.QstCod=%ld"
" AND tst_answers.AnsInd=%u",
CrsCod,QstCod,QstCod,AnsInd);
/***** Go over result removing media files *****/
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/*** Remove all image files associated to all answers of one test question ***/
/******* Remove all media associated to all answers of a test question *******/
/*****************************************************************************/
static void Tst_RemoveAllMedFilesFromAnsOfQst (long CrsCod,long QstCod)
@ -6778,7 +6783,7 @@ static void Tst_RemoveAllMedFilesFromAnsOfQst (long CrsCod,long QstCod)
MYSQL_RES *mysql_res;
unsigned NumMedia;
/***** Get names of media files associated to answers of test questions from database *****/
/***** Get media codes associated to answers of test questions from database *****/
NumMedia =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
"SELECT tst_answers.MedCod" // row[0]
@ -6789,7 +6794,7 @@ static void Tst_RemoveAllMedFilesFromAnsOfQst (long CrsCod,long QstCod)
" AND tst_answers.QstCod=%ld",
CrsCod,QstCod,QstCod);
/***** Go over result removing media files *****/
/***** Go over result removing media *****/
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
/***** Free structure that stores the query result *****/
@ -6797,8 +6802,7 @@ static void Tst_RemoveAllMedFilesFromAnsOfQst (long CrsCod,long QstCod)
}
/*****************************************************************************/
/** Remove all media files associated to all answers of all test questions ***/
/** in a course ***/
/* Remove media associated to all answers of all test questions in a course **/
/*****************************************************************************/
static void Tst_RemoveAllMedFilesFromAnsOfAllQstsInCrs (long CrsCod)

View File

@ -234,7 +234,6 @@ static void TL_UnfavComment (struct TL_Comment *SocCom);
static void TL_RequestRemovalNote (void);
static void TL_PutParamsRemoveNote (void);
static void TL_RemoveNote (void);
static void TL_RemoveMediaFromPost (long PstCod);
static void TL_RemoveNoteMediaAndDBEntries (struct TL_Note *SocNot);
static long TL_GetNotCodOfPublication (long PubCod);
@ -3868,27 +3867,6 @@ static void TL_RemoveNote (void)
Ale_ShowAlert (Ale_WARNING,Txt_The_original_post_no_longer_exists);
}
/*****************************************************************************/
/***************** Remove one file associated to a post **********************/
/*****************************************************************************/
static void TL_RemoveMediaFromPost (long PstCod)
{
MYSQL_RES *mysql_res;
/***** Get name of media associated to a post from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get image",
"SELECT MedCod" // row[0]
" FROM social_posts"
" WHERE PstCod=%ld",
PstCod))
/***** Remove media file *****/
Med_RemoveMediaFromRow (mysql_res);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
/*****************************************************************************/
/*********************** Remove a note from database *************************/
/*****************************************************************************/
@ -3900,6 +3878,7 @@ static void TL_RemoveNoteMediaAndDBEntries (struct TL_Note *SocNot)
long PubCod;
unsigned long NumComments;
unsigned long NumCom;
unsigned NumMedia;
/***** Remove comments associated to this note *****/
/* Get comments of this note */
@ -3930,17 +3909,16 @@ static void TL_RemoveNoteMediaAndDBEntries (struct TL_Note *SocNot)
/***** Remove media associated to post *****/
if (SocNot->NoteType == TL_NOTE_POST)
{
TL_RemoveMediaFromPost (SocNot->Cod);
MYSQL_RES *mysql_res;
/* Get name of media associated to a post from database */
if (DB_QuerySELECT (&mysql_res,"can not get image",
"SELECT MedCod" // row[0]
" FROM social_posts"
" WHERE PstCod=%ld",
SocNot->Cod))
/* Remove media */
Med_RemoveMediaFromRow (mysql_res);
NumMedia =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
"SELECT MedCod" // row[0]
" FROM social_posts"
" WHERE PstCod=%ld",
SocNot->Cod);
/* Remove media */
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);
@ -4212,16 +4190,19 @@ static void TL_RemoveComment (void)
static void TL_RemoveCommentMediaAndDBEntries (long PubCod)
{
MYSQL_RES *mysql_res;
unsigned NumMedia;
/***** Remove media associated to comment *****/
/* Get name of media associated to a comment from database */
if (DB_QuerySELECT (&mysql_res,"can not get media",
"SELECT MedCod" // row[0]
" FROM social_comments"
" WHERE PubCod=%ld",
PubCod))
/* Remove media */
Med_RemoveMediaFromRow (mysql_res);
NumMedia =
(unsigned) DB_QuerySELECT (&mysql_res,"can not get media",
"SELECT MedCod" // row[0]
" FROM social_comments"
" WHERE PubCod=%ld",
PubCod);
/* Remove media */
Med_RemoveMediaFromAllRows (NumMedia,mysql_res);
/* Free structure that stores the query result */
DB_FreeMySQLResult (&mysql_res);