Issue #1921106 by donatasp: Fixed use of drupal_access_denied() causing 'cannot modify header information' errors.