Unified description of the cooperative Jahn-Teller effect in FeCr2S4 and the impurity Jahn-Teller effect in CoCr2S4:Fe2+