diff --git a/sql/swad.sql b/sql/swad.sql index 5a7e1e2d0..b7470f444 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -407,7 +407,6 @@ CREATE TABLE IF NOT EXISTS degrees ( FirstYear TINYINT NOT NULL DEFAULT 0, LastYear TINYINT NOT NULL DEFAULT 0, OptYear ENUM('N','Y') NOT NULL DEFAULT 'N', - Logo VARCHAR(16) NOT NULL, WWW VARCHAR(255) NOT NULL, UNIQUE INDEX(DegCod), INDEX(CtrCod), diff --git a/swad_action.c b/swad_action.c index 3a6c07c71..a82a352cd 100644 --- a/swad_action.c +++ b/swad_action.c @@ -245,7 +245,8 @@ Degree: 138. ActDegSch Search for courses, teachers, documents... 139. ActPrnDegInf Print information on the current degree - 140. ActChgDegLog Request change of the logo of a degree + ---. ActReqDegLog Show form to send the logo of the current degree + 140. ActRecDegLog Receive and store the logo of the current degree 141. ActEdiCrs Request edition of courses of a degree 142. ActReqCrs Request the creation of a request for a new course (a teacher makes the petition to an administrator) @@ -1313,8 +1314,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}, - /* 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}, + /* ActReqInsLog */{1245,-1,TabIns,ActSeeInsInf ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Ins_RequestLogo ,NULL}, + /* ActRecInsLog */{ 699,-1,TabIns,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}, @@ -1392,7 +1393,8 @@ struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = /* ActDegSch */{1184,-1,TabDeg,ActDegReqSch ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_MAIN_WINDOW,Sch_GetParamsSearch ,Sch_DegSearch ,NULL}, /* ActPrnDegInf */{1150,-1,TabDeg,ActSeeDegInf ,0x1FF,0x1FF,0x1FF,Act_CONTENT_NORM,Act_NEW_WINDOW ,NULL ,Deg_PrintConfiguration ,NULL}, - /* ActChgDegLog */{ 553,-1,TabDeg,ActSeeDegInf ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Deg_ChangeDegLogo ,NULL}, + /* ActReqDegLog */{1246,-1,TabDeg,ActSeeDegInf ,0x100,0x100,0x100,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Deg_RequestLogo ,NULL}, + /* ActRecDegLog */{ 553,-1,TabDeg,ActSeeDegInf ,0x100,0x100,0x100,Act_CONTENT_DATA,Act_MAIN_WINDOW,NULL ,Deg_ReceiveLogo ,NULL}, /* ActEdiCrs */{ 555,-1,TabDeg,ActSeeCrs ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Crs_ReqEditCourses ,NULL}, /* ActReqCrs */{1053,-1,TabDeg,ActSeeCrs ,0x1FE,0x1FE,0x1FE,Act_CONTENT_NORM,Act_MAIN_WINDOW,NULL ,Crs_RecFormReqCrs ,NULL}, @@ -2836,7 +2838,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActChgDegFstYea, // #550 ActChgDegLstYea, // #551 ActChgDegOptYea, // #552 - ActChgDegLog, // #553 + ActRecDegLog, // #553 ActChgDegWWW, // #554 ActEdiCrs, // #555 ActNewCrs, // #556 @@ -3529,6 +3531,7 @@ Act_Action_t Act_FromActCodToAction[1+Act_MAX_ACTION_COD] = // Do not reuse uniq ActChgMnu, // #1243 ActReqCtrLog, // #1244 ActReqInsLog, // #1245 + ActReqDegLog, // #1246 }; /*****************************************************************************/ diff --git a/swad_action.h b/swad_action.h index 3fc6b8bfe..5acc57546 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+40+23+17+204+184+94+168+28+75) +#define Act_NUM_ACTIONS (7+52+15+40+23+18+204+184+94+168+28+75) -#define Act_MAX_ACTION_COD 1245 +#define Act_MAX_ACTION_COD 1246 #define Act_MAX_OPTIONS_IN_MENU_PER_TAB 20 @@ -265,19 +265,20 @@ typedef int Act_Action_t; // Must be a signed type, because -1 is used to indica // Secondary actions #define ActDegSch (ActChgDegSta+ 4) #define ActPrnDegInf (ActChgDegSta+ 5) -#define ActChgDegLog (ActChgDegSta+ 6) +#define ActReqDegLog (ActChgDegSta+ 6) +#define ActRecDegLog (ActChgDegSta+ 7) -#define ActEdiCrs (ActChgDegSta+ 7) -#define ActReqCrs (ActChgDegSta+ 8) -#define ActNewCrs (ActChgDegSta+ 9) -#define ActRemCrs (ActChgDegSta+ 10) -#define ActChgInsCrsCod (ActChgDegSta+ 11) -#define ActChgCrsDeg (ActChgDegSta+ 12) -#define ActChgCrsYea (ActChgDegSta+ 13) -#define ActChgCrsSem (ActChgDegSta+ 14) -#define ActRenCrsSho (ActChgDegSta+ 15) -#define ActRenCrsFul (ActChgDegSta+ 16) -#define ActChgCrsSta (ActChgDegSta+ 17) +#define ActEdiCrs (ActChgDegSta+ 8) +#define ActReqCrs (ActChgDegSta+ 9) +#define ActNewCrs (ActChgDegSta+ 10) +#define ActRemCrs (ActChgDegSta+ 11) +#define ActChgInsCrsCod (ActChgDegSta+ 12) +#define ActChgCrsDeg (ActChgDegSta+ 13) +#define ActChgCrsYea (ActChgDegSta+ 14) +#define ActChgCrsSem (ActChgDegSta+ 15) +#define ActRenCrsSho (ActChgDegSta+ 16) +#define ActRenCrsFul (ActChgDegSta+ 17) +#define ActChgCrsSta (ActChgDegSta+ 18) /*****************************************************************************/ /******************************** Course tab *********************************/ diff --git a/swad_changelog.h b/swad_changelog.h index e24ab412c..c720bc5b7 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -39,11 +39,17 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 14.56 (2015/01/17)" +#define Log_PLATFORM_VERSION "SWAD 14.57 (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.57: Jan 17, 2015 New option to upload logo of degree. (173720 lines) + 3 changes necessary in database: +UPDATE actions SET Txt='Cambiar logo de titulación' WHERE ActCod='553' AND Language='es'; +INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1246','es','N','Solicitar envío de logo de titulación'); +ALTER TABLE degrees DROP COLUMN Logo; + 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: diff --git a/swad_chat.c b/swad_chat.c index 1e868d662..bdde086cb 100644 --- a/swad_chat.c +++ b/swad_chat.c @@ -58,8 +58,9 @@ extern struct Globals Gbl; /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void Cht_WriteLinkToChat (const char *Icon,const char *RoomCode,const char *RoomShortName,const char *RoomFullName, - unsigned Level,bool IsLastItemInLevel[1+Cht_CHAT_MAX_LEVELS]); +static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShortName,const char *RoomFullName, + unsigned Level,bool IsLastItemInLevel[1+Cht_CHAT_MAX_LEVELS]); +static void Cht_WriteLinkToChat2 (const char *RoomCode,const char *RoomFullName); static unsigned Cht_GetNumUsrsInChatRoom (const char *RoomCode); /*****************************************************************************/ @@ -105,8 +106,8 @@ void Cht_ShowListOfAvailableChatRooms (void) struct Course Crs; MYSQL_RES *mysql_res; MYSQL_ROW row; - unsigned long NumRow,NumRows; - char Icon[512]; + unsigned long NumRow; + unsigned long NumRows; char ThisRoomCode [MAX_LENGTH_ROOM_CODE +1]; char ThisRoomShortName[MAX_LENGTH_ROOM_SHORT_NAME+1]; char ThisRoomFullName [MAX_LENGTH_ROOM_FULL_NAME +1]; @@ -133,26 +134,35 @@ void Cht_ShowListOfAvailableChatRooms (void) Gbl.Prefs.IconsURL,Txt_Chat_rooms); /***** Link to chat available for all the users *****/ - sprintf (Icon,"", - Gbl.Prefs.IconsURL); - IsLastItemInLevel[1] = (Gbl.Usrs.Me.LoggedRole != Rol_ROLE_STUDENT && Gbl.Usrs.Me.LoggedRole != Rol_ROLE_TEACHER && !Gbl.Usrs.Me.MyDegrees.Num); sprintf (ThisRoomFullName,"%s (%s)",Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]); - Cht_WriteLinkToChat (Icon,"GBL_USR",Txt_SEX_PLURAL_Abc[Usr_SEX_ALL],ThisRoomFullName,1,IsLastItemInLevel); + Cht_WriteLinkToChat1 ("GBL_USR",Txt_SEX_PLURAL_Abc[Usr_SEX_ALL],ThisRoomFullName,1,IsLastItemInLevel); + fprintf (Gbl.F.Out,"", + Gbl.Prefs.IconsURL); + Cht_WriteLinkToChat2 ("GBL_USR",ThisRoomFullName); + IsLastItemInLevel[1] = !Gbl.Usrs.Me.MyDegrees.Num; switch (Gbl.Usrs.Me.LoggedRole) { case Rol_ROLE_STUDENT: sprintf (ThisRoomFullName,"%s (%s)",Txt_General,Txt_ROLES_PLURAL_abc[Rol_ROLE_STUDENT][Usr_SEX_ALL]); - Cht_WriteLinkToChat (Icon,"GBL_STD",Txt_Students_ABBREVIATION,ThisRoomFullName,1,IsLastItemInLevel); + Cht_WriteLinkToChat1 ("GBL_STD",Txt_Students_ABBREVIATION,ThisRoomFullName,1,IsLastItemInLevel); + fprintf (Gbl.F.Out,"", + Gbl.Prefs.IconsURL); + Cht_WriteLinkToChat2 ("GBL_STD",ThisRoomFullName); break; case Rol_ROLE_TEACHER: sprintf (ThisRoomFullName,"%s (%s)",Txt_General,Txt_ROLES_PLURAL_abc[Rol_ROLE_TEACHER][Usr_SEX_ALL]); - Cht_WriteLinkToChat (Icon,"GBL_TCH",Txt_Teachers_ABBREVIATION,ThisRoomFullName,1,IsLastItemInLevel); + Cht_WriteLinkToChat1 ("GBL_TCH",Txt_Teachers_ABBREVIATION,ThisRoomFullName,1,IsLastItemInLevel); + fprintf (Gbl.F.Out,"", + Gbl.Prefs.IconsURL); + Cht_WriteLinkToChat2 ("GBL_TCH",ThisRoomFullName); break; default: break; @@ -169,14 +179,13 @@ void Cht_ShowListOfAvailableChatRooms (void) Lay_ShowErrorAndExit ("Degree not found."); /* Link to the room of this degree */ - IsLastItemInLevel[1] = (NumMyDeg == Gbl.Usrs.Me.MyDegrees.Num-1); - sprintf (Icon,"", - Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_DEGREES,Deg.Logo); + IsLastItemInLevel[1] = (NumMyDeg == Gbl.Usrs.Me.MyDegrees.Num - 1); sprintf (ThisRoomCode,"DEG_%ld",Deg.DegCod); sprintf (ThisRoomShortName,"%s",Deg.ShortName); sprintf (ThisRoomFullName,"%s %s",Txt_Degree,Deg.ShortName); - Cht_WriteLinkToChat (Icon,ThisRoomCode,ThisRoomShortName,ThisRoomFullName,1,IsLastItemInLevel); + Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShortName,ThisRoomFullName,1,IsLastItemInLevel); + Deg_DrawDegreeLogo (Deg.DegCod,Deg.ShortName,16,NULL); + Cht_WriteLinkToChat2 (ThisRoomCode,ThisRoomFullName); /* Get my courses in this degree from database */ if ((NumRows = Usr_GetCrssFromUsr (Gbl.Usrs.Me.UsrDat.UsrCod,Deg.DegCod,&mysql_res)) > 0) // Courses found in this degree @@ -194,14 +203,15 @@ void Cht_ShowListOfAvailableChatRooms (void) Crs_GetDataOfCourseByCod (&Crs); /* Link to the room of this course */ - IsLastItemInLevel[2] = (NumRow == NumRows-1); - sprintf (Icon,"", - Gbl.Prefs.IconsURL); + IsLastItemInLevel[2] = (NumRow == NumRows - 1); sprintf (ThisRoomCode,"CRS_%ld",Crs.CrsCod); sprintf (ThisRoomShortName,"%s",Crs.ShortName); sprintf (ThisRoomFullName,"%s %s",Txt_Course,Crs.ShortName); - Cht_WriteLinkToChat (Icon,ThisRoomCode,ThisRoomShortName,ThisRoomFullName,2,IsLastItemInLevel); + Cht_WriteLinkToChat1 (ThisRoomCode,ThisRoomShortName,ThisRoomFullName,2,IsLastItemInLevel); + fprintf (Gbl.F.Out,"", + Gbl.Prefs.IconsURL); + Cht_WriteLinkToChat2 (ThisRoomCode,ThisRoomFullName); } } @@ -284,24 +294,30 @@ void Cht_ShowListOfChatRoomsWithUsrs (void) /******************** Write title and link to a chat room ********************/ /*****************************************************************************/ -static void Cht_WriteLinkToChat (const char *Icon,const char *RoomCode,const char *RoomShortName,const char *RoomFullName, - unsigned Level,bool IsLastItemInLevel[1+Cht_CHAT_MAX_LEVELS]) +static void Cht_WriteLinkToChat1 (const char *RoomCode,const char *RoomShortName,const char *RoomFullName, + unsigned Level,bool IsLastItemInLevel[1+Cht_CHAT_MAX_LEVELS]) { extern const char *The_ClassFormul[The_NUM_THEMES]; - extern const char *Txt_connected_PLURAL; - extern const char *Txt_connected_SINGULAR; - unsigned NumUsrsInRoom = Cht_GetNumUsrsInChatRoom (RoomCode); - sprintf (Gbl.Chat.WindowName,"%s_%s",RoomCode,Gbl.UniqueNameEncrypted); + // sprintf (Gbl.Chat.WindowName,"%s_%s",RoomCode,Gbl.UniqueNameEncrypted); fprintf (Gbl.F.Out,"
  • "); Lay_IndentDependingOnLevel (Level,IsLastItemInLevel); Act_FormStart (ActCht); Cht_WriteParamsRoomCodeAndNames (RoomCode,RoomShortName,RoomFullName); Act_LinkFormSubmit (RoomFullName,The_ClassFormul[Gbl.Prefs.Theme]); + } + +static void Cht_WriteLinkToChat2 (const char *RoomCode,const char *RoomFullName) + { + extern const char *The_ClassFormul[The_NUM_THEMES]; + extern const char *Txt_connected_PLURAL; + extern const char *Txt_connected_SINGULAR; + unsigned NumUsrsInRoom = Cht_GetNumUsrsInChatRoom (RoomCode); + if (NumUsrsInRoom) fprintf (Gbl.F.Out,""); - fprintf (Gbl.F.Out,"%s %s",Icon,RoomFullName); + fprintf (Gbl.F.Out,"%s",RoomFullName); if (NumUsrsInRoom > 1) fprintf (Gbl.F.Out," [%d %s]", NumUsrsInRoom,Txt_connected_PLURAL); diff --git a/swad_config.h b/swad_config.h index cfbaca8d0..026614fa1 100644 --- a/swad_config.h +++ b/swad_config.h @@ -399,7 +399,7 @@ #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_DEGREES "degree" // Directory with icons for degrees +// #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 #define Cfg_ICON_ACTION "action64x64" // Directory with icons for title of current menu action diff --git a/swad_course.c b/swad_course.c index d27122bef..3a1f94403 100644 --- a/swad_course.c +++ b/swad_course.c @@ -211,11 +211,7 @@ static void Crs_Configuration (bool PrintView) " class=\"TITLE_LOCATION\" title=\"%s\">", Gbl.CurrentDeg.Deg.WWW, Gbl.CurrentDeg.Deg.FullName); - fprintf (Gbl.F.Out,"\"%s\"", - Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_DEGREES, - Gbl.CurrentDeg.Deg.Logo, - Gbl.CurrentDeg.Deg.ShortName); + Deg_DrawDegreeLogo (Gbl.CurrentDeg.Deg.DegCod,Gbl.CurrentDeg.Deg.ShortName,64,NULL); if (PutLink) fprintf (Gbl.F.Out,""); fprintf (Gbl.F.Out,"
    %s" @@ -746,7 +742,7 @@ static void Crs_WriteListMyCoursesToSelectOne (void) Deg_PutParamDegCod (Deg.DegCod); Act_LinkFormSubmit (Act_GetActionTextFromDB (Act_Actions[ActSeeDegInf].ActCod,ActTxt), The_ClassFormul[Gbl.Prefs.Theme]); - Deg_DrawDegreeLogo (Deg.Logo,Deg.ShortName,16,NULL); + Deg_DrawDegreeLogo (Deg.DegCod,Deg.ShortName,16,NULL); Highlight = (Gbl.CurrentCrs.Crs.CrsCod <= 0 && Gbl.CurrentDeg.Deg.DegCod == Deg.DegCod); if (Highlight) @@ -3085,7 +3081,7 @@ void Crs_GetAndWriteCrssOfAUsr (long UsrCod,Rol_Role_t Role) unsigned NumCrs; /***** Get courses of a user from database *****/ - sprintf (Query,"SELECT degrees.DegCod,courses.CrsCod,degrees.Logo,degrees.ShortName,degrees.FullName," + sprintf (Query,"SELECT degrees.DegCod,courses.CrsCod,degrees.ShortName,degrees.FullName," "courses.Year,courses.Semester,courses.FullName,centres.ShortName,crs_usr.Accepted" " FROM crs_usr,courses,degrees,centres" " WHERE crs_usr.UsrCod='%ld'" @@ -3249,7 +3245,7 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA extern const char *Txt_Go_to_X; extern const char *Txt_YEAR_OF_DEGREE[1+Deg_MAX_YEARS_PER_DEGREE]; extern const char *Txt_SEMESTER_OF_YEAR[1+2]; - long DegCod; + struct Degree Deg; long CrsCod; unsigned NumStds; unsigned NumTchs; @@ -3259,8 +3255,10 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA bool Accepted; /***** Get degree code (row[0]) *****/ - if ((DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0) + if ((Deg.DegCod = Str_ConvertStrCodToLongCod (row[0])) < 0) Lay_ShowErrorAndExit ("Wrong code of degree."); + if (!Deg_GetDataOfDegreeByCod (&Deg)) + Lay_ShowErrorAndExit ("Degree not found."); /***** Get course code (row[1]) *****/ if ((CrsCod = Str_ConvertStrCodToLongCod (row[1])) < 0) @@ -3288,7 +3286,7 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA /***** Teacher has accepted joining to this course/to any course in degree/to any course? *****/ if (WriteColumnAccepted) { - Accepted = (Str_ConvertToUpperLetter (row[9][0]) == 'Y'); + Accepted = (Str_ConvertToUpperLetter (row[8][0]) == 'Y'); fprintf (Gbl.F.Out,"" "\"\"" @@ -3308,44 +3306,42 @@ static void Crs_WriteRowCrsData (unsigned NumCrs,MYSQL_ROW row,bool WriteColumnA "", StyleNoBR,BgColor,NumCrs); - /***** Write degree logo (row[2]), degree short name (row[3]) and centre short name (row[8]) *****/ + /***** Write degree logo, degree short name (row[2]) and centre short name (row[7]) *****/ fprintf (Gbl.F.Out,"", StyleNoBR,BgColor); Act_FormGoToStart (ActSeeDegInf); - Deg_PutParamDegCod (DegCod); - sprintf (Gbl.Title,Txt_Go_to_X,row[4]); + Deg_PutParamDegCod (Deg.DegCod); + sprintf (Gbl.Title,Txt_Go_to_X,row[2]); Act_LinkFormSubmit (Gbl.Title,StyleNoBR); - fprintf (Gbl.F.Out,"\"%s\""" - " %s (%s)" + Deg_DrawDegreeLogo (Deg.DegCod,Deg.ShortName,64,NULL); + fprintf (Gbl.F.Out," %s (%s)" "" "" "", - Gbl.Prefs.IconsURL,Cfg_ICON_FOLDER_DEGREES,row[2], - row[3],row[3],row[8]); + row[2],row[7]); - /***** Write year (row[5]) *****/ + /***** Write year (row[4]) *****/ fprintf (Gbl.F.Out,"" "%s" "", - Style,BgColor,Txt_YEAR_OF_DEGREE[Deg_ConvStrToYear (row[5])]); + Style,BgColor,Txt_YEAR_OF_DEGREE[Deg_ConvStrToYear (row[4])]); - /***** Write semester (row[6]) *****/ + /***** Write semester (row[5]) *****/ fprintf (Gbl.F.Out,"" "%s" "", - Style,BgColor,Txt_SEMESTER_OF_YEAR[Deg_ConvStrToSemester (row[6])]); + Style,BgColor,Txt_SEMESTER_OF_YEAR[Deg_ConvStrToSemester (row[5])]); - /***** Write course full name (row[7]) *****/ + /***** Write course full name (row[6]) *****/ fprintf (Gbl.F.Out,"", Style,BgColor); Act_FormGoToStart (ActSeeCrsInf); Crs_PutParamCrsCod (CrsCod); - sprintf (Gbl.Title,Txt_Go_to_X,row[7]); + sprintf (Gbl.Title,Txt_Go_to_X,row[6]); Act_LinkFormSubmit (Gbl.Title,Style); fprintf (Gbl.F.Out,"%s" "" diff --git a/swad_database.c b/swad_database.c index 28212887a..9ddc4cf76 100644 --- a/swad_database.c +++ b/swad_database.c @@ -874,10 +874,9 @@ mysql> DESCRIBE degrees; | FirstYear | tinyint(4) | NO | | 0 | | | LastYear | tinyint(4) | NO | | 0 | | | OptYear | enum('N','Y') | NO | | N | | -| Logo | varchar(16) | NO | | NULL | | | WWW | varchar(255) | NO | | NULL | | +-----------------+---------------+------+-----+---------+----------------+ -12 rows in set (0.01 sec) +11 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS degrees (" "DegCod INT NOT NULL AUTO_INCREMENT," @@ -890,7 +889,6 @@ mysql> DESCRIBE degrees; "FirstYear TINYINT NOT NULL DEFAULT 0," "LastYear TINYINT NOT NULL DEFAULT 0," "OptYear ENUM('N','Y') NOT NULL DEFAULT 'N'," - "Logo VARCHAR(16) NOT NULL," "WWW VARCHAR(255) NOT NULL," "UNIQUE INDEX(DegCod),INDEX(CtrCod),INDEX(DegTypCod),INDEX(Status))"); diff --git a/swad_degree.c b/swad_degree.c index 65044e33a..72e22e94d 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -223,7 +223,7 @@ void Deg_SeeDegWithPendingCrss (void) "", BgColor,Deg.WWW,Deg.FullName); - Deg_DrawDegreeLogo (Deg.Logo,Deg.ShortName,16,"vertical-align:top;"); + Deg_DrawDegreeLogo (Deg.DegCod,Deg.ShortName,16,"vertical-align:top;"); fprintf (Gbl.F.Out,"" ""); @@ -288,7 +288,6 @@ static void Deg_Configuration (bool PrintView) extern const char *The_ClassFormul[The_NUM_THEMES]; extern const char *Txt_Degree; extern const char *Txt_Short_Name; - extern const char *Txt_Logo; extern const char *Txt_Shortcut_to_this_degree; extern const char *Txt_QR_code; extern const char *Txt_Courses; @@ -325,7 +324,7 @@ static void Deg_Configuration (bool PrintView) " class=\"TITLE_LOCATION\" title=\"%s\">", Gbl.CurrentDeg.Deg.WWW, Gbl.CurrentDeg.Deg.FullName); - Deg_DrawDegreeLogo (Gbl.CurrentDeg.Deg.Logo, + Deg_DrawDegreeLogo (Gbl.CurrentDeg.Deg.DegCod, Gbl.CurrentDeg.Deg.ShortName, 64,NULL); fprintf (Gbl.F.Out,"
    %s", @@ -372,28 +371,6 @@ static void Deg_Configuration (bool PrintView) Txt_Short_Name, Gbl.CurrentDeg.Deg.ShortName); - /***** Degree logo *****/ - if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER) - { - fprintf (Gbl.F.Out,"" - "" - "%s:" - "" - "", - The_ClassFormul[Gbl.Prefs.Theme], - Txt_Logo); - Act_FormStart (ActChgDegLog); - fprintf (Gbl.F.Out,"" - "" - "" - "", - Deg_MAX_LENGTH_DEGREE_LOGO,Gbl.CurrentDeg.Deg.Logo, - Gbl.FormId); - } - /***** Link to the degree *****/ fprintf (Gbl.F.Out,"" " 0) - Deg_DrawDegreeLogo (Gbl.CurrentDeg.Deg.Logo,Gbl.CurrentDeg.Deg.ShortName,32, + Deg_DrawDegreeLogo (Gbl.CurrentDeg.Deg.DegCod,Gbl.CurrentDeg.Deg.ShortName,32, "vertical-align:top; margin-right:8px;"); else if (Gbl.CurrentCtr.Ctr.CtrCod > 0) Ctr_DrawCentreLogo (Gbl.CurrentCtr.Ctr.CtrCod,Gbl.CurrentCtr.Ctr.ShortName,32, @@ -1291,7 +1268,7 @@ static void Deg_ListOneDegreeForSeeing (struct Degree *Deg,unsigned NumDeg) "", TxtClass,BgColor, Deg->WWW,Deg->FullName); - Deg_DrawDegreeLogo (Deg->Logo,Deg->ShortName,16,"vertical-align:top;"); + Deg_DrawDegreeLogo (Deg->DegCod,Deg->ShortName,16,"vertical-align:top;"); fprintf (Gbl.F.Out,"" ""); @@ -1434,7 +1411,7 @@ static void Deg_ListDegreesForEdition (void) fprintf (Gbl.F.Out,"", Deg->FullName); - Deg_DrawDegreeLogo (Deg->Logo,Deg->ShortName,16,NULL); + Deg_DrawDegreeLogo (Deg->DegCod,Deg->ShortName,16,NULL); fprintf (Gbl.F.Out,""); /* Centre */ @@ -1841,7 +1818,7 @@ static void Deg_PutFormToCreateDegree (void) /***** Degree logo *****/ fprintf (Gbl.F.Out,""); - Deg_DrawDegreeLogo (NULL,"",16,NULL); + Deg_DrawDegreeLogo (-1L,"",16,NULL); fprintf (Gbl.F.Out,""); /***** Centre *****/ @@ -2211,9 +2188,9 @@ static void Deg_CreateDegree (struct Degree *Deg,unsigned Status) /***** Create a new degree *****/ sprintf (Query,"INSERT INTO degrees (CtrCod,DegTypCod,Status,RequesterUsrCod," - "ShortName,FullName,FirstYear,LastYear,OptYear,Logo,WWW)" + "ShortName,FullName,FirstYear,LastYear,OptYear,WWW)" " VALUES ('%ld','%ld','%u','%ld'," - "'%s','%s','%u','%u','%c','','%s')", + "'%s','%s','%u','%u','%c','%s')", Deg->CtrCod,Deg->DegTypCod, Status, Gbl.Usrs.Me.UsrDat.UsrCod, @@ -2377,7 +2354,7 @@ void Deg_GetListAllDegs (void) /***** Get degrees admin by me from database *****/ sprintf (Query,"SELECT DegCod,CtrCod,DegTypCod,Status,RequesterUsrCod," - "ShortName,FullName,FirstYear,LastYear,OptYear,Logo,WWW" + "ShortName,FullName,FirstYear,LastYear,OptYear,WWW" " FROM degrees ORDER BY FullName"); Gbl.Degs.AllDegs.Num = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get degrees admin by you"); @@ -2432,7 +2409,7 @@ static void Deg_GetListDegsOfCurrentCtr (void) /***** Get degrees of the current centre from database *****/ sprintf (Query,"SELECT DegCod,CtrCod,DegTypCod,Status,RequesterUsrCod," - "ShortName,FullName,FirstYear,LastYear,OptYear,Logo,WWW" + "ShortName,FullName,FirstYear,LastYear,OptYear,WWW" " FROM degrees WHERE CtrCod='%ld' ORDER BY FullName", Gbl.CurrentCtr.Ctr.CtrCod); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get degrees of a centre"); @@ -2506,7 +2483,7 @@ void Deg_GetListDegsAdminByMe (void) /***** Get degrees admin by me from database *****/ if (Gbl.Usrs.Me.LoggedRole == Rol_ROLE_SUPERUSER) sprintf (Query,"SELECT DegCod,CtrCod,DegTypCod,Status,RequesterUsrCod," - "ShortName,FullName,FirstYear,LastYear,OptYear,Logo,WWW" + "ShortName,FullName,FirstYear,LastYear,OptYear,WWW" " FROM degrees" " WHERE CtrCod='%ld'" " ORDER BY ShortName", @@ -2514,7 +2491,7 @@ void Deg_GetListDegsAdminByMe (void) // TODO: put an if to select all degrees for admins of all degrees !!!!!!!!!!!!! else // Gbl.Usrs.Me.LoggedRole == Rol_ROLE_DEG_ADMIN sprintf (Query,"SELECT degrees.DegCod,degrees.CtrCod,degrees.DegTypCod,degrees.Status,degrees.RequesterUsrCod," - "degrees.ShortName,degrees.FullName,degrees.FirstYear,degrees.LastYear,degrees.OptYear,degrees.Logo,degrees.WWW" + "degrees.ShortName,degrees.FullName,degrees.FirstYear,degrees.LastYear,degrees.OptYear,degrees.WWW" " FROM deg_admin,degrees" " WHERE deg_admin.UsrCod='%ld' AND deg_admin.DegCod<>'-1' AND deg_admin.DegCod=degrees.DegCod" " ORDER BY degrees.ShortName", @@ -2938,7 +2915,6 @@ bool Deg_GetDataOfDegreeByCod (struct Degree *Deg) Deg->FirstYear = 0; Deg->LastYear = 0; Deg->OptYear = false; - Deg->Logo[0] = '\0'; Deg->WWW[0] = '\0'; Deg->NumCourses = 0; Deg->LstCrss = NULL; @@ -2947,7 +2923,7 @@ bool Deg_GetDataOfDegreeByCod (struct Degree *Deg) /***** Get data of a degree from database *****/ sprintf (Query,"SELECT DegCod,CtrCod,DegTypCod,Status,RequesterUsrCod," - "ShortName,FullName,FirstYear,LastYear,OptYear,Logo,WWW" + "ShortName,FullName,FirstYear,LastYear,OptYear,WWW" " FROM degrees WHERE DegCod ='%ld'", Deg->DegCod); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get data of a degree"); @@ -2972,7 +2948,6 @@ bool Deg_GetDataOfDegreeByCod (struct Degree *Deg) Deg->FirstYear = 0; Deg->LastYear = 0; Deg->OptYear = false; - Deg->Logo[0] = '\0'; Deg->WWW[0] = '\0'; Deg->NumCourses = 0; Deg->LstCrss = NULL; @@ -3026,10 +3001,7 @@ static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row) Deg->OptYear = (Str_ConvertToUpperLetter (row[9][0]) == 'Y'); /***** Get logo (row[10]) *****/ - strcpy (Deg->Logo,row[10]); - - /***** Get logo (row[11]) *****/ - strcpy (Deg->WWW,row[11]); + strcpy (Deg->WWW,row[10]); /***** Get number of courses *****/ Deg->NumCourses = Crs_GetNumCrssInDeg (Deg->DegCod); @@ -3670,31 +3642,6 @@ void Deg_ChangeDegOptYear (void) Deg_EditDegrees (); } -/*****************************************************************************/ -/************************ Change the logo of a degree ************************/ -/*****************************************************************************/ - -void Deg_ChangeDegLogo (void) - { - extern const char *Txt_The_new_logo_is_X; - char Query[256+Deg_MAX_LENGTH_DEGREE_LOGO]; - - /***** Get the new logo for the degree from form *****/ - Par_GetParToText ("Logo",Gbl.CurrentDeg.Deg.Logo,Deg_MAX_LENGTH_DEGREE_LOGO); - - /***** Update the table changing old logo by new logo *****/ - sprintf (Query,"UPDATE degrees SET Logo='%s' WHERE DegCod='%ld'", - Gbl.CurrentDeg.Deg.Logo,Gbl.CurrentDeg.Deg.DegCod); - DB_QueryUPDATE (Query,"can not update the logo of the degree"); - - /***** Write message to show the change made *****/ - sprintf (Gbl.Message,Txt_The_new_logo_is_X,Gbl.CurrentDeg.Deg.Logo); - Lay_ShowAlert (Lay_SUCCESS,Gbl.Message); - - /***** Show the form again *****/ - Deg_ShowConfiguration (); - } - /*****************************************************************************/ /************************* Change the WWW of a degree ************************/ /*****************************************************************************/ @@ -3787,6 +3734,24 @@ void Deg_ChangeDegStatus (void) Deg_EditDegrees (); } +/*****************************************************************************/ +/*********** Show a form for sending a logo of the current degree ************/ +/*****************************************************************************/ + +void Deg_RequestLogo (void) + { + Log_RequestLogo (Sco_SCOPE_DEGREE); + } + +/*****************************************************************************/ +/***************** Receive the logo of the current degree ********************/ +/*****************************************************************************/ + +void Deg_ReceiveLogo (void) + { + Log_ReceiveLogo (Sco_SCOPE_DEGREE); + } + /*****************************************************************************/ /*********************** Get total number of degrees *************************/ /*****************************************************************************/ @@ -3913,8 +3878,9 @@ void Deg_GetAndWriteDegreesAdminBy (long UsrCod,unsigned ColSpan) /***** Get degrees admin by a user from database *****/ sprintf (Query,"(SELECT DegCod,'','' AS ShortName,'' FROM deg_admin WHERE UsrCod='%ld' AND DegCod<'0')" " UNION " - "(SELECT degrees.DegCod,degrees.ShortName AS ShortName,degrees.FullName,degrees.Logo FROM deg_admin,degrees" - " WHERE deg_admin.UsrCod='%ld' AND deg_admin.DegCod>='0' AND deg_admin.DegCod=degrees.DegCod) ORDER BY ShortName", + "(SELECT degrees.DegCod,degrees.ShortName AS ShortName,degrees.FullName FROM deg_admin,degrees" + " WHERE deg_admin.UsrCod='%ld' AND deg_admin.DegCod>='0' AND deg_admin.DegCod=degrees.DegCod)" + " ORDER BY ShortName", UsrCod,UsrCod); if ((NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get degrees admin by a user"))) // If degrees found for this administrator { @@ -3952,7 +3918,7 @@ void Deg_GetAndWriteDegreesAdminBy (long UsrCod,unsigned ColSpan) Deg_PutParamDegCod (DegCod); sprintf (Gbl.Title,Txt_Go_to_X,row[2]); Act_LinkFormSubmit (Gbl.Title,"DAT_SMALL_NOBR"); - Deg_DrawDegreeLogo (row[3],row[1],16,"vertical-align:top;"); + Deg_DrawDegreeLogo (DegCod,row[1],16,"vertical-align:top;"); fprintf (Gbl.F.Out," %s" "", row[2]); @@ -3978,33 +3944,37 @@ void Deg_GetAndWriteDegreesAdminBy (long UsrCod,unsigned ColSpan) /****************************** Draw degree logo *****************************/ /*****************************************************************************/ -void Deg_DrawDegreeLogo (const char *Logo,const char *AltText, +void Deg_DrawDegreeLogo (long DegCod,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_DEGREES, - Logo); - LogoExists = Fil_CheckIfPathExists (PathLogo); - } + if (DegCod > 0) + { + sprintf (PathLogo,"%s/%s/%02u/%u/logo/%u.png", + Cfg_PATH_SWAD_PUBLIC,Cfg_FOLDER_DEG, + (unsigned) (DegCod % 100), + (unsigned) DegCod, + (unsigned) DegCod); + LogoExists = Fil_CheckIfPathExists (PathLogo); + } + else + LogoExists = false; /***** Draw logo *****/ fprintf (Gbl.F.Out,"\"%s\"" "", row[4],row[5]); diff --git a/swad_forum.c b/swad_forum.c index 80ebef3eb..f8f5773be 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -2154,7 +2154,7 @@ static void For_WriteLinkToForum (For_ForumType_t ForumType,Act_Action_t NextAct break; case For_FORUM_DEGREE_USRS: case For_FORUM_DEGREE_TCHS: - Deg_DrawDegreeLogo (Gbl.Forum.Deg.Logo,ForumName,16,"vertical-align:middle;"); + Deg_DrawDegreeLogo (Gbl.Forum.Deg.DegCod,ForumName,16,"vertical-align:middle;"); break; default: fprintf (Gbl.F.Out,"%s",Icon); diff --git a/swad_global.c b/swad_global.c index fbc916ce0..bdb614cb7 100644 --- a/swad_global.c +++ b/swad_global.c @@ -207,7 +207,6 @@ void Gbl_InitializeGlobals (void) Gbl.CurrentIns.Ins.InsCod = -1L; // Unknown institution Gbl.CurrentIns.Ins.ShortName[0] = '\0'; Gbl.CurrentIns.Ins.FullName[0] = '\0'; - Gbl.CurrentIns.Ins.Logo[0] = '\0'; Gbl.CurrentIns.Ins.WWW[0] = '\0'; Gbl.CurrentIns.Ins.NumStds = Gbl.CurrentIns.Ins.NumTchs = Gbl.CurrentIns.Ins.NumUsrs = Gbl.CurrentIns.Ins.NumCtrs = Gbl.CurrentIns.Ins.NumDpts = Gbl.CurrentIns.Ins.NumDegs = 0; @@ -237,7 +236,6 @@ void Gbl_InitializeGlobals (void) Gbl.Inss.EditingIns.CtyCod = -1L; Gbl.Inss.EditingIns.ShortName[0] = '\0'; Gbl.Inss.EditingIns.FullName[0] = '\0'; - Gbl.Inss.EditingIns.Logo[0] = '\0'; Gbl.Inss.EditingIns.WWW[0] = '\0'; Gbl.Inss.EditingIns.NumStds = Gbl.Inss.EditingIns.NumTchs = Gbl.Inss.EditingIns.NumUsrs = Gbl.Inss.EditingIns.NumCtrs = Gbl.Inss.EditingIns.NumDpts = Gbl.Inss.EditingIns.NumDegs = 0; @@ -303,7 +301,6 @@ void Gbl_InitializeGlobals (void) Gbl.Degs.EditingDeg.FullName[0] = '\0'; Gbl.Degs.EditingDeg.FirstYear = Gbl.Degs.EditingDeg.LastYear = 0; Gbl.Degs.EditingDeg.OptYear = false; - Gbl.Degs.EditingDeg.Logo[0] = '\0'; Gbl.Degs.EditingDeg.WWW[0] = '\0'; Gbl.Degs.EditingDeg.NumCourses = 0; Gbl.Degs.EditingDeg.LstCrss = NULL; diff --git a/swad_global.h b/swad_global.h index 0bd66beb5..abf9cee75 100644 --- a/swad_global.h +++ b/swad_global.h @@ -584,10 +584,10 @@ struct Globals { unsigned CurrentPage; } Pag; - struct - { - char WindowName[256]; - } Chat; + // struct + // { + // char WindowName[256]; + // } Chat; struct { unsigned Day,Hour,Column; diff --git a/swad_institution.c b/swad_institution.c index f06daf951..09d5c3d8a 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -2072,7 +2072,7 @@ void Ins_DrawInstitutionLogo (long InsCod,const char *AltText, unsigned Size,const char *Style) { char PathLogo[PATH_MAX+1]; - bool LogoExists = false; + bool LogoExists; /***** Path to logo *****/ if (InsCod > 0) diff --git a/swad_layout.c b/swad_layout.c index e9ff957d9..b30afc66b 100644 --- a/swad_layout.c +++ b/swad_layout.c @@ -1327,7 +1327,7 @@ void Lay_WriteHeaderClassPhoto (unsigned NumColumns,bool PrintView,bool DrawingC if (!PrintView) fprintf (Gbl.F.Out,"", Deg.WWW); - Deg_DrawDegreeLogo (Deg.Logo,Deg.ShortName,Size,NULL); + Deg_DrawDegreeLogo (Deg.DegCod,Deg.ShortName,Size,NULL); if (!PrintView) fprintf (Gbl.F.Out,""); } diff --git a/swad_photo.c b/swad_photo.c index 497a3965e..d05e8bf81 100644 --- a/swad_photo.c +++ b/swad_photo.c @@ -1983,7 +1983,7 @@ static void Pho_ShowOrPrintListDegrees (Pho_AvgPhotoSeeOrPrint_t SeeOrPrint) if (SeeOrPrint == Pho_DEGREES_SEE) fprintf (Gbl.F.Out,"", Deg.WWW,Deg.FullName); - Deg_DrawDegreeLogo (Deg.Logo,Deg.ShortName,16,"vertical-align:top;"); + Deg_DrawDegreeLogo (Deg.DegCod,Deg.ShortName,16,"vertical-align:top;"); fprintf (Gbl.F.Out," %s ", Deg.ShortName); if (SeeOrPrint == Pho_DEGREES_SEE) diff --git a/swad_record.c b/swad_record.c index ddeffbe94..2ee4f343c 100644 --- a/swad_record.c +++ b/swad_record.c @@ -1529,7 +1529,7 @@ void Rec_ShowCrsRecord (Rec_RecordViewType_t TypeOfView,struct UsrData *UsrDat) "" "", Rec_DEGREE_LOGO_SIZE); - Deg_DrawDegreeLogo (Gbl.CurrentDeg.Deg.Logo, + Deg_DrawDegreeLogo (Gbl.CurrentDeg.Deg.DegCod, Gbl.CurrentDeg.Deg.ShortName, Rec_DEGREE_LOGO_SIZE,NULL); fprintf (Gbl.F.Out,"" diff --git a/swad_search.c b/swad_search.c index e78507fe7..eef6feddd 100644 --- a/swad_search.c +++ b/swad_search.c @@ -700,7 +700,7 @@ static unsigned Sch_SearchCoursesInDB (const char *RangeQuery) if (Sch_BuildSearchQuery (SearchQuery,"courses.FullName",NULL,NULL)) { /***** Query database and list courses found *****/ - sprintf (Query,"SELECT degrees.DegCod,courses.CrsCod,degrees.Logo,degrees.ShortName,degrees.FullName," + sprintf (Query,"SELECT degrees.DegCod,courses.CrsCod,degrees.ShortName,degrees.FullName," "courses.Year,courses.Semester,courses.FullName,centres.ShortName" " FROM courses,degrees,centres,institutions,countries" " WHERE %s" diff --git a/swad_statistic.c b/swad_statistic.c index 9d2350a01..8a5759cac 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -3486,7 +3486,7 @@ static void Sta_WriteDegree (long DegCod) fprintf (Gbl.F.Out,"%s\">" "", Deg.WWW,Deg.FullName); - Deg_DrawDegreeLogo (Deg.Logo,Deg.ShortName,16,"vertical-align:top;"); + Deg_DrawDegreeLogo (Deg.DegCod,Deg.ShortName,16,"vertical-align:top;"); fprintf (Gbl.F.Out," %s ", Deg.ShortName); }