2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_forum.c: forums
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
SWAD (Shared Workspace At a Distance),
|
|
|
|
|
is a web platform developed at the University of Granada (Spain),
|
|
|
|
|
and used to support university teaching.
|
|
|
|
|
|
|
|
|
|
This file is part of SWAD core.
|
2021-02-09 12:43:45 +01:00
|
|
|
|
Copyright (C) 1999-2021 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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-10-22 00:31:44 +02:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <malloc.h> // For malloc
|
|
|
|
|
#include <mysql/mysql.h> // To access MySQL databases
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2018-10-22 00:31:44 +02:00
|
|
|
|
#include <stdio.h> // For asprintf
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <time.h> // For time_t
|
|
|
|
|
|
|
|
|
|
#include "swad_action.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#include "swad_center_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_config.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#include "swad_course_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_database.h"
|
2021-11-03 11:35:21 +01:00
|
|
|
|
#include "swad_degree_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_figure.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_forum.h"
|
2021-09-15 13:48:41 +02:00
|
|
|
|
#include "swad_forum_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2021-02-11 23:27:48 +01:00
|
|
|
|
#include "swad_hierarchy.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_layout.h"
|
2015-01-17 20:06:25 +01:00
|
|
|
|
#include "swad_logo.h"
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_message.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_notification.h"
|
2021-10-01 09:11:58 +02:00
|
|
|
|
#include "swad_notification_database.h"
|
2020-04-07 03:01:41 +02:00
|
|
|
|
#include "swad_pagination.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_parameter.h"
|
2015-03-14 17:39:04 +01:00
|
|
|
|
#include "swad_profile.h"
|
2021-10-07 01:21:23 +02:00
|
|
|
|
#include "swad_profile_database.h"
|
2016-12-13 13:32:19 +01:00
|
|
|
|
#include "swad_role.h"
|
2019-03-12 21:25:55 +01:00
|
|
|
|
#include "swad_timeline.h"
|
2021-02-27 14:25:17 +01:00
|
|
|
|
#include "swad_timeline_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-11-21 11:39:30 +01:00
|
|
|
|
/************************ Public constants and types *************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
const Act_Action_t For_ActionsSeeFor[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActSeeForCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActSeeForCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActSeeForDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActSeeForDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActSeeForCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActSeeForCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActSeeForInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActSeeForInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActSeeForGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActSeeForGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActSeeForSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActSeeForSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2019-11-21 11:39:30 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const Act_Action_t For_ActionsSeePstFor[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActSeePstForCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActSeePstForCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActSeePstForDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActSeePstForDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActSeePstForCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActSeePstForCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActSeePstForInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActSeePstForInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActSeePstForGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActSeePstForGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActSeePstForSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActSeePstForSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2019-11-21 11:39:30 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const Act_Action_t For_ActionsRecThrFor[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActRcvThrForCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActRcvThrForCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActRcvThrForDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActRcvThrForDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActRcvThrForCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActRcvThrForCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActRcvThrForInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActRcvThrForInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActRcvThrForGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActRcvThrForGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActRcvThrForSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActRcvThrForSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2019-11-21 11:39:30 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const Act_Action_t For_ActionsRecRepFor[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActRcvRepForCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActRcvRepForCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActRcvRepForDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActRcvRepForDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActRcvRepForCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActRcvRepForCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActRcvRepForInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActRcvRepForInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActRcvRepForGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActRcvRepForGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActRcvRepForSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActRcvRepForSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2019-11-21 11:39:30 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const Act_Action_t For_ActionsReqDelThr[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActReqDelThrCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActReqDelThrCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActReqDelThrDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActReqDelThrDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActReqDelThrCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActReqDelThrCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActReqDelThrInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActReqDelThrInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActReqDelThrGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActReqDelThrGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActReqDelThrSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActReqDelThrSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2019-11-21 11:39:30 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const Act_Action_t For_ActionsDelThrFor[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActDelThrForCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActDelThrForCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActDelThrForDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActDelThrForDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActDelThrForCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActDelThrForCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActDelThrForInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActDelThrForInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActDelThrForGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActDelThrForGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActDelThrForSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActDelThrForSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2019-11-21 11:39:30 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const Act_Action_t For_ActionsCutThrFor[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActCutThrForCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActCutThrForCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActCutThrForDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActCutThrForDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActCutThrForCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActCutThrForCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActCutThrForInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActCutThrForInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActCutThrForGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActCutThrForGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActCutThrForSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActCutThrForSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2019-11-21 11:39:30 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const Act_Action_t For_ActionsPasThrFor[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActPasThrForCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActPasThrForCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActPasThrForDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActPasThrForDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActPasThrForCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActPasThrForCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActPasThrForInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActPasThrForInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActPasThrForGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActPasThrForGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActPasThrForSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActPasThrForSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2019-11-21 11:39:30 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const Act_Action_t For_ActionsDelPstFor[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActDelPstForCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActDelPstForCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActDelPstForDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActDelPstForDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActDelPstForCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActDelPstForCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActDelPstForInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActDelPstForInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActDelPstForGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActDelPstForGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActDelPstForSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActDelPstForSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2019-11-21 11:39:30 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const Act_Action_t For_ActionsEnbPstFor[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActEnbPstForCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActEnbPstForCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActEnbPstForDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActEnbPstForDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActEnbPstForCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActEnbPstForCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActEnbPstForInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActEnbPstForInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActEnbPstForGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActEnbPstForGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActEnbPstForSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActEnbPstForSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
2019-11-21 11:39:30 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
const Act_Action_t For_ActionsDisPstFor[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_COURSE_USRS] = ActDisPstForCrsUsr,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = ActDisPstForCrsTch,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = ActDisPstForDegUsr,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = ActDisPstForDegTch,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = ActDisPstForCtrUsr,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = ActDisPstForCtrTch,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = ActDisPstForInsUsr,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = ActDisPstForInsTch,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = ActDisPstForGenUsr,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = ActDisPstForGenTch,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = ActDisPstForSWAUsr,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = ActDisPstForSWATch,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = ActSeeFor,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********************** Private constants and types *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#define For_FORUM_MAX_LEVELS 4
|
|
|
|
|
|
|
|
|
|
static const unsigned PermissionThreadDeletion[For_NUM_TYPES_FORUM] =
|
|
|
|
|
{
|
|
|
|
|
[For_FORUM_COURSE_USRS] = 0x3F0,
|
|
|
|
|
[For_FORUM_COURSE_TCHS] = 0x3F0,
|
|
|
|
|
[For_FORUM_DEGREE_USRS] = 0x3E0,
|
|
|
|
|
[For_FORUM_DEGREE_TCHS] = 0x3E0,
|
2021-03-07 21:21:04 +01:00
|
|
|
|
[For_FORUM_CENTER_USRS] = 0x3C0,
|
|
|
|
|
[For_FORUM_CENTER_TCHS] = 0x3C0,
|
2019-11-21 11:39:30 +01:00
|
|
|
|
[For_FORUM_INSTIT_USRS] = 0x380,
|
|
|
|
|
[For_FORUM_INSTIT_TCHS] = 0x380,
|
|
|
|
|
[For_FORUM_GLOBAL_USRS] = 0x300,
|
|
|
|
|
[For_FORUM_GLOBAL_TCHS] = 0x300,
|
|
|
|
|
[For_FORUM__SWAD__USRS] = 0x300,
|
|
|
|
|
[For_FORUM__SWAD__TCHS] = 0x300,
|
|
|
|
|
[For_FORUM_UNKNOWN ] = 0x000,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
2017-04-11 14:27:45 +02:00
|
|
|
|
// Links to go to <section>
|
2017-05-25 13:43:54 +02:00
|
|
|
|
#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"
|
2017-04-10 12:41:26 +02:00
|
|
|
|
|
2016-04-10 14:09:50 +02:00
|
|
|
|
// Forum images will be saved with:
|
|
|
|
|
// - maximum width of For_IMAGE_SAVED_MAX_HEIGHT
|
|
|
|
|
// - maximum height of For_IMAGE_SAVED_MAX_HEIGHT
|
|
|
|
|
// - maintaining the original aspect ratio (aspect ratio recommended: 3:2)
|
|
|
|
|
#define For_IMAGE_SAVED_MAX_WIDTH 768
|
2020-02-13 22:33:31 +01:00
|
|
|
|
#define For_IMAGE_SAVED_MAX_HEIGHT 768
|
|
|
|
|
#define For_IMAGE_SAVED_QUALITY 90 // 1 to 100
|
2016-04-10 14:09:50 +02:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
/*****************************************************************************/
|
2021-11-09 18:32:04 +01:00
|
|
|
|
/****************************** Private prototypes ***************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-04-10 19:19:20 +02:00
|
|
|
|
static long For_InsertForumPst (long ThrCod,long UsrCod,
|
|
|
|
|
const char *Subject,const char *Content,
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Med_Media *Media);
|
2019-03-18 15:42:22 +01:00
|
|
|
|
static bool For_RemoveForumPst (long PstCod,long MedCod);
|
2016-04-10 19:19:20 +02:00
|
|
|
|
static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod);
|
|
|
|
|
|
|
|
|
|
static void For_RemoveThreadOnly (long ThrCod);
|
|
|
|
|
static void For_RemoveThreadAndItsPsts (long ThrCod);
|
2017-04-18 19:55:56 +02:00
|
|
|
|
|
2015-10-24 20:12:03 +02:00
|
|
|
|
static time_t For_GetThrReadTime (long ThrCod);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
|
|
|
|
Ale_AlertType_t AlertType,const char *Message);
|
|
|
|
|
static void For_PutIconNewPost (void *Forums);
|
|
|
|
|
static void For_PutAllHiddenParamsNewPost (void *Forums);
|
2016-11-07 10:53:03 +01:00
|
|
|
|
|
2020-10-14 00:59:24 +02:00
|
|
|
|
static void For_ShowAForumPost (struct For_Forums *Forums,
|
|
|
|
|
unsigned PstNum,
|
2017-01-17 03:10:43 +01:00
|
|
|
|
bool LastPst,char LastSubject[Cns_MAX_BYTES_SUBJECT + 1],
|
2016-11-07 10:53:03 +01:00
|
|
|
|
bool NewPst,bool ICanModerateForum);
|
|
|
|
|
static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
2021-02-15 22:49:44 +01:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1],
|
2017-01-17 03:10:43 +01:00
|
|
|
|
char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Med_Media *Media);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_WriteNumberOfPosts (const struct For_Forums *Forums,long UsrCod);
|
2016-11-07 10:53:03 +01:00
|
|
|
|
|
2020-10-14 00:59:24 +02:00
|
|
|
|
static void For_PutParamsForum (void *Forums);
|
|
|
|
|
|
2017-04-18 01:25:44 +02:00
|
|
|
|
static void For_PutParamForumSet (For_ForumSet_t ForumSet);
|
|
|
|
|
static void For_PutParamForumLocation (long Location);
|
|
|
|
|
static void For_PutHiddenParamThrCod (long ThrCod);
|
|
|
|
|
static void For_PutHiddenParamPstCod (long PstCod);
|
2017-04-17 12:19:58 +02:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_ShowForumList (struct For_Forums *Forums);
|
2020-04-08 03:41:05 +02:00
|
|
|
|
static void For_PutIconsForums (__attribute__((unused)) void *Args);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_PutFormWhichForums (const struct For_Forums *Forums);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_WriteLinksToGblForums (const struct For_Forums *Forums,
|
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]);
|
|
|
|
|
static void For_WriteLinksToPlatformForums (const struct For_Forums *Forums,
|
|
|
|
|
bool IsLastForum,
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static long For_WriteLinksToInsForums (const struct For_Forums *Forums,
|
|
|
|
|
long InsCod,bool IsLastIns,
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static long For_WriteLinksToCtrForums (const struct For_Forums *Forums,
|
|
|
|
|
long CtrCod,bool IsLastCtr,
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static long For_WriteLinksToDegForums (const struct For_Forums *Forums,
|
|
|
|
|
long DegCod,bool IsLastDeg,
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static long For_WriteLinksToCrsForums (const struct For_Forums *Forums,
|
|
|
|
|
long CrsCod,bool IsLastCrs,
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_WriteLinkToForum (const struct For_Forums *Forums,
|
2021-02-15 23:58:48 +01:00
|
|
|
|
const struct For_Forum *Forum,
|
2019-11-18 17:59:02 +01:00
|
|
|
|
bool Highlight,
|
2017-04-19 12:34:38 +02:00
|
|
|
|
unsigned Level,
|
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS]);
|
2021-02-15 23:58:48 +01:00
|
|
|
|
static unsigned For_GetNumThrsWithNewPstsInForum (const struct For_Forum *Forum,
|
2017-04-16 23:48:05 +02:00
|
|
|
|
unsigned NumThreads);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static unsigned For_GetNumOfUnreadPostsInThr (long ThrCod,unsigned NumPostsInThr);
|
2015-04-11 14:00:23 +02:00
|
|
|
|
|
2019-11-18 17:59:02 +01:00
|
|
|
|
static void For_WriteNumberOfThrs (unsigned NumThrs);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums,
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_AlertType_t AlertType,const char *Message);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_PutIconNewThread (void *Forums);
|
|
|
|
|
static void For_PutAllHiddenParamsNewThread (void *Forums);
|
2020-04-10 19:14:08 +02:00
|
|
|
|
static void For_ListForumThrs (struct For_Forums *Forums,
|
2020-04-07 03:01:41 +02:00
|
|
|
|
long ThrCods[Pag_ITEMS_PER_PAGE],
|
2017-04-14 01:02:33 +02:00
|
|
|
|
long ThrCodHighlighted,
|
2017-04-13 23:53:57 +02:00
|
|
|
|
struct Pagination *PaginationThrs);
|
2020-04-10 19:14:08 +02:00
|
|
|
|
static void For_GetThreadData (struct For_Thread *Thr);
|
2017-04-12 20:56:45 +02:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_GetParamsForums (struct For_Forums *Forums);
|
|
|
|
|
static void For_SetForumType (struct For_Forums *Forums);
|
|
|
|
|
static void For_RestrictAccess (const struct For_Forums *Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void For_WriteFormForumPst (struct For_Forums *Forums,
|
2020-04-07 03:01:41 +02:00
|
|
|
|
bool IsReply,const char *Subject);
|
2017-04-17 12:19:58 +02:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_PutAllHiddenParamsRemThread (void *Forums);
|
2017-04-28 10:35:41 +02:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
static bool For_CheckIfICanMoveThreads (void);
|
2017-04-17 12:19:58 +02:00
|
|
|
|
static void For_InsertThrInClipboard (long ThrCod);
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************** Reset forum ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void For_ResetForums (struct For_Forums *Forums)
|
|
|
|
|
{
|
2020-04-14 00:11:28 +02:00
|
|
|
|
Forums->ForumSet = For_DEFAULT_FORUM_SET;
|
|
|
|
|
Forums->ThreadsOrder = For_DEFAULT_ORDER;
|
|
|
|
|
Forums->CurrentPageThrs = 0;
|
|
|
|
|
Forums->CurrentPagePsts = 0;
|
2020-04-10 21:57:50 +02:00
|
|
|
|
|
2020-04-14 00:11:28 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM_UNKNOWN;
|
|
|
|
|
Forums->Forum.Location = -1L;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
|
2020-11-11 01:14:53 +01:00
|
|
|
|
Forums->Thread.Selected =
|
|
|
|
|
Forums->Thread.Current =
|
|
|
|
|
Forums->Thread.ToMove = -1L;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
|
2020-04-14 00:11:28 +02:00
|
|
|
|
Forums->PstCod = -1L;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************************** Enable a forum post **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_EnablePost (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-03-06 10:13:39 +01:00
|
|
|
|
extern const char *Txt_FORUM_Post_unbanned;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forums Forums;
|
|
|
|
|
|
|
|
|
|
/***** Reset forum *****/
|
|
|
|
|
For_ResetForums (&Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Get parameters related to forum *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_GetParamsForums (&Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Delete post from table of disabled posts *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
For_DB_RemovePstFromDisabled (Forums.PstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
|
|
|
|
/***** Show threads again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,NULL);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Show the posts again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowPostsOfAThread (&Forums,Ale_SUCCESS,Txt_FORUM_Post_unbanned);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Disable a forum post **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_DisablePost (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-03-06 10:13:39 +01:00
|
|
|
|
extern const char *Txt_FORUM_Post_banned;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forums Forums;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
/***** Get parameters related to forums *****/
|
|
|
|
|
For_GetParamsForums (&Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if post really exists, if it has not been removed *****/
|
2021-11-05 23:41:26 +01:00
|
|
|
|
if (For_DB_CheckIfForumPstExists (Forums.PstCod))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Insert post into table of banned posts *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
For_DB_InsertPstIntoDisabled (Forums.PstCod);
|
2017-04-18 09:55:25 +02:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
|
|
|
|
/***** Show threads again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,NULL);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
2017-04-18 09:55:25 +02:00
|
|
|
|
/***** Show the posts again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowPostsOfAThread (&Forums,Ale_SUCCESS,Txt_FORUM_Post_banned);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPostExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Insert a post new in the table of posts of forums ************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-04-10 19:19:20 +02:00
|
|
|
|
static long For_InsertForumPst (long ThrCod,long UsrCod,
|
|
|
|
|
const char *Subject,const char *Content,
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Med_Media *Media)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-03-19 11:20:29 +01:00
|
|
|
|
/***** Store media in filesystem and database *****/
|
|
|
|
|
Med_RemoveKeepOrStoreMedia (-1L,Media);
|
2019-03-18 15:42:22 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Insert forum post in the database *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
return For_DB_InsertForumPst (ThrCod,UsrCod,Subject,Content,Media->MedCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Delete a post from the forum post table *******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Return true if the post thread is deleted
|
|
|
|
|
|
2019-03-18 15:42:22 +01:00
|
|
|
|
static bool For_RemoveForumPst (long PstCod,long MedCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
long ThrCod;
|
|
|
|
|
bool ThreadDeleted = false;
|
|
|
|
|
|
2019-03-02 21:49:11 +01:00
|
|
|
|
/***** Remove media file attached to forum post *****/
|
2019-03-18 15:42:22 +01:00
|
|
|
|
Med_RemoveMedia (MedCod);
|
2016-04-10 23:59:45 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** If the post is the only one in its thread, delete that thread *****/
|
|
|
|
|
if (For_NumPstsInThrWithPstCod (PstCod,&ThrCod) < 2)
|
|
|
|
|
{
|
|
|
|
|
For_RemoveThreadOnly (ThrCod);
|
|
|
|
|
ThreadDeleted = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Delete the post from the table of disabled forum posts *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
For_DB_RemovePstFromDisabled (PstCod);
|
|
|
|
|
|
|
|
|
|
/***** Delete post from forum post table *****/
|
|
|
|
|
For_DB_RemovePst (PstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update the last post of the thread *****/
|
|
|
|
|
if (!ThreadDeleted)
|
2021-09-15 20:21:02 +02:00
|
|
|
|
For_DB_UpdateThrLastPst (ThrCod,For_DB_GetThrLastPst (ThrCod));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
return ThreadDeleted;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*********** Get the number of posts in the thread than holds a post *********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-04-10 19:19:20 +02:00
|
|
|
|
static unsigned For_NumPstsInThrWithPstCod (long PstCod,long *ThrCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned NumPsts;
|
|
|
|
|
|
2021-03-04 13:43:06 +01:00
|
|
|
|
/***** Initialize default values *****/
|
|
|
|
|
*ThrCod = -1L;
|
|
|
|
|
NumPsts = 0;
|
|
|
|
|
|
|
|
|
|
/***** Trivial check: PstCod should be > 0 *****/
|
|
|
|
|
if (PstCod <= 0)
|
|
|
|
|
return NumPsts;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-04 13:43:06 +01:00
|
|
|
|
/***** Get number of posts in the thread that holds a post from database *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
if (For_DB_GetThreadAndNumPostsGivenPstCod (&mysql_res,PstCod) == 1) // Result should have one row
|
2021-03-04 13:43:06 +01:00
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2021-09-15 13:48:41 +02:00
|
|
|
|
/*
|
|
|
|
|
row[0]: ThrCod
|
|
|
|
|
row[1]: COUNT(PstCod)
|
|
|
|
|
*/
|
|
|
|
|
if (sscanf (row[0],"%ld",ThrCod) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of posts in a thread.");
|
2021-09-15 13:48:41 +02:00
|
|
|
|
if (sscanf (row[1],"%u",&NumPsts) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Error when getting number of posts in a thread.");
|
2021-03-04 13:43:06 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumPsts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Delete a thread from the forum thread table *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-04-10 19:19:20 +02:00
|
|
|
|
static void For_RemoveThreadOnly (long ThrCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Indicate that this thread has not been read by anyone *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
For_DB_RemoveThrFromReadThrs (ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove thread code from thread clipboard *****/
|
2021-09-15 20:21:02 +02:00
|
|
|
|
For_DB_RemoveThrFromClipboard (ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Delete thread from forum thread table *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
For_DB_RemoveThread (ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Delete a thread from the forum thread table *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-04-10 19:19:20 +02:00
|
|
|
|
static void For_RemoveThreadAndItsPsts (long ThrCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-09-15 13:48:41 +02:00
|
|
|
|
/***** Delete disabled posts in thread *****/
|
|
|
|
|
For_DB_RemoveDisabledPstsInThread (ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Delete thread posts *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
For_DB_RemoveThreadPsts (ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Delete thread from forum thread table *****/
|
|
|
|
|
For_RemoveThreadOnly (ThrCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-04-17 11:57:55 +02:00
|
|
|
|
/*************** Get the forum type and location of a post *******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
void For_GetForumTypeAndLocationOfAPost (long PstCod,struct For_Forum *Forum)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-18 19:55:56 +02:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned UnsignedNum;
|
|
|
|
|
long LongNum;
|
|
|
|
|
|
|
|
|
|
/***** Set default forum type and location *****/
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum->Type = For_FORUM_UNKNOWN;
|
|
|
|
|
Forum->Location = -1L;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if there is a row with forum type *****/
|
2021-09-16 17:10:32 +02:00
|
|
|
|
if (For_DB_GetForumTypeAndLocationOfAPost (&mysql_res,PstCod))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2017-04-16 23:48:05 +02:00
|
|
|
|
|
|
|
|
|
/* Get forum type (row[0]) */
|
2017-04-18 19:55:56 +02:00
|
|
|
|
if (sscanf (row[0],"%u",&UnsignedNum) == 1)
|
|
|
|
|
if (UnsignedNum < For_NUM_TYPES_FORUM)
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum->Type = (For_ForumType_t) UnsignedNum;
|
2017-04-16 23:48:05 +02:00
|
|
|
|
|
|
|
|
|
/* Get forum location (row[1]) */
|
2017-04-18 19:55:56 +02:00
|
|
|
|
if (sscanf (row[1],"%ld",&LongNum) == 1)
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum->Location = LongNum;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Get thread read time for the current user ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-10-24 20:12:03 +02:00
|
|
|
|
static time_t For_GetThrReadTime (long ThrCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2015-10-24 20:12:03 +02:00
|
|
|
|
time_t ReadTimeUTC;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get read time of a thread from database *****/
|
2021-09-16 17:10:32 +02:00
|
|
|
|
if (For_DB_GetThrReadTime (&mysql_res,ThrCod))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2015-10-24 20:12:03 +02:00
|
|
|
|
/***** There is a row ==> get read time *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2015-10-24 20:12:03 +02:00
|
|
|
|
|
|
|
|
|
ReadTimeUTC = Dat_GetUNIXTimeFromStr (row[0]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2021-09-16 17:10:32 +02:00
|
|
|
|
ReadTimeUTC = (time_t) 0; // If there is no row for this thread and current user,
|
|
|
|
|
// then current user has not read this thread
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2015-10-24 20:12:03 +02:00
|
|
|
|
|
|
|
|
|
return ReadTimeUTC;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-04-13 20:09:22 +02:00
|
|
|
|
/************************ Show posts in a thread *****************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_ShowPostsOfAThread (struct For_Forums *Forums,
|
|
|
|
|
Ale_AlertType_t AlertType,const char *Message)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-09-26 17:20:01 +02:00
|
|
|
|
extern const char *Hlp_COMMUNICATION_Forums_posts;
|
2015-04-11 14:00:23 +02:00
|
|
|
|
extern const char *Txt_Thread;
|
2020-04-14 00:11:28 +02:00
|
|
|
|
struct For_Thread Thread;
|
2017-04-11 19:05:15 +02:00
|
|
|
|
char LastSubject[Cns_MAX_BYTES_SUBJECT + 1];
|
|
|
|
|
char FrameTitle[128 + Cns_MAX_BYTES_SUBJECT];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2021-04-16 13:51:12 +02:00
|
|
|
|
unsigned NumRow;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumPst = 0; // Initialized to avoid warning
|
|
|
|
|
unsigned NumPsts;
|
2015-10-24 20:12:03 +02:00
|
|
|
|
time_t ReadTimeUTC; // Read time of thread for the current user
|
|
|
|
|
time_t CreatTimeUTC; // Creation time of post
|
2017-04-13 20:09:22 +02:00
|
|
|
|
struct Pagination PaginationPsts;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool NewPst = false;
|
|
|
|
|
bool ICanModerateForum = false;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get data of the thread *****/
|
2020-11-11 01:14:53 +01:00
|
|
|
|
Thread.ThrCod =
|
|
|
|
|
Forums->Thread.Current =
|
|
|
|
|
Forums->Thread.Selected;
|
2020-04-14 00:11:28 +02:00
|
|
|
|
For_GetThreadData (&Thread);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Get if there is a thread ready to be moved *****/
|
|
|
|
|
if (For_CheckIfICanMoveThreads ())
|
2021-05-10 21:10:06 +02:00
|
|
|
|
Forums->Thread.ToMove = For_DB_GetThrInMyClipboard ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Get thread read time for the current user *****/
|
2020-04-14 00:11:28 +02:00
|
|
|
|
ReadTimeUTC = For_GetThrReadTime (Thread.ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 09:55:25 +02:00
|
|
|
|
/***** Show alert after action *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_Begin (For_FORUM_POSTS_SECTION_ID);
|
2017-04-18 09:55:25 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Ale_ShowAlerts (For_FORUM_POSTS_SECTION_ID); // Possible pending alerts
|
|
|
|
|
if (Message)
|
|
|
|
|
if (Message[0])
|
|
|
|
|
Ale_ShowAlert (AlertType,Message);
|
|
|
|
|
|
|
|
|
|
/***** Begin box *****/
|
|
|
|
|
snprintf (FrameTitle,sizeof (FrameTitle),"%s: %s",
|
|
|
|
|
Txt_Thread,Thread.Subject);
|
|
|
|
|
Box_BoxBegin (NULL,FrameTitle,
|
|
|
|
|
For_PutIconNewPost,Forums,
|
|
|
|
|
Hlp_COMMUNICATION_Forums_posts,Box_NOT_CLOSABLE);
|
|
|
|
|
|
|
|
|
|
/***** Get posts of a thread from database *****/
|
|
|
|
|
LastSubject[0] = '\0';
|
2021-09-16 17:10:32 +02:00
|
|
|
|
if ((NumPsts = For_DB_GetPostsOfAThread (&mysql_res,Thread.ThrCod))) // If there are posts...
|
2021-06-17 13:26:25 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Check if I can moderate posts in forum *****/
|
|
|
|
|
switch (Forums->Forum.Type)
|
|
|
|
|
{
|
|
|
|
|
case For_FORUM_GLOBAL_USRS:
|
|
|
|
|
case For_FORUM_GLOBAL_TCHS:
|
|
|
|
|
case For_FORUM__SWAD__USRS:
|
|
|
|
|
case For_FORUM__SWAD__TCHS:
|
|
|
|
|
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
|
|
|
|
break;
|
|
|
|
|
case For_FORUM_INSTIT_USRS:
|
|
|
|
|
case For_FORUM_INSTIT_TCHS:
|
|
|
|
|
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM);
|
|
|
|
|
break;
|
|
|
|
|
case For_FORUM_CENTER_USRS:
|
|
|
|
|
case For_FORUM_CENTER_TCHS:
|
|
|
|
|
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_CTR_ADM);
|
|
|
|
|
break;
|
|
|
|
|
case For_FORUM_DEGREE_USRS:
|
|
|
|
|
case For_FORUM_DEGREE_TCHS:
|
|
|
|
|
case For_FORUM_COURSE_TCHS:
|
|
|
|
|
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM);
|
|
|
|
|
break;
|
|
|
|
|
case For_FORUM_COURSE_USRS:
|
|
|
|
|
ICanModerateForum = (Gbl.Usrs.Me.Role.Logged >= Rol_TCH);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
ICanModerateForum = false;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Compute variables related to pagination *****/
|
|
|
|
|
PaginationPsts.NumItems = NumPsts;
|
|
|
|
|
PaginationPsts.CurrentPage = (int) Forums->CurrentPagePsts;
|
|
|
|
|
Pag_CalculatePagination (&PaginationPsts);
|
|
|
|
|
PaginationPsts.Anchor = For_FORUM_POSTS_SECTION_ID;
|
|
|
|
|
Forums->CurrentPagePsts = (unsigned) PaginationPsts.CurrentPage;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Write links to pages *****/
|
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_POSTS_FORUM,&PaginationPsts,
|
|
|
|
|
Forums,Thread.ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Begin table *****/
|
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Show posts from this page, the author and the date of last reply *****/
|
|
|
|
|
mysql_data_seek (mysql_res,(my_ulonglong) (PaginationPsts.FirstItemVisible - 1));
|
|
|
|
|
for (NumRow = PaginationPsts.FirstItemVisible;
|
|
|
|
|
NumRow <= PaginationPsts.LastItemVisible;
|
|
|
|
|
NumRow++)
|
|
|
|
|
{
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
if (sscanf (row[0],"%ld",&Forums->PstCod) != 1)
|
|
|
|
|
Err_WrongPostExit ();
|
|
|
|
|
|
|
|
|
|
CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
|
|
|
|
|
|
|
|
|
|
NumPst = NumRow;
|
|
|
|
|
NewPst = (CreatTimeUTC > ReadTimeUTC);
|
|
|
|
|
|
|
|
|
|
if (NewPst && NumRow == PaginationPsts.LastItemVisible)
|
|
|
|
|
/* Update for_read table indicating that this thread page and previous ones
|
|
|
|
|
have been read and have no new posts for the current user
|
|
|
|
|
(even if any previous pages have been no read actually).
|
|
|
|
|
Note that database is not updated with the current time,
|
|
|
|
|
but with the creation time of the most recent post
|
|
|
|
|
in this page of threads. */
|
|
|
|
|
For_DB_UpdateThrReadTime (Thread.ThrCod,CreatTimeUTC);
|
|
|
|
|
|
|
|
|
|
/* Show post */
|
|
|
|
|
For_ShowAForumPost (Forums,NumPst,
|
|
|
|
|
(NumRow == NumPsts),LastSubject,
|
|
|
|
|
NewPst,ICanModerateForum);
|
|
|
|
|
|
|
|
|
|
/* Mark possible notification as seen */
|
|
|
|
|
switch (Forums->Forum.Type)
|
|
|
|
|
{
|
|
|
|
|
case For_FORUM_COURSE_TCHS:
|
|
|
|
|
case For_FORUM_COURSE_USRS:
|
2021-11-09 12:36:32 +01:00
|
|
|
|
Ntf_DB_MarkNotifAsSeenUsingCod (Ntf_EVENT_FORUM_POST_COURSE,
|
|
|
|
|
Forums->PstCod);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (Thread.NumMyPosts)
|
2021-11-09 12:36:32 +01:00
|
|
|
|
Ntf_DB_MarkNotifAsSeenUsingCod (Ntf_EVENT_FORUM_REPLY,
|
|
|
|
|
Forums->PstCod);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
}
|
2017-04-11 19:05:15 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write again links to pages *****/
|
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_POSTS_FORUM,&PaginationPsts,
|
|
|
|
|
Forums,Thread.ThrCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Form to write a new post in the thread *****/
|
|
|
|
|
HTM_SECTION_Begin (For_NEW_POST_SECTION_ID);
|
|
|
|
|
For_WriteFormForumPst (Forums,true,LastSubject);
|
|
|
|
|
HTM_SECTION_End ();
|
|
|
|
|
|
|
|
|
|
/***** End box *****/
|
|
|
|
|
Box_BoxEnd ();
|
2017-04-11 19:05:15 +02:00
|
|
|
|
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-07 10:53:03 +01:00
|
|
|
|
/*****************************************************************************/
|
2017-04-17 12:19:58 +02:00
|
|
|
|
/*********************** Put icon to write a new post ************************/
|
2017-04-10 12:41:26 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_PutIconNewPost (void *Forums)
|
2017-04-10 12:41:26 +02:00
|
|
|
|
{
|
2017-04-17 12:19:58 +02:00
|
|
|
|
extern const char *Txt_New_post;
|
2017-04-10 12:41:26 +02:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
if (Forums)
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Ico_PutContextualIconToAdd (For_ActionsSeePstFor[((struct For_Forums *) Forums)->Forum.Type],
|
2020-03-26 02:54:30 +01:00
|
|
|
|
For_NEW_POST_SECTION_ID,
|
2020-04-09 21:36:21 +02:00
|
|
|
|
For_PutAllHiddenParamsNewPost,Forums,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Txt_New_post);
|
2017-04-10 12:41:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_PutAllHiddenParamsNewPost (void *Forums)
|
2017-04-19 14:43:08 +02:00
|
|
|
|
{
|
2020-04-07 03:01:41 +02:00
|
|
|
|
if (Forums)
|
|
|
|
|
For_PutAllHiddenParamsForum (((struct For_Forums *) Forums)->CurrentPageThrs, // Page of threads = current
|
|
|
|
|
UINT_MAX, // Page of posts = last
|
|
|
|
|
((struct For_Forums *) Forums)->ForumSet,
|
|
|
|
|
((struct For_Forums *) Forums)->ThreadsOrder,
|
2020-04-10 19:14:08 +02:00
|
|
|
|
((struct For_Forums *) Forums)->Forum.Location,
|
2020-11-11 01:14:53 +01:00
|
|
|
|
((struct For_Forums *) Forums)->Thread.Current,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
-1L);
|
2017-04-19 14:43:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Show a post from forum *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-10-14 00:59:24 +02:00
|
|
|
|
static void For_ShowAForumPost (struct For_Forums *Forums,
|
|
|
|
|
unsigned PstNum,
|
2017-01-17 03:10:43 +01:00
|
|
|
|
bool LastPst,char LastSubject[Cns_MAX_BYTES_SUBJECT + 1],
|
2015-10-24 20:12:03 +02:00
|
|
|
|
bool NewPst,bool ICanModerateForum)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-13 20:09:22 +02:00
|
|
|
|
extern const char *Txt_MSG_New;
|
2015-07-21 20:20:59 +02:00
|
|
|
|
extern const char *Txt_MSG_Open;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_no_subject;
|
2019-03-06 10:13:39 +01:00
|
|
|
|
extern const char *Txt_FORUM_Post_X_allowed;
|
|
|
|
|
extern const char *Txt_FORUM_Post_banned;
|
|
|
|
|
extern const char *Txt_FORUM_Post_X_banned;
|
|
|
|
|
extern const char *Txt_FORUM_Post_X_allowed_Click_to_ban_it;
|
|
|
|
|
extern const char *Txt_FORUM_Post_X_banned_Click_to_unban_it;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_This_post_has_been_banned_probably_for_not_satisfy_the_rules_of_the_forums;
|
|
|
|
|
struct UsrData UsrDat;
|
2015-10-24 20:12:03 +02:00
|
|
|
|
time_t CreatTimeUTC; // Creation time of a post
|
2017-01-17 03:10:43 +01:00
|
|
|
|
char OriginalContent[Cns_MAX_BYTES_LONG_TEXT + 1];
|
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
|
|
|
|
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Med_Media Media;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool Enabled;
|
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
2016-04-10 19:19:20 +02:00
|
|
|
|
/***** Initialize image *****/
|
2019-03-02 21:49:11 +01:00
|
|
|
|
Med_MediaConstructor (&Media);
|
2016-04-10 19:19:20 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Check if post is enabled *****/
|
2021-11-24 22:57:10 +01:00
|
|
|
|
Enabled = !For_DB_GetIfPstIsDisabled (Forums->PstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of post *****/
|
2020-10-14 00:59:24 +02:00
|
|
|
|
For_GetPstData (Forums->PstCod,&UsrDat.UsrCod,&CreatTimeUTC,
|
2019-03-02 21:49:11 +01:00
|
|
|
|
Subject,OriginalContent,&Media);
|
2016-04-11 02:16:27 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Enabled)
|
|
|
|
|
/* Return this subject as last subject */
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (LastSubject,Subject,Cns_MAX_BYTES_SUBJECT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 15:15:55 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Put an icon with post status *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CONTEXT_COL %s\"",
|
|
|
|
|
NewPst ? "MSG_TIT_BG_NEW" :
|
|
|
|
|
"MSG_TIT_BG");
|
|
|
|
|
Ico_PutIcon (NewPst ? "envelope.svg" :
|
|
|
|
|
"envelope-open-text.svg",
|
|
|
|
|
NewPst ? Txt_MSG_New :
|
|
|
|
|
Txt_MSG_Open,
|
|
|
|
|
"ICO16x16");
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write post number *****/
|
|
|
|
|
Msg_WriteMsgNumber ((unsigned long) PstNum,NewPst);
|
|
|
|
|
|
|
|
|
|
/***** Write date *****/
|
|
|
|
|
Msg_WriteMsgDate (CreatTimeUTC,NewPst ? "MSG_TIT_BG_NEW" :
|
|
|
|
|
"MSG_TIT_BG");
|
|
|
|
|
|
|
|
|
|
/***** Write subject *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s LT\"",NewPst ? "MSG_TIT_BG_NEW" :
|
|
|
|
|
"MSG_TIT_BG");
|
|
|
|
|
if (Enabled)
|
|
|
|
|
{
|
|
|
|
|
if (Subject[0])
|
|
|
|
|
HTM_Txt (Subject);
|
|
|
|
|
else
|
|
|
|
|
HTM_TxtF ("[%s]",Txt_no_subject);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
HTM_TxtF ("[%s]",Txt_FORUM_Post_banned);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2017-04-18 16:44:44 +02:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
/***** Form to ban/unban post *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CONTEXT_COL\"");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
if (ICanModerateForum)
|
|
|
|
|
{
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Frm_BeginFormAnchor (Enabled ? For_ActionsDisPstFor[Forums->Forum.Type] :
|
2021-04-24 15:10:07 +02:00
|
|
|
|
For_ActionsEnbPstFor[Forums->Forum.Type],
|
|
|
|
|
For_FORUM_POSTS_SECTION_ID);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
For_PutParamsForum (Forums);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Ico_PutIconLink (Enabled ? "eye-green.svg" :
|
|
|
|
|
"eye-slash-red.svg",
|
2021-12-15 14:02:49 +01:00
|
|
|
|
Str_BuildString (Enabled ? Txt_FORUM_Post_X_allowed_Click_to_ban_it :
|
|
|
|
|
Txt_FORUM_Post_X_banned_Click_to_unban_it,
|
|
|
|
|
PstNum));
|
2021-12-15 00:47:29 +01:00
|
|
|
|
Str_FreeStrings ();
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Ico_PutIcon (Enabled ? "eye-green.svg" :
|
|
|
|
|
"eye-slash-red.svg",
|
2021-12-15 14:02:49 +01:00
|
|
|
|
Str_BuildString (Enabled ? Txt_FORUM_Post_X_allowed :
|
|
|
|
|
Txt_FORUM_Post_X_banned,
|
|
|
|
|
PstNum),
|
2021-04-24 15:10:07 +02:00
|
|
|
|
"ICO_HIDDEN ICO16x16");
|
2021-12-15 00:47:29 +01:00
|
|
|
|
Str_FreeStrings ();
|
2021-04-24 15:10:07 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
/***** Form to remove post *****/
|
|
|
|
|
if (LastPst)
|
|
|
|
|
if (Usr_ItsMe (UsrDat.UsrCod))
|
|
|
|
|
// Post can be removed if post is the last (without answers) and it's mine
|
|
|
|
|
Ico_PutContextualIconToRemove (For_ActionsDelPstFor[Forums->Forum.Type],
|
|
|
|
|
PstNum == 1 ? For_FORUM_THREADS_SECTION_ID : // First and unique post in thread
|
|
|
|
|
For_FORUM_POSTS_SECTION_ID, // Last of several posts in thread
|
|
|
|
|
For_PutParamsForum,Forums);
|
2016-04-10 19:19:20 +02:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write author *****/
|
|
|
|
|
HTM_TD_Begin ("colspan=\"2\" class=\"AUTHOR_TXT LT\" style=\"width:150px;\"");
|
|
|
|
|
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
|
|
|
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
|
|
|
|
Msg_WriteMsgAuthor (&UsrDat,Enabled,NULL);
|
|
|
|
|
if (Enabled)
|
|
|
|
|
/* Write number of posts from this user */
|
|
|
|
|
For_WriteNumberOfPosts (Forums,UsrDat.UsrCod);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write post content *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"MSG_TXT LT\"");
|
|
|
|
|
if (Enabled)
|
|
|
|
|
{
|
|
|
|
|
Str_Copy (Content,OriginalContent,sizeof (Content) - 1);
|
2021-11-24 01:20:08 +01:00
|
|
|
|
Msg_WriteMsgContent (Content,true,false);
|
2021-04-24 15:10:07 +02:00
|
|
|
|
|
|
|
|
|
/***** Show image *****/
|
|
|
|
|
Med_ShowMedia (&Media,"FOR_IMG_CONT","FOR_IMG");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
HTM_Txt (Txt_This_post_has_been_banned_probably_for_not_satisfy_the_rules_of_the_forums);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-04-10 19:19:20 +02:00
|
|
|
|
/***** Free image *****/
|
2019-03-02 21:49:11 +01:00
|
|
|
|
Med_MediaDestructor (&Media);
|
2016-04-10 19:19:20 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Get data of a forum post ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2015-10-24 20:12:03 +02:00
|
|
|
|
static void For_GetPstData (long PstCod,long *UsrCod,time_t *CreatTimeUTC,
|
2021-02-15 22:49:44 +01:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1],
|
2017-01-17 03:10:43 +01:00
|
|
|
|
char Content[Cns_MAX_BYTES_LONG_TEXT + 1],
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Med_Media *Media)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
|
|
/***** Get data of a post from database *****/
|
2021-09-16 17:10:32 +02:00
|
|
|
|
if (For_DB_GetPstData (&mysql_res,PstCod) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPostExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of rows *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2019-03-18 15:42:22 +01:00
|
|
|
|
/***** Get author code (row[1]) *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
*UsrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
2019-03-18 15:42:22 +01:00
|
|
|
|
/***** Get creation time (row[1]) *****/
|
2015-10-24 20:12:03 +02:00
|
|
|
|
*CreatTimeUTC = Dat_GetUNIXTimeFromStr (row[1]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-02-15 22:49:44 +01:00
|
|
|
|
/***** Get subject (row[2]) and location (row[3]) *****/
|
|
|
|
|
Str_Copy (Subject,row[2],Cns_MAX_BYTES_SUBJECT );
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Content,row[3],Cns_MAX_BYTES_LONG_TEXT);
|
2016-04-10 19:19:20 +02:00
|
|
|
|
|
2019-03-18 15:42:22 +01:00
|
|
|
|
/***** Get media (row[4]) *****/
|
|
|
|
|
Media->MedCod = Str_ConvertStrCodToLongCod (row[4]);
|
|
|
|
|
Med_GetMediaDataByCod (Media);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2015-12-28 19:22:56 +01:00
|
|
|
|
/***************** Get summary and content for a forum post ******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
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,
|
2017-03-06 13:01:16 +01:00
|
|
|
|
long PstCod,bool GetContent)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2017-01-13 10:49:56 +01:00
|
|
|
|
size_t Length;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
SummaryStr[0] = '\0'; // Return nothing on error
|
|
|
|
|
|
2020-02-24 12:43:18 +01:00
|
|
|
|
/***** Get post subject and content from database *****/
|
2021-09-16 17:10:32 +02:00
|
|
|
|
if (For_DB_GetPstSubjectAndContent (&mysql_res,PstCod) == 1)
|
2020-02-24 12:43:18 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get subject and content of the post *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Copy subject *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (SummaryStr,row[0],Ntf_MAX_BYTES_SUMMARY);
|
2020-02-24 12:43:18 +01:00
|
|
|
|
|
|
|
|
|
/***** Copy content *****/
|
|
|
|
|
if (GetContent)
|
|
|
|
|
{
|
|
|
|
|
Length = strlen (row[1]);
|
|
|
|
|
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((*ContentStr = malloc (Length + 1)) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2020-02-24 12:43:18 +01:00
|
|
|
|
|
|
|
|
|
if (Length)
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (*ContentStr,row[1],Length);
|
2020-02-24 12:43:18 +01:00
|
|
|
|
else
|
|
|
|
|
**ContentStr = '\0';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Write number of posts in a forum of an user *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_WriteNumberOfPosts (const struct For_Forums *Forums,long UsrCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-03-06 10:13:39 +01:00
|
|
|
|
extern const char *Txt_FORUM_post;
|
|
|
|
|
extern const char *Txt_FORUM_posts;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumPsts;
|
|
|
|
|
|
|
|
|
|
/***** Get number of posts from database *****/
|
2021-09-16 23:28:29 +02:00
|
|
|
|
NumPsts = For_DB_GetNumPstsOfUsrInForum (&Forums->Forum,UsrCod);
|
|
|
|
|
|
|
|
|
|
/***** Write number of posts *****/
|
|
|
|
|
HTM_DIV_Begin ("class=\"AUTHOR_TXT LT\"");
|
|
|
|
|
HTM_TxtF ("[%u %s]",NumPsts,NumPsts == 1 ? Txt_FORUM_post :
|
|
|
|
|
Txt_FORUM_posts);
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/************** Put all hidden parameters related to forums ******************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-10-14 00:59:24 +02:00
|
|
|
|
static void For_PutParamsForum (void *Forums)
|
|
|
|
|
{
|
|
|
|
|
if (Forums)
|
|
|
|
|
For_PutAllHiddenParamsForum (((struct For_Forums *) Forums)->CurrentPageThrs, // Page of threads = current
|
|
|
|
|
((struct For_Forums *) Forums)->CurrentPagePsts, // Page of posts = current
|
|
|
|
|
((struct For_Forums *) Forums)->ForumSet,
|
|
|
|
|
((struct For_Forums *) Forums)->ThreadsOrder,
|
|
|
|
|
((struct For_Forums *) Forums)->Forum.Location,
|
2020-11-11 01:14:53 +01:00
|
|
|
|
((struct For_Forums *) Forums)->Thread.Current,
|
2020-10-14 00:59:24 +02:00
|
|
|
|
((struct For_Forums *) Forums)->PstCod);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_PutAllHiddenParamsForum (unsigned NumPageThreads,
|
|
|
|
|
unsigned NumPagePosts,
|
|
|
|
|
For_ForumSet_t ForumSet,
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Dat_StartEndTime_t Order,
|
2017-04-18 01:25:44 +02:00
|
|
|
|
long Location,
|
|
|
|
|
long ThrCod,
|
|
|
|
|
long PstCod)
|
|
|
|
|
{
|
2017-04-18 16:44:44 +02:00
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_THREADS_FORUM,NumPageThreads);
|
|
|
|
|
Pag_PutHiddenParamPagNum (Pag_POSTS_FORUM,NumPagePosts);
|
2017-04-18 01:25:44 +02:00
|
|
|
|
For_PutParamForumSet (ForumSet);
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Dat_PutHiddenParamOrder (Order);
|
2017-04-18 01:25:44 +02:00
|
|
|
|
For_PutParamForumLocation (Location);
|
|
|
|
|
For_PutHiddenParamThrCod (ThrCod);
|
|
|
|
|
For_PutHiddenParamPstCod (PstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-04-17 19:03:21 +02:00
|
|
|
|
/********* Put a hidden parameter with set of forums I want to see ***********/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 01:25:44 +02:00
|
|
|
|
static void For_PutParamForumSet (For_ForumSet_t ForumSet)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamUnsigned (NULL,"ForumSet",(unsigned) ForumSet);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-04-16 23:48:05 +02:00
|
|
|
|
/************** Put hidden parameter with code of *****************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************** forum institution, center, degree and course *****************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 01:25:44 +02:00
|
|
|
|
static void For_PutParamForumLocation (long Location)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-18 01:25:44 +02:00
|
|
|
|
if (Location > 0)
|
|
|
|
|
/***** Put a hidden parameter with the
|
2021-03-07 21:21:04 +01:00
|
|
|
|
institution, center, degree or course of the forum *****/
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamLong (NULL,"Location",Location);
|
2017-04-18 01:25:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Write a form parameter to specify a thread code ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void For_PutHiddenParamThrCod (long ThrCod)
|
|
|
|
|
{
|
|
|
|
|
if (ThrCod > 0)
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamLong (NULL,"ThrCod",ThrCod);
|
2017-04-18 01:25:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Write a form parameter to specify a post code *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void For_PutHiddenParamPstCod (long PstCod)
|
|
|
|
|
{
|
|
|
|
|
if (PstCod > 0)
|
2019-11-03 13:19:32 +01:00
|
|
|
|
Par_PutHiddenParamLong (NULL,"PstCod",PstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Show list of available forums ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_ShowForumList (struct For_Forums *Forums)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-09-26 17:20:01 +02:00
|
|
|
|
extern const char *Hlp_COMMUNICATION_Forums;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Forums;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
MYSQL_RES *mysql_resCtr;
|
|
|
|
|
MYSQL_RES *mysql_resDeg;
|
|
|
|
|
MYSQL_RES *mysql_resCrs;
|
|
|
|
|
MYSQL_ROW row;
|
2017-04-16 23:48:05 +02:00
|
|
|
|
long InsCod;
|
|
|
|
|
long CtrCod;
|
|
|
|
|
long DegCod;
|
|
|
|
|
long CrsCod;
|
|
|
|
|
unsigned NumMyIns;
|
|
|
|
|
unsigned NumCtr;
|
|
|
|
|
unsigned NumCtrs;
|
|
|
|
|
unsigned NumDeg;
|
|
|
|
|
unsigned NumDegs;
|
|
|
|
|
unsigned NumCrs;
|
|
|
|
|
unsigned NumCrss;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ICanSeeInsForum;
|
|
|
|
|
bool ICanSeeCtrForum;
|
|
|
|
|
bool ICanSeeDegForum;
|
|
|
|
|
|
|
|
|
|
/***** Get if there is a thread ready to be moved *****/
|
2017-04-18 13:17:40 +02:00
|
|
|
|
if (For_CheckIfICanMoveThreads ())
|
2021-05-10 21:10:06 +02:00
|
|
|
|
Forums->Thread.ToMove = For_DB_GetThrInMyClipboard ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Fill the list with the institutions I belong to *****/
|
2021-11-03 11:35:21 +01:00
|
|
|
|
Ins_GetMyInstits ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Forums,
|
2020-04-08 03:41:05 +02:00
|
|
|
|
For_PutIconsForums,NULL,
|
2020-09-26 17:20:01 +02:00
|
|
|
|
Hlp_COMMUNICATION_Forums,Box_NOT_CLOSABLE);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Put a form to select which forums *****/
|
|
|
|
|
For_PutFormWhichForums (Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin list *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_UL_Begin ("class=\"LIST_TREE\"");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Links to global forums *****/
|
|
|
|
|
For_WriteLinksToGblForums (Forums,IsLastItemInLevel);
|
|
|
|
|
switch (Forums->ForumSet)
|
2016-06-12 14:03:33 +02:00
|
|
|
|
{
|
2021-06-17 13:26:25 +02:00
|
|
|
|
case For_ONLY_CURRENT_FORUMS:
|
|
|
|
|
if (Gbl.Hierarchy.Ins.InsCod > 0)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
|
|
|
|
|
ICanSeeInsForum = true;
|
|
|
|
|
else
|
2021-11-03 11:35:21 +01:00
|
|
|
|
ICanSeeInsForum = Ins_CheckIfIBelongToIns (Gbl.Hierarchy.Ins.InsCod);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
ICanSeeInsForum = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Links to forums about the platform *****/
|
|
|
|
|
For_WriteLinksToPlatformForums (Forums,!ICanSeeInsForum,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
if (ICanSeeInsForum)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
|
|
|
|
|
ICanSeeCtrForum = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2021-11-03 11:35:21 +01:00
|
|
|
|
ICanSeeCtrForum = Ctr_CheckIfIBelongToCtr (Gbl.Hierarchy.Ctr.CtrCod);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
|
|
|
|
|
/***** Links to forums of current institution *****/
|
|
|
|
|
if (For_WriteLinksToInsForums (Forums,Gbl.Hierarchy.Ins.InsCod,
|
|
|
|
|
true,
|
|
|
|
|
IsLastItemInLevel) > 0)
|
|
|
|
|
if (ICanSeeCtrForum)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged >= Rol_DEG_ADM)
|
|
|
|
|
ICanSeeDegForum = true;
|
|
|
|
|
else
|
2021-11-03 11:35:21 +01:00
|
|
|
|
ICanSeeDegForum = Deg_CheckIfIBelongToDeg (Gbl.Hierarchy.Deg.DegCod);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
|
|
|
|
|
/***** Links to forums of current center *****/
|
|
|
|
|
if (For_WriteLinksToCtrForums (Forums,
|
|
|
|
|
Gbl.Hierarchy.Ctr.CtrCod,
|
|
|
|
|
true,
|
|
|
|
|
IsLastItemInLevel) > 0)
|
|
|
|
|
if (ICanSeeDegForum)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Links to forums of current degree *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
if (For_WriteLinksToDegForums (Forums,
|
|
|
|
|
Gbl.Hierarchy.Deg.DegCod,
|
|
|
|
|
true,
|
|
|
|
|
IsLastItemInLevel) > 0)
|
|
|
|
|
if (Gbl.Usrs.Me.IBelongToCurrentCrs ||
|
|
|
|
|
Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
|
|
|
|
|
/***** Links to forums of current degree *****/
|
|
|
|
|
For_WriteLinksToCrsForums (Forums,
|
|
|
|
|
Gbl.Hierarchy.Crs.CrsCod,
|
|
|
|
|
true,
|
|
|
|
|
IsLastItemInLevel);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case For_ALL_MY_FORUMS:
|
|
|
|
|
/***** Links to forums about the platform *****/
|
|
|
|
|
For_WriteLinksToPlatformForums (Forums,(Gbl.Usrs.Me.MyInss.Num == 0),IsLastItemInLevel);
|
|
|
|
|
|
|
|
|
|
/***** Links to forums of users from my institutions, the degrees in each institution and the courses in each degree *****/
|
|
|
|
|
for (NumMyIns = 0;
|
|
|
|
|
NumMyIns < Gbl.Usrs.Me.MyInss.Num;
|
|
|
|
|
NumMyIns++)
|
2021-04-16 13:51:12 +02:00
|
|
|
|
{
|
2021-06-17 13:26:25 +02:00
|
|
|
|
InsCod = Gbl.Usrs.Me.MyInss.Inss[NumMyIns].InsCod;
|
|
|
|
|
|
|
|
|
|
/* Links to forums of this institution */
|
|
|
|
|
For_WriteLinksToInsForums (Forums,
|
|
|
|
|
InsCod,
|
|
|
|
|
(NumMyIns == Gbl.Usrs.Me.MyInss.Num - 1),
|
|
|
|
|
IsLastItemInLevel);
|
|
|
|
|
|
|
|
|
|
/* Get my centers in this institution from database */
|
2021-11-03 11:35:21 +01:00
|
|
|
|
NumCtrs = Ctr_DB_GetCtrsFromUsr (&mysql_resCtr,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
InsCod);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
for (NumCtr = 0;
|
|
|
|
|
NumCtr < NumCtrs;
|
|
|
|
|
NumCtr++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next center */
|
|
|
|
|
row = mysql_fetch_row (mysql_resCtr);
|
|
|
|
|
CtrCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
|
|
|
|
/* Links to forums of this center */
|
|
|
|
|
if (For_WriteLinksToCtrForums (Forums,
|
|
|
|
|
CtrCod,
|
|
|
|
|
(NumCtr == NumCtrs - 1),
|
|
|
|
|
IsLastItemInLevel) > 0)
|
2021-04-16 13:51:12 +02:00
|
|
|
|
{
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/* Get my degrees in this institution from database */
|
2021-11-03 11:35:21 +01:00
|
|
|
|
NumDegs = Deg_DB_GetDegsFromUsr (&mysql_resDeg,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
CtrCod);
|
|
|
|
|
for (NumDeg = 0;
|
|
|
|
|
NumDeg < NumDegs;
|
|
|
|
|
NumDeg++)
|
|
|
|
|
{
|
|
|
|
|
/* Get next degree */
|
|
|
|
|
row = mysql_fetch_row (mysql_resDeg);
|
|
|
|
|
DegCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
|
|
|
|
/* Links to forums of this degree */
|
|
|
|
|
if (For_WriteLinksToDegForums (Forums,
|
|
|
|
|
DegCod,
|
|
|
|
|
(NumDeg == NumDegs - 1),
|
|
|
|
|
IsLastItemInLevel) > 0)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-11-03 11:35:21 +01:00
|
|
|
|
/* Get my courses in this degree from database */
|
|
|
|
|
NumCrss = Crs_DB_GetCrssFromUsr (&mysql_resCrs,
|
|
|
|
|
Gbl.Usrs.Me.UsrDat.UsrCod,
|
|
|
|
|
DegCod);
|
|
|
|
|
for (NumCrs = 0;
|
|
|
|
|
NumCrs < NumCrss;
|
|
|
|
|
NumCrs++)
|
2021-06-17 13:26:25 +02:00
|
|
|
|
{
|
2021-11-03 11:35:21 +01:00
|
|
|
|
/* Get next course */
|
|
|
|
|
row = mysql_fetch_row (mysql_resCrs);
|
|
|
|
|
CrsCod = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
|
|
|
|
|
/* Links to forums of this course */
|
|
|
|
|
For_WriteLinksToCrsForums (Forums,
|
|
|
|
|
CrsCod,
|
|
|
|
|
(NumCrs == NumCrss - 1),
|
|
|
|
|
IsLastItemInLevel);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
}
|
2021-11-03 11:35:21 +01:00
|
|
|
|
|
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_resCrs);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2021-11-03 11:35:21 +01:00
|
|
|
|
}
|
2021-04-16 13:51:12 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/* Free structure that stores the query result */
|
|
|
|
|
DB_FreeMySQLResult (&mysql_resDeg);
|
2021-04-16 13:51:12 +02:00
|
|
|
|
}
|
2021-06-17 13:26:25 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-04-16 13:51:12 +02:00
|
|
|
|
/* Free structure that stores the query result */
|
2021-06-17 13:26:25 +02:00
|
|
|
|
DB_FreeMySQLResult (&mysql_resCtr);
|
2021-04-16 13:51:12 +02:00
|
|
|
|
}
|
2021-06-17 13:26:25 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** End list *****/
|
|
|
|
|
HTM_UL_End ();
|
2017-04-13 23:53:57 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-17 12:19:58 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Put contextual icons in forums ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 03:41:05 +02:00
|
|
|
|
static void For_PutIconsForums (__attribute__((unused)) void *Args)
|
2017-04-17 12:19:58 +02:00
|
|
|
|
{
|
2020-04-08 03:41:05 +02:00
|
|
|
|
/***** Put icon to show a figure *****/
|
|
|
|
|
Fig_PutIconToShowFigure (Fig_FORUMS);
|
2017-04-17 12:19:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2017-02-24 00:42:20 +01:00
|
|
|
|
/*************** Put form to select which forums I want to see ***************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_PutFormWhichForums (const struct For_Forums *Forums)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-17 19:03:21 +02:00
|
|
|
|
extern const char *Txt_FORUM_WHICH_FORUM[For_NUM_FORUM_SETS];
|
2017-04-17 11:57:55 +02:00
|
|
|
|
For_ForumSet_t ForumSet;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-02-24 00:42:20 +01:00
|
|
|
|
/***** Form to select which forums I want to see:
|
|
|
|
|
- all my forums
|
|
|
|
|
- only the forums of current institution/degree/course *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActSeeFor);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Dat_PutHiddenParamOrder (Forums->ThreadsOrder);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_DIV_Begin ("class=\"SEL_BELOW_TITLE\"");
|
|
|
|
|
HTM_UL_Begin (NULL);
|
2014-12-27 21:09:34 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
for (ForumSet = (For_ForumSet_t) 0;
|
|
|
|
|
ForumSet <= (For_ForumSet_t) (For_NUM_FORUM_SETS - 1);
|
|
|
|
|
ForumSet++)
|
|
|
|
|
{
|
|
|
|
|
HTM_LI_Begin (NULL);
|
|
|
|
|
HTM_LABEL_Begin (NULL);
|
|
|
|
|
HTM_INPUT_RADIO ("ForumSet",true,
|
|
|
|
|
"value=\"%u\"%s",
|
|
|
|
|
(unsigned) ForumSet,
|
|
|
|
|
(ForumSet == Forums->ForumSet) ? " checked=\"checked\"" :
|
|
|
|
|
"");
|
|
|
|
|
HTM_Txt (Txt_FORUM_WHICH_FORUM[ForumSet]);
|
|
|
|
|
HTM_LABEL_End ();
|
|
|
|
|
HTM_LI_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTM_UL_End ();
|
|
|
|
|
HTM_DIV_End ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Write links to global forums **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_WriteLinksToGblForums (const struct For_Forums *Forums,
|
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-11 13:53:17 +02:00
|
|
|
|
bool Highlight;
|
2017-05-23 20:42:38 +02:00
|
|
|
|
bool ICanSeeTeacherForum;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forum Forum;
|
2017-04-11 13:53:17 +02:00
|
|
|
|
|
2017-05-23 20:42:38 +02:00
|
|
|
|
/***** Can I see teachers's forums? *****/
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeTeacherForum = Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-06-08 15:32:33 +02:00
|
|
|
|
(Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) |
|
2019-03-07 22:15:47 +01:00
|
|
|
|
(1 << Rol_TCH)));
|
2017-05-23 20:42:38 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Link to forum global *****/
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Type = For_FORUM_GLOBAL_USRS;
|
|
|
|
|
Forum.Location = -1L;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM_GLOBAL_USRS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[1] = false;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,0,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to forum of teachers global *****/
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
2017-05-23 20:42:38 +02:00
|
|
|
|
if (ICanSeeTeacherForum)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Type = For_FORUM_GLOBAL_TCHS;
|
|
|
|
|
Forum.Location = -1L;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM_GLOBAL_TCHS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[1] = false;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,0,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/****************** Write links to forums about the platform *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_WriteLinksToPlatformForums (const struct For_Forums *Forums,
|
|
|
|
|
bool IsLastForum,
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-11 13:53:17 +02:00
|
|
|
|
bool Highlight;
|
2016-12-13 13:32:19 +01:00
|
|
|
|
bool ICanSeeTeacherForum;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forum Forum;
|
2016-12-13 13:32:19 +01:00
|
|
|
|
|
|
|
|
|
/***** Can I see teachers's forums? *****/
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeTeacherForum = Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-06-08 15:32:33 +02:00
|
|
|
|
(Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) |
|
2019-03-07 22:15:47 +01:00
|
|
|
|
(1 << Rol_TCH)));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to forum of users about the platform *****/
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Type = For_FORUM__SWAD__USRS;
|
|
|
|
|
Forum.Location = -1L;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM__SWAD__USRS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[1] = (IsLastForum && !ICanSeeTeacherForum);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,0,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to forum of teachers about the platform *****/
|
|
|
|
|
if (ICanSeeTeacherForum)
|
|
|
|
|
{
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Type = For_FORUM__SWAD__TCHS;
|
|
|
|
|
Forum.Location = -1L;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM__SWAD__TCHS);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[1] = IsLastForum;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,0,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Write links to institution forums ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns institution code
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static long For_WriteLinksToInsForums (const struct For_Forums *Forums,
|
|
|
|
|
long InsCod,bool IsLastIns,
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-11 13:53:17 +02:00
|
|
|
|
bool Highlight;
|
2017-05-23 20:42:38 +02:00
|
|
|
|
Rol_Role_t MaxRoleInIns;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ICanSeeTeacherForum;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forum Forum;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (InsCod > 0)
|
|
|
|
|
{
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRoleInIns = Rol_GetMyMaxRoleInIns (InsCod);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRoleInIns == Rol_NET ||
|
|
|
|
|
MaxRoleInIns == Rol_TCH);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to the forum of users from this institution *****/
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Type = For_FORUM_INSTIT_USRS;
|
|
|
|
|
Forum.Location = InsCod;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM_INSTIT_USRS &&
|
|
|
|
|
Forums->Forum.Location == InsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[1] = (IsLastIns && !ICanSeeTeacherForum);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,1,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to forum of teachers from this institution *****/
|
|
|
|
|
if (ICanSeeTeacherForum)
|
|
|
|
|
{
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Type = For_FORUM_INSTIT_TCHS;
|
|
|
|
|
Forum.Location = InsCod;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM_INSTIT_TCHS &&
|
|
|
|
|
Forums->Forum.Location == InsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[1] = IsLastIns;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,1,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return InsCod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************************ Write links to center forums ***********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
// Returns center code
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static long For_WriteLinksToCtrForums (const struct For_Forums *Forums,
|
|
|
|
|
long CtrCod,bool IsLastCtr,
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-11 13:53:17 +02:00
|
|
|
|
bool Highlight;
|
2017-05-23 20:42:38 +02:00
|
|
|
|
Rol_Role_t MaxRoleInCtr;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ICanSeeTeacherForum;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forum Forum;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (CtrCod > 0)
|
|
|
|
|
{
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRoleInCtr = Rol_GetMyMaxRoleInCtr (CtrCod);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRoleInCtr == Rol_NET ||
|
|
|
|
|
MaxRoleInCtr == Rol_TCH);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Link to the forum of users from this center *****/
|
|
|
|
|
Forum.Type = For_FORUM_CENTER_USRS;
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Location = CtrCod;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM_CENTER_USRS &&
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Location == CtrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[2] = (IsLastCtr && !ICanSeeTeacherForum);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,2,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Link to forum of teachers from this center *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (ICanSeeTeacherForum)
|
|
|
|
|
{
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Forum.Type = For_FORUM_CENTER_TCHS;
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Location = CtrCod;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM_CENTER_TCHS &&
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Location == CtrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[2] = IsLastCtr;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,2,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return CtrCod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Write links to degree forums ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns degree code
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static long For_WriteLinksToDegForums (const struct For_Forums *Forums,
|
|
|
|
|
long DegCod,bool IsLastDeg,
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-11 13:53:17 +02:00
|
|
|
|
bool Highlight;
|
2017-05-23 20:42:38 +02:00
|
|
|
|
Rol_Role_t MaxRoleInDeg;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ICanSeeTeacherForum;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forum Forum;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (DegCod > 0)
|
|
|
|
|
{
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRoleInDeg = Rol_GetMyMaxRoleInDeg (DegCod);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRoleInDeg == Rol_NET ||
|
|
|
|
|
MaxRoleInDeg == Rol_TCH);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to the forum of users from this degree *****/
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Type = For_FORUM_DEGREE_USRS;
|
|
|
|
|
Forum.Location = DegCod;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM_DEGREE_USRS &&
|
|
|
|
|
Forums->Forum.Location == DegCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[3] = (IsLastDeg && !ICanSeeTeacherForum);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,3,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to forum of teachers from this degree *****/
|
|
|
|
|
if (ICanSeeTeacherForum)
|
|
|
|
|
{
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Type = For_FORUM_DEGREE_TCHS;
|
|
|
|
|
Forum.Location = DegCod;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM_DEGREE_TCHS &&
|
|
|
|
|
Forums->Forum.Location == DegCod);
|
2017-04-11 13:53:17 +02:00
|
|
|
|
IsLastItemInLevel[3] = IsLastDeg;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,3,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return DegCod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Write links to course forums ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
// Returns course code
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static long For_WriteLinksToCrsForums (const struct For_Forums *Forums,
|
|
|
|
|
long CrsCod,bool IsLastCrs,
|
2017-01-28 15:58:46 +01:00
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-11 13:53:17 +02:00
|
|
|
|
bool Highlight;
|
2017-05-23 20:42:38 +02:00
|
|
|
|
Rol_Role_t MyRoleInCrs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ICanSeeTeacherForum;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forum Forum;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (CrsCod > 0)
|
|
|
|
|
{
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MyRoleInCrs = Rol_GetMyRoleInCrs (CrsCod);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeTeacherForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MyRoleInCrs == Rol_NET ||
|
|
|
|
|
MyRoleInCrs == Rol_TCH);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to the forum of users from this course *****/
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Type = For_FORUM_COURSE_USRS;
|
|
|
|
|
Forum.Location = CrsCod;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM_COURSE_USRS &&
|
|
|
|
|
Forums->Forum.Location == CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[4] = (IsLastCrs && !ICanSeeTeacherForum);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,4,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link to forum of teachers from this course *****/
|
|
|
|
|
if (ICanSeeTeacherForum)
|
|
|
|
|
{
|
2017-04-19 12:34:38 +02:00
|
|
|
|
Forum.Type = For_FORUM_COURSE_TCHS;
|
|
|
|
|
Forum.Location = CrsCod;
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Highlight = (Forums->Forum.Type == For_FORUM_COURSE_TCHS &&
|
|
|
|
|
Forums->Forum.Location == CrsCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
IsLastItemInLevel[4] = IsLastCrs;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_WriteLinkToForum (Forums,&Forum,Highlight,4,IsLastItemInLevel);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return CrsCod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Write title and link to a forum **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_WriteLinkToForum (const struct For_Forums *Forums,
|
2021-02-15 23:58:48 +01:00
|
|
|
|
const struct For_Forum *Forum,
|
2019-11-18 17:59:02 +01:00
|
|
|
|
bool Highlight,
|
|
|
|
|
unsigned Level,
|
|
|
|
|
bool IsLastItemInLevel[1 + For_FORUM_MAX_LEVELS])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-12-15 14:02:49 +01:00
|
|
|
|
extern const char *The_ClassBgHighlight[The_NUM_THEMES];
|
2019-11-18 14:21:01 +01:00
|
|
|
|
extern const char *The_ClassFormLinkInBox[The_NUM_THEMES];
|
|
|
|
|
extern const char *The_ClassFormLinkInBoxBold[The_NUM_THEMES];
|
2017-04-19 12:34:38 +02:00
|
|
|
|
extern const char *Txt_Copy_not_allowed;
|
|
|
|
|
unsigned NumThrs;
|
|
|
|
|
unsigned NumThrsWithNewPosts;
|
2019-11-18 14:21:01 +01:00
|
|
|
|
const char *Class;
|
2017-01-13 10:49:56 +01:00
|
|
|
|
char ForumName[For_MAX_BYTES_FORUM_NAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-19 12:34:38 +02:00
|
|
|
|
/***** Get number of threads and number of posts *****/
|
2021-09-15 20:21:02 +02:00
|
|
|
|
NumThrs = For_DB_GetNumThrsInForum (Forum);
|
2017-04-19 12:34:38 +02:00
|
|
|
|
NumThrsWithNewPosts = For_GetNumThrsWithNewPstsInForum (Forum,NumThrs);
|
2019-11-18 14:21:01 +01:00
|
|
|
|
Class = (NumThrsWithNewPosts ? The_ClassFormLinkInBoxBold[Gbl.Prefs.Theme] :
|
|
|
|
|
The_ClassFormLinkInBox[Gbl.Prefs.Theme]);
|
2017-04-19 12:34:38 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin row *****/
|
2021-12-15 14:02:49 +01:00
|
|
|
|
if (Highlight)
|
|
|
|
|
HTM_LI_Begin ("class=\"%s\"",The_ClassBgHighlight[Gbl.Prefs.Theme]);
|
|
|
|
|
else
|
|
|
|
|
HTM_LI_Begin (NULL);
|
2017-04-19 12:34:38 +02:00
|
|
|
|
|
2021-12-15 14:02:49 +01:00
|
|
|
|
/***** Indent forum title *****/
|
|
|
|
|
Lay_IndentDependingOnLevel (Level,IsLastItemInLevel);
|
2017-04-19 12:34:38 +02:00
|
|
|
|
|
2021-12-15 14:02:49 +01:00
|
|
|
|
/***** Write paste button used to move a thread in clipboard to this forum *****/
|
|
|
|
|
if (Forums->Thread.ToMove >= 0) // If I have permission to paste threads and there is a thread ready to be pasted...
|
|
|
|
|
{
|
|
|
|
|
/* Check if thread to move is yet in current forum */
|
|
|
|
|
if (For_DB_CheckIfThrBelongsToForum (Forums->Thread.ToMove,Forum))
|
|
|
|
|
Ico_PutIcon ("paste.svg",Txt_Copy_not_allowed,"CONTEXT_OPT ICO_HIDDEN ICO16x16");
|
|
|
|
|
else
|
2021-06-17 13:26:25 +02:00
|
|
|
|
{
|
2021-12-15 14:02:49 +01:00
|
|
|
|
Frm_BeginFormAnchor (For_ActionsPasThrFor[Forum->Type],
|
|
|
|
|
For_FORUM_THREADS_SECTION_ID);
|
|
|
|
|
For_PutAllHiddenParamsForum (1, // Page of threads = first
|
|
|
|
|
1, // Page of posts = first
|
|
|
|
|
Forums->ForumSet,
|
|
|
|
|
Forums->ThreadsOrder,
|
|
|
|
|
Forum->Location,
|
|
|
|
|
Forums->Thread.ToMove,
|
|
|
|
|
-1L);
|
|
|
|
|
Ico_PutIconPaste ();
|
|
|
|
|
Frm_EndForm ();
|
2021-06-17 13:26:25 +02:00
|
|
|
|
}
|
2021-12-15 14:02:49 +01:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-12-15 14:02:49 +01:00
|
|
|
|
/***** Write link to forum *****/
|
|
|
|
|
Frm_BeginFormAnchor (For_ActionsSeeFor[Forum->Type],
|
|
|
|
|
For_FORUM_THREADS_SECTION_ID);
|
|
|
|
|
For_PutAllHiddenParamsForum (1, // Page of threads = first
|
|
|
|
|
1, // Page of posts = first
|
|
|
|
|
Forums->ForumSet,
|
|
|
|
|
Forums->ThreadsOrder,
|
|
|
|
|
Forum->Location,
|
|
|
|
|
-1L,
|
|
|
|
|
-1L);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
|
2021-12-15 14:02:49 +01:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Act_GetActionText (For_ActionsSeeFor[Forum->Type]),
|
|
|
|
|
Class,NULL);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
|
2021-12-15 14:02:49 +01:00
|
|
|
|
For_SetForumName (Forum,ForumName,Gbl.Prefs.Language,true);
|
|
|
|
|
switch (Forum->Type)
|
|
|
|
|
{
|
|
|
|
|
case For_FORUM_GLOBAL_USRS:
|
|
|
|
|
case For_FORUM_GLOBAL_TCHS:
|
|
|
|
|
Ico_PutIcon ("comments.svg",ForumName,"ICO16x16");
|
|
|
|
|
break;
|
|
|
|
|
case For_FORUM__SWAD__USRS:
|
|
|
|
|
case For_FORUM__SWAD__TCHS:
|
|
|
|
|
Ico_PutIcon ("swad64x64.png",ForumName,"ICO16x16");
|
|
|
|
|
break;
|
|
|
|
|
case For_FORUM_INSTIT_USRS:
|
|
|
|
|
case For_FORUM_INSTIT_TCHS:
|
|
|
|
|
Lgo_DrawLogo (HieLvl_INS,Forum->Location,ForumName,16,NULL,true);
|
|
|
|
|
break;
|
|
|
|
|
case For_FORUM_CENTER_USRS:
|
|
|
|
|
case For_FORUM_CENTER_TCHS:
|
|
|
|
|
Lgo_DrawLogo (HieLvl_CTR,Forum->Location,ForumName,16,NULL,true);
|
|
|
|
|
break;
|
|
|
|
|
case For_FORUM_DEGREE_USRS:
|
|
|
|
|
case For_FORUM_DEGREE_TCHS:
|
|
|
|
|
Lgo_DrawLogo (HieLvl_DEG,Forum->Location,ForumName,16,NULL,true);
|
|
|
|
|
break;
|
|
|
|
|
case For_FORUM_COURSE_USRS:
|
|
|
|
|
case For_FORUM_COURSE_TCHS:
|
|
|
|
|
Ico_PutIcon ("chalkboard-teacher.svg",ForumName,"ICO16x16");
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
HTM_TxtF (" %s",ForumName);
|
|
|
|
|
|
|
|
|
|
/***** Write total number of threads and posts in this forum *****/
|
|
|
|
|
if (NumThrs)
|
|
|
|
|
For_WriteNumberOfThrs (NumThrs);
|
2017-05-29 21:34:43 +02:00
|
|
|
|
|
2021-12-15 14:02:49 +01:00
|
|
|
|
/***** End row *****/
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
|
|
|
|
|
Frm_EndForm ();
|
2021-06-17 13:26:25 +02:00
|
|
|
|
|
2021-12-15 14:02:49 +01:00
|
|
|
|
/***** Put link to register students *****/
|
|
|
|
|
if (Forum->Type == For_FORUM_COURSE_USRS)
|
|
|
|
|
Enr_PutButtonInlineToRegisterStds (Forum->Location);
|
2017-05-29 21:34:43 +02:00
|
|
|
|
|
2019-10-26 22:49:13 +02:00
|
|
|
|
HTM_LI_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Set the name of a forum **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
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)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_General;
|
2018-12-08 16:43:13 +01:00
|
|
|
|
extern const char *Txt_General_NO_HTML[1 + Lan_NUM_LANGUAGES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_only_teachers;
|
2018-12-08 16:43:13 +01:00
|
|
|
|
extern const char *Txt_only_teachers_NO_HTML[1 + Lan_NUM_LANGUAGES];
|
2017-04-18 19:55:56 +02:00
|
|
|
|
extern const char *Txt_Unknown_FORUM;
|
2021-02-11 23:27:48 +01:00
|
|
|
|
struct Hie_Hierarchy Hie;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 01:25:44 +02:00
|
|
|
|
switch (Forum->Type)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_GLOBAL_USRS:
|
|
|
|
|
Str_Copy (ForumName,UseHTMLEntities ? Txt_General :
|
|
|
|
|
Txt_General_NO_HTML[Language],
|
2017-01-17 03:10:43 +01:00
|
|
|
|
For_MAX_BYTES_FORUM_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_GLOBAL_TCHS:
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
2018-10-18 02:02:32 +02:00
|
|
|
|
UseHTMLEntities ? Txt_General :
|
|
|
|
|
Txt_General_NO_HTML[Language],
|
|
|
|
|
UseHTMLEntities ? Txt_only_teachers :
|
|
|
|
|
Txt_only_teachers_NO_HTML[Language]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM__SWAD__USRS:
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (ForumName,Cfg_PLATFORM_SHORT_NAME,For_MAX_BYTES_FORUM_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM__SWAD__TCHS:
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
|
|
|
|
Cfg_PLATFORM_SHORT_NAME,
|
2018-10-18 02:02:32 +02:00
|
|
|
|
UseHTMLEntities ? Txt_only_teachers :
|
|
|
|
|
Txt_only_teachers_NO_HTML[Language]);
|
2017-04-18 19:55:56 +02:00
|
|
|
|
break;
|
|
|
|
|
case For_FORUM_INSTIT_USRS:
|
2021-02-11 23:27:48 +01:00
|
|
|
|
Hie.Ins.InsCod = Forum->Location;
|
2021-10-01 18:54:12 +02:00
|
|
|
|
if (!Ins_GetDataOfInstitByCod (&Hie.Ins))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongInstitExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (ForumName,Hie.Ins.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
2017-04-18 19:55:56 +02:00
|
|
|
|
break;
|
|
|
|
|
case For_FORUM_INSTIT_TCHS:
|
2021-02-11 23:27:48 +01:00
|
|
|
|
Hie.Ins.InsCod = Forum->Location;
|
2021-10-01 18:54:12 +02:00
|
|
|
|
if (!Ins_GetDataOfInstitByCod (&Hie.Ins))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongInstitExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
|
|
|
|
Hie.Ins.ShrtName,
|
2018-10-18 02:02:32 +02:00
|
|
|
|
UseHTMLEntities ? Txt_only_teachers :
|
|
|
|
|
Txt_only_teachers_NO_HTML[Language]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
case For_FORUM_CENTER_USRS:
|
2021-02-11 23:27:48 +01:00
|
|
|
|
Hie.Ctr.CtrCod = Forum->Location;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
if (!Ctr_GetDataOfCenterByCod (&Hie.Ctr))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongCenterExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (ForumName,Hie.Ctr.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
case For_FORUM_CENTER_TCHS:
|
2021-02-11 23:27:48 +01:00
|
|
|
|
Hie.Ctr.CtrCod = Forum->Location;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
if (!Ctr_GetDataOfCenterByCod (&Hie.Ctr))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongCenterExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
|
|
|
|
Hie.Ctr.ShrtName,
|
2018-10-18 02:02:32 +02:00
|
|
|
|
UseHTMLEntities ? Txt_only_teachers :
|
|
|
|
|
Txt_only_teachers_NO_HTML[Language]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_DEGREE_USRS:
|
2021-02-11 23:27:48 +01:00
|
|
|
|
Hie.Deg.DegCod = Forum->Location;
|
|
|
|
|
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongDegreeExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (ForumName,Hie.Deg.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_DEGREE_TCHS:
|
2021-02-11 23:27:48 +01:00
|
|
|
|
Hie.Deg.DegCod = Forum->Location;
|
|
|
|
|
if (!Deg_GetDataOfDegreeByCod (&Hie.Deg))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongDegreeExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
|
|
|
|
Hie.Deg.ShrtName,
|
2018-10-18 02:02:32 +02:00
|
|
|
|
UseHTMLEntities ? Txt_only_teachers :
|
|
|
|
|
Txt_only_teachers_NO_HTML[Language]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_COURSE_USRS:
|
2021-02-11 23:27:48 +01:00
|
|
|
|
Hie.Crs.CrsCod = Forum->Location;
|
|
|
|
|
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongCourseExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (ForumName,Hie.Crs.ShrtName,For_MAX_BYTES_FORUM_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_COURSE_TCHS:
|
2021-02-11 23:27:48 +01:00
|
|
|
|
Hie.Crs.CrsCod = Forum->Location;
|
|
|
|
|
if (!Crs_GetDataOfCourseByCod (&Hie.Crs))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongCourseExit ();
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (ForumName,For_MAX_BYTES_FORUM_NAME + 1,"%s%s",
|
|
|
|
|
Hie.Crs.ShrtName,
|
2018-10-18 02:02:32 +02:00
|
|
|
|
UseHTMLEntities ? Txt_only_teachers :
|
|
|
|
|
Txt_only_teachers_NO_HTML[Language]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
default:
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (ForumName,Txt_Unknown_FORUM,For_MAX_BYTES_FORUM_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***** Get number of threads with new posts since my last read of a forum ****/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-02-15 23:58:48 +01:00
|
|
|
|
static unsigned For_GetNumThrsWithNewPstsInForum (const struct For_Forum *Forum,
|
2017-04-16 23:48:05 +02:00
|
|
|
|
unsigned NumThreads)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2021-10-30 13:28:48 +02:00
|
|
|
|
unsigned NumThrsWithNewPosts = NumThreads; // By default, all threads are new to me
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get last time I read this forum from database *****/
|
2021-09-16 23:28:29 +02:00
|
|
|
|
if (For_DB_GetLastTimeIReadForum (&mysql_res,Forum))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get number of threads with a last message modify time > newest read time (row[0]) *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2021-09-16 23:28:29 +02:00
|
|
|
|
NumThrsWithNewPosts = For_DB_GetNumThrsInForumNewerThan (Forum,row[0]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumThrsWithNewPosts;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/** Get number of unread posts in a thread since my last read of that thread */
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static unsigned For_GetNumOfUnreadPostsInThr (long ThrCod,unsigned NumPostsInThr)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2021-10-30 13:28:48 +02:00
|
|
|
|
unsigned NumUnreadPosts = NumPostsInThr; // By default, all posts are unread by me
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get last time I read this thread from database *****/
|
2021-09-16 23:28:29 +02:00
|
|
|
|
if (For_DB_GetLastTimeIReadThread (&mysql_res,ThrCod))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get the number of posts in thread with a modify time > newest read time for me (row[0]) *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2021-09-15 20:21:02 +02:00
|
|
|
|
NumUnreadPosts = For_DB_GetNumPstsInThrNewerThan (ThrCod,row[0]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
return NumUnreadPosts;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-17 12:19:58 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Get and write total number of threads and posts **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-11-18 17:59:02 +01:00
|
|
|
|
static void For_WriteNumberOfThrs (unsigned NumThrs)
|
2017-04-17 12:19:58 +02:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_thread;
|
|
|
|
|
extern const char *Txt_threads;
|
|
|
|
|
|
|
|
|
|
/***** Write number of threads and number of posts *****/
|
2019-11-18 17:59:02 +01:00
|
|
|
|
HTM_TxtF (" [%u %s]",NumThrs,NumThrs == 1 ? Txt_thread :
|
|
|
|
|
Txt_threads);
|
2017-04-17 12:19:58 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Show available threads of a forum ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_ShowForumTheads (void)
|
2017-04-14 01:02:33 +02:00
|
|
|
|
{
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forums Forums;
|
|
|
|
|
|
|
|
|
|
/***** Reset forum *****/
|
|
|
|
|
For_ResetForums (&Forums);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters related to forums *****/
|
|
|
|
|
For_GetParamsForums (&Forums);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Show forum threads with no one highlighted *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,NULL);
|
2017-04-14 01:02:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Show available threads of a forum highlighting a thread **********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_ShowForumThreadsHighlightingOneThread (struct For_Forums *Forums,
|
2017-05-11 23:45:46 +02:00
|
|
|
|
Ale_AlertType_t AlertType,const char *Message)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-09-26 17:20:01 +02:00
|
|
|
|
extern const char *Hlp_COMMUNICATION_Forums_threads;
|
2017-04-11 14:27:45 +02:00
|
|
|
|
extern const char *Txt_Forum;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_MSG_Subject;
|
2020-04-05 22:53:58 +02:00
|
|
|
|
extern const char *Txt_FORUM_THREAD_HELP_ORDER[Dat_NUM_START_END_TIME];
|
|
|
|
|
extern const char *Txt_FORUM_THREAD_ORDER[Dat_NUM_START_END_TIME];
|
2020-05-07 14:15:39 +02:00
|
|
|
|
extern const char *Txt_Number_BR_msgs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Unread_BR_msgs;
|
|
|
|
|
extern const char *Txt_WriBRters;
|
|
|
|
|
extern const char *Txt_ReaBRders;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
2017-04-11 14:27:45 +02:00
|
|
|
|
char FrameTitle[128 + For_MAX_BYTES_FORUM_NAME];
|
|
|
|
|
char ForumName[For_MAX_BYTES_FORUM_NAME + 1];
|
2017-04-11 13:53:17 +02:00
|
|
|
|
unsigned NumThr;
|
|
|
|
|
unsigned NumThrs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumThrInScreen; // From 0 to Pag_ITEMS_PER_PAGE-1
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Dat_StartEndTime_t Order;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long ThrCods[Pag_ITEMS_PER_PAGE];
|
|
|
|
|
struct Pagination PaginationThrs;
|
2017-04-11 13:53:17 +02:00
|
|
|
|
|
2017-04-11 14:27:45 +02:00
|
|
|
|
/***** Set forum name *****/
|
2020-04-10 19:14:08 +02:00
|
|
|
|
For_SetForumName (&Forums->Forum,
|
2017-04-11 14:27:45 +02:00
|
|
|
|
ForumName,Gbl.Prefs.Language,true);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get threads of a forum from database *****/
|
2021-09-16 17:10:32 +02:00
|
|
|
|
NumThrs = For_DB_GetForumThreads (&mysql_res,Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Compute variables related to pagination of threads *****/
|
|
|
|
|
PaginationThrs.NumItems = NumThrs;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
PaginationThrs.CurrentPage = (int) Forums->CurrentPageThrs;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Pag_CalculatePagination (&PaginationThrs);
|
2017-05-25 13:43:54 +02:00
|
|
|
|
PaginationThrs.Anchor = For_FORUM_THREADS_SECTION_ID;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
Forums->CurrentPageThrs = (unsigned) PaginationThrs.CurrentPage;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Fill the list of threads for current page *****/
|
2016-10-26 01:23:02 +02:00
|
|
|
|
mysql_data_seek (mysql_res,(my_ulonglong) (PaginationThrs.FirstItemVisible - 1));
|
2021-11-24 22:57:10 +01:00
|
|
|
|
for (NumThr = PaginationThrs.FirstItemVisible, NumThrInScreen = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumThr <= PaginationThrs.LastItemVisible;
|
|
|
|
|
NumThr++, NumThrInScreen++)
|
|
|
|
|
/* Get thread code(row[0]) */
|
2021-04-04 19:57:17 +02:00
|
|
|
|
if ((ThrCods[NumThrInScreen] = DB_GetNextCode (mysql_res)) < 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_ShowErrorAndExit ("Error when getting thread of a forum.");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
2017-04-18 09:55:25 +02:00
|
|
|
|
/***** Show alert after action *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_Begin (For_FORUM_THREADS_SECTION_ID);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
if (Message)
|
|
|
|
|
if (Message[0])
|
|
|
|
|
Ale_ShowAlert (AlertType,Message);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Begin box for threads of this forum *****/
|
|
|
|
|
snprintf (FrameTitle,sizeof (FrameTitle),"%s: %s",Txt_Forum,ForumName);
|
|
|
|
|
Box_BoxBegin (NULL,FrameTitle,
|
|
|
|
|
For_PutIconNewThread,Forums,
|
|
|
|
|
Hlp_COMMUNICATION_Forums_threads,Box_NOT_CLOSABLE);
|
2019-10-12 00:07:52 +02:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** List the threads *****/
|
|
|
|
|
if (NumThrs)
|
|
|
|
|
{
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Write links to all pages in the listing of threads *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_THREADS_FORUM,&PaginationThrs,
|
|
|
|
|
Forums,-1L);
|
|
|
|
|
|
|
|
|
|
/***** Heading row *****/
|
|
|
|
|
HTM_TABLE_BeginWideMarginPadding (2);
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
HTM_TH (1,1,"BT",NULL);
|
|
|
|
|
HTM_TH (1,1,"CONTEXT_COL",NULL); // Column for contextual icons
|
|
|
|
|
HTM_TH (1,1,"LM",Txt_MSG_Subject);
|
|
|
|
|
|
2021-09-18 18:22:26 +02:00
|
|
|
|
for (Order = Dat_STR_TIME;
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Order <= Dat_END_TIME;
|
|
|
|
|
Order++)
|
|
|
|
|
{
|
|
|
|
|
HTM_TH_Begin (1,2,"CM");
|
|
|
|
|
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Frm_BeginFormAnchor (For_ActionsSeeFor[Forums->Forum.Type],
|
2021-06-17 13:26:25 +02:00
|
|
|
|
For_FORUM_THREADS_SECTION_ID);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
For_PutAllHiddenParamsForum (Forums->CurrentPageThrs, // Page of threads = current
|
|
|
|
|
1, // Page of posts = first
|
|
|
|
|
Forums->ForumSet,
|
|
|
|
|
Order,
|
|
|
|
|
Forums->Forum.Location,
|
|
|
|
|
-1L,
|
|
|
|
|
-1L);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_BUTTON_SUBMIT_Begin (Txt_FORUM_THREAD_HELP_ORDER[Order],"BT_LINK TIT_TBL",NULL);
|
|
|
|
|
if (Order == Forums->ThreadsOrder)
|
|
|
|
|
HTM_U_Begin ();
|
|
|
|
|
HTM_Txt (Txt_FORUM_THREAD_ORDER[Order]);
|
|
|
|
|
if (Order == Forums->ThreadsOrder)
|
|
|
|
|
HTM_U_End ();
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
|
|
|
|
HTM_TH_End ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Number_BR_msgs);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_Unread_BR_msgs);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_WriBRters);
|
|
|
|
|
HTM_TH (1,1,"RM",Txt_ReaBRders);
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
|
|
|
|
|
/***** List the threads *****/
|
|
|
|
|
For_ListForumThrs (Forums,ThrCods,Forums->Thread.Current,&PaginationThrs);
|
|
|
|
|
|
|
|
|
|
/***** End table *****/
|
|
|
|
|
HTM_TABLE_End ();
|
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Write links to all pages in the listing of threads *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Pag_WriteLinksToPagesCentered (Pag_THREADS_FORUM,&PaginationThrs,
|
|
|
|
|
Forums,-1L);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** Put a form to write the first post of a new thread *****/
|
|
|
|
|
HTM_SECTION_Begin (For_NEW_THREAD_SECTION_ID);
|
2021-09-16 17:10:32 +02:00
|
|
|
|
For_WriteFormForumPst (Forums,false,NULL);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
HTM_SECTION_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-06-17 13:26:25 +02:00
|
|
|
|
/***** End box with threads of this forum ****/
|
|
|
|
|
Box_BoxEnd ();
|
2017-04-11 14:27:45 +02:00
|
|
|
|
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-04-17 12:19:58 +02:00
|
|
|
|
/********************** Put icon to write a new thread ***********************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_PutIconNewThread (void *Forums)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-17 12:19:58 +02:00
|
|
|
|
extern const char *Txt_New_thread;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
if (Forums)
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Ico_PutContextualIconToAdd (For_ActionsSeeFor[((struct For_Forums *) Forums)->Forum.Type],
|
2020-03-26 02:54:30 +01:00
|
|
|
|
For_NEW_THREAD_SECTION_ID,
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_PutAllHiddenParamsNewThread,Forums,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Txt_New_thread);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_PutAllHiddenParamsNewThread (void *Forums)
|
2017-04-19 14:43:08 +02:00
|
|
|
|
{
|
2020-04-07 03:01:41 +02:00
|
|
|
|
if (Forums)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
For_PutAllHiddenParamsForum (1, // Page of threads = first
|
|
|
|
|
1, // Page of posts = first
|
2020-04-07 03:01:41 +02:00
|
|
|
|
((struct For_Forums *)Forums)->ForumSet,
|
|
|
|
|
((struct For_Forums *)Forums)->ThreadsOrder,
|
2020-04-10 19:14:08 +02:00
|
|
|
|
((struct For_Forums *)Forums)->Forum.Location,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
-1L,
|
|
|
|
|
-1L);
|
2017-04-19 14:43:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ List the threads of a forum ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 19:14:08 +02:00
|
|
|
|
static void For_ListForumThrs (struct For_Forums *Forums,
|
2020-04-07 03:01:41 +02:00
|
|
|
|
long ThrCods[Pag_ITEMS_PER_PAGE],
|
2017-04-14 01:02:33 +02:00
|
|
|
|
long ThrCodHighlighted,
|
2017-04-13 23:53:57 +02:00
|
|
|
|
struct Pagination *PaginationThrs)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-12-15 14:02:49 +01:00
|
|
|
|
extern const char *The_ClassBgHighlight[The_NUM_THEMES];
|
2019-02-22 21:47:50 +01:00
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
|
|
|
|
extern const char *The_ClassFormInBoxBold[The_NUM_THEMES];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Thread_with_posts_from_you;
|
|
|
|
|
extern const char *Txt_There_are_new_posts;
|
|
|
|
|
extern const char *Txt_No_new_posts;
|
2021-12-02 08:39:18 +01:00
|
|
|
|
static const char *ClassPhoto[Pho_NUM_SHAPES] =
|
2021-12-01 01:43:13 +01:00
|
|
|
|
{
|
2021-12-02 08:39:18 +01:00
|
|
|
|
[Pho_SHAPE_CIRCLE ] = "PHOTOC15x20",
|
|
|
|
|
[Pho_SHAPE_ELLIPSE ] = "PHOTOE15x20",
|
|
|
|
|
[Pho_SHAPE_OVAL ] = "PHOTOO15x20",
|
|
|
|
|
[Pho_SHAPE_RECTANGLE] = "PHOTOR15x20",
|
2021-12-01 01:43:13 +01:00
|
|
|
|
};
|
2014-12-01 23:55:08 +01:00
|
|
|
|
unsigned NumThr;
|
|
|
|
|
unsigned NumThrInScreen; // From 0 to Pag_ITEMS_PER_PAGE-1
|
2020-04-14 00:11:28 +02:00
|
|
|
|
struct For_Thread Thr;
|
2015-10-24 20:46:11 +02:00
|
|
|
|
unsigned UniqueId;
|
2019-11-01 22:53:39 +01:00
|
|
|
|
char *Id;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct UsrData UsrDat;
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Dat_StartEndTime_t Order;
|
2015-10-24 20:12:03 +02:00
|
|
|
|
time_t TimeUTC;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct Pagination PaginationPsts;
|
|
|
|
|
const char *Style;
|
|
|
|
|
long ThreadInMyClipboard = -1L;
|
|
|
|
|
unsigned Column;
|
2015-09-04 17:43:18 +02:00
|
|
|
|
const char *BgColor;
|
2017-04-18 13:17:40 +02:00
|
|
|
|
bool ICanMoveThreads;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get if there is a thread ready to be moved *****/
|
2017-04-18 13:17:40 +02:00
|
|
|
|
if ((ICanMoveThreads = For_CheckIfICanMoveThreads ()))
|
2021-05-10 21:10:06 +02:00
|
|
|
|
ThreadInMyClipboard = For_DB_GetThrInMyClipboard ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Initialize structure with user's data *****/
|
|
|
|
|
Usr_UsrDataConstructor (&UsrDat);
|
|
|
|
|
|
2020-12-01 09:58:21 +01:00
|
|
|
|
/***** List threads *****/
|
2020-04-14 00:11:28 +02:00
|
|
|
|
for (NumThr = PaginationThrs->FirstItemVisible, NumThrInScreen = 0, UniqueId = 0, Gbl.RowEvenOdd = 0;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
NumThr <= PaginationThrs->LastItemVisible;
|
|
|
|
|
NumThr++, NumThrInScreen++, Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd)
|
|
|
|
|
{
|
|
|
|
|
/***** Get the data of this thread *****/
|
2020-04-14 00:11:28 +02:00
|
|
|
|
Thr.ThrCod = ThrCods[NumThrInScreen];
|
|
|
|
|
For_GetThreadData (&Thr);
|
2020-11-11 01:14:53 +01:00
|
|
|
|
Forums->Thread.Current = Thr.ThrCod;
|
2020-04-14 00:11:28 +02:00
|
|
|
|
Style = (Thr.NumUnreadPosts ? "AUTHOR_TXT_NEW" :
|
|
|
|
|
"AUTHOR_TXT");
|
|
|
|
|
BgColor = (Thr.ThrCod == ThreadInMyClipboard) ? "LIGHT_GREEN" :
|
2021-12-15 14:02:49 +01:00
|
|
|
|
((Thr.ThrCod == ThrCodHighlighted) ? The_ClassBgHighlight[Gbl.Prefs.Theme] :
|
2020-04-14 00:11:28 +02:00
|
|
|
|
Gbl.ColorRows[Gbl.RowEvenOdd]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-12 19:10:32 +02:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
/***** Show my photo if I have any posts in this thread *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"BT %s\"",BgColor);
|
|
|
|
|
if (Thr.NumMyPosts)
|
|
|
|
|
HTM_IMG (Gbl.Usrs.Me.PhotoURL[0] ? Gbl.Usrs.Me.PhotoURL :
|
|
|
|
|
Cfg_URL_ICON_PUBLIC,
|
|
|
|
|
Gbl.Usrs.Me.PhotoURL[0] ? NULL :
|
|
|
|
|
"usr_bl.jpg",
|
|
|
|
|
Txt_Thread_with_posts_from_you,
|
2021-12-02 08:39:18 +01:00
|
|
|
|
"class=\"%s\"",ClassPhoto[Gbl.Prefs.PhotoShape]);
|
2021-04-24 15:10:07 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TD_Begin ("class=\"CONTEXT_COL %s\"",BgColor);
|
|
|
|
|
/***** Put an icon with thread status *****/
|
|
|
|
|
Ico_PutIcon (Thr.NumUnreadPosts ? "envelope.svg" :
|
|
|
|
|
"envelope-open-text.svg",
|
|
|
|
|
Thr.NumUnreadPosts ? Txt_There_are_new_posts :
|
|
|
|
|
Txt_No_new_posts,
|
|
|
|
|
"ICO16x16");
|
|
|
|
|
|
|
|
|
|
/***** Put button to remove the thread *****/
|
|
|
|
|
if (PermissionThreadDeletion[Forums->Forum.Type] &
|
|
|
|
|
(1 << Gbl.Usrs.Me.Role.Logged)) // If I have permission to remove thread in this forum...
|
|
|
|
|
{
|
|
|
|
|
HTM_BR ();
|
|
|
|
|
Ico_PutContextualIconToRemove (For_ActionsReqDelThr[Forums->Forum.Type],For_REMOVE_THREAD_SECTION_ID,
|
|
|
|
|
For_PutParamsForum,Forums);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
/***** Put button to cut the thread for moving it to another forum *****/
|
|
|
|
|
if (ICanMoveThreads)
|
|
|
|
|
{
|
|
|
|
|
HTM_BR ();
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Frm_BeginFormAnchor (For_ActionsCutThrFor[Forums->Forum.Type],
|
2021-04-24 15:10:07 +02:00
|
|
|
|
For_FORUM_THREADS_SECTION_ID);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
For_PutAllHiddenParamsForum (Forums->CurrentPageThrs, // Page of threads = current
|
|
|
|
|
1, // Page of posts = first
|
|
|
|
|
Forums->ForumSet,
|
|
|
|
|
Forums->ThreadsOrder,
|
|
|
|
|
Forums->Forum.Location,
|
|
|
|
|
Thr.ThrCod,
|
|
|
|
|
-1L);
|
|
|
|
|
Ico_PutIconCut ();
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write subject and links to thread pages *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"LT %s\"",BgColor);
|
|
|
|
|
PaginationPsts.NumItems = Thr.NumPosts;
|
|
|
|
|
PaginationPsts.CurrentPage = 1; // First page
|
|
|
|
|
Pag_CalculatePagination (&PaginationPsts);
|
|
|
|
|
PaginationPsts.Anchor = For_FORUM_POSTS_SECTION_ID;
|
|
|
|
|
Pag_WriteLinksToPages (Pag_POSTS_FORUM,
|
|
|
|
|
&PaginationPsts,
|
|
|
|
|
Forums,Thr.ThrCod,
|
2021-09-18 18:22:26 +02:00
|
|
|
|
Thr.Enabled[Dat_STR_TIME],
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Thr.Subject,
|
|
|
|
|
Thr.NumUnreadPosts ? The_ClassFormInBoxBold[Gbl.Prefs.Theme] :
|
|
|
|
|
The_ClassFormInBox[Gbl.Prefs.Theme],
|
|
|
|
|
true);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/***** Write the authors and date-times of first and last posts *****/
|
2021-09-18 18:22:26 +02:00
|
|
|
|
for (Order = Dat_STR_TIME;
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Order <= Dat_END_TIME;
|
|
|
|
|
Order++)
|
|
|
|
|
{
|
2021-09-18 18:22:26 +02:00
|
|
|
|
if (Order == Dat_STR_TIME || Thr.NumPosts > 1) // Don't write twice the same author when thread has only one thread
|
2021-04-24 15:10:07 +02:00
|
|
|
|
{
|
|
|
|
|
/* Write the author of first or last message */
|
|
|
|
|
UsrDat.UsrCod = Thr.UsrCod[Order];
|
|
|
|
|
Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&UsrDat,
|
|
|
|
|
Usr_DONT_GET_PREFS,
|
|
|
|
|
Usr_DONT_GET_ROLE_IN_CURRENT_CRS);
|
|
|
|
|
HTM_TD_Begin ("class=\"%s LT %s\"",Style,BgColor);
|
|
|
|
|
Msg_WriteMsgAuthor (&UsrDat,Thr.Enabled[Order],BgColor);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Write the date of first or last message (it's in YYYYMMDDHHMMSS format) */
|
|
|
|
|
TimeUTC = Thr.WriteTime[Order];
|
|
|
|
|
UniqueId++;
|
|
|
|
|
if (asprintf (&Id,"thr_date_%u",UniqueId) < 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2021-04-24 15:10:07 +02:00
|
|
|
|
HTM_TD_Begin ("id=\"%s\" class=\"%s LT %s\"",Id,Style,BgColor);
|
|
|
|
|
Dat_WriteLocalDateHMSFromUTC (Id,TimeUTC,
|
|
|
|
|
Gbl.Prefs.DateFormat,Dat_SEPARATOR_BREAK,
|
|
|
|
|
true,true,false,0x6);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
free (Id);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
for (Column = 1;
|
|
|
|
|
Column <= 2;
|
|
|
|
|
Column++)
|
|
|
|
|
{
|
|
|
|
|
HTM_TD_Begin ("class=\"%s LT %s\"",Style,BgColor);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
/***** Write number of posts in this thread *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor);
|
|
|
|
|
HTM_TxtF ("%u ",Thr.NumPosts);
|
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
/***** Write number of new posts in this thread *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor);
|
|
|
|
|
HTM_TxtF ("%u ",Thr.NumUnreadPosts);
|
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
/***** Write number of users who have write posts in this thread *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor);
|
|
|
|
|
HTM_TxtF ("%u ",Thr.NumWriters);
|
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-04-24 15:10:07 +02:00
|
|
|
|
/***** Write number of users who have read this thread *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"%s RT %s\"",Style,BgColor);
|
|
|
|
|
HTM_TxtF ("%u ",Thr.NumReaders);
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 15:15:55 +02:00
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free memory used for user's data *****/
|
|
|
|
|
Usr_UsrDataDestructor (&UsrDat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Get data of a thread **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-10 19:14:08 +02:00
|
|
|
|
static void For_GetThreadData (struct For_Thread *Thr)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_no_subject;
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Dat_StartEndTime_t Order;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of a thread from database *****/
|
2021-09-15 20:21:02 +02:00
|
|
|
|
if (For_DB_GetThreadData (&mysql_res,Thr->ThrCod) != 1)
|
|
|
|
|
Err_WrongThreadExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
2021-09-15 20:21:02 +02:00
|
|
|
|
/***** Get the codes of the first (row[0])
|
|
|
|
|
and the last post (row[1]) in this thread *****/
|
2021-09-18 18:22:26 +02:00
|
|
|
|
Thr->PstCod[Dat_STR_TIME] = Str_ConvertStrCodToLongCod (row[0]);
|
|
|
|
|
Thr->PstCod[Dat_END_TIME] = Str_ConvertStrCodToLongCod (row[1]);
|
2016-12-30 01:20:49 +01:00
|
|
|
|
|
2021-04-25 20:36:48 +02:00
|
|
|
|
/***** Get the code of the first message (row[0])
|
|
|
|
|
and the last message (row[1]) in this thread *****/
|
2021-09-18 18:22:26 +02:00
|
|
|
|
if (sscanf (row[0],"%ld",&(Thr->PstCod[Dat_STR_TIME])) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPostExit ();
|
2021-09-18 18:22:26 +02:00
|
|
|
|
if (sscanf (row[1],"%ld",&(Thr->PstCod[Dat_END_TIME])) != 1)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPostExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-16 17:10:32 +02:00
|
|
|
|
/***** Get the author of the first post in this thread (row[2])
|
|
|
|
|
and the author of the last post in this thread (row[3]) *****/
|
2021-09-18 18:22:26 +02:00
|
|
|
|
Thr->UsrCod[Dat_STR_TIME] = Str_ConvertStrCodToLongCod (row[2]);
|
|
|
|
|
Thr->UsrCod[Dat_END_TIME] = Str_ConvertStrCodToLongCod (row[3]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-16 17:10:32 +02:00
|
|
|
|
/***** Get the date of the first post in this thread (row[4])
|
|
|
|
|
and the date of the last post in this thread (row[5]) *****/
|
2021-09-18 18:22:26 +02:00
|
|
|
|
Thr->WriteTime[Dat_STR_TIME] = Dat_GetUNIXTimeFromStr (row[4]);
|
|
|
|
|
Thr->WriteTime[Dat_END_TIME] = Dat_GetUNIXTimeFromStr (row[5]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the subject of this thread (row[6]) *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Thr->Subject,row[6],sizeof (Thr->Subject) - 1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (!Thr->Subject[0])
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (Thr->Subject,sizeof (Thr->Subject),"[%s]",Txt_no_subject);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
|
|
|
|
|
/***** Get if first or last message are enabled *****/
|
2021-09-18 18:22:26 +02:00
|
|
|
|
for (Order = Dat_STR_TIME;
|
2020-04-05 22:53:58 +02:00
|
|
|
|
Order <= Dat_END_TIME;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Order++)
|
2021-11-24 22:57:10 +01:00
|
|
|
|
Thr->Enabled[Order] = !For_DB_GetIfPstIsDisabled (Thr->PstCod[Order]);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of posts in this thread *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Thr->NumPosts = For_DB_GetNumPstsInThr (Thr->ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of unread (by me) posts in this thread *****/
|
|
|
|
|
Thr->NumUnreadPosts = For_GetNumOfUnreadPostsInThr (Thr->ThrCod,Thr->NumPosts);
|
|
|
|
|
|
|
|
|
|
/***** Get number of posts that I have written in this thread *****/
|
2021-09-15 20:21:02 +02:00
|
|
|
|
Thr->NumMyPosts = For_DB_GetNumMyPstsInThr (Thr->ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of users who have write posts in this thread *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Thr->NumWriters = For_DB_GetNumOfWritersInThr (Thr->ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get number of users who have read this thread *****/
|
2021-09-15 20:21:02 +02:00
|
|
|
|
Thr->NumReaders = For_DB_GetNumReadersOfThr (Thr->ThrCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Show posts of a thread in a discussion forum ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_ShowThreadPosts (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forums Forums;
|
|
|
|
|
|
|
|
|
|
/***** Reset forum *****/
|
|
|
|
|
For_ResetForums (&Forums);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters related to forums *****/
|
|
|
|
|
For_GetParamsForums (&Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
|
|
|
|
/***** Show threads again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,NULL);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Show the posts of that thread *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowPostsOfAThread (&Forums,Ale_SUCCESS,NULL);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get parameters related to a forum *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_GetParamsForums (struct For_Forums *Forums)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Set forum type *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_SetForumType (Forums);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/***** Get parameter with code of course, degree, center or institution *****/
|
2020-04-10 19:14:08 +02:00
|
|
|
|
switch (Forums->Forum.Type)
|
2017-04-16 13:54:02 +02:00
|
|
|
|
{
|
|
|
|
|
case For_FORUM_INSTIT_USRS:
|
|
|
|
|
case For_FORUM_INSTIT_TCHS:
|
2021-03-07 21:21:04 +01:00
|
|
|
|
case For_FORUM_CENTER_USRS:
|
|
|
|
|
case For_FORUM_CENTER_TCHS:
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_DEGREE_USRS:
|
|
|
|
|
case For_FORUM_DEGREE_TCHS:
|
|
|
|
|
case For_FORUM_COURSE_USRS:
|
|
|
|
|
case For_FORUM_COURSE_TCHS:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Location = Par_GetParToLong ("Location");
|
2017-04-16 13:54:02 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Location = -1L;
|
2017-04-16 13:54:02 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-17 19:03:21 +02:00
|
|
|
|
/***** Get optional parameter with code of a selected thread *****/
|
2020-11-11 01:14:53 +01:00
|
|
|
|
Forums->Thread.Current =
|
|
|
|
|
Forums->Thread.Selected = Par_GetParToLong ("ThrCod");
|
2017-04-18 01:25:44 +02:00
|
|
|
|
|
|
|
|
|
/***** Get optional parameter with code of a selected post *****/
|
2020-04-14 00:11:28 +02:00
|
|
|
|
Forums->PstCod = Par_GetParToLong ("PstCod");
|
2017-04-17 19:03:21 +02:00
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Get which forums I want to see *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
Forums->ForumSet = (For_ForumSet_t)
|
|
|
|
|
Par_GetParToUnsignedLong ("ForumSet",
|
|
|
|
|
0,
|
|
|
|
|
For_NUM_FORUM_SETS - 1,
|
|
|
|
|
(unsigned long) For_DEFAULT_FORUM_SET);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
|
|
|
|
|
/***** Get order type *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
Forums->ThreadsOrder = (Dat_StartEndTime_t)
|
|
|
|
|
Par_GetParToUnsignedLong ("Order",
|
|
|
|
|
0,
|
|
|
|
|
Dat_NUM_START_END_TIME - 1,
|
|
|
|
|
(unsigned long) For_DEFAULT_ORDER);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Get optional page numbers for threads and posts *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
Forums->CurrentPageThrs = Pag_GetParamPagNum (Pag_THREADS_FORUM);
|
|
|
|
|
Forums->CurrentPagePsts = Pag_GetParamPagNum (Pag_POSTS_FORUM);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Restrict access to forum *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_RestrictAccess (Forums);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
}
|
2017-04-14 00:27:38 +02:00
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Set the type of forum *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_SetForumType (struct For_Forums *Forums)
|
2017-04-16 13:45:11 +02:00
|
|
|
|
{
|
|
|
|
|
switch (Gbl.Action.Act)
|
|
|
|
|
{
|
|
|
|
|
case ActSeeFor:
|
|
|
|
|
case ActSeeForGenUsr: case ActSeePstForGenUsr:
|
|
|
|
|
case ActRcvThrForGenUsr: case ActRcvRepForGenUsr:
|
|
|
|
|
case ActReqDelThrGenUsr: case ActDelThrForGenUsr:
|
|
|
|
|
case ActCutThrForGenUsr: case ActPasThrForGenUsr:
|
|
|
|
|
case ActDelPstForGenUsr:
|
|
|
|
|
case ActEnbPstForGenUsr: case ActDisPstForGenUsr:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM_GLOBAL_USRS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForGenTch: case ActSeePstForGenTch:
|
|
|
|
|
case ActRcvThrForGenTch: case ActRcvRepForGenTch:
|
|
|
|
|
case ActReqDelThrGenTch: case ActDelThrForGenTch:
|
|
|
|
|
case ActCutThrForGenTch: case ActPasThrForGenTch:
|
|
|
|
|
case ActDelPstForGenTch:
|
|
|
|
|
case ActEnbPstForGenTch: case ActDisPstForGenTch:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM_GLOBAL_TCHS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForSWAUsr: case ActSeePstForSWAUsr:
|
|
|
|
|
case ActRcvThrForSWAUsr: case ActRcvRepForSWAUsr:
|
|
|
|
|
case ActReqDelThrSWAUsr: case ActDelThrForSWAUsr:
|
|
|
|
|
case ActCutThrForSWAUsr: case ActPasThrForSWAUsr:
|
|
|
|
|
case ActDelPstForSWAUsr:
|
|
|
|
|
case ActEnbPstForSWAUsr: case ActDisPstForSWAUsr:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM__SWAD__USRS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForSWATch: case ActSeePstForSWATch:
|
|
|
|
|
case ActRcvThrForSWATch: case ActRcvRepForSWATch:
|
|
|
|
|
case ActReqDelThrSWATch: case ActDelThrForSWATch:
|
|
|
|
|
case ActCutThrForSWATch: case ActPasThrForSWATch:
|
|
|
|
|
case ActDelPstForSWATch:
|
|
|
|
|
case ActEnbPstForSWATch: case ActDisPstForSWATch:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM__SWAD__TCHS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForInsUsr: case ActSeePstForInsUsr:
|
|
|
|
|
case ActRcvThrForInsUsr: case ActRcvRepForInsUsr:
|
|
|
|
|
case ActReqDelThrInsUsr: case ActDelThrForInsUsr:
|
|
|
|
|
case ActCutThrForInsUsr: case ActPasThrForInsUsr:
|
|
|
|
|
case ActDelPstForInsUsr:
|
|
|
|
|
case ActEnbPstForInsUsr: case ActDisPstForInsUsr:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM_INSTIT_USRS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForInsTch: case ActSeePstForInsTch:
|
|
|
|
|
case ActRcvThrForInsTch: case ActRcvRepForInsTch:
|
|
|
|
|
case ActReqDelThrInsTch: case ActDelThrForInsTch:
|
|
|
|
|
case ActCutThrForInsTch: case ActPasThrForInsTch:
|
|
|
|
|
case ActDelPstForInsTch:
|
|
|
|
|
case ActEnbPstForInsTch: case ActDisPstForInsTch:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM_INSTIT_TCHS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForCtrUsr: case ActSeePstForCtrUsr:
|
|
|
|
|
case ActRcvThrForCtrUsr: case ActRcvRepForCtrUsr:
|
|
|
|
|
case ActReqDelThrCtrUsr: case ActDelThrForCtrUsr:
|
|
|
|
|
case ActCutThrForCtrUsr: case ActPasThrForCtrUsr:
|
|
|
|
|
case ActDelPstForCtrUsr:
|
|
|
|
|
case ActEnbPstForCtrUsr: case ActDisPstForCtrUsr:
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Forums->Forum.Type = For_FORUM_CENTER_USRS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForCtrTch: case ActSeePstForCtrTch:
|
|
|
|
|
case ActRcvThrForCtrTch: case ActRcvRepForCtrTch:
|
|
|
|
|
case ActReqDelThrCtrTch: case ActDelThrForCtrTch:
|
|
|
|
|
case ActCutThrForCtrTch: case ActPasThrForCtrTch:
|
|
|
|
|
case ActDelPstForCtrTch:
|
|
|
|
|
case ActEnbPstForCtrTch: case ActDisPstForCtrTch:
|
2021-03-07 21:21:04 +01:00
|
|
|
|
Forums->Forum.Type = For_FORUM_CENTER_TCHS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForDegUsr: case ActSeePstForDegUsr:
|
|
|
|
|
case ActRcvThrForDegUsr: case ActRcvRepForDegUsr:
|
|
|
|
|
case ActReqDelThrDegUsr: case ActDelThrForDegUsr:
|
|
|
|
|
case ActCutThrForDegUsr: case ActPasThrForDegUsr:
|
|
|
|
|
case ActDelPstForDegUsr:
|
|
|
|
|
case ActEnbPstForDegUsr: case ActDisPstForDegUsr:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM_DEGREE_USRS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForDegTch: case ActSeePstForDegTch:
|
|
|
|
|
case ActRcvThrForDegTch: case ActRcvRepForDegTch:
|
|
|
|
|
case ActReqDelThrDegTch: case ActDelThrForDegTch:
|
|
|
|
|
case ActCutThrForDegTch: case ActPasThrForDegTch:
|
|
|
|
|
case ActDelPstForDegTch:
|
|
|
|
|
case ActEnbPstForDegTch: case ActDisPstForDegTch:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM_DEGREE_TCHS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForCrsUsr: case ActSeePstForCrsUsr:
|
|
|
|
|
case ActRcvThrForCrsUsr: case ActRcvRepForCrsUsr:
|
|
|
|
|
case ActReqDelThrCrsUsr: case ActDelThrForCrsUsr:
|
|
|
|
|
case ActCutThrForCrsUsr: case ActPasThrForCrsUsr:
|
|
|
|
|
case ActDelPstForCrsUsr:
|
|
|
|
|
case ActEnbPstForCrsUsr: case ActDisPstForCrsUsr:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM_COURSE_USRS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
|
|
|
|
case ActSeeForCrsTch: case ActSeePstForCrsTch:
|
|
|
|
|
case ActRcvThrForCrsTch: case ActRcvRepForCrsTch:
|
|
|
|
|
case ActReqDelThrCrsTch: case ActDelThrForCrsTch:
|
|
|
|
|
case ActCutThrForCrsTch: case ActPasThrForCrsTch:
|
|
|
|
|
case ActDelPstForCrsTch:
|
|
|
|
|
case ActEnbPstForCrsTch: case ActDisPstForCrsTch:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM_COURSE_TCHS;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
default:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
Forums->Forum.Type = For_FORUM_UNKNOWN;
|
2017-04-14 00:27:38 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Restrict access to forum *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_RestrictAccess (const struct For_Forums *Forums)
|
2017-04-16 13:45:11 +02:00
|
|
|
|
{
|
2017-05-23 20:42:38 +02:00
|
|
|
|
Rol_Role_t MaxRole;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
bool ICanSeeForum;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
|
|
|
|
|
/***** Restrict access *****/
|
2020-04-10 19:14:08 +02:00
|
|
|
|
switch (Forums->Forum.Type)
|
2017-04-16 13:45:11 +02:00
|
|
|
|
{
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_GLOBAL_USRS:
|
|
|
|
|
case For_FORUM__SWAD__USRS:
|
|
|
|
|
ICanSeeForum = true;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_GLOBAL_TCHS:
|
|
|
|
|
case For_FORUM__SWAD__TCHS:
|
2021-04-24 15:10:07 +02:00
|
|
|
|
Rol_GetRolesInAllCrss (&Gbl.Usrs.Me.UsrDat);
|
2017-06-08 15:32:33 +02:00
|
|
|
|
ICanSeeForum = (Gbl.Usrs.Me.UsrDat.Roles.InCrss & ((1 << Rol_NET) |
|
2019-03-07 22:15:47 +01:00
|
|
|
|
(1 << Rol_TCH)));
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_INSTIT_USRS:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
MaxRole = Rol_GetMyMaxRoleInIns (Forums->Forum.Location);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRole == Rol_STD ||
|
|
|
|
|
MaxRole == Rol_NET ||
|
|
|
|
|
MaxRole == Rol_TCH);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_INSTIT_TCHS:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
MaxRole = Rol_GetMyMaxRoleInIns (Forums->Forum.Location);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRole == Rol_NET ||
|
|
|
|
|
MaxRole == Rol_TCH);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
case For_FORUM_CENTER_USRS:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
MaxRole = Rol_GetMyMaxRoleInCtr (Forums->Forum.Location);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRole >= Rol_STD ||
|
|
|
|
|
MaxRole == Rol_NET ||
|
|
|
|
|
MaxRole == Rol_TCH);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2021-03-07 21:21:04 +01:00
|
|
|
|
case For_FORUM_CENTER_TCHS:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
MaxRole = Rol_GetMyMaxRoleInCtr (Forums->Forum.Location);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRole == Rol_NET ||
|
|
|
|
|
MaxRole == Rol_TCH);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_DEGREE_USRS:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
MaxRole = Rol_GetMyMaxRoleInDeg (Forums->Forum.Location);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRole >= Rol_STD ||
|
|
|
|
|
MaxRole == Rol_NET ||
|
|
|
|
|
MaxRole == Rol_TCH);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_DEGREE_TCHS:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
MaxRole = Rol_GetMyMaxRoleInDeg (Forums->Forum.Location);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRole == Rol_NET ||
|
|
|
|
|
MaxRole == Rol_TCH);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_COURSE_USRS:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
MaxRole = Rol_GetMyRoleInCrs (Forums->Forum.Location);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRole >= Rol_STD ||
|
|
|
|
|
MaxRole == Rol_NET ||
|
|
|
|
|
MaxRole == Rol_TCH);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM_COURSE_TCHS:
|
2020-04-10 19:14:08 +02:00
|
|
|
|
MaxRole = Rol_GetMyRoleInCrs (Forums->Forum.Location);
|
2017-06-04 18:18:54 +02:00
|
|
|
|
ICanSeeForum = (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM ||
|
2017-05-23 20:42:38 +02:00
|
|
|
|
MaxRole == Rol_NET ||
|
|
|
|
|
MaxRole == Rol_TCH);
|
2017-04-16 13:45:11 +02:00
|
|
|
|
break;
|
2017-04-18 19:55:56 +02:00
|
|
|
|
default:
|
|
|
|
|
ICanSeeForum = false;
|
|
|
|
|
break;
|
2017-04-16 13:45:11 +02:00
|
|
|
|
}
|
|
|
|
|
if (!ICanSeeForum)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2017-04-16 13:45:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Show an area to write a message **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-09 21:36:21 +02:00
|
|
|
|
static void For_WriteFormForumPst (struct For_Forums *Forums,
|
2020-04-07 03:01:41 +02:00
|
|
|
|
bool IsReply,const char *Subject)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-09-26 17:20:01 +02:00
|
|
|
|
extern const char *Hlp_COMMUNICATION_Forums_new_post;
|
|
|
|
|
extern const char *Hlp_COMMUNICATION_Forums_new_thread;
|
2019-02-22 21:47:50 +01:00
|
|
|
|
extern const char *The_ClassFormInBox[The_NUM_THEMES];
|
2021-12-15 23:54:57 +01:00
|
|
|
|
extern const char *The_ClassInput[The_NUM_THEMES];
|
2017-04-17 14:18:57 +02:00
|
|
|
|
extern const char *Txt_New_post;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_New_thread;
|
|
|
|
|
extern const char *Txt_MSG_Subject;
|
2017-04-19 14:27:52 +02:00
|
|
|
|
extern const char *Txt_MSG_Content;
|
2017-04-17 14:18:57 +02:00
|
|
|
|
extern const char *Txt_Send;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2017-06-11 22:26:40 +02:00
|
|
|
|
if (IsReply)
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_New_post,
|
|
|
|
|
NULL,NULL,
|
2020-09-26 17:20:01 +02:00
|
|
|
|
Hlp_COMMUNICATION_Forums_new_post,Box_NOT_CLOSABLE);
|
2017-06-11 22:26:40 +02:00
|
|
|
|
else
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_New_thread,
|
|
|
|
|
NULL,NULL,
|
2020-09-26 17:20:01 +02:00
|
|
|
|
Hlp_COMMUNICATION_Forums_new_thread,Box_NOT_CLOSABLE);
|
2016-04-09 18:23:15 +02:00
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2017-04-19 14:43:08 +02:00
|
|
|
|
if (IsReply) // Form to write a reply to a post of an existing thread
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Frm_BeginFormAnchor (For_ActionsRecRepFor[Forums->Forum.Type],
|
2017-05-25 13:43:54 +02:00
|
|
|
|
For_FORUM_POSTS_SECTION_ID);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
For_PutAllHiddenParamsNewPost (Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2017-04-19 14:43:08 +02:00
|
|
|
|
else // Form to write the first post of a new thread
|
2017-04-18 01:25:44 +02:00
|
|
|
|
{
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Frm_BeginFormAnchor (For_ActionsRecThrFor[Forums->Forum.Type],
|
2017-05-25 13:43:54 +02:00
|
|
|
|
For_FORUM_POSTS_SECTION_ID);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
For_PutAllHiddenParamsNewThread (Forums);
|
2017-04-18 01:25:44 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/***** Subject and content *****/
|
|
|
|
|
HTM_TABLE_BeginCenterPadding (2);
|
2017-03-07 01:56:41 +01:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
// If writing a reply to a message of an existing thread ==> write subject
|
|
|
|
|
/* Subject */
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 15:15:55 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/* Label */
|
|
|
|
|
Frm_LabelColumn ("RT","Subject",Txt_MSG_Subject);
|
2019-10-07 15:15:55 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
|
|
|
|
HTM_INPUT_TEXT ("Subject",Cns_MAX_CHARS_SUBJECT,
|
|
|
|
|
IsReply ? Subject :
|
|
|
|
|
"",
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
2021-12-17 00:17:35 +01:00
|
|
|
|
"id=\"Subject\" class=\"MSG_SUBJECT %s\""
|
|
|
|
|
" required=\"required\"",
|
|
|
|
|
The_ClassInput[Gbl.Prefs.Theme]);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TD_End ();
|
2019-10-07 15:15:55 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TR_End ();
|
2017-03-07 01:56:41 +01:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/* Content */
|
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-07 15:15:55 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/* Label */
|
|
|
|
|
Frm_LabelColumn ("RT","Content",Txt_MSG_Content);
|
2019-10-07 15:15:55 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/* Data */
|
|
|
|
|
HTM_TD_Begin ("class=\"LT\"");
|
2021-12-17 00:17:35 +01:00
|
|
|
|
HTM_TEXTAREA_Begin ("id=\"Content\" name=\"Content\""
|
|
|
|
|
" class=\"MSG_CONTENT %s\" rows=\"10\"",
|
|
|
|
|
The_ClassInput[Gbl.Prefs.Theme]);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TEXTAREA_End ();
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 15:15:55 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TR_End ();
|
2017-03-07 01:56:41 +01:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
HTM_TABLE_End ();
|
2016-04-09 18:15:54 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/***** Help for text editor *****/
|
|
|
|
|
Lay_HelpPlainEditor ();
|
2015-04-11 14:00:23 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/***** Attached image (optional) *****/
|
2021-12-15 23:54:57 +01:00
|
|
|
|
Med_PutMediaUploader (-1,Str_BuildString ("FOR_MED_INPUT %s",
|
|
|
|
|
The_ClassInput[Gbl.Prefs.Theme]));
|
|
|
|
|
Str_FreeStrings ();
|
2016-04-10 14:09:50 +02:00
|
|
|
|
|
2021-12-01 01:43:13 +01:00
|
|
|
|
/***** Send button *****/
|
|
|
|
|
Btn_PutCreateButton (Txt_Send);
|
2015-04-11 14:00:23 +02:00
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2016-04-09 18:23:15 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Receive message of a forum ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_ReceiveForumPost (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-03-06 10:13:39 +01:00
|
|
|
|
extern const char *Txt_FORUM_Post_sent;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forums Forums;
|
2017-04-18 16:44:44 +02:00
|
|
|
|
bool IsReply = false;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
long PstCod = 0;
|
|
|
|
|
unsigned NumUsrsToBeNotifiedByEMail;
|
2020-04-11 15:21:30 +02:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Content[Cns_MAX_BYTES_LONG_TEXT + 1];
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Med_Media Media;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
/***** Reset forum *****/
|
|
|
|
|
For_ResetForums (&Forums);
|
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Get parameters related to forum *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_GetParamsForums (&Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the code of the thread y the n<>mero of page *****/
|
2016-01-17 15:10:54 +01:00
|
|
|
|
if (Gbl.Action.Act == ActRcvRepForCrsUsr || Gbl.Action.Act == ActRcvRepForCrsTch ||
|
|
|
|
|
Gbl.Action.Act == ActRcvRepForDegUsr || Gbl.Action.Act == ActRcvRepForDegTch ||
|
|
|
|
|
Gbl.Action.Act == ActRcvRepForCtrUsr || Gbl.Action.Act == ActRcvRepForCtrTch ||
|
|
|
|
|
Gbl.Action.Act == ActRcvRepForInsUsr || Gbl.Action.Act == ActRcvRepForInsTch ||
|
|
|
|
|
Gbl.Action.Act == ActRcvRepForGenUsr || Gbl.Action.Act == ActRcvRepForGenTch ||
|
|
|
|
|
Gbl.Action.Act == ActRcvRepForSWAUsr || Gbl.Action.Act == ActRcvRepForSWATch)
|
2017-04-18 16:44:44 +02:00
|
|
|
|
IsReply = true;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get message subject *****/
|
2020-04-11 15:21:30 +02:00
|
|
|
|
Par_GetParToHTML ("Subject",Subject,Cns_MAX_BYTES_SUBJECT);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get message body *****/
|
|
|
|
|
Par_GetParAndChangeFormat ("Content",Content,Cns_MAX_BYTES_LONG_TEXT,
|
|
|
|
|
Str_TO_RIGOROUS_HTML,false);
|
|
|
|
|
|
2019-03-17 14:47:58 +01:00
|
|
|
|
/***** Initialize media *****/
|
2019-03-02 21:49:11 +01:00
|
|
|
|
Med_MediaConstructor (&Media);
|
2016-04-10 14:09:50 +02:00
|
|
|
|
|
2019-03-17 14:47:58 +01:00
|
|
|
|
/***** Get attached media *****/
|
2019-03-02 21:49:11 +01:00
|
|
|
|
Media.Width = For_IMAGE_SAVED_MAX_WIDTH;
|
|
|
|
|
Media.Height = For_IMAGE_SAVED_MAX_HEIGHT;
|
|
|
|
|
Media.Quality = For_IMAGE_SAVED_QUALITY;
|
2020-03-17 00:35:11 +01:00
|
|
|
|
Med_GetMediaFromForm (-1L,-1L,-1,&Media,NULL,
|
2019-03-17 14:47:58 +01:00
|
|
|
|
For_FORUM_POSTS_SECTION_ID); // Alerts will be shown later in posts section
|
2016-04-10 14:09:50 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Create a new message *****/
|
2017-04-18 16:44:44 +02:00
|
|
|
|
if (IsReply) // This post is a reply to another posts in the thread
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-04-14 00:11:28 +02:00
|
|
|
|
// Forums.ThrCod has been received from form
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create last message of the thread *****/
|
2020-11-11 01:14:53 +01:00
|
|
|
|
PstCod = For_InsertForumPst (Forums.Thread.Current,Gbl.Usrs.Me.UsrDat.UsrCod,
|
2020-04-11 15:21:30 +02:00
|
|
|
|
Subject,Content,&Media);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Modify last message of the thread *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
For_DB_UpdateThrLastPst (Forums.Thread.Current,PstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2016-04-10 19:19:20 +02:00
|
|
|
|
else // This post is the first of a new thread
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create new thread with unknown first and last message codes *****/
|
2020-11-11 01:14:53 +01:00
|
|
|
|
Forums.Thread.Current =
|
2021-06-17 13:26:25 +02:00
|
|
|
|
Forums.Thread.Selected = For_DB_InsertForumThread (&Forums,-1L);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Create first (and last) message of the thread *****/
|
2020-11-11 01:14:53 +01:00
|
|
|
|
PstCod = For_InsertForumPst (Forums.Thread.Current,Gbl.Usrs.Me.UsrDat.UsrCod,
|
2020-04-11 15:21:30 +02:00
|
|
|
|
Subject,Content,&Media);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Update first and last posts of new thread *****/
|
2021-06-17 13:26:25 +02:00
|
|
|
|
For_DB_UpdateThrFirstAndLastPst (Forums.Thread.Current,PstCod,PstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-03-18 15:42:22 +01:00
|
|
|
|
/***** Free media *****/
|
2019-03-02 21:49:11 +01:00
|
|
|
|
Med_MediaDestructor (&Media);
|
2016-04-10 14:09:50 +02:00
|
|
|
|
|
2015-03-11 12:38:47 +01:00
|
|
|
|
/***** Increment number of forum posts in my user's figures *****/
|
2021-07-08 15:00:17 +02:00
|
|
|
|
Prf_DB_IncrementNumForPstUsr (Gbl.Usrs.Me.UsrDat.UsrCod);
|
2015-03-11 12:38:47 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Notify the new post to users in course *****/
|
2020-04-10 19:14:08 +02:00
|
|
|
|
switch (Forums.Forum.Type)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
case For_FORUM_COURSE_USRS:
|
|
|
|
|
case For_FORUM_COURSE_TCHS:
|
|
|
|
|
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_FORUM_POST_COURSE,PstCod)))
|
2021-05-10 21:10:06 +02:00
|
|
|
|
For_DB_UpdateNumUsrsNotifiedByEMailAboutPost (PstCod,NumUsrsToBeNotifiedByEMail);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Notify the new post to previous writers in this thread *****/
|
2017-04-18 16:44:44 +02:00
|
|
|
|
if (IsReply)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if ((NumUsrsToBeNotifiedByEMail = Ntf_StoreNotifyEventsToAllUsrs (Ntf_EVENT_FORUM_REPLY,PstCod)))
|
2021-05-10 21:10:06 +02:00
|
|
|
|
For_DB_UpdateNumUsrsNotifiedByEMailAboutPost (PstCod,NumUsrsToBeNotifiedByEMail);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2015-12-31 14:25:28 +01:00
|
|
|
|
/***** Insert forum post into public social activity *****/
|
2020-04-10 19:14:08 +02:00
|
|
|
|
switch (Forums.Forum.Type) // Only if forum is public for any logged user
|
2015-12-28 20:46:48 +01:00
|
|
|
|
{
|
|
|
|
|
case For_FORUM_GLOBAL_USRS:
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM__SWAD__USRS:
|
2021-11-12 01:12:15 +01:00
|
|
|
|
Tml_Not_StoreAndPublishNote (Tml_NOTE_FORUM_POST,PstCod);
|
2015-12-28 20:46:48 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
|
|
|
|
/***** Show threads again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,NULL);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Show again the posts of this thread of the forum *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowPostsOfAThread (&Forums,Ale_SUCCESS,Txt_FORUM_Post_sent);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Delete a forum post ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_RemovePost (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-03-06 10:13:39 +01:00
|
|
|
|
extern const char *Txt_FORUM_Post_and_thread_removed;
|
|
|
|
|
extern const char *Txt_FORUM_Post_removed;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forums Forums;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
struct UsrData UsrDat;
|
2015-10-24 20:12:03 +02:00
|
|
|
|
time_t CreatTimeUTC; // Creation time of a message
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
|
|
|
|
char OriginalContent[Cns_MAX_BYTES_LONG_TEXT + 1];
|
2021-02-11 00:58:53 +01:00
|
|
|
|
struct Med_Media Media;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
bool ThreadDeleted = false;
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
/***** Reset forum *****/
|
|
|
|
|
For_ResetForums (&Forums);
|
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Get parameters related to forum *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_GetParamsForums (&Forums);
|
2016-04-10 23:59:45 +02:00
|
|
|
|
|
|
|
|
|
/***** Initialize image *****/
|
2019-03-02 21:49:11 +01:00
|
|
|
|
Med_MediaConstructor (&Media);
|
2016-04-10 23:59:45 +02:00
|
|
|
|
|
|
|
|
|
/***** Get forum post data *****/
|
2020-04-14 00:11:28 +02:00
|
|
|
|
For_GetPstData (Forums.PstCod,&UsrDat.UsrCod,&CreatTimeUTC,
|
2019-03-02 21:49:11 +01:00
|
|
|
|
Subject,OriginalContent,&Media);
|
2016-04-10 23:59:45 +02:00
|
|
|
|
|
|
|
|
|
/***** Check if I can remove the post *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/* Check if the message really exists, if it has not been removed */
|
2021-11-05 23:41:26 +01:00
|
|
|
|
if (!For_DB_CheckIfForumPstExists (Forums.PstCod))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongPostExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Check if I am the author of the message */
|
2021-11-18 22:06:06 +01:00
|
|
|
|
if (!Usr_ItsMe (UsrDat.UsrCod))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Check if the message is the last message in the thread */
|
2021-09-15 20:21:02 +02:00
|
|
|
|
if (Forums.PstCod != For_DB_GetThrLastPst (Forums.Thread.Current))
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-04-10 23:59:45 +02:00
|
|
|
|
/***** Remove the post *****/
|
2020-04-14 00:11:28 +02:00
|
|
|
|
ThreadDeleted = For_RemoveForumPst (Forums.PstCod,Media.MedCod);
|
2016-04-10 23:59:45 +02:00
|
|
|
|
|
|
|
|
|
/***** Free image *****/
|
2019-03-02 21:49:11 +01:00
|
|
|
|
Med_MediaDestructor (&Media);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark possible notifications as removed *****/
|
2021-06-29 15:25:42 +02:00
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_FORUM_POST_COURSE,Forums.PstCod);
|
|
|
|
|
Ntf_DB_MarkNotifAsRemoved (Ntf_EVENT_FORUM_REPLY ,Forums.PstCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-01-03 19:45:15 +01:00
|
|
|
|
/***** Mark possible social note as unavailable *****/
|
2020-04-10 19:14:08 +02:00
|
|
|
|
switch (Forums.Forum.Type) // Only if forum is public for any logged user
|
2016-01-03 19:45:15 +01:00
|
|
|
|
{
|
|
|
|
|
case For_FORUM_GLOBAL_USRS:
|
2017-04-18 19:55:56 +02:00
|
|
|
|
case For_FORUM__SWAD__USRS:
|
2021-11-12 01:12:15 +01:00
|
|
|
|
Tml_DB_MarkNoteAsUnavailable (Tml_NOTE_FORUM_POST,Forums.PstCod);
|
2016-01-03 19:45:15 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (ThreadDeleted)
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show the remaining threads *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Txt_FORUM_Post_and_thread_removed);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2017-04-18 13:17:40 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Show threads again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,NULL);
|
2021-11-18 22:06:06 +01:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show the remaining posts *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowPostsOfAThread (&Forums,Ale_SUCCESS,Txt_FORUM_Post_removed);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-04-18 01:25:44 +02:00
|
|
|
|
/***************** Request the removing of an existing thread ****************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_RequestRemoveThread (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_entire_thread_X;
|
|
|
|
|
extern const char *Txt_Do_you_really_want_to_remove_the_entire_thread;
|
|
|
|
|
extern const char *Txt_Remove_thread;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forums Forums;
|
2017-01-17 03:10:43 +01:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
/***** Reset forum *****/
|
|
|
|
|
For_ResetForums (&Forums);
|
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Get parameters related to forum *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_GetParamsForums (&Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Get subject of the thread to delete *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
For_DB_GetThrSubject (Forums.Thread.Current,Subject);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
2017-04-28 10:35:41 +02:00
|
|
|
|
/***** Show question and button to remove the thread *****/
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_Begin (For_REMOVE_THREAD_SECTION_ID);
|
2021-06-17 13:26:25 +02:00
|
|
|
|
if (Subject[0])
|
|
|
|
|
Ale_ShowAlertAndButton (For_ActionsDelThrFor[Forums.Forum.Type],
|
|
|
|
|
For_FORUM_THREADS_SECTION_ID,NULL,
|
|
|
|
|
For_PutAllHiddenParamsRemThread,&Forums,
|
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Remove_thread,
|
|
|
|
|
Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_entire_thread_X,
|
|
|
|
|
Subject);
|
|
|
|
|
else
|
|
|
|
|
Ale_ShowAlertAndButton (For_ActionsDelThrFor[Forums.Forum.Type],
|
|
|
|
|
For_FORUM_THREADS_SECTION_ID,NULL,
|
|
|
|
|
For_PutAllHiddenParamsRemThread,&Forums,
|
|
|
|
|
Btn_REMOVE_BUTTON,Txt_Remove_thread,
|
|
|
|
|
Ale_QUESTION,Txt_Do_you_really_want_to_remove_the_entire_thread);
|
2019-10-26 01:56:36 +02:00
|
|
|
|
HTM_SECTION_End ();
|
2017-04-28 10:35:41 +02:00
|
|
|
|
|
|
|
|
|
/***** Show the threads again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,NULL);
|
2017-04-28 10:35:41 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
static void For_PutAllHiddenParamsRemThread (void *Forums)
|
2017-04-28 10:35:41 +02:00
|
|
|
|
{
|
2020-04-07 03:01:41 +02:00
|
|
|
|
if (Forums)
|
|
|
|
|
For_PutAllHiddenParamsForum (((struct For_Forums *) Forums)->CurrentPageThrs, // Page of threads = current
|
2020-03-26 02:54:30 +01:00
|
|
|
|
1, // Page of posts = first
|
2020-04-07 03:01:41 +02:00
|
|
|
|
((struct For_Forums *) Forums)->ForumSet,
|
|
|
|
|
((struct For_Forums *) Forums)->ThreadsOrder,
|
2020-04-10 19:14:08 +02:00
|
|
|
|
((struct For_Forums *) Forums)->Forum.Location,
|
2020-11-11 01:14:53 +01:00
|
|
|
|
((struct For_Forums *) Forums)->Thread.Current,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
-1L);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Remove an existing thread ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_RemoveThread (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Thread_X_removed;
|
|
|
|
|
extern const char *Txt_Thread_removed;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forums Forums;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
2019-03-09 20:12:44 +01:00
|
|
|
|
char Message[256 + Cns_MAX_BYTES_SUBJECT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
/***** Reset forum *****/
|
|
|
|
|
For_ResetForums (&Forums);
|
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Get parameters related to forum *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_GetParamsForums (&Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-10 19:14:08 +02:00
|
|
|
|
if (PermissionThreadDeletion[Forums.Forum.Type] &
|
2017-06-04 18:18:54 +02:00
|
|
|
|
(1 << Gbl.Usrs.Me.Role.Logged)) // If I have permission to remove thread in this forum...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Get subject of thread to delete *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
For_DB_GetThrSubject (Forums.Thread.Current,Subject);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove the thread and all its posts *****/
|
2020-11-11 01:14:53 +01:00
|
|
|
|
For_RemoveThreadAndItsPsts (Forums.Thread.Current);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
|
|
|
|
/***** Show the threads again *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Subject[0])
|
|
|
|
|
{
|
2019-03-09 20:12:44 +01:00
|
|
|
|
snprintf (Message,sizeof (Message),
|
2018-10-16 21:56:01 +02:00
|
|
|
|
Txt_Thread_X_removed,Subject);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Message);
|
2017-04-18 09:55:25 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Txt_Thread_removed);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NoPermissionExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************** Cut a thread to move it to another forum ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_CutThread (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Thread_X_marked_to_be_moved;
|
|
|
|
|
extern const char *Txt_Thread_marked_to_be_moved;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forums Forums;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
2019-03-09 20:12:44 +01:00
|
|
|
|
char Message[256 + Cns_MAX_BYTES_SUBJECT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
/***** Reset forum *****/
|
|
|
|
|
For_ResetForums (&Forums);
|
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Get parameters related to forum *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_GetParamsForums (&Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get subject of thread to cut *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
For_DB_GetThrSubject (Forums.Thread.Current,Subject);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Mark the thread as cut *****/
|
2020-11-11 01:14:53 +01:00
|
|
|
|
For_InsertThrInClipboard (Forums.Thread.Current);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
|
|
|
|
/***** Show the threads again *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Subject[0])
|
2017-04-18 09:55:25 +02:00
|
|
|
|
{
|
2019-03-09 20:12:44 +01:00
|
|
|
|
snprintf (Message,sizeof (Message),
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Txt_Thread_X_marked_to_be_moved,Subject);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Message);
|
2017-04-18 09:55:25 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Txt_Thread_marked_to_be_moved);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************* Paste the thread in clipboard into current forum **************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-18 16:44:44 +02:00
|
|
|
|
void For_PasteThread (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_thread_X_is_already_in_this_forum;
|
|
|
|
|
extern const char *Txt_The_thread_is_already_in_this_forum;
|
|
|
|
|
extern const char *Txt_Thread_X_moved_to_this_forum;
|
|
|
|
|
extern const char *Txt_Thread_moved_to_this_forum;
|
2020-04-07 03:01:41 +02:00
|
|
|
|
struct For_Forums Forums;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Subject[Cns_MAX_BYTES_SUBJECT + 1];
|
2019-03-09 20:12:44 +01:00
|
|
|
|
char Message[256 + Cns_MAX_BYTES_SUBJECT + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2020-04-07 03:01:41 +02:00
|
|
|
|
/***** Reset forum *****/
|
|
|
|
|
For_ResetForums (&Forums);
|
|
|
|
|
|
2017-04-16 13:45:11 +02:00
|
|
|
|
/***** Get parameters related to forum *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_GetParamsForums (&Forums);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get subject of thread to paste *****/
|
2021-09-15 13:48:41 +02:00
|
|
|
|
For_DB_GetThrSubject (Forums.Thread.Current,Subject);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-04-18 09:55:25 +02:00
|
|
|
|
/***** Check if paste (move) the thread to current forum has sense *****/
|
2021-05-10 21:10:06 +02:00
|
|
|
|
if (For_DB_CheckIfThrBelongsToForum (Forums.Thread.Current,&Forums.Forum))
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
2017-04-18 09:55:25 +02:00
|
|
|
|
/***** Show the threads again *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Subject[0])
|
2017-04-18 09:55:25 +02:00
|
|
|
|
{
|
2019-03-09 20:12:44 +01:00
|
|
|
|
snprintf (Message,sizeof (Message),
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Txt_The_thread_X_is_already_in_this_forum,Subject);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_WARNING,Message);
|
2017-04-18 09:55:25 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_WARNING,Txt_The_thread_is_already_in_this_forum);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2017-04-18 09:55:25 +02:00
|
|
|
|
/***** Paste (move) the thread to current forum *****/
|
2021-05-10 21:10:06 +02:00
|
|
|
|
For_DB_MoveThrToCurrentForum (&Forums);
|
2017-04-18 09:55:25 +02:00
|
|
|
|
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/***** Show forum list again *****/
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumList (&Forums);
|
2017-04-18 13:17:40 +02:00
|
|
|
|
|
2017-04-18 09:55:25 +02:00
|
|
|
|
/***** Show the threads again *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Subject[0])
|
2017-04-18 09:55:25 +02:00
|
|
|
|
{
|
2019-03-09 20:12:44 +01:00
|
|
|
|
snprintf (Message,sizeof (Message),
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Txt_Thread_X_moved_to_this_forum,Subject);
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Message);
|
2017-04-18 09:55:25 +02:00
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
2020-04-07 03:01:41 +02:00
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,Txt_Thread_moved_to_this_forum);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2017-04-18 13:17:40 +02:00
|
|
|
|
/*********************** Check if I can move threads *************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool For_CheckIfICanMoveThreads (void)
|
|
|
|
|
{
|
2017-06-04 18:18:54 +02:00
|
|
|
|
return (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM); // If I have permission to move threads...
|
2017-04-18 13:17:40 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Insert thread in thread clipboard ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2017-04-16 23:48:05 +02:00
|
|
|
|
static void For_InsertThrInClipboard (long ThrCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Remove expired thread clipboards *****/
|
2021-09-15 20:21:02 +02:00
|
|
|
|
For_DB_RemoveExpiredClipboards ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Add thread to my clipboard *****/
|
2021-09-15 20:21:02 +02:00
|
|
|
|
For_DB_InsertThrInMyClipboard (ThrCod);
|
2016-10-27 22:26:52 +02:00
|
|
|
|
}
|