Changed function to check user permissions - gallery ajaxpage class