Version 21.12: Sep 22, 2021 New module swad_link_database for database queries related to institutional links.

This commit is contained in:
acanas 2021-09-22 13:20:57 +02:00
parent ddf9d0dfdc
commit ebc93b6c27
9 changed files with 624 additions and 457 deletions

View File

@ -59,7 +59,8 @@ OBJS = swad_account.o swad_account_database.o swad_action.o swad_admin.o \
swad_indicator_database.o swad_info.o swad_info_database.o \
swad_institution.o swad_institution_config.o \
swad_institution_database.o \
swad_language.o swad_layout.o swad_link.o swad_log.o swad_logo.o \
swad_language.o swad_layout.o swad_link.o swad_link_database.o \
swad_log.o swad_logo.o \
swad_MAC.o swad_mail.o swad_main.o swad_maintenance.o swad_map.o \
swad_mark.o swad_match.o swad_match_print.o swad_match_result.o \
swad_media.o swad_media_database.o swad_menu.o swad_message.o \

View File

@ -602,13 +602,14 @@ TODO: FIX BUG, URGENT! En las fechas como par
TODO: En las encuestas, que los estudiantes no puedan ver los resultados hasta que no finalice el plazo.
*/
#define Log_PLATFORM_VERSION "SWAD 21.11.1 (2021-09-22)"
#define Log_PLATFORM_VERSION "SWAD 21.12 (2021-09-22)"
#define CSS_FILE "swad20.45.css"
#define JS_FILE "swad20.69.1.js"
/*
TODO: Rename CENTRE to CENTER in help wiki.
TODO: Rename ASSESSMENT.Announcements to ASSESSMENT.Calls_for_exams
Version 21.12: Sep 22, 2021 New module swad_link_database for database queries related to institutional links. (316361 lines)
Version 21.11.1: Sep 22, 2021 Queries moved to module swad_info_database. (316237 lines)
Version 21.11: Sep 22, 2021 New module swad_info_database for database queries related to course information. (316228 lines)
Version 21.10.1: Sep 21, 2021 Fixed bugs in roles. Reported by Javier Fernández Baldomero and Carmen García Miranda. (316111 lines)

View File

@ -196,18 +196,11 @@ void Lan_ChangeLanguage (void)
void Lan_UpdateMyLanguageToCurrentLanguage (void)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
/***** Set my language to the current language *****/
Gbl.Usrs.Me.UsrDat.Prefs.Language = Gbl.Prefs.Language;
/***** Update my language in database *****/
DB_QueryUPDATE ("can not update your language",
"UPDATE usr_data"
" SET Language='%s'"
" WHERE UsrCod=%ld",
Lan_STR_LANG_ID[Gbl.Prefs.Language],
Gbl.Usrs.Me.UsrDat.UsrCod);
Set_DB_UpdateMySettingsAboutLanguage ();
}
/*****************************************************************************/

View File

@ -269,12 +269,12 @@ void Lay_WriteStartOfPage (void)
switch (BrowserTab)
{
case Act_BRW_1ST_TAB:
HTM_Txt ("<body onload=\"init();\">\n");
HTM_DIV_Begin ("id=\"zoomLyr\" class=\"ZOOM\"");
HTM_IMG (Cfg_URL_ICON_PUBLIC,"usr_bl.jpg",NULL,
"class=\"IMG_USR\" id=\"zoomImg\"");
HTM_DIV_Begin ("id=\"zoomTxt\" class=\"CM\"");
HTM_DIV_End ();
HTM_Txt ("<body onload=\"init();\">\n");
HTM_DIV_Begin ("id=\"zoomLyr\" class=\"ZOOM\"");
HTM_IMG (Cfg_URL_ICON_PUBLIC,"usr_bl.jpg",NULL,
"class=\"IMG_USR\" id=\"zoomImg\"");
HTM_DIV_Begin ("id=\"zoomTxt\" class=\"CM\"");
HTM_DIV_End ();
HTM_DIV_End ();
break;
case Act_BRW_NEW_TAB:
@ -311,77 +311,77 @@ void Lay_WriteStartOfPage (void)
/***** Begin box that contains the whole page except the foot *****/
HTM_DIV_Begin ("id=\"whole_page\"");
/***** Header of layout *****/
Lay_WritePageTopHeading ();
/***** Header of layout *****/
Lay_WritePageTopHeading ();
/***** 3rd. row (tabs) *****/
Tab_DrawTabs ();
/***** 3rd. row (tabs) *****/
Tab_DrawTabs ();
/***** 4th row: main zone *****/
HTM_DIV_Begin ("id=\"main_zone\"");
/***** 4th row: main zone *****/
HTM_DIV_Begin ("id=\"main_zone\"");
/* Left column */
if (Gbl.Prefs.SideCols & Lay_SHOW_LEFT_COLUMN) // Left column visible
{
HTM_Txt ("<aside id=\"left_col\">");
Lay_ShowLeftColumn ();
HTM_Txt ("</aside>");
}
/* Left column */
if (Gbl.Prefs.SideCols & Lay_SHOW_LEFT_COLUMN) // Left column visible
{
HTM_Txt ("<aside id=\"left_col\">");
Lay_ShowLeftColumn ();
HTM_Txt ("</aside>");
}
/* Right column */
// Right column is written before central column
// but it must be drawn at right using "position:absolute; right:0".
// The reason to write right column before central column
// is that central column may hold a lot of content drawn slowly.
if (Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN) // Right column visible
{
HTM_Txt ("<aside id=\"right_col\">");
Lay_ShowRightColumn ();
HTM_Txt ("</aside>");
}
/* Right column */
// Right column is written before central column
// but it must be drawn at right using "position:absolute; right:0".
// The reason to write right column before central column
// is that central column may hold a lot of content drawn slowly.
if (Gbl.Prefs.SideCols & Lay_SHOW_RIGHT_COLUMN) // Right column visible
{
HTM_Txt ("<aside id=\"right_col\">");
Lay_ShowRightColumn ();
HTM_Txt ("</aside>");
}
/* Central (main) column */
switch (Gbl.Prefs.SideCols)
{
case 0:
HTM_DIV_Begin ("id=\"main_zone_central_none\"");
break;
case Lay_SHOW_LEFT_COLUMN:
HTM_DIV_Begin ("id=\"main_zone_central_left\"");
break;
case Lay_SHOW_RIGHT_COLUMN:
HTM_DIV_Begin ("id=\"main_zone_central_right\"");
break;
case (Lay_SHOW_LEFT_COLUMN | Lay_SHOW_RIGHT_COLUMN):
HTM_DIV_Begin ("id=\"main_zone_central_both\"");
break;
}
HTM_DIV_Begin ("id=\"main_zone_central_container\" class=\"%s\"",
The_TabOnBgColors[Gbl.Prefs.Theme]);
/* Central (main) column */
switch (Gbl.Prefs.SideCols)
{
case 0:
HTM_DIV_Begin ("id=\"main_zone_central_none\"");
break;
case Lay_SHOW_LEFT_COLUMN:
HTM_DIV_Begin ("id=\"main_zone_central_left\"");
break;
case Lay_SHOW_RIGHT_COLUMN:
HTM_DIV_Begin ("id=\"main_zone_central_right\"");
break;
case (Lay_SHOW_LEFT_COLUMN | Lay_SHOW_RIGHT_COLUMN):
HTM_DIV_Begin ("id=\"main_zone_central_both\"");
break;
}
HTM_DIV_Begin ("id=\"main_zone_central_container\" class=\"%s\"",
The_TabOnBgColors[Gbl.Prefs.Theme]);
/* Layout with horizontal or vertical menu */
HTM_DIV_Begin ("id=\"%s\"",LayoutMainZone[Gbl.Prefs.Menu]);
/* Layout with horizontal or vertical menu */
HTM_DIV_Begin ("id=\"%s\"",LayoutMainZone[Gbl.Prefs.Menu]);
/* Menu */
Mnu_WriteMenuThisTab ();
/* Menu */
Mnu_WriteMenuThisTab ();
/* Begin canvas: main zone for actions output */
HTM_MAIN_Begin ("MAIN_ZONE_CANVAS");
/* Begin canvas: main zone for actions output */
HTM_MAIN_Begin ("MAIN_ZONE_CANVAS");
/* If it is mandatory to read any information about course */
if (Gbl.Crs.Info.ShowMsgMustBeRead)
Inf_WriteMsgYouMustReadInfo ();
/* If it is mandatory to read any information about course */
if (Gbl.Crs.Info.ShowMsgMustBeRead)
Inf_WriteMsgYouMustReadInfo ();
/* Write title of the current action */
if (Gbl.Prefs.Menu == Mnu_MENU_VERTICAL &&
Act_GetIndexInMenu (Gbl.Action.Act) >= 0)
Lay_WriteTitleAction ();
/* Write title of the current action */
if (Gbl.Prefs.Menu == Mnu_MENU_VERTICAL &&
Act_GetIndexInMenu (Gbl.Action.Act) >= 0)
Lay_WriteTitleAction ();
Gbl.Layout.WritingHTMLStart = false;
Gbl.Layout.HTMLStartWritten = true;
Gbl.Layout.WritingHTMLStart = false;
Gbl.Layout.HTMLStartWritten = true;
/* Write message indicating number of clicks allowed before sending my photo */
Usr_InformAboutNumClicksBeforePhoto ();
/* Write message indicating number of clicks allowed before sending my photo */
Usr_InformAboutNumClicksBeforePhoto ();
}
/*****************************************************************************/
@ -1096,9 +1096,9 @@ static void Lay_WritePageTopHeading (void)
static void Lay_WriteBreadcrumb (void)
{
HTM_Txt ("<nav id=\"breadcrumb\">");
Crs_PutIconToSelectMyCoursesInBreadcrumb ();
Hie_WriteHierarchyInBreadcrumb ();
Crs_WriteSelectorMyCoursesInBreadcrumb ();
Crs_PutIconToSelectMyCoursesInBreadcrumb ();
Hie_WriteHierarchyInBreadcrumb ();
Crs_WriteSelectorMyCoursesInBreadcrumb ();
HTM_Txt ("</nav>");
}
@ -1117,16 +1117,16 @@ static void Lay_WriteTitleAction (void)
Gbl.Prefs.URLIconSet,
Act_GetIcon (Act_GetSuperAction (Gbl.Action.Act)));
/***** Title *****/
HTM_DIV_Begin ("class=\"%s\"",The_ClassTitleAction[Gbl.Prefs.Theme]);
HTM_TxtF ("%s &gt; %s",Txt_TABS_TXT[Act_GetTab (Gbl.Action.Act)],
Act_GetTitleAction (Gbl.Action.Act));
HTM_DIV_End ();
/***** Title *****/
HTM_DIV_Begin ("class=\"%s\"",The_ClassTitleAction[Gbl.Prefs.Theme]);
HTM_TxtF ("%s &gt; %s",Txt_TABS_TXT[Act_GetTab (Gbl.Action.Act)],
Act_GetTitleAction (Gbl.Action.Act));
HTM_DIV_End ();
/***** Subtitle *****/
HTM_DIV_Begin ("class=\"%s\"",The_ClassSubtitleAction[Gbl.Prefs.Theme]);
HTM_Txt (Act_GetSubtitleAction (Gbl.Action.Act));
HTM_DIV_End ();
/***** Subtitle *****/
HTM_DIV_Begin ("class=\"%s\"",The_ClassSubtitleAction[Gbl.Prefs.Theme]);
HTM_Txt (Act_GetSubtitleAction (Gbl.Action.Act));
HTM_DIV_End ();
/***** Container end *****/
HTM_DIV_End ();
@ -1142,33 +1142,33 @@ static void Lay_ShowLeftColumn (void)
HTM_DIV_Begin ("style=\"width:160px;\"");
HTM_DIV_Begin ("class=\"LEFT_RIGHT_CELL\"");
if (Gbl.Usrs.Me.Logged)
{
/***** Most frequently used actions *****/
MFU_AllocateMFUActions (&ListMFUActions,6);
MFU_GetMFUActions (&ListMFUActions,6);
MFU_WriteSmallMFUActions (&ListMFUActions);
MFU_FreeMFUActions (&ListMFUActions);
}
else
/***** Institutional links *****/
Lnk_WriteMenuWithInstitutionalLinks ();
HTM_DIV_End ();
/***** Month *****/
HTM_DIV_Begin ("class=\"LEFT_RIGHT_CELL\"");
Cal_DrawCurrentMonth ();
HTM_DIV_End ();
/***** Notices (yellow notes) *****/
if (Gbl.Hierarchy.Level == HieLvl_CRS)
{
HTM_DIV_Begin ("class=\"LEFT_RIGHT_CELL\"");
Not_ShowNotices (Not_LIST_BRIEF_NOTICES,
-1L); // No notice highlighted
if (Gbl.Usrs.Me.Logged)
{
/***** Most frequently used actions *****/
MFU_AllocateMFUActions (&ListMFUActions,6);
MFU_GetMFUActions (&ListMFUActions,6);
MFU_WriteSmallMFUActions (&ListMFUActions);
MFU_FreeMFUActions (&ListMFUActions);
}
else
/***** Institutional links *****/
Lnk_WriteMenuWithInstitutionalLinks ();
HTM_DIV_End ();
}
/***** Month *****/
HTM_DIV_Begin ("class=\"LEFT_RIGHT_CELL\"");
Cal_DrawCurrentMonth ();
HTM_DIV_End ();
/***** Notices (yellow notes) *****/
if (Gbl.Hierarchy.Level == HieLvl_CRS)
{
HTM_DIV_Begin ("class=\"LEFT_RIGHT_CELL\"");
Not_ShowNotices (Not_LIST_BRIEF_NOTICES,
-1L); // No notice highlighted
HTM_DIV_End ();
}
HTM_DIV_End ();
}
@ -1190,7 +1190,7 @@ static void Lay_ShowRightColumn (void)
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
{
HTM_DIV_Begin ("id=\"globalconnected\" class=\"LEFT_RIGHT_CELL\""); // Used for AJAX based refresh
Con_ShowGlobalConnectedUsrs ();
Con_ShowGlobalConnectedUsrs ();
HTM_DIV_End (); // Used for AJAX based refresh
}
@ -1198,15 +1198,15 @@ static void Lay_ShowRightColumn (void)
if (Gbl.Hierarchy.Level == HieLvl_CRS) // There is a course selected
{
HTM_DIV_Begin ("id=\"courseconnected\" class=\"LEFT_RIGHT_CELL\""); // Used for AJAX based refresh
Gbl.Scope.Current = HieLvl_CRS;
Con_ShowConnectedUsrsBelongingToCurrentCrs ();
Gbl.Scope.Current = HieLvl_CRS;
Con_ShowConnectedUsrsBelongingToCurrentCrs ();
HTM_DIV_End (); // Used for AJAX based refresh
}
else if (Gbl.Usrs.Me.Logged) // I am logged
{
/***** Suggest one user to follow *****/
HTM_DIV_Begin ("class=\"LEFT_RIGHT_CELL\"");
Fol_SuggestUsrsToFollowMainZoneOnRightColumn ();
Fol_SuggestUsrsToFollowMainZoneOnRightColumn ();
HTM_DIV_End ();
}
@ -1214,12 +1214,12 @@ static void Lay_ShowRightColumn (void)
{
/***** SWADroid advertisement *****/
HTM_DIV_Begin ("class=\"LEFT_RIGHT_CELL\"");
HTM_A_Begin ("href=\"https://play.google.com/store/apps/details?id=es.ugr.swad.swadroid\""
" target=\"_blank\" title=\"%s\"",
Txt_If_you_have_an_Android_device_try_SWADroid);
HTM_IMG (Cfg_URL_ICON_PUBLIC,"SWADroid120x200.png","SWADroid",
"style=\"width:150px; height:250px;\"");
HTM_A_End ();
HTM_A_Begin ("href=\"https://play.google.com/store/apps/details?id=es.ugr.swad.swadroid\""
" target=\"_blank\" title=\"%s\"",
Txt_If_you_have_an_Android_device_try_SWADroid);
HTM_IMG (Cfg_URL_ICON_PUBLIC,"SWADroid120x200.png","SWADroid",
"style=\"width:150px; height:250px;\"");
HTM_A_End ();
HTM_DIV_End ();
}
}
@ -1267,7 +1267,7 @@ void Lay_PutContextualLinkIconText (Act_Action_t NextAction,const char *Anchor,
/***** Put icon and text with link *****/
HTM_BUTTON_SUBMIT_Begin (Text,The_ClassFormLinkOutBoxBold[Gbl.Prefs.Theme],NULL);
Ico_PutIconTextLink (Icon,Text);
Ico_PutIconTextLink (Icon,Text);
HTM_BUTTON_End ();
/***** End form *****/
@ -1301,7 +1301,7 @@ void Lay_PutContextualLinkIconTextOnSubmit (Act_Action_t NextAction,const char *
/***** Put icon with link *****/
HTM_BUTTON_SUBMIT_Begin (Text,The_ClassFormLinkOutBoxBold[Gbl.Prefs.Theme],OnSubmit);
Ico_PutIconTextLink (Icon,Text);
Ico_PutIconTextLink (Icon,Text);
HTM_BUTTON_End ();
/***** End form *****/
@ -1334,29 +1334,33 @@ void Lay_PutContextualCheckbox (Act_Action_t NextAction,
if (FuncParams)
FuncParams ();
/***** Begin container and label *****/
/***** Begin container *****/
HTM_DIV_Begin ("class=\"CONTEXT_OPT %s %s\" title=\"%s\"",
Checked ? "CHECKBOX_CHECKED" :
"CHECKBOX_UNCHECKED",
The_ClassFormOutBoxBold[Gbl.Prefs.Theme],
Title);
HTM_LABEL_Begin (NULL);
/****** Checkbox *****/
HTM_INPUT_CHECKBOX (CheckboxName,HTM_SUBMIT_ON_CHANGE,
"value=\"Y\"%s%s",
Checked ? " checked=\"checked\"" :
"",
Disabled ? " disabled=\"disabled\"" :
"");
/***** Begin label *****/
HTM_LABEL_Begin (NULL);
/***** Text *****/
if (Text)
if (Text[0])
HTM_TxtF ("&nbsp;%s",Text);
/****** Checkbox *****/
HTM_INPUT_CHECKBOX (CheckboxName,HTM_SUBMIT_ON_CHANGE,
"value=\"Y\"%s%s",
Checked ? " checked=\"checked\"" :
"",
Disabled ? " disabled=\"disabled\"" :
"");
/***** End label and container *****/
HTM_LABEL_End ();
/***** Text *****/
if (Text)
if (Text[0])
HTM_TxtF ("&nbsp;%s",Text);
/***** End label *****/
HTM_LABEL_End ();
/***** End container *****/
HTM_DIV_End ();
/***** End form *****/
@ -1513,9 +1517,9 @@ static void Lay_WriteFootFromHTMLFile (void)
{
HTM_Txt ("<footer id=\"foot_zone\">");
/***** Copy HTML to output file *****/
Fil_FastCopyOfOpenFiles (FileHTML,Gbl.F.Out);
fclose (FileHTML);
/***** Copy HTML to output file *****/
Fil_FastCopyOfOpenFiles (FileHTML,Gbl.F.Out);
fclose (FileHTML);
HTM_Txt ("</footer>");
}
@ -1544,69 +1548,71 @@ void Lay_WriteHeaderClassPhoto (bool PrintView,bool DrawingClassPhoto,
/***** Begin table *****/
HTM_TABLE_BeginWidePadding (10);
HTM_TR_Begin (NULL);
/***** First column: institution logo *****/
HTM_TD_Begin ("class=\"LT\" style=\"width:60px;\"");
if (InsCod > 0)
{
if (!PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",Hie.Ins.WWW);
Lgo_DrawLogo (HieLvl_INS,Hie.Ins.InsCod,Hie.Ins.ShrtName,40,NULL,true);
if (!PrintView)
HTM_A_End ();
}
HTM_TD_End ();
HTM_TR_Begin (NULL);
/***** Second column: class photo title *****/
HTM_TD_Begin ("class=\"CLASSPHOTO_TITLE CM\"");
if (InsCod > 0)
{
if (!PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"CLASSPHOTO_TITLE\"",
Hie.Ins.WWW);
HTM_Txt (Hie.Ins.FullName);
if (!PrintView)
HTM_A_End ();
}
if (DegCod > 0)
{
if (Hie.Ins.InsCod > 0)
HTM_Txt (" - ");
if (!PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"CLASSPHOTO_TITLE\"",
Hie.Deg.WWW);
HTM_Txt (Hie.Deg.FullName);
if (!PrintView)
HTM_A_End ();
}
HTM_BR ();
if (CrsCod > 0)
{
HTM_Txt (Hie.Crs.FullName);
if (DrawingClassPhoto && !Gbl.Usrs.ClassPhoto.AllGroups)
{
HTM_BR ();
Grp_WriteNamesOfSelectedGrps ();
}
}
HTM_TD_End ();
/***** First column: institution logo *****/
HTM_TD_Begin ("class=\"LT\" style=\"width:60px;\"");
if (InsCod > 0)
{
if (!PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",Hie.Ins.WWW);
Lgo_DrawLogo (HieLvl_INS,Hie.Ins.InsCod,Hie.Ins.ShrtName,40,NULL,true);
if (!PrintView)
HTM_A_End ();
}
HTM_TD_End ();
/***** Third column: degree logo *****/
HTM_TD_Begin ("class=\"RT\" style=\"width:60px;\"");
if (DegCod > 0)
{
if (!PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"CLASSPHOTO_TITLE\"",
Hie.Deg.WWW);
Lgo_DrawLogo (HieLvl_DEG,Hie.Deg.DegCod,Hie.Deg.ShrtName,40,NULL,true);
if (!PrintView)
HTM_A_End ();
}
HTM_TD_End ();
/***** Second column: class photo title *****/
HTM_TD_Begin ("class=\"CLASSPHOTO_TITLE CM\"");
if (InsCod > 0)
{
if (!PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"CLASSPHOTO_TITLE\"",
Hie.Ins.WWW);
HTM_Txt (Hie.Ins.FullName);
if (!PrintView)
HTM_A_End ();
}
if (DegCod > 0)
{
if (Hie.Ins.InsCod > 0)
HTM_Txt (" - ");
if (!PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"CLASSPHOTO_TITLE\"",
Hie.Deg.WWW);
HTM_Txt (Hie.Deg.FullName);
if (!PrintView)
HTM_A_End ();
}
HTM_BR ();
if (CrsCod > 0)
{
HTM_Txt (Hie.Crs.FullName);
if (DrawingClassPhoto && !Gbl.Usrs.ClassPhoto.AllGroups)
{
HTM_BR ();
Grp_WriteNamesOfSelectedGrps ();
}
}
HTM_TD_End ();
/***** Third column: degree logo *****/
HTM_TD_Begin ("class=\"RT\" style=\"width:60px;\"");
if (DegCod > 0)
{
if (!PrintView)
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"CLASSPHOTO_TITLE\"",
Hie.Deg.WWW);
Lgo_DrawLogo (HieLvl_DEG,Hie.Deg.DegCod,Hie.Deg.ShrtName,40,NULL,true);
if (!PrintView)
HTM_A_End ();
}
HTM_TD_End ();
HTM_TR_End ();
/***** End table *****/
HTM_TR_End ();
HTM_TABLE_End ();
}
@ -1629,19 +1635,19 @@ void Lay_AdvertisementMobile (void)
NULL,NULL,
NULL,Box_NOT_CLOSABLE,8);
/***** Show advertisement *****/
HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"DAT CM\"");
HTM_A_Begin ("href=\"https://play.google.com/store/apps/details?id=es.ugr.swad.swadroid\""
" class=\"DAT\"");
HTM_Txt (Txt_Stay_connected_with_SWADroid);
HTM_BR ();
HTM_BR ();
HTM_IMG (Cfg_URL_ICON_PUBLIC,"SWADroid200x300.png",Txt_Stay_connected_with_SWADroid,
"style=\"width:250px; height:375px;\"");
HTM_A_End ();
HTM_TD_End ();
HTM_TR_End ();
/***** Show advertisement *****/
HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"DAT CM\"");
HTM_A_Begin ("href=\"https://play.google.com/store/apps/details?id=es.ugr.swad.swadroid\""
" class=\"DAT\"");
HTM_Txt (Txt_Stay_connected_with_SWADroid);
HTM_BR ();
HTM_BR ();
HTM_IMG (Cfg_URL_ICON_PUBLIC,"SWADroid200x300.png",Txt_Stay_connected_with_SWADroid,
"style=\"width:250px; height:375px;\"");
HTM_A_End ();
HTM_TD_End ();
HTM_TR_End ();
/***** End table and box *****/
Box_BoxTableEnd ();
@ -1702,14 +1708,14 @@ static void Lay_HelpTextEditor (const char *Text,const char *InlineMath,const ch
extern const char *Txt_Equation_centered;
HTM_DIV_Begin ("class=\"HELP_EDIT\"");
HTM_TxtF ("%s: %s"
" "
"%s: <code>%s</code>"
" "
"%s: <code>%s</code>",
Txt_Text,Text,
Txt_Inline_math,InlineMath,
Txt_Equation_centered,Equation);
HTM_TxtF ("%s: %s"
" "
"%s: <code>%s</code>"
" "
"%s: <code>%s</code>",
Txt_Text,Text,
Txt_Inline_math,InlineMath,
Txt_Equation_centered,Equation);
HTM_DIV_End ();
}
@ -1723,11 +1729,13 @@ void Lay_BeginHTMLFile (FILE *File,const char *Title)
fprintf (File,"<!DOCTYPE html>\n"
"<html lang=\"%s\">\n"
"<head>\n"
"<meta http-equiv=\"Content-Type\""
" content=\"text/html;charset=windows-1252\" />\n"
"<title>%s</title>\n"
"</head>\n",
"<head>\n"
"<meta http-equiv=\"Content-Type\""
" content=\"text/html;charset=windows-1252\" />\n"
"<title>"
"%s"
"</title>\n"
"</head>\n",
Lan_STR_LANG_ID[Gbl.Prefs.Language], // Language
Title); // Page title
}

