Scheduled Task Module#
Description#
This module implements the scheduled task feature. This module allows you to enter a URL to hit and the task interval.
The compiled module can be downloaded here
Note
The module implements the util feature just so it can be assigned to the store.
Snippet#
<MvFUNCTION NAME = "Module_Description" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
<MvASSIGN NAME = "l.module:code" VALUE = "call_url_stsk">
<MvASSIGN NAME = "l.module:name" VALUE = "HTTP Request to URL">
<MvASSIGN NAME = "l.module:provider" VALUE = "Miva Merchant">
<MvASSIGN NAME = "l.module:version" VALUE = "9.0003">
<MvASSIGN NAME = "l.module:api_ver" VALUE = "9.05">
<MvASSIGN NAME = "l.module:description" VALUE = "This Scheduled Task allows you to setup a URL which will get called via an http request when the task is run.">
<MvASSIGN NAME = "l.module:features" VALUE = "util, vis_util, scheduledtask">
</MvFUNCTION>
<MvCOMMENT>
|
| Feature util
|
</MvCOMMENT>
<MvFUNCTION NAME = "StoreUtilityModule_Action" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "StoreUtilityModule_LeftNavigation" PARAMETERS = "module var, indent" STANDARDOUTPUTLEVEL = "">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "StoreUtilityModule_Screen" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "StoreUtilityModule_Validate" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvCOMMENT>
|
| Feature vis_util
|
</MvCOMMENT>
<MvFUNCTION NAME = "Module_Utility_Content" PARAMETERS = "module var, tab, load_fields" STANDARDOUTPUTLEVEL = "text, html, compresswhitespace">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "Module_Utility_Head" PARAMETERS = "module var, tab" STANDARDOUTPUTLEVEL = "text, html, compresswhitespace">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "Module_Utility_Tabs" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
<MvFUNCTIONRETURN VALUE = "">
</MvFUNCTION>
<MvFUNCTION NAME = "Module_Utility_Update" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "Module_Utility_Validate" PARAMETERS = "module var" STANDARDOUTPUTLEVEL = "">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvCOMMENT>
|
| Scheduled Task Feature (scheduledtask)
|
</MvCOMMENT>
<MvFUNCTION NAME = "ScheduledTaskModule_Capabilities" PARAMETERS = "module var, capabilities var" STANDARDOUTPUTLEVEL = "">
<MvASSIGN NAME = "l.capabilities:provision_settings" VALUE = 1> <MvCOMMENT> This allows you to set module specific provision settings </MvCOMMENT>
<MvCOMMENT> OR </MvCOMMENT>
<MvASSIGN NAME = "l.capabilities:provision" VALUE = 1> <MvCOMMENT> This allows you to add the schedule task via provisioning </MvCOMMENT>
</MvFUNCTION>
<MvFUNCTION NAME = "ScheduledTaskModule_Operations" PARAMETERS = "module var, operations var" STANDARDOUTPUTLEVEL = "">
<MvASSIGN NAME = "l.operations" INDEX = 1 MEMBER = "code" VALUE = "call_url">
<MvASSIGN NAME = "l.operations" INDEX = 1 MEMBER = "descrip" VALUE = "HTTP Request to URL">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "ScheduledTaskModule_Fields" PARAMETERS = "module var, task var" STANDARDOUTPUTLEVEL = "">
<MvASSIGN NAME = "l.fields" VALUE = "">
<MvIF EXPR = "{ l.task:operation EQ 'call_url' }">
<MvASSIGN NAME = "g.ScheduledTasks_Call_Url_Field" VALUE = "{ l.task:config:call_url_field }">
<MvASSIGN NAME = "l.fields" VALUE = "call_url_field">
</MvIF>
<MvFUNCTIONRETURN VALUE = "{ l.fields }">
</MvFUNCTION>
<MvFUNCTION NAME = "ScheduledTaskModule_Invalid" PARAMETERS = "module var, field_id" STANDARDOUTPUTLEVEL = "">
<MvFUNCTIONRETURN VALUE = 0>
</MvFUNCTION>
<MvFUNCTION NAME = "ScheduledTaskModule_Prompt" PARAMETERS = "module var, field_id" STANDARDOUTPUTLEVEL = "">
<MvASSIGN NAME = "l.prompt" VALUE = "">
<MvIF EXPR = "{ l.field_id EQ 'call_url_field' }">
<MvASSIGN NAME = "l.prompt" VALUE = "<b>URL to Hit:</b>">
</MvIF>
<MvFUNCTIONRETURN VALUE = "{ l.prompt }">
</MvFUNCTION>
<MvFUNCTION NAME = "ScheduledTaskModule_Field" PARAMETERS = "module var, field_id" STANDARDOUTPUTLEVEL = "text, html, compresswhitespace">
<MvIF EXPR = "{ l.field_id EQ 'call_url_field' }">
<MvCOMMENT> This can be a input, checkbox, select, radio option or text area </MvCOMMENT>
<input type="text" name="ScheduledTasks_Call_Url_Field" id="ScheduledTasks_Call_Url_Field" value="{ encodeentities( g.ScheduledTasks_Call_Url_Field ) }">
</MvIF>
</MvFUNCTION>
<MvFUNCTION NAME = "ScheduledTaskModule_Validate" PARAMETERS = "module var, task var" STANDARDOUTPUTLEVEL = "">
<MvIF EXPR = "{ l.task:operation EQ 'call_url' }">
<MvASSIGN NAME = "g.ScheduledTasks_Call_Url_Field" VALUE = "{ trim( g.ScheduledTasks_Call_Url_Field ) }">
<MvIF EXPR = "{ ISNULL g.ScheduledTasks_Call_Url_Field }">
<MvFUNCTIONRETURN VALUE = "{ [ g.Module_Admin ].FieldError( '', 'ScheduledTasks_Call_Url_Field', 'Please enter a URL' ) }">
</MvIF>
<MvIF EXPR = "{ NOT (('http://' CIN g.ScheduledTasks_Call_Url_Field) OR ('https://' CIN g.ScheduledTasks_Call_Url_Field)) }">
<MvFUNCTIONRETURN VALUE = "{ [ g.Module_Admin ].FieldError( '', 'ScheduledTasks_Call_Url_Field', 'The URL must start with http:// or https://' ) }">
</MvIF>
</MvIF>
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "ScheduledTaskModule_Update" PARAMETERS = "module var, task var" STANDARDOUTPUTLEVEL = "">
<MvIF EXPR = "{ l.task:operation EQ 'call_url' }">
<MvASSIGN NAME = "l.task:config:call_url_field" VALUE = "{ g.ScheduledTasks_Call_Url_Field }">
</MvIF>
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "ScheduledTaskModule_Delete" PARAMETERS = "module var, task var" STANDARDOUTPUTLEVEL = "">
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvFUNCTION NAME = "ScheduledTaskModule_Execute" PARAMETERS = "module var, task var" STANDARDOUTPUTLEVEL = "">
<MvIF EXPR = "{ l.task:operation EQ 'call_url' }">
<MvFUNCTIONRETURN VALUE = "{ Task_Run( l.task ) }">
</MvIF>
<MvFUNCTIONRETURN VALUE = "{ [ g.Module_Library_Utilities ].Error( 'MER-URL-TASK-1', 'Unsupported operation' ) }">
</MvFUNCTION>
<MvFUNCTION NAME = "ScheduledTaskModule_Provision_Settings" PARAMETERS = "module var, task var, provide_xml var" STANDARDOUTPUTLEVEL = "">
<MvCOMMENT>
<MvIF EXPR = "{ l.task:operation EQ 'test_task' }">
<MvIF EXPR = "{ NOT [ g.Module_Feature_PRV_AD ].PRV_Tag_Number( 'O', l.provide_xml, 'TestTaskField', l.task:config:test_task_field, -1, -1 ) }">
<MvFUNCTIONRETURN VALUE = 0>
</MvIF>
<MvIF EXPR = "{ l.task:config:test_task_field LT 1 OR l.task:config:test_task_field GT 30 }">
<MvFUNCTIONRETURN VALUE = "{ [ g.Module_Feature_PRV_AD ].PRV_LogMessage( l.provide_xml, 'Test task field must be between 1 and 30' ) }">
</MvIF>
</MvIF>
</MvCOMMENT>
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>
<MvCOMMENT>
|
| Helper functions
|
</MvCOMMENT>
<MvFUNCTION NAME = "Task_Run" PARAMETERS = " task var" STANDARDOUTPUTLEVEL = "">
<MvCOMMENT>Use MvCALL to call URL. Response is Ignored.</MvCOMMENT>
<MIVA MvCALL_Error = "nonfatal, nodisplay">
<MvCAPTURE VARIABLE = "l.response">
<MvCALL METHOD = "POST"
ACTION = "{ l.task:config:call_url_field }"
FIELDS = "">
<MvEVAL EXPR = "{ s.callvalue }">
</MvCALL>
</MvCAPTURE>
<MIVA MvCALL_Error = "fatal, display">
<MvCOMMENT>If Error, handle</MvCOMMENT>
<MvIF EXPR = "{ g.MvCALL_Error }">
<MvFUNCTIONRETURN VALUE = "{ [ g.Module_Library_Utilities ].Error( 'MER-URL-TASK-2', 'Failed To Reqest URL: ' $ MvCALL_Error ) }">
</MvIF>
<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>