Version 20.88.1: Jun 02, 2021 Queries moved to module swad_center_database.

This commit is contained in:
acanas 2021-06-02 13:09:30 +02:00
parent 17c04cc470
commit 920018f1f3
16 changed files with 530 additions and 486 deletions

View File

@ -32,6 +32,7 @@
#include "swad_center.h"
#include "swad_center_config.h"
#include "swad_center_database.h"
#include "swad_database.h"
#include "swad_error.h"
#include "swad_figure.h"
@ -90,8 +91,6 @@ static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt);
static void Ctr_PutParamOtherCtrCod (void *CtrCod);
static void Ctr_DB_UpdateCtrName (long CtrCod,const char *FieldName,const char *NewCtrName);
static void Ctr_ShowAlertAndButtonToGoToCtr (void);
static void Ctr_PutParamGoToCtr (void *CtrCod);
@ -99,7 +98,6 @@ static void Ctr_PutFormToCreateCenter (const struct Plc_Places *Places);
static void Ctr_PutHeadCentersForSeeing (bool OrderSelectable);
static void Ctr_PutHeadCentersForEdition (void);
static void Ctr_ReceiveFormRequestOrCreateCtr (unsigned Status);
static void Ctr_DB_CreateCenter (unsigned Status);
static unsigned Ctr_GetNumCtrsInCty (long CtyCod);
@ -127,42 +125,7 @@ void Ctr_SeeCtrWithPendingDegs (void)
const char *BgColor;
/***** Get centers with pending degrees *****/
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_CTR_ADM:
NumCtrs = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get centers with pending degrees",
"SELECT deg_degrees.CtrCod," // row[0]
"COUNT(*)" // row[1]
" FROM deg_degrees,"
"ctr_admin,"
"ctr_centers"
" WHERE (deg_degrees.Status & %u)<>0"
" AND deg_degrees.CtrCod=ctr_admin.CtrCod"
" AND ctr_admin.UsrCod=%ld"
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
" GROUP BY deg_degrees.CtrCod"
" ORDER BY ctr_centers.ShortName",
(unsigned) Deg_STATUS_BIT_PENDING,
Gbl.Usrs.Me.UsrDat.UsrCod);
break;
case Rol_SYS_ADM:
NumCtrs = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get centers with pending degrees",
"SELECT deg_degrees.CtrCod," // row[0]
"COUNT(*)" // row[1]
" FROM deg_degrees,"
"ctr_centers"
" WHERE (deg_degrees.Status & %u)<>0"
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
" GROUP BY deg_degrees.CtrCod"
" ORDER BY ctr_centers.ShortName",
(unsigned) Deg_STATUS_BIT_PENDING);
break;
default: // Forbidden for other users
return;
}
if (NumCtrs)
if ((NumCtrs = Ctr_DB_GetCtrsWithPendingDegs (&mysql_res)))
{
/***** Begin box and table *****/
Box_BoxTableBegin (NULL,Txt_Centers_with_pending_degrees,
@ -262,7 +225,8 @@ void Ctr_ShowCtrsOfCurrentIns (void)
Ctr_GetParamCtrOrder ();
/***** Get list of centers *****/
Ctr_GetFullListOfCenters (Gbl.Hierarchy.Ins.InsCod);
Ctr_GetFullListOfCenters (Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ctrs.SelectedOrder);
/***** Write menu to select country and institution *****/
Hie_WriteMenuHierarchy ();
@ -490,7 +454,8 @@ static void Ctr_EditCentersInternal (void)
/***** Get list of centers *****/
Gbl.Hierarchy.Ctrs.SelectedOrder = Ctr_ORDER_BY_CENTER;
Ctr_GetFullListOfCenters (Gbl.Hierarchy.Ins.InsCod);
Ctr_GetFullListOfCenters (Gbl.Hierarchy.Ins.InsCod,
Gbl.Hierarchy.Ctrs.SelectedOrder);
/***** Write menu to select country and institution *****/
Hie_WriteMenuHierarchy ();
@ -557,27 +522,11 @@ void Ctr_GetBasicListOfCenters (long InsCod)
struct Ctr_Center *Ctr;
/***** Get centers from database *****/
Gbl.Hierarchy.Ctrs.Num = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get centers",
"SELECT CtrCod," // row[ 0]
"InsCod," // row[ 1]
"PlcCod," // row[ 2]
"Status," // row[ 3]
"RequesterUsrCod," // row[ 4]
"Latitude," // row[ 5]
"Longitude," // row[ 6]
"Altitude," // row[ 7]
"ShortName," // row[ 8]
"FullName," // row[ 9]
"WWW" // row[10]
" FROM ctr_centers"
" WHERE InsCod=%ld"
" ORDER BY FullName",
InsCod);
Gbl.Hierarchy.Ctrs.Num = Ctr_DB_GetListOfCtrsFull (&mysql_res,InsCod);
if (Gbl.Hierarchy.Ctrs.Num) // Centers found...
{
/***** Create list with courses in degree *****/
/***** Create list with centers in institution *****/
if ((Gbl.Hierarchy.Ctrs.Lst = calloc ((size_t) Gbl.Hierarchy.Ctrs.Num,
sizeof (*Gbl.Hierarchy.Ctrs.Lst))) == NULL)
Err_NotEnoughMemoryExit ();
@ -607,59 +556,15 @@ void Ctr_GetBasicListOfCenters (long InsCod)
/************* with number of users who claim to belong to them **************/
/*****************************************************************************/
void Ctr_GetFullListOfCenters (long InsCod)
void Ctr_GetFullListOfCenters (long InsCod,Ctr_Order_t SelectedOrder)
{
static const char *OrderBySubQuery[Ctr_NUM_ORDERS] =
{
[Ctr_ORDER_BY_CENTER ] = "FullName",
[Ctr_ORDER_BY_NUM_USRS] = "NumUsrs DESC,FullName",
};
MYSQL_RES *mysql_res;
MYSQL_ROW row;
unsigned NumCtr;
struct Ctr_Center *Ctr;
/***** Get centers from database *****/
Gbl.Hierarchy.Ctrs.Num = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get centers",
"(SELECT ctr_centers.CtrCod," // row[ 0]
"ctr_centers.InsCod," // row[ 1]
"ctr_centers.PlcCod," // row[ 2]
"ctr_centers.Status," // row[ 3]
"ctr_centers.RequesterUsrCod," // row[ 4]
"ctr_centers.Latitude," // row[ 5]
"ctr_centers.Longitude," // row[ 6]
"ctr_centers.Altitude," // row[ 7]
"ctr_centers.ShortName," // row[ 8]
"ctr_centers.FullName," // row[ 9]
"ctr_centers.WWW," // row[10]
"COUNT(*) AS NumUsrs" // row[11]
" FROM ctr_centers,usr_data"
" WHERE ctr_centers.InsCod=%ld"
" AND ctr_centers.CtrCod=usr_data.CtrCod"
" GROUP BY ctr_centers.CtrCod)"
" UNION "
"(SELECT CtrCod," // row[ 0]
"InsCod," // row[ 1]
"PlcCod," // row[ 2]
"Status," // row[ 3]
"RequesterUsrCod," // row[ 4]
"Latitude," // row[ 5]
"Longitude," // row[ 6]
"Altitude," // row[ 7]
"ShortName," // row[ 8]
"FullName," // row[ 9]
"WWW," // row[10]
"0 AS NumUsrs" // row[11]
" FROM ctr_centers"
" WHERE InsCod=%ld"
" AND CtrCod NOT IN"
" (SELECT DISTINCT CtrCod"
" FROM usr_data))"
" ORDER BY %s",
InsCod,
InsCod,
OrderBySubQuery[Gbl.Hierarchy.Ctrs.SelectedOrder]);
Gbl.Hierarchy.Ctrs.Num = Ctr_DB_GetListOfCtrsFullWithNumUsrs (&mysql_res,InsCod,SelectedOrder);
if (Gbl.Hierarchy.Ctrs.Num) // Centers found...
{
@ -714,21 +619,7 @@ bool Ctr_GetDataOfCenterByCod (struct Ctr_Center *Ctr)
if (Ctr->CtrCod > 0)
{
/***** Get data of a center from database *****/
if (DB_QuerySELECT (&mysql_res,"can not get data of a center",
"SELECT CtrCod," // row[ 0]
"InsCod," // row[ 1]
"PlcCod," // row[ 2]
"Status," // row[ 3]
"RequesterUsrCod," // row[ 4]
"Latitude," // row[ 5]
"Longitude," // row[ 6]
"Altitude," // row[ 7]
"ShortName," // row[ 8]
"FullName," // row[ 9]
"WWW" // row[10]
" FROM ctr_centers"
" WHERE CtrCod=%ld",
Ctr->CtrCod)) // Center found...
if (Ctr_DB_GetDataOfCenterByCod (&mysql_res,Ctr->CtrCod)) // Center found...
{
/* Get row */
row = mysql_fetch_row (mysql_res);
@ -780,46 +671,6 @@ static void Ctr_GetDataOfCenterFromRow (struct Ctr_Center *Ctr,MYSQL_ROW row)
Str_Copy (Ctr->WWW ,row[10],sizeof (Ctr->WWW ) - 1);
}
/*****************************************************************************/
/*********** Get the institution code of a center from its code **************/
/*****************************************************************************/
long Ctr_GetInsCodOfCenterByCod (long CtrCod)
{
/***** Trivial check: center code should be > 0 *****/
if (CtrCod <= 0)
return -1L;
/***** Get the institution code of a center from database *****/
return DB_QuerySELECTCode ("can not get the institution of a center",
"SELECT InsCod"
" FROM ctr_centers"
" WHERE CtrCod=%ld",
CtrCod);
}
/*****************************************************************************/
/*************** Get the short name of a center from its code ****************/
/*****************************************************************************/
void Ctr_GetShortNameOfCenterByCod (struct Ctr_Center *Ctr)
{
/***** Trivial check: center code should be > 0 *****/
if (Ctr->CtrCod <= 0)
{
Ctr->ShrtName[0] = '\0';
return;
}
/***** Get the short name of a center from database *****/
DB_QuerySELECTString (Ctr->ShrtName,sizeof (Ctr->ShrtName) - 1,
"can not get the short name of a center",
"SELECT ShortName"
" FROM ctr_centers"
" WHERE CtrCod=%ld",
Ctr->CtrCod);
}
/*****************************************************************************/
/**************************** Free list of centers ***************************/
/*****************************************************************************/
@ -865,17 +716,8 @@ void Ctr_WriteSelectorOfCenter (void)
if (Gbl.Hierarchy.Ins.InsCod > 0)
{
/***** Get centers from database *****/
NumCtrs = (unsigned)
DB_QuerySELECT (&mysql_res,"can not get centers",
"SELECT DISTINCT CtrCod," // row[0]
"ShortName" // row[1]
" FROM ctr_centers"
" WHERE InsCod=%ld"
" ORDER BY ShortName",
Gbl.Hierarchy.Ins.InsCod);
/***** Get centers *****/
/***** Get centers in current institution from database *****/
NumCtrs = Ctr_DB_GetListOfCtrsInCurrentIns (&mysql_res);
for (NumCtr = 0;
NumCtr < NumCtrs;
NumCtr++)
@ -1257,10 +1099,7 @@ void Ctr_RemoveCenter (void)
Enr_DB_RemAdmins (HieLvl_CTR,Ctr_EditingCtr->CtrCod);
/***** Remove center *****/
DB_QueryDELETE ("can not remove a center",
"DELETE FROM ctr_centers"
" WHERE CtrCod=%ld",
Ctr_EditingCtr->CtrCod);
Ctr_DB_RemoveCenter (Ctr_EditingCtr->CtrCod);
/***** Flush caches *****/
Deg_FlushCacheNumDegsInCtr ();
@ -1307,20 +1146,6 @@ void Ctr_ChangeCtrPlc (void)
Txt_The_place_of_the_center_has_changed);
}
/*****************************************************************************/
/************** Update database changing old place by new place **************/
/*****************************************************************************/
void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod)
{
DB_QueryUPDATE ("can not update the place of a center",
"UPDATE ctr_centers"
" SET PlcCod=%ld"
" WHERE CtrCod=%ld",
NewPlcCod,
CtrCod);
}
/*****************************************************************************/
/************************ Change the name of a center ************************/
/*****************************************************************************/
@ -1418,43 +1243,6 @@ void Ctr_RenameCenter (struct Ctr_Center *Ctr,Cns_ShrtOrFullName_t ShrtOrFullNam
}
}
/*****************************************************************************/
/********************* Check if the name of center exists ********************/
/*****************************************************************************/
bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,
long CtrCod,long InsCod)
{
/***** Get number of centers with a name from database *****/
return (DB_QueryCOUNT ("can not check if the name of a center"
" already existed",
"SELECT COUNT(*)"
" FROM ctr_centers"
" WHERE InsCod=%ld"
" AND %s='%s'"
" AND CtrCod<>%ld",
InsCod,
FieldName,
Name,
CtrCod) != 0);
}
/*****************************************************************************/
/****************** Update center name in table of centers *******************/
/*****************************************************************************/
static void Ctr_DB_UpdateCtrName (long CtrCod,const char *FieldName,const char *NewCtrName)
{
/***** Update center changing old name by new name */
DB_QueryUPDATE ("can not update the name of a center",
"UPDATE ctr_centers"
" SET %s='%s'"
" WHERE CtrCod=%ld",
FieldName,
NewCtrName,
CtrCod);
}
/*****************************************************************************/
/************************* Change the URL of a center ************************/
/*****************************************************************************/
@ -1493,21 +1281,6 @@ void Ctr_ChangeCtrWWW (void)
Ale_CreateAlertYouCanNotLeaveFieldEmpty ();
}
/*****************************************************************************/
/**************** Update database changing old WWW by new WWW ****************/
/*****************************************************************************/
void Ctr_DB_UpdateCtrWWW (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1])
{
/***** Update database changing old WWW by new WWW *****/
DB_QueryUPDATE ("can not update the web of a center",
"UPDATE ctr_centers"
" SET WWW='%s'"
" WHERE CtrCod=%ld",
NewWWW,
CtrCod);
}
/*****************************************************************************/
/*********************** Change the status of a center ***********************/
/*****************************************************************************/
@ -1877,7 +1650,7 @@ static void Ctr_ReceiveFormRequestOrCreateCtr (unsigned Status)
Ctr_EditingCtr->FullName);
else // Add new center to database
{
Ctr_DB_CreateCenter (Status);
Ctr_EditingCtr->CtrCod = Ctr_DB_CreateCenter (Ctr_EditingCtr,Status);
Ale_CreateAlert (Ale_SUCCESS,NULL,
Txt_Created_new_center_X,
Ctr_EditingCtr->FullName);
@ -1892,30 +1665,6 @@ static void Ctr_ReceiveFormRequestOrCreateCtr (unsigned Status)
Txt_You_must_specify_the_short_name_and_the_full_name_of_the_new_center);
}
/*****************************************************************************/
/***************************** Create a new center ***************************/
/*****************************************************************************/
static void Ctr_DB_CreateCenter (unsigned Status)
{
/***** Create a new center *****/
Ctr_EditingCtr->CtrCod =
DB_QueryINSERTandReturnCode ("can not create a new center",
"INSERT INTO ctr_centers"
" (InsCod,PlcCod,Status,RequesterUsrCod,"
"ShortName,FullName,WWW,PhotoAttribution)"
" VALUES"
" (%ld,%ld,%u,%ld,"
"'%s','%s','%s','')",
Ctr_EditingCtr->InsCod,
Ctr_EditingCtr->PlcCod,
Status,
Gbl.Usrs.Me.UsrDat.UsrCod,
Ctr_EditingCtr->ShrtName,
Ctr_EditingCtr->FullName,
Ctr_EditingCtr->WWW);
}
/*****************************************************************************/
/************************** Get number of centers ****************************/
/*****************************************************************************/
@ -2118,23 +1867,6 @@ unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod)
return NumCtrsWithMap;
}
/*****************************************************************************/
/******* Get number of centers (of the current institution) in a place *******/
/*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod)
{
/***** Get number of centers (of the current institution) in a place *****/
return (unsigned)
DB_QueryCOUNT ("can not get the number of centers in a place",
"SELECT COUNT(*)"
" FROM ctr_centers"
" WHERE InsCod=%ld"
" AND PlcCod=%ld",
Gbl.Hierarchy.Ins.InsCod,
PlcCod);
}
/*****************************************************************************/
/********************* Get number of centers with degrees ********************/
/*****************************************************************************/

