mirror of https://github.com/acanas/swad-core.git
Version 22.118.13:May 31, 2023 Code refactoring in forums.
This commit is contained in:
parent
bf031de6db
commit
31642fe486
|
@ -629,10 +629,11 @@ TODO: Emilce Barrera Mesa: Podr
|
||||||
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
|
TODO: Emilce Barrera Mesa: Mis estudiantes presentan muchas dificultades a la hora de poner la foto porque la plataforma es muy exigente respecto al fondo de la imagen.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
#define Log_PLATFORM_VERSION "SWAD 22.118.11 (2023-05-30)"
|
#define Log_PLATFORM_VERSION "SWAD 22.118.13 (2023-05-31)"
|
||||||
#define CSS_FILE "swad22.118.5.css"
|
#define CSS_FILE "swad22.118.5.css"
|
||||||
#define JS_FILE "swad22.49.js"
|
#define JS_FILE "swad22.49.js"
|
||||||
/*
|
/*
|
||||||
|
Version 22.118.13:May 31, 2023 Code refactoring in forums. (337417 lines)
|
||||||
Version 22.118.12:May 30, 2023 Code refactoring in forums and messages. (337408 lines)
|
Version 22.118.12:May 30, 2023 Code refactoring in forums and messages. (337408 lines)
|
||||||
Version 22.118.11:May 30, 2023 Code refactoring in strings. (337391 lines)
|
Version 22.118.11:May 30, 2023 Code refactoring in strings. (337391 lines)
|
||||||
Version 22.118.10:May 30, 2023 Draw logo in head even if it does not exist. (337359 lines)
|
Version 22.118.10:May 30, 2023 Draw logo in head even if it does not exist. (337359 lines)
|
||||||
|
|
|
@ -119,10 +119,11 @@ typedef enum
|
||||||
Cns_FULL_NAME,
|
Cns_FULL_NAME,
|
||||||
} Cns_ShrtOrFullName_t;
|
} Cns_ShrtOrFullName_t;
|
||||||
|
|
||||||
|
#define Cns_NUM_DISABLED_ENABLED 2
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
Cns_DISABLED,
|
Cns_DISABLED,
|
||||||
Cns_ENABLED,
|
Cns_ENABLED,
|
||||||
} Cns_Enabled_t;
|
} Cns_DisabledOrEnabled_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
55
swad_forum.c
55
swad_forum.c
|
@ -906,14 +906,30 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
|
||||||
extern const char *Txt_FORUM_Post_banned;
|
extern const char *Txt_FORUM_Post_banned;
|
||||||
extern const char *Txt_FORUM_Post_X_banned;
|
extern const char *Txt_FORUM_Post_X_banned;
|
||||||
extern const char *Txt_This_post_has_been_banned_probably_for_not_satisfy_the_rules_of_the_forums;
|
extern const char *Txt_This_post_has_been_banned_probably_for_not_satisfy_the_rules_of_the_forums;
|
||||||
|
static const char *Icon[Cns_NUM_DISABLED_ENABLED] =
|
||||||
|
{
|
||||||
|
[Cns_DISABLED] = "eye-slash.svg",
|
||||||
|
[Cns_ENABLED ] = "eye.svg",
|
||||||
|
};
|
||||||
|
static Ico_Color_t Color[Cns_NUM_DISABLED_ENABLED] =
|
||||||
|
{
|
||||||
|
[Cns_DISABLED] = Ico_RED,
|
||||||
|
[Cns_ENABLED ] = Ico_GREEN,
|
||||||
|
};
|
||||||
|
static const char **TxtAllowedBanned[Cns_NUM_DISABLED_ENABLED] =
|
||||||
|
{
|
||||||
|
[Cns_DISABLED] = &Txt_FORUM_Post_X_banned,
|
||||||
|
[Cns_ENABLED ] = &Txt_FORUM_Post_X_allowed,
|
||||||
|
};
|
||||||
struct Usr_Data UsrDat;
|
struct Usr_Data UsrDat;
|
||||||
time_t CreatTimeUTC; // Creation time of a post
|
time_t CreatTimeUTC; // Creation time of a post
|
||||||
char OriginalContent[Cns_MAX_BYTES_LONG_TEXT + 1];
|
char OriginalContent[Cns_MAX_BYTES_LONG_TEXT + 1];
|
||||||
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
||||||
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
|
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
|
||||||
struct Med_Media Media;
|
struct Med_Media Media;
|
||||||
Cns_Enabled_t Enabled;
|
Cns_DisabledOrEnabled_t DisabledOrEnabled;
|
||||||
char *Title;
|
char *Title;
|
||||||
|
Act_Action_t NextAction;
|
||||||
|
|
||||||
/***** Initialize structure with user's data *****/
|
/***** Initialize structure with user's data *****/
|
||||||
Usr_UsrDataConstructor (&UsrDat);
|
Usr_UsrDataConstructor (&UsrDat);
|
||||||
|
@ -922,13 +938,13 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
|
||||||
Med_MediaConstructor (&Media);
|
Med_MediaConstructor (&Media);
|
||||||
|
|
||||||
/***** Check if post is enabled *****/
|
/***** Check if post is enabled *****/
|
||||||
Enabled = For_DB_GetIfPstIsEnabled (Forums->PstCod);
|
DisabledOrEnabled = For_DB_GetIfPstIsDisabledOrEnabled (Forums->PstCod);
|
||||||
|
|
||||||
/***** Get data of post *****/
|
/***** Get data of post *****/
|
||||||
For_GetPstData (Forums->PstCod,&UsrDat.UsrCod,&CreatTimeUTC,
|
For_GetPstData (Forums->PstCod,&UsrDat.UsrCod,&CreatTimeUTC,
|
||||||
Subject,OriginalContent,&Media);
|
Subject,OriginalContent,&Media);
|
||||||
|
|
||||||
if (Enabled == Cns_ENABLED)
|
if (DisabledOrEnabled == Cns_ENABLED)
|
||||||
/* Return this subject as last subject */
|
/* Return this subject as last subject */
|
||||||
Str_Copy (LastSubject,Subject,Cns_MAX_BYTES_SUBJECT);
|
Str_Copy (LastSubject,Subject,Cns_MAX_BYTES_SUBJECT);
|
||||||
|
|
||||||
|
@ -964,7 +980,7 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
|
||||||
NewPst ? "MSG_BG_NEW" :
|
NewPst ? "MSG_BG_NEW" :
|
||||||
"MSG_BG",
|
"MSG_BG",
|
||||||
The_GetSuffix ());
|
The_GetSuffix ());
|
||||||
switch (Enabled)
|
switch (DisabledOrEnabled)
|
||||||
{
|
{
|
||||||
case Cns_DISABLED:
|
case Cns_DISABLED:
|
||||||
HTM_TxtF ("[%s]",Txt_FORUM_Post_banned);
|
HTM_TxtF ("[%s]",Txt_FORUM_Post_banned);
|
||||||
|
@ -986,29 +1002,18 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
|
||||||
|
|
||||||
if (ICanModerateForum)
|
if (ICanModerateForum)
|
||||||
{
|
{
|
||||||
Frm_BeginFormAnchor (Enabled == Cns_ENABLED ? For_ActionsDisPstFor[Forums->Forum.Type] :
|
NextAction = DisabledOrEnabled == Cns_ENABLED ? For_ActionsDisPstFor[Forums->Forum.Type] :
|
||||||
For_ActionsEnbPstFor[Forums->Forum.Type],
|
For_ActionsEnbPstFor[Forums->Forum.Type];
|
||||||
For_FORUM_POSTS_SECTION_ID);
|
Frm_BeginFormAnchor (NextAction,For_FORUM_POSTS_SECTION_ID);
|
||||||
For_PutParsForum (Forums);
|
For_PutParsForum (Forums);
|
||||||
Ico_PutIconLink (Enabled == Cns_ENABLED ? "eye.svg" :
|
Ico_PutIconLink (Icon[DisabledOrEnabled],Color[DisabledOrEnabled],NextAction);
|
||||||
"eye-slash.svg",
|
|
||||||
Enabled == Cns_ENABLED ? Ico_GREEN :
|
|
||||||
Ico_RED,
|
|
||||||
Enabled == Cns_ENABLED ? For_ActionsDisPstFor[Forums->Forum.Type] :
|
|
||||||
For_ActionsEnbPstFor[Forums->Forum.Type]);
|
|
||||||
Frm_EndForm ();
|
Frm_EndForm ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (asprintf (&Title,Enabled == Cns_ENABLED ? Txt_FORUM_Post_X_allowed :
|
if (asprintf (&Title,*TxtAllowedBanned[DisabledOrEnabled],PstNum) < 0)
|
||||||
Txt_FORUM_Post_X_banned,
|
|
||||||
PstNum) < 0)
|
|
||||||
Err_NotEnoughMemoryExit ();
|
Err_NotEnoughMemoryExit ();
|
||||||
Ico_PutIcon (Enabled == Cns_ENABLED ? "eye.svg" :
|
Ico_PutIcon (Icon[DisabledOrEnabled],Color[DisabledOrEnabled],Title,
|
||||||
"eye-slash.svg",
|
|
||||||
Enabled == Cns_ENABLED ? Ico_GREEN :
|
|
||||||
Ico_RED,
|
|
||||||
Title,
|
|
||||||
"ICO_HIDDEN ICO16x16");
|
"ICO_HIDDEN ICO16x16");
|
||||||
free (Title);
|
free (Title);
|
||||||
}
|
}
|
||||||
|
@ -1030,15 +1035,15 @@ static void For_ShowAForumPost (struct For_Forums *Forums,
|
||||||
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,
|
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,
|
||||||
Usr_DONT_GET_PREFS,
|
Usr_DONT_GET_PREFS,
|
||||||
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
||||||
Usr_WriteAuthor (&UsrDat,Enabled);
|
Usr_WriteAuthor (&UsrDat,DisabledOrEnabled);
|
||||||
if (Enabled == Cns_ENABLED)
|
if (DisabledOrEnabled == Cns_ENABLED)
|
||||||
/* Write number of posts from this user */
|
/* Write number of posts from this user */
|
||||||
For_WriteNumberOfPosts (Forums,UsrDat.UsrCod);
|
For_WriteNumberOfPosts (Forums,UsrDat.UsrCod);
|
||||||
HTM_TD_End ();
|
HTM_TD_End ();
|
||||||
|
|
||||||
/***** Write post content *****/
|
/***** Write post content *****/
|
||||||
HTM_TD_Begin ("class=\"LT MSG_TXT_%s\"",The_GetSuffix ());
|
HTM_TD_Begin ("class=\"LT MSG_TXT_%s\"",The_GetSuffix ());
|
||||||
switch (Enabled)
|
switch (DisabledOrEnabled)
|
||||||
{
|
{
|
||||||
case Cns_DISABLED:
|
case Cns_DISABLED:
|
||||||
HTM_Txt (Txt_This_post_has_been_banned_probably_for_not_satisfy_the_rules_of_the_forums);
|
HTM_Txt (Txt_This_post_has_been_banned_probably_for_not_satisfy_the_rules_of_the_forums);
|
||||||
|
@ -2402,7 +2407,7 @@ void For_GetThreadData (struct For_Thread *Thr)
|
||||||
for (Order = (Dat_StartEndTime_t) 0;
|
for (Order = (Dat_StartEndTime_t) 0;
|
||||||
Order <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
|
Order <= (Dat_StartEndTime_t) (Dat_NUM_START_END_TIME - 1);
|
||||||
Order++)
|
Order++)
|
||||||
Thr->Enabled[Order] = For_DB_GetIfPstIsEnabled (Thr->PstCod[Order]);
|
Thr->Enabled[Order] = For_DB_GetIfPstIsDisabledOrEnabled (Thr->PstCod[Order]);
|
||||||
|
|
||||||
/***** Get number of posts in this thread *****/
|
/***** Get number of posts in this thread *****/
|
||||||
Thr->NumPosts = For_DB_GetNumPstsInThr (Thr->ThrCod);
|
Thr->NumPosts = For_DB_GetNumPstsInThr (Thr->ThrCod);
|
||||||
|
|
|
@ -77,7 +77,7 @@ struct For_Thread
|
||||||
long PstCod[Dat_NUM_START_END_TIME];
|
long PstCod[Dat_NUM_START_END_TIME];
|
||||||
long UsrCod[Dat_NUM_START_END_TIME];
|
long UsrCod[Dat_NUM_START_END_TIME];
|
||||||
time_t WriteTime[Dat_NUM_START_END_TIME];
|
time_t WriteTime[Dat_NUM_START_END_TIME];
|
||||||
Cns_Enabled_t Enabled[Dat_NUM_START_END_TIME];
|
Cns_DisabledOrEnabled_t Enabled[Dat_NUM_START_END_TIME];
|
||||||
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
||||||
unsigned NumPosts;
|
unsigned NumPosts;
|
||||||
unsigned NumUnreadPosts; // Number of my unread posts in thread
|
unsigned NumUnreadPosts; // Number of my unread posts in thread
|
||||||
|
|
|
@ -969,7 +969,7 @@ void For_DB_InsertPstIntoDisabled (long PstCod)
|
||||||
/*********************** Get if a forum post is disabled *********************/
|
/*********************** Get if a forum post is disabled *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
Cns_Enabled_t For_DB_GetIfPstIsEnabled (long PstCod)
|
Cns_DisabledOrEnabled_t For_DB_GetIfPstIsDisabledOrEnabled (long PstCod)
|
||||||
{
|
{
|
||||||
/***** Trivial check: post code should be > 0 *****/
|
/***** Trivial check: post code should be > 0 *****/
|
||||||
if (PstCod <= 0)
|
if (PstCod <= 0)
|
||||||
|
|
|
@ -98,7 +98,7 @@ void For_DB_RemoveExpiredClipboards (void);
|
||||||
|
|
||||||
//--------------------------- Disabled posts ----------------------------------
|
//--------------------------- Disabled posts ----------------------------------
|
||||||
void For_DB_InsertPstIntoDisabled (long PstCod);
|
void For_DB_InsertPstIntoDisabled (long PstCod);
|
||||||
Cns_Enabled_t For_DB_GetIfPstIsEnabled (long PstCod);
|
Cns_DisabledOrEnabled_t For_DB_GetIfPstIsDisabledOrEnabled (long PstCod);
|
||||||
void For_DB_RemovePstFromDisabled (long PstCod);
|
void For_DB_RemovePstFromDisabled (long PstCod);
|
||||||
void For_DB_RemoveDisabledPstsInThread (long ThrCod);
|
void For_DB_RemoveDisabledPstsInThread (long ThrCod);
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ void Pag_WriteLinksToPagesCentered (Pag_WhatPaginate_t WhatPaginate,
|
||||||
void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
||||||
struct Pag_Pagination *Pagination,
|
struct Pag_Pagination *Pagination,
|
||||||
const void *Context,long Cod,
|
const void *Context,long Cod,
|
||||||
Cns_Enabled_t FirstMsgEnabled,
|
Cns_DisabledOrEnabled_t FirstMsgDisabledOrEnabled,
|
||||||
const char *Subject,const char *ClassTxt,
|
const char *Subject,const char *ClassTxt,
|
||||||
bool LinkToPagCurrent)
|
bool LinkToPagCurrent)
|
||||||
{
|
{
|
||||||
|
@ -281,7 +281,7 @@ void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
HTM_SPAN_Begin ("class=\"%s_%s\"",ClassTxt,The_GetSuffix ());
|
HTM_SPAN_Begin ("class=\"%s_%s\"",ClassTxt,The_GetSuffix ());
|
||||||
switch (FirstMsgEnabled)
|
switch (FirstMsgDisabledOrEnabled)
|
||||||
{
|
{
|
||||||
case Cns_DISABLED:
|
case Cns_DISABLED:
|
||||||
HTM_TxtF ("[%s]",Txt_FORUM_Post_banned);
|
HTM_TxtF ("[%s]",Txt_FORUM_Post_banned);
|
||||||
|
|
|
@ -84,7 +84,7 @@ void Pag_WriteLinksToPagesCentered (Pag_WhatPaginate_t WhatPaginate,
|
||||||
void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
void Pag_WriteLinksToPages (Pag_WhatPaginate_t WhatPaginate,
|
||||||
struct Pag_Pagination *Pagination,
|
struct Pag_Pagination *Pagination,
|
||||||
const void *Context,long Cod,
|
const void *Context,long Cod,
|
||||||
Cns_Enabled_t FirstMsgEnabled,
|
Cns_DisabledOrEnabled_t FirstMsgEnabled,
|
||||||
const char *Subject,const char *ClassTxt,
|
const char *Subject,const char *ClassTxt,
|
||||||
bool LinkToPagCurrent);
|
bool LinkToPagCurrent);
|
||||||
void Pag_PutParPagNum (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage);
|
void Pag_PutParPagNum (Pag_WhatPaginate_t WhatPaginate,unsigned NumPage);
|
||||||
|
|
|
@ -6340,7 +6340,8 @@ unsigned Usr_GetTotalNumberOfUsers (void)
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Input: UsrDat must hold user's data
|
// Input: UsrDat must hold user's data
|
||||||
|
|
||||||
void Usr_WriteAuthor (struct Usr_Data *UsrDat,Cns_Enabled_t Enabled)
|
void Usr_WriteAuthor (struct Usr_Data *UsrDat,
|
||||||
|
Cns_DisabledOrEnabled_t DisabledOrEnabled)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Unknown_or_without_photo;
|
extern const char *Txt_Unknown_or_without_photo;
|
||||||
static const char *ClassPhoto[PhoSha_NUM_SHAPES] =
|
static const char *ClassPhoto[PhoSha_NUM_SHAPES] =
|
||||||
|
@ -6354,7 +6355,7 @@ void Usr_WriteAuthor (struct Usr_Data *UsrDat,Cns_Enabled_t Enabled)
|
||||||
|
|
||||||
/***** Write author name or don't write it? *****/
|
/***** Write author name or don't write it? *****/
|
||||||
WriteAuthor = false;
|
WriteAuthor = false;
|
||||||
if (Enabled == Cns_ENABLED)
|
if (DisabledOrEnabled == Cns_ENABLED)
|
||||||
if (UsrDat->UsrCod > 0)
|
if (UsrDat->UsrCod > 0)
|
||||||
WriteAuthor = true;
|
WriteAuthor = true;
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,8 @@ void Usr_ShowWarningNoUsersFound (Rol_Role_t Role);
|
||||||
|
|
||||||
unsigned Usr_GetTotalNumberOfUsers (void);
|
unsigned Usr_GetTotalNumberOfUsers (void);
|
||||||
|
|
||||||
void Usr_WriteAuthor (struct Usr_Data *UsrDat,Cns_Enabled_t Enabled);
|
void Usr_WriteAuthor (struct Usr_Data *UsrDat,
|
||||||
|
Cns_DisabledOrEnabled_t DisabledOrEnabled);
|
||||||
void Usr_WriteAuthor1Line (long UsrCod,bool Hidden);
|
void Usr_WriteAuthor1Line (long UsrCod,bool Hidden);
|
||||||
|
|
||||||
void Usr_ShowTableCellWithUsrData (struct Usr_Data *UsrDat,unsigned NumRows);
|
void Usr_ShowTableCellWithUsrData (struct Usr_Data *UsrDat,unsigned NumRows);
|
||||||
|
|
Loading…
Reference in New Issue