Make compatible with ownCloud 7

The code is ugly and not very nice but works (TM) which is what @stp-ip wanted ;-)
same here