Compartilhar via


PublishingPage.Contact propriedade

Obtém ou define um usuário que possui atualmente este objeto PublishingPage .

Namespace:  Microsoft.SharePoint.Publishing
Assembly:  Microsoft.SharePoint.Publishing (em Microsoft.SharePoint.Publishing.dll)

Sintaxe

'Declaração
Public Property Contact As SPUser
    Get
    Set
'Uso
Dim instance As PublishingPage
Dim value As SPUser

value = instance.Contact

instance.Contact = value
public SPUser Contact { get; set; }

Valor de propriedade

Tipo: Microsoft.SharePoint.SPUser
O objeto SPUser que representa o usuário que possui atualmente este PublishingPage

Exceções

Exceção Condição
[UnauthorizedAccessException]

o usuário atual não tem permissões suficientes para executar essa ação.

Comentários

A propriedade Contact é a propriedade preferencial para acompanhamento SPUser proprietária um PublishingPage. No entanto, se você não especificar um valor de Contact , em seguida, as propriedades LocalContactName, LocalContactEmaile LocalContactImage fornecem informações do usuário que são específicas para esse PublishingPage. Esses valores são relevantes apenas para o especificado PublishingPage e não têm efeito em quaisquer objetos SPUser no site.

A propriedade Contact é mutuamente exclusivos das propriedades LocalContactName, LocalContactEmaile LocalContactImage . Definindo as propriedades de LocalContactName, LocalContactE-mailou LocalContactImage com um valor que não está vazio e não nulo limpa a propriedade Contact . Da mesma forma, a configuração da propriedade de Contact como um valor que não for nulo limpa as propriedades LocalContactName, LocalContactE-maile LocalContactImage .

Você pode definir o valor de Contact para uma referência nula (Nothing no Visual Basic).

Para salvar as alterações após a configuração da propriedade Contact , você deve chamar o método Update .

Para definir esse valor, o usuário deverá ter ambos exibir e editar permissões do PublishingPage., exibir permissões para recuperar a página e para retornar os seus valores de propriedade e editar permissões para alterar o valor.

Exemplos

Este exemplo define algumas propriedades em um objeto PublishingPage , salva os novos valores e publica o PublishingPage.

Antes de compilação e a execução deste exemplo, verifique se essa SPLIstItem é um item de lista na biblioteca de documentos de páginas de um PublishingWeb.

Este exemplo pressupõe que a biblioteca de documentos que contém o SPListItem exige a aprovação de conteúdo.

using PublishingPage = Microsoft.SharePoint.Publishing.PublishingPage;
using SPListItem = Microsoft.SharePoint.SPListItem;
using SPFile = Microsoft.SharePoint.SPFile;
using SPModerationStatusType = Microsoft.SharePoint.SPModerationStatusType;
using PublishingWeb = Microsoft.SharePoint.Publishing.PublishingWeb;
using SPUser = Microsoft.SharePoint.SPUser;
using PageLayout = Microsoft.SharePoint.Publishing.PageLayout;
using PublishingPageCollection = Microsoft.SharePoint.Publishing.PublishingPageCollection;

namespace Microsoft.SDK.SharePointServer.Samples
{
    public static class PublishingPageCodeSamples
    {