View File

@ -108,24 +108,18 @@ void Ctr_EditCenters (void);
void Ctr_PutIconToViewCenters (void);
void Ctr_GetBasicListOfCenters (long InsCod);
void Ctr_GetFullListOfCenters (long InsCod);
void Ctr_GetFullListOfCenters (long InsCod,Ctr_Order_t SelectedOrder);
bool Ctr_GetDataOfCenterByCod (struct Ctr_Center *Ctr);
long Ctr_GetInsCodOfCenterByCod (long CtrCod);
void Ctr_GetShortNameOfCenterByCod (struct Ctr_Center *Ctr);
void Ctr_FreeListCenters (void);
void Ctr_WriteSelectorOfCenter (void);
void Ctr_PutParamCtrCod (long CtrCod);
long Ctr_GetAndCheckParamOtherCtrCod (long MinCodAllowed);
void Ctr_RemoveCenter (void);
void Ctr_ChangeCtrPlc (void);
void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod);
void Ctr_RenameCenterShort (void);
void Ctr_RenameCenterFull (void);
void Ctr_RenameCenter (struct Ctr_Center *Ctr,Cns_ShrtOrFullName_t ShrtOrFullName);
bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,
long CtrCod,long InsCod);
void Ctr_ChangeCtrWWW (void);
void Ctr_DB_UpdateCtrWWW (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
void Ctr_ChangeCtrStatus (void);
void Ctr_ContEditAfterChgCtr (void);
@ -145,8 +139,6 @@ unsigned Ctr_GetCachedNumCtrsWithMapInSys (void);
unsigned Ctr_GetCachedNumCtrsWithMapInCty (long CtyCod);
unsigned Ctr_GetCachedNumCtrsWithMapInIns (long InsCod);
unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod);
unsigned Ctr_GetCachedNumCtrsWithDegs (const char *SubQuery,
HieLvl_Level_t Scope,long Cod);
unsigned Ctr_GetCachedNumCtrsWithCrss (const char *SubQuery,

View File

@ -32,8 +32,8 @@
#include "swad_center.h"
#include "swad_center_config.h"
// #include "swad_database.h"
// #include "swad_error.h"
#include "swad_database.h"
#include "swad_error.h"
// #include "swad_figure.h"
// #include "swad_figure_cache.h"
// #include "swad_form.h"
@ -68,3 +68,325 @@ extern struct Globals Gbl;
/*****************************************************************************/
/***************************** Private prototypes ****************************/
/*****************************************************************************/
/*****************************************************************************/
/***************************** Create a new center ***************************/
/*****************************************************************************/
long Ctr_DB_CreateCenter (const struct Ctr_Center *Ctr,unsigned Status)
{
return
DB_QueryINSERTandReturnCode ("can not create a new center",
"INSERT INTO ctr_centers"
" (InsCod,PlcCod,Status,RequesterUsrCod,"
"ShortName,FullName,WWW,PhotoAttribution)"
" VALUES"
" (%ld,%ld,%u,%ld,"
"'%s','%s','%s','')",
Ctr->InsCod,
Ctr->PlcCod,
Status,
Gbl.Usrs.Me.UsrDat.UsrCod,
Ctr->ShrtName,
Ctr->FullName,
Ctr->WWW);
}
/*****************************************************************************/
/************ Get basic list of centers ordered by name of center ************/
/*****************************************************************************/
unsigned Ctr_DB_GetListOfCtrsInCurrentIns (MYSQL_RES **mysql_res)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get centers",
"SELECT DISTINCT CtrCod," // row[0]
"ShortName" // row[1]
" FROM ctr_centers"
" WHERE InsCod=%ld"
" ORDER BY ShortName",
Gbl.Hierarchy.Ins.InsCod);
}
/*****************************************************************************/
/************ Get full list of centers ordered by name of center ************/
/*****************************************************************************/
unsigned Ctr_DB_GetListOfCtrsFull (MYSQL_RES **mysql_res,long InsCod)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get centers",
"SELECT CtrCod," // row[ 0]
"InsCod," // row[ 1]
"PlcCod," // row[ 2]
"Status," // row[ 3]
"RequesterUsrCod," // row[ 4]
"Latitude," // row[ 5]
"Longitude," // row[ 6]
"Altitude," // row[ 7]
"ShortName," // row[ 8]
"FullName," // row[ 9]
"WWW" // row[10]
" FROM ctr_centers"
" WHERE InsCod=%ld"
" ORDER BY FullName",
InsCod);
}
/*****************************************************************************/
/************* Get full list of centers **************/
/************* with number of users who claim to belong to them **************/
/*****************************************************************************/
unsigned Ctr_DB_GetListOfCtrsFullWithNumUsrs (MYSQL_RES **mysql_res,
long InsCod,Ctr_Order_t SelectedOrder)
{
static const char *OrderBySubQuery[Ctr_NUM_ORDERS] =
{
[Ctr_ORDER_BY_CENTER ] = "FullName",
[Ctr_ORDER_BY_NUM_USRS] = "NumUsrs DESC,"
"FullName",
};
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get centers",
"(SELECT ctr_centers.CtrCod," // row[ 0]
"ctr_centers.InsCod," // row[ 1]
"ctr_centers.PlcCod," // row[ 2]
"ctr_centers.Status," // row[ 3]
"ctr_centers.RequesterUsrCod," // row[ 4]
"ctr_centers.Latitude," // row[ 5]
"ctr_centers.Longitude," // row[ 6]
"ctr_centers.Altitude," // row[ 7]
"ctr_centers.ShortName," // row[ 8]
"ctr_centers.FullName," // row[ 9]
"ctr_centers.WWW," // row[10]
"COUNT(*) AS NumUsrs" // row[11]
" FROM ctr_centers,usr_data"
" WHERE ctr_centers.InsCod=%ld"
" AND ctr_centers.CtrCod=usr_data.CtrCod"
" GROUP BY ctr_centers.CtrCod)"
" UNION "
"(SELECT CtrCod," // row[ 0]
"InsCod," // row[ 1]
"PlcCod," // row[ 2]
"Status," // row[ 3]
"RequesterUsrCod," // row[ 4]
"Latitude," // row[ 5]
"Longitude," // row[ 6]
"Altitude," // row[ 7]
"ShortName," // row[ 8]
"FullName," // row[ 9]
"WWW," // row[10]
"0 AS NumUsrs" // row[11]
" FROM ctr_centers"
" WHERE InsCod=%ld"
" AND CtrCod NOT IN"
" (SELECT DISTINCT CtrCod"
" FROM usr_data))"
" ORDER BY %s",
InsCod,
InsCod,
OrderBySubQuery[SelectedOrder]);
}
/*****************************************************************************/
/******************* Get centers with pending degrees ***********************/
/*****************************************************************************/
unsigned Ctr_DB_GetCtrsWithPendingDegs (MYSQL_RES **mysql_res)
{
switch (Gbl.Usrs.Me.Role.Logged)
{
case Rol_CTR_ADM:
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get centers with pending degrees",
"SELECT deg_degrees.CtrCod," // row[0]
"COUNT(*)" // row[1]
" FROM deg_degrees,"
"ctr_admin,"
"ctr_centers"
" WHERE (deg_degrees.Status & %u)<>0"
" AND deg_degrees.CtrCod=ctr_admin.CtrCod"
" AND ctr_admin.UsrCod=%ld"
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
" GROUP BY deg_degrees.CtrCod"
" ORDER BY ctr_centers.ShortName",
(unsigned) Deg_STATUS_BIT_PENDING,
Gbl.Usrs.Me.UsrDat.UsrCod);
case Rol_SYS_ADM:
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get centers with pending degrees",
"SELECT deg_degrees.CtrCod," // row[0]
"COUNT(*)" // row[1]
" FROM deg_degrees,"
"ctr_centers"
" WHERE (deg_degrees.Status & %u)<>0"
" AND deg_degrees.CtrCod=ctr_centers.CtrCod"
" GROUP BY deg_degrees.CtrCod"
" ORDER BY ctr_centers.ShortName",
(unsigned) Deg_STATUS_BIT_PENDING);
default: // Forbidden for other users
Err_WrongRoleExit ();
return 0; // Not reached
}
}
/*****************************************************************************/
/************************ Get data of center by code *************************/
/*****************************************************************************/
unsigned Ctr_DB_GetDataOfCenterByCod (MYSQL_RES **mysql_res,long CtrCod)
{
return (unsigned)
DB_QuerySELECT (mysql_res,"can not get data of a center",
"SELECT CtrCod," // row[ 0]
"InsCod," // row[ 1]
"PlcCod," // row[ 2]
"Status," // row[ 3]
"RequesterUsrCod," // row[ 4]
"Latitude," // row[ 5]
"Longitude," // row[ 6]
"Altitude," // row[ 7]
"ShortName," // row[ 8]
"FullName," // row[ 9]
"WWW" // row[10]
" FROM ctr_centers"
" WHERE CtrCod=%ld",
CtrCod);
}
/*****************************************************************************/
/*********** Get the institution code of a center from its code **************/
/*****************************************************************************/
long Ctr_DB_GetInsCodOfCenterByCod (long CtrCod)
{
/***** Trivial check: center code should be > 0 *****/
if (CtrCod <= 0)
return -1L;
/***** Get the institution code of a center from database *****/
return DB_QuerySELECTCode ("can not get the institution of a center",
"SELECT InsCod"
" FROM ctr_centers"
" WHERE CtrCod=%ld",
CtrCod);
}
/*****************************************************************************/
/*************** Get the short name of a center from its code ****************/
/*****************************************************************************/
void Ctr_DB_GetShortNameOfCenterByCod (long CtrCod,char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1])
{
/***** Trivial check: center code should be > 0 *****/
if (CtrCod <= 0)
{
ShrtName[0] = '\0';
return;
}
/***** Get the short name of a center from database *****/
DB_QuerySELECTString (ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME,
"can not get the short name of a center",
"SELECT ShortName"
" FROM ctr_centers"
" WHERE CtrCod=%ld",
CtrCod);
}
/*****************************************************************************/
/********************* Check if the name of center exists ********************/
/*****************************************************************************/
bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,
long CtrCod,long InsCod)
{
/***** Get number of centers with a name from database *****/
return (DB_QueryCOUNT ("can not check if the name of a center"
" already existed",
"SELECT COUNT(*)"
" FROM ctr_centers"
" WHERE InsCod=%ld"
" AND %s='%s'"
" AND CtrCod<>%ld",
InsCod,
FieldName,
Name,
CtrCod) != 0);
}
/*****************************************************************************/
/******* Get number of centers (of the current institution) in a place *******/
/*****************************************************************************/
unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod)
{
/***** Get number of centers (of the current institution) in a place *****/
return (unsigned)
DB_QueryCOUNT ("can not get the number of centers in a place",
"SELECT COUNT(*)"
" FROM ctr_centers"
" WHERE InsCod=%ld"
" AND PlcCod=%ld",
Gbl.Hierarchy.Ins.InsCod,
PlcCod);
}
/*****************************************************************************/
/************** Update database changing old place by new place **************/
/*****************************************************************************/
void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod)
{
DB_QueryUPDATE ("can not update the place of a center",
"UPDATE ctr_centers"
" SET PlcCod=%ld"
" WHERE CtrCod=%ld",
NewPlcCod,
CtrCod);
}
/*****************************************************************************/
/****************** Update center name in table of centers *******************/
/*****************************************************************************/
void Ctr_DB_UpdateCtrName (long CtrCod,const char *FieldName,const char *NewCtrName)
{
/***** Update center changing old name by new name */
DB_QueryUPDATE ("can not update the name of a center",
"UPDATE ctr_centers"
" SET %s='%s'"
" WHERE CtrCod=%ld",
FieldName,
NewCtrName,
CtrCod);
}
/*****************************************************************************/
/**************** Update database changing old WWW by new WWW ****************/
/*****************************************************************************/
void Ctr_DB_UpdateCtrWWW (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1])
{
/***** Update database changing old WWW by new WWW *****/
DB_QueryUPDATE ("can not update the web of a center",
"UPDATE ctr_centers"
" SET WWW='%s'"
" WHERE CtrCod=%ld",
NewWWW,
CtrCod);
}
/*****************************************************************************/
/****************************** Remove a center ******************************/
/*****************************************************************************/
void Ctr_DB_RemoveCenter (long CtrCod)
{
DB_QueryDELETE ("can not remove a center",
"DELETE FROM ctr_centers"
" WHERE CtrCod=%ld",
CtrCod);
}

