You probably know, that SharePoint document libraries with content approval provide a special view called Approve / reject items.
This view helps users to review the approval status of the documents, without opening the display / edit form of each document.
A few weeks ago I was to create a similar aggregation on the site level using the Content Query Web Part. I used the following custom CAML query to get the list of documents waiting for approval (see the possible value of the corresponding SPModerationStatusType enumeration here):
<Where><Eq><FieldRef Name="_ModerationStatus" /><Value Type="ModStat">2</Value></Eq></Where>
Without delving too deep into further details of implementation, I want to share this time a very strange discovery. In the list of the displayed documents (that should be the list of pending documents) appeared a few documents from a library where the content approval was turned off. At first look it seems to be a bug, however it has a rational reason: the content approval was formerly activated on the library, but later it was deactivated. Documents in the library kept their actual moderation status (value of the hidden _ModerationStatus field is not deleted), that means, after a possible re-activation the original status would be easily recovered.
Minor side-effect for me, that due to this feature my site query does not produce the expected results.
