Add activities for shared users when a file is added or deleted

Fix #1670
Fix activities and links when folders and files are shared:
* When sharing via link, the activity link leads to the user's root instead of the folder
* When sharing an item with a user, the links always lead to the new user's target folder
* When sharing an item with a group, an activity was created for the group
Do not loop over all shares unneccessarily
Fix sharing an item with a group
Do not add activities for .part files

Fix owncloud/core#7950
Change type to string and use one preference per type
Correctly store unselected user setting
Filter users by their settings before adding the activity for them.
Use userid as key in filtered list to allow isset() checks
Correctly initialise $user
Fix order of arguments in array_chunk()
Fix some small failures in the template
Prepare code layout and loops for email settings
Fix getSourcePathAndOwner() for reshares
Do not work on results of failed queries
Add simple methods for fixed create and update hooks
Remove old wrapper
Remove translation strings from database
Better translation for activities
Fix parameter order in shared_with_by