There is an unhandled case. Is that intentional? If no, the two ifs could be merged into one (`if(dw_mediamanager.onlyownmedia && $user != JSINFO.user)`).
The same is true for showonlyrecentlyuploaded().