Backport 3617

Backport of #3963 as part of solution for #3617 

lib/hooks/ are also copied from master, because the Updater class inherits from it. According to @icewind1991  it does not touch other parts of ownCloud, so it is probably more safe to use this instead of writing new code that may contain errors.

While testing I get these messages
```
{"app":"PHP","message":"Cannot modify header information - headers already sent at \/home\/blizzz\/owncloud\/dev\/stable5\/lib\/user.php#653","level":2,"time":1373657467}
{"app":"PHP","message":"Cannot modify header information - headers already sent at \/home\/blizzz\/owncloud\/dev\/stable5\/lib\/user.php#654","level":2,"time":1373657467}
{"app":"PHP","message":"Cannot modify header information - headers already sent at \/home\/blizzz\/owncloud\/dev\/stable5\/lib\/user.php#655","level":2,"time":1373657467}
```

But I get them with current stable5 also → not in the scope of this PR. Besides of this, upgrade worked for me. Though, so far I just tested upgrade in the stable5 branch by decreasing version in config.php. I'd do another final test from a clean 5.0.8 to this state on Monday.

Please give it a good look, because I somehow feel a bit dirty with this backport and we don't want to destroy upgrade experience.

@icewind1991 @DeepDiver1975 @karlitschek @VicDeo @bartv2 (or others :) )