2022-09-24 19:17:00 +02:00
|
|
|
|
// swad_forum_resource.c: links to course forum threads as program resources
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
|
2022-09-24 19:17:00 +02:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************************* Headers ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2022-09-24 19:17:00 +02:00
|
|
|
|
#include "swad_alert.h"
|
|
|
|
|
#include "swad_forum.h"
|
|
|
|
|
#include "swad_forum_database.h"
|
2022-09-28 15:19:17 +02:00
|
|
|
|
#include "swad_forum_resource.h"
|
2022-09-24 19:17:00 +02:00
|
|
|
|
#include "swad_global.h"
|
2023-04-06 12:39:13 +02:00
|
|
|
|
#include "swad_parameter_code.h"
|
2023-03-27 12:18:14 +02:00
|
|
|
|
#include "swad_resource_database.h"
|
2022-09-24 19:17:00 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Get link to thread *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void ForRsc_GetLinkToThread (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Link_to_resource_X_copied_into_clipboard;
|
2023-04-18 22:13:37 +02:00
|
|
|
|
extern const char *Txt_Course_forum;
|
2022-09-24 19:17:00 +02:00
|
|
|
|
struct For_Forums Forums;
|
2023-04-18 22:13:37 +02:00
|
|
|
|
struct For_Thread Thr;
|
2022-09-24 19:17:00 +02:00
|
|
|
|
|
|
|
|
|
/***** Reset forum *****/
|
|
|
|
|
For_ResetForums (&Forums);
|
|
|
|
|
|
|
|
|
|
/***** Get parameters related to forums *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
For_GetParsForums (&Forums);
|
2023-04-18 22:13:37 +02:00
|
|
|
|
Thr.ThrCod = Forums.Thread.Current;
|
2022-09-24 19:17:00 +02:00
|
|
|
|
|
|
|
|
|
/***** Get thread subject *****/
|
2023-04-18 22:13:37 +02:00
|
|
|
|
if (Thr.ThrCod > 0)
|
|
|
|
|
For_GetThreadData (&Thr);
|
2022-09-24 19:17:00 +02:00
|
|
|
|
|
|
|
|
|
/***** Copy link to thread into resource clipboard *****/
|
2023-04-18 22:13:37 +02:00
|
|
|
|
Rsc_DB_CopyToClipboard (Rsc_FORUM_THREAD,Thr.ThrCod);
|
2022-09-24 19:17:00 +02:00
|
|
|
|
|
|
|
|
|
/***** Write sucess message *****/
|
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Link_to_resource_X_copied_into_clipboard,
|
2023-04-18 22:13:37 +02:00
|
|
|
|
Thr.ThrCod > 0 ? Thr.Subject :
|
|
|
|
|
Txt_Course_forum);
|
2022-09-24 19:17:00 +02:00
|
|
|
|
|
|
|
|
|
/***** Show forum list again *****/
|
|
|
|
|
For_ShowForumList (&Forums);
|
|
|
|
|
|
|
|
|
|
/***** Show threads again *****/
|
|
|
|
|
For_ShowForumThreadsHighlightingOneThread (&Forums,Ale_SUCCESS,NULL);
|
|
|
|
|
|
|
|
|
|
/***** Show the posts of that thread *****/
|
|
|
|
|
For_ShowPostsOfAThread (&Forums,Ale_SUCCESS,NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-06 19:59:33 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Build/free anchor string given a thread code *****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void ForRsc_SetAnchorStr (long ThrCod,char **Anchor)
|
|
|
|
|
{
|
|
|
|
|
*Anchor = (ThrCod > 0) ? For_FORUM_POSTS_SECTION_ID :
|
|
|
|
|
For_FORUM_THREADS_SECTION_ID;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ForRsc_FreeAnchorStr (char **Anchor)
|
|
|
|
|
{
|
|
|
|
|
*Anchor = NULL;
|
|
|
|
|
}
|