diff --git a/swad_centre.c b/swad_centre.c index 56ac9f190..4e2d0942a 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -944,6 +944,36 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr) return CtrFound; } +/*****************************************************************************/ +/*********** Get the institution code of a centre from its code **************/ +/*****************************************************************************/ + +long Ctr_GetInsCodOfCentreByCod (long CtrCod) + { + char Query[128]; + MYSQL_RES *mysql_res; + MYSQL_ROW row; + long InsCod = -1L; + + if (CtrCod > 0) + { + /***** Get the institution code of a centre from database *****/ + sprintf (Query,"SELECT InsCod FROM centres WHERE CtrCod ='%ld'", + CtrCod); + if (DB_QuerySELECT (Query,&mysql_res,"can not get the institution of a centre") == 1) + { + /***** Get the institution code of this centre *****/ + row = mysql_fetch_row (mysql_res); + CtrCod = Str_ConvertStrCodToLongCod (row[0]); + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + + return InsCod; + } + /*****************************************************************************/ /******************* Get photo attribution from database *********************/ /*****************************************************************************/ diff --git a/swad_centre.h b/swad_centre.h index 60c56c836..06b4065fb 100644 --- a/swad_centre.h +++ b/swad_centre.h @@ -92,6 +92,7 @@ void Ctr_ShowCtrsOfCurrentIns (void); void Ctr_EditCentres (void); void Ctr_GetListCentres (long InsCod); bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr); +long Ctr_GetInsCodOfCentreByCod (long CtrCod); void Ctr_FreeListCentres (void); void Ctr_WriteSelectorOfCentre (Act_Action_t NextAction); void Ctr_PutParamCtrCod (long CtrCod); diff --git a/swad_changelog.h b/swad_changelog.h index d1587dc39..03831a878 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -39,11 +39,12 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.72.5 (2015/02/01)" +#define Log_PLATFORM_VERSION "SWAD 14.72.6 (2015/02/03)" // 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 | tail -1 /* + Version 14.72.6: Feb 03, 2015 Changes in icons for degrees and centres. (176883 lines) Version 14.72.5: Feb 01, 2015 Changed related to administrators. (176805 lines) Version 14.72.4: Feb 01, 2015 Refactoring of registering and removing admins. (176787 lines) Version 14.72.3: Feb 01, 2015 Refactoring of registering and removing admins. (177139 lines) diff --git a/swad_config.h b/swad_config.h index 026614fa1..4702408af 100644 --- a/swad_config.h +++ b/swad_config.h @@ -28,8 +28,8 @@ /** Uncomment one of the following installations of SWAD or create your own **/ /*****************************************************************************/ -#define LOCALHOST_UBUNTU // Comment this line if not applicable -//#define OPENSWAD_ORG // Comment this line if not applicable +//#define LOCALHOST_UBUNTU // Comment this line if not applicable +#define OPENSWAD_ORG // Comment this line if not applicable //#define SWAD_UGR_ES // Comment this line if not applicable //#define WWW_CEVUNA_UNA_PY // Comment this line if not applicable diff --git a/swad_degree.c b/swad_degree.c index 27ffcba7a..bb1381c14 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -3053,26 +3053,56 @@ void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg) } } +/*****************************************************************************/ +/************* Get the centre code of a degree from its code *****************/ +/*****************************************************************************/ + +long Deg_GetCtrCodOfDegreeByCod (long DegCod) + { + char Query[128]; + MYSQL_RES *mysql_res; + MYSQL_ROW row; + long CtrCod = -1L; + + if (DegCod > 0) + { + /***** Get the centre code of a degree from database *****/ + sprintf (Query,"SELECT CtrCod FROM degrees WHERE DegCod ='%ld'", + DegCod); + if (DB_QuerySELECT (Query,&mysql_res,"can not get the centre of a degree") == 1) + { + /***** Get the centre code of this degree *****/ + row = mysql_fetch_row (mysql_res); + CtrCod = Str_ConvertStrCodToLongCod (row[0]); + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + + return CtrCod; + } + /*****************************************************************************/ /********** Get the institution code of a degree from its code ***************/ /*****************************************************************************/ long Deg_GetInsCodOfDegreeByCod (long DegCod) { - char Query[512]; + char Query[256]; MYSQL_RES *mysql_res; MYSQL_ROW row; long InsCod = -1L; if (DegCod > 0) { - /***** Get the short name of a degree from database *****/ + /***** Get the institution code of a degree from database *****/ sprintf (Query,"SELECT centres.InsCod FROM degrees,centres" " WHERE degrees.DegCod ='%ld' AND degrees.CtrCod=centres.CtrCod", DegCod); if (DB_QuerySELECT (Query,&mysql_res,"can not get the institution of a degree") == 1) { - /***** Get the institution of this degree *****/ + /***** Get the institution code of this degree *****/ row = mysql_fetch_row (mysql_res); InsCod = Str_ConvertStrCodToLongCod (row[0]); } diff --git a/swad_degree.h b/swad_degree.h index 4faf4d45a..03d7ca73d 100644 --- a/swad_degree.h +++ b/swad_degree.h @@ -139,6 +139,7 @@ unsigned Deg_CountNumDegsInCtr (long CtrCod); bool Deg_GetDataOfDegreeTypeByCod (struct DegreeType *DegTyp); bool Deg_GetDataOfDegreeByCod (struct Degree *Deg); void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg); +long Deg_GetCtrCodOfDegreeByCod (long DegCod); long Deg_GetInsCodOfDegreeByCod (long DegCod); void Deg_RenameDegreeType (void); void Deg_RenameDegreeShort (void); diff --git a/swad_logo.c b/swad_logo.c index 5ecfe0f9a..4a548a75b 100644 --- a/swad_logo.c +++ b/swad_logo.c @@ -65,56 +65,81 @@ extern struct Globals Gbl; void Log_DrawLogo (Sco_Scope_t Scope,long Cod,const char *AltText, unsigned Size,const char *Style,bool PutIconIfNotExists) { - const char *Folder; - const char *Icon; - char PathLogo[PATH_MAX+1]; - bool LogoExists; - - /***** Set variables depending on scope *****/ - switch (Scope) + static const char *Icon[Sco_NUM_SCOPES] = { - case Sco_SCOPE_INS: - Folder = Cfg_FOLDER_INS; - Icon = "ins"; - break; - case Sco_SCOPE_CTR: - Folder = Cfg_FOLDER_CTR; - Icon = "ctr"; - break; - case Sco_SCOPE_DEG: - Folder = Cfg_FOLDER_DEG; - Icon = "deg"; - break; - default: - return; // Nothing to do - } + NULL, // Sco_SCOPE_UNK + NULL, // Sco_SCOPE_SYS + NULL, // Sco_SCOPE_CTY + Cfg_FOLDER_INS, // Sco_SCOPE_INS + Cfg_FOLDER_CTR, // Sco_SCOPE_CTR + Cfg_FOLDER_DEG, // Sco_SCOPE_DEG + NULL, // Sco_SCOPE_CRS + }; + const char *Folder; + char PathLogo[PATH_MAX+1]; + bool LogoFound = false; /***** Path to logo *****/ if (Cod > 0) { - sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", - Cfg_PATH_SWAD_PUBLIC,Folder, - (unsigned) (Cod % 100), - (unsigned) Cod, - (unsigned) Cod); - LogoExists = Fil_CheckIfPathExists (PathLogo); + /* Degree */ + if (Scope == Sco_SCOPE_DEG) + { + Folder = Cfg_FOLDER_DEG; + sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", + Cfg_PATH_SWAD_PUBLIC,Folder, + (unsigned) (Cod % 100), + (unsigned) Cod, + (unsigned) Cod); + LogoFound = Fil_CheckIfPathExists (PathLogo); + } + + /* Centre */ + if (!LogoFound || Scope == Sco_SCOPE_CTR) + { + Folder = Cfg_FOLDER_CTR; + if (Scope == Sco_SCOPE_DEG) + Cod = Deg_GetCtrCodOfDegreeByCod (Cod); + sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", + Cfg_PATH_SWAD_PUBLIC,Folder, + (unsigned) (Cod % 100), + (unsigned) Cod, + (unsigned) Cod); + LogoFound = Fil_CheckIfPathExists (PathLogo); + } + + /* Institution */ + if (!LogoFound || Scope == Sco_SCOPE_INS) + { + Folder = Cfg_FOLDER_INS; + if (Scope == Sco_SCOPE_DEG) + Cod = Deg_GetInsCodOfDegreeByCod (Cod); + else if (Scope == Sco_SCOPE_CTR) + Cod = Ctr_GetInsCodOfCentreByCod (Cod); + sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", + Cfg_PATH_SWAD_PUBLIC,Folder, + (unsigned) (Cod % 100), + (unsigned) Cod, + (unsigned) Cod); + LogoFound = Fil_CheckIfPathExists (PathLogo); + } } else - LogoExists = false; + LogoFound = false; - if (LogoExists || PutIconIfNotExists) + if (LogoFound || PutIconIfNotExists) { /***** Draw logo *****/ fprintf (Gbl.F.Out,"