* 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(); llxHeader(); print_titre("Configuration du lien vers le calendrier partagé"); print '
'; $def = array(); $phpwebcalendar_url=$_POST["phpwebcalendar_url"]; $phpwebcalendar_host=$_POST["phpwebcalendar_host"]; $phpwebcalendar_dbname=$_POST["phpwebcalendar_dbname"]; $phpwebcalendar_user=$_POST["phpwebcalendar_user"]; $phpwebcalendar_pass=$_POST["phpwebcalendar_pass"]; $phpwebcalendar_pass2=$_POST["phpwebcalendar_pass2"]; $actionsave=$_POST["save"]; $actiontest=$_POST["test"]; // Positionne la variable pour le test d'affichage de l'icone if ($actionsave) { if (trim($phpwebcalendar_pass) == trim($phpwebcalendar_pass2)) { $sql = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_URL';"; $db->query($sql); $sql=''; $sql = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_URL','".$phpwebcalendar_url."',0);"; $db->query($sql); $sql=''; $sql1 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_HOST';"; $db->query($sql1); $sql1 = ''; $sql1 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_HOST','".$phpwebcalendar_host."',0);"; $db->query($sql1); $sql2 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_DBNAME';"; $db->query($sql2); $sql2=''; $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_DBNAME','".$phpwebcalendar_dbname."',0);"; $db->query($sql2); $sql2=''; $sql3 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_USER' ;"; $db->query($sql3); $sql3=''; $sql3 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_USER','".$phpwebcalendar_user."',0);"; $sql4 = "DELETE FROM ".MAIN_DB_PREFIX."const WHERE name = 'PHPWEBCALENDAR_PASS';"; $db->query($sql4); $sql4=''; $sql4 = "INSERT INTO ".MAIN_DB_PREFIX."const (name,value,visible) VALUES ('PHPWEBCALENDAR_PASS','".$phpwebcalendar_pass."',0);"; $db->query($sql4); if ($db->query($sql) && $db->query($sql1) && $db->query($sql2) && $db->query($sql3) && $db->query($sql4)) { // la constante qui a été lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage cohérent define("PHPWEBCALENDAR_URL", $phpwebcalendar_url); define("PHPWEBCALENDAR_HOST", $phpwebcalendar_host); define("PHPWEBCALENDAR_DBNAME",$phpwebcalendar_dbname); define("PHPWEBCALENDAR_USER", $phpwebcalendar_user); define("PHPWEBCALENDAR_PASS", $phpwebcalendar_pass); $ok = "

Les identifiants webcalendar ont été sauvegardés.

"; } } else { $ok="

Le mot de passe n'est pas identique, veuillez le saisir à nouveau


\n"; } } /** * Affichage du formulaire de saisie */ print '
'; print "\n"; clearstatcache(); print "
".$langs->trans("Parameter")." ".$langs->trans("Value")."
Adresse URL d'accès au calendrier
Serveur où la base du calendrier est hébergée
Nom de la base de données
Identifiant d'accès à la base
".$langs->trans("Password")."
".$langs->trans("PasswordRetype")."
trans("TestConnection")."\"> trans("Save")."\">
\n"; /** * Test de la connection a la database webcalendar * */ if ($ok) print "$ok
"; if ($actiontest) { $conf = new Conf(); $conf->db->host = $phpwebcalendar_host; $conf->db->name = $phpwebcalendar_dbname; $conf->db->user = $phpwebcalendar_user; $conf->db->pass = $phpwebcalendar_pass; $webcal = new DoliDb(); if ($webcal->connected == 1) { print "

La connection à la base de données '$phpwebcalendar_dbname' à réussi


"; $webcal->close(); } else print "

La connection à la base de données '$phpwebcalendar_dbname' à échoué.


"; } llxFooter(); ?>