Shapley Optical Survey - II. The effect of environment on the colour-magnitude relation and galaxy colours