This is one part of a prayer traditionally said before Mass, in honour of St. Joseph:
O felicem virum, beatum Ioseph, cui datum est Deum, quem multi reges voluerunt videre et non viderunt, audire et non audierunt, non solum videre et audire, sed portare, deosculari, vestire et custodire!
Most translations into English treat "O" as a vocative particle: "O happy man, blessed Joseph ..." But that doesn't make sense, as the phrase is in the accusative case. So it has to be a simple interjection: "Oh! Happy man, blessed Joseph ..."
The next part: cui datum est Deum [...] non solum videre et audire etc. - "to whom was given not only to see and hear God etc." is understandable enough. The prayer itself is rather easy, but it's this initial part I can't make sense of. Maybe it could be an accusative + infinitive construction of some sort? "Oh! To whom it has been given, blessed Joseph not only to see and hear God etc." But that doesn't seem correct either.
Of course, this could be an error, and maybe it was supposed to read O felix vir, beate Ioseph. It is possible, but this prayer was granted an indulgence by Pius VII (reigned 1800-1823) and found its way into the Church's official prayer books. So if it is a mistake, surely someone would have commented on it, corrected it or at least mentioned it in passing, at some point? I can't find anything.