<?xml version="1.0" encoding="UTF-8"?>
<ajxp_plugin id="action.scheduler" enabled="true" label="CONF_MESSAGE[Tasks Scheduler]" description="CONF_MESSAGE[Register tasks to be run on a regular basis instead of writing them one by one in cron tab.]"  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
    <client_settings>
        <resources>
            <i18n namespace="action.scheduler" path="plugins/action.scheduler/i18n"/>
            <js className="SchedulerActions" file="plugins/action.scheduler/res/build/SchedulerActions.js"/>
        </resources>
    </client_settings>
    <registry_contributions>
        <actions>
            <action name="scheduler_menu">
                <gui text="action.scheduler.18" iconClass="icon-time" title="action.scheduler.18d" hasAccessKey="false">
                    <context selection="false" dir="" recycle="hidden" allowedMimes="scheduler_zone"
                             actionBar="true" contextMenu="false" infoPanel="false" actionBarGroup="put"/>
                </gui>
                <subMenu>
                    <dynamicItems>
                        <item actionId="scheduler_addTask"></item>
                        <item actionId="scheduler_runAll"></item>
                        <item actionId="scheduler_generateCronExpression"></item>
                    </dynamicItems>
                </subMenu>
            </action>
            <action name="scheduler_generateCronExpression">
                <gui text="action.scheduler.20" title="action.scheduler.20d" iconClass="icon-paste" hasAccessKey="false">
                    <context selection="false" dir="" recycle="hidden" allowedMimes="scheduler_zone"
                             actionBar="false" contextMenu="true" infoPanel="true"
                             actionBarGroup="user"/>
                </gui>
                <processing>
                    <clientCallback module="SchedulerActions.Callbacks.generateCron"/>
                    <clientForm id="scheduler_cronExpression"><![CDATA[
                         <div id="scheduler_cronExpression" box_width="420">
                             <div class="dialogLegend" ajxp_message_id="action.scheduler.21">AJXP_MESSAGE[action.scheduler.21]</div>
                             <textarea class="dialogFocus" style="width:350px;height:80px; margin-top: 5px;" id="cron_expression"></textarea>
                         </div>
                    ]]></clientForm>
                    <serverCallback methodName="switchAction" developerComment="Generate a correct expression to be inserted in Crontab, in order to trigger the {runAll} action on a regular basis."/>
                </processing>
            </action>
            <action name="scheduler_runAll">
                <gui text="action.scheduler.15" title="action.scheduler.16d" iconClass="icon-play-circle" hasAccessKey="false">
                    <context selection="false" dir="" recycle="hidden" allowedMimes="scheduler_zone"
                             actionBar="false" contextMenu="true" infoPanel="true"
                             actionBarGroup="user"/>
                </gui>
                <processing>
                    <clientCallback module="SchedulerActions.Callbacks.runAll"/>
                    <serverCallback methodName="switchAction" restParams="/" developerComment="Run the scheduler: check if some tasks must be run now, and launch them. Generally launched from command line."/>
                </processing>
            </action>
            <action name="scheduler_loadTask">
                <processing>
                    <serverCallback methodName="handleTasks" developerComment="Returns a JSON representation of the task parameters">
                        <input_param description="The id of the task to run" name="task_id" type="string" mandatory="true"/>
                    </serverCallback>
                </processing>
            </action>
            <action name="scheduler_addTask">
                <processing>
                    <clientCallback module="SchedulerActions.Callbacks.addTask"/>
                    <clientForm id="scheduler-task-form"><![CDATA[
                        <div id="scheduler-task-form" box_width="300"></div>
                    ]]></clientForm>
                    <standardFormDefinition>
                        <param name="label" group="action.scheduler.23" label="action.scheduler.12" description="action.scheduler.12d" type="string" mandatory="true"/>
                        <param name="schedule" group="action.scheduler.23" label="action.scheduler.2" description="action.scheduler.2d" type="string" mandatory="true"/>
                        <param name="user_id" group="action.scheduler.23" label="action.scheduler.17" description="action.scheduler.17d" type="string" mandatory="true" default=""/>
                        <param name="repository_id" group="action.scheduler.23" replicationGroup="group2" label="action.scheduler.4" description="action.scheduler.4d" type="select" choices="" mandatory="true"/>
                        <param name="action_name" group="action.scheduler.24" label="action.scheduler.1" description="action.scheduler.1d" type="select" choices="json_list:list_all_plugins_actions" mandatory="true"/>
                        <param name="param_name" group="action.scheduler.24" replicationGroup="group1" label="action.scheduler.6" description="action.scheduler.6d" type="string" mandatory="false"/>
                        <param name="param_value" group="action.scheduler.24" replicationGroup="group1" label="action.scheduler.7" description="action.scheduler.7d" type="string" mandatory="false"/>
                    </standardFormDefinition>
                    <serverCallback methodName="handleTasks" developerComment="Create a new task by posting parameters">
                        <input_param description="All parameters generated by the FormManager (label, schedule, user_id, repository_id, action_name, one or more param_name / param_value)" name="FORM_DATA"
                                     type="FORM_DATA"/>
                    </serverCallback>
                </processing>
            </action>
            <action name="scheduler_runTask">
                <gui text="action.scheduler.16" title="action.scheduler.15d" iconClass="icon-play" hasAccessKey="false">
                    <context selection="true" dir="" recycle="hidden" allowedMimes="scheduler_zone"
                             actionBar="true" contextMenu="true" infoPanel="true"
                             actionBarGroup="get"/>
                    <selectionContext dir="false" behaviour="hidden" file="true" recycle="false" unique="true" allowedMimes="scheduler_task"/>
                </gui>
                <processing>
                    <clientCallback module="SchedulerActions.Callbacks.runTask"/>
                    <serverCallback methodName="switchAction" developerComment="Force running a specific task">
                        <input_param description="The id of the task to run" name="task_id" type="string" mandatory="true"/>
                    </serverCallback>
                </processing>
            </action>
            <action name="scheduler_editTask">
                <gui text="action.scheduler.10" title="action.scheduler.11" iconClass="mdi mdi-pencil" hasAccessKey="false">
                    <context selection="true" dir="" recycle="hidden" allowedMimes="scheduler_zone"
                             actionBar="true" contextMenu="true" infoPanel="true"
                             actionBarGroup="get"/>
                    <selectionContext dir="false" file="true" behaviour="hidden" recycle="false" unique="true" allowedMimes="scheduler_task"/>
                </gui>
                <processing>
                    <clientCallback module="SchedulerActions.Callbacks.editTask"/>
                </processing>
            </action>
            <action name="scheduler_removeTask">
                <gui text="action.scheduler.19" title="action.scheduler.12" iconClass="icon-trash" hasAccessKey="false">
                    <context selection="true" dir="" recycle="hidden" allowedMimes="scheduler_zone"
                             actionBar="true" contextMenu="true" infoPanel="true"
                             actionBarGroup="get"/>
                    <selectionContext dir="false" file="true" behaviour="hidden" recycle="false" unique="true" allowedMimes="scheduler_task,scheduler_error_task"/>
                </gui>
                <processing>
                    <clientCallback module="SchedulerActions.Callbacks.removeTask"/>
                    <serverCallback methodName="handleTasks" developerComment="Remove a given task from scheduler">
                        <input_param description="Id of the task to delete" name="task_id" type="string" mandatory="true"/>
                    </serverCallback>
                </processing>
            </action>
            <action name="scheduler_stopRunningTask">
                <gui text="action.scheduler.25" title="action.scheduler.26" iconClass="icon-stop" hasAccessKey="false">
                    <context selection="true" dir="" recycle="hidden" allowedMimes="scheduler_zone"
                             actionBar="true" contextMenu="true" infoPanel="true"
                             actionBarGroup="get"/>
                    <selectionContext dir="false" file="true" behaviour="hidden" recycle="false" unique="true" allowedMimes="scheduler_running_task"/>
                </gui>
                <processing>
                    <clientCallback module="SchedulerActions.Callbacks.stopTask"/>
                </processing>
            </action>
            <action name="scheduler_fakeLongTask">
                <processing>
                    <serverCallback methodName="fakeLongTask" developerComment="Launch a fake long task."/>
                </processing>
            </action>
            <action name="scheduler_checkConfig">
                <rightsContext adminOnly="true" noUser="false" read="true" userLogged="true" write="true"/>
                <processing>
                    <serverCallback methodName="switchAction" developerComment="Check scheduler configuration"/>
                </processing>
            </action>
        </actions>
        <hooks>
            <serverCallback methodName="placeConfigNode" hookName="ajxp_conf.list_config_nodes"/>
            <serverCallback methodName="placeConfigNode" hookName="admin.list_config_nodes"/>
        </hooks>
    </registry_contributions>
    <class_definition filename="plugins/action.scheduler/vendor/autoload.php" classname="Pydio\Action\Scheduler\Scheduler"/>
    <dependencies>
        <activePlugin pluginName="access.ajxp_conf|access.ajxp_admin"/>
    </dependencies>
</ajxp_plugin>
