<?xml version="1.0" encoding="utf-8"?>
<creole>
    <files>
        <file filelist='piwigo-bareos' name='/etc/bareos/bareosfichiers.d/piwigo.conf' source='piwigo-bareos.conf' rm='True'/>
        <file filelist='piwigo-files' name='/usr/share/eole/db/piwigo/gen/piwigo-create-1.sql' rm='True' mkdir='True'/>
        <file filelist='piwigo-files' name='/usr/share/eole/db/piwigo/updates/piwigo-update-1.sql' rm='True' mkdir='True'/>
        <file filelist='piwigo-file' name='/etc/eole/eole-db.d/piwigo-db.yml' rm='True' mkdir='True'/>
        <file filelist='piwigo-file' name='/usr/share/envole/eoledb/piwigo' source='piwigo.db' rm='True' mkdir='True'/>
    </files>
    
    <containers>
        <container name='web'>
            <!--Fichier de configuration de eole-piwigo -->
            <package>piwigo-apps</package>
            <file name='/etc/apache2/sites-available/piwigo' filelist='piwigo-files' source='piwigo-apache.conf.tmpl'/>
            <file filelist='piwigo-files' name='/var/www/html/piwigo/include/config_default.inc.php' source='piwigo-config.php.tmpl' rm='True'/>
            <file filelist='piwigo-files' name='/var/www/html/piwigo/local/config/database.inc.php' source='piwigo-database.inc.php.tmpl' rm='True'/>
            <file filelist='piwigo-files' name='/var/www/html/posh-profil/include/piwigo.php' source='piwigo-synchro.php' rm='True'/>
            <service method="apache" servicelist="piwigo">piwigo</service>
        </container>
    </containers>
    
    <variables>
        <family name='applications web'>
            <variable name='activer_piwigo' type='oui/non' description="Activer Piwigo (galerie photo)">
                <value>oui</value>
            </variable>
        </family>
        
        <family name='piwigo' mode='expert'>
            <variable type='string' name='piwigo_db_mode' description='Serveur de bases de données à utiliser'/>
            <variable type='string' name='piwigo_dbserver' description='Adresse du serveur de base de données'/>
            <variable type='number' name='piwigo_dbport' description="Port d'écoute du serveur de base de données"/>
            <variable type='string' name='piwigo_allow_hosts' description="Hôtes authorisés à utiliser la base de données" multi='True'/>
            <variable type='string' name='piwigo_dbuser' description='Utilisateur du serveur de base de données'/>
            <variable type='string' name='piwigo_dbpass' description='Fichier de mot de passe du serveur'/>
        </family>        
    </variables>
    
    <constraints>
        <condition name='hidden_if_in' source='activer_piwigo'>
            <param>non</param>
            <target type='filelist'>piwigo-files</target>
            <target type='filelist'>piwigo-bareos</target>
            <target type='servicelist'>piwigo</target>
        </condition>
        
        <condition name='hidden_if_in' source='activer_apache'>
            <param>non</param>
            <target type='filelist'>piwigo-files</target>
            <target type='filelist'>piwigo-bareos</target>
            <target type='servicelist'>piwigo</target>
        </condition>
        
        <condition name='hidden_if_in' source='activer_bareos_dir' fallback='True'>
            <param>non</param>
            <target type='filelist'>piwigo-bareos</target>    
        </condition>

        <check name='valid_enum' target='piwigo_db_mode'>
            <param>['default', 'externe', 'local']</param>
        </check>
        <condition name='disabled_if_in' source='piwigo_db_mode'>
            <param>local</param>
            <target type='variable'>piwigo_dbserver</target>
            <target type='variable'>piwigo_dbuser</target>
            <target type='variable'>piwigo_dbport</target>
            <target type='variable'>piwigo_dbpass</target>
        </condition>
        <condition name='disabled_if_in' source='piwigo_db_mode'>
            <param>default</param>
            <target type='variable'>piwigo_dbserver</target>
            <target type='variable'>piwigo_dbuser</target>
            <target type='variable'>piwigo_dbport</target>
            <target type='variable'>piwigo_dbpass</target>
            <target type='variable'>piwigo_allow_hosts</target>
        </condition>
        
    </constraints>
    <help>
        <variable name='activer_piwigo'>Piwigo est une application de galerie photo pour le web.</variable>
    </help>
</creole>