View File

@ -39,6 +39,7 @@
#include "swad_HTML.h"
#include "swad_language.h"
#include "swad_link.h"
#include "swad_link_database.h"
#include "swad_parameter.h"
/*****************************************************************************/
@ -72,16 +73,15 @@ static void Lnk_WriteListOfLinks (void);
static void Lnk_EditLinksInternal (void);
static void Lnk_PutIconsEditingLinks (__attribute__((unused)) void *Args);
static void Lnk_GetDataOfLink (MYSQL_RES *mysql_res,struct Link *Lnk);
static void Lnk_ListLinksForEdition (void);
static void Lnk_PutParamLnkCod (void *LnkCod);
static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName);
static bool Lnk_CheckIfLinkNameExists (const char *FieldName,const char *Name,long LnkCod);
static void Lnk_UpdateLnkNameDB (long LnkCod,const char *FieldName,const char *NewLnkName);
static void Lnk_PutFormToCreateLink (void);
static void Lnk_PutHeadLinks (void);
static void Lnk_CreateLink (struct Link *Lnk);
static void Lnk_EditingLinkConstructor (void);
static void Lnk_EditingLinkDestructor (void);
@ -105,19 +105,19 @@ void Lnk_SeeLinks (void)
Lnk_PutIconsListingLinks,NULL,
Hlp_SYSTEM_Links,Box_NOT_CLOSABLE);
/***** Write all links *****/
if (Gbl.Links.Num) // There are links
Lnk_WriteListOfLinks ();
else // No links created
Ale_ShowAlert (Ale_INFO,Txt_No_links);
/***** Write all links *****/
if (Gbl.Links.Num) // There are links
Lnk_WriteListOfLinks ();
else // No links created
Ale_ShowAlert (Ale_INFO,Txt_No_links);
/***** Button to create link *****/
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
{
Frm_BeginForm (ActEdiLnk);
Btn_PutConfirmButton (Txt_New_link);
Frm_EndForm ();
}
/***** Button to create link *****/
if (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM)
{
Frm_BeginForm (ActEdiLnk);
Btn_PutConfirmButton (Txt_New_link);
Frm_EndForm ();
}
/***** End box *****/
Box_BoxEnd ();
@ -166,13 +166,14 @@ void Lnk_WriteMenuWithInstitutionalLinks (void)
{
HTM_DIV_Begin ("id=\"institutional_links\"");
Frm_BeginForm (ActSeeLnk);
HTM_BUTTON_SUBMIT_Begin (Txt_Links,"BT_LINK LINK_TITLE",NULL);
HTM_TxtF ("%s",Txt_Links);
HTM_BUTTON_End ();
Frm_EndForm ();
Frm_BeginForm (ActSeeLnk);
HTM_BUTTON_SUBMIT_Begin (Txt_Links,"BT_LINK LINK_TITLE",NULL);
HTM_TxtF ("%s",Txt_Links);
HTM_BUTTON_End ();
Frm_EndForm ();
Lnk_WriteListOfLinks ();
Lnk_WriteListOfLinks ();
HTM_DIV_End ();
}
@ -191,20 +192,20 @@ static void Lnk_WriteListOfLinks (void)
/***** List start *****/
HTM_UL_Begin ("class=\"LIST_LEFT\"");
/***** Write all links *****/
for (NumLnk = 0;
NumLnk < Gbl.Links.Num;
NumLnk++)
{
/* Write data of this link */
HTM_LI_Begin ("class=\"INS_LNK\"");
HTM_A_Begin ("href=\"%s\" title=\"%s\" class=\"INS_LNK\" target=\"_blank\"",
Gbl.Links.Lst[NumLnk].WWW,
Gbl.Links.Lst[NumLnk].FullName);
HTM_Txt (Gbl.Links.Lst[NumLnk].ShrtName);
HTM_A_End ();
HTM_LI_End ();
}
/***** Write all links *****/
for (NumLnk = 0;
NumLnk < Gbl.Links.Num;
NumLnk++)
{
/* Write data of this link */
HTM_LI_Begin ("class=\"INS_LNK\"");
HTM_A_Begin ("href=\"%s\" title=\"%s\" class=\"INS_LNK\" target=\"_blank\"",
Gbl.Links.Lst[NumLnk].WWW,
Gbl.Links.Lst[NumLnk].FullName);
HTM_Txt (Gbl.Links.Lst[NumLnk].ShrtName);
HTM_A_End ();
HTM_LI_End ();
}
/***** List end *****/
HTM_UL_End ();
@ -239,12 +240,12 @@ static void Lnk_EditLinksInternal (void)
Lnk_PutIconsEditingLinks,NULL,
Hlp_SYSTEM_Links_edit,Box_NOT_CLOSABLE);
/***** Put a form to create a new link *****/
Lnk_PutFormToCreateLink ();
/***** Put a form to create a new link *****/
Lnk_PutFormToCreateLink ();
/***** Forms to edit current links *****/
if (Gbl.Links.Num)
Lnk_ListLinksForEdition ();
/***** Forms to edit current links *****/
if (Gbl.Links.Num)
Lnk_ListLinksForEdition ();
/***** End box *****/
Box_BoxEnd ();
@ -287,23 +288,12 @@ void Lnk_PutIconToViewLinks (void)
void Lnk_GetListLinks (void)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumLnk;
struct Link *Lnk;
if (Gbl.DB.DatabaseIsOpen)
{
/***** Get institutional links from database *****/
Gbl.Links.Num = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get institutional links",
"SELECT LnkCod," // row[0]
"ShortName," // row[1]
"FullName," // row[2]
"WWW" // row[3]
" FROM lnk_links"
" ORDER BY ShortName");
if (Gbl.Links.Num) // Places found...
if ((Gbl.Links.Num = Lnk_DB_GetLinks (&mysql_res))) // Links found...
{
/***** Create list with places *****/
if ((Gbl.Links.Lst = calloc ((size_t) Gbl.Links.Num,
@ -314,22 +304,8 @@ void Lnk_GetListLinks (void)
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)
Err_WrongLinkExit ();
/* Get the short name (row[0]), the full name (row[1])
and de URL (row[2]) 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);
}
Lnk_GetDataOfLink (mysql_res,&(Gbl.Links.Lst[NumLnk]));
}
/***** Free structure that stores the query result *****/
@ -344,38 +320,43 @@ void Lnk_GetListLinks (void)
void Lnk_GetDataOfLinkByCod (struct Link *Lnk)
{
MYSQL_RES *mysql_res;
MYSQL_ROW row;
/***** Clear data *****/
Lnk->ShrtName[0] = Lnk->FullName[0] = Lnk->WWW[0] = '\0';
Lnk->ShrtName[0] =
Lnk->FullName[0] =
Lnk->WWW[0] = '\0';
/***** Check if link code is correct *****/
if (Lnk->LnkCod > 0)
{
/***** Get data of an institutional link from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get data of an institutional link",
"SELECT ShortName," // row[0]
"FullName," // row[1]
"WWW" // row[2]
" FROM lnk_links"
" WHERE LnkCod=%ld",
Lnk->LnkCod)) // Link found...
{
/* Get row */
row = mysql_fetch_row (mysql_res);
/* Get the short name (row[0]), the full name (row[1])
and de URL (row[2]) of the link */
Str_Copy (Lnk->ShrtName,row[0],sizeof (Lnk->ShrtName) - 1);
Str_Copy (Lnk->FullName,row[1],sizeof (Lnk->FullName) - 1);
Str_Copy (Lnk->WWW ,row[2],sizeof (Lnk->WWW ) - 1);
}
if (Lnk_DB_GetDataOfLinkByCod (&mysql_res,Lnk->LnkCod)) // Link found...
Lnk_GetDataOfLink (mysql_res,Lnk);
/***** Free structure that stores the query result *****/
DB_FreeMySQLResult (&mysql_res);
}
}
/*****************************************************************************/
/**************************** Get data of link *******************************/
/*****************************************************************************/
static void Lnk_GetDataOfLink (MYSQL_RES *mysql_res,struct Link *Lnk)
{
MYSQL_ROW row;
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/***** Get the short name (row[0]),
the full name (row[1])
and the URL (row[2]) of the link *****/
Str_Copy (Lnk->ShrtName,row[0],sizeof (Lnk->ShrtName) - 1);
Str_Copy (Lnk->FullName,row[1],sizeof (Lnk->FullName) - 1);
Str_Copy (Lnk->WWW ,row[2],sizeof (Lnk->WWW ) - 1);
}
/*****************************************************************************/
/**************************** Free list of links *****************************/
/*****************************************************************************/
@ -403,60 +384,60 @@ static void Lnk_ListLinksForEdition (void)
/***** Begin table *****/
HTM_TABLE_BeginWidePadding (2);
/***** Table head *****/
Lnk_PutHeadLinks ();
/***** Table head *****/
Lnk_PutHeadLinks ();
/***** Write all the links *****/
for (NumLnk = 0;
NumLnk < Gbl.Links.Num;
NumLnk++)
{
Lnk = &Gbl.Links.Lst[NumLnk];
/***** Write all the links *****/
for (NumLnk = 0;
NumLnk < Gbl.Links.Num;
NumLnk++)
{
Lnk = &Gbl.Links.Lst[NumLnk];
HTM_TR_Begin (NULL);
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 ();
/* Put icon to remove link */
HTM_TD_Begin ("class=\"BM\"");
Ico_PutContextualIconToRemove (ActRemLnk,NULL,
Lnk_PutParamLnkCod,&Lnk->LnkCod);
HTM_TD_End ();
/* Link code */
HTM_TD_Begin ("class=\"DAT RM\"");
HTM_Long (Lnk->LnkCod);
HTM_TD_End ();
/* Link code */
HTM_TD_Begin ("class=\"DAT RM\"");
HTM_Long (Lnk->LnkCod);
HTM_TD_End ();
/* Link short name */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActRenLnkSho);
Lnk_PutParamLnkCod (&Lnk->LnkCod);
HTM_INPUT_TEXT ("ShortName",Lnk_MAX_CHARS_LINK_SHRT_NAME,Lnk->ShrtName,
HTM_SUBMIT_ON_CHANGE,
"class=\"INPUT_SHORT_NAME\" required=\"required\"");
Frm_EndForm ();
HTM_TD_End ();
/* Link short name */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActRenLnkSho);
Lnk_PutParamLnkCod (&Lnk->LnkCod);
HTM_INPUT_TEXT ("ShortName",Lnk_MAX_CHARS_LINK_SHRT_NAME,Lnk->ShrtName,
HTM_SUBMIT_ON_CHANGE,
"class=\"INPUT_SHORT_NAME\" required=\"required\"");
Frm_EndForm ();
HTM_TD_End ();
/* Link full name */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActRenLnkFul);
Lnk_PutParamLnkCod (&Lnk->LnkCod);
HTM_INPUT_TEXT ("FullName",Lnk_MAX_CHARS_LINK_FULL_NAME,Lnk->FullName,
HTM_SUBMIT_ON_CHANGE,
"class=\"INPUT_FULL_NAME\" required=\"required\"");
Frm_EndForm ();
HTM_TD_End ();
/* Link full name */
HTM_TD_Begin ("class=\"CM\"");
Frm_BeginForm (ActRenLnkFul);
Lnk_PutParamLnkCod (&Lnk->LnkCod);
HTM_INPUT_TEXT ("FullName",Lnk_MAX_CHARS_LINK_FULL_NAME,Lnk->FullName,
HTM_SUBMIT_ON_CHANGE,
"class=\"INPUT_FULL_NAME\" required=\"required\"");
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,
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
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,
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
Frm_EndForm ();
HTM_TD_End ();
HTM_TR_End ();
}
HTM_TR_End ();
}
/***** End table *****/
HTM_TABLE_End ();
@ -501,10 +482,7 @@ void Lnk_RemoveLink (void)
Lnk_GetDataOfLinkByCod (Lnk_EditingLnk);
/***** Remove link *****/
DB_QueryDELETE ("can not remove an institutional link",
"DELETE FROM lnk_links"
" WHERE LnkCod=%ld",
Lnk_EditingLnk->LnkCod);
Lnk_DB_RemoveLink (Lnk_EditingLnk->LnkCod);
/***** Write message to show the change made *****/
Ale_CreateAlert (Ale_SUCCESS,NULL,
@ -588,14 +566,14 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
if (strcmp (CurrentLnkName,NewLnkName)) // Different names
{
/***** If link was in database... *****/
if (Lnk_CheckIfLinkNameExists (ParamName,NewLnkName,Lnk_EditingLnk->LnkCod))
if (Lnk_DB_CheckIfLinkNameExists (ParamName,NewLnkName,Lnk_EditingLnk->LnkCod))
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_link_X_already_exists,
NewLnkName);
else
{
/* Update the table changing old name by new name */
Lnk_UpdateLnkNameDB (Lnk_EditingLnk->LnkCod,FieldName,NewLnkName);
Lnk_DB_UpdateLnkName (Lnk_EditingLnk->LnkCod,FieldName,NewLnkName);
/* Write message to show the change made */
Ale_CreateAlert (Ale_SUCCESS,NULL,
@ -615,37 +593,6 @@ static void Lnk_RenameLink (Cns_ShrtOrFullName_t ShrtOrFullName)
Str_Copy (CurrentLnkName,NewLnkName,MaxBytes);
}
/*****************************************************************************/
/********************** 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 *****/
return (DB_QueryCOUNT ("can not check if the name of an institutional link"
" already existed",
"SELECT COUNT(*)"
" FROM lnk_links"
" WHERE %s='%s'"
" AND LnkCod<>%ld",
FieldName,Name,LnkCod) != 0);
}
/*****************************************************************************/
/************ 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 */
DB_QueryUPDATE ("can not update the name of an institutional link",
"UPDATE lnk_links"
" SET %s='%s'"
" WHERE LnkCod=%ld",
FieldName,NewLnkName,
LnkCod);
}
/*****************************************************************************/
/**************** Change the WWW of an institutional link ********************/
/*****************************************************************************/
@ -673,12 +620,7 @@ void Lnk_ChangeLinkWWW (void)
if (NewWWW[0])
{
/***** Update the table changing old WWW by new WWW *****/
DB_QueryUPDATE ("can not update the web of an institutional link",
"UPDATE lnk_links"
" SET WWW='%s'"
" WHERE LnkCod=%ld",
NewWWW,
Lnk_EditingLnk->LnkCod);
Lnk_DB_UpdateLnkWWW (Lnk_EditingLnk->LnkCod,NewWWW);
/***** Message to show the change made *****/
Ale_CreateAlert (Ale_SUCCESS,NULL,
@ -721,46 +663,46 @@ static void Lnk_PutFormToCreateLink (void)
/***** Begin form *****/
Frm_BeginForm (ActNewLnk);
/***** Begin box and table *****/
Box_BoxTableBegin (NULL,Txt_New_link,
NULL,NULL,
Hlp_SYSTEM_Links_edit,Box_NOT_CLOSABLE,2);
/***** Begin box and table *****/
Box_BoxTableBegin (NULL,Txt_New_link,
NULL,NULL,
Hlp_SYSTEM_Links_edit,Box_NOT_CLOSABLE,2);
/***** Write heading *****/
Lnk_PutHeadLinks ();
/***** Write heading *****/
Lnk_PutHeadLinks ();
HTM_TR_Begin (NULL);
HTM_TR_Begin (NULL);
/***** Link code *****/
HTM_TD_Begin ("class=\"BM\"");
HTM_TD_End ();
/***** Link code *****/
HTM_TD_Begin ("class=\"BM\"");
HTM_TD_End ();
HTM_TD_Empty (1);
HTM_TD_Empty (1);
/***** 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,
"class=\"INPUT_SHORT_NAME\" required=\"required\"");
HTM_TD_End ();
/***** 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,
"class=\"INPUT_SHORT_NAME\" required=\"required\"");
HTM_TD_End ();
/***** 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,
"class=\"INPUT_FULL_NAME\" required=\"required\"");
HTM_TD_End ();
/***** 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,
"class=\"INPUT_FULL_NAME\" required=\"required\"");
HTM_TD_End ();
/***** Link WWW *****/
HTM_TD_Begin ("class=\"CM\"");
HTM_INPUT_URL ("WWW",Lnk_EditingLnk->WWW,HTM_DONT_SUBMIT_ON_CHANGE,
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
HTM_TD_End ();
/***** Link WWW *****/
HTM_TD_Begin ("class=\"CM\"");
HTM_INPUT_URL ("WWW",Lnk_EditingLnk->WWW,HTM_DONT_SUBMIT_ON_CHANGE,
"class=\"INPUT_WWW_NARROW\" required=\"required\"");
HTM_TD_End ();
HTM_TR_End ();
HTM_TR_End ();
/***** End table, send button and end box *****/
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_link);
/***** End table, send button and end box *****/
Box_BoxTableWithButtonEnd (Btn_CREATE_BUTTON,Txt_Create_link);
/***** End form *****/
Frm_EndForm ();
@ -779,11 +721,11 @@ static void Lnk_PutHeadLinks (void)
HTM_TR_Begin (NULL);
HTM_TH (1,1,"BM",NULL);
HTM_TH (1,1,"RM",Txt_Code);
HTM_TH (1,1,"LM",Txt_Short_name);
HTM_TH (1,1,"LM",Txt_Full_name);
HTM_TH (1,1,"LM",Txt_WWW);
HTM_TH (1,1,"BM",NULL);
HTM_TH (1,1,"RM",Txt_Code);
HTM_TH (1,1,"LM",Txt_Short_name);
HTM_TH (1,1,"LM",Txt_Full_name);
HTM_TH (1,1,"LM",Txt_WWW);
HTM_TR_End ();
}
@ -816,11 +758,11 @@ void Lnk_ReceiveFormNewLink (void)
Lnk_EditingLnk->FullName[0]) // If there's a link name
{
/***** If name of link was in database... *****/
if (Lnk_CheckIfLinkNameExists ("ShortName",Lnk_EditingLnk->ShrtName,-1L))
if (Lnk_DB_CheckIfLinkNameExists ("ShortName",Lnk_EditingLnk->ShrtName,-1L))
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_link_X_already_exists,
Lnk_EditingLnk->ShrtName);
else if (Lnk_CheckIfLinkNameExists ("FullName",Lnk_EditingLnk->FullName,-1L))
else if (Lnk_DB_CheckIfLinkNameExists ("FullName",Lnk_EditingLnk->FullName,-1L))
Ale_CreateAlert (Ale_WARNING,NULL,
Txt_The_link_X_already_exists,
Lnk_EditingLnk->FullName);
@ -829,7 +771,7 @@ void Lnk_ReceiveFormNewLink (void)
Txt_You_must_specify_the_URL_of_the_new_link);
else // Add new link to database
{
Lnk_CreateLink (Lnk_EditingLnk);
Lnk_DB_CreateLink (Lnk_EditingLnk);
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_Created_new_link_X,
Lnk_EditingLnk->ShrtName);
@ -840,23 +782,6 @@ void Lnk_ReceiveFormNewLink (void)
Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_link);
}
/*****************************************************************************/
/**************************** Create a new link ******************************/
/*****************************************************************************/
static void Lnk_CreateLink (struct Link *Lnk)
{
/***** Create a new link *****/
DB_QueryINSERT ("can not create institutional link",
"INSERT INTO lnk_links"
" (ShortName,FullName,WWW)"
" VALUES"
" ('%s','%s','%s')",
Lnk->ShrtName,
Lnk->FullName,
Lnk->WWW);
}
/*****************************************************************************/
/************************* Place constructor/destructor **********************/
/*****************************************************************************/

