<?xml version="1.0" encoding="utf-8"?>
<creole>
	<files>
        <!-- service de sauvegarde bareos -->
        <file filelist='wordpress-bareos' name='/etc/bareos/bareosfichiers.d/wordpress.conf' source='wordpress-bareos.conf' rm='True'/>
        <file filelist='wordpress_files' name='/etc/eole/eole-db.d/wordpress-db.yml' rm='True' mkdir='True'/>
        <file filelist='wordpress_files' name='/usr/share/envole/eoledb/wordpress' source='wordpress.db' rm='True' mkdir='True'/>
		<file filelist='wordpress_files' name='/usr/share/eole/db/wordpress/gen/wordpress-create.sql' rm='True' mkdir='True'/>
		<file filelist='wordpress_files' name='/usr/share/eole/db/wordpress/updates/wordpress-update-1.sql' rm='True' mkdir='True'/>
	</files>
	<containers>
		<container name='web'>
			<package>wordpress-apps</package>
			<!-- service de configuration apache -->
			<service method="apache" servicelist="wordpress">wordpress</service>

			<!-- fichiers de conf apache -->
			<file filelist='wordpress_files' name='/etc/apache2/sites-available/wordpress' source='wordpress-apache.conf' />
			<file filelist='wordpress_files' name='/var/www/html/wordpress/wp-config.php' source='wordpress-config.php' rm='True'/>
			<file filelist="wordpress_files" name="/var/www/html/wordpress/wp-content/plugins/wpcas.php" source="wordpress-wpcas.php" mkdir='True' rm='True'/>
			<file filelist="wordpress_files" name="/var/www/html/wordpress/wp-content/plugins/wpcas-conf.php" source="wordpress-wpcas-conf.php" mkdir='True' rm='True'/>
            <file filelist='wordpress_files' name='/var/www/html/posh-profil/include/wordpress.php' source='wordpress-synchro.php' rm='True'/>
		</container>
	</containers>
	<variables>
		<family name='applications web'>
			<variable name='activer_wordpress' type='oui/non' description='Activer Wordpress (blog)'>
				<value>oui</value>
			</variable>
			<variable name='activer_buddypress' type='oui/non' description='Activer le réseau social de wordpress'>
                <value>non</value>
            </variable>
			<variable name='activer_autoconnect' type='oui/non' description='Activer auto-connexion à Wordpress' mode='expert'>
                <value>oui</value>
            </variable>
		</family>

        <family name='wordpress' mode='expert'>
            <variable type='string' name='wordpress_db_mode' description='Serveur de bases de données à utiliser'/>
            <variable type='string' name='wordpress_dbserver' description='Adresse du serveur de base de données'/>
            <variable type='number' name='wordpress_dbport' description="Port d'écoute du serveur de base de données"/>
            <variable type='string' name='wordpress_allow_hosts' description="Hôtes autorisés à utiliser la base de données" multi='True'/>
            <variable type='string' name='wordpress_dbuser' description='Utilisateur du serveur de base de données'/>
            <variable type='string' name='wordpress_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'>wordpress_files</target>
            <target type='servicelist'>wordpress</target>
            <target type='variable'>activer_buddypress</target>
            <target type='variable'>activer_autoconnect</target>
        </condition>

		<condition name='hidden_if_in' source='activer_wordpress'>
			<param>non</param>
			<target type='filelist'>wordpress_files</target>
			<target type='servicelist'>wordpress</target>
            <target type='variable'>activer_buddypress</target>
            <target type='variable'>activer_autoconnect</target>
		</condition>

        <check name='valid_enum' target='wordpress_db_mode'>
            <param>['default', 'externe', 'local']</param>
        </check>
        <condition name='disabled_if_in' source='wordpress_db_mode'>
            <param>local</param>
            <target type='variable'>wordpress_dbserver</target>
            <target type='variable'>wordpress_dbuser</target>
            <target type='variable'>wordpress_dbport</target>
            <target type='variable'>wordpress_dbpass</target>
        </condition>
        <condition name='disabled_if_in' source='wordpress_db_mode'>
            <param>default</param>
            <target type='variable'>wordpress_dbserver</target>
            <target type='variable'>wordpress_dbuser</target>
            <target type='variable'>wordpress_dbport</target>
            <target type='variable'>wordpress_dbpass</target>
            <target type='variable'>wordpress_allow_hosts</target>
        </condition>

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

	<help>
		<variable name='activer_wordpress'>Wordpress est un puissant moteur de blog, conforme aux standards et simple à utiliser</variable>
	</help>
</creole>
