SPModerationInformation class
Provides information about the content approval status for an item in a list or a document library.
Inheritance hierarchy
System.Object
Microsoft.SharePoint.SPModerationInformation
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Class SPModerationInformation
'Usage
Dim instance As SPModerationInformation
public class SPModerationInformation
Examples
The following code example iterates through all the document libraries with content approval enabled on every site in the current site collection, and displays the URLs of all pending documents.
Note
For information about how to use Language-Integrated Query (LINQ) queries to retrieve list items in SharePoint Foundation, see Managing Data with LINQ to SharePoint.
Dim siteCollection As New SPSite("https://localhost")
Dim subSites As SPWebCollection = siteCollection.AllWebs
Dim site As SPWeb
For Each site In subSites
Dim lists As SPListCollection = site.Lists
Dim list As SPList
For Each list In lists
If list.BaseType = SPBaseType.DocumentLibrary Then
Dim docLibrary As SPDocumentLibrary =
CType(list, SPDocumentLibrary)
If Not docLibrary.IsCatalog AndAlso
docLibrary.EnableModeration = True Then
Dim allItemsQuery As New SPQuery()
allItemsQuery.ViewAttributes =
"ModerationType='Moderator'"
Dim docLibItems As SPListItemCollection =
docLibrary.GetItems(allItemsQuery)
Dim docLibItem As SPListItem
For Each docLibItem In docLibItems
If docLibItem.ModerationInformation.Status =
SPModerationStatusType.Pending Then
Console.WriteLine(site.Url + "/" +
docLibItem.File.Url)
End If
Next docLibItem
End If
End If
Next list
Next site
using (SPSite oSiteCollection = new SPSite("https://localhost"))
{
SPWebCollection collWebsites = oSiteCollection.AllWebs;
foreach (SPWeb oWebsite in collWebsites)
{
SPListCollection collLists = oWebsite.Lists;
foreach (SPList oList in collLists)
{
if (oList.BaseType == SPBaseType.DocumentLibrary)
{
SPDocumentLibrary oDocLibrary = (SPDocumentLibrary)oList;
if (!oDocLibrary.IsCatalog && oDocLibrary.EnableModeration == true)
{
SPQuery oQuery = new SPQuery();
oQuery.ViewAttributes = "ModerationType='Moderator'";
SPListItemCollection collListItems = oDocLibrary.GetItems(oQuery);
foreach (SPListItem oListItem in collListItems)
{
if (oListItem.ModerationInformation.Status == SPModerationStatusType.Pending)
{
Console.WriteLine(oWebsite.Url + "/" + oListItem.File.Url);
}
}
}
}
}
oWebsite.Dispose();
}
}
Note
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.
Thread safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.