diff --git a/README.md b/README.md index 9ea8cbd..25ebe52 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Make it easy to monitor menstrual cycles and apply natural methods. Billings. Sy - automatic sending of cycles by email - no data sales/no advertising -**Shipped version:** 10.0~ynh1 +**Shipped version:** 10.0~ynh2 **Demo:** https://tableau.moncycle.app/connexion.php?email1=demo@moncycle.app&mdp=demo diff --git a/README_fr.md b/README_fr.md index 3c8515c..7ea2d2c 100644 --- a/README_fr.md +++ b/README_fr.md @@ -36,7 +36,7 @@ Rendre facile le suivi des cycles menstruels et l’application des méthodes na - pas de vente de données/pas de publicité -**Version incluse :** 10.0~ynh1 +**Version incluse :** 10.0~ynh2 **Démo :** https://tableau.moncycle.app/connexion.php?email1=demo@moncycle.app&mdp=demo diff --git a/conf/config.php b/conf/config.php index f4ced39..fb6da8b 100644 --- a/conf/config.php +++ b/conf/config.php @@ -20,10 +20,10 @@ define("SMTP_PORT", 25); define("SMTP_MAIL", "__APP__@__DOMAIN__"); define("SMTP_PASSWORD", ""); -define("CREATION_COMPTE", true); -define("CONNEXION_COMPTE", true); +define("CREATION_COMPTE", __CREATION_COMPTE__); +define("CONNEXION_COMPTE", __CONNEXION_COMPTE__); -define("CSV_SEP", ";"); +define("CSV_SEP", "__CSV_SEP__"); define("PHP_SECURE_COOKIES", true); diff --git a/conf/version.json b/conf/version.json index 83ce69b..c7a0777 100644 --- a/conf/version.json +++ b/conf/version.json @@ -1,6 +1,6 @@ { "app": "moncycle.app", - "version": "10.0~ynh1", + "version": "10.0~ynh2", "build": "2024-02-21", "commit": "6e19865" } diff --git a/config_panel.toml b/config_panel.toml new file mode 100644 index 0000000..e2880fc --- /dev/null +++ b/config_panel.toml @@ -0,0 +1,180 @@ +version = "1.0" +[main] +name = "Configuration" +services = [ 'php8.3-fpm'] + + [main.comptes] + name = "Comptes" + + [main.comptes.creation_compte] + ask.en = "Enable account creation" + ask.fr = "Permettre la création de nouveaux comptes" + type = "boolean" + yes = true + no = false + default = true + help = "N'oubliez pas de créer votre propre compte avant de fermer cette option !" + + [main.comptes.connexion_compte] + ask.en = "Enable account connexion" + ask.fr = "Permettre la connexion aux comptes" + help = "La connexion sera activée ou désactivée pour l'ensemble des utilisateurs de l'instance" + type = "boolean" + yes = true + no = false + default = true + + [main.export] + name = "Export" + + [main.export.csv_sep] + ask.en = "For data in csv format" + ask.fr = "Pour les des données au format csv" + type = "select" + choices = ["Utiliser le séparateur ;", "Utiliser le séparateur ,", "Utiliser un espace"] + default = "Utiliser le séparateur ;" + +[statistics] +name = "Statistiques" + + [statistics.usage] + name = "Satistiques d'usage" + + [statistics.usage.moncycle_app_nb_session] + ask.fr = "Nombre de sessions" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_visite_mensuel] + ask.fr = "Nombre de visites mensuelles" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_visite_hebdo] + ask.fr = "Nombre de visites hebdomadaires" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_visite_jour] + ask.fr = "Nombre de visites quotidiennes" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_nb_cycle] + ask.fr = "Nombre de cycles" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_nb_cycle_recent] + ask.fr = "Nombre de cycles récents" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_age_moyen] + ask.fr = "Âge moyen" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_age_moyen_recent] + ask.fr = "Âge moyen récent" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_nb_total_observation] + ask.fr = "Nombre total d'observations" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_nb_observation_aujourdhui] + ask.fr = "Nombre d'observations aujourd'hui" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_nb_observation_1j] + ask.fr = "Nombre d'observations depuis 1 jour" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_nb_observation_5j] + ask.fr = "Nombre d'observations depuis 5 jours" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_nb_observation_15j] + ask.fr = "Nombre d'observations depuis 15 jours" + type = "number" + readonly = true + + [statistics.usage.moncycle_app_nb_observation_30j] + ask.fr = "Nombre d'observations depuis 30 jours" + type = "number" + readonly = true + + [statistics.comptes] + name = "Satistiques des comptes" + + [statistics.comptes.moncycle_app_nb_compte] + ask.fr = "Nombre de comptes" + type = "number" + readonly = true + + [statistics.comptes.moncycle_app_nb_compte_actif] + ask.fr = "Nombre de comptes actifs" + type = "number" + readonly = true + + [statistics.comptes.moncycle_app_pc_compte_actif] + ask.fr = "Part de comptes actifs" + type = "string" + readonly = true + + [statistics.comptes.moncycle_app_nb_compte_avec_totp] + ask.fr = "Nombre de comptes avec totp" + type = "number" + readonly = true + + [statistics.comptes.moncycle_app_nb_compte_actif_billings] + ask.fr = "Nombre de comptes Billings actifs" + type = "number" + readonly = true + + [statistics.comptes.moncycle_app_pc_compte_actif_billings] + ask.fr = "Part de comptes actifs Billings" + type = "string" + readonly = true + + [statistics.comptes.moncycle_app_nb_compte_actif_billings_temp] + ask.fr = "Nombre de comptes Billings avec température actifs" + type = "number" + readonly = true + + [statistics.comptes.moncycle_app_pc_compte_actif_billings_temp] + ask.fr = "Part de comptes actifs Billings avec température" + type = "string" + readonly = true + + [statistics.comptes.moncycle_app_nb_compte_actif_fertilitycare] + ask.fr = "Nombre de comptes Fertility Care actifs" + type = "number" + readonly = true + + [statistics.comptes.moncycle_app_pc_compte_actif_fertilitycare] + ask.fr = "Part de comptes actifs Fertility Care" + type = "string" + readonly = true + + [statistics.comptes.moncycle_app_nb_compte_actif_fertilitycare_temp] + ask.fr = "Nombre de comptes Fertility Care avec température actifs" + type = "number" + readonly = true + + [statistics.comptes.moncycle_app_pc_compte_actif_fertilitycare_temp] + ask.fr = "Part de comptes actifs FC avec température" + type = "string" + readonly = true + + [statistics.comptes.moncycle_app_nb_compte_recent] + ask.fr = "Nombre de comptes récents" + type = "string" + readonly = true + diff --git a/config_panel.toml.example b/config_panel.toml.example deleted file mode 100644 index f6c6c06..0000000 --- a/config_panel.toml.example +++ /dev/null @@ -1,34 +0,0 @@ -version = "1.0" -[main] -name = "Moncycle.app configuration" - - # [main.comptes] - # name = "comptes" - - # [main.comptes.creation_compte] - # ask.en = "Enable account creation" - # ask.fr = "Permettre la création de nouveaux comptes" - # type = "select" - # choices = ["true", "false"] - # default = "true" - # help = "Don't disable account creation before creating one for yourself !" - # bind = "CREATION_COMPTE:__INSTALL_DIR__/config.php" - # - # [main.comptes.connexion_compte] - # ask.en = "Enable account connexion" - # ask.fr = "Permettre la connexion aux comptes" - # type = "select" - # choices = ["true", "false"] - # default = "true" - # bind = "CONNEXION_COMPTE:__INSTALL_DIR__/config.php" - - [main.export] - name = "export" - - [main.export.csv_sep] - #ask.en = "Separator for data export in csv format" - #ask.fr = "Séparateur pour l'export des données au format csv" - bind = ":__INSTALL_DIR__/config.php" - type = "string" - #default = ";" - \ No newline at end of file diff --git a/doc/POST_INSTALL.md b/doc/POST_INSTALL.md index 9f0e131..6c47990 100644 --- a/doc/POST_INSTALL.md +++ b/doc/POST_INSTALL.md @@ -1,4 +1,4 @@ * After installing, you can create your own user using the form -* Once done, you can (if you want) set the account creation to false in `/var/www/moncycle/config.php` +* Once done, you can (if you want) disable the account creation in the config panel * If you want to use the app in PWA mode, be sure to be connected to your account first * After upgrading from 7.0 to 9.0, you may experience issues if you don't clean your browser cache diff --git a/manifest.toml b/manifest.toml index bf02ad5..9124843 100644 --- a/manifest.toml +++ b/manifest.toml @@ -5,7 +5,7 @@ name = "Moncycle" description.en = "Menstrual cycle follow-up for natural family planning" description.fr = "Suivi de cycle pour les méthodes naturelles de régulation de naissance" -version = "10.0~ynh1" +version = "10.0~ynh2" maintainers = ["Raoul de Limezy"] diff --git a/scripts/change_url b/scripts/change_url index 30276c1..050ace5 100644 --- a/scripts/change_url +++ b/scripts/change_url @@ -19,6 +19,14 @@ ynh_script_progression --message="Updating NGINX web server configuration..." -- ynh_change_url_nginx_config +#================================================= +# MODIFY CONFIG.PHP +#================================================= + +ynh_add_config --template="../conf/config.php" --destination="$install_dir/config.php" +chmod 400 "$install_dir/config.php" +chown $app:$app "$install_dir/config.php" + #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/config b/scripts/config index d03f829..220144d 100644 --- a/scripts/config +++ b/scripts/config @@ -24,10 +24,155 @@ ynh_abort_if_errors final_path=$(ynh_app_setting_get $app final_path) -## import needed settings -#creation_compte=$(ynh_app_setting_get --app="$app" --key=creation_compte) -#connexion_compte=$(ynh_app_setting_get --app="$app" --key=connexion_compte) -#csv_sep=$(ynh_app_setting_get --app="$app" --key=csv_sep) +pushd "$install_dir/script" + statistiques="$(/usr/bin/php8.3 --define apc.enable_cli=1 stat.php)" +popd + +get__csv_sep(){ + separateur="$(grep -oPi 'define\("CSV_SEP",[\s"]*\K[^\")]+' "$install_dir/config.php")" + if [ "$separateur" == " " ]; then + echo "Utiliser un espace" + else + echo "Utiliser le séparateur ""$separateur" + fi +} + +set__csv_sep(){ + if [ "$csv_sep" == "Utiliser le séparateur ," ]; then + sed -i "s/define(\"CSV_SEP\",.*);/define(\"CSV_SEP\", \",\");/" "$install_dir/config.php" + elif [ "$csv_sep" == "Utiliser un espace" ]; then + sed -i "s/define(\"CSV_SEP\",.*);/define(\"CSV_SEP\", \" \");/" "$install_dir/config.php" + else + sed -i "s/define(\"CSV_SEP\",.*);/define(\"CSV_SEP\", \";\");/" "$install_dir/config.php" + fi + ynh_app_setting_set --app=$app --key=csv_sep --value="$csv_sep" +} + +get__creation_compte(){ + grep -oPi 'define\("CREATION_COMPTE",[\s"]*\K[^\")]+' "$install_dir/config.php" +} + +set__creation_compte(){ + sed -i "s/define(\"CREATION_COMPTE\",.*);/define(\"CREATION_COMPTE\", $creation_compte);/" "$install_dir/config.php" + ynh_app_setting_set --app=$app --key=creation_compte --value="$creation_compte" +} + +get__connexion_compte(){ + grep -oPi 'define\("CONNEXION_COMPTE",[\s"]*\K[^\")]+' "$install_dir/config.php" +} + +set__connexion_compte(){ + sed -i "s/define(\"CONNEXION_COMPTE\",.*);/define(\"CONNEXION_COMPTE\", $connexion_compte);/" "$install_dir/config.php" + ynh_app_setting_set --app=$app --key=connexion_compte --value="$connexion_compte" +} + +get__moncycle_app_nb_compte(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_compte \K.*' +} + +get__moncycle_app_nb_session(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_session \K.*' +} + +get__moncycle_app_visite_mensuel(){ + echo "$statistiques" | grep -Poi 'moncycle_app_visite_mensuel \K.*' +} + +get__moncycle_app_visite_hebdo(){ + echo "$statistiques" | grep -Poi 'moncycle_app_visite_hebdo \K.*' +} + +get__moncycle_app_visite_jour(){ + echo "$statistiques" | grep -Poi 'moncycle_app_visite_jour \K.*' +} + +get__moncycle_app_nb_compte_actif(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_compte_actif \K.*' +} + +get__moncycle_app_pc_compte_actif(){ + echo $(echo "$statistiques" | grep -Poi 'moncycle_app_pc_compte_actif \K.*')"%" +} + +get__moncycle_app_nb_compte_avec_totp(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_compte_avec_totp \K.*' +} + +get__moncycle_app_nb_compte_actif_billings(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_compte_actif_billings \K.*' +} + +get__moncycle_app_pc_compte_actif_billings(){ + echo $(echo "$statistiques" | grep -Poi 'app_pc_compte_actif_billings \K.*')"%" +} + +get__moncycle_app_nb_compte_actif_billings_temp(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_compte_actif_billings_temp \K.*' +} + +get__moncycle_app_pc_compte_actif_billings_temp(){ + echo $(echo "$statistiques" | grep -Poi 'app_pc_compte_actif_billings_temp \K.*')"%" +} + +get__moncycle_app_nb_compte_actif_fertilitycare(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_compte_actif_fertilitycare \K.*' +} + +get__moncycle_app_pc_compte_actif_fertilitycare(){ + echo $(echo "$statistiques" | grep -Poi 'app_pc_compte_actif_fertilitycare \K.*')"%" +} + +get__moncycle_app_nb_compte_actif_fertilitycare_temp(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_compte_actif_fertilitycare_temp \K.*' +} + +get__moncycle_app_pc_compte_actif_fertilitycare_temp(){ + echo $(echo "$statistiques" | grep -Poi 'app_pc_compte_actif_fertilitycare_temp \K.*')"%" +} + +get__moncycle_app_nb_compte_recent(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_compte_recent \K.*' +} + +get__moncycle_app_nb_cycle(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_cycle \K.*' +} + +get__moncycle_app_nb_cycle_recent(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_cycle_recent \K.*' +} + +get__moncycle_app_age_moyen(){ + echo "$statistiques" | grep -Poi 'moncycle_app_age_moyen \K.*' +} + +get__moncycle_app_age_moyen_recent(){ + echo "$statistiques" | grep -Poi 'moncycle_app_age_moyen_recent \K.*' +} + +get__moncycle_app_nb_total_observation(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_total_observation \K.*' +} + +get__moncycle_app_nb_observation_aujourdhui(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_observation_aujourdhui \K.*' +} + +get__moncycle_app_nb_observation_1j(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_observation_1j \K.*' +} + +get__moncycle_app_nb_observation_5j(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_observation_5j \K.*' +} + +get__moncycle_app_nb_observation_15j(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_observation_15j \K.*' +} + +get__moncycle_app_nb_observation_30j(){ + echo "$statistiques" | grep -Poi 'moncycle_app_nb_observation_30j \K.*' +} #================================================= # GENERIC FINALIZATION diff --git a/scripts/install b/scripts/install index 7b55452..0713394 100755 --- a/scripts/install +++ b/scripts/install @@ -9,6 +9,14 @@ source _common.sh source /usr/share/yunohost/helpers +csv_sep=";" +creation_compte=true +connexion_compte=true +ynh_app_setting_set --app=$app --key=csv_sep --value="$csv_sep" +ynh_app_setting_set --app=$app --key=creation_compte --value="$creation_compte" +ynh_app_setting_set --app=$app --key=connexion_compte --value="$connexion_compte" + + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #=================================================