Guantanamo detainees have rights, court rules