SA police 'foiled terrorist plot'