mirror of https://github.com/acanas/swad-core.git
Version 20.39.7: Mar 02, 2021 Code refactoring in fav/share timeline comments.
This commit is contained in:
parent
3aab36a11b
commit
3612c0ef86
|
@ -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: 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
|
TODO: Salvador Romero Cortés: @acanas opción para editar posts
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 20.39.6 (2021-03-02)"
|
#define Log_PLATFORM_VERSION "SWAD 20.39.7 (2021-03-02)"
|
||||||
#define CSS_FILE "swad20.33.9.css"
|
#define CSS_FILE "swad20.33.9.css"
|
||||||
#define JS_FILE "swad20.6.2.js"
|
#define JS_FILE "swad20.6.2.js"
|
||||||
/*
|
/*
|
||||||
|
Version 20.39.7: Mar 02, 2021 Code refactoring in fav/share timeline comments. (305566 lines)
|
||||||
Version 20.39.6: Mar 02, 2021 Code refactoring in fav/share timeline notes. (305570 lines)
|
Version 20.39.6: Mar 02, 2021 Code refactoring in fav/share timeline notes. (305570 lines)
|
||||||
Version 20.39.5: Mar 02, 2021 Code refactoring in timeline notes and posts. (305620 lines)
|
Version 20.39.5: Mar 02, 2021 Code refactoring in timeline notes and posts. (305620 lines)
|
||||||
Version 20.39.4: Mar 02, 2021 Code refactoring in timeline notes. (305614 lines)
|
Version 20.39.4: Mar 02, 2021 Code refactoring in timeline notes. (305614 lines)
|
||||||
|
|
|
@ -1094,3 +1094,42 @@ static void TL_Com_ResetComm (struct TL_Com_Comment *Com)
|
||||||
Com->Content.Txt[0] = '\0';
|
Com->Content.Txt[0] = '\0';
|
||||||
Com->NumFavs = 0;
|
Com->NumFavs = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/******************* Check if I can fav/share a comment **********************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
bool TL_Com_CheckICanFavShaComm (struct TL_Com_Comment *Com)
|
||||||
|
{
|
||||||
|
extern const char *Txt_The_comment_no_longer_exists;
|
||||||
|
|
||||||
|
/***** Get data of comment *****/
|
||||||
|
Com->PubCod = TL_Pub_GetParamPubCod ();
|
||||||
|
TL_Com_GetDataOfCommByCod (Com);
|
||||||
|
|
||||||
|
/***** Trivial check 1: publication code should be > 0 *****/
|
||||||
|
if (Com->PubCod <= 0)
|
||||||
|
{
|
||||||
|
Med_MediaDestructor (&Com->Content.Media);
|
||||||
|
Ale_ShowAlert (Ale_WARNING,Txt_The_comment_no_longer_exists);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Trivial check 2: I must be logged *****/
|
||||||
|
if (!Gbl.Usrs.Me.Logged)
|
||||||
|
{
|
||||||
|
Med_MediaDestructor (&Com->Content.Media);
|
||||||
|
Ale_ShowAlert (Ale_ERROR,"You are not logged.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Trivial check 3: The author can not fav his/her own comments *****/
|
||||||
|
if (Usr_ItsMe (Com->UsrCod))
|
||||||
|
{
|
||||||
|
Med_MediaDestructor (&Com->Content.Media);
|
||||||
|
Ale_ShowAlert (Ale_ERROR,"You can not fav/unfav your own comments.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -77,4 +77,6 @@ void TL_Com_RemoveCommMediaAndDBEntries (long PubCod);
|
||||||
|
|
||||||
void TL_Com_GetDataOfCommByCod (struct TL_Com_Comment *Com);
|
void TL_Com_GetDataOfCommByCod (struct TL_Com_Comment *Com);
|
||||||
|
|
||||||
|
bool TL_Com_CheckICanFavShaComm (struct TL_Com_Comment *Com);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -267,40 +267,17 @@ void TL_Fav_UnfCommGbl (void)
|
||||||
|
|
||||||
static void TL_Fav_FavComm (struct TL_Com_Comment *Com)
|
static void TL_Fav_FavComm (struct TL_Com_Comment *Com)
|
||||||
{
|
{
|
||||||
extern const char *Txt_The_comment_no_longer_exists;
|
|
||||||
|
|
||||||
/***** Initialize image *****/
|
/***** Initialize image *****/
|
||||||
Med_MediaConstructor (&Com->Content.Media);
|
Med_MediaConstructor (&Com->Content.Media);
|
||||||
|
|
||||||
/***** Get data of comment *****/
|
/***** Get data of comment and do some checks *****/
|
||||||
Com->PubCod = TL_Pub_GetParamPubCod ();
|
if (!TL_Com_CheckICanFavShaComm (Com))
|
||||||
TL_Com_GetDataOfCommByCod (Com);
|
|
||||||
|
|
||||||
/***** Trivial check 1: publication code should be > 0 *****/
|
|
||||||
if (Com->PubCod <= 0)
|
|
||||||
{
|
{
|
||||||
Med_MediaDestructor (&Com->Content.Media);
|
Med_MediaDestructor (&Com->Content.Media);
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_The_comment_no_longer_exists);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***** Trivial check 2: I must be logged *****/
|
/***** Trivial check: Have I faved this comment? *****/
|
||||||
if (!Gbl.Usrs.Me.Logged)
|
|
||||||
{
|
|
||||||
Med_MediaDestructor (&Com->Content.Media);
|
|
||||||
Ale_ShowAlert (Ale_ERROR,"You are not logged.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Trivial check 3: The author can not fav his/her own comments *****/
|
|
||||||
if (Usr_ItsMe (Com->UsrCod))
|
|
||||||
{
|
|
||||||
Med_MediaDestructor (&Com->Content.Media);
|
|
||||||
Ale_ShowAlert (Ale_ERROR,"You can not fav/unfav your own comments.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Trivial check 4: Have I faved this comment? *****/
|
|
||||||
if (TL_DB_CheckIfFavedByUsr (TL_Fav_COMM,Com->PubCod,
|
if (TL_DB_CheckIfFavedByUsr (TL_Fav_COMM,Com->PubCod,
|
||||||
Gbl.Usrs.Me.UsrDat.UsrCod))
|
Gbl.Usrs.Me.UsrDat.UsrCod))
|
||||||
{
|
{
|
||||||
|
@ -327,36 +304,13 @@ static void TL_Fav_FavComm (struct TL_Com_Comment *Com)
|
||||||
|
|
||||||
static void TL_Fav_UnfComm (struct TL_Com_Comment *Com)
|
static void TL_Fav_UnfComm (struct TL_Com_Comment *Com)
|
||||||
{
|
{
|
||||||
extern const char *Txt_The_comment_no_longer_exists;
|
|
||||||
|
|
||||||
/***** Initialize image *****/
|
/***** Initialize image *****/
|
||||||
Med_MediaConstructor (&Com->Content.Media);
|
Med_MediaConstructor (&Com->Content.Media);
|
||||||
|
|
||||||
/***** Get data of comment *****/
|
/***** Get data of comment and do some checks *****/
|
||||||
Com->PubCod = TL_Pub_GetParamPubCod ();
|
if (!TL_Com_CheckICanFavShaComm (Com))
|
||||||
TL_Com_GetDataOfCommByCod (Com);
|
|
||||||
|
|
||||||
/***** Trivial check 1: publication code should be > 0 *****/
|
|
||||||
if (Com->PubCod <= 0)
|
|
||||||
{
|
{
|
||||||
Med_MediaDestructor (&Com->Content.Media);
|
Med_MediaDestructor (&Com->Content.Media);
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_The_comment_no_longer_exists);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Trivial check 2: I must be logged *****/
|
|
||||||
if (!Gbl.Usrs.Me.Logged)
|
|
||||||
{
|
|
||||||
Med_MediaDestructor (&Com->Content.Media);
|
|
||||||
Ale_ShowAlert (Ale_ERROR,"You are not logged.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Trivial check 3: The author can not fav its own notes *****/
|
|
||||||
if (Usr_ItsMe (Com->UsrCod))
|
|
||||||
{
|
|
||||||
Med_MediaDestructor (&Com->Content.Media);
|
|
||||||
Ale_ShowAlert (Ale_ERROR,"You can not fav/unfav your own comments.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue