diff --git a/swad_API.c b/swad_API.c index ee16717fd..d4b65a6b0 100644 --- a/swad_API.c +++ b/swad_API.c @@ -6024,7 +6024,7 @@ int swad__getLocation (struct soap *soap, struct swad__getLocationOutput *getLocationOut) // output { int ReturnCode; - unsigned long MACnum; + unsigned long long MACnum; MYSQL_RES *mysql_res; unsigned NumLocs; @@ -6049,7 +6049,7 @@ int swad__getLocation (struct soap *soap, Gbl.Usrs.Me.Role.Logged = Gbl.Usrs.Me.UsrDat.Roles.InCurrentCrs.Role; /***** Convert MAC string to number *****/ - if (sscanf (MAC,"%lx",&MACnum) != 1) + if (sscanf (MAC,"%llx",&MACnum) != 1) return soap_receiver_fault (soap, "Bad MAC", "MAC address format should be 12 hexadecimal digits"); @@ -6071,7 +6071,7 @@ int swad__getLocation (struct soap *soap, "rooms.ShortName," // row[11] "rooms.FullName" // row[12] " FROM room_MAC,rooms,buildings,centres,institutions" - " WHERE room_MAC.MAC=%lu" + " WHERE room_MAC.MAC=%llu" " AND room_MAC.RooCod=rooms.RooCod" " AND rooms.BldCod=buildings.BldCod" " AND buildings.CtrCod=centres.CtrCod" diff --git a/swad_changelog.h b/swad_changelog.h index de9c68c71..626f26f16 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -555,7 +555,7 @@ enscript -2 --landscape --color --file-align=2 --highlight --line-numbers -o - * En OpenSWAD: ps2pdf source.ps destination.pdf */ -#define Log_PLATFORM_VERSION "SWAD 19.260.3 (2020-08-30)" +#define Log_PLATFORM_VERSION "SWAD 19.261 (2020-09-01)" #define CSS_FILE "swad19.253.css" #define JS_FILE "swad19.254.js" /* @@ -573,6 +573,7 @@ TODO: Que al generar un examen s TODO: Create module swad_test_result "sudo apt install webp" en Ubuntu, y "yum install libwebp libwebp-tools" en CentOS, para decodificar imágenes Web/ug reportado por Javier Fernández Baldomero. + Version 19.261 : Sep 01, 2020 MAC addresses are printed in listing of rooms. (304103 lines) Version 19.260.3: Aug 30, 2020 Fixed bug in API function answerMatchQuestion. Reported by Sergio Díaz Rueda. (304010 lines) Version 19.260.2: Aug 28, 2020 Fixed bugs in API functions related to games and matches. Reported by Sergio Díaz Rueda. (304010 lines) Version 19.260.1: Aug 26, 2020 Fixed bugs in API functions related to games and matches. Reported by Sergio Díaz Rueda. (304027 lines) diff --git a/swad_database.c b/swad_database.c index a92ab72f2..eda862c51 100644 --- a/swad_database.c +++ b/swad_database.c @@ -2756,7 +2756,7 @@ mysql> DESCRIBE room_MAC; 2 rows in set (0.00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS room_MAC (" - "RooCod INT NOT NULL AUTO_INCREMENT," + "RooCod INT NOT NULL," "MAC BIGINT NOT NULL," // 12 digits hexadecimal number "UNIQUE INDEX(RooCod,MAC)," "UNIQUE INDEX(MAC,RooCod))"); diff --git a/swad_room.c b/swad_room.c index d4b11fb0a..f6748571f 100644 --- a/swad_room.c +++ b/swad_room.c @@ -119,6 +119,8 @@ static struct Roo_Room *Roo_EditingRoom = NULL; // Static variable to keep the r /***************************** Private prototypes ****************************/ /*****************************************************************************/ +static void Roo_GetAndWriteMACAddresses (long RooCod); + static Roo_Order_t Roo_GetParamRoomOrder (void); static bool Roo_CheckIfICanCreateRooms (void); static void Roo_PutIconsListingRooms (__attribute__((unused)) void *Args); @@ -176,6 +178,7 @@ void Roo_SeeRooms (void) extern const char *Txt_Rooms; extern const char *Txt_ROOMS_HELP_ORDER[Roo_NUM_ORDERS]; extern const char *Txt_ROOMS_ORDER[Roo_NUM_ORDERS]; + extern const char *Txt_MAC_address; extern const char *Txt_ROOM_TYPES[Roo_NUM_TYPES]; extern const char *Txt_New_room; struct Roo_Rooms Rooms; @@ -203,6 +206,8 @@ void Roo_SeeRooms (void) Hlp_CENTRE_Rooms,Box_NOT_CLOSABLE); HTM_TABLE_BeginWideMarginPadding (2); HTM_TR_Begin (NULL); + + /* Columns visible by all */ for (Order = (Roo_Order_t) 0; Order <= (Roo_Order_t) (Roo_NUM_ORDERS - 1); Order++) @@ -220,6 +225,21 @@ void Roo_SeeRooms (void) Frm_EndForm (); HTM_TH_End (); } + + /* Column visible by admins */ + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_CTR_ADM: + case Rol_INS_ADM: + case Rol_SYS_ADM: + HTM_TH_Begin (1,1,"LM"); + HTM_Txt (Txt_MAC_address); + HTM_TH_End (); + break; + default: + break; + } + HTM_TR_End (); /***** Write list of rooms *****/ @@ -260,6 +280,20 @@ void Roo_SeeRooms (void) HTM_Txt (StrCapacity); HTM_TD_End (); + /* Column visible by admins */ + switch (Gbl.Usrs.Me.Role.Logged) + { + case Rol_CTR_ADM: + case Rol_INS_ADM: + case Rol_SYS_ADM: + HTM_TD_Begin ("class=\"DAT RM %s\"",Gbl.ColorRows[RowEvenOdd]); + Roo_GetAndWriteMACAddresses (Rooms.Lst[NumRoom].RooCod); + HTM_TD_End (); + break; + default: + break; + } + HTM_TR_End (); } @@ -281,6 +315,56 @@ void Roo_SeeRooms (void) Roo_FreeListRooms (&Rooms); } +/*****************************************************************************/ +/************* Write list of MAC addresses associated to a room **************/ +/*****************************************************************************/ + +static void Roo_GetAndWriteMACAddresses (long RooCod) + { + MYSQL_RES *mysql_res; + MYSQL_ROW row; + unsigned NumMACs; + unsigned NumMAC; + unsigned long long MACnum; + + /***** Get MAC addresses from database *****/ + NumMACs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get MAC addresses", + "SELECT MAC" // row[0] + " FROM room_MAC" + " WHERE RooCod=%ld" + " ORDER BY MAC", + RooCod); + + /***** Write the MACs *****/ + for (NumMAC = 0; + NumMAC < NumMACs; + NumMAC++) + { + /* Get next MAC */ + row = mysql_fetch_row (mysql_res); + + /* Write break line */ + if (NumMAC) + HTM_BR (); + + /* Get MAC (row[0]) */ + if (sscanf (row[0],"%llu",&MACnum) == 1) + /* Write MAC */ + HTM_TxtF ("%02x:%02x:%02x:%02x:%02x:%02x", + (unsigned char) ((MACnum >> 40) & 0xff), + (unsigned char) ((MACnum >> 32) & 0xff), + (unsigned char) ((MACnum >> 24) & 0xff), + (unsigned char) ((MACnum >> 16) & 0xff), + (unsigned char) ((MACnum >> 8) & 0xff), + (unsigned char) ((MACnum ) & 0xff)); + else + HTM_Txt ("?"); + } + + /***** Free structure that stores the query result *****/ + DB_FreeMySQLResult (&mysql_res); + } + /*****************************************************************************/ /*********** Get parameter with the type or order in list of rooms ***********/ /*****************************************************************************/ diff --git a/swad_text.c b/swad_text.c index 115e30aab..fd47a54ad 100644 --- a/swad_text.c +++ b/swad_text.c @@ -18992,6 +18992,27 @@ const char *Txt_Longitude = "Longitude"; #endif +const char *Txt_MAC_address = +#if L==1 // ca + "Adreça MAC"; +#elif L==2 // de + "MAC-Adresse"; +#elif L==3 // en + "MAC address"; +#elif L==4 // es + "Dirección MAC"; +#elif L==5 // fr + "Adresse MAC"; +#elif L==6 // gn + "Dirección MAC"; // Okoteve traducción +#elif L==7 // it + "Indirizzo MAC"; +#elif L==8 // pl + "Adres MAC"; +#elif L==9 // pt + "Endereço MAC"; +#endif + const char *Txt_Mandatory_enrolment = // (to a type of group) #if L==1 // ca "¿Adscripción obligatoria?"; // Necessita traduccio