diff --git a/htdocs/admin/webcalendar.php b/htdocs/admin/webcalendar.php
index a38d493e279..fa4bf7ad1c0 100644
--- a/htdocs/admin/webcalendar.php
+++ b/htdocs/admin/webcalendar.php
@@ -52,13 +52,13 @@ $phpwebcalendar_user=trim($_POST["phpwebcalendar_user"]);
$phpwebcalendar_pass=trim($_POST["phpwebcalendar_pass"]);
$phpwebcalendar_pass2=trim($_POST["phpwebcalendar_pass2"]);
$phpwebcalendar_syncro=trim($_POST["phpwebcalendar_syncro"]);
-$actionsave=$_POST["save"];
$actiontest=$_POST["test"];
+$actionsave=$_POST["save"];
// Test saisie mot de passe
if ($phpwebcalendar_pass != $phpwebcalendar_pass2)
{
- $ok="".$langs->trans("ErrorPasswordDiffers")."";
+ $ok="
".$langs->trans("ErrorPasswordDiffers")."
";
}
// Positionne la variable pour le test d'affichage de l'icone
elseif ($actionsave)
@@ -105,13 +105,16 @@ elseif ($actionsave)
}
}
-if (! $phpwebcalendar_url) { $phpwebcalendar_url=PHPWEBCALENDAR_URL; }
-if (! $phpwebcalendar_host) { $phpwebcalendar_host=PHPWEBCALENDAR_HOST; }
-if (! $phpwebcalendar_dbname) { $phpwebcalendar_dbname=PHPWEBCALENDAR_DBNAME; }
-if (! $phpwebcalendar_user) { $phpwebcalendar_user=PHPWEBCALENDAR_USER; }
-if (! $phpwebcalendar_pass) { $phpwebcalendar_pass=PHPWEBCALENDAR_PASS; }
-if (! $phpwebcalendar_pass2) { $phpwebcalendar_pass2=PHPWEBCALENDAR_PASS; }
-if (! $phpwebcalendar_syncro) { $phpwebcalendar_syncro=PHPWEBCALENDAR_SYNCRO; }
+if (! $actiontest && ! $actionsave)
+{
+ if (! $phpwebcalendar_url) { $phpwebcalendar_url=PHPWEBCALENDAR_URL; }
+ if (! $phpwebcalendar_host) { $phpwebcalendar_host=PHPWEBCALENDAR_HOST; }
+ if (! $phpwebcalendar_dbname) { $phpwebcalendar_dbname=PHPWEBCALENDAR_DBNAME; }
+ if (! $phpwebcalendar_user) { $phpwebcalendar_user=PHPWEBCALENDAR_USER; }
+ if (! $phpwebcalendar_pass) { $phpwebcalendar_pass=PHPWEBCALENDAR_PASS; }
+ if (! $phpwebcalendar_pass2) { $phpwebcalendar_pass2=PHPWEBCALENDAR_PASS; }
+ if (! $phpwebcalendar_syncro) { $phpwebcalendar_syncro=PHPWEBCALENDAR_SYNCRO; }
+}
/**
@@ -167,27 +170,46 @@ print "\n";
clearstatcache();
if ($ok) print "
$ok
";
-
+print "
";
// Test de la connection a la database webcalendar
if ($actiontest && ($phpwebcalendar_pass == $phpwebcalendar_pass2))
{
+ // Test connexion
$webcal = new DoliDb('',$phpwebcalendar_host,$phpwebcalendar_user,$phpwebcalendar_pass,$phpwebcalendar_dbname);
if ($webcal->connected == 1 && $webcal->database_selected == 1)
{
- print "
".$langs->trans("WebCalTestOk",$phpwebcalendar_host,$phpwebcalendar_dbname,$phpwebcalendar_user)."
";
+ // Vérifie si bonne base
+ $sql="SELECT cal_value FROM webcal_config WHERE cal_setting='application_name'";
+ $resql=$webcal->query($sql);
+ if ($resql) {
+ $mesg ="".$langs->trans("WebCalTestOk",$phpwebcalendar_host,$phpwebcalendar_dbname,$phpwebcalendar_user);
+ $mesg.="
";
+ }
+ else {
+ $mesg ="".$langs->trans("ErrorConnectOkButWrongDatabase");
+ $mesg.=$webcal->error;
+ $mesg.="
";
+ }
+
$webcal->close();
}
- elseif ($webcal->connected == 1)
+ elseif ($webcal->connected == 1 && $webcal->database_selected != 1)
{
- print "
".$langs->trans("WebCalTestKo1",$phpwebcalendar_host,$phpwebcalendar_dbname)."
";
+ $mesg ="".$langs->trans("WebCalTestKo1",$phpwebcalendar_host,$phpwebcalendar_dbname);
+ $mesg.="
".$webcal->error;
+ $mesg.="
";
$webcal->close();
}
else
{
- print "
".$langs->trans("WebCalTestKo2",$phpwebcalendar_host,$phpwebcalendar_user)."
";
+ $mesg ="".$langs->trans("WebCalTestKo2",$phpwebcalendar_host,$phpwebcalendar_user);
+ $mesg.="
".$webcal->error;
+ $mesg.="
";
}
+
+ print $mesg;
}