View File

@ -27,10 +27,11 @@
/********************************* Headers ***********************************/
/*****************************************************************************/
// #include <mysql/mysql.h> // To access MySQL databases
#include <mysql/mysql.h> // To access MySQL databases
// #include "swad_action.h"
// #include "swad_constant.h"
#include "swad_center.h"
#include "swad_constant.h"
// #include "swad_degree.h"
// #include "swad_map.h"
// #include "swad_role_type.h"
@ -43,4 +44,24 @@
/****************************** Public prototypes ****************************/
/*****************************************************************************/
long Ctr_DB_CreateCenter (const struct Ctr_Center *Ctr,unsigned Status);
unsigned Ctr_DB_GetListOfCtrsInCurrentIns (MYSQL_RES **mysql_res);
unsigned Ctr_DB_GetListOfCtrsFull (MYSQL_RES **mysql_res,long InsCod);
unsigned Ctr_DB_GetListOfCtrsFullWithNumUsrs (MYSQL_RES **mysql_res,
long InsCod,Ctr_Order_t SelectedOrder);
unsigned Ctr_DB_GetCtrsWithPendingDegs (MYSQL_RES **mysql_res);
unsigned Ctr_DB_GetDataOfCenterByCod (MYSQL_RES **mysql_res,long CtrCod);
long Ctr_DB_GetInsCodOfCenterByCod (long CtrCod);
void Ctr_DB_GetShortNameOfCenterByCod (long CtrCod,char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]);
bool Ctr_DB_CheckIfCtrNameExistsInIns (const char *FieldName,const char *Name,
long CtrCod,long InsCod);
unsigned Ctr_DB_GetNumCtrsInPlc (long PlcCod);
void Ctr_DB_UpdateCtrPlc (long CtrCod,long NewPlcCod);
void Ctr_DB_UpdateCtrName (long CtrCod,const char *FieldName,const char *NewCtrName);
void Ctr_DB_UpdateCtrWWW (long CtrCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]);
void Ctr_DB_RemoveCenter (long CtrCod);
#endif

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 20.88 (2021-06-02)"
#define Log_PLATFORM_VERSION "SWAD 20.88.1 (2021-06-02)"
#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 20.88.1: Jun 02, 2021 Queries moved to module swad_center_database. (312668 lines)
Version 20.88: Jun 02, 2021 New module swad_center_database for database queries related to centers. (312638 lines)
Version 20.87.1: Jun 01, 2021 Database function moved from swad_calendar to swad_setting. (312549 lines)
Version 20.87: Jun 01, 2021 New module swad_building_database for database queries related to buildings. (312538 lines)

View File

@ -532,7 +532,7 @@ void Cty_DB_UpdateCtyMapAttr (const char NewMapAttribution[Med_MAX_BYTES_ATTRIBU
}
/*****************************************************************************/
/********************************* Remove country ****************************/
/******************************* Remove a country ****************************/
/*****************************************************************************/
void Cty_DB_RemoveCty (long CtyCod)

View File

@ -280,22 +280,22 @@ long Deg_DB_GetCtrCodOfDegreeByCod (long DegCod)
/************* Get the short name of a degree from its code ******************/
/*****************************************************************************/
void Deg_DB_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg)
void Deg_DB_GetShortNameOfDegreeByCod (long DegCod,char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1])
{
/***** Trivial check: degree code should be > 0 *****/
if (Deg->DegCod > 0)
if (DegCod > 0)
{
Deg->ShrtName[0] = '\0';
ShrtName[0] = '\0';
return;
}
/***** Get the short name of a degree from database *****/
DB_QuerySELECTString (Deg->ShrtName,sizeof (Deg->ShrtName) - 1,
DB_QuerySELECTString (ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME,
"can not get the short name of a degree",
"SELECT ShortName"
" FROM deg_degrees"
" WHERE DegCod=%ld",
Deg->DegCod);
DegCod);
}
/*****************************************************************************/
@ -661,7 +661,7 @@ void Deg_DB_RemoveDegTyp (long DegTypCod)
}
/*****************************************************************************/
/***************************** Remove the degree *****************************/
/****************************** Remove a degree ******************************/
/*****************************************************************************/
void Deg_DB_RemoveDeg (long DegCod)

