* Copyright (C) 2003 Éric Seigne * Copyright (C) 2004 Laurent Destailleur * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Id$ * $Source$ */ /** \file htdocs/admin/webcalendar.php \ingroup webcal \brief Page de configuration du module webcalendar \version $Revision$ */ require("./pre.inc.php"); if (!$user->admin) accessforbidden(); $langs->load("admin"); $langs->load("other"); llxHeader(); print_titre($langs->trans("WebCalSetup")); print '
'; $def = array(); $phpwebcalendar_url=trim($_POST["phpwebcalendar_url"]); $phpwebcalendar_host=trim($_POST["phpwebcalendar_host"]); $phpwebcalendar_dbname=trim($_POST["phpwebcalendar_dbname"]); $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"]; // Test saisie mot de passe if ($phpwebcalendar_pass != $phpwebcalendar_pass2) { $ok="".$langs->trans("ErrorPasswordDiffers").""; } // Positionne la variable pour le test d'affichage de l'icone elseif ($actionsave) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_URL';"; $db->query($sql); $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_URL','".$phpwebcalendar_url."',0);"; $result=$db->query($sql); $sql1 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_HOST';"; $db->query($sql1); $sql1 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_HOST','".$phpwebcalendar_host."',0);"; $result1=$db->query($sql1); $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_DBNAME';"; $db->query($sql2); $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_DBNAME','".$phpwebcalendar_dbname."',0);"; $result2=$db->query($sql2); $sql3 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_USER' ;"; $db->query($sql3); $sql3 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_USER','".$phpwebcalendar_user."',0);"; $result3=$db->query($sql3); $sql4 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_PASS';"; $db->query($sql4); $sql4 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_PASS','".$phpwebcalendar_pass."',0);"; $result4=$db->query($sql4); $sql5 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_SYNCRO';"; $db->query($sql5); $sql5 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_SYNCRO','".$phpwebcalendar_syncro."',0);"; $result5=$db->query($sql5); if ($result && $result1 && $result2 && $result3 && $result4 && $result5) { $ok = "".$langs->trans("WebCalSetupSaved").""; } } 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; } /** * Affichage du formulaire de saisie */ print '
'; print "
".$langs->trans("Parameter")." ".$langs->trans("Value")."
".$langs->trans("WebCalURL")."
".$langs->trans("WebCalServer")."
".$langs->trans("WebCalDatabaseName")."
".$langs->trans("WebCalUser")."
".$langs->trans("Password")."
".$langs->trans("PasswordRetype")."
".$langs->trans("WebCalSyncro")." "; print ''; print '
'; print '
'; print "trans("TestConnection")."\">"; print "   "; print "trans("Save")."\">"; print "
\n"; clearstatcache(); if ($ok) print "
$ok
"; // Test de la connection a la database webcalendar if ($actiontest && ($phpwebcalendar_pass == $phpwebcalendar_pass2)) { $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)."
"; $webcal->close(); } elseif ($webcal->connected == 1) { print "
".$langs->trans("WebCalTestKo1",$phpwebcalendar_host,$phpwebcalendar_dbname)."
"; $webcal->close(); } else { print "
".$langs->trans("WebCalTestKo2",$phpwebcalendar_host,$phpwebcalendar_user)."
"; } } llxFooter(); ?>