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.
|
2019-01-07 21:52:19 +01:00
|
|
|
|
Copyright (C) 1999-2019 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 ***********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include <linux/stddef.h> // For NULL
|
|
|
|
|
#include <stdlib.h> // For calloc
|
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
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"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
#include "swad_global.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"
|
|
|
|
|
#include "swad_parameter.h"
|
2017-06-11 20:09:59 +02:00
|
|
|
|
#include "swad_table.h"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private constants *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************************* Private types *******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private variables *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/***************************** Private prototypes ****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2018-11-16 00:24:44 +01:00
|
|
|
|
static void Lnk_PutIconsEditingLinks (void);
|
|
|
|
|
|
|
|
|
|
static void Lnk_PutIconsListingLinks (void);
|
2016-03-16 22:40:35 +01:00
|
|
|
|
static void Lnk_PutIconToEditLinks (void);
|
2015-07-24 13:51:29 +02:00
|
|
|
|
static void Lnk_WriteListOfLinks (void);
|
|
|
|
|
|
2018-11-16 00:24:44 +01:00
|
|
|
|
static void Lnk_PutIconsEditingLinks (void);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Lnk_ListLinksForEdition (void);
|
|
|
|
|
static void Lnk_PutParamLnkCod (long 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);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static bool Lnk_CheckIfLinkNameExists (const char *FieldName,const char *Name,long LnkCod);
|
2017-03-09 11:16:17 +01:00
|
|
|
|
static void Lnk_UpdateLnkNameDB (long LnkCod,const char *FieldName,const char *NewLnkName);
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
static void Lnk_PutFormToCreateLink (void);
|
|
|
|
|
static void Lnk_PutHeadLinks (void);
|
|
|
|
|
static void Lnk_CreateLink (struct Link *Lnk);
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** List all the links ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
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 ();
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box *****/
|
2018-11-16 00:24:44 +01:00
|
|
|
|
Box_StartBox (NULL,Txt_Links,Lnk_PutIconsListingLinks,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_SYSTEM_Links,Box_NOT_CLOSABLE);
|
2017-03-26 23:16:51 +02:00
|
|
|
|
|
2017-03-27 10:13:34 +02:00
|
|
|
|
/***** Write all links *****/
|
2017-03-26 23:16:51 +02:00
|
|
|
|
if (Gbl.Links.Num) // There are links
|
2015-07-24 13:51:29 +02:00
|
|
|
|
Lnk_WriteListOfLinks ();
|
2017-03-26 23:16:51 +02:00
|
|
|
|
else // No links created
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_No_links);
|
2017-03-26 23:16:51 +02:00
|
|
|
|
|
|
|
|
|
/***** Button to create link *****/
|
2017-06-04 18:18:54 +02:00
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
|
2017-03-26 23:16:51 +02:00
|
|
|
|
{
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActEdiLnk);
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Btn_PutConfirmButton (Txt_New_link);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-07-24 13:51:29 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
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 *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_PutIconsListingLinks (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Put icon to edit links *****/
|
|
|
|
|
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
|
|
|
|
|
Lnk_PutIconToEditLinks ();
|
|
|
|
|
|
|
|
|
|
/***** Put icon to view banners *****/
|
|
|
|
|
Ban_PutIconToViewBanners ();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-16 22:40:35 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Put icon to edit links ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_PutIconToEditLinks (void)
|
|
|
|
|
{
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutContextualIconToEdit (ActEdiLnk,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 ();
|
|
|
|
|
|
|
|
|
|
/***** Write all the links *****/
|
2014-12-01 23:55:08 +01:00
|
|
|
|
if (Gbl.Links.Num)
|
|
|
|
|
{
|
2017-03-24 21:29:13 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<div id=\"institutional_links\">");
|
|
|
|
|
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActSeeLnk);
|
|
|
|
|
Frm_LinkFormSubmit (Txt_Links,NULL,NULL);
|
2017-03-24 21:29:13 +01:00
|
|
|
|
fprintf (Gbl.F.Out," %s"
|
|
|
|
|
"</a>",
|
|
|
|
|
Txt_Links);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2017-03-24 21:29:13 +01:00
|
|
|
|
|
2015-07-24 13:51:29 +02:00
|
|
|
|
Lnk_WriteListOfLinks ();
|
2017-03-24 21:29:13 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</div>");
|
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 *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_WriteListOfLinks (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned NumLnk;
|
|
|
|
|
|
|
|
|
|
/***** List start *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"<ul class=\"LIST_LEFT\">");
|
|
|
|
|
|
|
|
|
|
/***** Write all links *****/
|
|
|
|
|
for (NumLnk = 0;
|
|
|
|
|
NumLnk < Gbl.Links.Num;
|
|
|
|
|
NumLnk++)
|
|
|
|
|
/* Write data of this link */
|
|
|
|
|
fprintf (Gbl.F.Out,"<li class=\"INS_LNK\">"
|
|
|
|
|
"<a href=\"%s\" title=\"%s\" class=\"INS_LNK\""
|
|
|
|
|
" target=\"_blank\">"
|
|
|
|
|
"%s"
|
|
|
|
|
"</a>"
|
|
|
|
|
"</li>",
|
|
|
|
|
Gbl.Links.Lst[NumLnk].WWW,
|
|
|
|
|
Gbl.Links.Lst[NumLnk].FullName,
|
2016-10-28 10:03:37 +02:00
|
|
|
|
Gbl.Links.Lst[NumLnk].ShrtName);
|
2015-07-24 13:51:29 +02:00
|
|
|
|
|
|
|
|
|
/***** List end *****/
|
|
|
|
|
fprintf (Gbl.F.Out,"</ul>");
|
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Put forms to edit links **************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_EditLinks (void)
|
|
|
|
|
{
|
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 ();
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box *****/
|
2018-11-16 00:24:44 +01:00
|
|
|
|
Box_StartBox (NULL,Txt_Links,Lnk_PutIconsEditingLinks,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_SYSTEM_Links_edit,Box_NOT_CLOSABLE);
|
2017-06-03 17:47:07 +02:00
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/***** Put a form to create a new link *****/
|
|
|
|
|
Lnk_PutFormToCreateLink ();
|
|
|
|
|
|
|
|
|
|
/***** Forms to edit current links *****/
|
|
|
|
|
if (Gbl.Links.Num)
|
|
|
|
|
Lnk_ListLinksForEdition ();
|
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_EndBox ();
|
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 *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_PutIconsEditingLinks (void)
|
|
|
|
|
{
|
|
|
|
|
/***** Put icon to view links *****/
|
|
|
|
|
Lnk_PutIconToViewLinks ();
|
|
|
|
|
|
|
|
|
|
/***** Put icon to view banners *****/
|
|
|
|
|
Ban_PutIconToViewBanners ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************************** Put icon to view links ***************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_PutIconToViewLinks (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Links;
|
|
|
|
|
|
2019-01-12 03:00:59 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActSeeLnk,NULL,NULL,
|
|
|
|
|
"link.svg",
|
|
|
|
|
Txt_Links);
|
2018-11-16 00:24:44 +01:00
|
|
|
|
}
|
|
|
|
|
|
2014-12-01 23:55:08 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** List all the links *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_GetListLinks (void)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
unsigned NumLnk;
|
|
|
|
|
struct Link *Lnk;
|
|
|
|
|
|
|
|
|
|
if (Gbl.DB.DatabaseIsOpen)
|
|
|
|
|
{
|
|
|
|
|
/***** Get institutional links from database *****/
|
2018-10-31 16:16:57 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get institutional links",
|
|
|
|
|
"SELECT LnkCod,ShortName,FullName,WWW"
|
|
|
|
|
" FROM links ORDER BY ShortName");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (NumRows) // Places found...
|
|
|
|
|
{
|
|
|
|
|
Gbl.Links.Num = (unsigned) NumRows;
|
|
|
|
|
|
|
|
|
|
/***** Create list with places *****/
|
|
|
|
|
if ((Gbl.Links.Lst = (struct Link *) calloc (NumRows,sizeof (struct Link))) == NULL)
|
2018-10-18 20:06:54 +02:00
|
|
|
|
Lay_NotEnoughMemoryExit ();;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Get the links *****/
|
|
|
|
|
for (NumLnk = 0;
|
|
|
|
|
NumLnk < Gbl.Links.Num;
|
|
|
|
|
NumLnk++)
|
|
|
|
|
{
|
|
|
|
|
Lnk = &(Gbl.Links.Lst[NumLnk]);
|
|
|
|
|
|
|
|
|
|
/* Get next link */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get link code (row[0]) */
|
|
|
|
|
if ((Lnk->LnkCod = Str_ConvertStrCodToLongCod (row[0])) < 0)
|
|
|
|
|
Lay_ShowErrorAndExit ("Wrong code of institutional link.");
|
|
|
|
|
|
|
|
|
|
/* Get the short name of the link (row[1]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Lnk->ShrtName,row[1],
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Lnk_MAX_BYTES_LINK_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the full name of the link (row[2]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Lnk->FullName,row[2],
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Lnk_MAX_BYTES_LINK_FULL_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the URL of the link (row[3]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Lnk->WWW,row[3],
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Gbl.Links.Num = 0;
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Get link full name *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
|
|
|
|
|
{
|
|
|
|
|
MYSQL_RES *mysql_res;
|
|
|
|
|
MYSQL_ROW row;
|
|
|
|
|
unsigned long NumRows;
|
|
|
|
|
|
|
|
|
|
/***** Clear data *****/
|
2016-10-28 10:03:37 +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 *****/
|
2018-10-31 16:16:57 +01:00
|
|
|
|
NumRows = DB_QuerySELECT (&mysql_res,"can not get data"
|
|
|
|
|
" of an institutional link",
|
|
|
|
|
"SELECT ShortName,FullName,WWW FROM links"
|
|
|
|
|
" WHERE LnkCod=%ld",
|
|
|
|
|
Lnk->LnkCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
if (NumRows) // Link found...
|
|
|
|
|
{
|
|
|
|
|
/* Get row */
|
|
|
|
|
row = mysql_fetch_row (mysql_res);
|
|
|
|
|
|
|
|
|
|
/* Get the short name of the link (row[0]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Lnk->ShrtName,row[0],
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Lnk_MAX_BYTES_LINK_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the full name of the link (row[1]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Lnk->FullName,row[1],
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Lnk_MAX_BYTES_LINK_FULL_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get the URL of the link (row[2]) */
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Lnk->WWW,row[2],
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Free structure that stores the query result *****/
|
|
|
|
|
DB_FreeMySQLResult (&mysql_res);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Free list of links *****************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_FreeListLinks (void)
|
|
|
|
|
{
|
|
|
|
|
if (Gbl.Links.Lst)
|
|
|
|
|
{
|
|
|
|
|
/***** Free memory used by the list of links *****/
|
|
|
|
|
free ((void *) Gbl.Links.Lst);
|
|
|
|
|
Gbl.Links.Lst = NULL;
|
|
|
|
|
Gbl.Links.Num = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/*************************** List all the links ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_ListLinksForEdition (void)
|
|
|
|
|
{
|
|
|
|
|
unsigned NumLnk;
|
|
|
|
|
struct Link *Lnk;
|
|
|
|
|
|
2017-06-03 17:47:07 +02:00
|
|
|
|
/***** Start table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_StartTableWide (2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Table head *****/
|
|
|
|
|
Lnk_PutHeadLinks ();
|
|
|
|
|
|
|
|
|
|
/***** Write all the links *****/
|
|
|
|
|
for (NumLnk = 0;
|
|
|
|
|
NumLnk < Gbl.Links.Num;
|
|
|
|
|
NumLnk++)
|
|
|
|
|
{
|
|
|
|
|
Lnk = &Gbl.Links.Lst[NumLnk];
|
|
|
|
|
|
|
|
|
|
/* Put icon to remove link */
|
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<td class=\"BM\">");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActRemLnk);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lnk_PutParamLnkCod (Lnk->LnkCod);
|
2017-06-11 19:13:28 +02:00
|
|
|
|
Ico_PutIconRemove ();
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Link code */
|
2015-08-06 12:31:05 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE\">"
|
|
|
|
|
"%ld"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"</td>",
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lnk->LnkCod);
|
|
|
|
|
|
|
|
|
|
/* Link short name */
|
2015-08-06 12:31:05 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActRenLnkSho);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lnk_PutParamLnkCod (Lnk->LnkCod);
|
2015-10-22 14:49:48 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"ShortName\""
|
2015-12-05 21:15:30 +01:00
|
|
|
|
" maxlength=\"%u\" value=\"%s\""
|
|
|
|
|
" class=\"INPUT_SHORT_NAME\""
|
2015-10-22 14:49:48 +02:00
|
|
|
|
" onchange=\"document.getElementById('%s').submit();\" />",
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Lnk_MAX_CHARS_LINK_SHRT_NAME,Lnk->ShrtName,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
Gbl.Form.Id);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Link full name */
|
2015-08-06 12:31:05 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActRenLnkFul);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lnk_PutParamLnkCod (Lnk->LnkCod);
|
2015-10-22 14:49:48 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"FullName\""
|
2015-12-05 21:15:30 +01:00
|
|
|
|
" maxlength=\"%u\" value=\"%s\""
|
|
|
|
|
" class=\"INPUT_FULL_NAME\""
|
2015-10-22 14:49:48 +02:00
|
|
|
|
" onchange=\"document.getElementById('%s').submit();\" />",
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Lnk_MAX_CHARS_LINK_FULL_NAME,Lnk->FullName,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
Gbl.Form.Id);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Link WWW */
|
2015-08-06 12:31:05 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">");
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActChgLnkWWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lnk_PutParamLnkCod (Lnk->LnkCod);
|
2016-11-20 14:32:15 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<input type=\"url\" name=\"WWW\""
|
2015-12-05 21:15:30 +01:00
|
|
|
|
" maxlength=\"%u\" value=\"%s\""
|
|
|
|
|
" class=\"INPUT_WWW\""
|
2015-10-22 14:49:48 +02:00
|
|
|
|
" onchange=\"document.getElementById('%s').submit();\" />",
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Cns_MAX_CHARS_WWW,Lnk->WWW,
|
2016-01-14 10:31:09 +01:00
|
|
|
|
Gbl.Form.Id);
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_EndForm ();
|
2015-03-13 00:16:02 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"</td>"
|
|
|
|
|
"</tr>");
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-06-03 17:47:07 +02:00
|
|
|
|
/***** End table *****/
|
2017-06-11 20:09:59 +02:00
|
|
|
|
Tbl_EndTable ();
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************** Write parameter with code of link **********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_PutParamLnkCod (long LnkCod)
|
|
|
|
|
{
|
|
|
|
|
Par_PutHiddenParamLong ("LnkCod",LnkCod);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* 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;
|
|
|
|
|
struct Link Lnk;
|
|
|
|
|
|
|
|
|
|
/***** Get link code *****/
|
|
|
|
|
if ((Lnk.LnkCod = Lnk_GetParamLnkCod ()) == -1L)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of institutional link is missing.");
|
|
|
|
|
|
|
|
|
|
/***** Get data of the link from database *****/
|
|
|
|
|
Lnk_GetDataOfLinkByCod (&Lnk);
|
|
|
|
|
|
|
|
|
|
/***** Remove link *****/
|
2018-11-02 22:00:31 +01:00
|
|
|
|
DB_QueryDELETE ("can not remove an institutional link",
|
|
|
|
|
"DELETE FROM links WHERE LnkCod=%ld",
|
|
|
|
|
Lnk.LnkCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Link_X_removed,
|
|
|
|
|
Lnk.ShrtName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
|
|
|
|
Lnk_EditLinks ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* Change the short name of a link ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_RenameLinkShort (void)
|
|
|
|
|
{
|
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)
|
|
|
|
|
{
|
|
|
|
|
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_You_can_not_leave_the_name_of_the_link_X_empty;
|
|
|
|
|
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;
|
|
|
|
|
struct Link *Lnk;
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
Lnk = &Gbl.Links.EditingLnk;
|
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;
|
2016-10-28 10:03:37 +02:00
|
|
|
|
CurrentLnkName = Lnk->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;
|
2014-12-01 23:55:08 +01:00
|
|
|
|
CurrentLnkName = Lnk->FullName;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the link */
|
|
|
|
|
if ((Lnk->LnkCod = Lnk_GetParamLnkCod ()) == -1L)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of institutional link is missing.");
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
|
|
/***** Get from the database the old names of the link *****/
|
|
|
|
|
Lnk_GetDataOfLinkByCod (Lnk);
|
|
|
|
|
|
|
|
|
|
/***** Check if new name is empty *****/
|
|
|
|
|
if (!NewLnkName[0])
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_name_of_the_link_X_empty,
|
|
|
|
|
CurrentLnkName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
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... *****/
|
|
|
|
|
if (Lnk_CheckIfLinkNameExists (ParamName,NewLnkName,Lnk->LnkCod))
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,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 */
|
2017-03-09 11:16:17 +01:00
|
|
|
|
Lnk_UpdateLnkNameDB (Lnk->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-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_link_X_has_been_renamed_as_Y,
|
|
|
|
|
CurrentLnkName,NewLnkName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else // The same name
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_The_name_of_the_link_X_has_not_changed,
|
|
|
|
|
CurrentLnkName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (CurrentLnkName,NewLnkName,
|
2017-03-07 19:55:29 +01:00
|
|
|
|
MaxBytes);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lnk_EditLinks ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************** Check if the name of link exists *********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static bool Lnk_CheckIfLinkNameExists (const char *FieldName,const char *Name,long LnkCod)
|
|
|
|
|
{
|
|
|
|
|
/***** Get number of links with a name from database *****/
|
2018-11-03 20:52:00 +01:00
|
|
|
|
return (DB_QueryCOUNT ("can not check if the name of an institutional link"
|
|
|
|
|
" already existed",
|
|
|
|
|
"SELECT COUNT(*) FROM links"
|
|
|
|
|
" WHERE %s='%s' AND LnkCod<>%ld",
|
|
|
|
|
FieldName,Name,LnkCod) != 0);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-09 11:16:17 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************ Update link name in table of institutional links ***************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_UpdateLnkNameDB (long LnkCod,const char *FieldName,const char *NewLnkName)
|
|
|
|
|
{
|
|
|
|
|
/***** Update institutional link changing old name by new name */
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not update the name of an institutional link",
|
|
|
|
|
"UPDATE links SET %s='%s' WHERE LnkCod=%ld",
|
|
|
|
|
FieldName,NewLnkName,LnkCod);
|
2017-03-09 11:16:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
extern const char *Txt_You_can_not_leave_the_web_address_empty;
|
|
|
|
|
struct Link *Lnk;
|
2017-03-07 01:56:41 +01:00
|
|
|
|
char NewWWW[Cns_MAX_BYTES_WWW + 1];
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
Lnk = &Gbl.Links.EditingLnk;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get the code of the link */
|
|
|
|
|
if ((Lnk->LnkCod = Lnk_GetParamLnkCod ()) == -1L)
|
|
|
|
|
Lay_ShowErrorAndExit ("Code of institutional link is missing.");
|
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
|
|
|
|
/***** Check if new WWW is empty *****/
|
|
|
|
|
if (NewWWW[0])
|
|
|
|
|
{
|
|
|
|
|
/* Update the table changing old WWW by new WWW */
|
2018-11-03 12:16:40 +01:00
|
|
|
|
DB_QueryUPDATE ("can not update the web of an institutional link",
|
|
|
|
|
"UPDATE links SET WWW='%s' WHERE LnkCod=%ld",
|
|
|
|
|
NewWWW,Lnk->LnkCod);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write message to show the change made *****/
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X,
|
|
|
|
|
NewWWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_can_not_leave_the_web_address_empty);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
2017-01-17 03:10:43 +01:00
|
|
|
|
Str_Copy (Lnk->WWW,NewWWW,
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Lnk_EditLinks ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/********************* 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;
|
|
|
|
|
struct Link *Lnk;
|
|
|
|
|
|
|
|
|
|
Lnk = &Gbl.Links.EditingLnk;
|
|
|
|
|
|
|
|
|
|
/***** Start form *****/
|
2018-11-09 20:47:39 +01:00
|
|
|
|
Frm_StartForm (ActNewLnk);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** Start box and table *****/
|
2017-06-10 21:38:10 +02:00
|
|
|
|
Box_StartBoxTable (NULL,Txt_New_link,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
Hlp_SYSTEM_Links_edit,Box_NOT_CLOSABLE,2);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write heading *****/
|
|
|
|
|
Lnk_PutHeadLinks ();
|
|
|
|
|
|
|
|
|
|
/***** Link code *****/
|
2014-12-23 17:12:45 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
|
|
|
|
"<td class=\"BM\"></td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"<td></td>");
|
|
|
|
|
|
|
|
|
|
/***** Link short name *****/
|
2015-08-06 12:31:05 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
|
|
|
|
|
"<input type=\"text\" name=\"ShortName\""
|
2015-12-05 21:15:30 +01:00
|
|
|
|
" maxlength=\"%u\" value=\"%s\""
|
2016-11-19 20:20:40 +01:00
|
|
|
|
" class=\"INPUT_SHORT_NAME\""
|
|
|
|
|
" required=\"required\" />"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>",
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Lnk_MAX_CHARS_LINK_SHRT_NAME,Lnk->ShrtName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link full name *****/
|
2015-08-06 12:31:05 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
|
|
|
|
|
"<input type=\"text\" name=\"FullName\""
|
2015-12-05 21:15:30 +01:00
|
|
|
|
" maxlength=\"%u\" value=\"%s\""
|
2016-11-19 20:20:40 +01:00
|
|
|
|
" class=\"INPUT_FULL_NAME\""
|
|
|
|
|
" required=\"required\" />"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</td>",
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Lnk_MAX_CHARS_LINK_FULL_NAME,Lnk->FullName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Link WWW *****/
|
2015-08-06 12:31:05 +02:00
|
|
|
|
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
|
2016-11-20 14:32:15 +01:00
|
|
|
|
"<input type=\"url\" name=\"WWW\""
|
2015-12-05 21:15:30 +01:00
|
|
|
|
" maxlength=\"%u\" value=\"%s\""
|
2016-11-19 20:20:40 +01:00
|
|
|
|
" class=\"INPUT_WWW\""
|
|
|
|
|
" required=\"required\" />"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"</td>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Cns_MAX_CHARS_WWW,Lnk->WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End table, send button and end box *****/
|
2017-06-11 19:02:40 +02:00
|
|
|
|
Box_EndBoxTableWithButton (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;
|
|
|
|
|
|
2014-12-23 17:12:45 +01:00
|
|
|
|
fprintf (Gbl.F.Out,"<tr>"
|
2015-09-05 19:19:39 +02:00
|
|
|
|
"<th class=\"BM\"></th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"RIGHT_MIDDLE\">"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"%s"
|
2015-09-05 19:19:39 +02:00
|
|
|
|
"</th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"LEFT_MIDDLE\">"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"%s"
|
2015-09-05 19:19:39 +02:00
|
|
|
|
"</th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"LEFT_MIDDLE\">"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"%s"
|
2015-09-05 19:19:39 +02:00
|
|
|
|
"</th>"
|
2015-09-06 20:02:14 +02:00
|
|
|
|
"<th class=\"LEFT_MIDDLE\">"
|
2014-12-23 17:12:45 +01:00
|
|
|
|
"%s"
|
2015-09-05 19:19:39 +02:00
|
|
|
|
"</th>"
|
2014-12-01 23:55:08 +01:00
|
|
|
|
"</tr>",
|
|
|
|
|
Txt_Code,
|
2015-02-04 20:03:23 +01:00
|
|
|
|
Txt_Short_name,
|
|
|
|
|
Txt_Full_name,
|
2014-12-01 23:55:08 +01:00
|
|
|
|
Txt_WWW);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/******************* Receive form to create a new link ***********************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
void Lnk_RecFormNewLink (void)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_link_X_already_exists;
|
|
|
|
|
extern const char *Txt_You_must_specify_the_URL_of_the_new_link;
|
|
|
|
|
extern const char *Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_link;
|
|
|
|
|
struct Link *Lnk;
|
|
|
|
|
|
|
|
|
|
Lnk = &Gbl.Links.EditingLnk;
|
|
|
|
|
|
|
|
|
|
/***** Get parameters from form *****/
|
|
|
|
|
/* Get link short name */
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Par_GetParToText ("ShortName",Lnk->ShrtName,Lnk_MAX_BYTES_LINK_SHRT_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get link full name */
|
2017-03-07 19:55:29 +01:00
|
|
|
|
Par_GetParToText ("FullName",Lnk->FullName,Lnk_MAX_BYTES_LINK_FULL_NAME);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/* Get link URL */
|
2017-03-07 01:56:41 +01:00
|
|
|
|
Par_GetParToText ("WWW",Lnk->WWW,Cns_MAX_BYTES_WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
2016-10-28 10:03:37 +02:00
|
|
|
|
if (Lnk->ShrtName[0] && Lnk->FullName[0]) // If there's a link name
|
2014-12-01 23:55:08 +01:00
|
|
|
|
{
|
|
|
|
|
/***** If name of link was in database... *****/
|
2016-10-28 10:03:37 +02:00
|
|
|
|
if (Lnk_CheckIfLinkNameExists ("ShortName",Lnk->ShrtName,-1L))
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_The_link_X_already_exists,
|
|
|
|
|
Lnk->ShrtName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else if (Lnk_CheckIfLinkNameExists ("FullName",Lnk->FullName,-1L))
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_The_link_X_already_exists,
|
|
|
|
|
Lnk->FullName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else if (!Lnk->WWW[0])
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_URL_of_the_new_link);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
else // Add new link to database
|
|
|
|
|
Lnk_CreateLink (Lnk);
|
|
|
|
|
}
|
|
|
|
|
else // If there is not a link name
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_link);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Show the form again *****/
|
|
|
|
|
Lnk_EditLinks ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Create a new link ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void Lnk_CreateLink (struct Link *Lnk)
|
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_Created_new_link_X;
|
|
|
|
|
|
|
|
|
|
/***** Create a new link *****/
|
2018-11-02 19:37:11 +01:00
|
|
|
|
DB_QueryINSERT ("can not create institutional link",
|
|
|
|
|
"INSERT INTO links"
|
|
|
|
|
" (ShortName,FullName,WWW)"
|
|
|
|
|
" VALUES"
|
|
|
|
|
" ('%s','%s','%s')",
|
|
|
|
|
Lnk->ShrtName,Lnk->FullName,Lnk->WWW);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
|
|
|
|
|
/***** Write success message *****/
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_SUCCESS,Txt_Created_new_link_X,
|
|
|
|
|
Lnk->ShrtName);
|
2014-12-01 23:55:08 +01:00
|
|
|
|
}
|