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

    <containers>
        <container name='web'>
            <package>moodle-update-apps</package>
            <file filelist='moodle' name='/etc/apache2/sites-available/moodle' source='moodle-apache.conf'/>
            <file filelist='moodle' name='/var/www/html/moodle/config.php' source='moodle-config.php' rm='True'/>
            <file filelist='moodle' name='/var/www/html/moodle/moosh/proxy.php' source='moodle-mooshproxy.php' rm='True'/>
            <file filelist='moodle' name='/etc/cron.d/moodle' source='moodle.cron' rm='True'/>
            <file filelist='moodle' name='/var/www/html/posh-profil/include/moodle.php' source='moodle-synchro.php' rm='True'/>
            <service method="apache" servicelist="moodle">moodle</service>
        </container>
    </containers>

    <variables>
        <family name='applications web'>
            <variable name='activer_moodle' type='oui/non' description="Activer Moodle (plate-forme d'e-learning)">
                <value>oui</value>
            </variable>

            <variable name='activer_moodlevisiteur' type='oui/non' description="Autoriser les visiteurs sur la page d'accueil de Moodle">
                <value>non</value>
            </variable>

            <variable name='moodle_apikey' type='string' description="API Key pour accéder au webservice Moodle">
                <value>secretkeymoodle</value>
            </variable>

            <variable name='moodle_version' type='string' description="Version Moodle" hidden='True' mandatory='True'>
                <value>31</value>
            </variable>
        </family>

        <family name='moodle' mode='expert'>
            <variable type='string' name='moodle_db_mode' description='Serveur de bases de données à utiliser'/>
            <variable type='string' name='moodle_dbserver' description='Adresse du serveur de base de données'/>
            <variable type='number' name='moodle_dbport' description="Port d'écoute du serveur de base de données"/>
            <variable type='string' name='moodle_allow_hosts' description="Hôtes autorisés à utiliser la base de données" multi='True'/>
            <variable type='string' name='moodle_dbuser' description='Utilisateur du serveur de base de données'/>
            <variable type='string' name='moodle_dbpass' description='Fichier de mot de passe du serveur'/>
        </family>
    </variables>

    <constraints>
        <condition name='hidden_if_in' source='activer_apache'>
            <param>non</param>
            <target type='filelist'>moodle</target>
            <target type='filelist'>moodle-bareos</target>
            <target type='servicelist'>moodle</target>
            <target type='variable'>activer_moodlevisiteur</target>
            <target type='variable'>moodle_apikey</target>
        </condition>

        <condition name='hidden_if_in' source='activer_moodle'>
            <param>non</param>
            <target type='filelist'>moodle</target>
            <target type='filelist'>moodle-bareos</target>
            <target type='servicelist'>moodle</target>
            <target type='variable'>activer_moodlevisiteur</target>
            <target type='variable'>moodle_apikey</target>
        </condition>

        <check name='valid_enum' target='moodle_db_mode'>
            <param>['default', 'externe', 'local']</param>
        </check>
        <condition name='disabled_if_in' source='moodle_db_mode'>
            <param>local</param>
            <target type='variable'>moodle_dbserver</target>
            <target type='variable'>moodle_dbuser</target>
            <target type='variable'>moodle_dbport</target>
            <target type='variable'>moodle_dbpass</target>
        </condition>
        <condition name='disabled_if_in' source='moodle_db_mode'>
            <param>default</param>
            <target type='variable'>moodle_dbserver</target>
            <target type='variable'>moodle_dbuser</target>
            <target type='variable'>moodle_dbport</target>
            <target type='variable'>moodle_dbpass</target>
            <target type='variable'>moodle_allow_hosts</target>
        </condition>

        <condition name='disabled_if_in' source='activer_bareos_dir' fallback='True'>
            <param>non</param>
            <target type='filelist'>moodle-bareos</target>
		</condition>
    </constraints>

    <help>
        <variable name='activer_moodle'>Moodle est une plate-forme d'apprentissage en ligne (e-learning)</variable>
    </help>
</creole>