170
swad_link_database.c Normal file
View File

@ -0,0 +1,170 @@
// swad_link_database.c: institutional links, operations with database
/*
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.
Copyright (C) 1999-2021 Antonio Cañas Vargas
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 <stddef.h> // For NULL
// #include <stdlib.h> // For calloc
// #include <string.h> // For string functions
// #include "swad_banner.h"
// #include "swad_box.h"
// #include "swad_constant.h"
#include "swad_database.h"
// #include "swad_error.h"
// #include "swad_form.h"
// #include "swad_global.h"
// #include "swad_HTML.h"
// #include "swad_language.h"
// #include "swad_link.h"
#include "swad_link_database.h"
// #include "swad_parameter.h"
/*****************************************************************************/
/************** External global variables from others modules ****************/
/*****************************************************************************/
// extern struct Globals Gbl;
/*****************************************************************************/
/***************************** Private constants *****************************/
/*****************************************************************************/
/*****************************************************************************/
/******************************* Private types *******************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private variables *****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
/*****************************************************************************/
/**************************** Create a new link ******************************/
/*****************************************************************************/
void Lnk_DB_CreateLink (const struct Link *Lnk)
{
DB_QueryINSERT ("can not create institutional link",
"INSERT INTO lnk_links"
" (ShortName,FullName,WWW)"
" VALUES"
" ('%s','%s','%s')",
Lnk->ShrtName,
Lnk->FullName,
Lnk->WWW);
}
/*****************************************************************************/
/************ Update link name in table of institutional links ***************/
/*****************************************************************************/
void Lnk_DB_UpdateLnkName (long LnkCod,const char *FieldName,const char *NewLnkName)
{
DB_QueryUPDATE ("can not update the name of an institutional link",
"UPDATE lnk_links"
" SET %s='%s'"
" WHERE LnkCod=%ld",
FieldName,NewLnkName,
LnkCod);
}
/*****************************************************************************/
/****************** Update link changing old WWW by new WWW ******************/
/*****************************************************************************/
void Lnk_DB_UpdateLnkWWW (long LnkCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1])
{
DB_QueryUPDATE ("can not update the web of an institutional link",
"UPDATE lnk_links"
" SET WWW='%s'"
" WHERE LnkCod=%ld",
NewWWW,
LnkCod);
}
/*****************************************************************************/
/************************** Get institutional links **************************/
/*****************************************************************************/
unsigned Lnk_DB_GetLinks (MYSQL_RES **mysql_res)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get institutional links",
"SELECT LnkCod," // row[0]
"ShortName," // row[1]
"FullName," // row[2]
"WWW" // row[3]
" FROM lnk_links"
" ORDER BY ShortName");
}
/*****************************************************************************/
/**************************** Get link full name *****************************/
/*****************************************************************************/
unsigned Lnk_DB_GetDataOfLinkByCod (MYSQL_RES **mysql_res,long LnkCod)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get data of an institutional link",
"SELECT ShortName," // row[0]
"FullName," // row[1]
"WWW" // row[2]
" FROM lnk_links"
" WHERE LnkCod=%ld",
LnkCod);
}
/*****************************************************************************/
/********************** Check if the name of link exists *********************/
/*****************************************************************************/
bool Lnk_DB_CheckIfLinkNameExists (const char *FieldName,const char *Name,long LnkCod)
{
return (DB_QueryCOUNT ("can not check if the name of an institutional link"
" already existed",
"SELECT COUNT(*)"
" FROM lnk_links"
" WHERE %s='%s'"
" AND LnkCod<>%ld",
FieldName,Name,
LnkCod) != 0);
}
/*****************************************************************************/
/******************************* Remove a link *******************************/
/*****************************************************************************/
void Lnk_DB_RemoveLink (long LnkCod)
{
DB_QueryDELETE ("can not remove an institutional link",
"DELETE FROM lnk_links"
" WHERE LnkCod=%ld",
LnkCod);
}

