2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_forum.h: forums
|
|
|
|
|
|
|
|
|
|
#ifndef _SWAD_FOR
|
|
|
|
|
#define _SWAD_FOR
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2023-03-10 17:21:04 +01:00
|
|
|
|
Copyright (C) 1999-2023 Antonio Ca<EFBFBD>as Vargas
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
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 <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-09-24 19:17:00 +02:00
|
|
|
|
#include "swad_alert.h"
|
2021-03-07 21:21:04 +01:00
|
|
|
|
#include "swad_center.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_degree.h"
|
|
|
|
|
#include "swad_institution.h"
|
2017-03-08 14:12:33 +01:00
|
|
|
|
#include "swad_notification.h"
|
2016-10-28 00:23:02 +02:00
|
|
|
|
#include "swad_scope.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_string.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Public constants and types *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-17 19:03:21 +02:00
|
|
|
|
#define For_NUM_FORUM_SETS 2
|
2014-12-01 23:55:08 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
|
|
|
|
For_ONLY_CURRENT_FORUMS = 0,
|
|
|
|
|
For_ALL_MY_FORUMS = 1,
|
2017-04-17 11:57:55 +02:00
|
|
|
|
} For_ForumSet_t; // Which set of forums I want to see: all my forums or only the forums of current institution/degree/course.
|
2017-04-17 19:03:21 +02:00
|
|
|
|
#define For_DEFAULT_FORUM_SET For_ONLY_CURRENT_FORUMS
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 19:55:56 +02:00
|
|
|
|
#define For_NUM_TYPES_FORUM 13
|
2014-12-01 23:55:08 +01:00
|
|
|
|
typedef enum
|
|
|
|
|
{
|
2017-04-18 19:55:56 +02:00
|
|
|
|
For_FORUM_COURSE_USRS = 0, // TODO: Change to 11 (also in database)
|
|
|
|
|
For_FORUM_COURSE_TCHS = 1, // TODO: Change to 12 (also in database)
|
|
|
|
|
For_FORUM_DEGREE_USRS = 2, // TODO: Change to 9 (also in database)
|
|
|
|
|
For_FORUM_DEGREE_TCHS = 3, // TODO: Change to 10 (also in database)
|
2021-03-07 21:21:04 +01:00
|
|
|
|
For_FORUM_CENTER_USRS = 4, // TODO: Change to 7 (also in database)
|
|
|
|
|
For_FORUM_CENTER_TCHS = 5, // TODO: Change to 8 (also in database)
|
2017-04-18 19:55:56 +02:00
|
|
|
|
For_FORUM_INSTIT_USRS = 6, // TODO: Change to 5 (also in database)
|
|
|
|
|
For_FORUM_INSTIT_TCHS = 7, // TODO: Change to 6 (also in database)
|
|
|
|
|
For_FORUM_GLOBAL_USRS = 8, // TODO: Change to 1 (also in database)
|
|
|
|
|
For_FORUM_GLOBAL_TCHS = 9, // TODO: Change to 2 (also in database)
|
|
|
|
|
For_FORUM__SWAD__USRS = 10, // TODO: Change to 3 (also in database)
|
|
|
|
|
For_FORUM__SWAD__TCHS = 11, // TODO: Change to 4 (also in database)
|
|
|
|
|
For_FORUM_UNKNOWN = 12, // TODO: Change to 0 (also in database)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
} For_ForumType_t; // Don't change numbers (used in database)
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forum
|
2017-04-17 11:57:55 +02:00
|
|
|
|
{
|
2017-04-17 19:03:21 +02:00
|
|
|
|
For_ForumType_t Type; // Type of forum
|
2023-04-06 12:39:13 +02:00
|
|
|
|
long HieCod; // Hierachy code (code of institution, center, degree or course)
|
2017-04-17 11:57:55 +02:00
|
|
|
|
};
|
|
|
|
|
|
2020-04-10 19:14:08 +02:00
|
|
|
|
struct For_Thread
|
2020-04-07 03:01:41 +02:00
|
|
|
|
{
|
2020-04-10 19:14:08 +02:00
|
|
|
|
long ThrCod; // Thread code
|
2020-04-10 21:57:50 +02:00
|
|
|
|
long PstCod[Dat_NUM_START_END_TIME];
|
|
|
|
|
long UsrCod[Dat_NUM_START_END_TIME];
|
|
|
|
|
time_t WriteTime[Dat_NUM_START_END_TIME];
|
2023-05-31 09:29:23 +02:00
|
|
|
|
Cns_DisabledOrEnabled_t Enabled[Dat_NUM_START_END_TIME];
|
2017-01-17 03:10:43 +01:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumPosts;
|
|
|
|
|
unsigned NumUnreadPosts; // Number of my unread posts in thread
|
|
|
|
|
unsigned NumMyPosts; // Number of posts written by me in thread
|
|
|
|
|
unsigned NumWriters;
|
|
|
|
|
unsigned NumReaders;
|
|
|
|
|
};
|
2017-01-29 21:41:08 +01:00
|
|
|
|
|
2020-04-10 19:14:08 +02:00
|
|
|
|
struct For_Post
|
|
|
|
|
{
|
|
|
|
|
long PstCod; // Post code
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct For_Forums
|
|
|
|
|
{
|
|
|
|
|
For_ForumSet_t ForumSet;
|
|
|
|
|
Dat_StartEndTime_t ThreadsOrder;
|
|
|
|
|
unsigned CurrentPageThrs;
|
|
|
|
|
unsigned CurrentPagePsts;
|
|
|
|
|
struct For_Forum Forum; // Forum selected
|
2020-11-11 01:14:53 +01:00
|
|
|
|
struct
|
|
|
|
|
{
|
|
|
|
|
long Selected; // Thread selected
|
|
|
|
|
long Current; // Current thread
|
|
|
|
|
long ToMove; // Thread to move
|
|
|
|
|
} Thread;
|
2020-04-14 00:11:28 +02:00
|
|
|
|
long PstCod; // Post selected
|
2020-04-10 19:14:08 +02:00
|
|
|
|
};
|
|
|
|
|
|
2020-04-05 22:53:58 +02:00
|
|
|
|
#define For_DEFAULT_ORDER Dat_END_TIME
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-01-13 10:49:56 +01:00
|
|
|
|
#define For_MAX_BYTES_FORUM_NAME (512 - 1)
|
|
|
|
|
|
2022-09-24 19:17:00 +02:00
|
|
|
|
// Links to go to <section>
|
|
|
|
|
#define For_REMOVE_THREAD_SECTION_ID "remove_thread"
|
|
|
|
|
#define For_FORUM_THREADS_SECTION_ID "forum_threads"
|
|
|
|
|
#define For_NEW_THREAD_SECTION_ID "new_thread"
|
|
|
|
|
#define For_FORUM_POSTS_SECTION_ID "thread_posts"
|
|
|
|
|
#define For_NEW_POST_SECTION_ID "new_post"
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Public prototypes *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
void For_ResetForums (struct For_Forums *Forums);
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_EnablePost (void);
|
|
|
|
|
void For_DisablePost (void);
|
2016-04-10 19:19:20 +02:00
|
|
|
|
|
2023-04-06 12:39:13 +02:00
|
|
|
|
long For_GetThreadForumTypeAndHieCodOfAPost (long PstCod,struct For_Forum *Forum);
|
|
|
|
|
void For_GetForumTypeAndHieCodOfAThread (long ThrCod,struct For_Forum *Forum);
|
2016-04-10 19:19:20 +02:00
|
|
|
|
|
2022-09-24 19:17:00 +02:00
|
|
|
|
void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
|
|
|
|
Ale_AlertType_t AlertType,const char *Message);
|
|
|
|
|
|
2017-03-08 14:12:33 +01:00
|
|
|
|
void For_GetSummaryAndContentForumPst (char SummaryStr[Ntf_MAX_BYTES_SUMMARY + 1],
|
2017-01-13 10:49:56 +01:00
|
|
|
|
char **ContentStr,
|
2023-11-05 19:44:03 +01:00
|
|
|
|
long PstCod,Ntf_GetContent_t GetContent);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
void For_PutAllParsForum (unsigned NumPageThreads,
|
|
|
|
|
unsigned NumPagePosts,
|
|
|
|
|
For_ForumSet_t ForumSet,
|
|
|
|
|
Dat_StartEndTime_t Order,
|
2023-04-06 12:39:13 +02:00
|
|
|
|
long HieCod,
|
2023-03-10 00:13:55 +01:00
|
|
|
|
long ThrCod,
|
|
|
|
|
long PstCod);
|
2022-09-24 19:17:00 +02:00
|
|
|
|
void For_ShowForumList (struct For_Forums *Forums);
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
void For_SetForumName (const struct For_Forum *Forum,
|
2017-01-13 10:49:56 +01:00
|
|
|
|
char ForumName[For_MAX_BYTES_FORUM_NAME + 1],
|
2018-12-08 16:43:13 +01:00
|
|
|
|
Lan_Language_t Language,bool UseHTMLEntities);
|
2017-04-16 23:48:05 +02:00
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_ShowForumTheads (void);
|
2022-09-24 19:17:00 +02:00
|
|
|
|
void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums,
|
|
|
|
|
Ale_AlertType_t AlertType,const char *Message);
|
2017-04-13 23:53:57 +02:00
|
|
|
|
|
2023-04-18 22:13:37 +02:00
|
|
|
|
void For_GetThreadData (struct For_Thread *Thr);
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_ShowThreadPosts (void);
|
2022-09-24 19:17:00 +02:00
|
|
|
|
|
2023-03-10 00:13:55 +01:00
|
|
|
|
void For_GetParsForums (struct For_Forums *Forums);
|
2022-09-24 19:17:00 +02:00
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_ReceiveForumPost (void);
|
|
|
|
|
void For_RemovePost (void);
|
2023-03-17 12:51:11 +01:00
|
|
|
|
void For_ReqRemThread (void);
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_RemoveThread (void);
|
|
|
|
|
void For_CutThread (void);
|
|
|
|
|
void For_PasteThread (void);
|
2016-10-27 22:26:52 +02:00
|
|
|
|
|
2022-01-03 02:47:16 +01:00
|
|
|
|
//-------------------------------- Figures ------------------------------------
|
|
|
|
|
void For_GetAndShowForumStats (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#endif
|