[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2003 Éric Seigne <erics@rycks.com> 4 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 5 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> 6 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation; either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 21 * 22 * $Id: webcalendar.php,v 1.23 2005/10/03 01:36:21 eldy Exp $ 23 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/admin/webcalendar.php,v $ 24 */ 25 26 /** 27 \file htdocs/admin/webcalendar.php 28 \ingroup webcalendar 29 \brief Page de configuration du module webcalendar 30 \version $Revision: 1.23 $ 31 */ 32 33 require ("./pre.inc.php"); 34 require_once(DOL_DOCUMENT_ROOT.'/lib/webcal.class.php'); 35 36 37 if (!$user->admin) 38 accessforbidden(); 39 40 41 $langs->load("admin"); 42 $langs->load("other"); 43 44 $def = array(); 45 $actiontest=$_POST["test"]; 46 $actionsave=$_POST["save"]; 47 48 // Test saisie mot de passe 49 if ($_POST["phpwebcalendar_pass"] != $_POST["phpwebcalendar_pass2"]) 50 { 51 $mesg="<div class=\"error\">".$langs->trans("ErrorPasswordDiffers")."</div>"; 52 } 53 // Positionne la variable pour le test d'affichage de l'icone 54 elseif ($actionsave) 55 { 56 $i=0; 57 58 $db->begin(); 59 60 $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_URL',trim($_POST["phpwebcalendar_url"]),'',0); 61 $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_HOST',trim($_POST["phpwebcalendar_host"]),'',0); 62 $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_DBNAME',trim($_POST["phpwebcalendar_dbname"]),'',0); 63 $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_USER',trim($_POST["phpwebcalendar_user"]),'',0); 64 $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_PASS',trim($_POST["phpwebcalendar_pass"]),'',0); 65 66 $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_SYNCRO',trim($_POST["phpwebcalendar_syncro"]),'',0); 67 $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_COMPANYCREATE',trim($_POST["phpwebcalendar_companycreate"]),'',0); 68 $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_CONTRACTSTATUS',trim($_POST["phpwebcalendar_contractstatus"]),'',0); 69 $i+=dolibarr_set_const($db,'PHPWEBCALENDAR_BILLSTATUS',trim($_POST["phpwebcalendar_billstatus"]),'',0); 70 71 if ($i >= 9) 72 { 73 $db->commit(); 74 header("Location: webcalendar.php"); 75 exit; 76 } 77 else 78 { 79 $db->rollback(); 80 $mesg = "<font class=\"ok\">".$langs->trans("WebCalSetupSaved")."</font>"; 81 } 82 } 83 elseif ($actiontest) 84 { 85 //$resql=$db->query("select count(*) from llx_const"); 86 //print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error()."><br>\n"; 87 88 // Test de la connection a la database webcalendar 89 $conf->webcal->db->type=$dolibarr_main_db_type; 90 $conf->webcal->db->host=$_POST["phpwebcalendar_host"]; 91 $conf->webcal->db->user=$_POST["phpwebcalendar_user"]; 92 $conf->webcal->db->pass=$_POST["phpwebcalendar_pass"]; 93 $conf->webcal->db->name=$_POST["phpwebcalendar_dbname"]; 94 95 $webcal=new WebCal(); 96 97 //print "D ".$db." - ".$db->db."<br>\n"; 98 //print "W ".$webcal->localdb." - ".$webcal->localdb->db."<br>\n"; 99 100 if ($webcal->localdb->connected == 1 && $webcal->localdb->database_selected == 1) 101 { 102 // Vérifie si bonne base 103 $sql="SELECT cal_value FROM webcal_config WHERE cal_setting='application_name'"; 104 $resql=$webcal->localdb->query($sql); 105 if ($resql) { 106 $mesg ="<div class=\"ok\">".$langs->trans("WebCalTestOk",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_dbname"],$_POST["phpwebcalendar_user"]); 107 $mesg.="</div>"; 108 } 109 else { 110 $mesg ="<div class=\"error\">".$langs->trans("ErrorConnectOkButWrongDatabase"); 111 $mesg.="</div>"; 112 } 113 114 //$webcal->localdb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique 115 } 116 elseif ($webcal->connected == 1 && $webcal->database_selected != 1) 117 { 118 $mesg ="<div class=\"error\">".$langs->trans("WebCalTestKo1",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_dbname"]); 119 $mesg.="<br>".$webcal->localdb->error(); 120 $mesg.="</div>"; 121 //$webcal->localdb->close(); Ne pas fermer car la conn de webcal est la meme que dolibarr si parametre host/user/pass identique 122 } 123 else 124 { 125 $mesg ="<div class=\"error\">".$langs->trans("WebCalTestKo2",$_POST["phpwebcalendar_host"],$_POST["phpwebcalendar_user"]); 126 $mesg.="<br>".$webcal->localdb->error(); 127 $mesg.="</div>"; 128 } 129 130 //$resql=$db->query("select count(*) from llx_const"); 131 //print "< ".$db." - ".$db->db." - ".$resql." - ".$db->error()."><br>\n"; 132 } 133 134 135 /** 136 * Affichage du formulaire de saisie 137 */ 138 139 llxHeader(); 140 141 print_titre($langs->trans("WebCalSetup")); 142 print '<br>'; 143 144 145 print '<form name="phpwebcalendarconfig" action="webcalendar.php" method="post">'; 146 print "<table class=\"noborder\" width=\"100%\">"; 147 print "<tr class=\"liste_titre\">"; 148 print "<td width=\"30%\">".$langs->trans("Parameter")."</td>"; 149 print "<td>".$langs->trans("Value")."</td>"; 150 print "<td>".$langs->trans("Examples")."</td>"; 151 print "</tr>"; 152 print "<tr class=\"impair\">"; 153 print "<td>".$langs->trans("WebCalURL")."</td>"; 154 print "<td><input type=\"text\" class=\"flat\" name=\"phpwebcalendar_url\" value=\"". ($_POST["phpwebcalendar_url"]?$_POST["phpwebcalendar_url"]:$conf->global->PHPWEBCALENDAR_URL) . "\" size=\"40\"></td>"; 155 print "<td>http://localhost/webcalendar/"; 156 print "<br>https://webcalendarserver/"; 157 print "</td>"; 158 print "</tr>"; 159 print "<tr class=\"pair\">"; 160 print "<td>".$langs->trans("WebCalServer")."</td>"; 161 print "<td><input type=\"text\" class=\"flat\" name=\"phpwebcalendar_host\" value=\"". ($_POST["phpwebcalendar_host"]?$_POST["phpwebcalendar_host"]:$conf->global->PHPWEBCALENDAR_HOST) . "\" size=\"30\"></td>"; 162 print "<td>localhost"; 163 //print "<br>__dolibarr_main_db_host__ <i>(".$dolibarr_main_db_host.")</i>" 164 print "</td>"; 165 print "</tr>"; 166 print "<tr class=\"impair\">"; 167 print "<td>".$langs->trans("WebCalDatabaseName")."</td>"; 168 print "<td><input type=\"text\" class=\"flat\" name=\"phpwebcalendar_dbname\" value=\"". ($_POST["phpwebcalendar_dbname"]?$_POST["phpwebcalendar_dbname"]:$conf->global->PHPWEBCALENDAR_DBNAME) . "\" size=\"30\"></td>"; 169 print "<td>webcalendar"; 170 //print "<br>__dolibarr_main_db_name__ <i>(".$dolibarr_main_db_name.")</i>"; 171 print "</td>"; 172 print "</tr>"; 173 print "<tr class=\"pair\">"; 174 print "<td>".$langs->trans("WebCalUser")."</td>"; 175 print "<td><input type=\"text\" class=\"flat\" name=\"phpwebcalendar_user\" value=\"". ($_POST["phpwebcalendar_user"]?$_POST["phpwebcalendar_user"]:$conf->global->PHPWEBCALENDAR_USER) . "\" size=\"30\"></td>"; 176 print "<td>webcaluser"; 177 //print "<br>__dolibarr_main_db_user__ <i>(".$dolibarr_main_db_user.")</i>"; 178 print "</td>"; 179 print "</tr>"; 180 print "<tr class=\"impair\">"; 181 print "<td>".$langs->trans("Password")."</td>"; 182 print "<td><input type=\"password\" class=\"flat\" name=\"phpwebcalendar_pass\" value=\"" . ($_POST["phpwebcalendar_pass"]?$_POST["phpwebcalendar_pass"]:$conf->global->PHPWEBCALENDAR_PASS) . "\" size=\"30\"></td>"; 183 print '<td>'; 184 //if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ <i>('.eregi_replace('.','*',$dolibarr_main_db_pass).')</i>'; 185 print ' </td>'; 186 print "</tr>"; 187 print "<tr class=\"pair\">"; 188 print "<td>".$langs->trans("PasswordRetype")."</td>"; 189 print "<td><input type=\"password\" class=\"flat\" name=\"phpwebcalendar_pass2\" value=\"" . ($_POST["phpwebcalendar_pass2"]?$_POST["phpwebcalendar_pass2"]:$conf->global->PHPWEBCALENDAR_PASS) ."\" size=\"30\"></td>"; 190 print '<td>'; 191 //if ($dolibarr_main_db_pass) print '__dolibarr_main_db_pass__ <i>('.eregi_replace('.','*',$dolibarr_main_db_pass).')</i>'; 192 print ' </td>'; 193 print "</tr>"; 194 print "</table>"; 195 print "<br>"; 196 197 $var=true; 198 print "<table class=\"noborder\" width=\"100%\">"; 199 print "<tr class=\"liste_titre\">"; 200 print "<td colspan=\"2\">".$langs->trans("WebCalSyncro")."</td>"; 201 print "</tr>"; 202 if ($conf->societe->enabled) 203 { 204 $var=!$var; 205 print '<tr '.$bc[$var].'>'; 206 print '<td>'.$langs->trans("WebCalAddEventOnCreateActions").'</td>'; 207 print '<td>'; 208 print '<select name="phpwebcalendar_syncro" class="flat">'; 209 print '<option value="always"'.($conf->global->PHPWEBCALENDAR_SYNCRO=='always'?' selected="true"':'').'>'.$langs->trans("WebCalAllways").'</option>'; 210 print '<option value="yesbydefault"'.($conf->global->PHPWEBCALENDAR_SYNCRO=='yesbydefault'?' selected="true"':'').'>'.$langs->trans("WebCalYesByDefault").'</option>'; 211 print '<option value="nobydefault"'.((! $conf->global->PHPWEBCALENDAR_SYNCRO || $conf->global->PHPWEBCALENDAR_SYNCRO=='nobydefault')?' selected="true"':'').'>'.$langs->trans("WebCalNoByDefault").'</option>'; 212 print '<option value="never"'.($conf->global->PHPWEBCALENDAR_SYNCRO=='never'?' selected="true"':'').'>'.$langs->trans("WebCalNever").'</option>'; 213 print '</select>'; 214 print '</td></tr>'; 215 } 216 if ($conf->societe->enabled) 217 { 218 $var=!$var; 219 print '<tr '.$bc[$var].'>'; 220 print '<td>'.$langs->trans("WebCalAddEventOnCreateCompany").'</td>'; 221 print '<td>'; 222 print '<select name="phpwebcalendar_companycreate" class="flat">'; 223 print '<option value="always"'.($conf->global->PHPWEBCALENDAR_COMPANYCREATE=='always'?' selected="true"':'').'>'.$langs->trans("WebCalAllways").'</option>'; 224 print '<option value="never"'.(! $conf->global->PHPWEBCALENDAR_COMPANYCREATE || $conf->global->PHPWEBCALENDAR_COMPANYCREATE=='never'?' selected="true"':'').'>'.$langs->trans("WebCalNever").'</option>'; 225 print '</select>'; 226 print '</td></tr>'; 227 } 228 if ($conf->contrat->enabled) 229 { 230 $var=!$var; 231 print '<tr '.$bc[$var].'>'; 232 print '<td>'.$langs->trans("WebCalAddEventOnStatusContract").'</td>'; 233 print '<td>'; 234 print '<select name="phpwebcalendar_contractstatus" class="flat">'; 235 print '<option value="always"'.($conf->global->PHPWEBCALENDAR_CONTRACTSTATUS=='always'?' selected="true"':'').'>'.$langs->trans("WebCalAllways").'</option>'; 236 print '<option value="never"'.(! $conf->global->PHPWEBCALENDAR_CONTRACTSTATUS || $conf->global->PHPWEBCALENDAR_CONTRACTSTATUS=='never'?' selected="true"':'').'>'.$langs->trans("WebCalNever").'</option>'; 237 print '</select>'; 238 print '</td></tr>'; 239 } 240 if ($conf->facture->enabled) 241 { 242 $var=!$var; 243 print '<tr '.$bc[$var].'>'; 244 print '<td>'.$langs->trans("WebCalAddEventOnStatusBill").'</td>'; 245 print '<td>'; 246 print '<select name="phpwebcalendar_billstatus" class="flat">'; 247 print '<option value="always"'.($conf->global->PHPWEBCALENDAR_BILLSTATUS=='always'?' selected="true"':'').'>'.$langs->trans("WebCalAllways").'</option>'; 248 print '<option value="never"'.(! $conf->global->PHPWEBCALENDAR_BILLSTATUS || $conf->global->PHPWEBCALENDAR_BILLSTATUS=='never'?' selected="true"':'').'>'.$langs->trans("WebCalNever").'</option>'; 249 print '</select>'; 250 print '</td></tr>'; 251 print '</table>'; 252 } 253 print '<br><center>'; 254 print "<input type=\"submit\" name=\"test\" class=\"button\" value=\"".$langs->trans("TestConnection")."\">"; 255 print " "; 256 print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">"; 257 print "</center>"; 258 259 print "</form>\n"; 260 261 262 clearstatcache(); 263 264 if ($mesg) print "<br>$mesg<br>"; 265 print "<br>"; 266 267 $db->close(); 268 269 llxFooter('$Date: 2005/10/03 01:36:21 $ - $Revision: 1.23 $'); 270 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |