$id_agente], 'id_agente_modulo'); $count_modules = count($modules); // Update of layout 1 (Rack sample). $images_rack_server = [ 'rack_server_rack', 'rack_server', 'rack_switch', 'rack_firewall', 'rack_double_server', 'rack_frame', 'rack_pdu', ]; $query = 'UPDATE `tlayout_data` SET `id_agent` = '.$id_agente.', `id_agente_modulo` = CASE '; for ($i = 0; $i < $count_modules; $i++) { $query .= 'WHEN `image` = "'.$images_rack_server[$i].'" THEN '.$modules[$i]['id_agente_modulo'].' '; } $query .= 'END WHERE `id_layout` = 1 AND `image` IN ("'.implode('","', $images_rack_server).'");'; db_process_sql($query); // Update of layout 2 (Dashboard). $query = 'UPDATE `tlayout_data` SET `id_agent`= '.$id_agente.', `id_agente_modulo` = CASE '; $query .= 'WHEN `id` = 107 THEN '.$modules[0]['id_agente_modulo'].' '; $query .= 'WHEN `id` = 108 THEN '.$modules[1]['id_agente_modulo'].' '; $query .= 'WHEN `id` = 109 THEN '.$modules[2]['id_agente_modulo'].' '; $query .= 'WHEN `id` = 110 THEN '.$modules[2]['id_agente_modulo'].' '; $query .= 'WHEN `id` = 111 THEN '.$modules[3]['id_agente_modulo'].' '; $query .= 'WHEN `id` = 112 THEN '.$modules[4]['id_agente_modulo'].' '; $query .= 'WHEN `id` = 113 THEN '.$modules[5]['id_agente_modulo'].' '; $query .= 'WHEN `id` = 114 THEN '.$modules[6]['id_agente_modulo'].' '; $query .= 'END WHERE `id_layout` = 2 AND `id` IN (107,108,109,110,111,112,113,114);'; db_process_sql($query); // This setting will avoid regenerate all the times the visual consoles. config_update_value('sample_agent_deployed', 1); } extensions_add_main_function('sample_agent_deployment');