<!--#include virtual="/NR/System/WBC/Internals/Main/WBCApp.inc"-->
<!--#include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/PageOperation/EditMode/InternalProgrammingConstants.inc" -->
<!--#include virtual="/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/PageOperation/EditMode/EntryProgrammingConstants.inc" -->
<!--#include virtual="/NR/System/WBC/Customizable/WBCFuncPagesConfig/UIStringConstants/PageOperationUIStrings.inc" -->

<%
' ********************************************************************
' Copyright (C) 2001 Microsoft Corporation. All rights reserved.
'
'	IMPORTANT.  Please read the legal.txt file, located in the
'	"<CMS Install Directory>\Server\httpexec\WBC\Internals"
'	directory, governing the use of this internal file."
' ********************************************************************

' ********************************************************************
' File:		/NR/System/WBC/Internals/WBCFuncPages/Cross-Browser/PageOperation/
'			/EditMode/PageMove/PageMoveAcceptor/CNCASPPageManager_PageMoveAcceptor.inc
' Version: 	Microsoft Content Management Server
' Author:	Microsoft Corporation.
' Purpose:	Encapsulate the ASP logic associated with PageMoveAcceptor.asp
'
' Implements the INCASPPageManager interface:
'	- Sub InitManager()
'
' Exposes the following properties:
'	- Property URLGoBackEditModeLink
'	- Property DestinationChannelNode
'	- Property CurrentPostingNode
'	- Property Charset
' 	- Property Error
' ********************************************************************

Class CNCASPPageManager_PageMoveAcceptor

	'The URL that is going to go back to the edit mode when everything is successful
	Public URLGoBackEditModeLink

	'The destination channel node will be hosting the moved posting
	Public DestinationChannelNode

	'The posting that is going to be moving to the new channel
	Public CurrentPostingNode

	'CharSet
	Public Charset

	' -- Error code
	Public Error


	' ---- [Private] Class standard initialization routine
	Private Sub Class_Initialize()
		URLGoBackEditModeLink = "#"
		Set DestinationChannelNode = Nothing
		Set CurrentPostingNode = Nothing
		Error = ""
	End Sub


	' ---- [Public] InitManager will take care of all programming logic in the ASP page
	Public Sub InitManager()
		Dim pPostingAfterMove

		Call SetupCharset

		Call ReadQueryString

		If Error = "" Then
			Call ReadFormElement
		End If

		If Error = "" Then
			Call DoMove(pPostingAfterMove)
		End If

		If Error = "" Then
			Call SetupEditModeURL
		End If

	End Sub

	' ---- [Private] Get the charset for multi-lingual display
	Private Sub SetupCharset
		Charset = AutoSession.ThisPosting.Charset
	End Sub

	' ---- [Private] Get the query string to make sure the pass in posting guid is an existing posting
	Private Sub ReadQueryString()
		Dim strPostingGUID
		Dim pPosting

		strPostingGUID = Request.QueryString(IDS_QSTR_PAGEOPERATIONEDIT_SOURCEPAGE)

		If strPostingGUID = "" Then
			Error = IDS_UI_PAGE_DOES_NOT_EXIST
		Else
			Set CurrentPostingNode = AutoSession.Searches.GetByGUID(strPostingGuid)
			If CurrentPostingNode Is Nothing Then
				Error = IDS_UI_PAGE_DOES_NOT_EXIST
			End If
		End If
	End Sub

	' ---- [Private] Get the channel guid that the user has selected. This channel is going to be the channel that
	'                the page will Move to
	Private Sub ReadFormElement()

		Dim pFormReader
		Dim strChannelGuid

		Set pFormReader = GetInitializedFormReaderSafe(False)

		If (pFormReader.Form.Count <= 0) Then
			Error = IDS_UI_ERROR_NO_ITEMS_IN_FORM
		End If

		strChannelGuid = pFormReader.Form(IDS_FORM_CHANNEL_GUID)

		If strChannelGuid = "" Then
			Error = IDS_UI_ERROR_CHANNEL_NOT_FOUND
		Else
			Set DestinationChannelNode = AutoSession.Searches.GetByGUID(strChannelGuid)
			If DestinationChannelNode Is Nothing Then
				Error = IDS_UI_ERROR_CHANNEL_NOT_FOUND
			End If
		End If

	End Sub

	' ---- [Private]
	Private Sub DoMove(pPostingAfterMove)
		'In case something in here blows up
		On Error Resume Next
		Call AutoSession.ClearLastError()

		Set pPostingAfterMove = CurrentPostingNode.MoveTo(DestinationChannelNode)

		If AutoSession.LastError.ID <> 0 Then
			Call AutoSession.RollbackAll()
			Error = IDS_UI_ERROR_IN_MOVE_PROCESS
			Exit Sub
		End If

		Call AutoSession.CommitAll()
	End Sub


	Private Sub SetupEditModeURL()
		URLGoBackEditModeLink =  GetWBCBasicEditURL(CurrentPostingNode)
	End Sub

End Class

%>
