SPModerationInformation class

Provides information about the content approval status for an item in a list or a document library.

System.Object
  Microsoft.SharePoint.SPModerationInformation

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

'Declaration
Public Class SPModerationInformation
'Usage
Dim instance As SPModerationInformation

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.

NoteNote

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("http://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
NoteNote

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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show: