<?xml version="1.0" encoding="UTF-8"?>
<confdriver name="sql" id="conf.sql" label="CONF_MESSAGE[DB Storage]" description="CONF_MESSAGE[Stores the conf data in an SQL database.]"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd"
        mixins="dibidriver_consumer" >
    <client_settings>
        <resources>
            <i18n namespace="sql_conf" path="plugins/conf.sql/i18n"/>
            <js className="TeamEditor" file="plugins/conf.sql/class.TeamEditor.js"/>
        </resources>
    </client_settings>
	<server_settings>
		<param name="SQL_DRIVER" type="group_switch:dibi" label="CONF_MESSAGE[Connexion]" description="CONF_MESSAGE[The Database Connexion]" mandatory="true" default="core"/>
        <param type="button" name="INSTALL_SQL" choices="run_plugin_action:conf.sql:installSQLTables" label="CONF_MESSAGE[SQL Tables]" description="CONF_MESSAGE[Install SQL Tables]" mandatory="false"/>
	</server_settings>
	<class_definition filename="plugins/conf.sql/class.sqlConfDriver.php" classname="sqlConfDriver"/>
	<registry_contributions>
		<external_file filename="plugins/core.conf/standard_conf_actions.xml" include="actions/*,client_configs/*" exclude=""/>
        <actions>
            <action name="user_team_create">
                <gui src="delete.png" iconClass="icon-create" text="user_dash.57" title="user_dash.57">
                    <context dir="false" recycle="false" selection="false" actionBar="true" actionBarGroup="team_address_book"/>
                </gui>
                <processing>
                    <clientCallback dialogOpenForm="team_edit_form" prepareModal="true">
                        <dialogOnOpen><![CDATA[
                            var oForm = modal.getForm();
                            ResourcesManager.loadClassesAndApply(["TeamEditor"], function(){
                                TeamEditor.prototype.getInstance().open(oForm);
                            });
                        ]]></dialogOnOpen>
                        <dialogOnComplete><![CDATA[
                            TeamEditor.prototype.getInstance().complete(oForm);
                        ]]></dialogOnComplete>
                        <dialogOnCancel><![CDATA[
                            TeamEditor.prototype.getInstance().close(oForm);
                        ]]></dialogOnCancel>
                    </clientCallback>
                    <serverCallback methodName="userTeamsActions"/>
                </processing>
            </action>
            <action name="user_team_add_user">
                <processing>
                    <serverCallback methodName="userTeamsActions"/>
                </processing>
            </action>
            <action name="user_team_edit_users">
                <gui src="delete.png" iconClass="icon-edit" text="user_dash.54" title="user_dash.55">
                    <context dir="false" recycle="false" selection="true" actionBar="true" actionBarGroup="team_address_book"/>
                    <selectionContext dir="false" file="true" recycle="false" unique="true" allowedMimes="ajxp_team"/>
                </gui>
                <processing>
                    <clientCallback dialogOpenForm="team_edit_form" prepareModal="true">
                        <dialogOnOpen><![CDATA[
                            var contextHolder = window.actionManager.getDataModel();
                            var oForm = modal.getForm();
                            ResourcesManager.loadClassesAndApply(["TeamEditor"], function(){
                                TeamEditor.prototype.getInstance().open(oForm, contextHolder);
                            });
                        ]]></dialogOnOpen>
                        <dialogOnComplete><![CDATA[
                            TeamEditor.prototype.getInstance().complete(oForm);
                        ]]></dialogOnComplete>
                        <dialogOnCancel><![CDATA[
                            TeamEditor.prototype.getInstance().close(oForm);
                        ]]></dialogOnCancel>
                    </clientCallback>
                    <clientForm id="team_edit_form"><![CDATA[
                         <div id="team_edit_form" box_width="420">
                            <div class="dialogContentMainTitle" ajxp_message_id="user_dash.59">AJXP_MESSAGE[user_dash.59]</div>
                            <input type="text" style="width:367px;margin-bottom:30px;" id="team_edit_label"/>

                            <div class="dialogContentMainTitle" ajxp_message_id="user_dash.60">AJXP_MESSAGE[user_dash.60]</div>
                            <div class="dialogLegend" ajxp_message_id="user_dash.56">AJXP_MESSAGE[user_dash.56]</div>
                            <div style="position: relative;">
                                <div id="team_loader" style="position: absolute;top: 2px;right: 3px;font-size: 17px;display: none;"><span class="icon-spinner"></span></div>
                                <input type="text" style="width:367px;" id="team_edit_input"/>
                                <div type="text" class="editable_users_list" id="team_edit_entries"></div>
                                <div id="team_edit_container"></div>
                            </div>
                         </div>
                    ]]></clientForm>
                    <serverCallback methodName="userTeamsActions"/>
                </processing>
            </action>
            <action name="user_team_delete">
                <gui src="delete.png" iconClass="icon-trash" text="7" title="7">
                    <context dir="false" recycle="false" selection="true" actionBar="true" actionBarGroup="team_address_book"/>
                    <selectionContext dir="false" file="true" recycle="false" unique="true" allowedMimes="ajxp_team"/>
                </gui>
                <processing>
                    <clientCallback><![CDATA[
                    if(window.confirm(MessageHash["user_dash.52"])){
                        var sel = window.actionManager.getDataModel().getUniqueNode();
                        var conn = new Connexion();
                        conn.setParameters($H({
                            get_action: "user_team_delete",
                            team_id: getBaseName(sel.getPath())
                        }));
                        conn.onComplete = function(){
                            $("team_panel").ajxpPaneObject.reloadDataModel();
                        };
                        conn.sendAsync();
                    }
                    ]]></clientCallback>
                    <serverCallback methodName="userTeamsActions"/>
                </processing>
            </action>
            <action name="user_team_delete_user">
                <processing>
                    <serverCallback methodName="userTeamsActions"/>
                </processing>
            </action>
            <action name="ajxp_table_exists">
                <rightsContext adminOnly="true" noUser="false" read="true" userLogged="only" write="true"/>
                <processing>
                    <serverCallback methodName="ajxpTableExists" restParams="/table_name"/>
                </processing>
            </action>
        </actions>
        <client_configs>
            <component_config className="AjxpTabulator::userdashboard_main_tab">
                <additional_tab id="team_pane"
                                tabInfo='{"id":"team_pane","position":2,"iconClass":"icon-group","element":"team_pane","closeable":false,"label":"user_dash.50","title":"user_dash.51","dontFocus":true}'
                                paneInfo='{"type":"widget"}'><![CDATA[
                <div id="team_pane" ajxpClass="AjxpPane" ajxpOptions='{"fit":"height"}'>
                    <div id="buttons_bar" class="action_bar" ajxpClass="ActionsToolbar" ajxpOptions='{"dataModelElementId":"team_panel","toolbarsList":["team_address_book"],"skipBubbling":true, "skipCarousel":true,"submenuOffsetTop":2}'></div>
                    <h3 class="dashboard_panel_title">AJXP_MESSAGE[user_dash.50]</h3>
                    <div id="team_panel" ajxpClass="FetchedResultPane" ajxpOptions='{"updateGlobalContext":false,"nodeProviderProperties":{"get_action":"ls","dir":"teams"}}' class="tabbed_editor display_metadata"></div>
                </div>
                ]]></additional_tab>
            </component_config>
        </client_configs>
	</registry_contributions>
</confdriver>
