From a376042ee0584571ab87d090afc0eeab3f817cbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Wed, 14 Jan 2015 00:32:23 +0100 Subject: [PATCH] Version 14.55 --- sql/swad.sql | 1 - swad_action.c | 17 +-- swad_action.h | 39 +++--- swad_centre.c | 292 +++++++++++++++++++++++++++++---------------- swad_centre.h | 9 +- swad_changelog.h | 8 +- swad_config.h | 4 - swad_course.c | 2 +- swad_database.c | 4 +- swad_forum.c | 2 +- swad_info.c | 4 +- swad_photo.c | 7 +- swad_test_import.c | 9 +- swad_text.c | 134 ++++++++++++++++----- 14 files changed, 350 insertions(+), 182 deletions(-) diff --git a/sql/swad.sql b/sql/swad.sql index 5864bfe6..ce0ebbce 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -146,7 +146,6 @@ CREATE TABLE IF NOT EXISTS centres ( RequesterUsrCod INT NOT NULL DEFAULT -1, ShortName VARCHAR(32) COLLATE latin1_spanish_ci NOT NULL, FullName VARCHAR(127) COLLATE latin1_spanish_ci NOT NULL, - Logo VARCHAR(16) NOT NULL, WWW VARCHAR(255) NOT NULL, PhotoAttribution TEXT NOT NULL, UNIQUE INDEX(CtrCod), diff --git a/swad_action.c b/swad_action.c index 01a3a188..23460824 100644 --- a/swad_action.c +++ b/swad_action.c @@ -216,10 +216,11 @@ Centre: 116. ActCtrSch Search for courses, teachers, documents... 117. ActPrnCtrInf Print information on the current centre - 118. ActReqCtrPho Show form to send the photo of the current centre - 119. ActRecCtrPho Receive and store the photo of the current centre - 120. ActChgCtrPhoAtt Change attribution of centre photo - 121. ActChgCtrLog Change logo of centre + ---. ActReqCtrLog Show form to send the logo of the current centre + 118. ActRecCtrLog Receive and store the logo of the current centre + 119. ActReqCtrPho Show form to send the photo of the current centre + 120. ActRecCtrPho Receive and store the photo of the current centre + 121. ActChgCtrPhoAtt Change attribution of centre photo 122. ActEdiDeg Request edition of degrees of a type 123. ActReqDeg Request the creation of a request for a new degree (a teacher makes the petition to an administrator) @@ -1358,10 +1359,11 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActCtrSch */{1183,-1,TabCtr,ActCtrReqSch ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,Sch_GetParamsSearch ,Sch_CtrSearch ,NULL}, /* ActPrnCtrInf */{1152,-1,TabCtr,ActSeeCtrInf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Ctr_PrintConfiguration ,NULL}, - /* ActReqCtrPho */{1160,-1,TabCtr,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_ReqPhoto ,NULL}, + /* ActReqCtrLog */{1244,-1,TabCtr,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_RequestLogo ,NULL}, + /* ActRecCtrLog */{1051,-1,TabCtr,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONTENT_DATA,Act_MAIN_WINDOW,NULL ,Ctr_ReceiveLogo ,NULL}, + /* ActReqCtrPho */{1160,-1,TabCtr,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_RequestPhoto ,NULL}, /* ActRecCtrPho */{1161,-1,TabCtr,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONTENT_DATA,Act_MAIN_WINDOW,NULL ,Ctr_ReceivePhoto ,NULL}, /* ActChgCtrPhoAtt */{1159,-1,TabCtr,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_ChangeCtrPhotoAttribution ,NULL}, - /* ActChgCtrLog */{1051,-1,TabCtr,ActSeeCtrInf ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_ChangeCtrLogo ,NULL}, /* ActEdiDeg */{ 536,-1,TabCtr,ActSeeDeg ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Deg_EditDegrees ,NULL}, /* ActReqDeg */{1206,-1,TabCtr,ActSeeDeg ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Deg_RecFormReqDeg ,NULL}, @@ -3330,7 +3332,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActChgDatBrf, // #1048 ActChgDegCtr, // #1049 -1, // #1050 (obsolete action) - ActChgCtrLog, // #1051 + ActRecCtrLog, // #1051 -1, // #1052 (obsolete action) ActReqCrs, // #1053 ActReqSignUp, // #1054 @@ -3523,6 +3525,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActNewIDOth, // #1241 ActSeeSyl, // #1242 ActChgMnu, // #1243 + ActReqCtrLog, // #1244 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 87c804a4..2c8f5dac 100644 --- a/swad_action.h +++ b/swad_action.h @@ -69,9 +69,9 @@ typedef enum typedef int Act_Action_t; // Must be a signed type, because -1 is used to indicate obsolete action -#define Act_NUM_ACTIONS (7+52+15+39+22+17+204+184+94+168+28+75) +#define Act_NUM_ACTIONS (7+52+15+39+23+17+204+184+94+168+28+75) -#define Act_MAX_ACTION_COD 1243 +#define Act_MAX_ACTION_COD 1244 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20 @@ -233,24 +233,25 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica // Secondary actions #define ActCtrSch (ActRenHld+ 4) #define ActPrnCtrInf (ActRenHld+ 5) -#define ActReqCtrPho (ActRenHld+ 6) -#define ActRecCtrPho (ActRenHld+ 7) -#define ActChgCtrPhoAtt (ActRenHld+ 8) -#define ActChgCtrLog (ActRenHld+ 9) +#define ActReqCtrLog (ActRenHld+ 6) +#define ActRecCtrLog (ActRenHld+ 7) +#define ActReqCtrPho (ActRenHld+ 8) +#define ActRecCtrPho (ActRenHld+ 9) +#define ActChgCtrPhoAtt (ActRenHld+ 10) -#define ActEdiDeg (ActRenHld+ 10) -#define ActReqDeg (ActRenHld+ 11) -#define ActNewDeg (ActRenHld+ 12) -#define ActRemDeg (ActRenHld+ 13) -#define ActRenDegSho (ActRenHld+ 14) -#define ActRenDegFul (ActRenHld+ 15) -#define ActChgDegTyp (ActRenHld+ 16) -#define ActChgDegCtr (ActRenHld+ 17) -#define ActChgDegFstYea (ActRenHld+ 18) -#define ActChgDegLstYea (ActRenHld+ 19) -#define ActChgDegOptYea (ActRenHld+ 20) -#define ActChgDegWWW (ActRenHld+ 21) -#define ActChgDegSta (ActRenHld+ 22) +#define ActEdiDeg (ActRenHld+ 11) +#define ActReqDeg (ActRenHld+ 12) +#define ActNewDeg (ActRenHld+ 13) +#define ActRemDeg (ActRenHld+ 14) +#define ActRenDegSho (ActRenHld+ 15) +#define ActRenDegFul (ActRenHld+ 16) +#define ActChgDegTyp (ActRenHld+ 17) +#define ActChgDegCtr (ActRenHld+ 18) +#define ActChgDegFstYea (ActRenHld+ 19) +#define ActChgDegLstYea (ActRenHld+ 20) +#define ActChgDegOptYea (ActRenHld+ 21) +#define ActChgDegWWW (ActRenHld+ 22) +#define ActChgDegSta (ActRenHld+ 23) /*****************************************************************************/ /********************************* Degree tab ********************************/ diff --git a/swad_centre.c b/swad_centre.c index b2005de3..39835da8 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -82,6 +82,7 @@ static Ctr_Status_t Ctr_GetStatusBitsFromStatusTxt (Ctr_StatusTxt_t StatusTxt); static void Ctr_PutParamOtherCtrCod (long CtrCod); static void Ctr_RenameCentre (Cns_ShortOrFullName_t ShortOrFullName); static bool Ctr_CheckIfCentreNameExistsInCurrentIns (const char *FieldName,const char *Name,long CtrCod); +static void Ctr_PutFormToChangeCtrLogo (bool LogoExists); static void Ctr_PutFormToChangeCtrPhoto (bool PhotoExists); static void Ctr_PutFormToCreateCentre (void); static void Ctr_PutHeadCentresForSeeing (bool OrderSelectable); @@ -171,7 +172,7 @@ void Ctr_SeeCtrWithPendingDegs (void) " vertical-align:middle; background-color:%s;\">" "", BgColor,Ctr.WWW,Ctr.FullName); - Ctr_DrawCentreLogo (Ctr.Logo,Ctr.ShortName,16,"vertical-align:top;"); + Ctr_DrawCentreLogo (Ctr.CtrCod,Ctr.ShortName,16,"vertical-align:top;"); fprintf (Gbl.F.Out,"" ""); @@ -236,12 +237,13 @@ static void Ctr_Configuration (bool PrintView) extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_Centre; extern const char *Txt_Short_Name; - extern const char *Txt_Logo; extern const char *Txt_Shortcut_to_this_centre; extern const char *Txt_QR_code; extern const char *Txt_Degrees; extern const char *Txt_Courses; extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; + char PathLogo[PATH_MAX+1]; + bool LogoExists; char PathPhoto[PATH_MAX+1]; bool PhotoExists; char *PhotoAttribution = NULL; @@ -249,6 +251,15 @@ static void Ctr_Configuration (bool PrintView) if (Gbl.CurrentCtr.Ctr.CtrCod > 0) { + /***** Path to logo *****/ + sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR, + (unsigned) (Gbl.CurrentCtr.Ctr.CtrCod % 100), + (unsigned) Gbl.CurrentCtr.Ctr.CtrCod, + (unsigned) Gbl.CurrentCtr.Ctr.CtrCod); + LogoExists = Fil_CheckIfPathExists (PathLogo); + + /***** Path to photo *****/ sprintf (PathPhoto,"%s/%s/%02u/%u/%u.jpg", Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR, (unsigned) (Gbl.CurrentCtr.Ctr.CtrCod % 100), @@ -266,8 +277,11 @@ static void Ctr_Configuration (bool PrintView) Lay_PutLinkToPrintView2 (); /* Link to upload photo */ - if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER) + if (Gbl.Usrs.Me.LoggedRole >= Rol_ROLE_CTR_ADMIN) + { + Ctr_PutFormToChangeCtrLogo (LogoExists); Ctr_PutFormToChangeCtrPhoto (PhotoExists); + } fprintf (Gbl.F.Out,""); } @@ -284,7 +298,7 @@ static void Ctr_Configuration (bool PrintView) " class=\"TITLE_LOCATION\" title=\"%s\">", Gbl.CurrentCtr.Ctr.WWW, Gbl.CurrentCtr.Ctr.FullName); - Ctr_DrawCentreLogo (Gbl.CurrentCtr.Ctr.Logo, + Ctr_DrawCentreLogo (Gbl.CurrentCtr.Ctr.CtrCod, Gbl.CurrentCtr.Ctr.ShortName, 64,NULL); fprintf (Gbl.F.Out,"
%s",Gbl.CurrentCtr.Ctr.FullName); @@ -382,28 +396,6 @@ static void Ctr_Configuration (bool PrintView) Txt_Short_Name, Gbl.CurrentCtr.Ctr.ShortName); - /***** Centre logo *****/ - if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER) - { - fprintf (Gbl.F.Out,"" - "" - "%s:" - "" - "", - The_ClassFormul[Gbl.Prefs.Theme], - Txt_Logo); - Act_FormStart (ActChgCtrLog); - fprintf (Gbl.F.Out,"" - "" - "" - "", - Ctr_MAX_LENGTH_CENTRE_LOGO,Gbl.CurrentCtr.Ctr.Logo, - Gbl.FormId); - } - /***** Link to the centre *****/ fprintf (Gbl.F.Out,"" "", TxtClass,BgColor, Ctr->WWW,Ctr->FullName); - Ctr_DrawCentreLogo (Ctr->Logo,Ctr->ShortName,16,"vertical-align:top;"); + Ctr_DrawCentreLogo (Ctr->CtrCod,Ctr->ShortName,16,"vertical-align:top;"); fprintf (Gbl.F.Out,"" ""); @@ -759,7 +751,7 @@ void Ctr_GetListCentres (long InsCod) if (InsCod > 0) // Only the centres of the specified institution sprintf (Query,"(SELECT centres.CtrCod,centres.InsCod,centres.PlcCod," "centres.Status,centres.RequesterUsrCod," - "centres.ShortName,centres.FullName,centres.logo,centres.WWW," + "centres.ShortName,centres.FullName,centres.WWW," "COUNT(DISTINCT usr_data.UsrCod) AS NumTchs" " FROM centres,usr_data,crs_usr" " WHERE centres.InsCod='%ld' AND crs_usr.Role='%u'" @@ -767,7 +759,7 @@ void Ctr_GetListCentres (long InsCod) " GROUP BY centres.CtrCod)" " UNION " "(SELECT CtrCod,InsCod,PlcCod,Status,RequesterUsrCod," - "ShortName,FullName,Logo,WWW,0 AS NumTchs" + "ShortName,FullName,WWW,0 AS NumTchs" " FROM centres" " WHERE centres.InsCod='%ld' AND CtrCod NOT IN" " (SELECT DISTINCT usr_data.CtrCod FROM usr_data,crs_usr" @@ -782,7 +774,7 @@ void Ctr_GetListCentres (long InsCod) else // InsCod <= 0 ==> all the centres sprintf (Query,"(SELECT centres.CtrCod,centres.InsCod,centres.PlcCod," "centres.Status,centres.RequesterUsrCod," - "centres.ShortName,centres.FullName,centres.Logo,centres.WWW," + "centres.ShortName,centres.FullName,centres.WWW," "COUNT(DISTINCT usr_data.UsrCod) AS NumTchs" " FROM centres,usr_data,crs_usr" " WHERE crs_usr.Role='%u'" @@ -790,7 +782,7 @@ void Ctr_GetListCentres (long InsCod) " GROUP BY centres.CtrCod)" " UNION " "(SELECT CtrCod,InsCod,PlcCod,Status,RequesterUsrCod," - "ShortName,FullName,Logo,WWW,0 AS NumTchs" + "ShortName,FullName,WWW,0 AS NumTchs" " FROM centres" " WHERE CtrCod NOT IN" " (SELECT DISTINCT usr_data.CtrCod FROM usr_data,crs_usr" @@ -844,14 +836,11 @@ void Ctr_GetListCentres (long InsCod) /* Get the full name of the centre (row[6]) */ strcpy (Ctr->FullName,row[6]); - /* Get the logo of the centre (row[7]) */ - strcpy (Ctr->Logo,row[7]); + /* Get the URL of the centre (row[7]) */ + strcpy (Ctr->WWW,row[7]); - /* Get the URL of the centre (row[8]) */ - strcpy (Ctr->WWW,row[8]); - - /* Get number of teachers in this centre (row[9]) */ - if (sscanf (row[9],"%u",&Ctr->NumTchs) != 1) + /* Get number of teachers in this centre (row[8]) */ + if (sscanf (row[8],"%u",&Ctr->NumTchs) != 1) Ctr->NumTchs = 0; /* Count number of degrees in this centre */ @@ -883,7 +872,6 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr) Ctr->RequesterUsrCod = -1L; Ctr->ShortName[0] = '\0'; Ctr->FullName[0] = '\0'; - Ctr->Logo[0] = '\0'; Ctr->WWW[0] = '\0'; Ctr->NumDegs = 0; Ctr->NumTchs = 0; @@ -893,13 +881,13 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr) { /***** Get data of a centre from database *****/ sprintf (Query,"(SELECT centres.InsCod,centres.PlcCod,centres.Status,centres.RequesterUsrCod,centres.ShortName,centres.FullName," - "centres.Logo,centres.WWW,COUNT(DISTINCT usr_data.UsrCod) AS NumTchs" + "centres.WWW,COUNT(DISTINCT usr_data.UsrCod) AS NumTchs" " FROM centres,usr_data,crs_usr" " WHERE centres.CtrCod='%ld'" " AND centres.CtrCod=usr_data.CtrCod AND usr_data.UsrCod=crs_usr.UsrCod AND crs_usr.Role='%u'" " GROUP BY centres.CtrCod)" " UNION " - "(SELECT InsCod,PlcCod,Status,RequesterUsrCod,ShortName,FullName,Logo,WWW,0 AS NumTchs" + "(SELECT InsCod,PlcCod,Status,RequesterUsrCod,ShortName,FullName,WWW,0 AS NumTchs" " FROM centres" " WHERE CtrCod='%ld' AND CtrCod NOT IN" " (SELECT DISTINCT usr_data.CtrCod FROM usr_data,crs_usr" @@ -933,14 +921,11 @@ bool Ctr_GetDataOfCentreByCod (struct Centre *Ctr) /* Get the full name of the centre (row[5]) */ strcpy (Ctr->FullName,row[5]); - /* Get the logo of the centre (row[6]) */ - strcpy (Ctr->Logo,row[6]); + /* Get the URL of the centre (row[6]) */ + strcpy (Ctr->WWW,row[6]); - /* Get the URL of the centre (row[7]) */ - strcpy (Ctr->WWW,row[7]); - - /* Get number of teachers in this centre (row[8]) */ - if (sscanf (row[8],"%u",&Ctr->NumTchs) != 1) + /* Get number of teachers in this centre (row[7]) */ + if (sscanf (row[7],"%u",&Ctr->NumTchs) != 1) Ctr->NumTchs = 0; /* Count number of degrees in this centre */ @@ -1114,7 +1099,7 @@ static void Ctr_ListCentresForEdition (void) /***** Write heading *****/ sprintf (Gbl.Title,Txt_Centres_of_INSTITUTION_X, - Gbl.CurrentIns.Ins.ShortName); + Gbl.CurrentIns.Ins.FullName); Lay_StartRoundFrameTable10 (NULL,2,Gbl.Title); Ctr_PutHeadCentresForEdition (); @@ -1158,11 +1143,11 @@ static void Ctr_ListCentresForEdition (void) "", Ctr->CtrCod); - /* Institution logo */ + /* Centre logo */ fprintf (Gbl.F.Out,"", Ctr->FullName); - Ctr_DrawCentreLogo (Ctr->Logo,Ctr->ShortName,16,NULL); + Ctr_DrawCentreLogo (Ctr->CtrCod,Ctr->ShortName,16,NULL); fprintf (Gbl.F.Out,""); /* Institution */ @@ -1648,31 +1633,6 @@ static bool Ctr_CheckIfCentreNameExistsInCurrentIns (const char *FieldName,const return (DB_QueryCOUNT (Query,"can not check if the name of a centre already existed") != 0); } -/*****************************************************************************/ -/************************ Change the logo of a centre ************************/ -/*****************************************************************************/ - -void Ctr_ChangeCtrLogo (void) - { - extern const char *Txt_The_new_logo_is_X; - char Query[256+Ctr_MAX_LENGTH_CENTRE_LOGO]; - - /***** Get the new logo for the centre from form *****/ - Par_GetParToText ("Logo",Gbl.CurrentCtr.Ctr.Logo,Ctr_MAX_LENGTH_CENTRE_LOGO); - - /***** Update the table changing old logo by new logo *****/ - sprintf (Query,"UPDATE centres SET Logo='%s' WHERE CtrCod='%ld'", - Gbl.CurrentCtr.Ctr.Logo,Gbl.CurrentCtr.Ctr.CtrCod); - DB_QueryUPDATE (Query,"can not update the logo of the centre"); - - /***** Write message to show the change made *****/ - sprintf (Gbl.Message,Txt_The_new_logo_is_X,Gbl.CurrentCtr.Ctr.Logo); - Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); - - /***** Show the form again *****/ - Ctr_ShowConfiguration (); - } - /*****************************************************************************/ /************************* Change the URL of a centre ************************/ /*****************************************************************************/ @@ -1765,6 +1725,131 @@ void Ctr_ChangeCtrStatus (void) Ctr_EditCentres (); } +/*****************************************************************************/ +/********* Put a link to the action used to request logo of centre ***********/ +/*****************************************************************************/ + +static void Ctr_PutFormToChangeCtrLogo (bool LogoExists) + { + extern const char *The_ClassFormul[The_NUM_THEMES]; + extern const char *Txt_Change_logo; + extern const char *Txt_Upload_logo; + const char *Msg; + + /***** Link for changing / uploading the photo *****/ + Act_FormStart (ActReqCtrLog); + Msg = LogoExists ? Txt_Change_logo : + Txt_Upload_logo; + Act_LinkFormSubmit (Msg,The_ClassFormul[Gbl.Prefs.Theme]); + Lay_PutSendIcon ("ctr",Msg,Msg); + fprintf (Gbl.F.Out,""); + } + +/*****************************************************************************/ +/*********** Show a form for sending a logo of the current centre ************/ +/*****************************************************************************/ + +void Ctr_RequestLogo (void) + { + extern const char *The_ClassFormul[The_NUM_THEMES]; + extern const char *Txt_You_can_send_a_file_with_an_image_in_png_format_transparent_background_and_size_X_Y; + extern const char *Txt_File_with_the_logo; + extern const char *Txt_Upload_logo; + + /***** Write help message *****/ + sprintf (Gbl.Message,Txt_You_can_send_a_file_with_an_image_in_png_format_transparent_background_and_size_X_Y, + 64,64); + Lay_ShowAlert (Lay_INFO,Gbl.Message); + + /***** Write a form to send logo *****/ + Act_FormStart (ActRecCtrLog); + fprintf (Gbl.F.Out,"" + "" + "" + "" + "" + "" + "" + "" + "
" + "%s:" + "" + "" + "
" + "" + "
" + "", + The_ClassFormul[Gbl.Prefs.Theme], + Txt_File_with_the_logo, + Fil_NAME_OF_PARAM_FILENAME_ORG, + Txt_Upload_logo); + } + +/*****************************************************************************/ +/****************** Receive a photo of the current centre ********************/ +/*****************************************************************************/ + +void Ctr_ReceiveLogo (void) + { + extern const char *Txt_The_file_is_not_X; + char Path[PATH_MAX+1]; + char FileNameLogoSrc[PATH_MAX+1]; + char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; + char FileNameLogo[PATH_MAX+1]; // Full name (including path and .png) of the destination file + bool WrongType = false; + + /***** Creates directories if not exist *****/ + sprintf (Path,"%s/%s", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR); + Fil_CreateDirIfNotExists (Path); + sprintf (Path,"%s/%s/%02u", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR, + (unsigned) (Gbl.CurrentCtr.Ctr.CtrCod % 100)); + Fil_CreateDirIfNotExists (Path); + sprintf (Path,"%s/%s/%02u/%u", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR, + (unsigned) (Gbl.CurrentCtr.Ctr.CtrCod % 100), + (unsigned) Gbl.CurrentCtr.Ctr.CtrCod); + Fil_CreateDirIfNotExists (Path); + sprintf (Path,"%s/%s/%02u/%u/logo", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR, + (unsigned) (Gbl.CurrentCtr.Ctr.CtrCod % 100), + (unsigned) Gbl.CurrentCtr.Ctr.CtrCod); + Fil_CreateDirIfNotExists (Path); + + /***** Copy in disk the file received from stdin (really from Gbl.F.Tmp) *****/ + Fil_StartReceptionOfFile (FileNameLogoSrc,MIMEType); + + /* 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) + { + sprintf (Gbl.Message,Txt_The_file_is_not_X,"png"); + Lay_ShowAlert (Lay_WARNING,Gbl.Message); + return; + } + + /* End the reception of logo in a temporary file */ + sprintf (FileNameLogo,"%s/%s/%02u/%u/logo/%u.png", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR, + (unsigned) (Gbl.CurrentCtr.Ctr.CtrCod % 100), + (unsigned) Gbl.CurrentCtr.Ctr.CtrCod, + (unsigned) Gbl.CurrentCtr.Ctr.CtrCod); + if (!Fil_EndReceptionOfFile (FileNameLogo)) + { + Lay_ShowAlert (Lay_WARNING,"Error uploading file."); + return; + } + + /***** Show the centre information again *****/ + Ctr_ShowConfiguration (); + } + /*****************************************************************************/ /******** Put a link to the action used to request photo of centre ***********/ /*****************************************************************************/ @@ -1789,7 +1874,7 @@ static void Ctr_PutFormToChangeCtrPhoto (bool PhotoExists) /*********** Show a form for sending a photo of the current centre ***********/ /*****************************************************************************/ -void Ctr_ReqPhoto (void) +void Ctr_RequestPhoto (void) { extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_You_can_send_a_file_with_an_image_in_jpg_format_and_size_X_Y; @@ -1832,7 +1917,7 @@ void Ctr_ReqPhoto (void) void Ctr_ReceivePhoto (void) { - extern const char *Txt_The_file_is_not_jpg; + extern const char *Txt_The_file_is_not_X; char Path[PATH_MAX+1]; char FileNamePhotoSrc[PATH_MAX+1]; char MIMEType[Brw_MAX_BYTES_MIME_TYPE+1]; @@ -1865,7 +1950,8 @@ void Ctr_ReceivePhoto (void) WrongType = true; if (WrongType) { - Lay_ShowAlert (Lay_WARNING,Txt_The_file_is_not_jpg); + sprintf (Gbl.Message,Txt_The_file_is_not_X,"jpg"); + Lay_ShowAlert (Lay_WARNING,Gbl.Message); return; } @@ -1877,7 +1963,7 @@ void Ctr_ReceivePhoto (void) (unsigned) Gbl.CurrentCtr.Ctr.CtrCod); if (!Fil_EndReceptionOfFile (FileNamePhoto)) { - Lay_ShowAlert (Lay_WARNING,Gbl.Message); + Lay_ShowAlert (Lay_WARNING,"Error uploading file."); return; } @@ -1953,7 +2039,7 @@ static void Ctr_PutFormToCreateCentre (void) /***** Centre logo *****/ fprintf (Gbl.F.Out,""); - Ctr_DrawCentreLogo (NULL,"",16,NULL); + Ctr_DrawCentreLogo (-1L,"",16,NULL); fprintf (Gbl.F.Out,""); /***** Institution *****/ @@ -2231,7 +2317,7 @@ static void Ctr_RecFormRequestOrCreateCtr (unsigned Status) else // Add new centre to database Ctr_CreateCentre (Ctr,Status); } - else // If there is not a centre logo or web + else // If there is not a web { sprintf (Gbl.Message,"%s",Txt_You_must_specify_the_web_address_of_the_new_centre); Lay_ShowAlert (Lay_WARNING,Gbl.Message); @@ -2258,9 +2344,9 @@ static void Ctr_CreateCentre (struct Centre *Ctr,unsigned Status) /***** Create a new centre *****/ sprintf (Query,"INSERT INTO centres (InsCod,PlcCod,Status,RequesterUsrCod," - "ShortName,FullName,Logo,WWW)" + "ShortName,FullName,WWW)" " VALUES ('%ld','%ld','%u','%ld'," - "'%s','%s','','%s')", + "'%s','%s','%s')", Ctr->InsCod,Ctr->PlcCod, Status, Gbl.Usrs.Me.UsrDat.UsrCod, @@ -2391,33 +2477,37 @@ unsigned Ctr_GetNumCtrsWithUsrs (Rol_Role_t Role,const char *SubQuery) /****************************** Draw centre logo *****************************/ /*****************************************************************************/ -void Ctr_DrawCentreLogo (const char *Logo,const char *AltText, +void Ctr_DrawCentreLogo (long CtrCod,const char *AltText, unsigned Size,const char *Style) { char PathLogo[PATH_MAX+1]; - bool LogoExists = false; + bool LogoExists; /***** Path to logo *****/ - if (Logo) - if (Logo[0]) - { - sprintf (PathLogo,"%s/%s/%s/%s64x64.gif", - Cfg_PATH_SWAD_PUBLIC, - Cfg_FOLDER_PUBLIC_ICON, - Cfg_ICON_FOLDER_CENTRES, - Logo); - LogoExists = Fil_CheckIfPathExists (PathLogo); - } + if (CtrCod > 0) + { + sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_CTR, + (unsigned) (CtrCod % 100), + (unsigned) CtrCod, + (unsigned) CtrCod); + LogoExists = Fil_CheckIfPathExists (PathLogo); + } + else + LogoExists = false; /***** Draw logo *****/ fprintf (Gbl.F.Out,"\"%s\" DESCRIBE centres; | RequesterUsrCod | int(11) | NO | | -1 | | | ShortName | varchar(32) | NO | | NULL | | | FullName | varchar(127) | NO | | NULL | | -| Logo | varchar(16) | NO | | NULL | | | WWW | varchar(255) | NO | | NULL | | | PhotoAttribution | text | NO | | NULL | | +------------------+--------------+------+-----+---------+----------------+ -10 rows in set (0.01 sec) +9 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS centres (" "CtrCod INT NOT NULL AUTO_INCREMENT," @@ -392,7 +391,6 @@ mysql> DESCRIBE centres; "RequesterUsrCod INT NOT NULL DEFAULT -1," "ShortName VARCHAR(32) COLLATE latin1_spanish_ci NOT NULL," "FullName VARCHAR(127) COLLATE latin1_spanish_ci NOT NULL," - "Logo VARCHAR(16) NOT NULL," "WWW VARCHAR(255) NOT NULL," "PhotoAttribution TEXT NOT NULL," "UNIQUE INDEX(CtrCod),INDEX(InsCod),INDEX(PlcCod),INDEX(Status))"); diff --git a/swad_forum.c b/swad_forum.c index dc1f62de..95ea0950 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -2150,7 +2150,7 @@ static void For_WriteLinkToForum (For_ForumType_t ForumType,Act_Action_t NextAct break; case For_FORUM_CENTRE_USRS: case For_FORUM_CENTRE_TCHS: - Ctr_DrawCentreLogo (Gbl.Forum.Ctr.Logo,ForumName,16,"vertical-align:middle;"); + Ctr_DrawCentreLogo (Gbl.Forum.Ctr.CtrCod,ForumName,16,"vertical-align:middle;"); break; case For_FORUM_DEGREE_USRS: case For_FORUM_DEGREE_TCHS: diff --git a/swad_info.c b/swad_info.c index e1bf1b08..b927cc82 100644 --- a/swad_info.c +++ b/swad_info.c @@ -1949,7 +1949,7 @@ void Inf_ReceivePagInfo (void) FileIsOK = true; } else - Lay_ShowAlert (Lay_WARNING,Gbl.Message); + Lay_ShowAlert (Lay_WARNING,"Error uploading file."); } else if (Str_FileIs (SourceFileName,"zip")) // .zip file { @@ -1989,7 +1989,7 @@ void Inf_ReceivePagInfo (void) Lay_ShowErrorAndExit ("Can not unzip file."); } else - Lay_ShowAlert (Lay_WARNING,Gbl.Message); + Lay_ShowAlert (Lay_WARNING,"Error uploading file."); } else Lay_ShowAlert (Lay_WARNING,Txt_The_file_type_should_be_HTML_or_ZIP); diff --git a/swad_photo.c b/swad_photo.c index 0d82c20c..497a3965 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -385,7 +385,7 @@ void Pho_RemoveUsrPhoto (void) void Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *UsrDat) { - extern const char *Txt_The_file_is_not_jpg; + extern const char *Txt_The_file_is_not_X; extern const char *Txt_Could_not_detect_any_face_in_front_position_; extern const char *Txt_A_face_marked_in_green_has_been_detected_; extern const char *Txt_A_face_marked_in_red_has_been_detected_; @@ -450,7 +450,8 @@ void Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *UsrDat) WrongType = true; if (WrongType) { - Lay_ShowAlert (Lay_WARNING,Txt_The_file_is_not_jpg); + sprintf (Gbl.Message,Txt_The_file_is_not_X,"jpg"); + Lay_ShowAlert (Lay_WARNING,Gbl.Message); return; } @@ -460,7 +461,7 @@ void Pho_ReceivePhotoAndDetectFaces (bool ItsMe,const struct UsrData *UsrDat) Cfg_FOLDER_PHOTO_TMP,Gbl.UniqueNameEncrypted); if (!Fil_EndReceptionOfFile (FileNamePhotoTmp)) { - Lay_ShowAlert (Lay_WARNING,Gbl.Message); + Lay_ShowAlert (Lay_WARNING,"Error uploading file."); return; } diff --git a/swad_test_import.c b/swad_test_import.c index a5cb2862..fc984b85 100644 --- a/swad_test_import.c +++ b/swad_test_import.c @@ -386,7 +386,7 @@ static void TsI_WriteAnswersOfAQstXML (long QstCod) void TsI_ImportQstsFromXML (void) { - extern const char *Txt_The_file_is_not_xml; + extern const char *Txt_The_file_is_not_X; char PathTestPriv[PATH_MAX+1]; char FileNameXMLSrc[PATH_MAX+1]; char FileNameXMLTmp[PATH_MAX+1]; // Full name (including path and .xml) of the destination temporary file @@ -420,10 +420,13 @@ void TsI_ImportQstsFromXML (void) /***** Get questions from XML file and store them in database *****/ TsI_ReadQuestionsFromXMLFileAndStoreInDB (FileNameXMLTmp); else - Lay_ShowAlert (Lay_WARNING,Gbl.Message); + Lay_ShowAlert (Lay_WARNING,"Error uploading file."); } else - Lay_ShowAlert (Lay_WARNING,Txt_The_file_is_not_xml); + { + sprintf (Gbl.Message,Txt_The_file_is_not_X,"xml"); + Lay_ShowAlert (Lay_WARNING,Gbl.Message); + } } /*****************************************************************************/ diff --git a/swad_text.c b/swad_text.c index 0da389b8..693aab41 100644 --- a/swad_text.c +++ b/swad_text.c @@ -3996,6 +3996,27 @@ const char *Txt_Change_IDs = "Alterar nºs. identif."; #endif +const char *Txt_Change_logo = +#if L==0 + "Canviar logo"; +#elif L==1 + "Logo ändern"; +#elif L==2 + "Change logo"; +#elif L==3 + "Cambiar logo"; +#elif L==4 + "Changer logo"; +#elif L==5 + "Cambiar logo"; // Okoteve traducción +#elif L==6 + "Cambiare logo"; +#elif L==7 + "Zmień logo"; +#elif L==8 + "Alterar logotipo"; +#endif + const char *Txt_Change_my_groups = #if L==0 "Canviar de grups"; @@ -10730,6 +10751,27 @@ const char *Txt_FILE_UPLOAD_Done = "Terminar"; #endif +const char *Txt_File_with_the_logo = +#if L==0 + "Fitxer amb el logo"; +#elif L==1 + "Datei mit dem Logo"; +#elif L==2 + "File with the logo"; +#elif L==3 + "Archivo con el logo"; +#elif L==4 + "Fichier avec le logo"; +#elif L==5 + "Archivo con el logo"; // Okoteve traducción +#elif L==6 + "File con il logo"; +#elif L==7 + "Plik ze logo"; +#elif L==8 + "Arquivo com o logotipo"; +#endif + const char *Txt_File_with_the_photo = #if L==0 "Fitxer amb la foto"; @@ -38127,46 +38169,25 @@ const char *Txt_The_file_X_has_been_placed_inside_the_folder_Y = // Warning: it " dentro do diretório %s."; #endif -const char *Txt_The_file_is_not_jpg = +const char *Txt_The_file_is_not_X = // Warning: it is very important to include %s in the following sentences #if L==0 - "El archivo no es jpg."; // Necessita traduccio + "El archivo no es %s."; // Necessita traduccio #elif L==1 - "The file is not jpg."; // Need Übersetzung + "The file is not %s."; // Need Übersetzung #elif L==2 - "The file is not jpg."; + "The file is not %s."; #elif L==3 - "El archivo no es jpg."; + "El archivo no es %s."; #elif L==4 - "The file is not jpg."; // Besoin de traduction + "The file is not %s."; // Besoin de traduction #elif L==5 - "El archivo no es jpg."; // Okoteve traducción + "El archivo no es %s."; // Okoteve traducción #elif L==6 - "IL file non è jpg."; + "IL file non è %s."; #elif L==7 - "The file is not jpg."; // Potrzebujesz tlumaczenie + "The file is not %s."; // Potrzebujesz tlumaczenie #elif L==8 - "The file is not jpg."; // Necessita de tradução -#endif - -const char *Txt_The_file_is_not_xml = -#if L==0 - "El archivo no es xml."; // Necessita traduccio -#elif L==1 - "The file is not xml."; // Need Übersetzung -#elif L==2 - "The file is not xml."; -#elif L==3 - "El archivo no es xml."; -#elif L==4 - "The file is not xml."; // Besoin de traduction -#elif L==5 - "El archivo no es xml."; // Okoteve traducción -#elif L==6 - "IL file non è xml."; -#elif L==7 - "The file is not xml."; // Potrzebujesz tlumaczenie -#elif L==8 - "The file is not xml."; // Necessita de tradução + "The file is not %s."; // Necessita de tradução #endif const char *Txt_The_file_of_folder_no_longer_exists_or_is_now_hidden = @@ -45238,6 +45259,27 @@ const char *Txt_Upload_files_QUESTION = "Fazer upload
de arquivos?"; #endif +const char *Txt_Upload_logo = +#if L==0 + "Enviar logo"; +#elif L==1 + "Upload Logo"; +#elif L==2 + "Upload logo"; +#elif L==3 + "Subir logo"; +#elif L==4 + "Télécharger logo"; +#elif L==5 + "Subir logo"; // Okoteve traducción +#elif L==6 + "Caricare logo"; +#elif L==7 + "Upload logo"; // Potrzebujesz tlumaczenie +#elif L==8 + "Fazer upload de logotipo"; +#endif + const char *Txt_Upload_photo = #if L==0 "Enviar foto"; @@ -48488,6 +48530,36 @@ const char *Txt_You_can_register_voluntarily_in_one_or_more_groups_of_type_X = / " in one or more groups of type %s."; // Necessita de tradução #endif +const char *Txt_You_can_send_a_file_with_an_image_in_png_format_transparent_background_and_size_X_Y = // Warning: it is very important to include two %u in the following sentences +#if L==0 + "Puede enviar un archivo con una imagen en formato png," + " fondo transparente y tamaño %u×%u píxeles."; // Necessita traduccio +#elif L==1 + "You can send a file with an image in png format," + " transparent background and size %u×%u pixels."; // Need Übersetzung +#elif L==2 + "You can send a file with an image in png format," + " transparent background and size %u×%u pixels."; +#elif L==3 + "Puede enviar un archivo con una imagen en formato png," + " fondo transparente y tamaño %u×%u píxeles."; +#elif L==4 + "You can send a file with an image in png format," + " transparent background and size %u×%u pixels."; // Besoin de traduction +#elif L==5 + "Puede enviar un archivo con una imagen en formato png," + " fondo transparente y tamaño %u×%u píxeles."; // Okoteve traducción +#elif L==6 + "Puoi inviare un file con un'immagine in formato png," + " sfondo trasparente e di dimensione %u×%u pixel."; +#elif L==7 + "You can send a file with an image in png format," + " transparent background and size %u×%u pixels."; // Potrzebujesz tlumaczenie +#elif L==8 + "You can send a file with an image in png format," + " transparent background and size %u×%u pixels."; // Necessita de tradução +#endif + const char *Txt_You_can_send_a_file_with_an_image_in_jpg_format_ = #if L==0 "Puede enviar un archivo con una imagen en formato jpg.
"