        public static void SetPagePropertiesAndApprove(SPListItem listItem, SPUser pageContact)
        {
            //  Replace these variable values and input parameters with your own values.
            //
            // New PublishingPage.Title value
            string newTitle = "your Title";
            //
            // New PublishingPage.Description value
            string newDescription = "your Description";
            //
            // The comment to set when the page is checked in, published, and approved.
            string checkInComment = "Your comments";

            
            // Validate the input parameters.
            //
            if (null == listItem)
            {
                throw new System.ArgumentNullException("listItem");
            }
            if (null == pageContact)
            {
                throw new System.ArgumentNullException("pageContact");
            }

            // Get the PublishingPage wrapper for the SPListItem that was passed in.
            //
            PublishingPage publishingPage = null;
            if (PublishingPage.IsPublishingPage(listItem))
            {
                publishingPage = PublishingPage.GetPublishingPage(listItem);
            }
            else
            {
                throw new System.ArgumentException("This SPListItem is not a PublishingPage", "listItem");
            }

            
            // Check out the page if it is not checked out yet.
            //
            if (publishingPage.ListItem.File.CheckOutStatus == SPFile.SPCheckOutStatus.None)
            {
                publishingPage.CheckOut();
            }

            
            // Set and save some properties on the PublishingPage.
            //
            publishingPage.Title = newTitle;
            publishingPage.Description = newDescription;
            publishingPage.Contact = pageContact;
            publishingPage.Update();

            
            // Publish the page, and approve it if required, so that the updated 
            // values are visible on the published Web site.
            //
            publishingPage.CheckIn(checkInComment);
            SPFile pageFile = publishingPage.ListItem.File;
            pageFile.Publish(checkInComment);
            pageFile.Approve(checkInComment);
        }
    }
}
Imports PublishingPage = Microsoft.SharePoint.Publishing.PublishingPage
Imports SPListItem = Microsoft.SharePoint.SPListItem
Imports SPFile = Microsoft.SharePoint.SPFile
Imports SPModerationStatusType = Microsoft.SharePoint.SPModerationStatusType
Imports PublishingWeb = Microsoft.SharePoint.Publishing.PublishingWeb
Imports SPUser = Microsoft.SharePoint.SPUser
Imports PageLayout = Microsoft.SharePoint.Publishing.PageLayout
Imports PublishingPageCollection = Microsoft.SharePoint.Publishing.PublishingPageCollection

Namespace Microsoft.SDK.SharePointServer.Samples
    Public NotInheritable Class PublishingPageCodeSamples

        Private Sub New()
        End Sub
        Public Shared Sub SetPagePropertiesAndApprove(ByVal listItem As SPListItem, ByVal pageContact As SPUser)
            '  Replace these variable values and input parameters with your own values.
            '
            ' New PublishingPage.Title value
            Dim newTitle As String = "your Title"
            '
            ' New PublishingPage.Description value
            Dim newDescription As String = "your Description"
            '
            ' The comment to set when the page is checked in, published, and approved.
            Dim checkInComment As String = "Your comments"


            ' Validate the input parameters.
            '
            If Nothing Is listItem Then
                Throw New System.ArgumentNullException("listItem")
            End If
            If Nothing Is pageContact Then
                Throw New System.ArgumentNullException("pageContact")
            End If

            ' Get the PublishingPage wrapper for the SPListItem that was passed in.
            '
            Dim publishingPage As PublishingPage = Nothing
            If PublishingPage.IsPublishingPage(listItem) Then
                publishingPage = PublishingPage.GetPublishingPage(listItem)
            Else
                Throw New System.ArgumentException("This SPListItem is not a PublishingPage", "listItem")
            End If


            ' Check out the page if it is not checked out yet.
            '
            If publishingPage.ListItem.File.CheckOutStatus = SPFile.SPCheckOutStatus.None Then
                publishingPage.CheckOut()
            End If


            ' Set and save some properties on the PublishingPage.
            '
            publishingPage.Title = newTitle
            publishingPage.Description = newDescription
            publishingPage.Contact = pageContact
            publishingPage.Update()


            ' Publish the page, and approve it if required, so that the updated 
            ' values are visible on the published Web site.
            '
            publishingPage.CheckIn(checkInComment)
            Dim pageFile As SPFile = publishingPage.ListItem.File
            pageFile.Publish(checkInComment)
            pageFile.Approve(checkInComment)
        End Sub
    End Class
End Namespace

Ver também

Referência

PublishingPage classe

PublishingPage membros

Microsoft.SharePoint.Publishing namespace