2014-12-01 23:55:08 +01:00
|
|
|
|
// swad_link.c: institutional links
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-12-29 12:39:00 +01:00
|
|
|
|
#include <stddef.h> // For NULL
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
2020-04-14 17:15:17 +02:00
|
|
|
|
#include "swad_banner.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_constant.h"
|
|
|
|
|
#include "swad_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.h"
|
2019-10-23 19:05:05 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2018-12-08 16:43:13 +01:00
|
|
|
|
#include "swad_language.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_link.h"
|
2021-09-22 13:20:57 +02:00
|
|
|
|
#include "swad_link_database.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_parameter.h"
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private variables *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-11-28 00:49:23 +01:00
|
|
|
|
static struct Lnk_Link *Lnk_EditingLnk = NULL; // Static variable to keep the link being edited
|
2019-04-09 15:21:23 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
static void Lnk_PutIconsListingLinks (__attribute__((unused)) void *Args);
|
2016-03-16 22:40:35 +01:00
|
|
|
|
static void Lnk_PutIconToEditLinks (void);
|
2021-12-28 23:02:03 +01:00
|
|
|
|
static void Lnk_WriteListOfLinks (const char *Class);
|
2015-07-24 13:51:29 +02:00
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
static void Lnk_EditLinksInternal (void);
|
2020-04-08 19:42:03 +02:00
|
|
|
|
static void Lnk_PutIconsEditingLinks (__attribute__((unused)) void *Args);
|
2018-11-16 00:24:44 +01:00
|
|
|
|
|
2021-11-28 00:49:23 +01:00
|
|
|
|
static void Lnk_GetDataOfLink (MYSQL_RES *mysql_res,struct Lnk_Link *Lnk);
|
2021-09-22 13:20:57 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Lnk_ListLinksForEdition (void);
|
2020-10-13 22:34:31 +02:00
|
|
|
|
static void Lnk_PutParamLnkCod (void *LnkCod);
|
2017-03-09 11:16:17 +01:00
|
|
|
|
|
2016-10-28 10:03:37 +02:00
|
|
|
|
static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName);
|
2017-03-09 11:16:17 +01:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Lnk_PutFormToCreateLink (void);
|
|
|
|
|
static void Lnk_PutHeadLinks (void);
|
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
static void Lnk_EditingLinkConstructor (void);
|
|
|
|
|
static void Lnk_EditingLinkDestructor (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/****************************** List all links *******************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_SeeLinks (void)
|
|
|
|
|
{
|
2016-11-28 10:14:19 +01:00
|
|
|
|
extern const char *Hlp_SYSTEM_Links;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_Links;
|
2017-03-26 23:16:51 +02:00
|
|
|
|
extern const char *Txt_No_links;
|
2017-03-27 13:38:10 +02:00
|
|
|
|
extern const char *Txt_New_link;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get list of links *****/
|
|
|
|
|
Lnk_GetListLinks ();
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Links,
|
2020-04-08 19:42:03 +02:00
|
|
|
|
Lnk_PutIconsListingLinks,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_SYSTEM_Links,Box_NOT_CLOSABLE);
|
2017-03-26 23:16:51 +02:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Write all links *****/
|
|
|
|
|
if (Gbl.Links.Num) // There are links
|
2021-12-28 23:02:03 +01:00
|
|
|
|
Lnk_WriteListOfLinks ("class=\"LIST_LEFT\"");
|
2021-09-22 13:20:57 +02:00
|
|
|
|
else // No links created
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_links);
|
2017-03-26 23:16:51 +02:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Button to create link *****/
|
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
|
|
|
|
|
{
|
|
|
|
|
Frm_BeginForm (ActEdiLnk);
|
|
|
|
|
Btn_PutConfirmButton (Txt_New_link);
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
}
|
2015-07-24 13:51:29 +02:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2017-03-26 23:16:51 +02:00
|
|
|
|
|
2015-07-24 13:51:29 +02:00
|
|
|
|
/***** Free list of links *****/
|
|
|
|
|
Lnk_FreeListLinks ();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-16 00:24:44 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Put contextual icons in list of links *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
static void Lnk_PutIconsListingLinks (__attribute__((unused)) void *Args)
|
2018-11-16 00:24:44 +01:00
|
|
|
|
{
|
2020-04-08 19:42:03 +02:00
|
|
|
|
/***** Put icon to edit links *****/
|
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
|
|
|
|
|
Lnk_PutIconToEditLinks ();
|
2018-11-16 00:24:44 +01:00
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
/***** Put icon to view banners *****/
|
|
|
|
|
Ban_PutIconToViewBanners ();
|
2018-11-16 00:24:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 22:40:35 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Put icon to edit links ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_PutIconToEditLinks (void)
|
|
|
|
|
{
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiLnk,NULL,
|
|
|
|
|
NULL,NULL);
|
2016-03-16 22:40:35 +01:00
|
|
|
|
}
|
2015-07-24 13:51:29 +02:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************** Write menu with some institutional links ******************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_WriteMenuWithInstitutionalLinks (void)
|
|
|
|
|
{
|
2017-03-24 21:29:13 +01:00
|
|
|
|
extern const char *Txt_Links;
|
|
|
|
|
|
2015-07-24 13:51:29 +02:00
|
|
|
|
/***** Get list of links *****/
|
|
|
|
|
Lnk_GetListLinks ();
|
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Write all links *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Links.Num)
|
|
|
|
|
{
|
2021-12-28 23:02:03 +01:00
|
|
|
|
HTM_DIV_Begin ("id=\"institutional_links\" class=\"INS_LNK_%s\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2017-03-24 21:29:13 +01:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Frm_BeginForm (ActSeeLnk);
|
2022-04-01 01:06:44 +02:00
|
|
|
|
HTM_BUTTON_Submit_Begin (Txt_Links,"class=\"BT_LINK\"");
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_TxtF ("%s",Txt_Links);
|
|
|
|
|
HTM_BUTTON_End ();
|
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
|
2021-12-28 23:02:03 +01:00
|
|
|
|
Lnk_WriteListOfLinks (NULL);
|
2017-03-24 21:29:13 +01:00
|
|
|
|
|
2019-10-23 20:07:56 +02:00
|
|
|
|
HTM_DIV_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free list of links *****/
|
|
|
|
|
Lnk_FreeListLinks ();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-24 13:51:29 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** Write list of links *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-12-28 23:02:03 +01:00
|
|
|
|
static void Lnk_WriteListOfLinks (const char *Class)
|
2015-07-24 13:51:29 +02:00
|
|
|
|
{
|
|
|
|
|
unsigned NumLnk;
|
|
|
|
|
|
|
|
|
|
/***** List start *****/
|
2021-12-28 23:02:03 +01:00
|
|
|
|
HTM_UL_Begin (Class);
|
2015-07-24 13:51:29 +02:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Write all links *****/
|
|
|
|
|
for (NumLnk = 0;
|
|
|
|
|
NumLnk < Gbl.Links.Num;
|
|
|
|
|
NumLnk++)
|
|
|
|
|
{
|
|
|
|
|
/* Write data of this link */
|
2021-12-28 23:02:03 +01:00
|
|
|
|
HTM_LI_Begin ("class=\"ICO_HIGHLIGHT INS_LNK\"");
|
|
|
|
|
HTM_A_Begin ("href=\"%s\" title=\"%s\""
|
|
|
|
|
" class=\"INS_LNK_%s\" target=\"_blank\"",
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Gbl.Links.Lst[NumLnk].WWW,
|
2021-12-28 23:02:03 +01:00
|
|
|
|
Gbl.Links.Lst[NumLnk].FullName,
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_Txt (Gbl.Links.Lst[NumLnk].ShrtName);
|
|
|
|
|
HTM_A_End ();
|
|
|
|
|
HTM_LI_End ();
|
|
|
|
|
}
|
2015-07-24 13:51:29 +02:00
|
|
|
|
|
|
|
|
|
/***** List end *****/
|
2019-10-26 02:19:42 +02:00
|
|
|
|
HTM_UL_End ();
|
2015-07-24 13:51:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Put forms to edit links **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_EditLinks (void)
|
2019-04-09 15:21:23 +02:00
|
|
|
|
{
|
|
|
|
|
/***** Link constructor *****/
|
|
|
|
|
Lnk_EditingLinkConstructor ();
|
|
|
|
|
|
|
|
|
|
/***** Edit links *****/
|
|
|
|
|
Lnk_EditLinksInternal ();
|
|
|
|
|
|
|
|
|
|
/***** Link destructor *****/
|
|
|
|
|
Lnk_EditingLinkDestructor ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Lnk_EditLinksInternal (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2017-06-03 17:47:07 +02:00
|
|
|
|
extern const char *Hlp_SYSTEM_Links_edit;
|
|
|
|
|
extern const char *Txt_Links;
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Get list of links *****/
|
|
|
|
|
Lnk_GetListLinks ();
|
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Box_BoxBegin (NULL,Txt_Links,
|
2020-04-08 19:42:03 +02:00
|
|
|
|
Lnk_PutIconsEditingLinks,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_SYSTEM_Links_edit,Box_NOT_CLOSABLE);
|
2017-06-03 17:47:07 +02:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Put a form to create a new link *****/
|
|
|
|
|
Lnk_PutFormToCreateLink ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Forms to edit current links *****/
|
|
|
|
|
if (Gbl.Links.Num)
|
|
|
|
|
Lnk_ListLinksForEdition ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2017-06-03 17:47:07 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Free list of links *****/
|
|
|
|
|
Lnk_FreeListLinks ();
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-16 00:24:44 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Put contextual icons to view links *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
static void Lnk_PutIconsEditingLinks (__attribute__((unused)) void *Args)
|
2018-11-16 00:24:44 +01:00
|
|
|
|
{
|
2020-04-08 19:42:03 +02:00
|
|
|
|
/***** Put icon to view links *****/
|
|
|
|
|
Lnk_PutIconToViewLinks ();
|
2018-11-16 00:24:44 +01:00
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
/***** Put icon to view banners *****/
|
|
|
|
|
Ban_PutIconToViewBanners ();
|
2018-11-16 00:24:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Put icon to view links ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_PutIconToViewLinks (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Links;
|
|
|
|
|
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActSeeLnk,NULL,
|
|
|
|
|
NULL,NULL,
|
2021-12-22 00:20:06 +01:00
|
|
|
|
"link.svg",Ico_BLACK,
|
2019-01-12 03:00:59 +01:00
|
|
|
|
Txt_Links);
|
2018-11-16 00:24:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/****************************** List all links *******************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_GetListLinks (void)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
unsigned NumLnk;
|
|
|
|
|
|
|
|
|
|
if (Gbl.DB.DatabaseIsOpen)
|
|
|
|
|
{
|
|
|
|
|
/***** Get institutional links from database *****/
|
2021-09-22 13:20:57 +02:00
|
|
|
|
if ((Gbl.Links.Num = Lnk_DB_GetLinks (&mysql_res))) // Links found...
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** Create list with places *****/
|
2021-04-16 13:51:12 +02:00
|
|
|
|
if ((Gbl.Links.Lst = calloc ((size_t) Gbl.Links.Num,
|
|
|
|
|
sizeof (*Gbl.Links.Lst))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the links *****/
|
|
|
|
|
for (NumLnk = 0;
|
|
|
|
|
NumLnk < Gbl.Links.Num;
|
|
|
|
|
NumLnk++)
|
|
|
|
|
/* Get next link */
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Lnk_GetDataOfLink (mysql_res,&(Gbl.Links.Lst[NumLnk]));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Get link full name *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-11-28 00:49:23 +01:00
|
|
|
|
void Lnk_GetDataOfLinkByCod (struct Lnk_Link *Lnk)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
|
|
|
|
|
/***** Clear data *****/
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Lnk->ShrtName[0] =
|
|
|
|
|
Lnk->FullName[0] =
|
|
|
|
|
Lnk->WWW[0] = '\0';
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if link code is correct *****/
|
|
|
|
|
if (Lnk->LnkCod > 0)
|
|
|
|
|
{
|
|
|
|
|
/***** Get data of an institutional link from database *****/
|
2021-09-22 13:20:57 +02:00
|
|
|
|
if (Lnk_DB_GetDataOfLinkByCod (&mysql_res,Lnk->LnkCod)) // Link found...
|
|
|
|
|
Lnk_GetDataOfLink (mysql_res,Lnk);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Get data of link *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2021-11-28 00:49:23 +01:00
|
|
|
|
static void Lnk_GetDataOfLink (MYSQL_RES *mysql_res,struct Lnk_Link *Lnk)
|
2021-09-22 13:20:57 +02:00
|
|
|
|
{
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
|
|
|
|
|
/***** Get row *****/
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
2021-10-14 17:11:23 +02:00
|
|
|
|
/*
|
|
|
|
|
row[0] LnkCod
|
|
|
|
|
row[1] ShortName
|
|
|
|
|
row[2] FullName
|
|
|
|
|
row[3] WWW
|
|
|
|
|
*/
|
|
|
|
|
/***** Get the short name (row[1]),
|
|
|
|
|
the full name (row[2])
|
|
|
|
|
and the URL (row[3]) of the link *****/
|
|
|
|
|
Str_Copy (Lnk->ShrtName,row[1],sizeof (Lnk->ShrtName) - 1);
|
|
|
|
|
Str_Copy (Lnk->FullName,row[2],sizeof (Lnk->FullName) - 1);
|
|
|
|
|
Str_Copy (Lnk->WWW ,row[3],sizeof (Lnk->WWW ) - 1);
|
2021-09-22 13:20:57 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Free list of links *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_FreeListLinks (void)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Links.Lst)
|
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of links *****/
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Gbl.Links.Lst);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Gbl.Links.Lst = NULL;
|
|
|
|
|
Gbl.Links.Num = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/****************************** List all links *******************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_ListLinksForEdition (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned NumLnk;
|
2021-11-28 00:49:23 +01:00
|
|
|
|
struct Lnk_Link *Lnk;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_BeginWidePadding (2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Table head *****/
|
|
|
|
|
Lnk_PutHeadLinks ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-10-30 13:28:48 +02:00
|
|
|
|
/***** Write all links *****/
|
2021-09-22 13:20:57 +02:00
|
|
|
|
for (NumLnk = 0;
|
|
|
|
|
NumLnk < Gbl.Links.Num;
|
|
|
|
|
NumLnk++)
|
|
|
|
|
{
|
|
|
|
|
Lnk = &Gbl.Links.Lst[NumLnk];
|
|
|
|
|
|
|
|
|
|
HTM_TR_Begin (NULL);
|
|
|
|
|
|
|
|
|
|
/* Put icon to remove link */
|
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
|
|
|
|
Ico_PutContextualIconToRemove (ActRemLnk,NULL,
|
|
|
|
|
Lnk_PutParamLnkCod,&Lnk->LnkCod);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Link code */
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_TD_Begin ("class=\"RM DAT_%s\"",The_GetSuffix ());
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_Long (Lnk->LnkCod);
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Link short name */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActRenLnkSho);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Lnk_PutParamLnkCod (&Lnk->LnkCod);
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_INPUT_TEXT ("ShortName",Lnk_MAX_CHARS_LINK_SHRT_NAME,Lnk->ShrtName,
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
2022-03-30 00:46:18 +02:00
|
|
|
|
"class=\"INPUT_SHORT_NAME INPUT_%s\""
|
2021-12-20 09:24:49 +01:00
|
|
|
|
" required=\"required\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Link full name */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActRenLnkFul);
|
2021-12-01 01:43:13 +01:00
|
|
|
|
Lnk_PutParamLnkCod (&Lnk->LnkCod);
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_INPUT_TEXT ("FullName",Lnk_MAX_CHARS_LINK_FULL_NAME,Lnk->FullName,
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
2022-03-30 00:46:18 +02:00
|
|
|
|
"class=\"INPUT_FULL_NAME INPUT_%s\""
|
2021-12-20 09:24:49 +01:00
|
|
|
|
" required=\"required\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
/* Link WWW */
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
Frm_BeginForm (ActChgLnkWWW);
|
|
|
|
|
Lnk_PutParamLnkCod (&Lnk->LnkCod);
|
|
|
|
|
HTM_INPUT_URL ("WWW",Lnk->WWW,HTM_SUBMIT_ON_CHANGE,
|
2022-03-30 00:46:18 +02:00
|
|
|
|
"class=\"INPUT_WWW_NARROW INPUT_%s\""
|
2021-12-20 09:24:49 +01:00
|
|
|
|
" required=\"required\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Frm_EndForm ();
|
|
|
|
|
HTM_TD_End ();
|
|
|
|
|
|
|
|
|
|
HTM_TR_End ();
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-03 17:47:07 +02:00
|
|
|
|
/***** End table *****/
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TABLE_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write parameter with code of link **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-10-13 22:34:31 +02:00
|
|
|
|
static void Lnk_PutParamLnkCod (void *LnkCod)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2020-10-13 22:34:31 +02:00
|
|
|
|
if (LnkCod)
|
|
|
|
|
Par_PutHiddenParamLong (NULL,"LnkCod",*((long *) LnkCod));
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Get parameter with code of link ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
long Lnk_GetParamLnkCod (void)
|
|
|
|
|
{
|
2017-01-28 20:32:50 +01:00
|
|
|
|
/***** Get code of link *****/
|
|
|
|
|
return Par_GetParToLong ("LnkCod");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Remove a link *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_RemoveLink (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Link_X_removed;
|
2019-04-09 15:21:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Link constructor *****/
|
|
|
|
|
Lnk_EditingLinkConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get link code *****/
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongLinkExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get data of the link from database *****/
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Lnk_GetDataOfLinkByCod (Lnk_EditingLnk);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove link *****/
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Lnk_DB_RemoveLink (Lnk_EditingLnk->LnkCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_Link_X_removed,
|
|
|
|
|
Lnk_EditingLnk->ShrtName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Change the short name of a link ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_RenameLinkShort (void)
|
|
|
|
|
{
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/***** Link constructor *****/
|
|
|
|
|
Lnk_EditingLinkConstructor ();
|
|
|
|
|
|
|
|
|
|
/***** Rename link *****/
|
2016-10-28 10:03:37 +02:00
|
|
|
|
Lnk_RenameLink (Cns_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Change the full name of a link ************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_RenameLinkFull (void)
|
|
|
|
|
{
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/***** Link constructor *****/
|
|
|
|
|
Lnk_EditingLinkConstructor ();
|
|
|
|
|
|
|
|
|
|
/***** Rename link *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lnk_RenameLink (Cns_FULL_NAME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************ Change the name of a link **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2016-10-28 10:03:37 +02:00
|
|
|
|
static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_link_X_already_exists;
|
|
|
|
|
extern const char *Txt_The_link_X_has_been_renamed_as_Y;
|
|
|
|
|
extern const char *Txt_The_name_of_the_link_X_has_not_changed;
|
|
|
|
|
const char *ParamName = NULL; // Initialized to avoid warning
|
|
|
|
|
const char *FieldName = NULL; // Initialized to avoid warning
|
2017-03-07 19:55:29 +01:00
|
|
|
|
unsigned MaxBytes = 0; // Initialized to avoid warning
|
2014-12-01 23:55:08 +01:00
|
|
|
|
char *CurrentLnkName = NULL; // Initialized to avoid warning
|
2017-03-07 19:55:29 +01:00
|
|
|
|
char NewLnkName[Lnk_MAX_BYTES_LINK_FULL_NAME + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-28 10:03:37 +02:00
|
|
|
|
switch (ShrtOrFullName)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2016-10-28 10:03:37 +02:00
|
|
|
|
case Cns_SHRT_NAME:
|
2014-12-01 23:55:08 +01:00
|
|
|
|
ParamName = "ShortName";
|
|
|
|
|
FieldName = "ShortName";
|
2017-03-07 19:55:29 +01:00
|
|
|
|
MaxBytes = Lnk_MAX_BYTES_LINK_SHRT_NAME;
|
2019-04-09 15:21:23 +02:00
|
|
|
|
CurrentLnkName = Lnk_EditingLnk->ShrtName;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
case Cns_FULL_NAME:
|
|
|
|
|
ParamName = "FullName";
|
|
|
|
|
FieldName = "FullName";
|
2017-03-07 19:55:29 +01:00
|
|
|
|
MaxBytes = Lnk_MAX_BYTES_LINK_FULL_NAME;
|
2019-04-09 15:21:23 +02:00
|
|
|
|
CurrentLnkName = Lnk_EditingLnk->FullName;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the link */
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongLinkExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new name for the link */
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Par_GetParToText (ParamName,NewLnkName,MaxBytes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/***** Get link data from the database *****/
|
|
|
|
|
Lnk_GetDataOfLinkByCod (Lnk_EditingLnk);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Check if new name is empty *****/
|
2019-12-20 00:30:54 +01:00
|
|
|
|
if (NewLnkName[0])
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
2019-01-02 15:10:51 +01:00
|
|
|
|
/***** Check if old and new names are the same
|
|
|
|
|
(this happens when return is pressed without changes) *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (strcmp (CurrentLnkName,NewLnkName)) // Different names
|
|
|
|
|
{
|
|
|
|
|
/***** If link was in database... *****/
|
2021-09-22 13:20:57 +02:00
|
|
|
|
if (Lnk_DB_CheckIfLinkNameExists (ParamName,NewLnkName,Lnk_EditingLnk->LnkCod))
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_The_link_X_already_exists,
|
|
|
|
|
NewLnkName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old name by new name */
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Lnk_DB_UpdateLnkName (Lnk_EditingLnk->LnkCod,FieldName,NewLnkName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-03-09 11:16:17 +01:00
|
|
|
|
/* Write message to show the change made */
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_link_X_has_been_renamed_as_Y,
|
|
|
|
|
CurrentLnkName,NewLnkName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // The same name
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Ale_CreateAlert (Ale_INFO,NULL,
|
|
|
|
|
Txt_The_name_of_the_link_X_has_not_changed,
|
|
|
|
|
CurrentLnkName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
2019-12-20 00:30:54 +01:00
|
|
|
|
else
|
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/***** Update name *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (CurrentLnkName,NewLnkName,MaxBytes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************** Change the WWW of an institutional link ********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_ChangeLinkWWW (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_new_web_address_is_X;
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char NewWWW[Cns_MAX_BYTES_WWW + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/***** Link constructor *****/
|
|
|
|
|
Lnk_EditingLinkConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the link */
|
2021-04-25 20:36:48 +02:00
|
|
|
|
if ((Lnk_EditingLnk->LnkCod = Lnk_GetParamLnkCod ()) <= 0)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongLinkExit ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the new WWW for the link */
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/***** Get link data from the database *****/
|
|
|
|
|
Lnk_GetDataOfLinkByCod (Lnk_EditingLnk);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Check if new WWW is empty *****/
|
|
|
|
|
if (NewWWW[0])
|
|
|
|
|
{
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/***** Update the table changing old WWW by new WWW *****/
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Lnk_DB_UpdateLnkWWW (Lnk_EditingLnk->LnkCod,NewWWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/***** Message to show the change made *****/
|
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_The_new_web_address_is_X,
|
|
|
|
|
NewWWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-12-20 00:30:54 +01:00
|
|
|
|
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/***** Update web *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
Str_Copy (Lnk_EditingLnk->WWW,NewWWW,sizeof (Lnk_EditingLnk->WWW) - 1);
|
2019-04-09 15:21:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********** Show alerts after changing a link and continue editing ***********/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_ContEditAfterChgLnk (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Write message to show the change made *****/
|
|
|
|
|
Ale_ShowAlerts (NULL);
|
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
|
|
|
|
Lnk_EditLinksInternal ();
|
|
|
|
|
|
|
|
|
|
/***** Link destructor *****/
|
|
|
|
|
Lnk_EditingLinkDestructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Put a form to create a new link ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_PutFormToCreateLink (void)
|
|
|
|
|
{
|
2016-11-28 10:14:19 +01:00
|
|
|
|
extern const char *Hlp_SYSTEM_Links_edit;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_New_link;
|
|
|
|
|
extern const char *Txt_Create_link;
|
|
|
|
|
|
2019-10-20 22:00:28 +02:00
|
|
|
|
/***** Begin form *****/
|
2021-03-02 00:54:26 +01:00
|
|
|
|
Frm_BeginForm (ActNewLnk);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Begin box and table *****/
|
|
|
|
|
Box_BoxTableBegin (NULL,Txt_New_link,
|
|
|
|
|
NULL,NULL,
|
|
|
|
|
Hlp_SYSTEM_Links_edit,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Lnk_PutHeadLinks ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2019-10-05 13:27:58 +02:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Link code *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"BM\"");
|
|
|
|
|
HTM_TD_End ();
|
2019-10-07 17:36:41 +02:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_TD_Empty (1);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Link short name *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_INPUT_TEXT ("ShortName",Lnk_MAX_CHARS_LINK_SHRT_NAME,Lnk_EditingLnk->ShrtName,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
2022-03-30 00:46:18 +02:00
|
|
|
|
"class=\"INPUT_SHORT_NAME INPUT_%s\""
|
2021-12-20 09:24:49 +01:00
|
|
|
|
" required=\"required\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Link full name *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_INPUT_TEXT ("FullName",Lnk_MAX_CHARS_LINK_FULL_NAME,Lnk_EditingLnk->FullName,
|
|
|
|
|
HTM_DONT_SUBMIT_ON_CHANGE,
|
2022-03-30 00:46:18 +02:00
|
|
|
|
"class=\"INPUT_FULL_NAME INPUT_%s\""
|
2021-12-20 09:24:49 +01:00
|
|
|
|
" required=\"required\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_TD_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** Link WWW *****/
|
|
|
|
|
HTM_TD_Begin ("class=\"CM\"");
|
|
|
|
|
HTM_INPUT_URL ("WWW",Lnk_EditingLnk->WWW,HTM_DONT_SUBMIT_ON_CHANGE,
|
2022-03-30 00:46:18 +02:00
|
|
|
|
"class=\"INPUT_WWW_NARROW INPUT_%s\""
|
2021-12-20 09:24:49 +01:00
|
|
|
|
" required=\"required\"",
|
2022-04-05 01:00:24 +02:00
|
|
|
|
The_GetSuffix ());
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_TD_End ();
|
2019-10-05 13:27:58 +02:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2021-09-22 13:20:57 +02:00
|
|
|
|
/***** End table, send button and end box *****/
|
|
|
|
|
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_link);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write header with fields of a link *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_PutHeadLinks (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Code;
|
2015-02-04 20:03:23 +01:00
|
|
|
|
extern const char *Txt_Short_name;
|
|
|
|
|
extern const char *Txt_Full_name;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_WWW;
|
|
|
|
|
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_Begin (NULL);
|
2022-01-02 15:17:30 +01:00
|
|
|
|
HTM_TH_Span (NULL ,HTM_HEAD_CENTER,1,1,"BT");
|
|
|
|
|
HTM_TH (Txt_Code ,HTM_HEAD_RIGHT );
|
|
|
|
|
HTM_TH (Txt_Short_name,HTM_HEAD_LEFT );
|
|
|
|
|
HTM_TH (Txt_Full_name ,HTM_HEAD_LEFT );
|
|
|
|
|
HTM_TH (Txt_WWW ,HTM_HEAD_LEFT );
|
2019-10-23 19:05:05 +02:00
|
|
|
|
HTM_TR_End ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Receive form to create a new link ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-05-05 21:49:00 +02:00
|
|
|
|
void Lnk_ReceiveFormNewLink (void)
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_link_X_already_exists;
|
|
|
|
|
extern const char *Txt_You_must_specify_the_URL_of_the_new_link;
|
2019-04-09 15:21:23 +02:00
|
|
|
|
extern const char *Txt_Created_new_link_X;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_link;
|
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/***** Link constructor *****/
|
|
|
|
|
Lnk_EditingLinkConstructor ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get link short name */
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Par_GetParToText ("ShortName",Lnk_EditingLnk->ShrtName,Lnk_MAX_BYTES_LINK_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get link full name */
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Par_GetParToText ("FullName",Lnk_EditingLnk->FullName,Lnk_MAX_BYTES_LINK_FULL_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get link URL */
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Par_GetParToText ("WWW",Lnk_EditingLnk->WWW,Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
if (Lnk_EditingLnk->ShrtName[0] &&
|
|
|
|
|
Lnk_EditingLnk->FullName[0]) // If there's a link name
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** If name of link was in database... *****/
|
2021-09-22 13:20:57 +02:00
|
|
|
|
if (Lnk_DB_CheckIfLinkNameExists ("ShortName",Lnk_EditingLnk->ShrtName,-1L))
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_The_link_X_already_exists,
|
|
|
|
|
Lnk_EditingLnk->ShrtName);
|
2021-09-22 13:20:57 +02:00
|
|
|
|
else if (Lnk_DB_CheckIfLinkNameExists ("FullName",Lnk_EditingLnk->FullName,-1L))
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_The_link_X_already_exists,
|
|
|
|
|
Lnk_EditingLnk->FullName);
|
|
|
|
|
else if (!Lnk_EditingLnk->WWW[0])
|
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_You_must_specify_the_URL_of_the_new_link);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else // Add new link to database
|
2019-04-09 15:21:23 +02:00
|
|
|
|
{
|
2021-09-22 13:20:57 +02:00
|
|
|
|
Lnk_DB_CreateLink (Lnk_EditingLnk);
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Ale_CreateAlert (Ale_SUCCESS,NULL,
|
|
|
|
|
Txt_Created_new_link_X,
|
|
|
|
|
Lnk_EditingLnk->ShrtName);
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else // If there is not a link name
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Ale_CreateAlert (Ale_WARNING,NULL,
|
|
|
|
|
Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_link);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************* Place constructor/destructor **********************/
|
|
|
|
|
/*****************************************************************************/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2019-04-09 15:21:23 +02:00
|
|
|
|
static void Lnk_EditingLinkConstructor (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Pointer must be NULL *****/
|
|
|
|
|
if (Lnk_EditingLnk != NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_WrongLinkExit ();
|
2019-04-09 15:21:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Allocate memory for link *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
if ((Lnk_EditingLnk = malloc (sizeof (*Lnk_EditingLnk))) == NULL)
|
2021-04-26 15:27:27 +02:00
|
|
|
|
Err_NotEnoughMemoryExit ();
|
2019-04-09 15:21:23 +02:00
|
|
|
|
|
|
|
|
|
/***** Reset link *****/
|
|
|
|
|
Lnk_EditingLnk->LnkCod = -1L;
|
|
|
|
|
Lnk_EditingLnk->ShrtName[0] = '\0';
|
|
|
|
|
Lnk_EditingLnk->FullName[0] = '\0';
|
|
|
|
|
Lnk_EditingLnk->WWW[0] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Lnk_EditingLinkDestructor (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Free memory used for link *****/
|
|
|
|
|
if (Lnk_EditingLnk != NULL)
|
|
|
|
|
{
|
2019-11-06 19:45:20 +01:00
|
|
|
|
free (Lnk_EditingLnk);
|
2019-04-09 15:21:23 +02:00
|
|
|
|
Lnk_EditingLnk = NULL;
|
|
|
|
|
}
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|