diff --git a/Makefile b/Makefile index e4e29b64c..3efcf32ee 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ OBJS = swad_account.o swad_action.o swad_announcement.o swad_assignment.o swad_a swad_global.o swad_group.o \ swad_holiday.o \ swad_icon.o swad_ID.o swad_import.o swad_indicator.o swad_info.o swad_institution.o \ - swad_layout.o swad_link.o \ + swad_layout.o swad_link.o swad_logo.o \ swad_mail.o swad_main.o swad_mark.o swad_menu.o swad_message.o \ swad_network.o swad_nickname.o swad_notice.o swad_notification.o \ swad_pagination.o swad_parameter.o swad_password.o swad_photo.o swad_place.o swad_plugin.o swad_preference.o \ diff --git a/sql/swad.sql b/sql/swad.sql index ce0ebbce2..5a7e1e2d0 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -627,7 +627,6 @@ CREATE TABLE IF NOT EXISTS institutions ( RequesterUsrCod INT NOT NULL DEFAULT -1, ShortName VARCHAR(32) NOT NULL, FullName TEXT NOT NULL, - Logo VARCHAR(32) NOT NULL, WWW VARCHAR(255) NOT NULL, UNIQUE INDEX(InsCod), INDEX(CtyCod), diff --git a/swad_action.c b/swad_action.c index 234608247..3a6c07c71 100644 --- a/swad_action.c +++ b/swad_action.c @@ -172,7 +172,8 @@ Institution: 80. ActInsSch Search for courses, teachers, documents... 81. ActPrnInsInf Print information on the current institution - 82. ActChgInsLog Change logo of institution + --. ActReqInsLog Show form to send the logo of the current institution + 82. ActRecInsLog Receive and store the logo of the current institution 83. ActEdiCtr Edit centres 84. ActReqCtr Request the creation of a request for a new centre (a teacher makes the petition to an administrator) @@ -1312,7 +1313,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActInsSch */{1182,-1,TabIns,ActInsReqSch ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,Sch_GetParamsSearch ,Sch_InsSearch ,NULL}, /* ActPrnInsInf */{1154,-1,TabIns,ActSeeInsInf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Ins_PrintConfiguration ,NULL}, - /* ActChgInsLog */{ 699,-1,TabIns,ActSeeIns ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ins_ChangeInsLogo ,NULL}, + /* ActReqInsLog */{1245,-1,TabCtr,ActSeeInsInf ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ins_RequestLogo ,NULL}, + /* ActRecInsLog */{ 699,-1,TabCtr,ActSeeInsInf ,0x100,0x100,0x100,Act_CONTENT_DATA,Act_MAIN_WINDOW,NULL ,Ins_ReceiveLogo ,NULL}, /* ActEdiCtr */{ 681,-1,TabIns,ActSeeCtr ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_EditCentres ,NULL}, /* ActReqCtr */{1208,-1,TabIns,ActSeeCtr ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ctr_RecFormReqCtr ,NULL}, @@ -2980,7 +2982,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActSeeIns, // #696 ActEdiIns, // #697 ActNewIns, // #698 - ActChgInsLog, // #699 + ActRecInsLog, // #699 ActChgInsWWW, // #700 ActRenInsFul, // #701 ActRenInsSho, // #702 @@ -3526,6 +3528,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActSeeSyl, // #1242 ActChgMnu, // #1243 ActReqCtrLog, // #1244 + ActReqInsLog, // #1245 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 2c8f5dacd..3fc6b8bfe 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+23+17+204+184+94+168+28+75) +#define Act_NUM_ACTIONS (7+52+15+40+23+17+204+184+94+168+28+75) -#define Act_MAX_ACTION_COD 1244 +#define Act_MAX_ACTION_COD 1245 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20 @@ -186,41 +186,42 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica // Secondary actions #define ActInsSch (ActChgInsSta+ 7) #define ActPrnInsInf (ActChgInsSta+ 8) -#define ActChgInsLog (ActChgInsSta+ 9) +#define ActReqInsLog (ActChgInsSta+ 9) +#define ActRecInsLog (ActChgInsSta+ 10) -#define ActEdiCtr (ActChgInsSta+ 10) -#define ActReqCtr (ActChgInsSta+ 11) -#define ActNewCtr (ActChgInsSta+ 12) -#define ActRemCtr (ActChgInsSta+ 13) -#define ActChgCtrIns (ActChgInsSta+ 14) -#define ActChgCtrPlc (ActChgInsSta+ 15) -#define ActRenCtrSho (ActChgInsSta+ 16) -#define ActRenCtrFul (ActChgInsSta+ 17) -#define ActChgCtrWWW (ActChgInsSta+ 18) -#define ActChgCtrSta (ActChgInsSta+ 19) +#define ActEdiCtr (ActChgInsSta+ 11) +#define ActReqCtr (ActChgInsSta+ 12) +#define ActNewCtr (ActChgInsSta+ 13) +#define ActRemCtr (ActChgInsSta+ 14) +#define ActChgCtrIns (ActChgInsSta+ 15) +#define ActChgCtrPlc (ActChgInsSta+ 16) +#define ActRenCtrSho (ActChgInsSta+ 17) +#define ActRenCtrFul (ActChgInsSta+ 18) +#define ActChgCtrWWW (ActChgInsSta+ 19) +#define ActChgCtrSta (ActChgInsSta+ 20) -#define ActEdiDpt (ActChgInsSta+ 20) -#define ActNewDpt (ActChgInsSta+ 21) -#define ActRemDpt (ActChgInsSta+ 22) -#define ActChgDptIns (ActChgInsSta+ 23) -#define ActRenDptSho (ActChgInsSta+ 24) -#define ActRenDptFul (ActChgInsSta+ 25) -#define ActChgDptWWW (ActChgInsSta+ 26) +#define ActEdiDpt (ActChgInsSta+ 21) +#define ActNewDpt (ActChgInsSta+ 22) +#define ActRemDpt (ActChgInsSta+ 23) +#define ActChgDptIns (ActChgInsSta+ 24) +#define ActRenDptSho (ActChgInsSta+ 25) +#define ActRenDptFul (ActChgInsSta+ 26) +#define ActChgDptWWW (ActChgInsSta+ 27) -#define ActEdiPlc (ActChgInsSta+ 27) -#define ActNewPlc (ActChgInsSta+ 28) -#define ActRemPlc (ActChgInsSta+ 29) -#define ActRenPlcSho (ActChgInsSta+ 30) -#define ActRenPlcFul (ActChgInsSta+ 31) +#define ActEdiPlc (ActChgInsSta+ 28) +#define ActNewPlc (ActChgInsSta+ 29) +#define ActRemPlc (ActChgInsSta+ 30) +#define ActRenPlcSho (ActChgInsSta+ 31) +#define ActRenPlcFul (ActChgInsSta+ 32) -#define ActEdiHld (ActChgInsSta+ 32) -#define ActNewHld (ActChgInsSta+ 33) -#define ActRemHld (ActChgInsSta+ 34) -#define ActChgHldPlc (ActChgInsSta+ 35) -#define ActChgHldTyp (ActChgInsSta+ 36) -#define ActChgHldStrDat (ActChgInsSta+ 37) -#define ActChgHldEndDat (ActChgInsSta+ 38) -#define ActRenHld (ActChgInsSta+ 39) +#define ActEdiHld (ActChgInsSta+ 33) +#define ActNewHld (ActChgInsSta+ 34) +#define ActRemHld (ActChgInsSta+ 35) +#define ActChgHldPlc (ActChgInsSta+ 36) +#define ActChgHldTyp (ActChgInsSta+ 37) +#define ActChgHldStrDat (ActChgInsSta+ 38) +#define ActChgHldEndDat (ActChgInsSta+ 39) +#define ActRenHld (ActChgInsSta+ 40) /*****************************************************************************/ /********************************* Centre tab ********************************/ diff --git a/swad_centre.c b/swad_centre.c index 39835da8c..07b6efd9b 100644 --- a/swad_centre.c +++ b/swad_centre.c @@ -35,6 +35,7 @@ #include "swad_database.h" #include "swad_global.h" #include "swad_institution.h" +#include "swad_logo.h" #include "swad_parameter.h" #include "swad_QR.h" #include "swad_string.h" @@ -82,7 +83,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); @@ -242,8 +243,6 @@ static void Ctr_Configuration (bool PrintView) 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; @@ -251,14 +250,6 @@ 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, @@ -267,7 +258,7 @@ static void Ctr_Configuration (bool PrintView) (unsigned) Gbl.CurrentCtr.Ctr.CtrCod); PhotoExists = Fil_CheckIfPathExists (PathPhoto); - /***** Links to print view and upload photo *****/ + /***** Links to print view, upload logo and upload photo *****/ if (!PrintView) { fprintf (Gbl.F.Out,"
"); @@ -276,10 +267,10 @@ static void Ctr_Configuration (bool PrintView) Lay_PutLinkToPrintView1 (ActPrnCtrInf); Lay_PutLinkToPrintView2 (); - /* Link to upload photo */ + /* Links to upload logo and photo */ if (Gbl.Usrs.Me.LoggedRole >= Rol_ROLE_CTR_ADMIN) { - Ctr_PutFormToChangeCtrLogo (LogoExists); + Log_PutFormToChangeLogo (Sco_SCOPE_CENTRE); Ctr_PutFormToChangeCtrPhoto (PhotoExists); } @@ -1725,129 +1716,22 @@ 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); + Log_RequestLogo (Sco_SCOPE_CENTRE); } /*****************************************************************************/ -/****************** Receive a photo of the current centre ********************/ +/***************** Receive the logo 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 (); + Log_ReceiveLogo (Sco_SCOPE_CENTRE); } /*****************************************************************************/ diff --git a/swad_centre.h b/swad_centre.h index 3b473f4c1..ac8ae5723 100644 --- a/swad_centre.h +++ b/swad_centre.h @@ -103,6 +103,7 @@ void Ctr_RenameCentreShort (void); void Ctr_RenameCentreFull (void); void Ctr_ChangeCtrWWW (void); void Ctr_ChangeCtrStatus (void); + void Ctr_RequestLogo (void); void Ctr_ReceiveLogo (void); void Ctr_RequestPhoto (void); diff --git a/swad_changelog.h b/swad_changelog.h index 21c877483..e24ab412c 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -1,7 +1,7 @@ // swad_changelog.h: changelog -#ifndef _SWAD_LOG -#define _SWAD_LOG +#ifndef _SWAD_CHG +#define _SWAD_CHG /* SWAD (Shared Workspace At a Distance), is a web platform developed at the University of Granada (Spain), @@ -39,22 +39,31 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.55.5 (2015/01/16)" +#define Log_PLATFORM_VERSION "SWAD 14.56 (2015/01/17)" // 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.56: Jan 17, 2015 New module swad_logo for drawing logos of institutions, centres and degrees. + New option to upload logo of institution. (173735 lines) + 1 change necessary in Makefile: +Add swad_logo.o to list of object files + 3 changes necessary in database: +UPDATE actions SET Txt='Cambiar logo de institución' WHERE ActCod='699' AND Language='es'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1245','es','N','Solicitar envío de logo de institución'); +ALTER TABLE institutions DROP COLUMN Logo; + Version 14.55.5: Jan 16, 2015 Code refactoring related to maps of countries. (173573 lines) Version 14.55.4: Jan 16, 2015 Fixed bugs in enrollment. - New MIME type, reported by Francisco Ocaņa Lara. (173576 lines) + New MIME type, suggested by Francisco Ocaņa Lara. (173576 lines) Version 14.55.3: Jan 16, 2015 Link in course information to request registration in course. Fixed bug in enrollment. (173570 lines) Version 14.55.2: Jan 15, 2015 Logo of centre, degree, institution or country in title. (173546 lines) Version 14.55.1: Jan 14, 2015 Fixed bug in user's photo. (173510 lines) - Version 14.55 : Jan 14, 2015 New option to upload logo of a centre. (173509 lines) + Version 14.55: Jan 14, 2015 New option to upload logo of a centre. (173509 lines) 3 changes necessary in database: -UPDATE actions SET Txt='Enviar logo del centro' WHERE ActCod='1051' AND Language='es'; -INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1244','es','N','Solicitar envío de foto del centro'); +UPDATE actions SET Txt='Cambiar logo de centro' WHERE ActCod='1051' AND Language='es'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1244','es','N','Solicitar envío de logo cde entro'); ALTER TABLE centres DROP COLUMN Logo; Version 14.54.7: Jan 13, 2015 Fixed bug in edition of centres. (173349 lines) diff --git a/swad_config.h b/swad_config.h index 75755a278..cfbaca8d0 100644 --- a/swad_config.h +++ b/swad_config.h @@ -348,9 +348,15 @@ #define Cfg_MAX_BYTES_DATABASE_PASSWORD 256 #define Cfg_MAX_BYTES_SMTP_PASSWORD 256 -/* Folders for courses, inside public and private swad directories */ +/* Folders for institutions, inside public and private swad directories */ +#define Cfg_FOLDER_INS "ins" // If not exists, it should be created during installation inside swad private and public directory! + +/* Folders for centres, inside public and private swad directories */ #define Cfg_FOLDER_CTR "ctr" // If not exists, it should be created during installation inside swad private and public directory! +/* Folders for centres, inside public and private swad directories */ +#define Cfg_FOLDER_DEG "deg" // If not exists, it should be created during installation inside swad private and public directory! + /* Folders for courses, inside public and private swad directories */ #define Cfg_FOLDER_CRS "crs" // If not exists, it should be created during installation inside swad private and public directory! @@ -393,7 +399,6 @@ #define Cfg_ICON_FOLDER_THEMES "theme" // Directory with all the images for each theme #define Cfg_ICON_FOLDER_ICON_SETS "iconset" // Directory with all the icons for each icon set #define Cfg_ICON_FOLDER_COUNTRIES "country" // Directory with icons for countries -#define Cfg_ICON_FOLDER_INSTITUTIONS "institution" // Directory with icons for institutions #define Cfg_ICON_FOLDER_DEGREES "degree" // Directory with icons for degrees #define Cfg_ICON_FOLDER_FILEXT "filext" // Directory with icons for file extensions #define Cfg_ICON_FOLDER_PLUGINS "plugin" // Directory with icons for plugins diff --git a/swad_course.c b/swad_course.c index 1162fa908..d27122bef 100644 --- a/swad_course.c +++ b/swad_course.c @@ -672,7 +672,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Ins_PutParamInsCod (Ins.InsCod); Act_LinkFormSubmit (Act_GetActionTextFromDB (Act_Actions[ActSeeInsInf].ActCod,ActTxt), The_ClassFormul[Gbl.Prefs.Theme]); - Ins_DrawInstitutionLogo (Ins.Logo,Ins.ShortName,16,"vertical-align:middle;"); + Ins_DrawInstitutionLogo (Ins.InsCod,Ins.ShortName,16,"vertical-align:middle;"); Highlight = (Gbl.CurrentCtr.Ctr.CtrCod <= 0 && Gbl.CurrentIns.Ins.InsCod == Ins.InsCod); if (Highlight) diff --git a/swad_database.c b/swad_database.c index bb3edd9d2..28212887a 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1304,10 +1304,9 @@ mysql> DESCRIBE institutions; | RequesterUsrCod | int(11) | NO | | -1 | | | ShortName | varchar(32) | NO | | NULL | | | FullName | text | NO | | NULL | | -| Logo | varchar(32) | NO | | NULL | | | WWW | varchar(255) | NO | | NULL | | +-----------------+--------------+------+-----+---------+----------------+ -8 rows in set (0.00 sec) +7 rows in set (0.01 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS institutions (" "InsCod INT NOT NULL AUTO_INCREMENT," @@ -1316,7 +1315,6 @@ mysql> DESCRIBE institutions; "RequesterUsrCod INT NOT NULL DEFAULT -1," "ShortName VARCHAR(32) NOT NULL," "FullName TEXT NOT NULL," - "Logo VARCHAR(32) NOT NULL," "WWW VARCHAR(255) NOT NULL," "UNIQUE INDEX(InsCod),INDEX(CtyCod),INDEX(Status))"); diff --git a/swad_degree.c b/swad_degree.c index d552b6553..65044e33a 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -41,6 +41,7 @@ #include "swad_global.h" #include "swad_indicator.h" #include "swad_info.h" +#include "swad_logo.h" #include "swad_notification.h" #include "swad_parameter.h" #include "swad_QR.h" @@ -296,12 +297,19 @@ static void Deg_Configuration (bool PrintView) if (Gbl.CurrentDeg.Deg.DegCod > 0) { + /***** Links to print view and upload logo *****/ if (!PrintView) { - /* Link to print view */ fprintf (Gbl.F.Out,"
"); + + /* Link to print view */ Lay_PutLinkToPrintView1 (ActPrnDegInf); Lay_PutLinkToPrintView2 (); + + /* Link to upload logo */ + if (Gbl.Usrs.Me.LoggedRole >= Rol_ROLE_DEG_ADMIN) + Log_PutFormToChangeLogo (Sco_SCOPE_DEGREE); + fprintf (Gbl.F.Out,"
"); } @@ -754,7 +762,7 @@ void Deg_WriteBigNameCtyInsCtrDegCrs (void) Ctr_DrawCentreLogo (Gbl.CurrentCtr.Ctr.CtrCod,Gbl.CurrentCtr.Ctr.ShortName,32, "vertical-align:top; margin-right:8px;"); else if (Gbl.CurrentIns.Ins.InsCod > 0) - Ins_DrawInstitutionLogo (Gbl.CurrentIns.Ins.Logo,Gbl.CurrentIns.Ins.ShortName,32, + Ins_DrawInstitutionLogo (Gbl.CurrentIns.Ins.InsCod,Gbl.CurrentIns.Ins.ShortName,32, "vertical-align:top; margin-right:8px;"); else if (Gbl.CurrentCty.Cty.CtyCod > 0) if (Cty_CheckIfCountryMapExists (&Gbl.CurrentCty.Cty)) diff --git a/swad_exam.c b/swad_exam.c index 6dee12c60..0b1c4782d 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -790,7 +790,7 @@ static void Exa_ShowExamAnnouncement (long ExaCod,Exa_tTypeViewExamAnnouncement_ else fprintf (Gbl.F.Out,"", Ins.WWW,StyleTitle); - Ins_DrawInstitutionLogo (Ins.Logo,Ins.FullName,64,NULL); + Ins_DrawInstitutionLogo (Ins.InsCod,Ins.FullName,64,NULL); fprintf (Gbl.F.Out,"
%s%s" \ "" \ "", diff --git a/swad_forum.c b/swad_forum.c index 95ea09508..80ebef3eb 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -2146,7 +2146,7 @@ static void For_WriteLinkToForum (For_ForumType_t ForumType,Act_Action_t NextAct { case For_FORUM_INSTITUTION_USRS: case For_FORUM_INSTITUTION_TCHS: - Ins_DrawInstitutionLogo (Gbl.Forum.Ins.Logo,ForumName,16,"vertical-align:middle;"); + Ins_DrawInstitutionLogo (Gbl.Forum.Ins.InsCod,ForumName,16,"vertical-align:middle;"); break; case For_FORUM_CENTRE_USRS: case For_FORUM_CENTRE_TCHS: diff --git a/swad_institution.c b/swad_institution.c index 8e148792b..f06daf951 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -34,6 +34,7 @@ #include "swad_database.h" #include "swad_global.h" #include "swad_institution.h" +#include "swad_logo.h" #include "swad_parameter.h" #include "swad_QR.h" #include "swad_text.h" @@ -162,7 +163,7 @@ void Ins_SeeInsWithPendingCtrs (void) " vertical-align:middle; background-color:%s;\">" "
", BgColor,Ins.WWW,Ins.FullName); - Ins_DrawInstitutionLogo (Ins.Logo,Ins.ShortName,16,NULL); + Ins_DrawInstitutionLogo (Ins.InsCod,Ins.ShortName,16,"vertical-align:top;"); fprintf (Gbl.F.Out,"" ""); @@ -226,7 +227,6 @@ static void Ins_Configuration (bool PrintView) extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_Institution; extern const char *Txt_Short_Name; - extern const char *Txt_Logo; extern const char *Txt_Shortcut_to_this_institution; extern const char *Txt_QR_code; extern const char *Txt_Centres; @@ -238,12 +238,19 @@ static void Ins_Configuration (bool PrintView) if (Gbl.CurrentIns.Ins.InsCod > 0) { - /***** Link to print view *****/ + /***** Links to print view and upload logo *****/ if (!PrintView) { fprintf (Gbl.F.Out,"
"); + + /* Link to print view */ Lay_PutLinkToPrintView1 (ActPrnInsInf); Lay_PutLinkToPrintView2 (); + + /* Link to upload logo */ + if (Gbl.Usrs.Me.LoggedRole >= Rol_ROLE_INS_ADMIN) + Log_PutFormToChangeLogo (Sco_SCOPE_INSTITUTION); + fprintf (Gbl.F.Out,"
"); } @@ -259,7 +266,7 @@ static void Ins_Configuration (bool PrintView) " class=\"TITLE_LOCATION\" title=\"%s\">", Gbl.CurrentIns.Ins.WWW, Gbl.CurrentIns.Ins.FullName); - Ins_DrawInstitutionLogo (Gbl.CurrentIns.Ins.Logo, + Ins_DrawInstitutionLogo (Gbl.CurrentIns.Ins.InsCod, Gbl.CurrentIns.Ins.ShortName, 64,NULL); fprintf (Gbl.F.Out,"
%s",Gbl.CurrentIns.Ins.FullName); @@ -305,28 +312,6 @@ static void Ins_Configuration (bool PrintView) Txt_Short_Name, Gbl.CurrentIns.Ins.ShortName); - /***** Institution logo *****/ - if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER) - { - fprintf (Gbl.F.Out,"" - "" - "%s:" - "" - "", - The_ClassFormul[Gbl.Prefs.Theme], - Txt_Logo); - Act_FormStart (ActChgInsLog); - fprintf (Gbl.F.Out,"" - "" - "" - "", - Ins_MAX_LENGTH_INSTITUTION_LOGO,Gbl.CurrentIns.Ins.Logo, - Gbl.FormId); - } - /***** Link to the institution *****/ fprintf (Gbl.F.Out,"" "", BgColor, Ins->WWW,Ins->FullName); - Ins_DrawInstitutionLogo (Ins->Logo,Ins->ShortName,16,NULL); + Ins_DrawInstitutionLogo (Ins->InsCod,Ins->ShortName,16,NULL); fprintf (Gbl.F.Out,"" ""); @@ -737,11 +722,11 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData) { case Ins_GET_MINIMAL_DATA: if (CtyCod <= 0) // Get all the institutions, belonging to any country - sprintf (Query,"SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,Logo,WWW" + sprintf (Query,"SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW" " FROM institutions" " ORDER BY FullName"); else // Get only the institutions belonging to the country specified by CtyCod - sprintf (Query,"SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,Logo,WWW" + sprintf (Query,"SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW" " FROM institutions" " WHERE CtyCod='%ld'" " ORDER BY FullName", @@ -761,12 +746,12 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData) sprintf (Query,"(SELECT institutions.InsCod,institutions.CtyCod," "institutions.Status,institutions.RequesterUsrCod," "institutions.ShortName,institutions.FullName," - "institutions.Logo,institutions.WWW,COUNT(*) AS NumUsrs" + "institutions.WWW,COUNT(*) AS NumUsrs" " FROM institutions,usr_data" " WHERE institutions.InsCod=usr_data.InsCod" " GROUP BY institutions.InsCod)" " UNION " - "(SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,Logo,WWW,0 AS NumUsrs" + "(SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW,0 AS NumUsrs" " FROM institutions" " WHERE InsCod NOT IN (SELECT DISTINCT InsCod FROM usr_data))" " ORDER BY %s", @@ -775,12 +760,12 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData) sprintf (Query,"(SELECT institutions.InsCod,institutions.CtyCod," "institutions.Status,institutions.RequesterUsrCod," "institutions.ShortName,institutions.FullName," - "institutions.Logo,institutions.WWW,COUNT(*) AS NumUsrs" + "institutions.WWW,COUNT(*) AS NumUsrs" " FROM institutions,usr_data" " WHERE institutions.CtyCod='%ld' AND institutions.InsCod=usr_data.InsCod" " GROUP BY institutions.InsCod)" " UNION " - "(SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,Logo,WWW,0 AS NumUsrs" + "(SELECT InsCod,CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW,0 AS NumUsrs" " FROM institutions" " WHERE CtyCod='%ld' AND InsCod NOT IN (SELECT DISTINCT InsCod FROM usr_data))" " ORDER BY %s", @@ -830,11 +815,8 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData) strncpy (Ins->FullName,row[5],Ins_MAX_LENGTH_INSTITUTION_FULL_NAME); Ins->FullName[Ins_MAX_LENGTH_INSTITUTION_FULL_NAME] = '\0'; - /* Get the logo of the institution (row[6]) */ - strcpy (Ins->Logo,row[6]); - - /* Get the URL of the institution (row[7]) */ - strcpy (Ins->WWW,row[7]); + /* Get the URL of the institution (row[6]) */ + strcpy (Ins->WWW,row[6]); /* Get extra data */ switch (GetExtraData) @@ -844,8 +826,8 @@ void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData) Ins->NumCtrs = Ins->NumDpts = Ins->NumDegs = 0; break; case Ins_GET_EXTRA_DATA: - /* Get number of users in this institution (row[8]) */ - if (sscanf (row[8],"%u",&Ins->NumUsrs) == 1) + /* Get number of users in this institution (row[7]) */ + if (sscanf (row[7],"%u",&Ins->NumUsrs) == 1) { if (Ins->NumUsrs) { @@ -894,7 +876,6 @@ bool Ins_GetDataOfInstitutionByCod (struct Institution *Ins, Ins->RequesterUsrCod = -1L; Ins->ShortName[0] = Ins->FullName[0] = - Ins->Logo[0] = Ins->WWW[0] = '\0'; Ins->NumStds = Ins->NumTchs = Ins->NumUsrs = Ins->NumCtrs = Ins->NumDpts = Ins->NumDegs = 0; @@ -905,7 +886,7 @@ bool Ins_GetDataOfInstitutionByCod (struct Institution *Ins, // Ins->InsCod > 0 /***** Get data of an institution from database *****/ - sprintf (Query,"SELECT CtyCod,Status,RequesterUsrCod,ShortName,FullName,Logo,WWW" + sprintf (Query,"SELECT CtyCod,Status,RequesterUsrCod,ShortName,FullName,WWW" " FROM institutions WHERE InsCod='%ld'", Ins->InsCod); @@ -934,16 +915,13 @@ bool Ins_GetDataOfInstitutionByCod (struct Institution *Ins, strncpy (Ins->FullName,row[4],Ins_MAX_LENGTH_INSTITUTION_FULL_NAME); Ins->FullName[Ins_MAX_LENGTH_INSTITUTION_FULL_NAME] = '\0'; - /* Get the logo of the institution (row[5]) */ - strcpy (Ins->Logo,row[5]); - - /* Get the URL of the institution (row[6]) */ - strcpy (Ins->WWW,row[6]); + /* Get the URL of the institution (row[5]) */ + strcpy (Ins->WWW,row[5]); /* Get extra data */ if (GetExtraData == Ins_GET_EXTRA_DATA) { - /* Get number of users in this institution (row[8]) */ + /* Get number of users in this institution */ Ins->NumStds = Usr_GetNumberOfUsersInInstitution (Ins->InsCod,Rol_ROLE_STUDENT); // Slow query Ins->NumTchs = Usr_GetNumberOfUsersInInstitution (Ins->InsCod,Rol_ROLE_TEACHER); // Slow query Ins->NumUsrs = Ins->NumStds + Ins->NumTchs; @@ -1136,7 +1114,7 @@ static void Ins_ListInstitutionsForEdition (void) fprintf (Gbl.F.Out,"", Ins->FullName); - Ins_DrawInstitutionLogo (Ins->Logo,Ins->ShortName,16,NULL); + Ins_DrawInstitutionLogo (Ins->InsCod,Ins->ShortName,16,NULL); fprintf (Gbl.F.Out,""); /* Country */ @@ -1546,7 +1524,7 @@ void Ins_ChangeInsCountry (void) extern const char *Txt_The_country_of_the_institution_X_has_changed_Y; struct Institution *Ins; struct Country NewCty; - char Query[256+Ins_MAX_LENGTH_INSTITUTION_LOGO]; + char Query[256]; Ins = &Gbl.Inss.EditingIns; @@ -1583,8 +1561,9 @@ void Ins_ChangeInsCountry (void) } else { - /***** Update the table changing old logo by new logo *****/ - sprintf (Query,"UPDATE institutions SET CtyCod='%ld' WHERE InsCod='%ld'", + /***** Update the table changing the country of the institution *****/ + sprintf (Query,"UPDATE institutions SET CtyCod='%ld'" + " WHERE InsCod='%ld'", NewCty.CtyCod,Ins->InsCod); DB_QueryUPDATE (Query,"can not update the country of an institution"); @@ -1601,31 +1580,6 @@ void Ins_ChangeInsCountry (void) Ins_EditInstitutions (); } -/*****************************************************************************/ -/********************* Change the logo of a institution **********************/ -/*****************************************************************************/ - -void Ins_ChangeInsLogo (void) - { - extern const char *Txt_The_new_logo_is_X; - char Query[256+Ins_MAX_LENGTH_INSTITUTION_LOGO]; - - /***** Get the new logo for the institution from form *****/ - Par_GetParToText ("Logo",Gbl.CurrentIns.Ins.Logo,Ins_MAX_LENGTH_INSTITUTION_LOGO); - - /***** Update the table changing old logo by new logo *****/ - sprintf (Query,"UPDATE institutions SET Logo='%s' WHERE InsCod='%ld'", - Gbl.CurrentIns.Ins.Logo,Gbl.CurrentIns.Ins.InsCod); - DB_QueryUPDATE (Query,"can not update the logo of the institution"); - - /***** Write message to show the change made *****/ - sprintf (Gbl.Message,Txt_The_new_logo_is_X,Gbl.CurrentIns.Ins.Logo); - Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); - - /***** Show the form again *****/ - Ins_ShowConfiguration (); - } - /*****************************************************************************/ /********************** Change the URL of a institution **********************/ /*****************************************************************************/ @@ -1715,6 +1669,24 @@ void Ins_ChangeInsStatus (void) Ins_EditInstitutions (); } +/*****************************************************************************/ +/******** Show a form for sending a logo of the current institution **********/ +/*****************************************************************************/ + +void Ins_RequestLogo (void) + { + Log_RequestLogo (Sco_SCOPE_INSTITUTION); + } + +/*****************************************************************************/ +/************** Receive the logo of the current institution ******************/ +/*****************************************************************************/ + +void Ins_ReceiveLogo (void) + { + Log_ReceiveLogo (Sco_SCOPE_INSTITUTION); + } + /*****************************************************************************/ /******************* Put a form to create a new institution ******************/ /*****************************************************************************/ @@ -1761,7 +1733,7 @@ static void Ins_PutFormToCreateInstitution (void) /***** Institution logo *****/ fprintf (Gbl.F.Out,""); - Ins_DrawInstitutionLogo (NULL,"",16,NULL); + Ins_DrawInstitutionLogo (-1L,"",16,NULL); fprintf (Gbl.F.Out,""); /***** Country *****/ @@ -1958,7 +1930,7 @@ static void Ins_RecFormRequestOrCreateIns (unsigned Status) else // Add new institution to database Ins_CreateInstitution (Ins,Status); } - else // If there is not a logo or a web + else // If there is not a web Lay_ShowAlert (Lay_WARNING,Txt_You_must_specify_the_web_address_of_the_new_institution); } else // If there is not a institution name @@ -1979,9 +1951,9 @@ static void Ins_CreateInstitution (struct Institution *Ins,unsigned Status) /***** Create a new institution *****/ sprintf (Query,"INSERT INTO institutions (CtyCod,Status,RequesterUsrCod," - "ShortName,FullName,Logo,WWW)" + "ShortName,FullName,WWW)" " VALUES ('%ld','%u','%ld'," - "'%s','%s','','%s')", + "'%s','%s','%s')", Ins->CtyCod, Status, Gbl.Usrs.Me.UsrDat.UsrCod, @@ -2096,33 +2068,37 @@ unsigned Ins_GetNumInssWithUsrs (Rol_Role_t Role,const char *SubQuery) /**************************** Draw institution logo **************************/ /*****************************************************************************/ -void Ins_DrawInstitutionLogo (const char *Logo,const char *AltText, +void Ins_DrawInstitutionLogo (long InsCod,const char *AltText, unsigned Size,const char *Style) { char PathLogo[PATH_MAX+1]; bool LogoExists = false; /***** 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_INSTITUTIONS, - Logo); - LogoExists = Fil_CheckIfPathExists (PathLogo); - } + if (InsCod > 0) + { + sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_INS, + (unsigned) (InsCod % 100), + (unsigned) InsCod, + (unsigned) InsCod); + LogoExists = Fil_CheckIfPathExists (PathLogo); + } + else + LogoExists = false; /***** Draw logo *****/ fprintf (Gbl.F.Out,"\"%s\"",Ins.WWW); - Ins_DrawInstitutionLogo (Ins.Logo,Ins.ShortName,Size,NULL); + Ins_DrawInstitutionLogo (Ins.InsCod,Ins.ShortName,Size,NULL); if (!PrintView) fprintf (Gbl.F.Out,""); } diff --git a/swad_record.c b/swad_record.c index 1ee14248e..ddeffbe94 100644 --- a/swad_record.c +++ b/swad_record.c @@ -2143,7 +2143,7 @@ void Rec_ShowCommonRecord (Rec_RecordViewType_t TypeOfView, { Ins.InsCod = UsrDat->InsCod; Ins_GetDataOfInstitutionByCod (&Ins,Ins_GET_MINIMAL_DATA); - Ins_DrawInstitutionLogo (Ins.Logo,Ins.ShortName,Rec_INSTITUTION_LOGO_SIZE,NULL); + Ins_DrawInstitutionLogo (Ins.InsCod,Ins.ShortName,Rec_INSTITUTION_LOGO_SIZE,NULL); fprintf (Gbl.F.Out,"" "" diff --git a/swad_scope.h b/swad_scope.h index 831b881b0..f4f5feee9 100644 --- a/swad_scope.h +++ b/swad_scope.h @@ -27,6 +27,8 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ +#include "swad_bool.h" + /*****************************************************************************/ /***************************** Public constants ******************************/ /*****************************************************************************/