52
swad_link_database.h Normal file
View File

@ -0,0 +1,52 @@
// swad_link_database.h: institutional links, operations with database
#ifndef _SWAD_LNK_DB
#define _SWAD_LNK_DB
/*
SWAD (Shared Workspace At a Distance in Spanish),
is a web platform developed at the University of Granada (Spain),
and used to support university teaching.
This file is part of SWAD core.
Copyright (C) 1999-2021 Antonio Cañas Vargas
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 <mysql/mysql.h> // To access MySQL databases
#include "swad_link.h"
/*****************************************************************************/
/************************** Public types and constants ***********************/
/*****************************************************************************/
/*****************************************************************************/
/****************************** Public prototypes ****************************/
/*****************************************************************************/
void Lnk_DB_CreateLink (const struct Link *Lnk);
void Lnk_DB_UpdateLnkName (long LnkCod,const char *FieldName,const char *NewLnkName);
void Lnk_DB_UpdateLnkWWW (long LnkCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
unsigned Lnk_DB_GetLinks (MYSQL_RES **mysql_res);
unsigned Lnk_DB_GetDataOfLinkByCod (MYSQL_RES **mysql_res,long LnkCod);
bool Lnk_DB_CheckIfLinkNameExists (const char *FieldName,const char *Name,long LnkCod);
void Lnk_DB_RemoveLink (long LnkCod);
#endif

View File

@ -313,6 +313,22 @@ void Set_ChangeSideCols (void)
Set_SetSettingsFromIP ();
}
/*****************************************************************************/
/**************** Update my language to the current language *****************/
/*****************************************************************************/
void Set_DB_UpdateMySettingsAboutLanguage (void)
{
extern const char *Lan_STR_LANG_ID[1 + Lan_NUM_LANGUAGES];
DB_QueryUPDATE ("can not update your language",
"UPDATE usr_data"
" SET Language='%s'"
" WHERE UsrCod=%ld",
Lan_STR_LANG_ID[Gbl.Prefs.Language],
Gbl.Usrs.Me.UsrDat.UsrCod);
}
/*****************************************************************************/
/************** Update layout of side colums on user data table **************/
/*****************************************************************************/

View File

@ -50,6 +50,7 @@ void Set_RemoveOldSettingsFromIP (void);
void Set_ChangeSideCols (void);
unsigned Set_GetParamSideCols (void);
void Set_DB_UpdateMySettingsAboutLanguage (void);
void Set_DB_UpdateMySettingsAboutDateFormat (Dat_Format_t DateFormat);
void Set_DB_ChangeFirstDayOfWeek (unsigned FirstDayOfWeek);
void Set_DB_ChangeIconSet (const char *IconSetId);