mirror of https://github.com/acanas/swad-core.git
Version 20.41.1: Mar 03, 2021 Code refactoring in timeline posts.
This commit is contained in:
parent
f0a20654b0
commit
cae52f721c
|
@ -598,10 +598,11 @@ 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
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.41 (2021-03-03)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 20.41.1 (2021-03-03)"
|
||||
#define CSS_FILE "swad20.33.9.css"
|
||||
#define JS_FILE "swad20.6.2.js"
|
||||
/*
|
||||
Version 20.41.1: Mar 03, 2021 Code refactoring in timeline posts. (305563 lines)
|
||||
Version 20.41: Mar 03, 2021 Code refactoring in timeline comments. (305542 lines)
|
||||
Version 20.40.3: Mar 03, 2021 Code refactoring in timeline. (305528 lines)
|
||||
Version 20.40.2: Mar 03, 2021 Code refactoring in fav/share timeline. (305519 lines)
|
||||
|
|
|
@ -1401,7 +1401,8 @@ void Med_ShowMedia (const struct Med_Media *Media,
|
|||
char PathMedPriv[PATH_MAX + 1];
|
||||
|
||||
/***** If no media to show ==> nothing to do *****/
|
||||
if (Media->Status != Med_STORED_IN_DB ||
|
||||
if (Media->MedCod <= 0 ||
|
||||
Media->Status != Med_STORED_IN_DB ||
|
||||
Media->Type == Med_TYPE_NONE)
|
||||
return;
|
||||
|
||||
|
|
|
@ -738,7 +738,7 @@ void TL_Com_ReceiveCommGbl (void)
|
|||
static long TL_Com_ReceiveComm (void)
|
||||
{
|
||||
extern const char *Txt_The_post_no_longer_exists;
|
||||
struct TL_Pst_PostContent Content;
|
||||
struct TL_Pst_Content Content;
|
||||
struct TL_Not_Note Not;
|
||||
struct TL_Pub_Publication Pub;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ struct TL_Com_Comment
|
|||
long NotCod; // Note code to which this comment belongs
|
||||
time_t DateTimeUTC; // Date-time of publication in UTC time
|
||||
unsigned NumFavs; // Number of times (users) this comment has been favourited
|
||||
struct TL_Pst_PostContent Content;
|
||||
struct TL_Pst_Content Content;
|
||||
};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -422,7 +422,7 @@ long TL_DB_GetMedCodFromPost (long PstCod)
|
|||
/*****************************************************************************/
|
||||
// Returns code of just created post
|
||||
|
||||
long TL_DB_CreateNewPost (const struct TL_Pst_PostContent *Content)
|
||||
long TL_DB_CreateNewPost (const struct TL_Pst_Content *Content)
|
||||
{
|
||||
/***** Insert post content in the database *****/
|
||||
return
|
||||
|
@ -580,7 +580,7 @@ unsigned TL_DB_GetDataOfCommByCod (long PubCod,MYSQL_RES **mysql_res)
|
|||
/*****************************************************************************/
|
||||
|
||||
void TL_DB_InsertCommContent (long PubCod,
|
||||
const struct TL_Pst_PostContent *Content)
|
||||
const struct TL_Pst_Content *Content)
|
||||
{
|
||||
/***** Insert comment content in database *****/
|
||||
DB_QueryINSERT ("can not store comment content",
|
||||
|
|
|
@ -78,7 +78,7 @@ void TL_DB_RemoveAllNotesUsr (long UsrCod);
|
|||
/********************************* Posts *************************************/
|
||||
unsigned TL_DB_GetPostByCod (long PstCod,MYSQL_RES **mysql_res);
|
||||
long TL_DB_GetMedCodFromPost (long PubCod);
|
||||
long TL_DB_CreateNewPost (const struct TL_Pst_PostContent *Content);
|
||||
long TL_DB_CreateNewPost (const struct TL_Pst_Content *Content);
|
||||
void TL_DB_RemovePost (long PstCod);
|
||||
void TL_DB_RemoveAllPostsUsr (long UsrCod);
|
||||
|
||||
|
@ -92,7 +92,7 @@ unsigned TL_DB_GetFinalComms (long NotCod,unsigned NumFinalCommsToGet,
|
|||
MYSQL_RES **mysql_res);
|
||||
unsigned TL_DB_GetDataOfCommByCod (long PubCod,MYSQL_RES **mysql_res);
|
||||
void TL_DB_InsertCommContent (long PubCod,
|
||||
const struct TL_Pst_PostContent *Content);
|
||||
const struct TL_Pst_Content *Content);
|
||||
long TL_DB_GetMedCodFromComm (long PubCod);
|
||||
void TL_DB_RemoveCommFavs (long PubCod);
|
||||
void TL_DB_RemoveCommContent (long PubCod);
|
||||
|
|
|
@ -109,7 +109,7 @@ void TL_Ntf_GetNotifPublication (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
|||
MYSQL_ROW row;
|
||||
struct TL_Pub_Publication Pub;
|
||||
struct TL_Not_Note Not;
|
||||
struct TL_Pst_PostContent Content;
|
||||
struct TL_Pst_Content Content;
|
||||
size_t Length;
|
||||
bool ContentCopied = false;
|
||||
|
||||
|
|
|
@ -62,6 +62,9 @@ extern struct Globals Gbl;
|
|||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void TL_Pst_GetPostContent (long PstCod,struct TL_Pst_Content *Content);
|
||||
static void TL_Pst_ShowPostContent (struct TL_Pst_Content *Content);
|
||||
|
||||
static void TL_Pst_PutFormToWriteNewPost (struct TL_Timeline *Timeline);
|
||||
|
||||
static long TL_Pst_ReceivePost (void);
|
||||
|
@ -71,13 +74,31 @@ static long TL_Pst_ReceivePost (void);
|
|||
/*****************************************************************************/
|
||||
|
||||
void TL_Pst_GetAndWritePost (long PstCod)
|
||||
{
|
||||
struct TL_Pst_Content Content;
|
||||
|
||||
/***** Initialize media *****/
|
||||
Med_MediaConstructor (&Content.Media);
|
||||
|
||||
/***** Get post content from database *****/
|
||||
TL_Pst_GetPostContent (PstCod,&Content);
|
||||
|
||||
/***** Show post content *****/
|
||||
TL_Pst_ShowPostContent (&Content);
|
||||
|
||||
/***** Free media *****/
|
||||
Med_MediaDestructor (&Content.Media);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Get post content *****************************/
|
||||
/*****************************************************************************/
|
||||
// Media must be initialized before calling this function
|
||||
|
||||
static void TL_Pst_GetPostContent (long PstCod,struct TL_Pst_Content *Content)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
struct TL_Pst_PostContent Content;
|
||||
|
||||
/***** Initialize image *****/
|
||||
Med_MediaConstructor (&Content.Media);
|
||||
|
||||
/***** Get post from database *****/
|
||||
if (TL_DB_GetPostByCod (PstCod,&mysql_res) == 1)
|
||||
|
@ -89,33 +110,37 @@ void TL_Pst_GetAndWritePost (long PstCod)
|
|||
row[1] MedCod
|
||||
*/
|
||||
/* Get content (row[0]) */
|
||||
Str_Copy (Content.Txt,row[0],sizeof (Content.Txt) - 1);
|
||||
Str_Copy (Content->Txt,row[0],sizeof (Content->Txt) - 1);
|
||||
|
||||
/* Get media (row[1]) */
|
||||
Content.Media.MedCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
Med_GetMediaDataByCod (&Content.Media);
|
||||
Content->Media.MedCod = Str_ConvertStrCodToLongCod (row[1]);
|
||||
Med_GetMediaDataByCod (&Content->Media);
|
||||
}
|
||||
else
|
||||
Content.Txt[0] = '\0';
|
||||
Content->Txt[0] = '\0';
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Get post content *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void TL_Pst_ShowPostContent (struct TL_Pst_Content *Content)
|
||||
{
|
||||
/***** Write content text *****/
|
||||
if (Content.Txt[0])
|
||||
if (Content->Txt[0])
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"TL_TXT\"");
|
||||
Msg_WriteMsgContent (Content.Txt,Cns_MAX_BYTES_LONG_TEXT,true,false);
|
||||
Msg_WriteMsgContent (Content->Txt,Cns_MAX_BYTES_LONG_TEXT,true,false);
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
|
||||
/***** Show media *****/
|
||||
Med_ShowMedia (&Content.Media,"TL_PST_MED_CONT TL_RIGHT_WIDTH",
|
||||
"TL_PST_MED TL_RIGHT_WIDTH");
|
||||
|
||||
/***** Free image *****/
|
||||
Med_MediaDestructor (&Content.Media);
|
||||
}
|
||||
Med_ShowMedia (&Content->Media,"TL_PST_MED_CONT TL_RIGHT_WIDTH",
|
||||
"TL_PST_MED TL_RIGHT_WIDTH");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Form to write a new publication **********************/
|
||||
|
@ -260,7 +285,7 @@ void TL_Pst_ReceivePostGbl (void)
|
|||
// Returns the code of the note just created
|
||||
static long TL_Pst_ReceivePost (void)
|
||||
{
|
||||
struct TL_Pst_PostContent Content;
|
||||
struct TL_Pst_Content Content;
|
||||
long PstCod;
|
||||
struct TL_Pub_Publication Pub;
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
/******************************** Public types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
struct TL_Pst_PostContent
|
||||
struct TL_Pst_Content
|
||||
{
|
||||
char Txt[Cns_MAX_BYTES_LONG_TEXT + 1];
|
||||
struct Med_Media Media;
|
||||
|
|
Loading…
Reference in New Issue