* Copyright (C) 2003 Éric Seigne * Copyright (C) 2004-2005 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 webcalendar \brief Page de configuration du module webcalendar \version $Revision$ */ require("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/lib/webcal.class.php'); if (!$user->admin) accessforbidden(); $langs->load("admin"); $langs->load("other"); $def = array(); $actiontest=$_POST["test"]; $actionsave=$_POST["save"]; // Test saisie mot de passe if ($_POST["phpwebcalendar_pass"] != $_POST["phpwebcalendar_pass2"]) { $mesg="
".$langs->trans("ErrorPasswordDiffers")."
"; } // Positionne la variable pour le test d'affichage de l'icone elseif ($actionsave) { $i=0; $db->begin(); $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_URL',trim($_POST["phpwebcalendar_url"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_HOST',trim($_POST["phpwebcalendar_host"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_DBNAME',trim($_POST["phpwebcalendar_dbname"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_USER',trim($_POST["phpwebcalendar_user"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_PASS',trim($_POST["phpwebcalendar_pass"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_SYNCRO',trim($_POST["phpwebcalendar_syncro"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_COMPANYCREATE',trim($_POST["phpwebcalendar_companycreate"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_PROPALSTATUS',trim($_POST["phpwebcalendar_propalstatus"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_CONTRACTSTATUS',trim($_POST["phpwebcalendar_contractstatus"]),'chaine',0); $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_BILLSTATUS',trim($_POST["phpwebcalendar_billstatus"]),'chaine',0); if ($i >= 9) { $db->commit(); $mesg = "".$langs->trans("WebCalSetupSaved").""; } else { $db->rollback(); header("Location: ".$_SERVER["PHP_SELF"]); exit; } } elseif ($actiontest) { //$resql=$db->query("select count(*) from llx_const"); //print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error().">
\n"; // Test de la connection a la database webcalendar $conf->webcal->db->type=$dolibarr_main_db_type; $conf->webcal->db->host=$_POST["phpwebcalendar_host"]; $conf->webcal->db->user=$_POST["phpwebcalendar_user"]; $conf->webcal->db->pass=$_POST["phpwebcalendar_pass"]; $conf->webcal->db->name=$_POST["phpwebcalendar_dbname"]; $webcal=new WebCal(); //print "D ".$db." - ".$db->db."
\n"; //print "W ".$webcal->localdb." - ".$webcal->localdb->db."
\n"; if ($webcal->localdb->connected == 1 && $webcal->localdb->database_selected == 1) { // Vérifie si bonne base $sql="SELECT cal_value FROM webcal_config WHERE cal_setting='application_name'"; $resql=$webcal->localdb->query($sql); if ($resql) { $mesg ="
".$langs->trans("WebCalTestOk",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_dbname"],$_POST["phpwebcalendar_user"]); $mesg.="
"; } else { $mesg ="
".$langs->trans("ErrorConnectOkButWrongDatabase"); $mesg.="
"; } //$webcal->localdb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique } elseif ($webcal->connected == 1 && $webcal->database_selected != 1) { $mesg ="
".$langs->trans("WebCalTestKo1",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_dbname"]); $mesg.="
".$webcal->localdb->error(); $mesg.="
"; //$webcal->localdb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique } else { $mesg ="
".$langs->trans("WebCalTestKo2",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_user"]); $mesg.="
".$webcal->localdb->error(); $mesg.="
"; } //$resql=$db->query("select count(*) from llx_const"); //print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error().">
\n"; } /** * Affichage du formulaire de saisie */ llxHeader(); print_fiche_titre($langs->trans("WebCalSetup"),'','setup'); print '
'; print '
'; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ""; print ''; print ""; print ""; print ""; print ""; print ''; print ""; print "
".$langs->trans("Parameter")."".$langs->trans("Value")."".$langs->trans("Examples")."
".$langs->trans("WebCalURL")."global->PHPWEBCALENDAR_URL) . "\" size=\"40\">http://localhost/webcalendar/"; print "
https://webcalendarserver/"; print "
".$langs->trans("WebCalServer")."global->PHPWEBCALENDAR_HOST) . "\" size=\"30\">localhost"; //print "
__dolibarr_main_db_host__ (".$dolibarr_main_db_host.")" print "
".$langs->trans("WebCalDatabaseName")."global->PHPWEBCALENDAR_DBNAME) . "\" size=\"30\">webcalendar"; //print "
__dolibarr_main_db_name__ (".$dolibarr_main_db_name.")"; print "
".$langs->trans("WebCalUser")."global->PHPWEBCALENDAR_USER) . "\" size=\"30\">webcaluser"; //print "
__dolibarr_main_db_user__ (".$dolibarr_main_db_user.")"; print "
".$langs->trans("Password")."global->PHPWEBCALENDAR_PASS) . "\" size=\"30\">'; //if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ ('.eregi_replace('.','*',$dolibarr_main_db_pass).')'; print ' 
".$langs->trans("PasswordRetype")."global->PHPWEBCALENDAR_PASS) ."\" size=\"30\">'; //if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ ('.eregi_replace('.','*',$dolibarr_main_db_pass).')'; print ' 
"; print "
"; $var=true; print ""; print ""; print ""; print ""; if ($conf->societe->enabled) { $var=!$var; print ''; print ''; print ''; } if ($conf->societe->enabled) { $var=!$var; print ''; print ''; print ''; } if ($conf->propal->enabled) { $var=!$var; print ''; print ''; print ''; } if ($conf->contrat->enabled) { $var=!$var; print ''; print ''; print ''; } if ($conf->facture->enabled) { $var=!$var; print ''; print ''; print ''; } print '
".$langs->trans("WebCalSyncro")."
'.$langs->trans("WebCalAddEventOnCreateActions").''; print ''; print '
'.$langs->trans("WebCalAddEventOnCreateCompany").''; print ''; print '
'.$langs->trans("WebCalAddEventOnStatusPropal").''; print ''; print '
'.$langs->trans("WebCalAddEventOnStatusContract").''; print ''; print '
'.$langs->trans("WebCalAddEventOnStatusBill").''; print ''; print '
'; print '
'; print "trans("TestConnection")."\">"; print "   "; print "trans("Save")."\">"; print "
"; print "
\n"; clearstatcache(); if ($mesg) print "
$mesg
"; print "
"; $db->close(); llxFooter('$Date$ - $Revision$'); ?>