<?xml version="1.0" encoding="utf-8"?>
<creole>
    <files>
        <file filelist='envole-bareos' name='/etc/bareos/bareosfichiers.d/posh.conf' source='posh-bareos.conf' rm='True'/>
	    <file filelist='envole' name='/usr/share/eole/db/posh/gen/posh-create-1.sql' mkdir='True' rm='True'/>
        <file filelist='envole' name='/usr/share/eole/db/posh/updates/posh-update-1.sql' mkdir='True' rm='True'/>
        <file filelist='envole' name='/etc/eole/eole-db.d/posh-db.yml' rm='True' mkdir='True'/>
        <file filelist='envole' name='/usr/share/envole/eoledb/posh' source='posh.db' rm='True' mkdir='True'/>
    </files>

    <containers>
        <container name='web'>
            <package>posh-apps</package>

            <!-- services de configuration apache -->
            <service method="apache" servicelist="envole">posh</service>
            <service method="apache" servicelist="envole">ressources</service>

            <!-- fichier de configuration apache -->
            <file filelist='envole' name='/etc/apache2/sites-available/posh' source='posh-apache.conf'/>
			<file filelist='envole' name='/etc/apache2/sites-available/ressources' source='posh-apache-ressources.conf' mkdir='True'/>

            <!-- fichier de configuration posh -->
            <file filelist='envole' name='/var/www/html/posh/includes/config.inc.php' source='posh-config.inc.php'/>
            <file filelist='envole' name='/var/www/html/posh-profil/include/posh.php' source='posh-synchro.php'/>
            <file filelist='posh-migration' name='/var/www/html/envole-migration/config/config-db-posh.php' source='posh-migration.php' mkdir='True'/>

            <!-- fichier de configuration pour le plugin password -->
            <file filelist='envole' name='/usr/share/php/configCAS/ldap.inc.php' source='posh-ldap.inc.php' mkdir='True' rm='True'/>
            <file filelist='envole' name='/var/www/html/posh/includes/plugins/plugin_password/includes.php' source='posh-password-includes.php' mkdir='True' rm='True'/>

            <!-- fichier de configuration des logouts des applications -->
            <file filelist='envole' name='/var/www/html/posh/index.php' source='posh-index.php' mkdir='True' rm='True'/>

            <!-- fichier proxy.pac -->
            <file filelist='envoleproxy' name='/var/www/html/posh/includes/proxy.pac' source='posh-proxy.pac' mkdir='True' rm='True'/>

            <!-- Plugin CAS -->
            <file filelist='envole' name='/var/www/html/posh/includes/plugins/plugin_eolecas/cas.inc.php' source='posh-cas.inc.php' mkdir='True' rm='True'/>
            <file filelist='envole' name='/var/www/html/posh/includes/plugins/plugin_eolecas/logout.eole.inc.php' source='posh-logout.eole.inc.php' mkdir='True' rm='True'/>

            <!-- Plugin piwik -->
            <file filelist='envole' name='/var/www/html/posh/includes/plugins/plugin_piwik/plugin_piwik.php' source='posh-plugin-piwik.php' group='www-data' mode='640'/>

            <!-- Reverse Proxy -->
            <file filelist='envole' name='/var/www/html/posh/includes/plugins/plugin_widget_ressource/p_widget_ressource.php' source='posh-reverse-p_widget_ressource.php' mkdir='True' rm='True'/>
            <file filelist='envole' name='/var/www/html/posh/includes/plugins/plugin_widget_ressource/openexternalurl.php' source='posh-reverse-openexternalurl.php' mkdir='True' rm='True'/>
        </container>
    </containers>

    <variables>
        <family name='envole'>
            <variable name='test_force_envole' type='oui/non' hidden='True'/>

            <variable name='activer_envole' type='oui/non' description='Activer Envole (portail web)'>
                <value>oui</value>
            </variable>

            <variable name='activer_reseausocial' type='oui/non' description='Activer le réseau social Envole'>
                <value>oui</value>
            </variable>

            <variable name='force_envole' description='Utiliser Envole comme application par défaut en frontal' redefine='True'>
                <value>oui</value>
            </variable>

            <variable name='version_envole' type='string' hidden='True'>
                <value>4.1</value>
            </variable>
            <variable name='posh_proxy_http' description='Activer proxy http pour les inclusions de posh' mode='expert' type='oui/non'>
                <value>non</value>
            </variable>
            <variable name='posh_proxy_value' description='Url du proxy pour les inclusions https de posh' mode='expert'>
            </variable>
        </family>

        <family name='posh' mode='expert'>
            <variable name='posh_db_mode' type='string' description='Serveur de bases de données à utiliser'/>
            <variable name='posh_dbserver' type='string' description='Adresse du serveur de base de données'/>
            <variable name='posh_dbport' type='number' description="Port d'écoute du serveur de base de données"/>
            <variable name='posh_allow_hosts' type='string' description="Hôtes authorisés à utiliser la base de données" multi='True'/>
            <variable name='posh_dbuser' type='string' description='Utilisateur du serveur de base de données'/>
            <variable name='posh_dbpass' type='string'  description='Fichier de mot de passe du serveur'/>
        </family>
    </variables>

    <constraints>
        <condition name='disabled_if_in' source='activer_eoledb'>
            <param>non</param>
            <target type='variable'>activer_envole</target>
        </condition>

        <condition name='hidden_if_in' source='activer_apache'>
            <param>non</param>
            <target type='family'>envole</target>
            <target type='filelist'>posh-migration</target>
            <target type='filelist'>envole</target>
            <target type='filelist'>envole-bareos</target>
            <target type='servicelist'>envole</target>
            <target type='variable'>force_envole</target>
        </condition>

        <condition name='hidden_if_in' source='activer_envole'>
            <param>non</param>
            <target type='filelist'>envole</target>
            <target type='filelist'>posh-migration</target>
            <target type='filelist'>envole-bareos</target>
            <target type='servicelist'>envole</target>
            <target type='variable'>force_envole</target>
        </condition>

        <condition name='hidden_if_in' source='activer_envole_migration' fallback='True'>
            <param>non</param>
            <target type='filelist'>posh-migration</target>
        </condition>

        <auto name='calc_multi_condition' target='test_force_envole'>
            <param>oui</param>
            <param type='eole' name='condition_1'>activer_envole</param>
            <param type='eole' name='condition_2' hidden='False'>force_envole</param>
            <param name='match'>oui</param>
            <param name='mismatch'>non</param>
        </auto>

        <condition name='frozen_if_in' source='test_force_envole'>
            <param>oui</param>
            <target type='variable'>web_redirection</target>
        </condition>


		<condition name='hidden_if_in' source='activer_proxy_client'>
            <param>non</param>
            <target type='filelist'>envoleproxy</target>
        </condition>

		<condition name='hidden_if_in' source='posh_proxy_http'>
            <param>non</param>
            <target type='variable'>posh_proxy_value</target>
        </condition>
        <condition name='hidden_if_in' source='activer_bareos_dir' fallback='True'>
            <param>non</param>
            <target type='filelist'>envole-bareos</target>
		</condition>


        <check name='valid_enum' target='posh_db_mode'>
            <param>['default', 'externe', 'local']</param>
        </check>
        <condition name='disabled_if_in' source='posh_db_mode'>
            <param>local</param>
            <target type='variable'>posh_dbserver</target>
            <target type='variable'>posh_dbuser</target>
            <target type='variable'>posh_dbport</target>
            <target type='variable'>posh_dbpass</target>
        </condition>
        <condition name='disabled_if_in' source='posh_db_mode'>
            <param>default</param>
            <target type='variable'>posh_dbserver</target>
            <target type='variable'>posh_dbuser</target>
            <target type='variable'>posh_dbport</target>
            <target type='variable'>posh_dbpass</target>
            <target type='variable'>posh_allow_hosts</target>
        </condition>
    </constraints>

    <help>
        <variable name='activer_envole'>Envole est un ENP (Espace Numérique Personnalisable), permettant de centraliser les accès aux applications web</variable>
        <variable name='posh_proxy_http'>Utilisation d'un proxy pour inclure du http dans un environnement https</variable>
        <variable name='posh_proxy_value'>URL complète de votre proxy et balise $URL$ à placer dans le paramètre GET attendu par votre proxy (ex: https://proxy.ac-acad.fr/monproxy.php?url=$URL$ ou https://proxy.ac-acad.fr/monproxy.php?url=http://$URL$)</variable>
    </help>

</creole>
