swad-core/swad_country.h

140 lines
4.9 KiB
C
Raw Normal View History

2014-12-01 23:55:08 +01:00
// swad_country.h: countries
#ifndef _SWAD_CTY
#define _SWAD_CTY
/*
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-2023 Antonio Ca<EFBFBD>as Vargas
2014-12-01 23:55:08 +01:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*****************************************************************************/
/********************************* Headers ***********************************/
/*****************************************************************************/
2018-10-30 14:47:31 +01:00
#include <mysql/mysql.h> // To access MySQL databases
2015-10-16 02:24:29 +02:00
#include <stdbool.h> // For boolean type
2014-12-01 23:55:08 +01:00
#include "swad_action.h"
2021-02-11 22:57:09 +01:00
#include "swad_hierarchy_level.h"
2019-04-04 10:45:15 +02:00
#include "swad_institution.h"
2018-12-08 16:43:13 +01:00
#include "swad_language.h"
2016-12-13 13:32:19 +01:00
#include "swad_role_type.h"
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/************************** Public types and constants ***********************/
/*****************************************************************************/
2016-10-28 10:03:37 +02:00
#define Cty_MAX_COUNTRS_PER_USR 10 // Used in list of my countries
2016-10-27 01:30:14 +02:00
2017-03-10 02:40:01 +01:00
#define Cty_MAX_CHARS_NAME (48 - 1) // 47
#define Cty_MAX_BYTES_NAME ((Cty_MAX_CHARS_NAME + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 767
2021-02-11 22:57:09 +01:00
struct Cty_Countr
2014-12-01 23:55:08 +01:00
{
long CtyCod;
2017-01-13 01:51:23 +01:00
char Alpha2[2 + 1];
2018-12-08 16:43:13 +01:00
char Name[1 + Lan_NUM_LANGUAGES][Cty_MAX_BYTES_NAME + 1];
char WWW [1 + Lan_NUM_LANGUAGES][Cns_MAX_BYTES_WWW + 1];
2020-01-07 13:14:42 +01:00
struct
{
bool Valid;
unsigned NumUsrs;
} NumUsrsWhoClaimToBelongToCty;
2014-12-01 23:55:08 +01:00
};
2017-01-29 21:41:08 +01:00
#define Cty_NUM_ORDERS 2
2014-12-01 23:55:08 +01:00
typedef enum
{
Cty_ORDER_BY_COUNTRY = 0,
Cty_ORDER_BY_NUM_USRS = 1,
2017-01-29 12:42:19 +01:00
} Cty_Order_t;
#define Cty_ORDER_DEFAULT Cty_ORDER_BY_NUM_USRS
2014-12-01 23:55:08 +01:00
2020-01-08 14:04:25 +01:00
struct ListCountries
{
unsigned Num; // Number of countries
2021-02-11 22:57:09 +01:00
struct Cty_Countr *Lst; // List of countries
2020-01-08 14:04:25 +01:00
Cty_Order_t SelectedOrder; // Order of countries
};
2014-12-01 23:55:08 +01:00
/*****************************************************************************/
/***************************** Public prototypes *****************************/
/*****************************************************************************/
void Cty_SeeCtyWithPendingInss (void);
void Cty_ListCountries (void);
void Cty_ListCountries1 (void);
void Cty_ListCountries2 (void);
2015-11-11 21:14:33 +01:00
2019-12-29 19:07:59 +01:00
bool Cty_CheckIfICanEditCountries (void);
2021-02-11 22:57:09 +01:00
void Cty_DrawCountryMapAndNameWithLink (struct Cty_Countr *Cty,Act_Action_t Action,
2017-03-04 19:46:46 +01:00
const char *ClassContainer,
const char *ClassMap);
2021-02-11 22:57:09 +01:00
void Cty_DrawCountryMap (struct Cty_Countr *Cty,const char *Class);
bool Cty_CheckIfCountryPhotoExists (struct Cty_Countr *Cty);
2015-11-11 21:14:33 +01:00
2014-12-01 23:55:08 +01:00
void Cty_WriteScriptGoogleGeochart (void);
void Cty_PutParCtyOrder (void);
2014-12-01 23:55:08 +01:00
void Cty_EditCountries (void);
2020-01-07 22:07:06 +01:00
void Cty_GetBasicListOfCountries (void);
void Cty_GetFullListOfCountries (void);
2014-12-01 23:55:08 +01:00
void Cty_FreeListCountries (void);
2015-07-25 20:20:07 +02:00
void Cty_WriteSelectorOfCountry (void);
void Cty_WriteCountryName (long CtyCod);
bool Cty_GetCountryDataByCod (struct Cty_Countr *Cty);
2017-06-20 14:43:26 +02:00
void Cty_FlushCacheCountryName (void);
2020-01-07 22:07:06 +01:00
void Cty_GetCountryName (long CtyCod,Lan_Language_t Language,
char CtyName[Cty_MAX_BYTES_NAME + 1]);
2014-12-01 23:55:08 +01:00
void Cty_RemoveCountry (void);
void Cty_RenameCountry (void);
void Cty_ChangeCtyWWW (void);
2019-04-08 21:10:12 +02:00
void Cty_ContEditAfterChgCty (void);
2020-05-05 21:49:00 +02:00
void Cty_ReceiveFormNewCountry (void);
2014-12-01 23:55:08 +01:00
2020-05-03 20:58:03 +02:00
unsigned Cty_GetCachedNumCtysInSys (void);
unsigned Cty_GetCachedNumCtysWithInss (void);
unsigned Cty_GetCachedNumCtysWithCtrs (void);
unsigned Cty_GetCachedNumCtysWithDegs (void);
unsigned Cty_GetCachedNumCtysWithCrss (void);
unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role);
2014-12-01 23:55:08 +01:00
2018-10-30 14:47:31 +01:00
void Cty_ListCtysFound (MYSQL_RES **mysql_res,unsigned NumCtys);
2017-02-28 00:59:01 +01:00
void Cty_GetMyCountrs (void);
void Cty_FreeMyCountrs (void);
bool Cty_CheckIfIBelongToCty (long CtyCod);
void Cty_FlushCacheNumUsrsWhoDontClaimToBelongToAnyCty (void);
unsigned Cty_GetNumUsrsWhoDontClaimToBelongToAnyCty (void);
unsigned Cty_GetCachedNumUsrsWhoDontClaimToBelongToAnyCty (void);
void Cty_FlushCacheNumUsrsWhoClaimToBelongToAnotherCty (void);
unsigned Cty_GetNumUsrsWhoClaimToBelongToAnotherCty (void);
unsigned Cty_GetCachedNumUsrsWhoClaimToBelongToAnotherCty (void);
void Cty_FlushCacheNumUsrsWhoClaimToBelongToCty (void);
unsigned Cty_GetNumUsrsWhoClaimToBelongToCty (struct Cty_Countr *Cty);
unsigned Cty_GetCachedNumUsrsWhoClaimToBelongToCty (struct Cty_Countr *Cty);
2014-12-01 23:55:08 +01:00
#endif