View File

@ -53,7 +53,7 @@ void Deg_DB_GetDegTypeNameByCod (struct DegreeType *DegTyp);
unsigned Deg_DB_GetDataOfDegreeByCod (MYSQL_RES **mysql_res,long DegCod);
long Deg_DB_GetInsCodOfDegreeByCod (long DegCod);
long Deg_DB_GetCtrCodOfDegreeByCod (long DegCod);
void Deg_DB_GetShortNameOfDegreeByCod (struct Deg_Degree *Deg);
void Deg_DB_GetShortNameOfDegreeByCod (long DegCod,char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]);
bool Deg_DB_CheckIfDegreeTypeNameExists (const char *DegTypName,long DegTypCod);
unsigned Deg_DB_GetNumDegsOfType (long DegTypCod);
unsigned Deg_DB_GetDegsOfType (MYSQL_RES **mysql_res,long DegTypCod);

View File

@ -308,7 +308,6 @@ void Gbl_InitializeGlobals (void)
/* Flush caches */
Cty_FlushCacheCountryName ();
Ins_FlushCacheShortNameOfInstitution ();
Ins_FlushCacheFullNameAndCtyOfInstitution ();
Ins_FlushCacheNumInssInCty ();

View File

@ -449,11 +449,6 @@ struct Globals
Lan_Language_t Language;
char CtyName[Cty_MAX_BYTES_NAME + 1];
} CountryName;
struct
{
long InsCod;
char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1];
} InstitutionShrtName;
struct
{
long InsCod;

View File

@ -860,40 +860,22 @@ static void Ins_GetDataOfInstitFromRow (struct Ins_Instit *Ins,MYSQL_ROW row)
/*********** Get the short name of an institution from its code **************/
/*****************************************************************************/
void Ins_FlushCacheShortNameOfInstitution (void)
void Ins_DB_GetShortNameOfInstitution (long InsCod,char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1])
{
Gbl.Cache.InstitutionShrtName.InsCod = -1L;
Gbl.Cache.InstitutionShrtName.ShrtName[0] = '\0';
}
void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins)
{
/***** 1. Fast check: Trivial case *****/
if (Ins->InsCod <= 0)
/***** Trivial check: institution code should be > 0 *****/
if (InsCod <= 0)
{
Ins->ShrtName[0] = '\0'; // Empty name
ShrtName[0] = '\0'; // Empty name
return;
}
/***** 2. Fast check: If cached... *****/
if (Ins->InsCod == Gbl.Cache.InstitutionShrtName.InsCod)
{
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName,
sizeof (Ins->ShrtName) - 1);
return;
}
/***** 3. Slow: get short name of institution from database *****/
Gbl.Cache.InstitutionShrtName.InsCod = Ins->InsCod;
DB_QuerySELECTString (Gbl.Cache.InstitutionShrtName.ShrtName,
sizeof (Gbl.Cache.InstitutionShrtName.ShrtName) - 1,
/***** Get short name of institution from database *****/
DB_QuerySELECTString (ShrtName,Cns_HIERARCHY_MAX_BYTES_SHRT_NAME,
"can not get the short name of an institution",
"SELECT ShortName"
" FROM ins_instits"
" WHERE InsCod=%ld",
Ins->InsCod);
Str_Copy (Ins->ShrtName,Gbl.Cache.InstitutionShrtName.ShrtName,
sizeof (Ins->ShrtName) - 1);
InsCod);
}
/*****************************************************************************/
@ -1392,7 +1374,6 @@ void Ins_RemoveInstitution (void)
Ins_EditingIns->InsCod);
/***** Flush caches *****/
Ins_FlushCacheShortNameOfInstitution ();
Ins_FlushCacheFullNameAndCtyOfInstitution ();
Dpt_FlushCacheNumDptsInIns ();
Ctr_FlushCacheNumCtrsInIns ();
@ -1541,7 +1522,6 @@ static void Ins_UpdateInsNameDB (long InsCod,const char *FieldName,const char *N
InsCod);
/***** Flush caches *****/
Ins_FlushCacheShortNameOfInstitution ();
Ins_FlushCacheFullNameAndCtyOfInstitution ();
}

