mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-05 00:05:23 +02:00
Version19.106
This commit is contained in:
parent
53dada0fc0
commit
ac108860a7
3
Makefile
3
Makefile
|
@ -31,7 +31,8 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \
|
|||
swad_banner.o swad_box.o swad_button.o \
|
||||
swad_calendar.o swad_centre.o swad_centre_config.o swad_chat.o \
|
||||
swad_classroom.o swad_config.o swad_connected.o swad_cookie.o \
|
||||
swad_country.o swad_course.o swad_course_config.o swad_cryptography.o \
|
||||
swad_country.o swad_country_config.o swad_course.o \
|
||||
swad_course_config.o swad_cryptography.o \
|
||||
swad_database.o swad_date.o swad_degree.o swad_degree_config.o \
|
||||
swad_degree_type.o swad_department.o swad_duplicate.o \
|
||||
swad_enrolment.o swad_exam.o \
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "swad_config.h"
|
||||
#include "swad_cookie.h"
|
||||
#include "swad_country.h"
|
||||
#include "swad_country_config.h"
|
||||
#include "swad_course.h"
|
||||
#include "swad_course_config.h"
|
||||
#include "swad_chat.h"
|
||||
|
@ -1763,12 +1764,12 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
|
||||
// TabCty ******************************************************************
|
||||
// Actions in menu:
|
||||
[ActSeeCtyInf ] = {1155, 0,TabCty,ActSeeCtyInf , 0, 0, 0, 0, 0,0x3C7, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cty_ShowConfiguration ,"info" },
|
||||
[ActSeeCtyInf ] = {1155, 0,TabCty,ActSeeCtyInf , 0, 0, 0, 0, 0,0x3C7, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtyCfg_ShowConfiguration ,"info" },
|
||||
[ActSeeIns ] = { 696, 1,TabCty,ActSeeIns , 0, 0, 0, 0, 0,0x3C7, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Ins_ShowInssOfCurrentCty ,"university" },
|
||||
|
||||
// Actions not in menu:
|
||||
[ActPrnCtyInf ] = {1156,-1,TabUnk,ActSeeCtyInf , 0, 0, 0, 0, 0,0x3C7, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Cty_PrintConfiguration ,NULL},
|
||||
[ActChgCtyMapAtt ] = {1158,-1,TabUnk,ActSeeCtyInf , 0, 0, 0, 0, 0,0x200, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cty_ChangeCtyMapAttribution ,NULL},
|
||||
[ActPrnCtyInf ] = {1156,-1,TabUnk,ActSeeCtyInf , 0, 0, 0, 0, 0,0x3C7, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,CtyCfg_PrintConfiguration ,NULL},
|
||||
[ActChgCtyMapAtt ] = {1158,-1,TabUnk,ActSeeCtyInf , 0, 0, 0, 0, 0,0x200, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtyCfg_ChangeCtyMapAttr ,NULL},
|
||||
|
||||
[ActEdiIns ] = { 697,-1,TabUnk,ActSeeIns , 0, 0, 0, 0, 0,0x3C6, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Ins_EditInstitutions ,NULL},
|
||||
[ActReqIns ] = {1210,-1,TabUnk,ActSeeIns , 0, 0, 0, 0, 0,0x3C6, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Ins_RecFormReqIns ,Ins_ContEditAfterChgIns ,NULL},
|
||||
|
@ -1781,7 +1782,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
|
||||
// TabIns ******************************************************************
|
||||
// Actions in menu:
|
||||
[ActSeeInsInf ] = {1153, 0,TabIns,ActSeeInsInf , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,InsCfg_ShowConfiguration ,"info" },
|
||||
[ActSeeInsInf ] = {1153, 0,TabIns,ActSeeInsInf , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,InsCfg_ShowConfiguration ,"info" },
|
||||
[ActSeeCtr ] = { 676, 1,TabIns,ActSeeCtr , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Ctr_ShowCtrsOfCurrentIns ,"building" },
|
||||
[ActSeePlc ] = { 703, 2,TabIns,ActSeePlc , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plc_SeePlaces ,"map-marker-alt" },
|
||||
[ActSeeDpt ] = { 675, 3,TabIns,ActSeeDpt , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Dpt_SeeDepts ,"users" },
|
||||
|
@ -1832,7 +1833,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
|
||||
// TabCtr ******************************************************************
|
||||
// Actions in menu:
|
||||
[ActSeeCtrInf ] = {1151, 0,TabCtr,ActSeeCtrInf , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ShowConfiguration ,"info" },
|
||||
[ActSeeCtrInf ] = {1151, 0,TabCtr,ActSeeCtrInf , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ShowConfiguration ,"info" },
|
||||
[ActSeeDeg ] = {1011, 1,TabCtr,ActSeeDeg , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Deg_ShowDegsOfCurrentCtr ,"graduation-cap" },
|
||||
[ActSeeCla ] = {1744, 2,TabCtr,ActSeeCla , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cla_SeeClassrooms ,"classroom" },
|
||||
|
||||
|
@ -1851,7 +1852,7 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] =
|
|||
[ActRemCtrLog ] = {1342,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,CtrCfg_RemoveLogo ,CtrCfg_ShowConfiguration ,NULL},
|
||||
[ActReqCtrPho ] = {1160,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_RequestPhoto ,NULL},
|
||||
[ActRecCtrPho ] = {1161,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,CtrCfg_ReceivePhoto ,NULL},
|
||||
[ActChgCtrPhoAtt ] = {1159,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrPhotoAttribution,NULL},
|
||||
[ActChgCtrPhoAtt ] = {1159,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrPhotoAttr ,NULL},
|
||||
|
||||
[ActSeeDegTyp ] = {1013,-1,TabUnk,ActSeeDeg , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,DT_SeeDegreeTypesInDegTab ,NULL},
|
||||
[ActEdiDegTyp ] = { 573,-1,TabUnk,ActSeeDeg , 0, 0, 0,0x200, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,DT_EditDegreeTypes ,NULL},
|
||||
|
|
|
@ -82,8 +82,8 @@ static void CtrCfg_Longitude (void);
|
|||
static void CtrCfg_Altitude (void);
|
||||
static void CtrCfg_Photo (bool PrintView,bool PutForm,bool PutLink,
|
||||
const char PathPhoto[PATH_MAX + 1]);
|
||||
static void CtrCfg_GetPhotoAttribution (long CtrCod,char **PhotoAttribution);
|
||||
static void CtrCfg_FreePhotoAttribution (char **PhotoAttribution);
|
||||
static void CtrCfg_GetPhotoAttr (long CtrCod,char **PhotoAttribution);
|
||||
static void CtrCfg_FreePhotoAttr (char **PhotoAttribution);
|
||||
static void CtrCfg_Institution (bool PrintView,bool PutForm);
|
||||
static void CtrCfg_FullName (bool PutForm);
|
||||
static void CtrCfg_ShrtName (bool PutForm);
|
||||
|
@ -484,7 +484,7 @@ static void CtrCfg_Photo (bool PrintView,bool PutForm,bool PutLink,
|
|||
return;
|
||||
|
||||
/***** Get photo attribution *****/
|
||||
CtrCfg_GetPhotoAttribution (Gbl.Hierarchy.Ctr.CtrCod,&PhotoAttribution);
|
||||
CtrCfg_GetPhotoAttr (Gbl.Hierarchy.Ctr.CtrCod,&PhotoAttribution);
|
||||
|
||||
/***** Photo image *****/
|
||||
HTM_DIV_Begin ("class=\"DAT_SMALL CM\"");
|
||||
|
@ -530,21 +530,21 @@ static void CtrCfg_Photo (bool PrintView,bool PutForm,bool PutLink,
|
|||
}
|
||||
|
||||
/****** Free memory used for photo attribution ******/
|
||||
CtrCfg_FreePhotoAttribution (&PhotoAttribution);
|
||||
CtrCfg_FreePhotoAttr (&PhotoAttribution);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Get photo attribution from database *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtrCfg_GetPhotoAttribution (long CtrCod,char **PhotoAttribution)
|
||||
static void CtrCfg_GetPhotoAttr (long CtrCod,char **PhotoAttribution)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
size_t Length;
|
||||
|
||||
/***** Free possible former photo attribution *****/
|
||||
CtrCfg_FreePhotoAttribution (PhotoAttribution);
|
||||
CtrCfg_FreePhotoAttr (PhotoAttribution);
|
||||
|
||||
/***** Get photo attribution from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get photo attribution",
|
||||
|
@ -575,7 +575,7 @@ static void CtrCfg_GetPhotoAttribution (long CtrCod,char **PhotoAttribution)
|
|||
/****************** Free memory used for photo attribution *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtrCfg_FreePhotoAttribution (char **PhotoAttribution)
|
||||
static void CtrCfg_FreePhotoAttr (char **PhotoAttribution)
|
||||
{
|
||||
if (*PhotoAttribution)
|
||||
{
|
||||
|
@ -1050,7 +1050,7 @@ void CtrCfg_ReceivePhoto (void)
|
|||
/**************** Change the attribution of a centre photo *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void CtrCfg_ChangeCtrPhotoAttribution (void)
|
||||
void CtrCfg_ChangeCtrPhotoAttr (void)
|
||||
{
|
||||
char NewPhotoAttribution[Med_MAX_BYTES_ATTRIBUTION + 1];
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ void CtrCfg_ReceiveLogo (void);
|
|||
void CtrCfg_RemoveLogo (void);
|
||||
void CtrCfg_RequestPhoto (void);
|
||||
void CtrCfg_ReceivePhoto (void);
|
||||
void CtrCfg_ChangeCtrPhotoAttribution (void);
|
||||
void CtrCfg_ChangeCtrPhotoAttr (void);
|
||||
void CtrCfg_ChangeCtrIns (void);
|
||||
void CtrCfg_RenameCentreShort (void);
|
||||
void CtrCfg_RenameCentreFull (void);
|
||||
|
|
|
@ -492,7 +492,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - *
|
|||
En OpenSWAD:
|
||||
ps2pdf source.ps destination.pdf
|
||||
*/
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.104.2 (2019-12-29)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 19.106 (2019-12-29)"
|
||||
#define CSS_FILE "swad19.101.5.css"
|
||||
#define JS_FILE "swad19.91.1.js"
|
||||
/*
|
||||
|
@ -502,7 +502,8 @@ ps2pdf source.ps destination.pdf
|
|||
|
||||
Version 19.10x: Dec 29, 2019 Map in country information. (? lines)
|
||||
Version 19.10x: Dec 29, 2019 Map in institution information. (? lines)
|
||||
Version 19.105: Dec 29, 2019 New module swad_institution_config for insitution configuration. (249614 lines)
|
||||
Version 19.106: Dec 29, 2019 New module swad_country_config for country configuration. (249683 lines)
|
||||
Version 19.105: Dec 29, 2019 New module swad_institution_config for institution configuration. (249614 lines)
|
||||
Version 19.104.2: Dec 29, 2019 Code refactoring in degree configuration. (249541 lines)
|
||||
Version 19.104.1: Dec 29, 2019 Code refactoring in course configuration. (249536 lines)
|
||||
Version 19.104: Dec 29, 2019 New module swad_centre_config for centre configuration. (249534 lines)
|
||||
|
|
491
swad_country.c
491
swad_country.c
|
@ -26,24 +26,16 @@
|
|||
/*****************************************************************************/
|
||||
|
||||
#define _GNU_SOURCE // For asprintf
|
||||
#include <math.h> // For log10, ceil, pow...
|
||||
#include <stdbool.h> // For boolean type
|
||||
#include <stddef.h> // For NULL
|
||||
#include <stdio.h> // For asprintf
|
||||
#include <stdlib.h> // For calloc
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_box.h"
|
||||
#include "swad_constant.h"
|
||||
#include "swad_country.h"
|
||||
#include "swad_country_config.h"
|
||||
#include "swad_database.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_help.h"
|
||||
#include "swad_HTML.h"
|
||||
#include "swad_institution.h"
|
||||
#include "swad_language.h"
|
||||
#include "swad_QR.h"
|
||||
#include "swad_setting.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
|
@ -70,25 +62,9 @@ long Cty_CurrentCtyCod = -1L; // Used as parameter in contextual links
|
|||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_Configuration (bool PrintView);
|
||||
static void Cty_PutIconToPrint (void);
|
||||
static void Cty_ConfigTitle (bool PutLink);
|
||||
static void Cty_ConfigMap (bool PrintView,bool PutLink);
|
||||
static void Cty_ConfigName (bool PutLink);
|
||||
static void Cty_ConfigShortcut (bool PrintView);
|
||||
static void Cty_ConfigQR (void);
|
||||
static void Cty_ConfigNumUsrs (void);
|
||||
static void Cty_ConfigNumInss (void);
|
||||
static void Cty_ConfigNumCtrs (void);
|
||||
static void Cty_ConfigNumDegs (void);
|
||||
static void Cty_ConfigNumCrss (void);
|
||||
static void Cty_ShowNumUsrsInCrssOfCty (Rol_Role_t Role);
|
||||
|
||||
static void Cty_PutHeadCountriesForSeeing (bool OrderSelectable);
|
||||
static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty);
|
||||
|
||||
static bool Cty_CheckIfICanEditCountries (void);
|
||||
|
||||
static void Cty_PutIconsListingCountries (void);
|
||||
static void Cty_PutIconToEditCountries (void);
|
||||
|
||||
|
@ -99,8 +75,6 @@ static void Cty_EditCountriesInternal (void);
|
|||
static void Cty_PutIconsEditingCountries (void);
|
||||
static void Cty_PutIconToViewCountries (void);
|
||||
|
||||
static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution);
|
||||
static void Cty_FreeMapAttribution (char **MapAttribution);
|
||||
static void Cty_ListCountriesForEdition (void);
|
||||
static void Cty_PutParamOtherCtyCod (long CtyCod);
|
||||
static long Cty_GetParamOtherCtyCod (void);
|
||||
|
@ -218,377 +192,6 @@ void Cty_SeeCtyWithPendingInss (void)
|
|||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Show information of the current country *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Cty_ShowConfiguration (void)
|
||||
{
|
||||
Cty_Configuration (false);
|
||||
|
||||
/***** Show help to enrol me *****/
|
||||
Hlp_ShowHelpWhatWouldYouLikeToDo ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Print information of the current country ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Cty_PrintConfiguration (void)
|
||||
{
|
||||
Cty_Configuration (true);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Information of the current country *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_Configuration (bool PrintView)
|
||||
{
|
||||
extern const char *Hlp_COUNTRY_Information;
|
||||
bool PutLink;
|
||||
bool MapExists;
|
||||
|
||||
/***** Trivial check *****/
|
||||
if (Gbl.Hierarchy.Cty.CtyCod <= 0) // No country selected
|
||||
return;
|
||||
|
||||
/***** Initializations *****/
|
||||
PutLink = !PrintView && Gbl.Hierarchy.Cty.WWW[Gbl.Prefs.Language][0];
|
||||
|
||||
/***** Begin box *****/
|
||||
if (PrintView)
|
||||
Box_BoxBegin (NULL,NULL,NULL,
|
||||
NULL,Box_NOT_CLOSABLE);
|
||||
else
|
||||
Box_BoxBegin (NULL,NULL,Cty_PutIconToPrint,
|
||||
Hlp_COUNTRY_Information,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Title *****/
|
||||
Cty_ConfigTitle (PutLink);
|
||||
|
||||
/**************************** Left part ***********************************/
|
||||
HTM_DIV_Begin ("class=\"HIE_CFG_LEFT\"");
|
||||
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginWidePadding (2);
|
||||
|
||||
/***** Country name (an link to WWW if exists) *****/
|
||||
Cty_ConfigName (PutLink);
|
||||
|
||||
/***** Shortcut to the country *****/
|
||||
Cty_ConfigShortcut (PrintView);
|
||||
|
||||
if (PrintView)
|
||||
/***** QR code with link to the country *****/
|
||||
Cty_ConfigQR ();
|
||||
else
|
||||
{
|
||||
/***** Number of users who claim to belong to this centre,
|
||||
number of institutions,
|
||||
number of centres,
|
||||
number of degrees,
|
||||
number of courses *****/
|
||||
Cty_ConfigNumUsrs ();
|
||||
Cty_ConfigNumInss ();
|
||||
Cty_ConfigNumCtrs ();
|
||||
Cty_ConfigNumDegs ();
|
||||
Cty_ConfigNumCrss ();
|
||||
|
||||
/***** Number of users in courses of this country *****/
|
||||
Cty_ShowNumUsrsInCrssOfCty (Rol_TCH);
|
||||
Cty_ShowNumUsrsInCrssOfCty (Rol_NET);
|
||||
Cty_ShowNumUsrsInCrssOfCty (Rol_STD);
|
||||
Cty_ShowNumUsrsInCrssOfCty (Rol_UNK);
|
||||
}
|
||||
|
||||
/***** End table *****/
|
||||
HTM_TABLE_End ();
|
||||
|
||||
/***** End of left part *****/
|
||||
HTM_DIV_End ();
|
||||
|
||||
/**************************** Right part **********************************/
|
||||
/***** Check map *****/
|
||||
MapExists = Cty_CheckIfCountryMapExists (&Gbl.Hierarchy.Cty);
|
||||
|
||||
if (MapExists)
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT\"");
|
||||
|
||||
/***** Country map *****/
|
||||
Cty_ConfigMap (PrintView,PutLink);
|
||||
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
|
||||
/***** End box *****/
|
||||
Box_BoxEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Put icon to print the configuration of a country **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_PutIconToPrint (void)
|
||||
{
|
||||
Ico_PutContextualIconToPrint (ActPrnCtyInf,NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Show title in country configuration ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ConfigTitle (bool PutLink)
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"FRAME_TITLE FRAME_TITLE_BIG\"");
|
||||
if (PutLink)
|
||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\""
|
||||
" class=\"FRAME_TITLE_BIG\" title=\"%s\"",
|
||||
Gbl.Hierarchy.Cty.WWW[Gbl.Prefs.Language],
|
||||
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
|
||||
HTM_Txt (Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
|
||||
if (PutLink)
|
||||
HTM_A_End ();
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Show map in country configuration *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ConfigMap (bool PrintView,bool PutLink)
|
||||
{
|
||||
char *MapAttribution = NULL;
|
||||
|
||||
/***** Get map attribution *****/
|
||||
Cty_GetMapAttribution (Gbl.Hierarchy.Cty.CtyCod,&MapAttribution);
|
||||
|
||||
/***** Map image *****/
|
||||
HTM_DIV_Begin ("class=\"DAT_SMALL CM\"");
|
||||
if (PutLink)
|
||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",
|
||||
Gbl.Hierarchy.Cty.WWW[Gbl.Prefs.Language]);
|
||||
Cty_DrawCountryMap (&Gbl.Hierarchy.Cty,PrintView ? "COUNTRY_MAP_PRINT" :
|
||||
"COUNTRY_MAP_SHOW");
|
||||
if (PutLink)
|
||||
HTM_A_End ();
|
||||
HTM_DIV_End ();
|
||||
|
||||
/***** Map attribution *****/
|
||||
if (!PrintView && Cty_CheckIfICanEditCountries ())
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"CM\"");
|
||||
Frm_StartForm (ActChgCtyMapAtt);
|
||||
HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\" rows=\"3\""
|
||||
" onchange=\"document.getElementById('%s').submit();return false;\"",
|
||||
Gbl.Form.Id);
|
||||
if (MapAttribution)
|
||||
HTM_Txt (MapAttribution);
|
||||
HTM_TEXTAREA_End ();
|
||||
Frm_EndForm ();
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
else if (MapAttribution)
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"ATTRIBUTION\"");
|
||||
HTM_Txt (MapAttribution);
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
|
||||
/***** Free memory used for map attribution *****/
|
||||
Cty_FreeMapAttribution (&MapAttribution);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Show country name in country configuration *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ConfigName (bool PutLink)
|
||||
{
|
||||
extern const char *Txt_Country;
|
||||
|
||||
/***** Country name *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Country);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT_N LB\"");
|
||||
if (PutLink)
|
||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT_N\"",
|
||||
Gbl.Hierarchy.Cty.WWW[Gbl.Prefs.Language]);
|
||||
HTM_Txt (Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
|
||||
if (PutLink)
|
||||
HTM_A_End ();
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Show country shortcut in country configuration ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ConfigShortcut (bool PrintView)
|
||||
{
|
||||
Hie_ConfigShortcut (PrintView,"cty",Gbl.Hierarchy.Cty.CtyCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Show country QR in country configuration ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ConfigQR (void)
|
||||
{
|
||||
Hie_ConfigQR ("cty",Gbl.Hierarchy.Cty.CtyCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Show number of users who claim to belong to country in country config. **/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ConfigNumUsrs (void)
|
||||
{
|
||||
extern const char *Txt_Users_of_the_country;
|
||||
|
||||
/***** Number of users *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Users_of_the_country);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToCty (Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Show number of institutions in country configuration ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ConfigNumInss (void)
|
||||
{
|
||||
extern const char *Txt_Institutions;
|
||||
extern const char *Txt_Institutions_of_COUNTRY_X;
|
||||
|
||||
/***** Number of institutions ******/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Institutions);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"LB\"");
|
||||
Frm_StartFormGoTo (ActSeeIns);
|
||||
Cty_PutParamCtyCod (Gbl.Hierarchy.Cty.CtyCod);
|
||||
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
||||
Txt_Institutions_of_COUNTRY_X,
|
||||
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
|
||||
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK DAT",NULL);
|
||||
HTM_Unsigned (Ins_GetNumInssInCty (Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_BUTTON_End ();
|
||||
Frm_EndForm ();
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Show number of centres in country configuration ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ConfigNumCtrs (void)
|
||||
{
|
||||
extern const char *Txt_Centres;
|
||||
|
||||
/***** Number of centres *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Centres);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Ctr_GetNumCtrsInCty (Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Show number of degrees in country configuration ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ConfigNumDegs (void)
|
||||
{
|
||||
extern const char *Txt_Degrees;
|
||||
|
||||
/***** Number of degrees *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Degrees);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Deg_GetNumDegsInCty (Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Show number of courses in country configuration ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ConfigNumCrss (void)
|
||||
{
|
||||
extern const char *Txt_Courses;
|
||||
|
||||
/***** Number of courses *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Courses);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Crs_GetNumCrssInCty (Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Number of users in courses of this country *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ShowNumUsrsInCrssOfCty (Rol_Role_t Role)
|
||||
{
|
||||
extern const char *Txt_Users_in_courses;
|
||||
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||
|
||||
/***** Number of users in courses *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,
|
||||
Role == Rol_UNK ? Txt_Users_in_courses :
|
||||
Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN]);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Usr_GetNumUsrsInCrssOfCty (Role,Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************************** List all the countries **************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -841,15 +444,6 @@ static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty)
|
|||
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Check if I can edit countries ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static bool Cty_CheckIfICanEditCountries (void)
|
||||
{
|
||||
return (bool) (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Put contextual icons in list of countries *****************/
|
||||
/*****************************************************************************/
|
||||
|
@ -865,6 +459,15 @@ static void Cty_PutIconsListingCountries (void)
|
|||
Fig_PutIconToShowFigure ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Check if I can edit countries ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
bool Cty_CheckIfICanEditCountries (void)
|
||||
{
|
||||
return (bool) (Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Put icon to edit countries *************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -1613,56 +1216,6 @@ void Cty_GetCountryName (long CtyCod,char CtyName[Cty_MAX_BYTES_NAME + 1])
|
|||
Cty_MAX_BYTES_NAME);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Get map attribution from database **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
size_t Length;
|
||||
|
||||
/***** Free possible former map attribution *****/
|
||||
Cty_FreeMapAttribution (MapAttribution);
|
||||
|
||||
/***** Get photo attribution from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get photo attribution",
|
||||
"SELECT MapAttribution FROM countries WHERE CtyCod=%ld",
|
||||
CtyCod))
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get the attribution of the map of the country (row[0]) */
|
||||
if (row[0])
|
||||
if (row[0][0])
|
||||
{
|
||||
Length = strlen (row[0]);
|
||||
if ((*MapAttribution = (char *) malloc (Length + 1)) == NULL)
|
||||
Lay_ShowErrorAndExit ("Error allocating memory for map attribution.");
|
||||
Str_Copy (*MapAttribution,row[0],
|
||||
Length);
|
||||
}
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Free memory used for map attribution ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_FreeMapAttribution (char **MapAttribution)
|
||||
{
|
||||
if (*MapAttribution)
|
||||
{
|
||||
free (*MapAttribution);
|
||||
*MapAttribution = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*************************** Free list of countries **************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -2033,28 +1586,6 @@ void Cty_ChangeCtyWWW (void)
|
|||
NewWWW);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Change the attribution of the map of current country ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void Cty_ChangeCtyMapAttribution (void)
|
||||
{
|
||||
char NewMapAttribution[Med_MAX_BYTES_ATTRIBUTION + 1];
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Get the new map attribution for the country */
|
||||
Par_GetParToText ("Attribution",NewMapAttribution,Med_MAX_BYTES_ATTRIBUTION);
|
||||
|
||||
/***** Update the table changing old attribution by new attribution *****/
|
||||
DB_QueryUPDATE ("can not update the map attribution of a country",
|
||||
"UPDATE countries SET MapAttribution='%s'"
|
||||
" WHERE CtyCod='%03ld'",
|
||||
NewMapAttribution,Gbl.Hierarchy.Cty.CtyCod);
|
||||
|
||||
/***** Show the country information again *****/
|
||||
Cty_ShowConfiguration ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********* Show alerts after changing a country and continue editing *********/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -84,13 +84,12 @@ typedef enum
|
|||
|
||||
void Cty_SeeCtyWithPendingInss (void);
|
||||
|
||||
void Cty_ShowConfiguration (void);
|
||||
void Cty_PrintConfiguration (void);
|
||||
|
||||
void Cty_ListCountries (void);
|
||||
void Cty_ListCountries1 (void);
|
||||
void Cty_ListCountries2 (void);
|
||||
|
||||
bool Cty_CheckIfICanEditCountries (void);
|
||||
|
||||
void Cty_DrawCountryMapAndNameWithLink (struct Country *Cty,Act_Action_t Action,
|
||||
const char *ClassContainer,
|
||||
const char *ClassMap,
|
||||
|
@ -113,7 +112,6 @@ long Cty_GetAndCheckParamOtherCtyCod (long MinCodAllowed);
|
|||
void Cty_RemoveCountry (void);
|
||||
void Cty_RenameCountry (void);
|
||||
void Cty_ChangeCtyWWW (void);
|
||||
void Cty_ChangeCtyMapAttribution (void);
|
||||
void Cty_ContEditAfterChgCty (void);
|
||||
void Cty_RecFormNewCountry (void);
|
||||
|
||||
|
|
518
swad_country_config.c
Normal file
518
swad_country_config.c
Normal file
|
@ -0,0 +1,518 @@
|
|||
// swad_country_config.c: configuration of current country
|
||||
|
||||
/*
|
||||
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-2019 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 <stdbool.h> // For boolean type
|
||||
#include <stddef.h> // For NULL
|
||||
#include <string.h> // For string functions
|
||||
|
||||
#include "swad_database.h"
|
||||
#include "swad_form.h"
|
||||
#include "swad_global.h"
|
||||
#include "swad_help.h"
|
||||
#include "swad_HTML.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** External global variables from others modules ****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
extern struct Globals Gbl;
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************************* Private types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private variables *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Private prototypes ****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_Configuration (bool PrintView);
|
||||
static void CtyCfg_PutIconToPrint (void);
|
||||
static void CtyCfg_Title (bool PutLink);
|
||||
static void CtyCfg_Map (bool PrintView,bool PutLink);
|
||||
static void CtyCfg_Name (bool PutLink);
|
||||
static void CtyCfg_Shortcut (bool PrintView);
|
||||
static void CtyCfg_QR (void);
|
||||
static void CtyCfg_NumUsrs (void);
|
||||
static void CtyCfg_NumInss (void);
|
||||
static void CtyCfg_NumCtrs (void);
|
||||
static void CtyCfg_NumDegs (void);
|
||||
static void CtyCfg_NumCrss (void);
|
||||
static void CtyCfg_NumUsrsInCrssOfCty (Rol_Role_t Role);
|
||||
|
||||
static void CtyCfg_GetMapAttr (long CtyCod,char **MapAttribution);
|
||||
static void CtyCfg_FreeMapAttr (char **MapAttribution);
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Show information of the current country *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void CtyCfg_ShowConfiguration (void)
|
||||
{
|
||||
CtyCfg_Configuration (false);
|
||||
|
||||
/***** Show help to enrol me *****/
|
||||
Hlp_ShowHelpWhatWouldYouLikeToDo ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Print information of the current country ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void CtyCfg_PrintConfiguration (void)
|
||||
{
|
||||
CtyCfg_Configuration (true);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Information of the current country *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_Configuration (bool PrintView)
|
||||
{
|
||||
extern const char *Hlp_COUNTRY_Information;
|
||||
bool PutLink;
|
||||
bool MapExists;
|
||||
|
||||
/***** Trivial check *****/
|
||||
if (Gbl.Hierarchy.Cty.CtyCod <= 0) // No country selected
|
||||
return;
|
||||
|
||||
/***** Initializations *****/
|
||||
PutLink = !PrintView && Gbl.Hierarchy.Cty.WWW[Gbl.Prefs.Language][0];
|
||||
|
||||
/***** Begin box *****/
|
||||
if (PrintView)
|
||||
Box_BoxBegin (NULL,NULL,NULL,
|
||||
NULL,Box_NOT_CLOSABLE);
|
||||
else
|
||||
Box_BoxBegin (NULL,NULL,CtyCfg_PutIconToPrint,
|
||||
Hlp_COUNTRY_Information,Box_NOT_CLOSABLE);
|
||||
|
||||
/***** Title *****/
|
||||
CtyCfg_Title (PutLink);
|
||||
|
||||
/**************************** Left part ***********************************/
|
||||
HTM_DIV_Begin ("class=\"HIE_CFG_LEFT\"");
|
||||
|
||||
/***** Begin table *****/
|
||||
HTM_TABLE_BeginWidePadding (2);
|
||||
|
||||
/***** Country name (an link to WWW if exists) *****/
|
||||
CtyCfg_Name (PutLink);
|
||||
|
||||
/***** Shortcut to the country *****/
|
||||
CtyCfg_Shortcut (PrintView);
|
||||
|
||||
if (PrintView)
|
||||
/***** QR code with link to the country *****/
|
||||
CtyCfg_QR ();
|
||||
else
|
||||
{
|
||||
/***** Number of users who claim to belong to this centre,
|
||||
number of institutions,
|
||||
number of centres,
|
||||
number of degrees,
|
||||
number of courses *****/
|
||||
CtyCfg_NumUsrs ();
|
||||
CtyCfg_NumInss ();
|
||||
CtyCfg_NumCtrs ();
|
||||
CtyCfg_NumDegs ();
|
||||
CtyCfg_NumCrss ();
|
||||
|
||||
/***** Number of users in courses of this country *****/
|
||||
CtyCfg_NumUsrsInCrssOfCty (Rol_TCH);
|
||||
CtyCfg_NumUsrsInCrssOfCty (Rol_NET);
|
||||
CtyCfg_NumUsrsInCrssOfCty (Rol_STD);
|
||||
CtyCfg_NumUsrsInCrssOfCty (Rol_UNK);
|
||||
}
|
||||
|
||||
/***** End table *****/
|
||||
HTM_TABLE_End ();
|
||||
|
||||
/***** End of left part *****/
|
||||
HTM_DIV_End ();
|
||||
|
||||
/**************************** Right part **********************************/
|
||||
/***** Check map *****/
|
||||
MapExists = Cty_CheckIfCountryMapExists (&Gbl.Hierarchy.Cty);
|
||||
|
||||
if (MapExists)
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT\"");
|
||||
|
||||
/***** Country map *****/
|
||||
CtyCfg_Map (PrintView,PutLink);
|
||||
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
|
||||
/***** End box *****/
|
||||
Box_BoxEnd ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Put icon to print the configuration of a country **************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_PutIconToPrint (void)
|
||||
{
|
||||
Ico_PutContextualIconToPrint (ActPrnCtyInf,NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Show title in country configuration ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_Title (bool PutLink)
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"FRAME_TITLE FRAME_TITLE_BIG\"");
|
||||
if (PutLink)
|
||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\""
|
||||
" class=\"FRAME_TITLE_BIG\" title=\"%s\"",
|
||||
Gbl.Hierarchy.Cty.WWW[Gbl.Prefs.Language],
|
||||
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
|
||||
HTM_Txt (Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
|
||||
if (PutLink)
|
||||
HTM_A_End ();
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************* Show map in country configuration *********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_Map (bool PrintView,bool PutLink)
|
||||
{
|
||||
char *MapAttribution = NULL;
|
||||
|
||||
/***** Get map attribution *****/
|
||||
CtyCfg_GetMapAttr (Gbl.Hierarchy.Cty.CtyCod,&MapAttribution);
|
||||
|
||||
/***** Map image *****/
|
||||
HTM_DIV_Begin ("class=\"DAT_SMALL CM\"");
|
||||
if (PutLink)
|
||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\"",
|
||||
Gbl.Hierarchy.Cty.WWW[Gbl.Prefs.Language]);
|
||||
Cty_DrawCountryMap (&Gbl.Hierarchy.Cty,PrintView ? "COUNTRY_MAP_PRINT" :
|
||||
"COUNTRY_MAP_SHOW");
|
||||
if (PutLink)
|
||||
HTM_A_End ();
|
||||
HTM_DIV_End ();
|
||||
|
||||
/***** Map attribution *****/
|
||||
if (!PrintView && Cty_CheckIfICanEditCountries ())
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"CM\"");
|
||||
Frm_StartForm (ActChgCtyMapAtt);
|
||||
HTM_TEXTAREA_Begin ("id=\"AttributionArea\" name=\"Attribution\" rows=\"3\""
|
||||
" onchange=\"document.getElementById('%s').submit();return false;\"",
|
||||
Gbl.Form.Id);
|
||||
if (MapAttribution)
|
||||
HTM_Txt (MapAttribution);
|
||||
HTM_TEXTAREA_End ();
|
||||
Frm_EndForm ();
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
else if (MapAttribution)
|
||||
{
|
||||
HTM_DIV_Begin ("class=\"ATTRIBUTION\"");
|
||||
HTM_Txt (MapAttribution);
|
||||
HTM_DIV_End ();
|
||||
}
|
||||
|
||||
/***** Free memory used for map attribution *****/
|
||||
CtyCfg_FreeMapAttr (&MapAttribution);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Show country name in country configuration *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_Name (bool PutLink)
|
||||
{
|
||||
extern const char *Txt_Country;
|
||||
|
||||
/***** Country name *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Country);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT_N LB\"");
|
||||
if (PutLink)
|
||||
HTM_A_Begin ("href=\"%s\" target=\"_blank\" class=\"DAT_N\"",
|
||||
Gbl.Hierarchy.Cty.WWW[Gbl.Prefs.Language]);
|
||||
HTM_Txt (Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
|
||||
if (PutLink)
|
||||
HTM_A_End ();
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************** Show country shortcut in country configuration ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_Shortcut (bool PrintView)
|
||||
{
|
||||
Hie_ConfigShortcut (PrintView,"cty",Gbl.Hierarchy.Cty.CtyCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************** Show country QR in country configuration ******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_QR (void)
|
||||
{
|
||||
Hie_ConfigQR ("cty",Gbl.Hierarchy.Cty.CtyCod);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*** Show number of users who claim to belong to country in country config. **/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_NumUsrs (void)
|
||||
{
|
||||
extern const char *Txt_Users_of_the_country;
|
||||
|
||||
/***** Number of users *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Users_of_the_country);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToCty (Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Show number of institutions in country configuration ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_NumInss (void)
|
||||
{
|
||||
extern const char *Txt_Institutions;
|
||||
extern const char *Txt_Institutions_of_COUNTRY_X;
|
||||
|
||||
/***** Number of institutions ******/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Institutions);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"LB\"");
|
||||
Frm_StartFormGoTo (ActSeeIns);
|
||||
Cty_PutParamCtyCod (Gbl.Hierarchy.Cty.CtyCod);
|
||||
snprintf (Gbl.Title,sizeof (Gbl.Title),
|
||||
Txt_Institutions_of_COUNTRY_X,
|
||||
Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]);
|
||||
HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK DAT",NULL);
|
||||
HTM_Unsigned (Ins_GetNumInssInCty (Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_BUTTON_End ();
|
||||
Frm_EndForm ();
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Show number of centres in country configuration ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_NumCtrs (void)
|
||||
{
|
||||
extern const char *Txt_Centres;
|
||||
|
||||
/***** Number of centres *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Centres);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Ctr_GetNumCtrsInCty (Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Show number of degrees in country configuration ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_NumDegs (void)
|
||||
{
|
||||
extern const char *Txt_Degrees;
|
||||
|
||||
/***** Number of degrees *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Degrees);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Deg_GetNumDegsInCty (Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************* Show number of courses in country configuration ***************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_NumCrss (void)
|
||||
{
|
||||
extern const char *Txt_Courses;
|
||||
|
||||
/***** Number of courses *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,Txt_Courses);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Crs_GetNumCrssInCty (Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/**************** Number of users in courses of this country *****************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_NumUsrsInCrssOfCty (Rol_Role_t Role)
|
||||
{
|
||||
extern const char *Txt_Users_in_courses;
|
||||
extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||
|
||||
/***** Number of users in courses *****/
|
||||
HTM_TR_Begin (NULL);
|
||||
|
||||
/* Label */
|
||||
Frm_LabelColumn ("RT",NULL,
|
||||
Role == Rol_UNK ? Txt_Users_in_courses :
|
||||
Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN]);
|
||||
|
||||
/* Data */
|
||||
HTM_TD_Begin ("class=\"DAT LB\"");
|
||||
HTM_Unsigned (Usr_GetNumUsrsInCrssOfCty (Role,Gbl.Hierarchy.Cty.CtyCod));
|
||||
HTM_TD_End ();
|
||||
|
||||
HTM_TR_End ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************** Get map attribution from database **********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_GetMapAttr (long CtyCod,char **MapAttribution)
|
||||
{
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
size_t Length;
|
||||
|
||||
/***** Free possible former map attribution *****/
|
||||
CtyCfg_FreeMapAttr (MapAttribution);
|
||||
|
||||
/***** Get photo attribution from database *****/
|
||||
if (DB_QuerySELECT (&mysql_res,"can not get photo attribution",
|
||||
"SELECT MapAttribution FROM countries WHERE CtyCod=%ld",
|
||||
CtyCod))
|
||||
{
|
||||
/* Get row */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get the attribution of the map of the country (row[0]) */
|
||||
if (row[0])
|
||||
if (row[0][0])
|
||||
{
|
||||
Length = strlen (row[0]);
|
||||
if ((*MapAttribution = (char *) malloc (Length + 1)) == NULL)
|
||||
Lay_ShowErrorAndExit ("Error allocating memory for map attribution.");
|
||||
Str_Copy (*MapAttribution,row[0],
|
||||
Length);
|
||||
}
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Free memory used for map attribution ********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void CtyCfg_FreeMapAttr (char **MapAttribution)
|
||||
{
|
||||
if (*MapAttribution)
|
||||
{
|
||||
free (*MapAttribution);
|
||||
*MapAttribution = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*********** Change the attribution of the map of current country ************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void CtyCfg_ChangeCtyMapAttr (void)
|
||||
{
|
||||
char NewMapAttribution[Med_MAX_BYTES_ATTRIBUTION + 1];
|
||||
|
||||
/***** Get parameters from form *****/
|
||||
/* Get the new map attribution for the country */
|
||||
Par_GetParToText ("Attribution",NewMapAttribution,Med_MAX_BYTES_ATTRIBUTION);
|
||||
|
||||
/***** Update the table changing old attribution by new attribution *****/
|
||||
DB_QueryUPDATE ("can not update the map attribution of a country",
|
||||
"UPDATE countries SET MapAttribution='%s'"
|
||||
" WHERE CtyCod='%03ld'",
|
||||
NewMapAttribution,Gbl.Hierarchy.Cty.CtyCod);
|
||||
|
||||
/***** Show the country information again *****/
|
||||
CtyCfg_ShowConfiguration ();
|
||||
}
|
43
swad_country_config.h
Normal file
43
swad_country_config.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
// swad_country_config.h: configuration of current country
|
||||
|
||||
#ifndef _SWAD_CTY_CFG
|
||||
#define _SWAD_CTY_CFG
|
||||
/*
|
||||
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-2019 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 ***********************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************** Public types and constants ***********************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** Public prototypes *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void CtyCfg_ShowConfiguration (void);
|
||||
void CtyCfg_PrintConfiguration (void);
|
||||
|
||||
void CtyCfg_ChangeCtyMapAttr (void);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user