Change Foreign Key relationship for ResourceBase and Thumbnail

Prevents duplicate thumbnails in db when updatelayers is run

Cascade deletes Thumbnails with ResourceBase removal
Merge pull request #1672 from mwengren/thumbnail_fix

Change Foreign Key relationship for ResourceBase and Thumbnail
check if the user has the perms to save an existing map. fixes #1645