Function GROUP_AUDIT_EVENTS(CtrlEntId, Event, Param1, Param2, Param3, Param4, Param5, Param6, Param7, Param8, Param9, Param10, Param11, Param12, Param13, Param14, Param15)
/***********************************************************************************************************************

    This program is proprietary and is not to be used by or disclosed to others, nor is it to be copied without written
    permission from SRP Computer Solutions, Inc.

    Name        :   GROUP_AUDIT_EVENTS

    Description :   This function acts as a commuter module for all events related to this window.

    Notes       :   Commuter Modules are automatically called from the Promoted_Events function which is called by the
                    application-specific promoted event handler. This makes it possible to add QuickEvents that need to
                    execute Basic+ logic without having use the Form Designer to make the association, although this is
                    limited to the events which are currently promoted.

                    If the form needs to call the commuter module directly then the QuickEvent parameters should be
                    formatted like this:                                        

                        '@SELF','@EVENT',['@PARAM1','@PARAMx']

    Parameters  :
        CtrlEntId   [in] -- The fully qualified name of the control calling the promoted event
        Event       [in] -- The event being executed. See the Notes section regarding "PRE" events
        Param1-15   [in] -- Additional event parameter holders
        EventFlow  [out] -- Set to 1 or 0 so the calling event knows whether or not to chain forward. See comments in
                            EVENT_SETUP insert

    History (Date, Initials, Notes)
        12/02/20    jro     Original programmer.

***********************************************************************************************************************/

#pragma precomp SRP_PreCompiler
#window GROUP_AUDIT

$insert MSG_EQUATES
$insert POPUP_EQUATES

Equ EVENT_CONTINUE$             to 1
Equ EVENT_CONTINUE_NO_SYSTEM$   to 3
Equ EVENT_STOP$                 to 0
Equ CRLF$                       to \0D0A\

Declare subroutine  Set_Property, Send_Event, Post_Event, Send_Message, SendMessage, Error_Services
Declare function    Get_Property, Send_Message, SendMessage, Lsl_Users_Services, Error_Services, Popup

// Get the design time name of the window in case this is a multi-instance window.
Window = @Window[1, 'F*']

// Always get the CtrlClassID since we are not passing it through the event parameters.
CtrlClassId = Get_Property(CtrlEntId, 'TYPE')

// Get the name of the control on the window based on the CtrlClassId.
Begin Case
    Case CtrlClassId EQ 'WINDOW'
        Control = Window
    Case CtrlClassId EQ 'RADIOBUTTON'
        Control = Field(CtrlEntId, '.', 2, 2)
    Case CtrlClassId EQ 'MENU'
        Control = CtrlEntId[-1, 'B.']
    Case 1
        Control = Field(CtrlEntId, '.', 2, 1)
End Case

If Event EQ 'OLE' then GoSub TransferParams
GoToEvent Event for CtrlEntID
If Event EQ 'OLE' then GoSub RestoreParams

Return EventFlow OR EVENT_CONTINUE$


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Events
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Event WINDOW.CREATE(CreateParam)

	GoSub SetupOLEControls

end event

Event PUB_SELECT_GROUP.CLICK()
	Groups = Lsl_Users_Services('GetGroups')
	if Error_Services('NoError') then
		Convert @FM to @VM in Groups
		PopupOverride = ''
		PopupOverride<PDISPLAY$> = Groups
		GroupArray = Popup(@Window,PopupOverride, 'GROUP_SELECTION')
		Set_Property(@Window:'.EDT_SECURITY_GROUPS', 'LIST', GroupArray)
	end else
		Error_Services('DisplayError')
	end
end event

Event PUB_SEARCH.CLICK()
	Groups = Get_Property(@Window:'.EDT_SECURITY_GROUPS', 'ARRAY')<1>
	IF Groups NE '' then
		Convert @VM to @FM in Groups
		SearchResults = Lsl_Users_Services('GetMembersInGroup', Groups)
		Set_Property(@Window:'.EDT_SEARCH_RESULTS','LIST',SearchResults)
	end else
		Msg(@Window,'No Group Selec')
	end
	
end event







////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Internal Gosubs
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

SetupOLEControls:

    // All OLE controls can use this qualify configuration.
    Qualify     = ''
    Qualify<1>  = 1
    Qualify<3>  = ''
    Qualify<4>  = 0

    
return


TransferParams:

    // ActiveX controls pass their own event names through Param1. Modify the parameter values so they conform to
    // OpenInsight event parameter values. This will allow commuter modules to be structured the same for OpenInsight
    // event and ActiveX (OLE) events.
    Transfer Param1  to Event
    Transfer Param2  to Param1
    Transfer Param3  to Param2
    Transfer Param4  to Param3
    Transfer Param5  to Param4
    Transfer Param6  to Param5
    Transfer Param7  to Param6
    Transfer Param8  to Param7
    Transfer Param9  to Param8
    Transfer Param10 to Param9
    Transfer Param11 to Param10
    Transfer Param12 to Param11
    Transfer Param13 to Param12
    Transfer Param14 to Param13
    Transfer Param15 to Param14

return


RestoreParams:

    // Restore the event parameters so the rest of the event chain will see the parameter values as they were originally
    // created by OpenInsight. This will also prevent the parameter values from being transferred multiple times in case
    // there are multiple OLE promoted event handlers (e.g. APPNAME*..OIWIN* and APPNAME*OLE..OIWIN*).
    Transfer Param14 to Param15
    Transfer Param13 to Param14
    Transfer Param12 to Param13
    Transfer Param11 to Param12
    Transfer Param10 to Param11
    Transfer Param9  to Param10
    Transfer Param8  to Param9 
    Transfer Param7  to Param8 
    Transfer Param6  to Param7
    Transfer Param5  to Param6
    Transfer Param4  to Param5
    Transfer Param3  to Param4
    Transfer Param2  to Param3
    Transfer Param1  to Param2
    Transfer Event   to Param1
    Event             = 'OLE'

return


