diff --git a/css/swad15.188.css b/css/swad15.189.2.css similarity index 99% rename from css/swad15.188.css rename to css/swad15.189.2.css index 37550e86c..b927309a4 100644 --- a/css/swad15.188.css +++ b/css/swad15.189.2.css @@ -1945,7 +1945,8 @@ a:hover img.CENTRE_PHOTO_SHOW .SOCIAL_IMG_TIT_POST { box-sizing:border-box; - width:480px; + width:440px; + margin-bottom:10px; } .SOCIAL_TXT { @@ -2061,6 +2062,7 @@ a:hover img.CENTRE_PHOTO_SHOW { box-sizing:border-box; width:440px; + margin-bottom:10px; } /*********************************** Messages ********************************/ diff --git a/js/swad15.186.js b/js/swad15.186.js index 31dbc92bc..3db867951 100644 --- a/js/swad15.186.js +++ b/js/swad15.186.js @@ -635,13 +635,14 @@ function expandTextarea (textareaElem,idButton,rows) { } // Contract textarea when focus. Called from a textarea onblur +/* function contractTextarea (textareaElem,idButton,rows) { if (textareaElem.value == '') { document.getElementById(idButton).style.display = 'none'; textareaElem.rows = rows; } } - +*/ // Change display of a test answer function toggleAnswer (option) { toggleDisplay('ans_' + option); diff --git a/swad_changelog.h b/swad_changelog.h index 7f79a2ee6..411f0bf11 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -133,14 +133,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.189.1 (2016-04-08)" -#define CSS_FILE "swad15.188.css" +#define Log_PLATFORM_VERSION "SWAD 15.189.2 (2016-04-08)" +#define CSS_FILE "swad15.189.2.css" #define JS_FILE "swad15.186.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.189.2: Apr 08, 2016 Remove file of the image attached to a social post when the post is removed. (? lines) + Version 15.189.2: Apr 08, 2016 Remove file of the image attached to a social post when the post is removed. (199017 lines) Version 15.189.1: Apr 08, 2016 Change in layout of form to write a new social post. (198997 lines) Version 15.189: Apr 08, 2016 Get image attached to a social post. (198991 lines) 2 changes necessary in database: diff --git a/swad_file.c b/swad_file.c index 4e38ecb49..16d268e87 100644 --- a/swad_file.c +++ b/swad_file.c @@ -231,14 +231,6 @@ struct Param *Fil_StartReceptionOfFile (const char *ParamFile, /***** Get parameter *****/ Par_GetParameter (Par_PARAM_SINGLE,ParamFile,NULL,Fil_MAX_FILE_SIZE,&Param); - Lay_ShowAlert (Lay_ERROR,ParamFile); // !!!!!!!!!!!!!! - - Lay_ShowAlert (Lay_ERROR,"Fil_StartReceptionOfFile () - 0"); // !!!!!!!!!!!!!! - - sprintf (Gbl.Message,"Param->FileName.Start = %lu Param->FileName.Length = %lu", - Param->FileName.Start,Param->FileName.Length); - Lay_ShowAlert (Lay_ERROR,Gbl.Message); // !!!!!!!!!!!!!! - /***** Get filename *****/ /* Check if filename exists */ if (Param->FileName.Start == 0 || @@ -249,14 +241,12 @@ struct Param *Fil_StartReceptionOfFile (const char *ParamFile, } if (Param->FileName.Length > PATH_MAX) Lay_ShowErrorAndExit ("Error while getting filename."); - Lay_ShowAlert (Lay_ERROR,"Fil_StartReceptionOfFile () - 1"); // !!!!!!!!!!!!!! /* Copy filename */ fseek (Gbl.F.Tmp,Param->FileName.Start,SEEK_SET); if (fread (FileName,sizeof (char),Param->FileName.Length,Gbl.F.Tmp) != Param->FileName.Length) Lay_ShowErrorAndExit ("Error while getting filename."); - Lay_ShowAlert (Lay_ERROR,"Fil_StartReceptionOfFile () - 2"); // !!!!!!!!!!!!!! /***** Get MIME type *****/ /* Check if MIME type exists */ @@ -264,7 +254,6 @@ struct Param *Fil_StartReceptionOfFile (const char *ParamFile, Param->ContentType.Length == 0 || Param->ContentType.Length > Brw_MAX_BYTES_MIME_TYPE) Lay_ShowErrorAndExit ("Error while getting content type."); - Lay_ShowAlert (Lay_ERROR,"Fil_StartReceptionOfFile () - 3"); // !!!!!!!!!!!!!! /* Copy MIME type */ fseek (Gbl.F.Tmp,Param->ContentType.Start,SEEK_SET); @@ -272,7 +261,6 @@ struct Param *Fil_StartReceptionOfFile (const char *ParamFile, Param->ContentType.Length) Lay_ShowErrorAndExit ("Error while getting content type."); MIMEType[Param->ContentType.Length] = '\0'; - Lay_ShowAlert (Lay_ERROR,"Fil_StartReceptionOfFile () - 4"); // !!!!!!!!!!!!!! return Param; } diff --git a/swad_social.c b/swad_social.c index 5b6510b54..95f7fe1f8 100644 --- a/swad_social.c +++ b/swad_social.c @@ -218,6 +218,7 @@ static long Soc_UnfavSocialComment (void); static void Soc_RequestRemovalSocialNote (void); static void Soc_RemoveSocialNote (void); +static void Soc_RemoveImgFileFromSocialPost (long PstCod); static void Soc_RemoveASocialNoteFromDB (struct SocialNote *SocNot); static long Soc_GetNotCodOfSocialPublishing (long PubCod); @@ -2012,12 +2013,13 @@ static void Soc_PutTextarea (const char *Placeholder, fprintf (Gbl.F.Out,"", Soc_MAX_CHARS_IN_POST, Placeholder,ClassTextArea, - IdDivImgButton,IdDivImgButton); + // IdDivImgButton, + IdDivImgButton); /***** Start concealable div *****/ fprintf (Gbl.F.Out,"
", @@ -2053,8 +2055,7 @@ static void Soc_PutTextarea (const char *Placeholder, fprintf (Gbl.F.Out,"" - "
", + "", Txt_Post); /***** End hidden div *****/ @@ -3553,7 +3554,11 @@ static void Soc_RemoveSocialNote (void) if (Gbl.Usrs.Me.Logged && SocNot.UsrCod == Gbl.Usrs.Me.UsrDat.UsrCod) // I am the author of this note { - /***** Delete social publishing from database *****/ + if (SocNot.NoteType == Soc_NOTE_SOCIAL_POST) + /***** Remove image file associated to social post *****/ + Soc_RemoveImgFileFromSocialPost (SocNot.Cod); + + /***** Delete social note from database *****/ Soc_RemoveASocialNoteFromDB (&SocNot); /***** Message of success *****/ @@ -3564,6 +3569,32 @@ static void Soc_RemoveSocialNote (void) Lay_ShowAlert (Lay_WARNING,Txt_The_original_post_no_longer_exists); } +/*****************************************************************************/ +/************** Remove one file associated to a social post ******************/ +/*****************************************************************************/ + +static void Soc_RemoveImgFileFromSocialPost (long PstCod) + { + char Query[128]; + MYSQL_RES *mysql_res; + MYSQL_ROW row; + + /***** Get name of image associated to a social post from database *****/ + sprintf (Query,"SELECT ImageName FROM social_posts WHERE PstCod='%ld'", + PstCod); + if (DB_QuerySELECT (Query,&mysql_res,"can not get image")) + { + /***** Get image name (row[0]) *****/ + row = mysql_fetch_row (mysql_res); + + /***** Remove image file *****/ + Img_RemoveImageFile (row[0]); + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + /*****************************************************************************/ /******************* Remove a social note from database **********************/ /*****************************************************************************/ diff --git a/swad_test.c b/swad_test.c index a0494d598..b832cec56 100644 --- a/swad_test.c +++ b/swad_test.c @@ -6122,7 +6122,7 @@ static void Tst_RemoveImgFileFromStemOfQst (long CrsCod,long QstCod) sprintf (Query,"SELECT ImageName FROM tst_questions" " WHERE QstCod='%ld' AND CrsCod='%ld'", QstCod,CrsCod); - if (DB_QuerySELECT (Query,&mysql_res,"can not get test images")) + if (DB_QuerySELECT (Query,&mysql_res,"can not get image")) { /***** Get image name (row[0]) *****/ row = mysql_fetch_row (mysql_res); @@ -6152,7 +6152,7 @@ static void Tst_RemoveAllImgFilesFromStemOfAllQstsInCrs (long CrsCod) sprintf (Query,"SELECT ImageName FROM tst_questions" " WHERE CrsCod='%ld'", CrsCod); - NumImages = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get test images"); + NumImages = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get images"); /***** Go over result removing image files *****/ for (NumImg = 0; @@ -6189,7 +6189,7 @@ static void Tst_RemoveImgFileFromAnsOfQst (long CrsCod,long QstCod,unsigned AnsI " AND tst_answers.QstCod='%ld'" " AND tst_answers.AnsInd='%u'", CrsCod,QstCod,QstCod,AnsInd); - if (DB_QuerySELECT (Query,&mysql_res,"can not get test images")) + if (DB_QuerySELECT (Query,&mysql_res,"can not get images")) { /***** Get image name (row[0]) *****/ row = mysql_fetch_row (mysql_res); @@ -6222,7 +6222,7 @@ static void Tst_RemoveAllImgFilesFromAnsOfQst (long CrsCod,long QstCod) " AND tst_questions.QstCod=tst_answers.QstCod" " AND tst_answers.QstCod='%ld'", CrsCod,QstCod,QstCod); - NumImages = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get test images"); + NumImages = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get images"); /***** Go over result removing image files *****/ for (NumImg = 0; @@ -6259,7 +6259,7 @@ static void Tst_RemoveAllImgFilesFromAnsOfAllQstsInCrs (long CrsCod) " WHERE tst_questions.CrsCod='%ld'" " AND tst_questions.QstCod=tst_answers.QstCod", CrsCod); - NumImages = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get test images"); + NumImages = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get images"); /***** Go over result removing image files *****/ for (NumImg = 0;