option explicit

!INC Local Scripts.EAConstants-VBScript

'
' This code has been included from the default Workflow template.
' If you wish to modify this template, it is located in the Config\Script Templates
' directory of your EA install path.   
'
' Script Name:
' Author:
' Purpose:
' Date:
'

' ================================================================================================
' SCRIPT GLOBALS
' ================================================================================================
' How to advise the user of validation errors. Use this global when calling SetLastError eg:
' SetLastError "A validation error occured", ERROR_OUTPUT
dim ERROR_OUTPUT
ERROR_OUTPUT = "MessageBox"

' ================================================================================================
' ELEMENT/CONNECTOR CREATION
' ================================================================================================
' The methods in this section may be used to restrict the creation of Elements and Connectors.
'
' For each of the calls below, the objects WorkflowUser and WorkflowContext are accessible to query
' for information about the currently logged in user and currently selected item respectively.
' 
' The user can be notified of any validation errors/notifications through the SetLastError function.
'
' For more information on the WorkflowUser, WorkflowContext and WorkflowStatus objects, please
' consult the 'Workflow Script Functions' section of the Enterprise Architect user guide.
' ================================================================================================
'
' Advises Enterprise Architect whether the current user (WorkflowUser) is allowed create an element
' of the provided type/stereotype.
'
' @return A boolean value specifying whether the current user is permitted to create the specified
' element
'
public function OnPreNewElement( ElementType, ElementStereotype )

	' Obtain a reference to the current user
	dim currentUser
	set currentUser = WorkflowUser

	OnPreNewElement = true
	
end function

'
' Advises Enterprise Architect whether the current user (WorkflowUser) is allowed create a connector
' of the provided type/subtype/stereotype.
'
' @return A boolean value specifying whether the current user is permitted to create the specified
' connector
'
public function OnPreNewConnector( ConnectorType, ConnectorSubType, ConnectorStereotype )

	' Obtain a reference to the current user
	dim currentUser
	set currentUser = WorkflowUser
	
	OnPreNewConnector = true
	
end function

' ================================================================================================
' ELEMENT PROPERTY VALIDATION
' ================================================================================================
' The methods in this section may be used to restrict modification of various Element properties.
'
' For each of the calls below, the objects WorkflowUser and WorkflowContext are accessible to query
' for information about the currently logged in user and currently selected item respectively.
' 
' The user can be notified of any validation errors/notifications through the SetLastError function.
'
' For more information on the WorkflowUser, WorkflowContext and WorkflowStatus objects, please
' consult the 'Workflow Script Functions' section of the Enterprise Architect user guide.
' ================================================================================================

'---------------------------------------------------------------------------------------------------
' Phase
'---------------------------------------------------------------------------------------------------
'
' Advises Enterprise Architect whether the current user (WorkflowUser) is allowed to make changes to 
' the currently selected item's (WorkflowContext) phase property. If this function returns FALSE, 
' then UI controls that allow changes to the currently selected item's phase value will be disabled.
'
' @return A boolean value specifying whether the current user is permitted to make changes to the
' currently selected item's phase property
'
public function CanEditPhase()

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    CanEditPhase = true
	
end function

'
' Determines what additional information is required to validate a requested change to the phase
' property of the currently selected item (WorkflowContext).
' 
' @param OldValue The current value of the selected item's phase property
' @param NewValue The value that the currently selected user wishes to change the selected item's 
' phase value to
'
' @return A semi-colon separated list of additional data required in order to validate this change.
'
public function PreAllowPhaseUpdate( OldValue, NewValue )

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    PreAllowPhaseUpdate = ""
	
end function

'
' Determines whether the proposed change to the currently selected item's (WorkflowContext) phase 
' value should be accepted. 
' NOTE: If changes to the phase value are rejected by this function, the user can be advised of
' the cause of the validation error through the SetLastError function.
'
' @param OldValue The current value of the selected item's phase property
' @param NewValue The value that the currently selected user wishes to change the selected item's 
' phase value to
'
' @return A boolean value indicating whether the proposed change to the selected item's phase value
' should be accepted.
'
public function AllowPhaseUpdate( OldValue, NewValue )

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    AllowPhaseUpdate = true
	
end function

'---------------------------------------------------------------------------------------------------
' Status
'---------------------------------------------------------------------------------------------------
'
' Advises Enterprise Architect whether the current user (WorkflowUser) is allowed to make changes to 
' the currently selected item's (WorkflowContext) status property. If this function returns FALSE, 
' then UI controls that allow changes to the currently selected item's status value will be disabled.
'
' @return A boolean value specifying whether the current user is permitted to make changes to the
' currently selected item's status property
'
public function CanEditStatus()

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    CanEditStatus = true
	
end function