View File

@ -104,8 +104,7 @@ void Ins_GetFullListOfInstitutions (long CtyCod);
void Ins_WriteInstitutionNameAndCty (long InsCod);
bool Ins_GetDataOfInstitutionByCod (struct Ins_Instit *Ins);
void Ins_FlushCacheShortNameOfInstitution (void);
void Ins_GetShortNameOfInstitution (struct Ins_Instit *Ins);
void Ins_DB_GetShortNameOfInstitution (long InsCod,char ShrtName[Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + 1]);
void Ins_FlushCacheFullNameAndCtyOfInstitution (void);
void Ins_FreeListInstitutions (void);

View File

@ -30,6 +30,7 @@
#include "swad_action.h"
#include "swad_banner.h"
#include "swad_center_database.h"
#include "swad_config.h"
#include "swad_database.h"
#include "swad_degree_database.h"
@ -292,96 +293,95 @@ void Log_GetAndShowLastClicks (void)
/***** Write list of connected users *****/
HTM_TABLE_BeginCenterPadding (1);
HTM_TR_Begin (NULL);
HTM_TH (1,1,"LC_CLK",Txt_Click); // Click
HTM_TH (1,1,"LC_TIM",Txt_ELAPSED_TIME); // Elapsed time
HTM_TH (1,1,"LC_ROL",Txt_Role); // Role
HTM_TH (1,1,"LC_CTY",Txt_Country); // Country
HTM_TH (1,1,"LC_INS",Txt_Institution); // Institution
HTM_TH (1,1,"LC_CTR",Txt_Center); // Center
HTM_TH (1,1,"LC_DEG",Txt_Degree); // Degree
HTM_TH (1,1,"LC_ACT",Txt_Action); // Action
HTM_TR_End ();
for (NumClick = 0;
NumClick < NumClicks;
NumClick++)
{
row = mysql_fetch_row (mysql_res);
/* Get action code (row[1]) */
ActCod = Str_ConvertStrCodToLongCod (row[1]);
Action = Act_GetActionFromActCod (ActCod);
/* Use a special color for this row depending on the action */
ClassRow = (Act_GetBrowserTab (Action) == Act_DOWNLD_FILE) ? "DAT_SMALL_YELLOW" :
(ActCod == Act_GetActCod (ActLogIn ) ||
ActCod == Act_GetActCod (ActLogInNew)) ? "DAT_SMALL_GREEN" :
(ActCod == Act_GetActCod (ActLogOut )) ? "DAT_SMALL_RED" :
(ActCod == Act_GetActCod (ActWebSvc )) ? "DAT_SMALL_BLUE" :
"DAT_SMALL_GREY";
/* Compute elapsed time from last access */
if (sscanf (row[2],"%ld",&TimeDiff) != 1)
TimeDiff = (time_t) 0;
/* Get country code (row[4]) */
Hie.Cty.CtyCod = Str_ConvertStrCodToLongCod (row[4]);
Cty_GetCountryName (Hie.Cty.CtyCod,Gbl.Prefs.Language,
Hie.Cty.Name[Gbl.Prefs.Language]);
/* Get institution code (row[5]) */
Hie.Ins.InsCod = Str_ConvertStrCodToLongCod (row[5]);
Ins_GetShortNameOfInstitution (&Hie.Ins);
/* Get center code (row[6]) */
Hie.Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[6]);
Ctr_GetShortNameOfCenterByCod (&Hie.Ctr);
/* Get degree code (row[7]) */
Hie.Deg.DegCod = Str_ConvertStrCodToLongCod (row[7]);
Deg_DB_GetShortNameOfDegreeByCod (&Hie.Deg);
/* Print table row */
HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"LC_CLK %s\"",ClassRow);
HTM_Txt (row[0]); // Click
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_TIM %s\"",ClassRow); // Elapsed time
Dat_WriteHoursMinutesSecondsFromSeconds (TimeDiff);
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_ROL %s\"",ClassRow);
HTM_Txt ( // Role
Txt_ROLES_SINGUL_Abc[Rol_ConvertUnsignedStrToRole (row[3])][Usr_SEX_UNKNOWN]);
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_CTY %s\"",ClassRow);
HTM_Txt (Hie.Cty.Name[Gbl.Prefs.Language]); // Country
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_INS %s\"",ClassRow);
HTM_Txt (Hie.Ins.ShrtName); // Institution
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_CTR %s\"",ClassRow);
HTM_Txt (Hie.Ctr.ShrtName); // Center
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_DEG %s\"",ClassRow);
HTM_Txt (Hie.Deg.ShrtName); // Degree
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_ACT %s\"",ClassRow);
HTM_Txt (Act_GetActionText (Action)); // Action
HTM_TD_End ();
HTM_TH (1,1,"LC_CLK",Txt_Click); // Click
HTM_TH (1,1,"LC_TIM",Txt_ELAPSED_TIME); // Elapsed time
HTM_TH (1,1,"LC_ROL",Txt_Role); // Role
HTM_TH (1,1,"LC_CTY",Txt_Country); // Country
HTM_TH (1,1,"LC_INS",Txt_Institution); // Institution
HTM_TH (1,1,"LC_CTR",Txt_Center); // Center
HTM_TH (1,1,"LC_DEG",Txt_Degree); // Degree
HTM_TH (1,1,"LC_ACT",Txt_Action); // Action
HTM_TR_End ();
}
for (NumClick = 0;
NumClick < NumClicks;
NumClick++)
{
row = mysql_fetch_row (mysql_res);
/* Get action code (row[1]) */
ActCod = Str_ConvertStrCodToLongCod (row[1]);
Action = Act_GetActionFromActCod (ActCod);
/* Use a special color for this row depending on the action */
ClassRow = (Act_GetBrowserTab (Action) == Act_DOWNLD_FILE) ? "DAT_SMALL_YELLOW" :
(ActCod == Act_GetActCod (ActLogIn ) ||
ActCod == Act_GetActCod (ActLogInNew)) ? "DAT_SMALL_GREEN" :
(ActCod == Act_GetActCod (ActLogOut )) ? "DAT_SMALL_RED" :
(ActCod == Act_GetActCod (ActWebSvc )) ? "DAT_SMALL_BLUE" :
"DAT_SMALL_GREY";
/* Compute elapsed time from last access */
if (sscanf (row[2],"%ld",&TimeDiff) != 1)
TimeDiff = (time_t) 0;
/* Get country code (row[4]) */
Hie.Cty.CtyCod = Str_ConvertStrCodToLongCod (row[4]);
Cty_GetCountryName (Hie.Cty.CtyCod,Gbl.Prefs.Language,
Hie.Cty.Name[Gbl.Prefs.Language]);
/* Get institution code (row[5]) */
Hie.Ins.InsCod = Str_ConvertStrCodToLongCod (row[5]);
Ins_DB_GetShortNameOfInstitution (Hie.Ins.InsCod,Hie.Ins.ShrtName);
/* Get center code (row[6]) */
Hie.Ctr.CtrCod = Str_ConvertStrCodToLongCod (row[6]);
Ctr_DB_GetShortNameOfCenterByCod (Hie.Ctr.CtrCod,Hie.Ctr.ShrtName);
/* Get degree code (row[7]) */
Hie.Deg.DegCod = Str_ConvertStrCodToLongCod (row[7]);
Deg_DB_GetShortNameOfDegreeByCod (Hie.Deg.DegCod,Hie.Deg.ShrtName);
/* Print table row */
HTM_TR_Begin (NULL);
HTM_TD_Begin ("class=\"LC_CLK %s\"",ClassRow);
HTM_Txt (row[0]); // Click
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_TIM %s\"",ClassRow); // Elapsed time
Dat_WriteHoursMinutesSecondsFromSeconds (TimeDiff);
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_ROL %s\"",ClassRow);
HTM_Txt (Txt_ROLES_SINGUL_Abc[Rol_ConvertUnsignedStrToRole (row[3])][Usr_SEX_UNKNOWN]); // Role
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_CTY %s\"",ClassRow);
HTM_Txt (Hie.Cty.Name[Gbl.Prefs.Language]); // Country
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_INS %s\"",ClassRow);
HTM_Txt (Hie.Ins.ShrtName); // Institution
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_CTR %s\"",ClassRow);
HTM_Txt (Hie.Ctr.ShrtName); // Center
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_DEG %s\"",ClassRow);
HTM_Txt (Hie.Deg.ShrtName); // Degree
HTM_TD_End ();
HTM_TD_Begin ("class=\"LC_ACT %s\"",ClassRow);
HTM_Txt (Act_GetActionText (Action)); // Action
HTM_TD_End ();
HTM_TR_End ();
}
HTM_TABLE_End ();
/***** Free structure that stores the query result *****/

