Mechanisms of luminescence tuning and quenching in porous silicon