'
' Determines what additional information is required to validate a requested change to the status
' property of the currently selected item (WorkflowContext).
' 
' @param OldValue The current value of the selected item's status property
' @param NewValue The value that the currently selected user wishes to change the selected item's 
' status value to
'
' @return A semi-colon separated list of additional data required in order to validate this change.
'
public function PreAllowStatusUpdate( OldValue, NewValue )

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    PreAllowStatusUpdate = ""
	
end function

'
' Determines whether the proposed change to the currently selected item's (WorkflowContext) status 
' value should be accepted. 
' NOTE: If changes to the status value are rejected by this function, the user can be advised of
' the cause of the validation error through the SetLastError function.
'
' @param OldValue The current value of the selected item's status property
' @param NewValue The value that the currently selected user wishes to change the selected item's 
' status value to
'
' @return A boolean value indicating whether the proposed change to the selected item's status value
' should be accepted.
'
public function AllowStatusUpdate( OldValue, NewValue )

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    AllowStatusUpdate = true
	
end function

'---------------------------------------------------------------------------------------------------
' Tagged Values
'---------------------------------------------------------------------------------------------------
'
' Advises Enterprise Architect whether the current user (WorkflowUser) is allowed to make changes to 
' the specified Tagged Value that belongs to the currently selected item (WorkflowContext). If this 
' function returns FALSE, then UI controls that allow changes to the Tagged Value will be disabled.
'
' @param TagName The name of the tagged value in question
'
' @return A boolean value specifying whether the current user is permitted to make changes to the
' specified Tagged Value
'
public function CanEditTag( TagName )

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    CanEditTag = true
	
end function

'
' Determines what additional information is required to validate a requested change to the specified
' Tagged Value belonging to the currently selected item (WorkflowContext).
' 
' @param TagName The name of the tagged value in question
' @param OldValue The current value of the specified Tagged Value
' @param NewValue The value that the currently selected user wishes to change the specified Tagged
' Value to
'
' @return A semi-colon separated list of additional data required in order to validate this change.
'
public function PreAllowTagUpdate( TagName, OldValue, NewValue )

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext
	
    PreAllowTagUpdate = ""
	
end function

'
' Determines whether the proposed change to the specified Tagged Value belonging to the currently 
' selected item (WorkflowContext) should be accepted. 
' NOTE: If changes to the Tagged Value are rejected by this function, the user can be advised of
' the cause of the validation error through the SetLastError function.
'
' @param TagName The name of the tagged value in question
' @param OldValue The current value of the selected item's status property
' @param NewValue The value that the currently selected user wishes to change the selected item's 
' status value to
'
' @return A boolean value indicating whether the proposed change to the selected item's status value
' should be accepted.
'
public function AllowTagUpdate( TagName, OldValue, NewValue )

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    AllowTagUpdate = true
	
end function

'---------------------------------------------------------------------------------------------------
' Version
'---------------------------------------------------------------------------------------------------
'
' Advises Enterprise Architect whether the current user (WorkflowUser) is allowed to make changes to 
' the currently selected item's (WorkflowContext) version property. If this function returns FALSE, 
' then UI controls that allow changes to the currently selected item's version value will be 
' disabled.
'
' @return A boolean value specifying whether the current user is permitted to make changes to the
' currently selected item's version property
'
public function CanEditVersion()

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    CanEditVersion = true
	
end function

'
' Determines what additional information is required to validate a requested change to the version
' property of the currently selected item (WorkflowContext).
' 
' @param OldValue The current value of the selected item's version property
' @param NewValue The value that the currently selected user wishes to change the selected item's 
' version value to
'
' @return A semi-colon separated list of additional data required in order to validate this change.
'
public function PreAllowVersionUpdate( OldValue, NewValue )

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    PreAllowVersionUpdate = ""
	
end function

'
' Determines whether the proposed change to the currently selected item's (WorkflowContext) version 
' value should be accepted. 
' NOTE: If changes to the version value are rejected by this function, the user can be advised of
' the cause of the validation error through the SetLastError function.
'
' @param OldValue The current value of the selected item's version property
' @param NewValue The value that the currently selected user wishes to change the selected item's 
' version value to
'
' @return A boolean value indicating whether the proposed change to the selected item's version 
' value should be accepted.
'
public function AllowVersionUpdate( OldValue, NewValue )

	' Obtain a reference to the current user and selected item
	dim currentUser, currentItem
	set currentUser = WorkflowUser
	set currentItem = WorkflowContext

    AllowVersionUpdate = true
	
end function


' ================================================================================================
' WORKFLOW SEARCHES
' ================================================================================================
'
' Add any required searches to WorkflowSearches
'
public function GetWorkflowTasks

	redim WorkflowSearches(0)
	
end function