View File

@ -33,6 +33,7 @@
#include "swad_action.h"
#include "swad_box.h"
#include "swad_degree_database.h"
#include "swad_center_database.h"
#include "swad_error.h"
#include "swad_form.h"
#include "swad_global.h"
@ -143,7 +144,7 @@ void Lgo_DrawLogo (HieLvl_Level_t Scope,long Cod,const char *AltText,
if (Scope == HieLvl_DEG) // && !LogoFound
InsCod = Deg_DB_GetInsCodOfDegreeByCod (Cod);
else if (Scope == HieLvl_CTR) // && !LogoFound
InsCod = Ctr_GetInsCodOfCenterByCod (Cod);
InsCod = Ctr_DB_GetInsCodOfCenterByCod (Cod);
else
InsCod = Cod;
snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png",

View File

@ -1115,7 +1115,8 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
else
Frm_BeginForm (ActSeeOthPubPrf);
Usr_PutParamUsrCodEncrypted (UsrDat->EnUsrCod);
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_LINK",NULL);
HTM_BUTTON_SUBMIT_Begin (NULL,"BT_LINK",NULL);
}
/***** Hidden div to pass user's name to Javascript *****/
@ -1124,71 +1125,71 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
Frm_SetUniqueId (IdCaption);
HTM_DIV_Begin ("id=\"%s\" class=\"NOT_SHOWN\"",IdCaption);
/* First name and surnames */
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE DAT_N_BOLD\""); // Limited width
Usr_WriteFirstNameBRSurnames (UsrDat);
HTM_DIV_End ();
/* Nickname */
if (UsrDat->Nickname[0])
{
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE DAT_SMALL_N\"");
HTM_TxtF ("@%s",UsrDat->Nickname);
/* First name and surnames */
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE DAT_N_BOLD\""); // Limited width
Usr_WriteFirstNameBRSurnames (UsrDat);
HTM_DIV_End ();
}
/* Institution full name and institution country */
if (UsrDat->InsCod > 0)
{
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE DAT_SMALL\"");
Ins_WriteInstitutionNameAndCty (UsrDat->InsCod);
HTM_DIV_End ();
}
/* User's country */
else if (UsrDat->CtyCod > 0)
{
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE DAT_SMALL\"");
Cty_WriteCountryName (UsrDat->CtyCod,
NULL); // Don't put link to country
HTM_DIV_End ();
}
/* Nickname */
if (UsrDat->Nickname[0])
{
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE DAT_SMALL_N\"");
HTM_TxtF ("@%s",UsrDat->Nickname);
HTM_DIV_End ();
}
/* Main degree (in which the user has more courses) short name */
Usr_GetMainDeg (UsrDat->UsrCod,MainDegreeShrtName,&MaxRole);
if (MainDegreeShrtName[0])
{
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE DAT_SMALL\"");
HTM_DIV_Begin ("class=\"ZOOM_DEG\" style=\"background-image:url('%s/%s');\"",
Cfg_URL_ICON_PUBLIC,Rol_Icons[MaxRole]);
HTM_Txt (MainDegreeShrtName);
HTM_DIV_End ();
HTM_DIV_End ();
}
/* Institution full name and institution country */
if (UsrDat->InsCod > 0)
{
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE DAT_SMALL\"");
Ins_WriteInstitutionNameAndCty (UsrDat->InsCod);
HTM_DIV_End ();
}
/* User's country */
else if (UsrDat->CtyCod > 0)
{
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE DAT_SMALL\"");
Cty_WriteCountryName (UsrDat->CtyCod,
NULL); // Don't put link to country
HTM_DIV_End ();
}
/* Following and followers */
if (UsrDat->Nickname[0]) // Get social data only if nickname is retrieved (in some actions)
{
Fol_GetNumFollow (UsrDat->UsrCod,&NumFollowing,&NumFollowers);
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE\"");
/* Main degree (in which the user has more courses) short name */
Usr_GetMainDeg (UsrDat->UsrCod,MainDegreeShrtName,&MaxRole);
if (MainDegreeShrtName[0])
{
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE DAT_SMALL\"");
HTM_DIV_Begin ("class=\"ZOOM_DEG\" style=\"background-image:url('%s/%s');\"",
Cfg_URL_ICON_PUBLIC,Rol_Icons[MaxRole]);
HTM_Txt (MainDegreeShrtName);
HTM_DIV_End ();
HTM_DIV_End ();
}
HTM_SPAN_Begin ("class=\"DAT_N_BOLD\"");
HTM_Unsigned (NumFollowing);
HTM_SPAN_End ();
/* Following and followers */
if (UsrDat->Nickname[0]) // Get social data only if nickname is retrieved (in some actions)
{
Fol_GetNumFollow (UsrDat->UsrCod,&NumFollowing,&NumFollowers);
HTM_DIV_Begin ("class=\"ZOOM_TXT_LINE\"");
HTM_SPAN_Begin ("class=\"DAT_SMALL\"");
HTM_TxtF ("&nbsp;%s&nbsp;",Txt_Following);
HTM_SPAN_End ();
HTM_SPAN_Begin ("class=\"DAT_N_BOLD\"");
HTM_Unsigned (NumFollowing);
HTM_SPAN_End ();
HTM_SPAN_Begin ("class=\"DAT_N_BOLD\"");
HTM_Unsigned (NumFollowers);
HTM_SPAN_End ();
HTM_SPAN_Begin ("class=\"DAT_SMALL\"");
HTM_TxtF ("&nbsp;%s&nbsp;",Txt_Following);
HTM_SPAN_End ();
HTM_SPAN_Begin ("class=\"DAT_SMALL\"");
HTM_TxtF ("&nbsp;%s",Txt_Followers);
HTM_SPAN_End ();
HTM_SPAN_Begin ("class=\"DAT_N_BOLD\"");
HTM_Unsigned (NumFollowers);
HTM_SPAN_End ();
HTM_DIV_End ();
}
HTM_SPAN_Begin ("class=\"DAT_SMALL\"");
HTM_TxtF ("&nbsp;%s",Txt_Followers);
HTM_SPAN_End ();
HTM_DIV_End ();
}
HTM_DIV_End ();
}
@ -1226,7 +1227,8 @@ void Pho_ShowUsrPhoto (const struct UsrData *UsrDat,const char *PhotoURL,
/***** End form to go to public profile *****/
if (PutLinkToPublicProfile)
{
HTM_BUTTON_End ();
HTM_BUTTON_End ();
Frm_EndForm ();
}
}

View File

@ -363,7 +363,7 @@ void Set_DB_ChangeFirstDayOfWeek (unsigned FirstDayOfWeek)
"UPDATE usr_data"
" SET FirstDayOfWeek=%u"
" WHERE UsrCod=%ld",
Gbl.Prefs.FirstDayOfWeek,
FirstDayOfWeek,
Gbl.Usrs.Me.UsrDat.UsrCod);
}