summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rest.c30
-rw-r--r--src/schema.c35
2 files changed, 64 insertions, 1 deletions
diff --git a/src/rest.c b/src/rest.c
index 5f6d3ec..f0953b2 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -1082,7 +1082,35 @@ static int og_set_client_mode(struct og_dbi *dbi, const char *mac,
int fd;
result = dbi_conn_queryf(dbi->conn,
- "SELECT ' LANG=%s', ' ip=', CONCAT_WS(':', ordenadores.ip, (SELECT (@serverip:=ipserveradm) FROM entornos LIMIT 1), aulas.router, aulas.netmask, ordenadores.nombreordenador, ordenadores.netiface, 'none'), ' group=', REPLACE(TRIM(aulas.nombreaula), ' ', '_'), ' ogrepo=', (@repoip:=IFNULL(repositorios.ip, '')), ' oglive=', @serverip, ' oglog=', @serverip, ' ogshare=', @serverip, ' oglivedir=', ordenadores.oglivedir, ' ogprof=', IF(ordenadores.idordenador=aulas.idordprofesor, 'true', 'false'), IF(perfileshard.descripcion<>'', CONCAT(' hardprofile=', REPLACE(TRIM(perfileshard.descripcion), ' ', '_')), ''), IF(aulas.ntp<>'', CONCAT(' ogntp=', aulas.ntp), ''), IF(aulas.dns<>'', CONCAT(' ogdns=', aulas.dns), ''), IF(aulas.proxy<>'', CONCAT(' ogproxy=', aulas.proxy), ''), IF(entidades.ogunit=1 AND NOT centros.directorio='', CONCAT(' ogunit=', centros.directorio), ''), CASE WHEN menus.resolucion IS NULL THEN '' WHEN menus.resolucion <= '999' THEN CONCAT(' vga=', menus.resolucion) WHEN menus.resolucion LIKE '%:%' THEN CONCAT(' video=', menus.resolucion) ELSE menus.resolucion END FROM ordenadores JOIN aulas USING(idaula) JOIN centros USING(idcentro) JOIN entidades USING(identidad) LEFT JOIN repositorios USING(idrepositorio) LEFT JOIN perfileshard USING(idperfilhard) LEFT JOIN menus USING(idmenu) WHERE ordenadores.mac='%s'", getenv("LANG"), mac);
+ "SELECT ' LANG=%s', "
+ "' ip=', CONCAT_WS(':', ordenadores.ip, (@serverip:=entornos.ipserveradm), aulas.router, aulas.netmask, ordenadores.nombreordenador, ordenadores.netiface, 'none'), "
+ "' group=', REPLACE(TRIM(aulas.nombreaula), ' ', '_'), "
+ "' ogrepo=', (@repoip:=IFNULL(repositorios.ip, '')), "
+ "' oglive=', @serverip, "
+ "' oglog=', @serverip, "
+ "' ogshare=', @serverip, "
+ "' oglivedir=', ordenadores.oglivedir, "
+ "' ogprof=', IF(ordenadores.idordenador=aulas.idordprofesor, 'true', 'false'), "
+ "IF(perfileshard.descripcion<>'', CONCAT(' hardprofile=', REPLACE(TRIM(perfileshard.descripcion), ' ', '_')), ''), "
+ "IF(aulas.ntp<>'', CONCAT(' ogntp=', aulas.ntp), ''), "
+ "IF(aulas.dns<>'', CONCAT(' ogdns=', aulas.dns), ''), "
+ "IF(aulas.proxy<>'', CONCAT(' ogproxy=', aulas.proxy), ''), "
+ "IF(entidades.ogunit=1 AND NOT centros.directorio='', CONCAT(' ogunit=', centros.directorio), ''), "
+ "CASE WHEN menus.resolucion IS NULL THEN '' "
+ "WHEN menus.resolucion <= '999' THEN CONCAT(' vga=', menus.resolucion) "
+ "WHEN menus.resolucion LIKE '%:%' THEN CONCAT(' video=', menus.resolucion) "
+ "ELSE menus.resolucion END "
+
+ "FROM ordenadores "
+ "JOIN aulas USING(idaula) "
+ "JOIN centros USING(idcentro) "
+ "JOIN entidades USING(identidad) "
+ "JOIN entornos USING(identorno) "
+ "LEFT JOIN repositorios USING(idrepositorio) "
+ "LEFT JOIN perfileshard USING(idperfilhard) "
+ "LEFT JOIN menus USING(idmenu) "
+
+ "WHERE ordenadores.mac='%s'", getenv("LANG"), mac);
if (dbi_result_get_numrows(result) != 1) {
dbi_conn_error(dbi->conn, &msglog);
diff --git a/src/schema.c b/src/schema.c
index 1d935b9..56d52ba 100644
--- a/src/schema.c
+++ b/src/schema.c
@@ -206,6 +206,40 @@ static int og_dbi_schema_v3(struct og_dbi *dbi)
return 0;
}
+static int og_dbi_schema_v4(struct og_dbi *dbi)
+{
+ const char *msglog;
+ dbi_result result;
+
+ syslog(LOG_DEBUG, "Adding identorno to ordenadores\n");
+ result = dbi_conn_query(dbi->conn,
+ "ALTER TABLE `ordenadores` "
+ "ADD `identorno` int(11) NOT NULL DEFAULT '1' "
+ "AFTER `idordenador`, "
+ "ADD CONSTRAINT `FK_entornos` "
+ "FOREIGN KEY (`identorno`) "
+ "REFERENCES `entornos` (`identorno`) "
+ "ON DELETE RESTRICT;");
+ if (!result) {
+ dbi_conn_error(dbi->conn, &msglog);
+ syslog(LOG_INFO, "Error when adding identorno (%s:%d) %s\n",
+ __func__, __LINE__, msglog);
+ return -1;
+ }
+ dbi_result_free(result);
+
+ result = dbi_conn_query(dbi->conn, "UPDATE version SET version = 4");
+ if (!result) {
+ dbi_conn_error(dbi->conn, &msglog);
+ syslog(LOG_INFO, "Could not update version row (%s:%d) %s\n",
+ __func__, __LINE__, msglog);
+ return -1;
+ }
+ dbi_result_free(result);
+
+ return 0;
+}
+
static struct og_schema_version {
int version;
int (*update)(struct og_dbi *dbi);
@@ -213,6 +247,7 @@ static struct og_schema_version {
{ .version = 1, .update = og_dbi_schema_v1 },
{ .version = 2, .update = og_dbi_schema_v2 },
{ .version = 3, .update = og_dbi_schema_v3 },
+ { .version = 4, .update = og_dbi_schema_v4 },
{ 0, NULL },
};