diff --git a/Makefile b/Makefile index 8420385f..71b046bb 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,7 @@ OBJS = swad_account.o swad_action.o swad_agenda.o swad_alert.o \ swad_game.o swad_global.o swad_group.o \ swad_help.o swad_hierarchy.o swad_holiday.o swad_HTML.o \ swad_icon.o swad_ID.o swad_indicator.o swad_info.o swad_institution.o \ + swad_institution_config.o \ swad_language.o swad_layout.o swad_link.o swad_log.o swad_logo.o \ swad_mail.o swad_main.o swad_map.o swad_mark.o swad_match.o \ swad_match_result.o swad_media.o swad_menu.o swad_message.o swad_MFU.o \ diff --git a/swad_action.c b/swad_action.c index 6ff7070c..e46a9db0 100644 --- a/swad_action.c +++ b/swad_action.c @@ -55,6 +55,7 @@ #include "swad_global.h" #include "swad_ID.h" #include "swad_indicator.h" +#include "swad_institution_config.h" #include "swad_language.h" #include "swad_log.h" #include "swad_mail.h" @@ -1780,21 +1781,21 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = // TabIns ****************************************************************** // Actions in menu: - [ActSeeInsInf ] = {1153, 0,TabIns,ActSeeInsInf , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Ins_ShowConfiguration ,"info" }, + [ActSeeInsInf ] = {1153, 0,TabIns,ActSeeInsInf , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,InsCfg_ShowConfiguration ,"info" }, [ActSeeCtr ] = { 676, 1,TabIns,ActSeeCtr , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Ctr_ShowCtrsOfCurrentIns ,"building" }, [ActSeePlc ] = { 703, 2,TabIns,ActSeePlc , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Plc_SeePlaces ,"map-marker-alt" }, [ActSeeDpt ] = { 675, 3,TabIns,ActSeeDpt , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Dpt_SeeDepts ,"users" }, [ActSeeHld ] = { 707, 4,TabIns,ActSeeHld , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Hld_SeeHolidays ,"calendar-day" }, // Actions not in menu: - [ActPrnInsInf ] = {1154,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,Ins_PrintConfiguration ,NULL}, - [ActChgInsCtyCfg ] = {1590,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Ins_ChangeInsCtyInConfig ,Ins_ContEditAfterChgInsInConfig,NULL}, - [ActRenInsShoCfg ] = {1592,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Ins_RenameInsShortInConfig ,Ins_ContEditAfterChgInsInConfig,NULL}, - [ActRenInsFulCfg ] = {1591,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Ins_RenameInsFullInConfig ,Ins_ContEditAfterChgInsInConfig,NULL}, - [ActChgInsWWWCfg ] = {1593,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x300, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Ins_ChangeInsWWWInConfig ,NULL}, - [ActReqInsLog ] = {1245,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x300, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Ins_RequestLogo ,NULL}, - [ActRecInsLog ] = { 699,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x300, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,Ins_ReceiveLogo ,Ins_ShowConfiguration ,NULL}, - [ActRemInsLog ] = {1341,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x300, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,Ins_RemoveLogo ,Ins_ShowConfiguration ,NULL}, + [ActPrnInsInf ] = {1154,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x3C7, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,InsCfg_PrintConfiguration ,NULL}, + [ActChgInsCtyCfg ] = {1590,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,InsCfg_ChangeInsCty ,InsCfg_ContEditAfterChgIns ,NULL}, + [ActRenInsShoCfg ] = {1592,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,InsCfg_RenameInsShort ,InsCfg_ContEditAfterChgIns ,NULL}, + [ActRenInsFulCfg ] = {1591,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x200, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,InsCfg_RenameInsFull ,InsCfg_ContEditAfterChgIns ,NULL}, + [ActChgInsWWWCfg ] = {1593,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x300, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,InsCfg_ChangeInsWWW ,NULL}, + [ActReqInsLog ] = {1245,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x300, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,InsCfg_RequestLogo ,NULL}, + [ActRecInsLog ] = { 699,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x300, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,InsCfg_ReceiveLogo ,InsCfg_ShowConfiguration ,NULL}, + [ActRemInsLog ] = {1341,-1,TabUnk,ActSeeInsInf , 0, 0, 0, 0,0x300, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,InsCfg_RemoveLogo ,InsCfg_ShowConfiguration ,NULL}, [ActEdiCtr ] = { 681,-1,TabUnk,ActSeeCtr , 0, 0, 0, 0,0x3C6, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Ctr_EditCentres ,NULL}, [ActReqCtr ] = {1208,-1,TabUnk,ActSeeCtr , 0, 0, 0, 0,0x3C6, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Ctr_RecFormReqCtr ,Ctr_ContEditAfterChgCtr ,NULL}, @@ -1836,21 +1837,21 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActSeeCla ] = {1744, 2,TabCtr,ActSeeCla , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Cla_SeeClassrooms ,"classroom" }, // Actions not in menu: - [ActPrnCtrInf ] = {1152,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,CtrCfg_PrintConfiguration ,NULL}, - [ActChgCtrInsCfg ] = {1589,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x200, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CtrCfg_ChangeCtrInsInConfig ,CtrCfg_ContEditAfterChgCtrInConfig,NULL}, - [ActRenCtrShoCfg ] = {1595,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x300, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CtrCfg_RenameCentreShortInConfig ,CtrCfg_ContEditAfterChgCtrInConfig,NULL}, - [ActRenCtrFulCfg ] = {1594,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x300, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CtrCfg_RenameCentreFullInConfig ,CtrCfg_ContEditAfterChgCtrInConfig,NULL}, - [ActChgCtrPlcCfg ] = {1648,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrPlcInConfig ,NULL}, - [ActChgCtrLatCfg ] = {1815,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrLatitudeInConfig ,NULL}, - [ActChgCtrLgtCfg ] = {1816,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrLongitudeInConfig ,NULL}, - [ActChgCtrAltCfg ] = {1817,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrAltitudeInConfig ,NULL}, - [ActChgCtrWWWCfg ] = {1596,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrWWWInConfig ,NULL}, + [ActPrnCtrInf ] = {1152,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,CtrCfg_PrintConfiguration ,NULL}, + [ActChgCtrInsCfg ] = {1589,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x200, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CtrCfg_ChangeCtrIns ,CtrCfg_ContEditAfterChgCtr ,NULL}, + [ActRenCtrShoCfg ] = {1595,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x300, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CtrCfg_RenameCentreShort ,CtrCfg_ContEditAfterChgCtr ,NULL}, + [ActRenCtrFulCfg ] = {1594,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x300, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CtrCfg_RenameCentreFull ,CtrCfg_ContEditAfterChgCtr ,NULL}, + [ActChgCtrPlcCfg ] = {1648,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrPlc ,NULL}, + [ActChgCtrLatCfg ] = {1815,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrLatitude ,NULL}, + [ActChgCtrLgtCfg ] = {1816,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrLongitude ,NULL}, + [ActChgCtrAltCfg ] = {1817,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrAltitude ,NULL}, + [ActChgCtrWWWCfg ] = {1596,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrWWW ,NULL}, [ActReqCtrLog ] = {1244,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_RequestLogo ,NULL}, - [ActRecCtrLog ] = {1051,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,CtrCfg_ReceiveLogo ,CtrCfg_ShowConfiguration ,NULL}, - [ActRemCtrLog ] = {1342,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,CtrCfg_RemoveLogo ,CtrCfg_ShowConfiguration ,NULL}, + [ActRecCtrLog ] = {1051,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,CtrCfg_ReceiveLogo ,CtrCfg_ShowConfiguration ,NULL}, + [ActRemCtrLog ] = {1342,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,CtrCfg_RemoveLogo ,CtrCfg_ShowConfiguration ,NULL}, [ActReqCtrPho ] = {1160,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_RequestPhoto ,NULL}, [ActRecCtrPho ] = {1161,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,NULL ,CtrCfg_ReceivePhoto ,NULL}, - [ActChgCtrPhoAtt ] = {1159,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrPhotoAttribution ,NULL}, + [ActChgCtrPhoAtt ] = {1159,-1,TabUnk,ActSeeCtrInf , 0, 0, 0,0x380, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,CtrCfg_ChangeCtrPhotoAttribution,NULL}, [ActSeeDegTyp ] = {1013,-1,TabUnk,ActSeeDeg , 0, 0, 0,0x3C7, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,DT_SeeDegreeTypesInDegTab ,NULL}, [ActEdiDegTyp ] = { 573,-1,TabUnk,ActSeeDeg , 0, 0, 0,0x200, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,DT_EditDegreeTypes ,NULL}, @@ -1878,18 +1879,18 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = // TabDeg ****************************************************************** // Actions in menu: - [ActSeeDegInf ] = {1149, 0,TabDeg,ActSeeDegInf , 0, 0,0x3C7, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,DegCfg_ShowConfiguration ,"info" }, + [ActSeeDegInf ] = {1149, 0,TabDeg,ActSeeDegInf , 0, 0,0x3C7, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,DegCfg_ShowConfiguration ,"info" }, [ActSeeCrs ] = {1009, 1,TabDeg,ActSeeCrs , 0, 0,0x3C7, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Crs_ShowCrssOfCurrentDeg ,"list-ol" }, // Actions not in menu: - [ActPrnDegInf ] = {1150,-1,TabUnk,ActSeeDegInf , 0, 0,0x3C7, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,DegCfg_PrintConfiguration ,NULL}, - [ActChgDegCtrCfg ] = {1588,-1,TabUnk,ActSeeDegInf , 0, 0,0x300, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,DegCfg_ChangeDegCtrInConfig ,DegCfg_ContEditAfterChgDegInConfig,NULL}, - [ActRenDegShoCfg ] = {1598,-1,TabUnk,ActSeeDegInf , 0, 0,0x380, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,DegCfg_RenameDegreeShortInConfig ,DegCfg_ContEditAfterChgDegInConfig,NULL}, - [ActRenDegFulCfg ] = {1597,-1,TabUnk,ActSeeDegInf , 0, 0,0x380, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,DegCfg_RenameDegreeFullInConfig ,DegCfg_ContEditAfterChgDegInConfig,NULL}, - [ActChgDegWWWCfg ] = {1599,-1,TabUnk,ActSeeDegInf , 0, 0,0x3C0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,DegCfg_ChangeDegWWWInConfig ,NULL}, + [ActPrnDegInf ] = {1150,-1,TabUnk,ActSeeDegInf , 0, 0,0x3C7, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,DegCfg_PrintConfiguration ,NULL}, + [ActChgDegCtrCfg ] = {1588,-1,TabUnk,ActSeeDegInf , 0, 0,0x300, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,DegCfg_ChangeDegCtr ,DegCfg_ContEditAfterChgDeg ,NULL}, + [ActRenDegShoCfg ] = {1598,-1,TabUnk,ActSeeDegInf , 0, 0,0x380, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,DegCfg_RenameDegreeShort ,DegCfg_ContEditAfterChgDeg ,NULL}, + [ActRenDegFulCfg ] = {1597,-1,TabUnk,ActSeeDegInf , 0, 0,0x380, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,DegCfg_RenameDegreeFull ,DegCfg_ContEditAfterChgDeg ,NULL}, + [ActChgDegWWWCfg ] = {1599,-1,TabUnk,ActSeeDegInf , 0, 0,0x3C0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,DegCfg_ChangeDegWWW ,NULL}, [ActReqDegLog ] = {1246,-1,TabUnk,ActSeeDegInf , 0, 0,0x3C0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Deg_RequestLogo ,NULL}, - [ActRecDegLog ] = { 553,-1,TabUnk,ActSeeDegInf , 0, 0,0x3C0, 0, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,Deg_ReceiveLogo ,DegCfg_ShowConfiguration ,NULL}, - [ActRemDegLog ] = {1343,-1,TabUnk,ActSeeDegInf , 0, 0,0x3C0, 0, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,Deg_RemoveLogo ,DegCfg_ShowConfiguration ,NULL}, + [ActRecDegLog ] = { 553,-1,TabUnk,ActSeeDegInf , 0, 0,0x3C0, 0, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,Deg_ReceiveLogo ,DegCfg_ShowConfiguration ,NULL}, + [ActRemDegLog ] = {1343,-1,TabUnk,ActSeeDegInf , 0, 0,0x3C0, 0, 0, 0, 0,Act_CONT_DATA,Act_BRW_1ST_TAB,Deg_RemoveLogo ,DegCfg_ShowConfiguration ,NULL}, [ActEdiCrs ] = { 555,-1,TabUnk,ActSeeCrs , 0, 0,0x3C6, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Crs_EditCourses ,NULL}, [ActReqCrs ] = {1053,-1,TabUnk,ActSeeCrs , 0, 0,0x3C6, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,Crs_RecFormReqCrs ,Crs_ContEditAfterChgCrs ,NULL}, @@ -1912,12 +1913,12 @@ const struct Act_Actions Act_Actions[Act_NUM_ACTIONS] = [ActSeeCrsTT ] = { 25, 6,TabCrs,ActSeeCrsTT ,0x3F8,0x3C7, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,TT_ShowClassTimeTable ,"clock" }, // Actions not in menu: - [ActPrnCrsInf ] = {1028,-1,TabUnk,ActSeeCrsInf ,0x3F8,0x3C7, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,CrsCfg_PrintConfiguration ,NULL}, - [ActChgCrsDegCfg ] = {1587,-1,TabUnk,ActSeeCrsInf ,0x380,0x380, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_ChangeCrsDegInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, - [ActRenCrsShoCfg ] = {1601,-1,TabUnk,ActSeeCrsInf ,0x3C0,0x3C0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_RenameCourseShortInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, - [ActRenCrsFulCfg ] = {1600,-1,TabUnk,ActSeeCrsInf ,0x3C0,0x3C0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_RenameCourseFullInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, - [ActChgInsCrsCodCfg ] = {1024,-1,TabUnk,ActSeeCrsInf ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_ChangeInsCrsCodInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, - [ActChgCrsYeaCfg ] = {1573,-1,TabUnk,ActSeeCrsInf ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_ChangeCrsYearInConfig ,CrsCfg_ContEditAfterChgCrsInConfig,NULL}, + [ActPrnCrsInf ] = {1028,-1,TabUnk,ActSeeCrsInf ,0x3F8,0x3C7, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_NEW_TAB,NULL ,CrsCfg_PrintConfiguration ,NULL}, + [ActChgCrsDegCfg ] = {1587,-1,TabUnk,ActSeeCrsInf ,0x380,0x380, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_ChangeCrsDeg ,CrsCfg_ContEditAfterChgCrs ,NULL}, + [ActRenCrsShoCfg ] = {1601,-1,TabUnk,ActSeeCrsInf ,0x3C0,0x3C0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_RenameCourseShort ,CrsCfg_ContEditAfterChgCrs ,NULL}, + [ActRenCrsFulCfg ] = {1600,-1,TabUnk,ActSeeCrsInf ,0x3C0,0x3C0, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_RenameCourseFull ,CrsCfg_ContEditAfterChgCrs ,NULL}, + [ActChgInsCrsCodCfg ] = {1024,-1,TabUnk,ActSeeCrsInf ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_ChangeInsCrsCod ,CrsCfg_ContEditAfterChgCrs ,NULL}, + [ActChgCrsYeaCfg ] = {1573,-1,TabUnk,ActSeeCrsInf ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,CrsCfg_ChangeCrsYear ,CrsCfg_ContEditAfterChgCrs ,NULL}, [ActEdiCrsInf ] = { 848,-1,TabUnk,ActSeeCrsInf ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Inf_FormsToSelSendInfo ,NULL}, [ActEdiTchGui ] = { 785,-1,TabUnk,ActSeeTchGui ,0x220,0x200, 0, 0, 0, 0, 0,Act_CONT_NORM,Act_BRW_1ST_TAB,NULL ,Inf_FormsToSelSendInfo ,NULL}, diff --git a/swad_centre_config.c b/swad_centre_config.c index 1dcda08a..e731ae31 100644 --- a/swad_centre_config.c +++ b/swad_centre_config.c @@ -1073,7 +1073,7 @@ void CtrCfg_ChangeCtrPhotoAttribution (void) /********************* Change the institution of a centre ********************/ /*****************************************************************************/ -void CtrCfg_ChangeCtrInsInConfig (void) +void CtrCfg_ChangeCtrIns (void) { extern const char *Txt_The_centre_X_already_exists; extern const char *Txt_The_centre_X_has_been_moved_to_the_institution_Y; @@ -1139,7 +1139,7 @@ static void CtrCfg_UpdateCtrInsDB (long CtrCod,long InsCod) /************************ Change the place of a centre ***********************/ /*****************************************************************************/ -void CtrCfg_ChangeCtrPlcInConfig (void) +void CtrCfg_ChangeCtrPlc (void) { extern const char *Txt_The_place_of_the_centre_has_changed; long NewPlcCod; @@ -1162,12 +1162,12 @@ void CtrCfg_ChangeCtrPlcInConfig (void) /*************** Change the name of a centre in configuration ****************/ /*****************************************************************************/ -void CtrCfg_RenameCentreShortInConfig (void) +void CtrCfg_RenameCentreShort (void) { Ctr_RenameCentre (&Gbl.Hierarchy.Ctr,Cns_SHRT_NAME); } -void CtrCfg_RenameCentreFullInConfig (void) +void CtrCfg_RenameCentreFull (void) { Ctr_RenameCentre (&Gbl.Hierarchy.Ctr,Cns_FULL_NAME); } @@ -1176,7 +1176,7 @@ void CtrCfg_RenameCentreFullInConfig (void) /********************** Change the latitude of a centre **********************/ /*****************************************************************************/ -void CtrCfg_ChangeCtrLatitudeInConfig (void) +void CtrCfg_ChangeCtrLatitude (void) { extern const char *Txt_The_new_latitude_is_X; char LatitudeStr[64]; @@ -1205,7 +1205,7 @@ void CtrCfg_ChangeCtrLatitudeInConfig (void) /********************** Change the longitude of a centre **********************/ /*****************************************************************************/ -void CtrCfg_ChangeCtrLongitudeInConfig (void) +void CtrCfg_ChangeCtrLongitude (void) { extern const char *Txt_The_new_longitude_is_X; char LongitudeStr[64]; @@ -1234,7 +1234,7 @@ void CtrCfg_ChangeCtrLongitudeInConfig (void) /********************** Change the latitude of a centre **********************/ /*****************************************************************************/ -void CtrCfg_ChangeCtrAltitudeInConfig (void) +void CtrCfg_ChangeCtrAltitude (void) { extern const char *Txt_The_new_altitude_is_X; char AltitudeStr[64]; @@ -1278,7 +1278,7 @@ static void CtrCfg_UpdateCtrCoordinateDB (long CtrCod, /************************* Change the URL of a centre ************************/ /*****************************************************************************/ -void CtrCfg_ChangeCtrWWWInConfig (void) +void CtrCfg_ChangeCtrWWW (void) { extern const char *Txt_The_new_web_address_is_X; char NewWWW[Cns_MAX_BYTES_WWW + 1]; @@ -1310,7 +1310,7 @@ void CtrCfg_ChangeCtrWWWInConfig (void) /** Show message of success after changing a centre in centre configuration **/ /*****************************************************************************/ -void CtrCfg_ContEditAfterChgCtrInConfig (void) +void CtrCfg_ContEditAfterChgCtr (void) { /***** Write error/success message *****/ Ale_ShowAlerts (NULL); diff --git a/swad_centre_config.h b/swad_centre_config.h index 4a16cac0..5aed6eb8 100644 --- a/swad_centre_config.h +++ b/swad_centre_config.h @@ -44,14 +44,14 @@ void CtrCfg_RemoveLogo (void); void CtrCfg_RequestPhoto (void); void CtrCfg_ReceivePhoto (void); void CtrCfg_ChangeCtrPhotoAttribution (void); -void CtrCfg_ChangeCtrInsInConfig (void); -void CtrCfg_RenameCentreShortInConfig (void); -void CtrCfg_RenameCentreFullInConfig (void); -void CtrCfg_ChangeCtrPlcInConfig (void); -void CtrCfg_ChangeCtrLatitudeInConfig (void); -void CtrCfg_ChangeCtrLongitudeInConfig (void); -void CtrCfg_ChangeCtrAltitudeInConfig (void); -void CtrCfg_ChangeCtrWWWInConfig (void); -void CtrCfg_ContEditAfterChgCtrInConfig (void); +void CtrCfg_ChangeCtrIns (void); +void CtrCfg_RenameCentreShort (void); +void CtrCfg_RenameCentreFull (void); +void CtrCfg_ChangeCtrPlc (void); +void CtrCfg_ChangeCtrLatitude (void); +void CtrCfg_ChangeCtrLongitude (void); +void CtrCfg_ChangeCtrAltitude (void); +void CtrCfg_ChangeCtrWWW (void); +void CtrCfg_ContEditAfterChgCtr (void); #endif diff --git a/swad_changelog.h b/swad_changelog.h index 3127c38c..1f5c9297 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -502,6 +502,7 @@ ps2pdf source.ps destination.pdf Version 19.10x: Dec 29, 2019 Map in country information. (? lines) Version 19.10x: Dec 29, 2019 Map in institution information. (? lines) + Version 19.105: Dec 29, 2019 New module swad_institution_config for insitution configuration. (249614 lines) Version 19.104.2: Dec 29, 2019 Code refactoring in degree configuration. (249541 lines) Version 19.104.1: Dec 29, 2019 Code refactoring in course configuration. (249536 lines) Version 19.104: Dec 29, 2019 New module swad_centre_config for centre configuration. (249534 lines) diff --git a/swad_course_config.c b/swad_course_config.c index 43376978..1cd7dc83 100644 --- a/swad_course_config.c +++ b/swad_course_config.c @@ -475,7 +475,7 @@ static void CrsCfg_Indicators (void) /***************** Change the degree of the current course *******************/ /*****************************************************************************/ -void CrsCfg_ChangeCrsDegInConfig (void) +void CrsCfg_ChangeCrsDeg (void) { extern const char *Txt_In_the_year_X_of_the_degree_Y_already_existed_a_course_with_the_name_Z; extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; @@ -541,12 +541,12 @@ static void CrsCfg_UpdateCrsDegDB (long CrsCod,long DegCod) /*************** Change the name of a course in configuration ****************/ /*****************************************************************************/ -void CrsCfg_RenameCourseShortInConfig (void) +void CrsCfg_RenameCourseShort (void) { Crs_RenameCourse (&Gbl.Hierarchy.Crs,Cns_SHRT_NAME); } -void CrsCfg_RenameCourseFullInConfig (void) +void CrsCfg_RenameCourseFull (void) { Crs_RenameCourse (&Gbl.Hierarchy.Crs,Cns_FULL_NAME); } @@ -555,7 +555,7 @@ void CrsCfg_RenameCourseFullInConfig (void) /*********** Change the year of a course in course configuration *************/ /*****************************************************************************/ -void CrsCfg_ChangeCrsYearInConfig (void) +void CrsCfg_ChangeCrsYear (void) { extern const char *Txt_The_course_X_already_exists_in_year_Y; extern const char *Txt_YEAR_OF_DEGREE[1 + Deg_MAX_YEARS_PER_DEGREE]; @@ -604,7 +604,7 @@ void CrsCfg_ChangeCrsYearInConfig (void) /***** Change the institutional code of a course in course configuration *****/ /*****************************************************************************/ -void CrsCfg_ChangeInsCrsCodInConfig (void) +void CrsCfg_ChangeInsCrsCod (void) { extern const char *Txt_The_institutional_code_of_the_course_X_has_changed_to_Y; extern const char *Txt_The_institutional_code_of_the_course_X_has_not_changed; @@ -633,7 +633,7 @@ void CrsCfg_ChangeInsCrsCodInConfig (void) /** Show message of success after changing a course in course configuration **/ /*****************************************************************************/ -void CrsCfg_ContEditAfterChgCrsInConfig (void) +void CrsCfg_ContEditAfterChgCrs (void) { /***** Write error/success message *****/ Ale_ShowAlerts (NULL); diff --git a/swad_course_config.h b/swad_course_config.h index 7022fe8a..7d325086 100644 --- a/swad_course_config.h +++ b/swad_course_config.h @@ -44,11 +44,11 @@ void CrsCfg_Configuration (bool PrintView); void CrsCfg_PrintConfiguration (void); -void CrsCfg_ChangeCrsDegInConfig (void); -void CrsCfg_RenameCourseShortInConfig (void); -void CrsCfg_RenameCourseFullInConfig (void); -void CrsCfg_ChangeCrsYearInConfig (void); -void CrsCfg_ChangeInsCrsCodInConfig (void); -void CrsCfg_ContEditAfterChgCrsInConfig (void); +void CrsCfg_ChangeCrsDeg (void); +void CrsCfg_RenameCourseShort (void); +void CrsCfg_RenameCourseFull (void); +void CrsCfg_ChangeCrsYear (void); +void CrsCfg_ChangeInsCrsCod (void); +void CrsCfg_ContEditAfterChgCrs (void); #endif diff --git a/swad_degree_config.c b/swad_degree_config.c index 0669b294..aeffb5a3 100644 --- a/swad_degree_config.c +++ b/swad_degree_config.c @@ -376,7 +376,7 @@ static void DegCfg_NumUsrsInCrssOfDeg (Rol_Role_t Role) /************************ Change the centre of a degree **********************/ /*****************************************************************************/ -void DegCfg_ChangeDegCtrInConfig (void) +void DegCfg_ChangeDegCtr (void) { extern const char *Txt_The_degree_X_already_exists; extern const char *Txt_The_degree_X_has_been_moved_to_the_centre_Y; @@ -435,12 +435,12 @@ static void DegCfg_UpdateDegCtrDB (long DegCod,long CtrCod) /*************** Change the name of a degree in configuration ****************/ /*****************************************************************************/ -void DegCfg_RenameDegreeShortInConfig (void) +void DegCfg_RenameDegreeShort (void) { Deg_RenameDegree (&Gbl.Hierarchy.Deg,Cns_SHRT_NAME); } -void DegCfg_RenameDegreeFullInConfig (void) +void DegCfg_RenameDegreeFull (void) { Deg_RenameDegree (&Gbl.Hierarchy.Deg,Cns_FULL_NAME); } @@ -449,7 +449,7 @@ void DegCfg_RenameDegreeFullInConfig (void) /************************* Change the WWW of a degree ************************/ /*****************************************************************************/ -void DegCfg_ChangeDegWWWInConfig (void) +void DegCfg_ChangeDegWWW (void) { extern const char *Txt_The_new_web_address_is_X; char NewWWW[Cns_MAX_BYTES_WWW + 1]; @@ -481,7 +481,7 @@ void DegCfg_ChangeDegWWWInConfig (void) /** Show message of success after changing a degree in degree configuration **/ /*****************************************************************************/ -void DegCfg_ContEditAfterChgDegInConfig (void) +void DegCfg_ContEditAfterChgDeg (void) { /***** Write success / warning message *****/ Ale_ShowAlerts (NULL); diff --git a/swad_degree_config.h b/swad_degree_config.h index f13cce5a..a873de85 100644 --- a/swad_degree_config.h +++ b/swad_degree_config.h @@ -42,10 +42,10 @@ void DegCfg_ShowConfiguration (void); void DegCfg_PrintConfiguration (void); -void DegCfg_ChangeDegCtrInConfig (void); -void DegCfg_RenameDegreeShortInConfig (void); -void DegCfg_RenameDegreeFullInConfig (void); -void DegCfg_ChangeDegWWWInConfig (void); -void DegCfg_ContEditAfterChgDegInConfig (void); +void DegCfg_ChangeDegCtr (void); +void DegCfg_RenameDegreeShort (void); +void DegCfg_RenameDegreeFull (void); +void DegCfg_ChangeDegWWW (void); +void DegCfg_ContEditAfterChgDeg (void); #endif diff --git a/swad_institution.c b/swad_institution.c index ec37d185..db5f6afa 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -25,24 +25,16 @@ /********************************* Headers ***********************************/ /*****************************************************************************/ +#include // For boolean type #include // For NULL -#include // For calloc #include // For string functions -#include "swad_box.h" -#include "swad_config.h" -#include "swad_constant.h" #include "swad_database.h" #include "swad_form.h" #include "swad_global.h" -#include "swad_help.h" -#include "swad_hierarchy.h" #include "swad_HTML.h" #include "swad_institution.h" -#include "swad_language.h" #include "swad_logo.h" -#include "swad_parameter.h" -#include "swad_user.h" /*****************************************************************************/ /************** External global variables from others modules ****************/ @@ -68,24 +60,6 @@ static struct Instit *Ins_EditingIns = NULL; // Static variable to keep the inst /***************************** Private prototypes ****************************/ /*****************************************************************************/ -static void Ins_Configuration (bool PrintView); -static void Ins_PutIconsToPrintAndUpload (void); -static void Ins_ConfigTitle (bool PutLink); -static bool Ins_GetIfMapIsAvailable (void); -static void Ins_ConfigMap (void); -static void Ins_ConfigCountry (bool PrintView,bool PutForm); -static void Ins_ConfigFullName (bool PutForm); -static void Ins_ConfigShrtName (bool PutForm); -static void Ins_ConfigWWW (bool PrintView,bool PutForm); -static void Ins_ConfigShortcut (bool PrintView); -static void Ins_ConfigQR (void); -static void Ins_ConfigNumUsrs (void); -static void Ins_ConfigNumCtrs (void); -static void Ins_ConfigNumDegs (void); -static void Ins_ConfigNumCrss (void); -static void Ins_ConfigNumDpts (void); -static void Ins_ShowNumUsrsInCrssOfIns (Rol_Role_t Role); - static void Ins_ListInstitutions (void); static bool Ins_CheckIfICanCreateInstitutions (void); static void Ins_PutIconsListingInstitutions (void); @@ -109,15 +83,8 @@ static Ins_Status_t Ins_GetStatusBitsFromStatusTxt (Ins_StatusTxt_t StatusTxt); static void Ins_PutParamOtherInsCod (long InsCod); static long Ins_GetParamOtherInsCod (void); -static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFullName); -static bool Ins_CheckIfInsNameExistsInCty (const char *FieldName, - const char *Name, - long InsCod, - long CtyCod); static void Ins_UpdateInsNameDB (long InsCod,const char *FieldName,const char *NewInsName); -static void Ins_UpdateInsCtyDB (long InsCod,long CtyCod); -static void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]); static void Ins_ShowAlertAndButtonToGoToIns (void); static void Ins_PutParamGoToIns (void); @@ -289,500 +256,6 @@ void Ins_DrawInstitutionLogoAndNameWithLink (struct Instit *Ins,Act_Action_t Act Frm_EndForm (); } -/*****************************************************************************/ -/*************** Show information of the current institution *****************/ -/*****************************************************************************/ - -void Ins_ShowConfiguration (void) - { - Ins_Configuration (false); - - /***** Show help to enrol me *****/ - Hlp_ShowHelpWhatWouldYouLikeToDo (); - } - -/*****************************************************************************/ -/*************** Print information of the current institution ****************/ -/*****************************************************************************/ - -void Ins_PrintConfiguration (void) - { - Ins_Configuration (true); - } - -/*****************************************************************************/ -/***************** Information of the current institution ********************/ -/*****************************************************************************/ - -static void Ins_Configuration (bool PrintView) - { - extern const char *Hlp_INSTITUTION_Information; - bool PutLink; - bool PutFormCty; - bool PutFormName; - bool PutFormWWW; - bool MapIsAvailable; - - /***** Trivial check *****/ - if (Gbl.Hierarchy.Ins.InsCod <= 0) // No institution selected - return; - - /***** Initializations *****/ - PutLink = !PrintView && Gbl.Hierarchy.Ins.WWW[0]; - PutFormCty = - PutFormName = !PrintView && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; - PutFormWWW = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; - - /***** Begin box *****/ - if (PrintView) - Box_BoxBegin (NULL,NULL,NULL, - NULL,Box_NOT_CLOSABLE); - else - Box_BoxBegin (NULL,NULL,Ins_PutIconsToPrintAndUpload, - Hlp_INSTITUTION_Information,Box_NOT_CLOSABLE); - - - /***** Title *****/ - Ins_ConfigTitle (PutLink); - - /**************************** Left part ***********************************/ - HTM_DIV_Begin ("class=\"HIE_CFG_LEFT\""); - - /***** Begin table *****/ - HTM_TABLE_BeginWidePadding (2); - - /***** Country *****/ - Ins_ConfigCountry (PrintView,PutFormCty); - - /***** Institution name *****/ - Ins_ConfigFullName (PutFormName); - Ins_ConfigShrtName (PutFormName); - - /***** Institution WWW *****/ - Ins_ConfigWWW (PrintView,PutFormWWW); - - /***** Shortcut to the institution *****/ - Ins_ConfigShortcut (PrintView); - - if (PrintView) - /***** QR code with link to the institution *****/ - Ins_ConfigQR (); - else - { - /***** Number of users who claim to belong to this institution, - number of centres, - number of degrees, - number of courses, - number of departments *****/ - Ins_ConfigNumUsrs (); - Ins_ConfigNumCtrs (); - Ins_ConfigNumDegs (); - Ins_ConfigNumCrss (); - Ins_ConfigNumDpts (); - - /***** Number of users in courses of this institution *****/ - Ins_ShowNumUsrsInCrssOfIns (Rol_TCH); - Ins_ShowNumUsrsInCrssOfIns (Rol_NET); - Ins_ShowNumUsrsInCrssOfIns (Rol_STD); - Ins_ShowNumUsrsInCrssOfIns (Rol_UNK); - } - - /***** End table *****/ - HTM_TABLE_End (); - - /***** End of left part *****/ - HTM_DIV_End (); - - /**************************** Right part **********************************/ - /***** Check map *****/ - MapIsAvailable = Ins_GetIfMapIsAvailable (); - - if (MapIsAvailable) - { - HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT\""); - - /***** Institution map *****/ - Ins_ConfigMap (); - - HTM_DIV_End (); - } - - /***** End box *****/ - Box_BoxEnd (); - } - -/*****************************************************************************/ -/********* Put contextual icons in configuration of an institution ***********/ -/*****************************************************************************/ - -static void Ins_PutIconsToPrintAndUpload (void) - { - /***** Icon to print info about institution *****/ - Ico_PutContextualIconToPrint (ActPrnInsInf,NULL); - - if (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) - /***** Icon to upload logo of institution *****/ - Lgo_PutIconToChangeLogo (Hie_INS); - - /***** Put icon to view places *****/ - Plc_PutIconToViewPlaces (); - } - -/*****************************************************************************/ -/***************** Show title in institution configuration *******************/ -/*****************************************************************************/ - -static void Ins_ConfigTitle (bool PutLink) - { - Hie_ConfigTitle (PutLink, - Hie_INS, // Logo scope - Gbl.Hierarchy.Ins.InsCod, // Logo code - Gbl.Hierarchy.Ins.ShrtName, // Logo short name - Gbl.Hierarchy.Ins.FullName, // Logo full name - Gbl.Hierarchy.Ins.WWW, // Logo www - Gbl.Hierarchy.Ins.FullName); // Text full name - } - -/*****************************************************************************/ -/******************** Check if centre map should be shown ********************/ -/*****************************************************************************/ - -// TODO: Change code!!!! - -static bool Ins_GetIfMapIsAvailable (void) - { - return true; - - /***** Coordinates 0, 0 means not set ==> don't show map *****/ - /* - return (bool) (Gbl.Hierarchy.Ctr.Coord.Latitude || - Gbl.Hierarchy.Ctr.Coord.Longitude); - */ - } - -/*****************************************************************************/ -/****************************** Draw centre map ******************************/ -/*****************************************************************************/ - -// TODO: Change code!!!! - -static void Ins_ConfigMap (void) - { - /* https://leafletjs.com/examples/quick-start/ */ - /***** Leaflet CSS *****/ - HTM_Txt (""); - - /***** Leaflet script *****/ - /* Put this AFTER Leaflet's CSS */ - HTM_Txt (""); - - /***** Container for the map *****/ - HTM_DIV_Begin ("id=\"centre_mapid\""); - HTM_DIV_End (); - - /***** Script to draw the map *****/ - HTM_SCRIPT_Begin (NULL,NULL); - Str_SetDecimalPointToUS (); // To write the decimal point as a dot - - /* Let's create a map of the center of London with pretty Mapbox Streets tiles */ - HTM_TxtF ("\tvar mymap = L.map('centre_mapid').setView([%lg, %lg], 16);\n", - Gbl.Hierarchy.Ctr.Coord.Latitude, - Gbl.Hierarchy.Ctr.Coord.Longitude); - - /* Next we'll add a tile layer to add to our map, - in this case it's a Mapbox Streets tile layer. - Creating a tile layer usually involves - setting the URL template for the tile images, - the attribution text and the maximum zoom level of the layer. - In this example we'll use the mapbox/streets-v11 tiles - from Mapbox's Static Tiles API - (in order to use tiles from Mapbox, - you must also request an access token).*/ - HTM_Txt ("\tL.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {" - "attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox'," - "maxZoom: 20," - "id: 'mapbox/streets-v11'," - "accessToken: 'pk.eyJ1IjoiYWNhbmFzIiwiYSI6ImNrNGFoNXFxOTAzdHozcnA4d3Y0M3BwOGkifQ.uSg754Lv2iZEJg0W2pjiOQ'" - "}).addTo(mymap);\n"); - - /* Marker */ - HTM_TxtF ("\tvar marker = L.marker([%lg, %lg]).addTo(mymap);", - Gbl.Hierarchy.Ctr.Coord.Latitude, - Gbl.Hierarchy.Ctr.Coord.Longitude); - - HTM_TxtF ("\tmarker.bindPopup(\"%s
%s\").openPopup();", - Gbl.Hierarchy.Ctr.ShrtName, - Gbl.Hierarchy.Ins.ShrtName); - - Str_SetDecimalPointToLocal (); // Return to local system - HTM_SCRIPT_End (); - } - -/*****************************************************************************/ -/***************** Show country in institution configuration *****************/ -/*****************************************************************************/ - -static void Ins_ConfigCountry (bool PrintView,bool PutForm) - { - extern const char *Txt_Country; - extern const char *Txt_Go_to_X; - unsigned NumCty; - - /***** Country *****/ - HTM_TR_Begin (NULL); - - /* Label */ - Frm_LabelColumn ("RT",PutForm ? "OthCtyCod" : - NULL, - Txt_Country); - - /* Data */ - HTM_TD_Begin ("class=\"DAT LB\""); - if (PutForm) - { - /* Get list of countries */ - Cty_GetListCountries (Cty_GET_BASIC_DATA); - - /* Put form to select country */ - Frm_StartForm (ActChgInsCtyCfg); - HTM_SELECT_Begin (true, - "id=\"OthCtyCod\" name=\"OthCtyCod\"" - " class=\"INPUT_SHORT_NAME\""); - for (NumCty = 0; - NumCty < Gbl.Hierarchy.Sys.Ctys.Num; - NumCty++) - HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod, - Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod == Gbl.Hierarchy.Cty.CtyCod,false, - "%s",Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]); - HTM_SELECT_End (); - Frm_EndForm (); - - /* Free list of countries */ - Cty_FreeListCountries (); - } - else // I can not move institution to another country - { - if (!PrintView) - { - Frm_StartFormGoTo (ActSeeCtyInf); - Cty_PutParamCtyCod (Gbl.Hierarchy.Cty.CtyCod); - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Go_to_X, - Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]); - HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK LT DAT",NULL); - } - Cty_DrawCountryMap (&Gbl.Hierarchy.Cty,"COUNTRY_MAP_TINY"); - HTM_NBSP (); - HTM_Txt (Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]); - if (!PrintView) - { - HTM_BUTTON_End (); - Frm_EndForm (); - } - } - HTM_TD_End (); - - HTM_TR_End (); - } - -/*****************************************************************************/ -/********* Show institution full name in institution configuration ***********/ -/*****************************************************************************/ - -static void Ins_ConfigFullName (bool PutForm) - { - extern const char *Txt_Institution; - - Hie_ConfigFullName (PutForm,Txt_Institution,ActRenInsFulCfg, - Gbl.Hierarchy.Ins.FullName); - } - -/*****************************************************************************/ -/********* Show institution short name in institution configuration **********/ -/*****************************************************************************/ - -static void Ins_ConfigShrtName (bool PutForm) - { - Hie_ConfigShrtName (PutForm,ActRenInsShoCfg,Gbl.Hierarchy.Ins.ShrtName); - } - -/*****************************************************************************/ -/************ Show institution WWW in institution configuration **************/ -/*****************************************************************************/ - -static void Ins_ConfigWWW (bool PrintView,bool PutForm) - { - Hie_ConfigWWW (PrintView,PutForm,ActChgInsWWWCfg,Gbl.Hierarchy.Ins.WWW); - } - -/*****************************************************************************/ -/********** Show institution shortcut in institution configuration ***********/ -/*****************************************************************************/ - -static void Ins_ConfigShortcut (bool PrintView) - { - Hie_ConfigShortcut (PrintView,"ins",Gbl.Hierarchy.Ins.InsCod); - } - -/*****************************************************************************/ -/************* Show institution QR in institution configuration **************/ -/*****************************************************************************/ - -static void Ins_ConfigQR (void) - { - Hie_ConfigQR ("ins",Gbl.Hierarchy.Ins.InsCod); - } - -/*****************************************************************************/ -/** Show number of users who claim to belong to instit. in instit. config. ***/ -/*****************************************************************************/ - -static void Ins_ConfigNumUsrs (void) - { - extern const char *Txt_Users_of_the_institution; - - /***** Number of users *****/ - HTM_TR_Begin (NULL); - - /* Label */ - Frm_LabelColumn ("RT",NULL,Txt_Users_of_the_institution); - - /* Data */ - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToIns (Gbl.Hierarchy.Ins.InsCod)); - HTM_TD_End (); - - HTM_TR_End (); - } - -/*****************************************************************************/ -/*********** Show number of centres in institution configuration *************/ -/*****************************************************************************/ - -static void Ins_ConfigNumCtrs (void) - { - extern const char *Txt_Centres; - extern const char *Txt_Centres_of_INSTITUTION_X; - - /***** Number of centres *****/ - HTM_TR_Begin (NULL); - - /* Label */ - Frm_LabelColumn ("RT",NULL,Txt_Centres); - - /* Data */ - HTM_TD_Begin ("class=\"LB\""); - Frm_StartFormGoTo (ActSeeCtr); - Ins_PutParamInsCod (Gbl.Hierarchy.Ins.InsCod); - snprintf (Gbl.Title,sizeof (Gbl.Title), - Txt_Centres_of_INSTITUTION_X, - Gbl.Hierarchy.Ins.ShrtName); - HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK DAT",NULL); - HTM_Unsigned (Ctr_GetNumCtrsInIns (Gbl.Hierarchy.Ins.InsCod)); - HTM_BUTTON_End (); - Frm_EndForm (); - HTM_TD_End (); - - HTM_TR_End (); - } - -/*****************************************************************************/ -/*********** Show number of degrees in institution configuration *************/ -/*****************************************************************************/ - -static void Ins_ConfigNumDegs (void) - { - extern const char *Txt_Degrees; - - /***** Number of degrees *****/ - HTM_TR_Begin (NULL); - - /* Label */ - Frm_LabelColumn ("RT",NULL,Txt_Degrees); - - /* Data */ - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (Deg_GetNumDegsInIns (Gbl.Hierarchy.Ins.InsCod)); - HTM_TD_End (); - - HTM_TR_End (); - } - -/*****************************************************************************/ -/************ Show number of courses in institution configuration ************/ -/*****************************************************************************/ - -static void Ins_ConfigNumCrss (void) - { - extern const char *Txt_Courses; - - /***** Number of courses *****/ - HTM_TR_Begin (NULL); - - /* Label */ - Frm_LabelColumn ("RT",NULL,Txt_Courses); - - /* Data */ - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (Crs_GetNumCrssInIns (Gbl.Hierarchy.Ins.InsCod)); - HTM_TD_End (); - - HTM_TR_End (); - } - -/*****************************************************************************/ -/********** Show number of departments in institution configuration **********/ -/*****************************************************************************/ - -static void Ins_ConfigNumDpts (void) - { - extern const char *Txt_Departments; - - /***** Number of departments *****/ - HTM_TR_Begin (NULL); - - /* Label */ - Frm_LabelColumn ("RT",NULL,Txt_Departments); - - /* Data */ - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (Dpt_GetNumDepartmentsInInstitution (Gbl.Hierarchy.Ins.InsCod)); - HTM_TD_End (); - - HTM_TR_End (); - } - -/*****************************************************************************/ -/************** Number of users in courses of this institution ***************/ -/*****************************************************************************/ - -static void Ins_ShowNumUsrsInCrssOfIns (Rol_Role_t Role) - { - extern const char *Txt_Users_in_courses; - extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; - - /***** Number of users in courses *****/ - HTM_TR_Begin (NULL); - - /* Label */ - Frm_LabelColumn ("RT",NULL, - Role == Rol_UNK ? Txt_Users_in_courses : - Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN]); - - /* Data */ - HTM_TD_Begin ("class=\"DAT LB\""); - HTM_Unsigned (Usr_GetNumUsrsInCrssOfIns (Role,Gbl.Hierarchy.Ins.InsCod)); - HTM_TD_End (); - - HTM_TR_End (); - } - /*****************************************************************************/ /**************** List the institutions of the current country ***************/ /*****************************************************************************/ @@ -1913,27 +1386,11 @@ void Ins_RenameInsFull (void) Ins_RenameInstitution (Ins_EditingIns,Cns_FULL_NAME); } -/*****************************************************************************/ -/************ Change the name of an institution in configuration *************/ -/*****************************************************************************/ - -void Ins_RenameInsShortInConfig (void) - { - /***** Rename institution *****/ - Ins_RenameInstitution (&Gbl.Hierarchy.Ins,Cns_SHRT_NAME); - } - -void Ins_RenameInsFullInConfig (void) - { - /***** Rename institution *****/ - Ins_RenameInstitution (&Gbl.Hierarchy.Ins,Cns_FULL_NAME); - } - /*****************************************************************************/ /******************** Change the name of an institution **********************/ /*****************************************************************************/ -static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFullName) +void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFullName) { extern const char *Txt_The_institution_X_already_exists; extern const char *Txt_The_institution_X_has_been_renamed_as_Y; @@ -2007,10 +1464,10 @@ static void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtO /****** Check if the name of institution exists in the current country *******/ /*****************************************************************************/ -static bool Ins_CheckIfInsNameExistsInCty (const char *FieldName, - const char *Name, - long InsCod, - long CtyCod) +bool Ins_CheckIfInsNameExistsInCty (const char *FieldName, + const char *Name, + long InsCod, + long CtyCod) { /***** Get number of institutions in current country with a name from database *****/ return (DB_QueryCOUNT ("can not check if the name of an institution" @@ -2036,77 +1493,6 @@ static void Ins_UpdateInsNameDB (long InsCod,const char *FieldName,const char *N Ins_FlushCacheFullNameAndCtyOfInstitution (); } -/*****************************************************************************/ -/******************* Change the country of a institution *********************/ -/*****************************************************************************/ - -void Ins_ChangeInsCtyInConfig (void) - { - extern const char *Txt_The_institution_X_already_exists; - extern const char *Txt_The_country_of_the_institution_X_has_changed_to_Y; - struct Country NewCty; - - /***** Get the new country code for the institution *****/ - NewCty.CtyCod = Cty_GetAndCheckParamOtherCtyCod (0); - - /***** Check if country has changed *****/ - if (NewCty.CtyCod != Gbl.Hierarchy.Ins.CtyCod) - { - /***** Get data of the country from database *****/ - Cty_GetDataOfCountryByCod (&NewCty,Cty_GET_BASIC_DATA); - - /***** Check if it already exists an institution with the same name in the new country *****/ - if (Ins_CheckIfInsNameExistsInCty ("ShortName",Gbl.Hierarchy.Ins.ShrtName,-1L,NewCty.CtyCod)) - Ale_CreateAlert (Ale_WARNING,NULL, - Txt_The_institution_X_already_exists, - Gbl.Hierarchy.Ins.ShrtName); - else if (Ins_CheckIfInsNameExistsInCty ("FullName",Gbl.Hierarchy.Ins.FullName,-1L,NewCty.CtyCod)) - Ale_CreateAlert (Ale_WARNING,NULL, - Txt_The_institution_X_already_exists, - Gbl.Hierarchy.Ins.FullName); - else - { - /***** Update the table changing the country of the institution *****/ - Ins_UpdateInsCtyDB (Gbl.Hierarchy.Ins.InsCod,NewCty.CtyCod); - Gbl.Hierarchy.Ins.CtyCod = - Gbl.Hierarchy.Cty.CtyCod = NewCty.CtyCod; - - /***** Initialize again current course, degree, centre... *****/ - Hie_InitHierarchy (); - - /***** Write message to show the change made *****/ - Ale_CreateAlert (Ale_SUCCESS,NULL, - Txt_The_country_of_the_institution_X_has_changed_to_Y, - Gbl.Hierarchy.Ins.FullName,NewCty.Name[Gbl.Prefs.Language]); - } - } - } - -/*****************************************************************************/ -/*** Show msg. of success after changing an institution in instit. config. ***/ -/*****************************************************************************/ - -void Ins_ContEditAfterChgInsInConfig (void) - { - /***** Write success / warning message *****/ - Ale_ShowAlerts (NULL); - - /***** Show the form again *****/ - Ins_ShowConfiguration (); - } - -/*****************************************************************************/ -/****************** Update country in table of institutions ******************/ -/*****************************************************************************/ - -static void Ins_UpdateInsCtyDB (long InsCod,long CtyCod) - { - /***** Update country in table of institutions *****/ - DB_QueryUPDATE ("can not update the country of an institution", - "UPDATE institutions SET CtyCod=%ld WHERE InsCod=%ld", - CtyCod,InsCod); - } - /*****************************************************************************/ /********************** Change the URL of a institution **********************/ /*****************************************************************************/ @@ -2147,39 +1533,11 @@ void Ins_ChangeInsWWW (void) Ale_CreateAlertYouCanNotLeaveFieldEmpty (); } -void Ins_ChangeInsWWWInConfig (void) - { - extern const char *Txt_The_new_web_address_is_X; - char NewWWW[Cns_MAX_BYTES_WWW + 1]; - - /***** Get parameters from form *****/ - /* Get the new WWW for the institution */ - Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW); - - /***** Check if new WWW is empty *****/ - if (NewWWW[0]) - { - /***** Update database changing old WWW by new WWW *****/ - Ins_UpdateInsWWWDB (Gbl.Hierarchy.Ins.InsCod,NewWWW); - Str_Copy (Gbl.Hierarchy.Ins.WWW,NewWWW, - Cns_MAX_BYTES_WWW); - - /***** Write message to show the change made *****/ - Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X, - NewWWW); - } - else - Ale_ShowAlertYouCanNotLeaveFieldEmpty (); - - /***** Show the form again *****/ - Ins_ShowConfiguration (); - } - /*****************************************************************************/ /**************** Update database changing old WWW by new WWW ****************/ /*****************************************************************************/ -static void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]) +void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]) { /***** Update database changing old WWW by new WWW *****/ DB_QueryUPDATE ("can not update the web of an institution", @@ -2278,33 +1636,6 @@ static void Ins_PutParamGoToIns (void) Ins_PutParamInsCod (Ins_EditingIns->InsCod); } -/*****************************************************************************/ -/******** Show a form for sending a logo of the current institution **********/ -/*****************************************************************************/ - -void Ins_RequestLogo (void) - { - Lgo_RequestLogo (Hie_INS); - } - -/*****************************************************************************/ -/************** Receive the logo of the current institution ******************/ -/*****************************************************************************/ - -void Ins_ReceiveLogo (void) - { - Lgo_ReceiveLogo (Hie_INS); - } - -/*****************************************************************************/ -/*************** Remove the logo of the current institution ******************/ -/*****************************************************************************/ - -void Ins_RemoveLogo (void) - { - Lgo_RemoveLogo (Hie_INS); - } - /*****************************************************************************/ /****************** Put a form to create a new institution *******************/ /*****************************************************************************/ diff --git a/swad_institution.h b/swad_institution.h index 772ba7b6..3c15513d 100644 --- a/swad_institution.h +++ b/swad_institution.h @@ -102,9 +102,6 @@ void Ins_DrawInstitutionLogoWithLink (struct Instit *Ins,unsigned Size); void Ins_DrawInstitutionLogoAndNameWithLink (struct Instit *Ins,Act_Action_t Action, const char *ClassLink,const char *ClassLogo); -void Ins_ShowConfiguration (void); -void Ins_PrintConfiguration (void); - void Ins_ShowInssOfCurrentCty (void); void Ins_EditInstitutions (void); void Ins_GetListInstitutions (long CtyCod,Ins_GetExtraData_t GetExtraData); @@ -124,18 +121,16 @@ long Ins_GetAndCheckParamOtherInsCod (long MinCodAllowed); void Ins_RemoveInstitution (void); void Ins_RenameInsShort (void); void Ins_RenameInsFull (void); -void Ins_RenameInsShortInConfig (void); -void Ins_RenameInsFullInConfig (void); -void Ins_ChangeInsCtyInConfig (void); -void Ins_ContEditAfterChgInsInConfig (void); +void Ins_RenameInstitution (struct Instit *Ins,Cns_ShrtOrFullName_t ShrtOrFullName); +bool Ins_CheckIfInsNameExistsInCty (const char *FieldName, + const char *Name, + long InsCod, + long CtyCod); void Ins_ChangeInsWWW (void); -void Ins_ChangeInsWWWInConfig (void); +void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]); void Ins_ChangeInsStatus (void); void Ins_ContEditAfterChgIns (void); -void Ins_RequestLogo (void); -void Ins_ReceiveLogo (void); -void Ins_RemoveLogo (void); void Ins_RecFormReqIns (void); void Ins_RecFormNewIns (void); diff --git a/swad_institution_config.c b/swad_institution_config.c new file mode 100644 index 00000000..654f20f3 --- /dev/null +++ b/swad_institution_config.c @@ -0,0 +1,719 @@ +// swad_institution.c: institutions + +/* + SWAD (Shared Workspace At a Distance), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2019 Antonio Caņas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************* Headers ***********************************/ +/*****************************************************************************/ + +#include // For boolean type +#include // For NULL + +#include "swad_database.h" +#include "swad_form.h" +#include "swad_global.h" +#include "swad_help.h" +#include "swad_HTML.h" +#include "swad_institution.h" +#include "swad_logo.h" + +/*****************************************************************************/ +/************** External global variables from others modules ****************/ +/*****************************************************************************/ + +extern struct Globals Gbl; + +/*****************************************************************************/ +/***************************** Private constants *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/******************************* Private types *******************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private variables *****************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Private prototypes ****************************/ +/*****************************************************************************/ + +static void InsCfg_Configuration (bool PrintView); +static void InsCfg_PutIconsToPrintAndUpload (void); +static void InsCfg_Title (bool PutLink); +static bool InsCfg_GetIfMapIsAvailable (void); +static void InsCfg_Map (void); +static void InsCfg_Country (bool PrintView,bool PutForm); +static void InsCfg_FullName (bool PutForm); +static void InsCfg_ShrtName (bool PutForm); +static void InsCfg_WWW (bool PrintView,bool PutForm); +static void InsCfg_Shortcut (bool PrintView); +static void InsCfg_QR (void); +static void InsCfg_NumUsrs (void); +static void InsCfg_NumCtrs (void); +static void InsCfg_NumDegs (void); +static void InsCfg_NumCrss (void); +static void InsCfg_NumDpts (void); +static void InsCfg_NumUsrsInCrssOfIns (Rol_Role_t Role); +static void InsCfg_UpdateInsCtyDB (long InsCod,long CtyCod); + +/*****************************************************************************/ +/*************** Show information of the current institution *****************/ +/*****************************************************************************/ + +void InsCfg_ShowConfiguration (void) + { + InsCfg_Configuration (false); + + /***** Show help to enrol me *****/ + Hlp_ShowHelpWhatWouldYouLikeToDo (); + } + +/*****************************************************************************/ +/*************** Print information of the current institution ****************/ +/*****************************************************************************/ + +void InsCfg_PrintConfiguration (void) + { + InsCfg_Configuration (true); + } + +/*****************************************************************************/ +/***************** Information of the current institution ********************/ +/*****************************************************************************/ + +static void InsCfg_Configuration (bool PrintView) + { + extern const char *Hlp_INSTITUTION_Information; + bool PutLink; + bool PutFormCty; + bool PutFormName; + bool PutFormWWW; + bool MapIsAvailable; + + /***** Trivial check *****/ + if (Gbl.Hierarchy.Ins.InsCod <= 0) // No institution selected + return; + + /***** Initializations *****/ + PutLink = !PrintView && Gbl.Hierarchy.Ins.WWW[0]; + PutFormCty = + PutFormName = !PrintView && Gbl.Usrs.Me.Role.Logged == Rol_SYS_ADM; + PutFormWWW = !PrintView && Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM; + + /***** Begin box *****/ + if (PrintView) + Box_BoxBegin (NULL,NULL,NULL, + NULL,Box_NOT_CLOSABLE); + else + Box_BoxBegin (NULL,NULL,InsCfg_PutIconsToPrintAndUpload, + Hlp_INSTITUTION_Information,Box_NOT_CLOSABLE); + + + /***** Title *****/ + InsCfg_Title (PutLink); + + /**************************** Left part ***********************************/ + HTM_DIV_Begin ("class=\"HIE_CFG_LEFT\""); + + /***** Begin table *****/ + HTM_TABLE_BeginWidePadding (2); + + /***** Country *****/ + InsCfg_Country (PrintView,PutFormCty); + + /***** Institution name *****/ + InsCfg_FullName (PutFormName); + InsCfg_ShrtName (PutFormName); + + /***** Institution WWW *****/ + InsCfg_WWW (PrintView,PutFormWWW); + + /***** Shortcut to the institution *****/ + InsCfg_Shortcut (PrintView); + + if (PrintView) + /***** QR code with link to the institution *****/ + InsCfg_QR (); + else + { + /***** Number of users who claim to belong to this institution, + number of centres, + number of degrees, + number of courses, + number of departments *****/ + InsCfg_NumUsrs (); + InsCfg_NumCtrs (); + InsCfg_NumDegs (); + InsCfg_NumCrss (); + InsCfg_NumDpts (); + + /***** Number of users in courses of this institution *****/ + InsCfg_NumUsrsInCrssOfIns (Rol_TCH); + InsCfg_NumUsrsInCrssOfIns (Rol_NET); + InsCfg_NumUsrsInCrssOfIns (Rol_STD); + InsCfg_NumUsrsInCrssOfIns (Rol_UNK); + } + + /***** End table *****/ + HTM_TABLE_End (); + + /***** End of left part *****/ + HTM_DIV_End (); + + /**************************** Right part **********************************/ + /***** Check map *****/ + MapIsAvailable = InsCfg_GetIfMapIsAvailable (); + + if (MapIsAvailable) + { + HTM_DIV_Begin ("class=\"HIE_CFG_RIGHT\""); + + /***** Institution map *****/ + InsCfg_Map (); + + HTM_DIV_End (); + } + + /***** End box *****/ + Box_BoxEnd (); + } + +/*****************************************************************************/ +/********* Put contextual icons in configuration of an institution ***********/ +/*****************************************************************************/ + +static void InsCfg_PutIconsToPrintAndUpload (void) + { + /***** Icon to print info about institution *****/ + Ico_PutContextualIconToPrint (ActPrnInsInf,NULL); + + if (Gbl.Usrs.Me.Role.Logged >= Rol_INS_ADM) + /***** Icon to upload logo of institution *****/ + Lgo_PutIconToChangeLogo (Hie_INS); + + /***** Put icon to view places *****/ + Plc_PutIconToViewPlaces (); + } + +/*****************************************************************************/ +/***************** Show title in institution configuration *******************/ +/*****************************************************************************/ + +static void InsCfg_Title (bool PutLink) + { + Hie_ConfigTitle (PutLink, + Hie_INS, // Logo scope + Gbl.Hierarchy.Ins.InsCod, // Logo code + Gbl.Hierarchy.Ins.ShrtName, // Logo short name + Gbl.Hierarchy.Ins.FullName, // Logo full name + Gbl.Hierarchy.Ins.WWW, // Logo www + Gbl.Hierarchy.Ins.FullName); // Text full name + } + +/*****************************************************************************/ +/******************** Check if centre map should be shown ********************/ +/*****************************************************************************/ + +// TODO: Change code!!!! + +static bool InsCfg_GetIfMapIsAvailable (void) + { + return true; + + /***** Coordinates 0, 0 means not set ==> don't show map *****/ + /* + return (bool) (Gbl.Hierarchy.Ctr.Coord.Latitude || + Gbl.Hierarchy.Ctr.Coord.Longitude); + */ + } + +/*****************************************************************************/ +/****************************** Draw centre map ******************************/ +/*****************************************************************************/ + +// TODO: Change code!!!! + +static void InsCfg_Map (void) + { + /* https://leafletjs.com/examples/quick-start/ */ + /***** Leaflet CSS *****/ + HTM_Txt (""); + + /***** Leaflet script *****/ + /* Put this AFTER Leaflet's CSS */ + HTM_Txt (""); + + /***** Container for the map *****/ + HTM_DIV_Begin ("id=\"centre_mapid\""); + HTM_DIV_End (); + + /***** Script to draw the map *****/ + HTM_SCRIPT_Begin (NULL,NULL); + Str_SetDecimalPointToUS (); // To write the decimal point as a dot + + /* Let's create a map of the center of London with pretty Mapbox Streets tiles */ + HTM_TxtF ("\tvar mymap = L.map('centre_mapid').setView([%lg, %lg], 16);\n", + Gbl.Hierarchy.Ctr.Coord.Latitude, + Gbl.Hierarchy.Ctr.Coord.Longitude); + + /* Next we'll add a tile layer to add to our map, + in this case it's a Mapbox Streets tile layer. + Creating a tile layer usually involves + setting the URL template for the tile images, + the attribution text and the maximum zoom level of the layer. + In this example we'll use the mapbox/streets-v11 tiles + from Mapbox's Static Tiles API + (in order to use tiles from Mapbox, + you must also request an access token).*/ + HTM_Txt ("\tL.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', {" + "attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox'," + "maxZoom: 20," + "id: 'mapbox/streets-v11'," + "accessToken: 'pk.eyJ1IjoiYWNhbmFzIiwiYSI6ImNrNGFoNXFxOTAzdHozcnA4d3Y0M3BwOGkifQ.uSg754Lv2iZEJg0W2pjiOQ'" + "}).addTo(mymap);\n"); + + /* Marker */ + HTM_TxtF ("\tvar marker = L.marker([%lg, %lg]).addTo(mymap);", + Gbl.Hierarchy.Ctr.Coord.Latitude, + Gbl.Hierarchy.Ctr.Coord.Longitude); + + HTM_TxtF ("\tmarker.bindPopup(\"%s
%s\").openPopup();", + Gbl.Hierarchy.Ctr.ShrtName, + Gbl.Hierarchy.Ins.ShrtName); + + Str_SetDecimalPointToLocal (); // Return to local system + HTM_SCRIPT_End (); + } + +/*****************************************************************************/ +/***************** Show country in institution configuration *****************/ +/*****************************************************************************/ + +static void InsCfg_Country (bool PrintView,bool PutForm) + { + extern const char *Txt_Country; + extern const char *Txt_Go_to_X; + unsigned NumCty; + + /***** Country *****/ + HTM_TR_Begin (NULL); + + /* Label */ + Frm_LabelColumn ("RT",PutForm ? "OthCtyCod" : + NULL, + Txt_Country); + + /* Data */ + HTM_TD_Begin ("class=\"DAT LB\""); + if (PutForm) + { + /* Get list of countries */ + Cty_GetListCountries (Cty_GET_BASIC_DATA); + + /* Put form to select country */ + Frm_StartForm (ActChgInsCtyCfg); + HTM_SELECT_Begin (true, + "id=\"OthCtyCod\" name=\"OthCtyCod\"" + " class=\"INPUT_SHORT_NAME\""); + for (NumCty = 0; + NumCty < Gbl.Hierarchy.Sys.Ctys.Num; + NumCty++) + HTM_OPTION (HTM_Type_LONG,&Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod, + Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].CtyCod == Gbl.Hierarchy.Cty.CtyCod,false, + "%s",Gbl.Hierarchy.Sys.Ctys.Lst[NumCty].Name[Gbl.Prefs.Language]); + HTM_SELECT_End (); + Frm_EndForm (); + + /* Free list of countries */ + Cty_FreeListCountries (); + } + else // I can not move institution to another country + { + if (!PrintView) + { + Frm_StartFormGoTo (ActSeeCtyInf); + Cty_PutParamCtyCod (Gbl.Hierarchy.Cty.CtyCod); + snprintf (Gbl.Title,sizeof (Gbl.Title), + Txt_Go_to_X, + Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]); + HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK LT DAT",NULL); + } + Cty_DrawCountryMap (&Gbl.Hierarchy.Cty,"COUNTRY_MAP_TINY"); + HTM_NBSP (); + HTM_Txt (Gbl.Hierarchy.Cty.Name[Gbl.Prefs.Language]); + if (!PrintView) + { + HTM_BUTTON_End (); + Frm_EndForm (); + } + } + HTM_TD_End (); + + HTM_TR_End (); + } + +/*****************************************************************************/ +/********* Show institution full name in institution configuration ***********/ +/*****************************************************************************/ + +static void InsCfg_FullName (bool PutForm) + { + extern const char *Txt_Institution; + + Hie_ConfigFullName (PutForm,Txt_Institution,ActRenInsFulCfg, + Gbl.Hierarchy.Ins.FullName); + } + +/*****************************************************************************/ +/********* Show institution short name in institution configuration **********/ +/*****************************************************************************/ + +static void InsCfg_ShrtName (bool PutForm) + { + Hie_ConfigShrtName (PutForm,ActRenInsShoCfg,Gbl.Hierarchy.Ins.ShrtName); + } + +/*****************************************************************************/ +/************ Show institution WWW in institution configuration **************/ +/*****************************************************************************/ + +static void InsCfg_WWW (bool PrintView,bool PutForm) + { + Hie_ConfigWWW (PrintView,PutForm,ActChgInsWWWCfg,Gbl.Hierarchy.Ins.WWW); + } + +/*****************************************************************************/ +/********** Show institution shortcut in institution configuration ***********/ +/*****************************************************************************/ + +static void InsCfg_Shortcut (bool PrintView) + { + Hie_ConfigShortcut (PrintView,"ins",Gbl.Hierarchy.Ins.InsCod); + } + +/*****************************************************************************/ +/************* Show institution QR in institution configuration **************/ +/*****************************************************************************/ + +static void InsCfg_QR (void) + { + Hie_ConfigQR ("ins",Gbl.Hierarchy.Ins.InsCod); + } + +/*****************************************************************************/ +/** Show number of users who claim to belong to instit. in instit. config. ***/ +/*****************************************************************************/ + +static void InsCfg_NumUsrs (void) + { + extern const char *Txt_Users_of_the_institution; + + /***** Number of users *****/ + HTM_TR_Begin (NULL); + + /* Label */ + Frm_LabelColumn ("RT",NULL,Txt_Users_of_the_institution); + + /* Data */ + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (Usr_GetNumUsrsWhoClaimToBelongToIns (Gbl.Hierarchy.Ins.InsCod)); + HTM_TD_End (); + + HTM_TR_End (); + } + +/*****************************************************************************/ +/*********** Show number of centres in institution configuration *************/ +/*****************************************************************************/ + +static void InsCfg_NumCtrs (void) + { + extern const char *Txt_Centres; + extern const char *Txt_Centres_of_INSTITUTION_X; + + /***** Number of centres *****/ + HTM_TR_Begin (NULL); + + /* Label */ + Frm_LabelColumn ("RT",NULL,Txt_Centres); + + /* Data */ + HTM_TD_Begin ("class=\"LB\""); + Frm_StartFormGoTo (ActSeeCtr); + Ins_PutParamInsCod (Gbl.Hierarchy.Ins.InsCod); + snprintf (Gbl.Title,sizeof (Gbl.Title), + Txt_Centres_of_INSTITUTION_X, + Gbl.Hierarchy.Ins.ShrtName); + HTM_BUTTON_SUBMIT_Begin (Gbl.Title,"BT_LINK DAT",NULL); + HTM_Unsigned (Ctr_GetNumCtrsInIns (Gbl.Hierarchy.Ins.InsCod)); + HTM_BUTTON_End (); + Frm_EndForm (); + HTM_TD_End (); + + HTM_TR_End (); + } + +/*****************************************************************************/ +/*********** Show number of degrees in institution configuration *************/ +/*****************************************************************************/ + +static void InsCfg_NumDegs (void) + { + extern const char *Txt_Degrees; + + /***** Number of degrees *****/ + HTM_TR_Begin (NULL); + + /* Label */ + Frm_LabelColumn ("RT",NULL,Txt_Degrees); + + /* Data */ + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (Deg_GetNumDegsInIns (Gbl.Hierarchy.Ins.InsCod)); + HTM_TD_End (); + + HTM_TR_End (); + } + +/*****************************************************************************/ +/************ Show number of courses in institution configuration ************/ +/*****************************************************************************/ + +static void InsCfg_NumCrss (void) + { + extern const char *Txt_Courses; + + /***** Number of courses *****/ + HTM_TR_Begin (NULL); + + /* Label */ + Frm_LabelColumn ("RT",NULL,Txt_Courses); + + /* Data */ + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (Crs_GetNumCrssInIns (Gbl.Hierarchy.Ins.InsCod)); + HTM_TD_End (); + + HTM_TR_End (); + } + +/*****************************************************************************/ +/********** Show number of departments in institution configuration **********/ +/*****************************************************************************/ + +static void InsCfg_NumDpts (void) + { + extern const char *Txt_Departments; + + /***** Number of departments *****/ + HTM_TR_Begin (NULL); + + /* Label */ + Frm_LabelColumn ("RT",NULL,Txt_Departments); + + /* Data */ + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (Dpt_GetNumDepartmentsInInstitution (Gbl.Hierarchy.Ins.InsCod)); + HTM_TD_End (); + + HTM_TR_End (); + } + +/*****************************************************************************/ +/************** Number of users in courses of this institution ***************/ +/*****************************************************************************/ + +static void InsCfg_NumUsrsInCrssOfIns (Rol_Role_t Role) + { + extern const char *Txt_Users_in_courses; + extern const char *Txt_ROLES_PLURAL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; + + /***** Number of users in courses *****/ + HTM_TR_Begin (NULL); + + /* Label */ + Frm_LabelColumn ("RT",NULL, + Role == Rol_UNK ? Txt_Users_in_courses : + Txt_ROLES_PLURAL_Abc[Role][Usr_SEX_UNKNOWN]); + + /* Data */ + HTM_TD_Begin ("class=\"DAT LB\""); + HTM_Unsigned (Usr_GetNumUsrsInCrssOfIns (Role,Gbl.Hierarchy.Ins.InsCod)); + HTM_TD_End (); + + HTM_TR_End (); + } + +/*****************************************************************************/ +/******** Show a form for sending a logo of the current institution **********/ +/*****************************************************************************/ + +void InsCfg_RequestLogo (void) + { + Lgo_RequestLogo (Hie_INS); + } + +/*****************************************************************************/ +/************** Receive the logo of the current institution ******************/ +/*****************************************************************************/ + +void InsCfg_ReceiveLogo (void) + { + Lgo_ReceiveLogo (Hie_INS); + } + +/*****************************************************************************/ +/*************** Remove the logo of the current institution ******************/ +/*****************************************************************************/ + +void InsCfg_RemoveLogo (void) + { + Lgo_RemoveLogo (Hie_INS); + } + +/*****************************************************************************/ +/******************* Change the country of a institution *********************/ +/*****************************************************************************/ + +void InsCfg_ChangeInsCty (void) + { + extern const char *Txt_The_institution_X_already_exists; + extern const char *Txt_The_country_of_the_institution_X_has_changed_to_Y; + struct Country NewCty; + + /***** Get the new country code for the institution *****/ + NewCty.CtyCod = Cty_GetAndCheckParamOtherCtyCod (0); + + /***** Check if country has changed *****/ + if (NewCty.CtyCod != Gbl.Hierarchy.Ins.CtyCod) + { + /***** Get data of the country from database *****/ + Cty_GetDataOfCountryByCod (&NewCty,Cty_GET_BASIC_DATA); + + /***** Check if it already exists an institution with the same name in the new country *****/ + if (Ins_CheckIfInsNameExistsInCty ("ShortName",Gbl.Hierarchy.Ins.ShrtName,-1L,NewCty.CtyCod)) + Ale_CreateAlert (Ale_WARNING,NULL, + Txt_The_institution_X_already_exists, + Gbl.Hierarchy.Ins.ShrtName); + else if (Ins_CheckIfInsNameExistsInCty ("FullName",Gbl.Hierarchy.Ins.FullName,-1L,NewCty.CtyCod)) + Ale_CreateAlert (Ale_WARNING,NULL, + Txt_The_institution_X_already_exists, + Gbl.Hierarchy.Ins.FullName); + else + { + /***** Update the table changing the country of the institution *****/ + InsCfg_UpdateInsCtyDB (Gbl.Hierarchy.Ins.InsCod,NewCty.CtyCod); + Gbl.Hierarchy.Ins.CtyCod = + Gbl.Hierarchy.Cty.CtyCod = NewCty.CtyCod; + + /***** Initialize again current course, degree, centre... *****/ + Hie_InitHierarchy (); + + /***** Write message to show the change made *****/ + Ale_CreateAlert (Ale_SUCCESS,NULL, + Txt_The_country_of_the_institution_X_has_changed_to_Y, + Gbl.Hierarchy.Ins.FullName,NewCty.Name[Gbl.Prefs.Language]); + } + } + } + +/*****************************************************************************/ +/****************** Update country in table of institutions ******************/ +/*****************************************************************************/ + +static void InsCfg_UpdateInsCtyDB (long InsCod,long CtyCod) + { + /***** Update country in table of institutions *****/ + DB_QueryUPDATE ("can not update the country of an institution", + "UPDATE institutions SET CtyCod=%ld WHERE InsCod=%ld", + CtyCod,InsCod); + } + +/*****************************************************************************/ +/************ Change the name of an institution in configuration *************/ +/*****************************************************************************/ + +void InsCfg_RenameInsShort (void) + { + /***** Rename institution *****/ + Ins_RenameInstitution (&Gbl.Hierarchy.Ins,Cns_SHRT_NAME); + } + +void InsCfg_RenameInsFull (void) + { + /***** Rename institution *****/ + Ins_RenameInstitution (&Gbl.Hierarchy.Ins,Cns_FULL_NAME); + } + +/*****************************************************************************/ +/********************** Change the URL of a institution **********************/ +/*****************************************************************************/ + +void InsCfg_ChangeInsWWW (void) + { + extern const char *Txt_The_new_web_address_is_X; + char NewWWW[Cns_MAX_BYTES_WWW + 1]; + + /***** Get parameters from form *****/ + /* Get the new WWW for the institution */ + Par_GetParToText ("WWW",NewWWW,Cns_MAX_BYTES_WWW); + + /***** Check if new WWW is empty *****/ + if (NewWWW[0]) + { + /***** Update database changing old WWW by new WWW *****/ + Ins_UpdateInsWWWDB (Gbl.Hierarchy.Ins.InsCod,NewWWW); + Str_Copy (Gbl.Hierarchy.Ins.WWW,NewWWW, + Cns_MAX_BYTES_WWW); + + /***** Write message to show the change made *****/ + Ale_ShowAlert (Ale_SUCCESS,Txt_The_new_web_address_is_X, + NewWWW); + } + else + Ale_ShowAlertYouCanNotLeaveFieldEmpty (); + + /***** Show the form again *****/ + InsCfg_ShowConfiguration (); + } + +/*****************************************************************************/ +/*** Show msg. of success after changing an institution in instit. config. ***/ +/*****************************************************************************/ + +void InsCfg_ContEditAfterChgIns (void) + { + /***** Write success / warning message *****/ + Ale_ShowAlerts (NULL); + + /***** Show the form again *****/ + InsCfg_ShowConfiguration (); + } + diff --git a/swad_institution_config.h b/swad_institution_config.h new file mode 100644 index 00000000..8be9ed16 --- /dev/null +++ b/swad_institution_config.h @@ -0,0 +1,50 @@ +// swad_institution_config.h: configuration of current institution + +#ifndef _SWAD_INS_CFG +#define _SWAD_INS_CFG +/* + SWAD (Shared Workspace At a Distance in Spanish), + is a web platform developed at the University of Granada (Spain), + and used to support university teaching. + + This file is part of SWAD core. + Copyright (C) 1999-2019 Antonio Caņas Vargas + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ +/*****************************************************************************/ +/********************************** Headers **********************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/************************ Public types and constants *************************/ +/*****************************************************************************/ + +/*****************************************************************************/ +/***************************** Public prototypes *****************************/ +/*****************************************************************************/ + +void InsCfg_ShowConfiguration (void); +void InsCfg_PrintConfiguration (void); + +void InsCfg_RequestLogo (void); +void InsCfg_ReceiveLogo (void); +void InsCfg_RemoveLogo (void); +void InsCfg_ChangeInsCty (void); +void InsCfg_RenameInsShort (void); +void InsCfg_RenameInsFull (void); +void InsCfg_ContEditAfterChgIns (void); +void InsCfg_ChangeInsWWW (void); + +#endif