diff --git a/Makefile b/Makefile index e8e9ffdb..720cf6a8 100644 --- a/Makefile +++ b/Makefile @@ -62,9 +62,10 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \ swad_tab.o swad_tag.o swad_test.o swad_test_config.o \ swad_test_import.o swad_test_print.o swad_test_visibility.o \ swad_theme.o \ - swad_timeline.o swad_timeline_comment.o swad_timeline_favourite.o \ - swad_timeline_form.o swad_timeline_note.o swad_timeline_notification.o \ - swad_timeline_post.o swad_timeline_publication.o swad_timeline_share.o \ + swad_timeline.o swad_timeline_comment.o swad_timeline_database.o \ + swad_timeline_favourite.o swad_timeline_form.o swad_timeline_note.o \ + swad_timeline_notification.o swad_timeline_post.o \ + swad_timeline_publication.o swad_timeline_share.o \ swad_timeline_user.o swad_timeline_who.o \ swad_timetable.o \ swad_user.o \ diff --git a/swad_changelog.h b/swad_changelog.h index 60739612..ed47e4ea 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -553,7 +553,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 20.35.1 (2021-02-23)" +#define Log_PLATFORM_VERSION "SWAD 20.36 (2021-02-26)" #define CSS_FILE "swad20.33.9.css" #define JS_FILE "swad20.6.2.js" /* @@ -601,6 +601,7 @@ TODO: DNI de un estudiante sale err TODO: BUG: Cuando un tipo de grupo sólo tiene un grupo, inscribirse es voluntario, el estudiante sólo puede pertenecer a un grupo, y se inscribe en él, debería poder desapuntarse. Ahora no puede. TODO: Salvador Romero Cortés: @acanas opción para editar posts + Version 20.36: Feb 26, 2021 New module swad_timeline_database. (305133 lines) Version 20.35.1: Feb 23, 2021 Code refactoring in timeline related to sharing and faving. (305021 lines) Version 20.35: Feb 23, 2021 Code refactoring in timeline related to sharing and faving. (304986 lines) Version 20.34.1: Feb 23, 2021 Code refactoring in timeline related to sharing and faving. (305009 lines) diff --git a/swad_timeline_comment.c b/swad_timeline_comment.c index 0b5e6a10..2f898ecb 100644 --- a/swad_timeline_comment.c +++ b/swad_timeline_comment.c @@ -36,6 +36,7 @@ #include "swad_photo.h" #include "swad_profile.h" #include "swad_timeline.h" +#include "swad_timeline_database.h" #include "swad_timeline_favourite.h" #include "swad_timeline_form.h" #include "swad_timeline_note.h" @@ -220,7 +221,11 @@ void TL_Com_WriteCommentsInNote (const struct TL_Timeline *Timeline, NumFinalCommentsToGet = TL_Com_NUM_VISIBLE_COMMENTS; } - /***** Get last comments of this note from database *****/ + /***** Get final comments of this note from database *****/ + NumFinalCommentsGot = TL_DB_GetFinalComments (Not->NotCod, + NumFinalCommentsToGet, + &mysql_res); + /* NumFinalCommentsGot = (unsigned) DB_QuerySELECT (&mysql_res,"can not get comments", "SELECT * FROM " @@ -241,7 +246,7 @@ void TL_Com_WriteCommentsInNote (const struct TL_Timeline *Timeline, " ORDER BY PubCod", Not->NotCod,(unsigned) TL_Pub_COMMENT_TO_NOTE, NumFinalCommentsToGet); - + */ /* Before clicking "See prev..." --> After clicking "See prev..." _________________________________ _________________________________ diff --git a/swad_timeline_database.c b/swad_timeline_database.c new file mode 100644 index 00000000..e3341b21 --- /dev/null +++ b/swad_timeline_database.c @@ -0,0 +1,81 @@ +// swad_timeline_database.c: social timeline operations with database + +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Cañas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General 3 License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/*********************************** Headers *********************************/ +/*****************************************************************************/ + +#include "swad_database.h" +#include "swad_timeline.h" +#include "swad_timeline_publication.h" + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************************* Private constants and types ***********************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************** External global variables from others modules ****************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************************* Private global variables **************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private prototypes ****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/*************** Get final comments of a note from database ******************/ +/*****************************************************************************/ + +unsigned TL_DB_GetFinalComments (long NotCod, + unsigned NumFinalCommentsToGet, + MYSQL_RES **mysql_res) + { + /***** Get final comments of a note from database *****/ + return (unsigned) + DB_QuerySELECT (mysql_res,"can not get comments", + "SELECT * FROM " + "(" + "SELECT tl_pubs.PubCod," // row[0] + "tl_pubs.PublisherCod," // row[1] + "tl_pubs.NotCod," // row[2] + "UNIX_TIMESTAMP(" + "tl_pubs.TimePublish)," // row[3] + "tl_comments.Txt," // row[4] + "tl_comments.MedCod" // row[5] + " FROM tl_pubs,tl_comments" + " WHERE tl_pubs.NotCod=%ld" + " AND tl_pubs.PubType=%u" + " AND tl_pubs.PubCod=tl_comments.PubCod" + " ORDER BY tl_pubs.PubCod DESC LIMIT %u" + ") AS comments" + " ORDER BY PubCod", + NotCod,(unsigned) TL_Pub_COMMENT_TO_NOTE, + NumFinalCommentsToGet); + } diff --git a/swad_timeline_database.h b/swad_timeline_database.h new file mode 100644 index 00000000..1a88ed95 --- /dev/null +++ b/swad_timeline_database.h @@ -0,0 +1,48 @@ +// swad_timeline_database.h: social timeline operations with database + +#ifndef _SWAD_TL_DB +#define _SWAD_TL_DB +/* + SWAD (Shared Workspace At a Distance in Spanish), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2021 Antonio Cañas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************** Headers **********************************/ +/*****************************************************************************/ + +#include "swad_database.h" + +/*****************************************************************************/ +/****************************** Public constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/******************************** Public types *******************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/****************************** Public prototypes ****************************/ +/*****************************************************************************/ + +unsigned TL_DB_GetFinalComments (long NotCod, + unsigned NumFinalCommentsToGet, + MYSQL_RES **mysql_res); + +#endif