added code for image viewing restrictions
added logic for checking permission to edit images