mirror of https://github.com/acanas/swad-core.git
Version 20.41.2: Mar 03, 2021 Code refactoring in timeline.
This commit is contained in:
parent
cae52f721c
commit
cfdfdc7c5f
|
@ -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.41.1 (2021-03-03)"
|
#define Log_PLATFORM_VERSION "SWAD 20.41.2 (2021-03-03)"
|
||||||
#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.41.2: Mar 03, 2021 Code refactoring in timeline. (? lines)
|
||||||
Version 20.41.1: Mar 03, 2021 Code refactoring in timeline posts. (305563 lines)
|
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.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.3: Mar 03, 2021 Code refactoring in timeline. (305528 lines)
|
||||||
|
|
|
@ -494,6 +494,7 @@ static void TL_Com_PutIconToToggleComms (const char *UniqueId,
|
||||||
extern const char *The_ClassFormLinkInBox[The_NUM_THEMES];
|
extern const char *The_ClassFormLinkInBox[The_NUM_THEMES];
|
||||||
char *OnClick;
|
char *OnClick;
|
||||||
|
|
||||||
|
/***** Build onclick text *****/
|
||||||
if (asprintf (&OnClick,"toggleComments('%s')",UniqueId) < 0)
|
if (asprintf (&OnClick,"toggleComments('%s')",UniqueId) < 0)
|
||||||
Lay_NotEnoughMemoryExit ();
|
Lay_NotEnoughMemoryExit ();
|
||||||
|
|
||||||
|
@ -502,6 +503,7 @@ static void TL_Com_PutIconToToggleComms (const char *UniqueId,
|
||||||
Ico_PutIconTextLink (Icon,Text);
|
Ico_PutIconTextLink (Icon,Text);
|
||||||
HTM_BUTTON_End ();
|
HTM_BUTTON_End ();
|
||||||
|
|
||||||
|
/***** Free onclick text *****/
|
||||||
free (OnClick);
|
free (OnClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -842,7 +844,6 @@ void TL_Com_RequestRemComGbl (void)
|
||||||
|
|
||||||
static void TL_Com_RequestRemovalComm (struct TL_Timeline *Timeline)
|
static void TL_Com_RequestRemovalComm (struct TL_Timeline *Timeline)
|
||||||
{
|
{
|
||||||
extern const char *Txt_The_post_no_longer_exists;
|
|
||||||
extern const char *Txt_Do_you_really_want_to_remove_the_following_comment;
|
extern const char *Txt_Do_you_really_want_to_remove_the_following_comment;
|
||||||
struct TL_Com_Comment Com;
|
struct TL_Com_Comment Com;
|
||||||
|
|
||||||
|
@ -853,19 +854,10 @@ static void TL_Com_RequestRemovalComm (struct TL_Timeline *Timeline)
|
||||||
Com.PubCod = TL_Pub_GetParamPubCod ();
|
Com.PubCod = TL_Pub_GetParamPubCod ();
|
||||||
TL_Com_GetDataOfCommByCod (&Com);
|
TL_Com_GetDataOfCommByCod (&Com);
|
||||||
|
|
||||||
/***** Trivial check 1: publication code *****/
|
/***** Do some checks *****/
|
||||||
if (Com.PubCod <= 0)
|
if (!TL_Usr_CheckIfICanRemove (Com.PubCod,Com.UsrCod))
|
||||||
{
|
{
|
||||||
Med_MediaDestructor (&Com.Content.Media);
|
Med_MediaDestructor (&Com.Content.Media);
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_The_post_no_longer_exists);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Trivial check 2: only if I am the author of this comment *****/
|
|
||||||
if (!Usr_ItsMe (Com.UsrCod))
|
|
||||||
{
|
|
||||||
Med_MediaDestructor (&Com.Content.Media);
|
|
||||||
Ale_ShowAlert (Ale_ERROR,"You are not the author.");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -146,7 +146,7 @@ static void TL_Fav_FavNote (struct TL_Not_Note *Not)
|
||||||
TL_Not_GetDataOfNoteByCod (Not);
|
TL_Not_GetDataOfNoteByCod (Not);
|
||||||
|
|
||||||
/***** Do some checks *****/
|
/***** Do some checks *****/
|
||||||
if (!TL_Usr_CheckICanFavSha (Not->NotCod,Not->UsrCod))
|
if (!TL_Usr_CheckIfICanFavSha (Not->NotCod,Not->UsrCod))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Trivial check: Have I faved this note? *****/
|
/***** Trivial check: Have I faved this note? *****/
|
||||||
|
@ -177,7 +177,7 @@ static void TL_Fav_UnfNote (struct TL_Not_Note *Not)
|
||||||
TL_Not_GetDataOfNoteByCod (Not);
|
TL_Not_GetDataOfNoteByCod (Not);
|
||||||
|
|
||||||
/***** Do some checks *****/
|
/***** Do some checks *****/
|
||||||
if (!TL_Usr_CheckICanFavSha (Not->NotCod,Not->UsrCod))
|
if (!TL_Usr_CheckIfICanFavSha (Not->NotCod,Not->UsrCod))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Trivial check: Have I faved this note? *****/
|
/***** Trivial check: Have I faved this note? *****/
|
||||||
|
@ -285,7 +285,7 @@ static void TL_Fav_FavComm (struct TL_Com_Comment *Com)
|
||||||
TL_Com_GetDataOfCommByCod (Com);
|
TL_Com_GetDataOfCommByCod (Com);
|
||||||
|
|
||||||
/***** Do some checks *****/
|
/***** Do some checks *****/
|
||||||
if (!TL_Usr_CheckICanFavSha (Com->PubCod,Com->UsrCod))
|
if (!TL_Usr_CheckIfICanFavSha (Com->PubCod,Com->UsrCod))
|
||||||
{
|
{
|
||||||
Med_MediaDestructor (&Com->Content.Media);
|
Med_MediaDestructor (&Com->Content.Media);
|
||||||
return;
|
return;
|
||||||
|
@ -324,7 +324,7 @@ static void TL_Fav_UnfComm (struct TL_Com_Comment *Com)
|
||||||
TL_Com_GetDataOfCommByCod (Com);
|
TL_Com_GetDataOfCommByCod (Com);
|
||||||
|
|
||||||
/***** Do some checks *****/
|
/***** Do some checks *****/
|
||||||
if (!TL_Usr_CheckICanFavSha (Com->PubCod,Com->UsrCod))
|
if (!TL_Usr_CheckIfICanFavSha (Com->PubCod,Com->UsrCod))
|
||||||
{
|
{
|
||||||
Med_MediaDestructor (&Com->Content.Media);
|
Med_MediaDestructor (&Com->Content.Media);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1121,7 +1121,6 @@ void TL_Not_RequestRemNoteGbl (void)
|
||||||
|
|
||||||
static void TL_Not_RequestRemovalNote (struct TL_Timeline *Timeline)
|
static void TL_Not_RequestRemovalNote (struct TL_Timeline *Timeline)
|
||||||
{
|
{
|
||||||
extern const char *Txt_The_post_no_longer_exists;
|
|
||||||
extern const char *Txt_Do_you_really_want_to_remove_the_following_post;
|
extern const char *Txt_Do_you_really_want_to_remove_the_following_post;
|
||||||
struct TL_Not_Note Not;
|
struct TL_Not_Note Not;
|
||||||
|
|
||||||
|
@ -1129,19 +1128,9 @@ static void TL_Not_RequestRemovalNote (struct TL_Timeline *Timeline)
|
||||||
Not.NotCod = TL_Not_GetParamNotCod ();
|
Not.NotCod = TL_Not_GetParamNotCod ();
|
||||||
TL_Not_GetDataOfNoteByCod (&Not);
|
TL_Not_GetDataOfNoteByCod (&Not);
|
||||||
|
|
||||||
/***** Trivial check 1: note code should be > 0 *****/
|
/***** Do some checks *****/
|
||||||
if (Not.NotCod <= 0)
|
if (!TL_Usr_CheckIfICanRemove (Not.NotCod,Not.UsrCod))
|
||||||
{
|
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_The_post_no_longer_exists);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/***** Trivial check 2: Am I the author of this note *****/
|
|
||||||
if (!Usr_ItsMe (Not.UsrCod))
|
|
||||||
{
|
|
||||||
Ale_ShowAlert (Ale_ERROR,"You are not the author.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Show question and button to remove note *****/
|
/***** Show question and button to remove note *****/
|
||||||
/* Begin alert */
|
/* Begin alert */
|
||||||
|
|
|
@ -122,7 +122,7 @@ static void TL_Sha_ShaNote (struct TL_Not_Note *Not)
|
||||||
TL_Not_GetDataOfNoteByCod (Not);
|
TL_Not_GetDataOfNoteByCod (Not);
|
||||||
|
|
||||||
/***** Do some checks *****/
|
/***** Do some checks *****/
|
||||||
if (!TL_Usr_CheckICanFavSha (Not->NotCod,Not->UsrCod))
|
if (!TL_Usr_CheckIfICanFavSha (Not->NotCod,Not->UsrCod))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Trivial check: Is note already shared by me? *****/
|
/***** Trivial check: Is note already shared by me? *****/
|
||||||
|
@ -181,7 +181,7 @@ static void TL_Sha_UnsNote (struct TL_Not_Note *Not)
|
||||||
TL_Not_GetDataOfNoteByCod (Not);
|
TL_Not_GetDataOfNoteByCod (Not);
|
||||||
|
|
||||||
/***** Do some checks *****/
|
/***** Do some checks *****/
|
||||||
if (!TL_Usr_CheckICanFavSha (Not->NotCod,Not->UsrCod))
|
if (!TL_Usr_CheckIfICanFavSha (Not->NotCod,Not->UsrCod))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/***** Delete publication from database *****/
|
/***** Delete publication from database *****/
|
||||||
|
|
|
@ -232,32 +232,6 @@ static void TL_Usr_ListSharersOrFavers (MYSQL_RES **mysql_res,
|
||||||
Usr_UsrDataDestructor (&UsrDat);
|
Usr_UsrDataDestructor (&UsrDat);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/***************** Check if I can fav/share a note/comment *******************/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
bool TL_Usr_CheckICanFavSha (long Cod,long UsrCod)
|
|
||||||
{
|
|
||||||
extern const char *Txt_The_post_no_longer_exists;
|
|
||||||
|
|
||||||
/***** Trivial check 1: note/comment code should be > 0 *****/
|
|
||||||
if (Cod <= 0)
|
|
||||||
{
|
|
||||||
Ale_ShowAlert (Ale_WARNING,Txt_The_post_no_longer_exists);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Trivial check 2: I must be logged
|
|
||||||
I can not fav/share my own notes/comments *****/
|
|
||||||
if (!Gbl.Usrs.Me.Logged || Usr_ItsMe (UsrCod))
|
|
||||||
{
|
|
||||||
Lay_NoPermissionExit ();
|
|
||||||
return false; // Not reached
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************* Check if a user has faved/shared a note/comment ***************/
|
/************* Check if a user has faved/shared a note/comment ***************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -365,3 +339,55 @@ static void TL_Usr_PutDisabledIconFavSha (TL_Usr_FavSha_t FavSha,
|
||||||
else
|
else
|
||||||
Ico_PutDivIcon ("TL_ICO_DISABLED",Icon[FavSha],TitleWithoutUsrs[FavSha]);
|
Ico_PutDivIcon ("TL_ICO_DISABLED",Icon[FavSha],TitleWithoutUsrs[FavSha]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************** Check if I can fav/share a note/comment *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
bool TL_Usr_CheckIfICanFavSha (long Cod,long UsrCod)
|
||||||
|
{
|
||||||
|
extern const char *Txt_The_post_no_longer_exists;
|
||||||
|
|
||||||
|
/***** Trivial check 1: note/comment code should be > 0 *****/
|
||||||
|
if (Cod <= 0)
|
||||||
|
{
|
||||||
|
Ale_ShowAlert (Ale_WARNING,Txt_The_post_no_longer_exists);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Trivial check 2: I must be logged
|
||||||
|
I can not fav/share my own notes/comments *****/
|
||||||
|
if (!Gbl.Usrs.Me.Logged || Usr_ItsMe (UsrCod))
|
||||||
|
{
|
||||||
|
Lay_NoPermissionExit ();
|
||||||
|
return false; // Not reached
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/***************** Check if I can fav/share a note/comment *******************/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
bool TL_Usr_CheckIfICanRemove (long Cod,long UsrCod)
|
||||||
|
{
|
||||||
|
extern const char *Txt_The_post_no_longer_exists;
|
||||||
|
|
||||||
|
/***** Trivial check 1: note/comment code should be > 0 *****/
|
||||||
|
if (Cod <= 0)
|
||||||
|
{
|
||||||
|
Ale_ShowAlert (Ale_WARNING,Txt_The_post_no_longer_exists);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Trivial check 2: I must be logged
|
||||||
|
I can only remove my own notes/comments *****/
|
||||||
|
if (!Gbl.Usrs.Me.Logged || !Usr_ItsMe (UsrCod))
|
||||||
|
{
|
||||||
|
Lay_NoPermissionExit ();
|
||||||
|
return false; // Not reached
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -69,11 +69,13 @@ typedef enum
|
||||||
|
|
||||||
void TL_Usr_RemoveUsrContent (long UsrCod);
|
void TL_Usr_RemoveUsrContent (long UsrCod);
|
||||||
|
|
||||||
bool TL_Usr_CheckICanFavSha (long Cod,long UsrCod);
|
|
||||||
bool TL_Usr_CheckIfFavedSharedByUsr (TL_Usr_FavSha_t FavSha,long Cod,long UsrCod);
|
bool TL_Usr_CheckIfFavedSharedByUsr (TL_Usr_FavSha_t FavSha,long Cod,long UsrCod);
|
||||||
|
|
||||||
void TL_Usr_PutIconFavSha (TL_Usr_FavSha_t FavSha,
|
void TL_Usr_PutIconFavSha (TL_Usr_FavSha_t FavSha,
|
||||||
long Cod,long UsrCod,unsigned NumUsrs,
|
long Cod,long UsrCod,unsigned NumUsrs,
|
||||||
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
TL_Usr_HowManyUsrs_t HowManyUsrs);
|
||||||
|
|
||||||
|
bool TL_Usr_CheckIfICanFavSha (long Cod,long UsrCod);
|
||||||
|
bool TL_Usr_CheckIfICanRemove (long Cod,long UsrCod);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue