Changed checking permissions to actionPermission variable - upload ajaxpage
Cleaned code, changed permission of saved thumbnails - gallery module