Classification of the phases of ID spin chains with commuting Hamiltonians