2021-03-07 21:21:04 +01:00
|
|
|
|
// swad_logo.c: logo of institution, center or degree
|
2015-01-17 20:07:13 +01:00
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
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.
|
2024-02-07 00:40:28 +01:00
|
|
|
|
Copyright (C) 1999-2024 Antonio Ca<EFBFBD>as Vargas
|
2015-01-17 20:07:13 +01:00
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General 3 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 *********************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-10-30 22:31:03 +01:00
|
|
|
|
#define _GNU_SOURCE // For asprintf
|
|
|
|
|
#include <stdio.h> // For asprintf
|
2019-11-04 23:33:59 +01:00
|
|
|
|
#include <stdlib.h> // For free
|
2015-01-17 20:07:13 +01:00
|
|
|
|
#include <string.h> // For string functions
|
|
|
|
|
|
|
|
|
|
#include "swad_action.h"
|
2022-11-06 18:11:10 +01:00
|
|
|
|
#include "swad_action_list.h"
|
2022-10-19 18:07:49 +02:00
|
|
|
|
#include "swad_alert.h"
|
2017-06-10 21:38:10 +02:00
|
|
|
|
#include "swad_box.h"
|
2021-06-02 13:09:30 +02:00
|
|
|
|
#include "swad_center_database.h"
|
2023-11-07 11:01:14 +01:00
|
|
|
|
#include "swad_course_database.h"
|
|
|
|
|
#include "swad_degree_database.h"
|
2021-04-26 15:27:27 +02:00
|
|
|
|
#include "swad_error.h"
|
2018-11-09 20:47:39 +01:00
|
|
|
|
#include "swad_form.h"
|
2015-01-17 20:07:13 +01:00
|
|
|
|
#include "swad_global.h"
|
2019-10-23 20:07:56 +02:00
|
|
|
|
#include "swad_HTML.h"
|
2015-01-17 20:07:13 +01:00
|
|
|
|
#include "swad_scope.h"
|
|
|
|
|
#include "swad_theme.h"
|
|
|
|
|
|
2023-09-19 22:27:20 +02:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/**************************** Private constants ******************************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
static const char *Lgo_Folder[Hie_NUM_LEVELS] =
|
2023-09-19 22:27:20 +02:00
|
|
|
|
{
|
2023-09-22 14:47:56 +02:00
|
|
|
|
[Hie_INS] = Cfg_FOLDER_INS,
|
|
|
|
|
[Hie_CTR] = Cfg_FOLDER_CTR,
|
|
|
|
|
[Hie_DEG] = Cfg_FOLDER_DEG,
|
2023-09-19 22:27:20 +02:00
|
|
|
|
};
|
|
|
|
|
|
2015-01-17 20:07:13 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** External global variables from others modules ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
extern struct Globals Gbl;
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-11-21 16:47:07 +01:00
|
|
|
|
/***************************** Private prototypes ****************************/
|
2015-01-17 20:07:13 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
static void Lgo_PutIconToRemoveLogoIns (__attribute__((unused)) void *Args);
|
|
|
|
|
static void Lgo_PutIconToRemoveLogoCtr (__attribute__((unused)) void *Args);
|
|
|
|
|
static void Lgo_PutIconToRemoveLogoDeg (__attribute__((unused)) void *Args);
|
2019-12-23 22:13:02 +01:00
|
|
|
|
static void Lgo_PutIconToRemoveLogo (Act_Action_t ActionRem);
|
|
|
|
|
|
2015-01-17 20:07:13 +01:00
|
|
|
|
/*****************************************************************************/
|
2022-10-05 01:32:04 +02:00
|
|
|
|
/***************** Draw institution, center or degree logo *******************/
|
2015-01-17 20:07:13 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-11-28 01:44:05 +01:00
|
|
|
|
void Lgo_DrawLogo (Hie_Level_t Level,const struct Hie_Node *Node,
|
|
|
|
|
const char *IconClass)
|
2015-01-17 20:07:13 +01:00
|
|
|
|
{
|
2023-11-28 01:44:05 +01:00
|
|
|
|
extern const char *Hie_Icons[Hie_NUM_LEVELS];
|
2015-02-03 18:43:55 +01:00
|
|
|
|
const char *Folder = NULL; // To avoid warning
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char PathLogo[PATH_MAX + 1];
|
2023-11-07 19:06:18 +01:00
|
|
|
|
bool LogoFound = false;
|
2023-11-28 01:44:05 +01:00
|
|
|
|
long HieCod;
|
|
|
|
|
long InsCod;
|
|
|
|
|
long CtrCod;
|
|
|
|
|
long DegCod;
|
|
|
|
|
long CrsCod;
|
2019-10-30 22:31:03 +01:00
|
|
|
|
char *URL;
|
|
|
|
|
char *Icon;
|
2015-01-17 20:07:13 +01:00
|
|
|
|
|
2023-11-28 01:44:05 +01:00
|
|
|
|
switch (Level)
|
2015-01-17 20:07:13 +01:00
|
|
|
|
{
|
2023-11-28 01:44:05 +01:00
|
|
|
|
case Hie_SYS:
|
|
|
|
|
Ico_PutIcon (Hie_Icons[Hie_SYS],Ico_BLACK,Node->ShrtName,IconClass);
|
|
|
|
|
break;
|
|
|
|
|
case Hie_CTY:
|
|
|
|
|
Cty_DrawCountryMap (Node,IconClass);
|
|
|
|
|
break;
|
|
|
|
|
case Hie_INS:
|
|
|
|
|
case Hie_CTR:
|
|
|
|
|
case Hie_DEG:
|
|
|
|
|
case Hie_CRS:
|
|
|
|
|
if (Node->HieCod > 0) // Institution, center, degree or course exists
|
2015-02-10 14:58:50 +01:00
|
|
|
|
{
|
2023-11-28 01:44:05 +01:00
|
|
|
|
HieCod =
|
|
|
|
|
InsCod =
|
|
|
|
|
CtrCod =
|
|
|
|
|
DegCod =
|
|
|
|
|
CrsCod = Node->HieCod;
|
|
|
|
|
|
|
|
|
|
/* Course */
|
|
|
|
|
|
|
|
|
|
/* Degree */
|
|
|
|
|
if (!LogoFound && Level >= Hie_DEG)
|
|
|
|
|
{
|
|
|
|
|
Folder = Cfg_FOLDER_DEG;
|
|
|
|
|
if (Level >= Hie_CRS)
|
|
|
|
|
DegCod = Crs_DB_GetDegCodOfCourseByCod (CrsCod);
|
|
|
|
|
snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png",
|
|
|
|
|
Cfg_PATH_DEG_PUBLIC,
|
|
|
|
|
(unsigned) (DegCod % 100),
|
|
|
|
|
(unsigned) DegCod,
|
|
|
|
|
(unsigned) DegCod);
|
|
|
|
|
LogoFound = Fil_CheckIfPathExists (PathLogo);
|
|
|
|
|
if (LogoFound)
|
|
|
|
|
HieCod = DegCod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Center */
|
|
|
|
|
if (!LogoFound && Level >= Hie_CTR)
|
|
|
|
|
{
|
|
|
|
|
Folder = Cfg_FOLDER_CTR;
|
|
|
|
|
if (Level >= Hie_DEG)
|
|
|
|
|
CtrCod = Deg_DB_GetCtrCodOfDegreeByCod (DegCod);
|
|
|
|
|
else
|
|
|
|
|
CtrCod = HieCod;
|
|
|
|
|
snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png",
|
|
|
|
|
Cfg_PATH_CTR_PUBLIC,
|
|
|
|
|
(unsigned) (CtrCod % 100),
|
|
|
|
|
(unsigned) CtrCod,
|
|
|
|
|
(unsigned) CtrCod);
|
|
|
|
|
LogoFound = Fil_CheckIfPathExists (PathLogo);
|
|
|
|
|
if (LogoFound)
|
|
|
|
|
HieCod = CtrCod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Institution */
|
|
|
|
|
if (!LogoFound)
|
|
|
|
|
{
|
|
|
|
|
Folder = Cfg_FOLDER_INS;
|
|
|
|
|
if (Level >= Hie_CTR)
|
|
|
|
|
InsCod = Ctr_DB_GetInsCodOfCenterByCod (CtrCod);
|
|
|
|
|
snprintf (PathLogo,sizeof (PathLogo),"%s/%02u/%u/logo/%u.png",
|
|
|
|
|
Cfg_PATH_INS_PUBLIC,
|
|
|
|
|
(unsigned) (InsCod % 100),
|
|
|
|
|
(unsigned) InsCod,
|
|
|
|
|
(unsigned) InsCod);
|
|
|
|
|
LogoFound = Fil_CheckIfPathExists (PathLogo);
|
|
|
|
|
if (LogoFound)
|
|
|
|
|
HieCod = InsCod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/***** Draw logo *****/
|
2015-02-10 15:07:28 +01:00
|
|
|
|
if (LogoFound)
|
2023-11-28 01:44:05 +01:00
|
|
|
|
{
|
|
|
|
|
if (asprintf (&URL,"%s/%s/%02u/%u/logo",
|
|
|
|
|
Cfg_URL_SWAD_PUBLIC,Folder,
|
|
|
|
|
(unsigned) (HieCod % 100),
|
|
|
|
|
(unsigned) HieCod) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
if (asprintf (&Icon,"%u.png",(unsigned) HieCod) < 0)
|
|
|
|
|
Err_NotEnoughMemoryExit ();
|
|
|
|
|
|
|
|
|
|
HTM_IMG (URL,Icon,Node->FullName,
|
|
|
|
|
"class=\"%s\"",IconClass);
|
|
|
|
|
free (Icon);
|
|
|
|
|
free (URL);
|
|
|
|
|
}
|
2015-02-10 14:58:50 +01:00
|
|
|
|
else
|
2023-11-28 01:44:05 +01:00
|
|
|
|
HTM_IMG (Cfg_URL_ICON_PUBLIC,Hie_Icons[Level],Node->ShrtName,
|
|
|
|
|
"class=\"%s ICO_%s_%s\"",
|
|
|
|
|
IconClass,
|
|
|
|
|
Ico_GetPreffix (Ico_BLACK),The_GetSuffix ());
|
2016-07-27 14:58:26 +02:00
|
|
|
|
}
|
2023-11-28 01:44:05 +01:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2015-01-17 20:07:13 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2016-05-05 20:16:28 +02:00
|
|
|
|
/************* Put an icon to go to the action used to request ***************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/************* the logo of institution, center or degree ***************/
|
2015-01-17 20:07:13 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
void Lgo_PutIconToChangeLogo (Hie_Level_t Level)
|
2015-01-17 20:07:13 +01:00
|
|
|
|
{
|
2024-03-20 09:39:04 +01:00
|
|
|
|
static Act_Action_t Action[Hie_NUM_LEVELS] =
|
2015-01-17 20:07:13 +01:00
|
|
|
|
{
|
2024-03-20 09:39:04 +01:00
|
|
|
|
[Hie_UNK] = ActUnk,
|
|
|
|
|
[Hie_SYS] = ActUnk,
|
|
|
|
|
[Hie_CTY] = ActUnk,
|
|
|
|
|
[Hie_INS] = ActReqInsLog,
|
|
|
|
|
[Hie_CTR] = ActReqCtrLog,
|
|
|
|
|
[Hie_DEG] = ActReqDegLog,
|
|
|
|
|
[Hie_CRS] = ActUnk,
|
2022-06-29 18:04:45 +02:00
|
|
|
|
};
|
2015-01-17 20:07:13 +01:00
|
|
|
|
|
2023-07-11 19:12:24 +02:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (Action[Level],NULL,
|
2020-03-26 02:54:30 +01:00
|
|
|
|
NULL,NULL,
|
2022-06-29 18:34:15 +02:00
|
|
|
|
"shield-alt.svg",Ico_BLACK);
|
2015-01-17 20:07:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/**** Show a form for sending a logo of the institution, center or degree ****/
|
2015-01-17 20:07:13 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
void Lgo_RequestLogo (Hie_Level_t Level)
|
2015-01-17 20:07:13 +01:00
|
|
|
|
{
|
2015-04-12 01:40:51 +02:00
|
|
|
|
extern const char *Txt_Logo;
|
2016-11-10 12:38:41 +01:00
|
|
|
|
extern const char *Txt_You_can_send_a_file_with_an_image_in_PNG_format_transparent_background_and_size_X_Y;
|
2015-01-17 20:07:13 +01:00
|
|
|
|
extern const char *Txt_File_with_the_logo;
|
2024-03-20 09:39:04 +01:00
|
|
|
|
static Act_Action_t ActionRec[Hie_NUM_LEVELS] =
|
2015-01-17 20:07:13 +01:00
|
|
|
|
{
|
2023-09-22 14:47:56 +02:00
|
|
|
|
[Hie_INS] = ActRecInsLog,
|
|
|
|
|
[Hie_CTR] = ActRecCtrLog,
|
|
|
|
|
[Hie_DEG] = ActRecDegLog,
|
2023-09-19 22:27:20 +02:00
|
|
|
|
};
|
2023-09-22 14:47:56 +02:00
|
|
|
|
static void (*FunctionToDrawContextualIcons[Hie_NUM_LEVELS]) (void *Args) =
|
2023-09-19 22:27:20 +02:00
|
|
|
|
{
|
2023-09-22 14:47:56 +02:00
|
|
|
|
[Hie_INS] = Lgo_PutIconToRemoveLogoIns,
|
|
|
|
|
[Hie_CTR] = Lgo_PutIconToRemoveLogoCtr,
|
|
|
|
|
[Hie_DEG] = Lgo_PutIconToRemoveLogoDeg,
|
2023-09-19 22:27:20 +02:00
|
|
|
|
};
|
2023-09-20 10:36:07 +02:00
|
|
|
|
long Cod = Gbl.Hierarchy.Node[Level].HieCod;
|
2023-09-19 22:27:20 +02:00
|
|
|
|
char PathLogo[PATH_MAX + 1];
|
2015-01-17 20:07:13 +01:00
|
|
|
|
|
2015-02-03 18:43:55 +01:00
|
|
|
|
/***** Check if logo exists *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (PathLogo,sizeof (PathLogo),"%s/%s/%02u/%u/logo/%u.png",
|
2023-09-19 22:27:20 +02:00
|
|
|
|
Cfg_PATH_SWAD_PUBLIC,Lgo_Folder[Level],
|
2018-10-18 02:02:32 +02:00
|
|
|
|
(unsigned) (Cod % 100),
|
2021-02-15 16:25:55 +01:00
|
|
|
|
(unsigned) Cod,
|
|
|
|
|
(unsigned) Cod);
|
2015-04-12 01:40:51 +02:00
|
|
|
|
|
2019-10-26 02:19:42 +02:00
|
|
|
|
/***** Begin box *****/
|
2024-01-29 09:45:28 +01:00
|
|
|
|
Box_BoxBegin (Txt_Logo,
|
2023-09-19 22:27:20 +02:00
|
|
|
|
Fil_CheckIfPathExists (PathLogo) ? FunctionToDrawContextualIcons[Level] :
|
|
|
|
|
NULL,NULL,
|
2017-06-12 15:03:29 +02:00
|
|
|
|
NULL,Box_NOT_CLOSABLE);
|
2015-04-12 01:40:51 +02:00
|
|
|
|
|
2021-07-08 15:00:17 +02:00
|
|
|
|
/***** Begin form to upload logo *****/
|
2023-09-19 22:27:20 +02:00
|
|
|
|
Frm_BeginForm (ActionRec[Level]);
|
2021-07-08 15:00:17 +02:00
|
|
|
|
|
|
|
|
|
/***** Write help message *****/
|
|
|
|
|
Ale_ShowAlert (Ale_INFO,Txt_You_can_send_a_file_with_an_image_in_PNG_format_transparent_background_and_size_X_Y,
|
|
|
|
|
64,64);
|
|
|
|
|
|
|
|
|
|
/***** Upload logo *****/
|
2022-04-05 01:00:24 +02:00
|
|
|
|
HTM_LABEL_Begin ("class=\"FORM_IN_%s\"",The_GetSuffix ());
|
2021-07-08 15:00:17 +02:00
|
|
|
|
HTM_TxtColonNBSP (Txt_File_with_the_logo);
|
|
|
|
|
HTM_INPUT_FILE (Fil_NAME_OF_PARAM_FILENAME_ORG,"image/png",
|
|
|
|
|
HTM_SUBMIT_ON_CHANGE,
|
|
|
|
|
NULL);
|
|
|
|
|
HTM_LABEL_End ();
|
|
|
|
|
|
|
|
|
|
/***** End form *****/
|
|
|
|
|
Frm_EndForm ();
|
2019-12-23 22:13:02 +01:00
|
|
|
|
|
2017-06-12 14:16:33 +02:00
|
|
|
|
/***** End box *****/
|
2019-10-25 22:48:34 +02:00
|
|
|
|
Box_BoxEnd ();
|
2019-12-23 22:13:02 +01:00
|
|
|
|
}
|
2015-04-12 01:40:51 +02:00
|
|
|
|
|
2019-12-23 22:13:02 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
/************** Put a link to request the removal of the logo ****************/
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
static void Lgo_PutIconToRemoveLogoIns (__attribute__((unused)) void *Args)
|
2019-12-23 22:13:02 +01:00
|
|
|
|
{
|
2020-04-08 19:42:03 +02:00
|
|
|
|
Lgo_PutIconToRemoveLogo (ActRemInsLog);
|
2019-12-23 22:13:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
static void Lgo_PutIconToRemoveLogoCtr (__attribute__((unused)) void *Args)
|
2019-12-23 22:13:02 +01:00
|
|
|
|
{
|
2020-04-08 19:42:03 +02:00
|
|
|
|
Lgo_PutIconToRemoveLogo (ActRemCtrLog);
|
2019-12-23 22:13:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-08 19:42:03 +02:00
|
|
|
|
static void Lgo_PutIconToRemoveLogoDeg (__attribute__((unused)) void *Args)
|
2019-12-23 22:13:02 +01:00
|
|
|
|
{
|
2020-04-08 19:42:03 +02:00
|
|
|
|
Lgo_PutIconToRemoveLogo (ActRemDegLog);
|
2019-12-23 22:13:02 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void Lgo_PutIconToRemoveLogo (Act_Action_t ActionRem)
|
|
|
|
|
{
|
2020-03-26 02:54:30 +01:00
|
|
|
|
Lay_PutContextualLinkOnlyIcon (ActionRem,NULL,
|
|
|
|
|
NULL,NULL,
|
2022-06-29 18:34:15 +02:00
|
|
|
|
"trash.svg",Ico_RED);
|
2015-01-17 20:07:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/******* Receive the logo of the current institution, center or degree *******/
|
2015-01-17 20:07:13 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
void Lgo_ReceiveLogo (Hie_Level_t Level)
|
2015-01-17 20:07:13 +01:00
|
|
|
|
{
|
|
|
|
|
extern const char *Txt_The_file_is_not_X;
|
2023-09-20 10:36:07 +02:00
|
|
|
|
long Cod = Gbl.Hierarchy.Node[Level].HieCod;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char Path[PATH_MAX + 1];
|
2023-03-10 00:13:55 +01:00
|
|
|
|
struct Par_Param *Par;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char FileNameLogoSrc[PATH_MAX + 1];
|
2017-01-15 18:02:52 +01:00
|
|
|
|
char MIMEType[Brw_MAX_BYTES_MIME_TYPE + 1];
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char FileNameLogo[PATH_MAX + 1]; // Full name (including path and .png) of the destination file
|
2015-01-17 20:07:13 +01:00
|
|
|
|
bool WrongType = false;
|
|
|
|
|
|
|
|
|
|
/***** Creates directories if not exist *****/
|
2023-09-19 22:27:20 +02:00
|
|
|
|
snprintf (Path,sizeof (Path),"%s/%s",
|
|
|
|
|
Cfg_PATH_SWAD_PUBLIC,Lgo_Folder[Level]);
|
2015-01-17 20:07:13 +01:00
|
|
|
|
Fil_CreateDirIfNotExists (Path);
|
2023-09-19 22:27:20 +02:00
|
|
|
|
snprintf (Path,sizeof (Path),"%s/%s/%02u",
|
|
|
|
|
Cfg_PATH_SWAD_PUBLIC,Lgo_Folder[Level],
|
2018-10-18 02:02:32 +02:00
|
|
|
|
(unsigned) (Cod % 100));
|
2015-01-17 20:07:13 +01:00
|
|
|
|
Fil_CreateDirIfNotExists (Path);
|
2023-09-19 22:27:20 +02:00
|
|
|
|
snprintf (Path,sizeof (Path),"%s/%s/%02u/%u",
|
|
|
|
|
Cfg_PATH_SWAD_PUBLIC,Lgo_Folder[Level],
|
2018-10-18 02:02:32 +02:00
|
|
|
|
(unsigned) (Cod % 100),
|
2021-02-15 16:25:55 +01:00
|
|
|
|
(unsigned) Cod);
|
2015-01-17 20:07:13 +01:00
|
|
|
|
Fil_CreateDirIfNotExists (Path);
|
2023-09-19 22:27:20 +02:00
|
|
|
|
snprintf (Path,sizeof (Path),"%s/%s/%02u/%u/logo",
|
|
|
|
|
Cfg_PATH_SWAD_PUBLIC,Lgo_Folder[Level],
|
2018-10-18 02:02:32 +02:00
|
|
|
|
(unsigned) (Cod % 100),
|
2021-02-15 16:25:55 +01:00
|
|
|
|
(unsigned) Cod);
|
2015-01-17 20:07:13 +01:00
|
|
|
|
Fil_CreateDirIfNotExists (Path);
|
|
|
|
|
|
2022-10-21 12:11:50 +02:00
|
|
|
|
/***** Copy in disk the file received *****/
|
2023-03-10 00:13:55 +01:00
|
|
|
|
Par = Fil_StartReceptionOfFile (Fil_NAME_OF_PARAM_FILENAME_ORG,
|
2016-04-04 12:13:37 +02:00
|
|
|
|
FileNameLogoSrc,MIMEType);
|
2015-01-17 20:07:13 +01:00
|
|
|
|
|
|
|
|
|
/* Check if the file type is image/jpeg or image/pjpeg or application/octet-stream */
|
|
|
|
|
if (strcmp (MIMEType,"image/png"))
|
|
|
|
|
if (strcmp (MIMEType,"image/x-png"))
|
|
|
|
|
if (strcmp (MIMEType,"application/octet-stream"))
|
|
|
|
|
if (strcmp (MIMEType,"application/octetstream"))
|
|
|
|
|
if (strcmp (MIMEType,"application/octet"))
|
|
|
|
|
WrongType = true;
|
|
|
|
|
if (WrongType)
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_WARNING,Txt_The_file_is_not_X,
|
|
|
|
|
"png");
|
2015-02-03 18:43:55 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* End the reception of logo in a temporary file */
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (FileNameLogo,sizeof (FileNameLogo),"%s/%s/%02u/%u/logo/%u.png",
|
2023-09-19 22:27:20 +02:00
|
|
|
|
Cfg_PATH_SWAD_PUBLIC,Lgo_Folder[Level],
|
2018-10-18 02:02:32 +02:00
|
|
|
|
(unsigned) (Cod % 100),
|
2021-02-15 16:25:55 +01:00
|
|
|
|
(unsigned) Cod,
|
|
|
|
|
(unsigned) Cod);
|
2023-03-10 00:13:55 +01:00
|
|
|
|
if (!Fil_EndReceptionOfFile (FileNameLogo,Par))
|
2019-02-16 17:20:05 +01:00
|
|
|
|
Ale_ShowAlert (Ale_ERROR,"Error copying file.");
|
2015-02-03 18:43:55 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2015-01-17 20:07:13 +01:00
|
|
|
|
|
2015-02-03 18:43:55 +01:00
|
|
|
|
/*****************************************************************************/
|
2021-03-07 21:21:04 +01:00
|
|
|
|
/******* Remove the logo of the current institution, center or degree ********/
|
2015-02-03 18:43:55 +01:00
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2023-09-22 14:47:56 +02:00
|
|
|
|
void Lgo_RemoveLogo (Hie_Level_t Level)
|
2015-02-03 18:43:55 +01:00
|
|
|
|
{
|
2023-09-20 10:36:07 +02:00
|
|
|
|
long Cod = Gbl.Hierarchy.Node[Level].HieCod;
|
2017-01-28 15:58:46 +01:00
|
|
|
|
char FileNameLogo[PATH_MAX + 1]; // Full name (including path and .png) of the destination file
|
2015-02-03 18:43:55 +01:00
|
|
|
|
|
|
|
|
|
/***** Remove logo *****/
|
2021-02-15 16:25:55 +01:00
|
|
|
|
snprintf (FileNameLogo,sizeof (FileNameLogo),"%s/%s/%02u/%u/logo/%u.png",
|
2023-09-19 22:27:20 +02:00
|
|
|
|
Cfg_PATH_SWAD_PUBLIC,Lgo_Folder[Level],
|
2018-10-18 02:02:32 +02:00
|
|
|
|
(unsigned) (Cod % 100),
|
2021-02-15 16:25:55 +01:00
|
|
|
|
(unsigned) Cod,
|
|
|
|
|
(unsigned) Cod);
|
2016-10-06 22:18:33 +02:00
|
|
|
|
Fil_RemoveTree (FileNameLogo);
|
2015-01-17 20:07:13 +01:00
|
|
|
|
}
|