<?xml version="1.0" encoding="UTF-8"?>
<ajxp_plugin id="core.mailer" label="CONF_MESSAGE[Mailers]" description="CONF_MESSAGE[Core configs for sending emails]" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
    <class_definition classname="AjxpMailer" filename="plugins/core.mailer/class.AjxpMailer.php"/>
    <server_settings>
        <global_param name="MAILER_ACTIVATE_QUEUE" type="boolean" label="CONF_MESSAGE[Activate Queue]" description="CONF_MESSAGE[Store emails in a queue and batch-process them. Users can choose the sending frequency. Make sure to set up a CRON on consume_mail_queue action if you use this option.]" default="false"/>
        <global_param name="UNIQUE_MAILER_INSTANCE" type="plugin_instance:mailer" label="CONF_MESSAGE[Mailer Plugin]" description="CONF_MESSAGE[Select the plugin to activate for concretely sending emails]" mandatory="true" default="mailer.phpmailer-lite"/>
        <global_param name="FROM" group="CONF_MESSAGE[Sender]" type="string" label="CONF_MESSAGE[Sender email]" description="CONF_MESSAGE[Adress of the sender]" mandatory="true" default=""/>
        <global_param name="FROM_NAME" group="CONF_MESSAGE[Sender]" type="string" label="CONF_MESSAGE[Sender name]" description="CONF_MESSAGE[Name of the sender]" mandatory="true" default=""/>
        <global_param name="FORCE_UNIQUE_FROM" group="CONF_MESSAGE[Sender]" type="boolean" label="CONF_MESSAGE[Unique Sender]" description="CONF_MESSAGE[Force all mails to be sent by this Sender email, instead of users adresses]" mandatory="true" default="false"/>
        <global_param name="SUBJECT_PREPEND" group="CONF_MESSAGE[Content]" label="CONF_MESSAGE[Subject Prepend]" description="CONF_MESSAGE[String automatically added at the beginning of the mail subject]" type="string" mandatory="false" default=""/>
        <global_param name="SUBJECT_APPEND" group="CONF_MESSAGE[Content]" label="CONF_MESSAGE[Subject Append]" description="CONF_MESSAGE[String automatically added at the end of the mail subject]" type="string" mandatory="false" default=""/>
        <global_param name="BODY_LAYOUT" group="CONF_MESSAGE[Content]" label="CONF_MESSAGE[Body Layout]" description="CONF_MESSAGE[Main Layout for the email body, use HTML for send nice emails, and use the AJXP_MAIL_BODY keyword for the real content.]" type="textarea" mandatory="false" default="AJXP_MAIL_BODY"/>
        <global_param name="LAYOUT_FOLDER" group="CONF_MESSAGE[Content]" label="CONF_MESSAGE[Layout Folder]" description="CONF_MESSAGE[Extract the main layout from a localized file. Will prevail on the previous parameter, make sure to have an AJXP_MAIL_BODY in the layout file.]" type="string" mandatory="false" default="plugins/core.mailer/layout"/>
        <param name="NOTIFICATIONS_EMAIL_GET" type="select" choices="true|AJXP_MESSAGE[440],false|AJXP_MESSAGE[441]" scope="user" description="CONF_MESSAGE[Receive Notifcations by email]" label="CONF_MESSAGE[Active notifications by email]" expose="true" mandatory="true" default="true" />
        <param name="NOTIFICATIONS_EMAIL_FREQUENCY" scope="user" type="select" choices="M|CONF_MESSAGE[Every X min],H|CONF_MESSAGE[Every X hour],D1|CONF_MESSAGE[Every day at ],D2|CONF_MESSAGE[Twice a day (every day at and)],W1|CONF_MESSAGE[Once a Week]" label="CONF_MESSAGE[Emails frequency]" description="CONF_MESSAGE[Emails frequency]" expose="true" mandatory="true" default="M" />
        <param name="NOTIFICATIONS_EMAIL_FREQUENCY_USER" scope="user" type="string" description="CONF_MESSAGE[Choose your mail frequency (like 9:00 or 9:00,14:00 or Wednesday)]" label="CONF_MESSAGE[Detail your frequency here]" expose="true" mandatory="true" default="5" />
        <param name="NOTIFICATIONS_EMAIL" scope="user" description="CONF_MESSAGE[You can add many email separated by commas]" label="CONF_MESSAGE[Send email to...]" type="string" expose="true" editable="true"/>
        <param name="NOTIFICATIONS_EMAIL_SEND_HTML" scope="user" type="select" choices="true|AJXP_MESSAGE[440],false|AJXP_MESSAGE[441]" description="CONF_MESSAGE[Send as HTML]" label="CONF_MESSAGE[Get the email in HTML]" expose="true" mandatory="true" default="true" />
    </server_settings>
    <client_settings>
        <resources>
            <i18n namespace="core.mailer" path="plugins/core.mailer/i18n"/>
            <js className="PydioMailer" file="plugins/core.mailer/js/build/PydioMailer.js" depends="React,ReactPydio,PydioForm,UsersCompleter"/>
        </resources>
    </client_settings>
    <registry_contributions>
        <actions>
            <action name="send_mail">
                <rightsContext adminOnly="false" noUser="false" read="false" userLogged="hidden" write="false"/>
                <processing>
                    <serverCallback methodName="sendMailAction" restParams="/" developerComment="Trigger an email to a user or external email, sent by currently logged user">
                        <input_param name="from" type="string" description="From email"/>
                        <input_param name="emails" type="string" description="A list of emails or user names"/>
                        <input_param name="subject" type="string" description="Subject of the message"/>
                        <input_param name="message" type="string" description="Body of the message"/>
                        <input_param name="link" type="string" description="URL of an image to be used in the message body."/>
                    </serverCallback>
                </processing>
            </action>
            <action name="consume_mail_queue">
                <rightsContext adminOnly="true" noUser="false" read="false" userLogged="only" write="false"/>
                <processing>
                    <serverCallback methodName="mailConsumeQueue" restParams="/"/>
                </processing>
            </action>
        </actions>
        <hooks>
            <serverCallback methodName="processNotification" hookName="msg.notification" dontBreakOnException="true"/>
        </hooks>
    </registry_contributions>
</ajxp_plugin>
