mirror of https://github.com/acanas/swad-core.git
Version 16.143
This commit is contained in:
parent
7d4499dc2d
commit
dfa4f837ad
|
@ -196,19 +196,18 @@
|
|||
|
||||
// TODO: Un administrador de institución, ¿debería poder cambiar la contraseña de un usuario de esa institución? No lo tengo claro.
|
||||
|
||||
// TODO: Register anonymously searches from users for system admins
|
||||
|
||||
/*****************************************************************************/
|
||||
/****************************** Public constants *****************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Log_PLATFORM_VERSION "SWAD 16.142.1 (2017-02-27)"
|
||||
#define Log_PLATFORM_VERSION "SWAD 16.143 (2017-02-28)"
|
||||
#define CSS_FILE "swad16.139.6.css"
|
||||
#define JS_FILE "swad16.141.1.js"
|
||||
|
||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1
|
||||
/*
|
||||
Version 16.143: Feb 28, 2017 Search countries. (213231 lines)
|
||||
Version 16.142.1: Feb 27, 2017 Public activity is renamed as timeline. (213085 lines)
|
||||
Version 16.142: Feb 27, 2017 Searches are registered anonymously. (213077 lines)
|
||||
1 change necessary in database:
|
||||
|
|
294
swad_country.c
294
swad_country.c
|
@ -66,6 +66,9 @@ extern struct Globals Gbl;
|
|||
static void Cty_Configuration (bool PrintView);
|
||||
static void Cty_PutIconToPrint (void);
|
||||
|
||||
static void Cty_PutHeadCountriesForSeeing (bool OrderSelectable);
|
||||
static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty);
|
||||
|
||||
static bool Cty_CheckIfICanEditCountries (void);
|
||||
|
||||
static void Cty_PutIconsListCountries (void);
|
||||
|
@ -83,7 +86,7 @@ static bool Cty_CheckIfNumericCountryCodeExists (long CtyCod);
|
|||
static bool Cty_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1]);
|
||||
static bool Cty_CheckIfCountryNameExists (Txt_Language_t Language,const char *Name,long CtyCod);
|
||||
static void Cty_PutFormToCreateCountry (void);
|
||||
static void Cty_PutHeadCountries (void);
|
||||
static void Cty_PutHeadCountriesForEdition (void);
|
||||
static void Cty_CreateCountry (struct Country *Cty);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -508,119 +511,32 @@ void Cty_ListCountries2 (void)
|
|||
{
|
||||
extern const char *Hlp_SYSTEM_Countries;
|
||||
extern const char *Txt_Countries;
|
||||
extern const char *Txt_COUNTRIES_HELP_ORDER[2];
|
||||
extern const char *Txt_COUNTRIES_ORDER[2];
|
||||
extern const char *Txt_Institutions_ABBREVIATION;
|
||||
extern const char *Txt_Centres_ABBREVIATION;
|
||||
extern const char *Txt_Degrees_ABBREVIATION;
|
||||
extern const char *Txt_Courses_ABBREVIATION;
|
||||
extern const char *Txt_Teachers_ABBREVIATION;
|
||||
extern const char *Txt_Students_ABBREVIATION;
|
||||
extern const char *Txt_Other_countries;
|
||||
extern const char *Txt_Country_unspecified;
|
||||
Cty_Order_t Order;
|
||||
unsigned NumCty;
|
||||
const char *BgColor;
|
||||
|
||||
/***** Table head *****/
|
||||
Lay_StartRoundFrameTable (NULL,Txt_Countries,
|
||||
Cty_PutIconsListCountries,Hlp_SYSTEM_Countries,2);
|
||||
fprintf (Gbl.F.Out,"<tr>");
|
||||
for (Order = Cty_ORDER_BY_COUNTRY;
|
||||
Order <= Cty_ORDER_BY_NUM_USRS;
|
||||
Order++)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<th class=\"%s\">",
|
||||
Order == Cty_ORDER_BY_COUNTRY ? "LEFT_MIDDLE" :
|
||||
"RIGHT_MIDDLE");
|
||||
Act_FormStart (ActSeeCty);
|
||||
Par_PutHiddenParamUnsigned ("Order",(unsigned) Order);
|
||||
Act_LinkFormSubmit (Txt_COUNTRIES_HELP_ORDER[Order],"TIT_TBL",NULL);
|
||||
if (Order == Gbl.Ctys.SelectedOrder)
|
||||
fprintf (Gbl.F.Out,"<u>");
|
||||
fprintf (Gbl.F.Out,"%s",Txt_COUNTRIES_ORDER[Order]);
|
||||
if (Order == Gbl.Ctys.SelectedOrder)
|
||||
fprintf (Gbl.F.Out,"</u>");
|
||||
fprintf (Gbl.F.Out,"</a>");
|
||||
Act_FormEnd ();
|
||||
fprintf (Gbl.F.Out,"</th>");
|
||||
}
|
||||
fprintf (Gbl.F.Out,"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s+<br />%s"
|
||||
"</th>"
|
||||
"</tr>",
|
||||
Txt_Institutions_ABBREVIATION,
|
||||
Txt_Centres_ABBREVIATION,
|
||||
Txt_Degrees_ABBREVIATION,
|
||||
Txt_Courses_ABBREVIATION,
|
||||
Txt_Teachers_ABBREVIATION,Txt_Students_ABBREVIATION);
|
||||
Cty_PutHeadCountriesForSeeing (true); // Order selectable
|
||||
|
||||
/***** Write all the countries and their number of users and institutions *****/
|
||||
for (NumCty = 0;
|
||||
NumCty < Gbl.Ctys.Num;
|
||||
NumCty++)
|
||||
{
|
||||
BgColor = (Gbl.Ctys.Lst[NumCty].CtyCod == Gbl.CurrentCty.Cty.CtyCod) ? "LIGHT_BLUE" :
|
||||
Gbl.ColorRows[Gbl.RowEvenOdd];
|
||||
|
||||
/***** Country map (and link to WWW if exists) *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"LEFT_MIDDLE %s\">",
|
||||
BgColor);
|
||||
Cty_DrawCountryMapAndNameWithLink (&Gbl.Ctys.Lst[NumCty],ActSeeIns,
|
||||
"DAT_N","COUNTRY_MAP_SMALL");
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
|
||||
/* Write stats of this country */
|
||||
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
BgColor,Gbl.Ctys.Lst[NumCty].NumUsrsWhoClaimToBelongToCty,
|
||||
BgColor,Gbl.Ctys.Lst[NumCty].NumInss,
|
||||
BgColor,Gbl.Ctys.Lst[NumCty].NumCtrs,
|
||||
BgColor,Gbl.Ctys.Lst[NumCty].NumDegs,
|
||||
BgColor,Gbl.Ctys.Lst[NumCty].NumCrss,
|
||||
BgColor,Gbl.Ctys.Lst[NumCty].NumUsrs);
|
||||
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
||||
}
|
||||
Cty_ListOneCountryForSeeing (&Gbl.Ctys.Lst[NumCty],NumCty + 1);
|
||||
|
||||
/***** Separation row *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td colspan=\"7\" class=\"DAT CENTER_MIDDLE\">"
|
||||
"<td colspan=\"8\" class=\"DAT CENTER_MIDDLE\">"
|
||||
" "
|
||||
"</td>"
|
||||
"</tr>");
|
||||
|
||||
/***** Write users and institutions in other countries *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE\">"
|
||||
"</td>"
|
||||
"<td class=\"DAT LEFT_MIDDLE\">"
|
||||
"%s"
|
||||
"</td>"
|
||||
|
@ -653,6 +569,8 @@ void Cty_ListCountries2 (void)
|
|||
|
||||
/***** Write users and institutions with unknown country *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE\">"
|
||||
"</td>"
|
||||
"<td class=\"DAT LEFT_MIDDLE\">"
|
||||
"%s"
|
||||
"</td>"
|
||||
|
@ -690,7 +608,7 @@ void Cty_ListCountries2 (void)
|
|||
if (Gbl.Action.Act == ActSeeCty)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<div id=\"chart_div\""
|
||||
" style=\"width:500px; margin:12px auto;\">"
|
||||
" style=\"width:600px; margin:12px auto;\">"
|
||||
"</div>");
|
||||
}
|
||||
|
||||
|
@ -698,6 +616,127 @@ void Cty_ListCountries2 (void)
|
|||
Cty_FreeListCountries ();
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/******************* Write header with fields of a country *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_PutHeadCountriesForSeeing (bool OrderSelectable)
|
||||
{
|
||||
extern const char *Txt_COUNTRIES_HELP_ORDER[2];
|
||||
extern const char *Txt_COUNTRIES_ORDER[2];
|
||||
extern const char *Txt_Institutions_ABBREVIATION;
|
||||
extern const char *Txt_Centres_ABBREVIATION;
|
||||
extern const char *Txt_Degrees_ABBREVIATION;
|
||||
extern const char *Txt_Courses_ABBREVIATION;
|
||||
extern const char *Txt_Teachers_ABBREVIATION;
|
||||
extern const char *Txt_Students_ABBREVIATION;
|
||||
Cty_Order_t Order;
|
||||
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<th></th>");
|
||||
for (Order = Cty_ORDER_BY_COUNTRY;
|
||||
Order <= Cty_ORDER_BY_NUM_USRS;
|
||||
Order++)
|
||||
{
|
||||
fprintf (Gbl.F.Out,"<th class=\"%s\">",
|
||||
Order == Cty_ORDER_BY_COUNTRY ? "LEFT_MIDDLE" :
|
||||
"RIGHT_MIDDLE");
|
||||
if (OrderSelectable)
|
||||
{
|
||||
Act_FormStart (ActSeeCty);
|
||||
Par_PutHiddenParamUnsigned ("Order",(unsigned) Order);
|
||||
Act_LinkFormSubmit (Txt_COUNTRIES_HELP_ORDER[Order],"TIT_TBL",NULL);
|
||||
if (Order == Gbl.Ctys.SelectedOrder)
|
||||
fprintf (Gbl.F.Out,"<u>");
|
||||
}
|
||||
fprintf (Gbl.F.Out,"%s",Txt_COUNTRIES_ORDER[Order]);
|
||||
if (OrderSelectable)
|
||||
{
|
||||
if (Order == Gbl.Ctys.SelectedOrder)
|
||||
fprintf (Gbl.F.Out,"</u>");
|
||||
fprintf (Gbl.F.Out,"</a>");
|
||||
Act_FormEnd ();
|
||||
}
|
||||
fprintf (Gbl.F.Out,"</th>");
|
||||
}
|
||||
fprintf (Gbl.F.Out,"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s"
|
||||
"</th>"
|
||||
"<th class=\"RIGHT_MIDDLE\">"
|
||||
"%s+<br />%s"
|
||||
"</th>"
|
||||
"</tr>",
|
||||
Txt_Institutions_ABBREVIATION,
|
||||
Txt_Centres_ABBREVIATION,
|
||||
Txt_Degrees_ABBREVIATION,
|
||||
Txt_Courses_ABBREVIATION,
|
||||
Txt_Teachers_ABBREVIATION,Txt_Students_ABBREVIATION);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ List one country for seeing ************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_ListOneCountryForSeeing (struct Country *Cty,unsigned NumCty)
|
||||
{
|
||||
const char *BgColor;
|
||||
|
||||
BgColor = (Cty->CtyCod == Gbl.CurrentCty.Cty.CtyCod) ? "LIGHT_BLUE" :
|
||||
Gbl.ColorRows[Gbl.RowEvenOdd];
|
||||
|
||||
/***** Number of country in this list *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>",
|
||||
BgColor,NumCty);
|
||||
|
||||
/***** Country map (and link to WWW if exists) *****/
|
||||
fprintf (Gbl.F.Out,"<td class=\"LEFT_MIDDLE %s\">",
|
||||
BgColor);
|
||||
Cty_DrawCountryMapAndNameWithLink (Cty,ActSeeIns,
|
||||
"DAT_N","COUNTRY_MAP_SMALL");
|
||||
fprintf (Gbl.F.Out,"</td>");
|
||||
|
||||
/* Write stats of this country */
|
||||
fprintf (Gbl.F.Out,"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"<td class=\"DAT RIGHT_MIDDLE %s\">"
|
||||
"%u"
|
||||
"</td>"
|
||||
"</tr>",
|
||||
BgColor,Cty->NumUsrsWhoClaimToBelongToCty,
|
||||
BgColor,Cty->NumInss,
|
||||
BgColor,Cty->NumCtrs,
|
||||
BgColor,Cty->NumDegs,
|
||||
BgColor,Cty->NumCrss,
|
||||
BgColor,Cty->NumUsrs);
|
||||
|
||||
Gbl.RowEvenOdd = 1 - Gbl.RowEvenOdd;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Check if I can edit countries ************************/
|
||||
/*****************************************************************************/
|
||||
|
@ -870,11 +909,11 @@ void Cty_WriteScriptGoogleGeochart (void)
|
|||
/***** Write end of the script *****/
|
||||
fprintf (Gbl.F.Out," ]);\n"
|
||||
" var options = {\n"
|
||||
" width:500,\n"
|
||||
" height:300,\n"
|
||||
" width:600,\n"
|
||||
" height:360,\n"
|
||||
" backgroundColor:'white',\n"
|
||||
" datalessRegionColor:'white',\n"
|
||||
" colorAxis:{colors:['white','#4D88A1'],minValue:0,maxValue:%u}};\n"
|
||||
" colorAxis:{colors:['#EAF1F4','#4D88A1'],minValue:0,maxValue:%u}};\n"
|
||||
" var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));\n"
|
||||
" chart.draw(data, options);\n"
|
||||
" };\n"
|
||||
|
@ -1463,7 +1502,7 @@ static void Cty_ListCountriesForEdition (void)
|
|||
Lay_StartRoundFrameTable (NULL,Txt_Countries,NULL,Hlp_SYSTEM_Countries,2);
|
||||
|
||||
/***** Table head *****/
|
||||
Cty_PutHeadCountries ();
|
||||
Cty_PutHeadCountriesForEdition ();
|
||||
|
||||
/***** Write all the countries *****/
|
||||
for (NumCty = 0;
|
||||
|
@ -1856,7 +1895,7 @@ static void Cty_PutFormToCreateCountry (void)
|
|||
Lay_StartRoundFrameTable (NULL,Txt_New_country,NULL,Hlp_SYSTEM_Countries,2);
|
||||
|
||||
/***** Write heading *****/
|
||||
Cty_PutHeadCountries ();
|
||||
Cty_PutHeadCountriesForEdition ();
|
||||
|
||||
/***** Firts columns for CtyCod *****/
|
||||
fprintf (Gbl.F.Out,"<tr>"
|
||||
|
@ -1943,7 +1982,7 @@ static void Cty_PutFormToCreateCountry (void)
|
|||
/******************* Write header with fields of a country *******************/
|
||||
/*****************************************************************************/
|
||||
|
||||
static void Cty_PutHeadCountries (void)
|
||||
static void Cty_PutHeadCountriesForEdition (void)
|
||||
{
|
||||
extern const char *Txt_Numeric_BR_code_BR_ISO_3166_1;
|
||||
extern const char *Txt_Alphabetic_BR_code_BR_ISO_3166_1;
|
||||
|
@ -2254,3 +2293,58 @@ unsigned Cty_GetNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery)
|
|||
SubQuery,(unsigned) Role);
|
||||
return (unsigned) DB_QueryCOUNT (Query,"can not get number of countries with users");
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/***************************** List countries found **************************/
|
||||
/*****************************************************************************/
|
||||
// Returns number of countries found
|
||||
|
||||
unsigned Cty_ListCtysFound (const char *Query)
|
||||
{
|
||||
extern const char *Txt_country;
|
||||
extern const char *Txt_countries;
|
||||
MYSQL_RES *mysql_res;
|
||||
MYSQL_ROW row;
|
||||
unsigned NumCtys;
|
||||
unsigned NumCty;
|
||||
struct Country Cty;
|
||||
|
||||
/***** Query database *****/
|
||||
if ((NumCtys = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get countries")))
|
||||
{
|
||||
/***** Write heading *****/
|
||||
/* Number of countries found */
|
||||
sprintf (Gbl.Title,"%u %s",
|
||||
NumCtys,NumCtys == 1 ? Txt_country :
|
||||
Txt_countries);
|
||||
Lay_StartRoundFrameTable (NULL,Gbl.Title,NULL,NULL,2);
|
||||
Cty_PutHeadCountriesForSeeing (false); // Order not selectable
|
||||
|
||||
/***** List the countries (one row per country) *****/
|
||||
for (NumCty = 1;
|
||||
NumCty <= NumCtys;
|
||||
NumCty++)
|
||||
{
|
||||
/* Get next country */
|
||||
row = mysql_fetch_row (mysql_res);
|
||||
|
||||
/* Get country code (row[0]) */
|
||||
Cty.CtyCod = Str_ConvertStrCodToLongCod (row[0]);
|
||||
|
||||
/* Get data of country */
|
||||
Cty_GetDataOfCountryByCod (&Cty,Cty_GET_EXTRA_DATA);
|
||||
|
||||
/* Write data of this country */
|
||||
Cty_ListOneCountryForSeeing (&Cty,NumCty);
|
||||
}
|
||||
|
||||
/***** End table *****/
|
||||
Lay_EndRoundFrameTable ();
|
||||
}
|
||||
|
||||
/***** Free structure that stores the query result *****/
|
||||
DB_FreeMySQLResult (&mysql_res);
|
||||
|
||||
return NumCtys;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,4 +112,6 @@ unsigned Cty_GetNumCtysWithDegs (const char *SubQuery);
|
|||
unsigned Cty_GetNumCtysWithCrss (const char *SubQuery);
|
||||
unsigned Cty_GetNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery);
|
||||
|
||||
unsigned Cty_ListCtysFound (const char *Query);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2435,7 +2435,7 @@ unsigned Ins_ListInssFound (const char *Query)
|
|||
Lay_StartRoundFrameTable (NULL,Gbl.Title,NULL,NULL,2);
|
||||
Ins_PutHeadInstitutionsForSeeing (false); // Order not selectable
|
||||
|
||||
/***** List the institutions (one row per centre) *****/
|
||||
/***** List the institutions (one row per institution) *****/
|
||||
for (NumIns = 1;
|
||||
NumIns <= NumInss;
|
||||
NumIns++)
|
||||
|
@ -2449,7 +2449,7 @@ unsigned Ins_ListInssFound (const char *Query)
|
|||
/* Get data of institution */
|
||||
Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_EXTRA_DATA);
|
||||
|
||||
/* Write data of this centre */
|
||||
/* Write data of this institution */
|
||||
Ins_ListOneInstitutionForSeeing (&Ins,NumIns);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Sco
|
|||
static bool Sch_CheckIfIHavePermissionToSearch (Sch_WhatToSearch_t WhatToSearch);
|
||||
static void Sch_GetParamSearch (char *SearchStr,size_t MaxLength);
|
||||
static void Sch_SearchInDB (void);
|
||||
static unsigned Sch_SearchCountriesInDB (const char *RangeQuery);
|
||||
static unsigned Sch_SearchInstitutionsInDB (const char *RangeQuery);
|
||||
static unsigned Sch_SearchCentresInDB (const char *RangeQuery);
|
||||
static unsigned Sch_SearchDegreesInDB (const char *RangeQuery);
|
||||
|
@ -202,6 +203,7 @@ static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Sco
|
|||
extern const char *Txt_Scope;
|
||||
extern const char *Txt_SEARCH_X_in_Y;
|
||||
extern const char *Txt_all;
|
||||
extern const char *Txt_countries;
|
||||
extern const char *Txt_institutions;
|
||||
extern const char *Txt_centres;
|
||||
extern const char *Txt_degrees;
|
||||
|
@ -216,6 +218,7 @@ static void Sch_PutFormToSearchWithWhatToSearchAndScope (Act_Action_t Action,Sco
|
|||
{
|
||||
"", // Sch_SEARCH_UNKNOWN
|
||||
Txt_all, // Sch_SEARCH_ALL
|
||||
Txt_countries, // Sch_SEARCH_COUNTRIES
|
||||
Txt_institutions, // Sch_SEARCH_INSTITS
|
||||
Txt_centres, // Sch_SEARCH_CENTRES
|
||||
Txt_degrees, // Sch_SEARCH_DEGREES
|
||||
|
@ -296,6 +299,7 @@ static bool Sch_CheckIfIHavePermissionToSearch (Sch_WhatToSearch_t WhatToSearch)
|
|||
{
|
||||
0x000, // Sch_SEARCH_UNKNOWN
|
||||
0x1FF, // Sch_SEARCH_ALL
|
||||
0x1FF, // Sch_SEARCH_COUNTRIES
|
||||
0x1FF, // Sch_SEARCH_INSTITS
|
||||
0x1FF, // Sch_SEARCH_CENTRES
|
||||
0x1FF, // Sch_SEARCH_DEGREES
|
||||
|
@ -318,31 +322,17 @@ static bool Sch_CheckIfIHavePermissionToSearch (Sch_WhatToSearch_t WhatToSearch)
|
|||
|
||||
void Sch_PutFormToSearchInPageTopHeading (void)
|
||||
{
|
||||
Act_Action_t ActionSearch;
|
||||
|
||||
/***** Set scope *****/
|
||||
/*
|
||||
Gbl.Scope.Allowed = 1 << Sco_SCOPE_SYS |
|
||||
1 << Sco_SCOPE_CTY |
|
||||
1 << Sco_SCOPE_INS |
|
||||
1 << Sco_SCOPE_CTR |
|
||||
1 << Sco_SCOPE_DEG |
|
||||
1 << Sco_SCOPE_CRS;
|
||||
Gbl.Scope.Default = Sco_SCOPE_SYS;
|
||||
Sco_GetScope ("ScopeSch"); */
|
||||
|
||||
/***** Set action *****/
|
||||
ActionSearch = (Gbl.CurrentCrs.Crs.CrsCod > 0 ? ActCrsSch :
|
||||
(Gbl.CurrentDeg.Deg.DegCod > 0 ? ActDegSch :
|
||||
(Gbl.CurrentCtr.Ctr.CtrCod > 0 ? ActCtrSch :
|
||||
(Gbl.CurrentIns.Ins.InsCod > 0 ? ActInsSch :
|
||||
(Gbl.CurrentCty.Cty.CtyCod > 0 ? ActCtySch :
|
||||
ActSysSch)))));
|
||||
Act_Action_t ActionSearch =
|
||||
(Gbl.CurrentCrs.Crs.CrsCod > 0 ? ActCrsSch :
|
||||
(Gbl.CurrentDeg.Deg.DegCod > 0 ? ActDegSch :
|
||||
(Gbl.CurrentCtr.Ctr.CtrCod > 0 ? ActCtrSch :
|
||||
(Gbl.CurrentIns.Ins.InsCod > 0 ? ActInsSch :
|
||||
(Gbl.CurrentCty.Cty.CtyCod > 0 ? ActCtySch :
|
||||
ActSysSch)))));
|
||||
|
||||
/***** Put form *****/
|
||||
fprintf (Gbl.F.Out,"<div id=\"head_row_1_search\">");
|
||||
Act_FormStart (ActionSearch);
|
||||
// Sco_PutParamScope ("ScopeSch",Gbl.Scope.Current);
|
||||
Sco_PutParamScope ("ScopeSch",Sco_SCOPE_SYS);
|
||||
Sch_PutInputStringToSearch ("head_search_text");
|
||||
Sch_PutMagnifyingGlassButton ("search-white64x64.png");
|
||||
|
@ -574,7 +564,7 @@ static void Sch_SearchInDB (void)
|
|||
RangeQuery[0] = '\0';
|
||||
break;
|
||||
case Sco_SCOPE_CTY:
|
||||
sprintf (RangeQuery," AND institutions.CtyCod='%ld'",
|
||||
sprintf (RangeQuery," AND countries.CtyCod='%ld'",
|
||||
Gbl.CurrentCty.Cty.CtyCod);
|
||||
break;
|
||||
case Sco_SCOPE_INS:
|
||||
|
@ -600,7 +590,8 @@ static void Sch_SearchInDB (void)
|
|||
switch (Gbl.Search.WhatToSearch)
|
||||
{
|
||||
case Sch_SEARCH_ALL:
|
||||
NumResults = Sch_SearchInstitutionsInDB (RangeQuery);
|
||||
NumResults = Sch_SearchCountriesInDB (RangeQuery);
|
||||
NumResults += Sch_SearchInstitutionsInDB (RangeQuery);
|
||||
NumResults += Sch_SearchCentresInDB (RangeQuery);
|
||||
NumResults += Sch_SearchDegreesInDB (RangeQuery);
|
||||
NumResults += Sch_SearchCoursesInDB (RangeQuery);
|
||||
|
@ -611,6 +602,9 @@ static void Sch_SearchInDB (void)
|
|||
NumResults += Sch_SearchDocumentsInMyCoursesInDB (RangeQuery);
|
||||
NumResults += Sch_SearchMyDocumentsInDB (RangeQuery);
|
||||
break;
|
||||
case Sch_SEARCH_COUNTRIES:
|
||||
NumResults = Sch_SearchCountriesInDB (RangeQuery);
|
||||
break;
|
||||
case Sch_SEARCH_INSTITS:
|
||||
NumResults = Sch_SearchInstitutionsInDB (RangeQuery);
|
||||
break;
|
||||
|
@ -653,6 +647,44 @@ static void Sch_SearchInDB (void)
|
|||
Lay_ShowAlert (Lay_INFO,Txt_No_results);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/************************ Search countries in database ***********************/
|
||||
/*****************************************************************************/
|
||||
// Returns number of countries found
|
||||
|
||||
static unsigned Sch_SearchCountriesInDB (const char *RangeQuery)
|
||||
{
|
||||
extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES];
|
||||
char SearchQuery[Sch_MAX_LENGTH_SEARCH_QUERY + 1];
|
||||
char Query[1024 + Sch_MAX_LENGTH_SEARCH_QUERY * 2];
|
||||
char FieldName[4+1+2+1]; // Example: Name_en
|
||||
|
||||
/***** Check scope *****/
|
||||
if (Gbl.Scope.Current != Sco_SCOPE_INS &&
|
||||
Gbl.Scope.Current != Sco_SCOPE_CTR &&
|
||||
Gbl.Scope.Current != Sco_SCOPE_DEG &&
|
||||
Gbl.Scope.Current != Sco_SCOPE_CRS)
|
||||
/***** Check user's permission *****/
|
||||
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_COUNTRIES))
|
||||
{
|
||||
/***** Split countries string into words *****/
|
||||
sprintf (FieldName,"Name_%s",Txt_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
if (Sch_BuildSearchQuery (SearchQuery,FieldName,NULL,NULL))
|
||||
{
|
||||
/***** Query database and list institutions found *****/
|
||||
sprintf (Query,"SELECT CtyCod"
|
||||
" FROM countries"
|
||||
" WHERE %s%s"
|
||||
" ORDER BY Name_%s",
|
||||
SearchQuery,RangeQuery,
|
||||
Txt_STR_LANG_ID[Gbl.Prefs.Language]);
|
||||
return Cty_ListCtysFound (Query);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/********************** Search institutions in database **********************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -40,22 +40,23 @@
|
|||
/******************************** Public types *******************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define Sch_NUM_WHAT_TO_SEARCH 13
|
||||
#define Sch_NUM_WHAT_TO_SEARCH 14
|
||||
typedef enum
|
||||
{
|
||||
Sch_SEARCH_UNKNOWN = 0,
|
||||
Sch_SEARCH_ALL = 1,
|
||||
Sch_SEARCH_INSTITS = 2,
|
||||
Sch_SEARCH_CENTRES = 3,
|
||||
Sch_SEARCH_DEGREES = 4,
|
||||
Sch_SEARCH_COURSES = 5,
|
||||
Sch_SEARCH_USERS = 6,
|
||||
Sch_SEARCH_TEACHERS = 7,
|
||||
Sch_SEARCH_STUDENTS = 8,
|
||||
Sch_SEARCH_GUESTS = 9,
|
||||
Sch_SEARCH_OPEN_DOCUMENTS = 10,
|
||||
Sch_SEARCH_DOCUM_IN_MY_COURSES = 11,
|
||||
Sch_SEARCH_MY_DOCUMENTS = 12,
|
||||
Sch_SEARCH_COUNTRIES = 2,
|
||||
Sch_SEARCH_INSTITS = 3,
|
||||
Sch_SEARCH_CENTRES = 4,
|
||||
Sch_SEARCH_DEGREES = 5,
|
||||
Sch_SEARCH_COURSES = 6,
|
||||
Sch_SEARCH_USERS = 7,
|
||||
Sch_SEARCH_TEACHERS = 8,
|
||||
Sch_SEARCH_STUDENTS = 9,
|
||||
Sch_SEARCH_GUESTS = 10,
|
||||
Sch_SEARCH_OPEN_DOCUMENTS = 11,
|
||||
Sch_SEARCH_DOCUM_IN_MY_COURSES = 12,
|
||||
Sch_SEARCH_MY_DOCUMENTS = 13,
|
||||
} Sch_WhatToSearch_t;
|
||||
#define Sch_WHAT_TO_SEARCH_DEFAULT Sch_SEARCH_ALL
|
||||
|
||||
|
|
42
swad_text.c
42
swad_text.c
|
@ -5360,6 +5360,27 @@ const char *Txt_Countries =
|
|||
"Países";
|
||||
#endif
|
||||
|
||||
const char *Txt_countries =
|
||||
#if L==1
|
||||
"països";
|
||||
#elif L==2
|
||||
"Länder";
|
||||
#elif L==3
|
||||
"countries";
|
||||
#elif L==4
|
||||
"países";
|
||||
#elif L==5
|
||||
"pays";
|
||||
#elif L==6
|
||||
"tetã";
|
||||
#elif L==7
|
||||
"paesi";
|
||||
#elif L==8
|
||||
"kraje";
|
||||
#elif L==9
|
||||
"países";
|
||||
#endif
|
||||
|
||||
const char *Txt_COUNTRIES_HELP_ORDER[2] =
|
||||
{
|
||||
#if L==1
|
||||
|
@ -5488,6 +5509,27 @@ const char *Txt_Country =
|
|||
"País";
|
||||
#endif
|
||||
|
||||
const char *Txt_country =
|
||||
#if L==1
|
||||
"país";
|
||||
#elif L==2
|
||||
"Land";
|
||||
#elif L==3
|
||||
"country";
|
||||
#elif L==4
|
||||
"país";
|
||||
#elif L==5
|
||||
"pays;";
|
||||
#elif L==6
|
||||
"tetã";
|
||||
#elif L==7
|
||||
"paese";
|
||||
#elif L==8
|
||||
"kraj";
|
||||
#elif L==9
|
||||
"país";
|
||||
#endif
|
||||
|
||||
const char *Txt_Country_of_your_institution =
|
||||
#if L==1
|
||||
"País de la seva institució";
|
||||
|
|
Loading…
Reference in New Issue