@@ -70,8 +70,12 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | dol_syslog(get_class($this)."::DolEditor htmlname=".$htmlname." width=".$width." height=".$height." toolbarname=".$toolbarname); |
| 72 | 72 | |
| 73 | - if (! $rows) $rows=round($height/20); |
|
| 74 | - if (! $cols) $cols=($width?round($width/6):80); |
|
| 73 | + if (! $rows) { |
|
| 74 | + $rows=round($height/20); |
|
| 75 | + } |
|
| 76 | + if (! $cols) { |
|
| 77 | + $cols=($width?round($width/6):80); |
|
| 78 | + } |
|
| 75 | 79 | $shorttoolbarname=preg_replace('/_encoded$/','',$toolbarname); |
| 76 | 80 | |
| 77 | 81 | // Name of extended editor to use (FCKEDITOR_EDITORNAME can be 'ckeditor' or 'fckeditor') |
@@ -81,8 +85,12 @@ discard block |
||
| 81 | 85 | $this->readonly=$readonly; |
| 82 | 86 | |
| 83 | 87 | // Check if extended editor is ok. If not we force textarea |
| 84 | - if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) $this->tool = 'textarea'; |
|
| 85 | - if ($okforextendededitor === 'ace') $this->tool='ace'; |
|
| 88 | + if ((empty($conf->fckeditor->enabled) && $okforextendededitor != 'ace') || empty($okforextendededitor)) { |
|
| 89 | + $this->tool = 'textarea'; |
|
| 90 | + } |
|
| 91 | + if ($okforextendededitor === 'ace') { |
|
| 92 | + $this->tool='ace'; |
|
| 93 | + } |
|
| 86 | 94 | //if ($conf->dol_use_jmobile) $this->tool = 'textarea'; // ckeditor and ace seems ok with mobile |
| 87 | 95 | |
| 88 | 96 | // Define content and some properties |
@@ -100,7 +108,9 @@ discard block |
||
| 100 | 108 | $this->editor->BasePath = DOL_URL_ROOT.'/includes/fckeditor/' ; |
| 101 | 109 | $this->editor->Value = $content; |
| 102 | 110 | $this->editor->Height = $height; |
| 103 | - if (! empty($width)) $this->editor->Width = $width; |
|
| 111 | + if (! empty($width)) { |
|
| 112 | + $this->editor->Width = $width; |
|
| 113 | + } |
|
| 104 | 114 | $this->editor->ToolbarSet = $shorttoolbarname; // Profile of this toolbar set is deinfed into theme/mytheme/ckeditor/config.js |
| 105 | 115 | $this->editor->Config['AutoDetectLanguage'] = 'true'; // Language of user (browser) |
| 106 | 116 | $this->editor->Config['ToolbarLocation'] = $toolbarlocation ? $toolbarlocation : 'In'; |
@@ -163,9 +173,11 @@ discard block |
||
| 163 | 173 | $found=0; |
| 164 | 174 | $out=''; |
| 165 | 175 | |
| 166 | - if ($this->tool == 'fckeditor') // not used anymore |
|
| 176 | + if ($this->tool == 'fckeditor') { |
|
| 177 | + // not used anymore |
|
| 167 | 178 | { |
| 168 | 179 | $found=1; |
| 180 | + } |
|
| 169 | 181 | $this->editor->Create(); |
| 170 | 182 | } |
| 171 | 183 | if (in_array($this->tool,array('textarea','ckeditor'))) |
@@ -179,7 +191,9 @@ discard block |
||
| 179 | 191 | |
| 180 | 192 | if ($this->tool == 'ckeditor' && ! empty($conf->use_javascript_ajax)) |
| 181 | 193 | { |
| 182 | - if (! defined('REQUIRE_CKEDITOR')) define('REQUIRE_CKEDITOR','1'); |
|
| 194 | + if (! defined('REQUIRE_CKEDITOR')) { |
|
| 195 | + define('REQUIRE_CKEDITOR','1'); |
|
| 196 | + } |
|
| 183 | 197 | |
| 184 | 198 | if (! empty($conf->global->FCKEDITOR_SKIN)) { |
| 185 | 199 | $skin = $conf->global->FCKEDITOR_SKIN; |
@@ -343,7 +357,10 @@ discard block |
||
| 343 | 357 | $out.= 'Error, unknown value for tool '.$this->tool.' in DolEditor Create function.'; |
| 344 | 358 | } |
| 345 | 359 | |
| 346 | - if ($noprint) return $out; |
|
| 347 | - else print $out; |
|
| 360 | + if ($noprint) { |
|
| 361 | + return $out; |
|
| 362 | + } else { |
|
| 363 | + print $out; |
|
| 364 | + } |
|
| 348 | 365 | } |
| 349 | 366 | } |
@@ -70,7 +70,9 @@ discard block |
||
| 70 | 70 | $sql = "SELECT id, code, libelle"; |
| 71 | 71 | $sql.= " FROM ".MAIN_DB_PREFIX."c_typent"; |
| 72 | 72 | $sql.= " WHERE active = 1 AND (fk_country IS NULL OR fk_country = ".(empty($mysoc->country_id)?'0':$mysoc->country_id).")"; |
| 73 | - if ($filter) $sql.=" ".$filter; |
|
| 73 | + if ($filter) { |
|
| 74 | + $sql.=" ".$filter; |
|
| 75 | + } |
|
| 74 | 76 | $sql.= " ORDER by position, id"; |
| 75 | 77 | dol_syslog(get_class($this).'::typent_array', LOG_DEBUG); |
| 76 | 78 | $resql=$this->db->query($sql); |
@@ -82,11 +84,19 @@ discard block |
||
| 82 | 84 | while ($i < $num) |
| 83 | 85 | { |
| 84 | 86 | $objp = $this->db->fetch_object($resql); |
| 85 | - if (! $mode) $key=$objp->id; |
|
| 86 | - else $key=$objp->code; |
|
| 87 | - if ($langs->trans($objp->code) != $objp->code) $effs[$key] = $langs->trans($objp->code); |
|
| 88 | - else $effs[$key] = $objp->libelle; |
|
| 89 | - if ($effs[$key]=='-') $effs[$key]=''; |
|
| 87 | + if (! $mode) { |
|
| 88 | + $key=$objp->id; |
|
| 89 | + } else { |
|
| 90 | + $key=$objp->code; |
|
| 91 | + } |
|
| 92 | + if ($langs->trans($objp->code) != $objp->code) { |
|
| 93 | + $effs[$key] = $langs->trans($objp->code); |
|
| 94 | + } else { |
|
| 95 | + $effs[$key] = $objp->libelle; |
|
| 96 | + } |
|
| 97 | + if ($effs[$key]=='-') { |
|
| 98 | + $effs[$key]=''; |
|
| 99 | + } |
|
| 90 | 100 | $i++; |
| 91 | 101 | } |
| 92 | 102 | $this->db->free($resql); |
@@ -111,7 +121,9 @@ discard block |
||
| 111 | 121 | $sql = "SELECT id, code, libelle"; |
| 112 | 122 | $sql .= " FROM ".MAIN_DB_PREFIX."c_effectif"; |
| 113 | 123 | $sql.= " WHERE active = 1"; |
| 114 | - if ($filter) $sql.=" ".$filter; |
|
| 124 | + if ($filter) { |
|
| 125 | + $sql.=" ".$filter; |
|
| 126 | + } |
|
| 115 | 127 | $sql .= " ORDER BY id ASC"; |
| 116 | 128 | dol_syslog(get_class($this).'::effectif_array', LOG_DEBUG); |
| 117 | 129 | $resql=$this->db->query($sql); |
@@ -123,8 +135,11 @@ discard block |
||
| 123 | 135 | while ($i < $num) |
| 124 | 136 | { |
| 125 | 137 | $objp = $this->db->fetch_object($resql); |
| 126 | - if (! $mode) $key=$objp->id; |
|
| 127 | - else $key=$objp->code; |
|
| 138 | + if (! $mode) { |
|
| 139 | + $key=$objp->id; |
|
| 140 | + } else { |
|
| 141 | + $key=$objp->code; |
|
| 142 | + } |
|
| 128 | 143 | |
| 129 | 144 | $effs[$key] = $objp->libelle!='-'?$objp->libelle:''; |
| 130 | 145 | $i++; |
@@ -179,9 +194,12 @@ discard block |
||
| 179 | 194 | } |
| 180 | 195 | |
| 181 | 196 | print Form::selectarray($htmlname, $options, $selected); |
| 197 | + } else { |
|
| 198 | + dol_print_error($this->db); |
|
| 199 | + } |
|
| 200 | + if (! empty($htmlname) && $user->admin) { |
|
| 201 | + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 182 | 202 | } |
| 183 | - else dol_print_error($this->db); |
|
| 184 | - if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 185 | 203 | print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">'; |
| 186 | 204 | print '</form>'; |
| 187 | 205 | } |
@@ -235,15 +253,23 @@ discard block |
||
| 235 | 253 | $sql .= " ".MAIN_DB_PREFIX ."c_departements as d, ".MAIN_DB_PREFIX."c_regions as r,".MAIN_DB_PREFIX."c_country as c"; |
| 236 | 254 | $sql .= " WHERE d.fk_region=r.code_region and r.fk_pays=c.rowid"; |
| 237 | 255 | $sql .= " AND d.active = 1 AND r.active = 1 AND c.active = 1"; |
| 238 | - if ($country_codeid && is_numeric($country_codeid)) $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; |
|
| 239 | - if ($country_codeid && ! is_numeric($country_codeid)) $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
| 256 | + if ($country_codeid && is_numeric($country_codeid)) { |
|
| 257 | + $sql .= " AND c.rowid = '".$this->db->escape($country_codeid)."'"; |
|
| 258 | + } |
|
| 259 | + if ($country_codeid && ! is_numeric($country_codeid)) { |
|
| 260 | + $sql .= " AND c.code = '".$this->db->escape($country_codeid)."'"; |
|
| 261 | + } |
|
| 240 | 262 | $sql .= " ORDER BY c.code, d.code_departement"; |
| 241 | 263 | |
| 242 | 264 | $result=$this->db->query($sql); |
| 243 | 265 | if ($result) |
| 244 | 266 | { |
| 245 | - if (!empty($htmlname)) $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
| 246 | - if ($country_codeid) $out.= '<option value="0"> </option>'; |
|
| 267 | + if (!empty($htmlname)) { |
|
| 268 | + $out.= '<select id="'.$htmlname.'" class="flat maxwidth200onsmartphone minwidth300" name="'.$htmlname.'">'; |
|
| 269 | + } |
|
| 270 | + if ($country_codeid) { |
|
| 271 | + $out.= '<option value="0"> </option>'; |
|
| 272 | + } |
|
| 247 | 273 | $num = $this->db->num_rows($result); |
| 248 | 274 | $i = 0; |
| 249 | 275 | dol_syslog(get_class($this)."::select_departement num=".$num,LOG_DEBUG); |
@@ -253,11 +279,12 @@ discard block |
||
| 253 | 279 | while ($i < $num) |
| 254 | 280 | { |
| 255 | 281 | $obj = $this->db->fetch_object($result); |
| 256 | - if ($obj->code == '0') // Le code peut etre une chaine |
|
| 282 | + if ($obj->code == '0') { |
|
| 283 | + // Le code peut etre une chaine |
|
| 257 | 284 | { |
| 258 | 285 | $out.= '<option value="0"> </option>'; |
| 259 | 286 | } |
| 260 | - else { |
|
| 287 | + } else { |
|
| 261 | 288 | if (! $country || $country != $obj->country) |
| 262 | 289 | { |
| 263 | 290 | // Affiche la rupture si on est en mode liste multipays |
@@ -272,8 +299,7 @@ discard block |
||
| 272 | 299 | || (empty($selected) && ! empty($conf->global->MAIN_FORCE_DEFAULT_STATE_ID) && $conf->global->MAIN_FORCE_DEFAULT_STATE_ID == $obj->rowid)) |
| 273 | 300 | { |
| 274 | 301 | $out.= '<option value="'.$obj->rowid.'" selected>'; |
| 275 | - } |
|
| 276 | - else |
|
| 302 | + } else |
|
| 277 | 303 | { |
| 278 | 304 | $out.= '<option value="'.$obj->rowid.'">'; |
| 279 | 305 | } |
@@ -283,16 +309,13 @@ discard block |
||
| 283 | 309 | ($conf->global->MAIN_SHOW_STATE_CODE == 1 || $conf->global->MAIN_SHOW_STATE_CODE == 2 || $conf->global->MAIN_SHOW_STATE_CODE === 'all')) { |
| 284 | 310 | if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
| 285 | 311 | $out.= $obj->region_name . ' - ' . $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
| 286 | - } |
|
| 287 | - else { |
|
| 312 | + } else { |
|
| 288 | 313 | $out.= $obj->code . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
| 289 | 314 | } |
| 290 | - } |
|
| 291 | - else { |
|
| 315 | + } else { |
|
| 292 | 316 | if(!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1) { |
| 293 | 317 | $out.= $obj->region_name . ' - ' . ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
| 294 | - } |
|
| 295 | - else { |
|
| 318 | + } else { |
|
| 296 | 319 | $out.= ($langs->trans($obj->code)!=$obj->code?$langs->trans($obj->code):($obj->name!='-'?$obj->name:'')); |
| 297 | 320 | } |
| 298 | 321 | } |
@@ -302,10 +325,13 @@ discard block |
||
| 302 | 325 | $i++; |
| 303 | 326 | } |
| 304 | 327 | } |
| 305 | - if (! empty($htmlname)) $out.= '</select>'; |
|
| 306 | - if (! empty($htmlname) && $user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 307 | - } |
|
| 308 | - else |
|
| 328 | + if (! empty($htmlname)) { |
|
| 329 | + $out.= '</select>'; |
|
| 330 | + } |
|
| 331 | + if (! empty($htmlname) && $user->admin) { |
|
| 332 | + $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 333 | + } |
|
| 334 | + } else |
|
| 309 | 335 | { |
| 310 | 336 | dol_print_error($this->db); |
| 311 | 337 | } |
@@ -358,8 +384,7 @@ discard block |
||
| 358 | 384 | $obj = $this->db->fetch_object($resql); |
| 359 | 385 | if ($obj->code == 0) { |
| 360 | 386 | print '<option value="0"> </option>'; |
| 361 | - } |
|
| 362 | - else { |
|
| 387 | + } else { |
|
| 363 | 388 | if ($country == '' || $country != $obj->country) |
| 364 | 389 | { |
| 365 | 390 | // Show break |
@@ -372,8 +397,7 @@ discard block |
||
| 372 | 397 | if ($selected > 0 && $selected == $obj->code) |
| 373 | 398 | { |
| 374 | 399 | print '<option value="'.$obj->code.'" selected>'.$obj->label.'</option>'; |
| 375 | - } |
|
| 376 | - else |
|
| 400 | + } else |
|
| 377 | 401 | { |
| 378 | 402 | print '<option value="'.$obj->code.'">'.$obj->label.'</option>'; |
| 379 | 403 | } |
@@ -382,8 +406,7 @@ discard block |
||
| 382 | 406 | } |
| 383 | 407 | } |
| 384 | 408 | print '</select>'; |
| 385 | - } |
|
| 386 | - else |
|
| 409 | + } else |
|
| 387 | 410 | { |
| 388 | 411 | dol_print_error($this->db); |
| 389 | 412 | } |
@@ -425,8 +448,7 @@ discard block |
||
| 425 | 448 | if ($selected == $obj->code) |
| 426 | 449 | { |
| 427 | 450 | $out.= '<option value="'.$obj->code.'" selected>'; |
| 428 | - } |
|
| 429 | - else |
|
| 451 | + } else |
|
| 430 | 452 | { |
| 431 | 453 | $out.= '<option value="'.$obj->code.'">'; |
| 432 | 454 | } |
@@ -437,9 +459,10 @@ discard block |
||
| 437 | 459 | } |
| 438 | 460 | } |
| 439 | 461 | $out.= '</select>'; |
| 440 | - if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 441 | - } |
|
| 442 | - else |
|
| 462 | + if ($user->admin) { |
|
| 463 | + $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 464 | + } |
|
| 465 | + } else |
|
| 443 | 466 | { |
| 444 | 467 | dol_print_error($this->db); |
| 445 | 468 | } |
@@ -489,8 +512,12 @@ discard block |
||
| 489 | 512 | $sql .= " FROM ".MAIN_DB_PREFIX."c_forme_juridique as f, ".MAIN_DB_PREFIX."c_country as c"; |
| 490 | 513 | $sql .= " WHERE f.fk_pays=c.rowid"; |
| 491 | 514 | $sql .= " AND f.active = 1 AND c.active = 1"; |
| 492 | - if ($country_codeid) $sql .= " AND c.code = '".$country_codeid."'"; |
|
| 493 | - if ($filter) $sql .= " ".$filter; |
|
| 515 | + if ($country_codeid) { |
|
| 516 | + $sql .= " AND c.code = '".$country_codeid."'"; |
|
| 517 | + } |
|
| 518 | + if ($filter) { |
|
| 519 | + $sql .= " ".$filter; |
|
| 520 | + } |
|
| 494 | 521 | $sql .= " ORDER BY c.code"; |
| 495 | 522 | |
| 496 | 523 | dol_syslog(get_class($this)."::select_juridicalstatus", LOG_DEBUG); |
@@ -499,7 +526,10 @@ discard block |
||
| 499 | 526 | { |
| 500 | 527 | $out.= '<div id="particulier2" class="visible">'; |
| 501 | 528 | $out.= '<select class="flat minwidth200" name="'.$htmlname.'" id="'.$htmlname.'">'; |
| 502 | - if ($country_codeid) $out.= '<option value="0"> </option>'; // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
| 529 | + if ($country_codeid) { |
|
| 530 | + $out.= '<option value="0"> </option>'; |
|
| 531 | + } |
|
| 532 | + // When country_codeid is set, we force to add an empty line because it does not appears from select. When not set, we already get the empty line from select. |
|
| 503 | 533 | |
| 504 | 534 | $num = $this->db->num_rows($resql); |
| 505 | 535 | if ($num) |
@@ -510,9 +540,11 @@ discard block |
||
| 510 | 540 | { |
| 511 | 541 | $obj = $this->db->fetch_object($resql); |
| 512 | 542 | |
| 513 | - if ($obj->code) // We exclude empty line, we will add it later |
|
| 543 | + if ($obj->code) { |
|
| 544 | + // We exclude empty line, we will add it later |
|
| 514 | 545 | { |
| 515 | 546 | $labelcountry=(($langs->trans("Country".$obj->country_code)!="Country".$obj->country_code) ? $langs->trans("Country".$obj->country_code) : $obj->country); |
| 547 | + } |
|
| 516 | 548 | $labeljs=(($langs->trans("JuridicalStatus".$obj->code)!="JuridicalStatus".$obj->code) ? $langs->trans("JuridicalStatus".$obj->code) : ($obj->label!='-'?$obj->label:'')); // $obj->label is already in output charset (converted by database driver) |
| 517 | 549 | $arraydata[$obj->code]=array('code'=>$obj->code, 'label'=>$labeljs, 'label_sort'=>$labelcountry.'_'.$labeljs, 'country_code'=>$obj->country_code, 'country'=>$labelcountry); |
| 518 | 550 | } |
@@ -520,10 +552,12 @@ discard block |
||
| 520 | 552 | } |
| 521 | 553 | |
| 522 | 554 | $arraydata=dol_sort_array($arraydata, 'label_sort', 'ASC'); |
| 523 | - if (empty($country_codeid)) // Introduce empty value (if $country_codeid not empty, empty value was already added) |
|
| 555 | + if (empty($country_codeid)) { |
|
| 556 | + // Introduce empty value (if $country_codeid not empty, empty value was already added) |
|
| 524 | 557 | { |
| 525 | 558 | $arraydata[0]=array('code'=>0, 'label'=>'', 'label_sort'=>'_', 'country_code'=>'', 'country'=>''); |
| 526 | 559 | } |
| 560 | + } |
|
| 527 | 561 | |
| 528 | 562 | foreach($arraydata as $key => $val) |
| 529 | 563 | { |
@@ -540,8 +574,7 @@ discard block |
||
| 540 | 574 | if ($selected > 0 && $selected == $val['code']) |
| 541 | 575 | { |
| 542 | 576 | $out.= '<option value="'.$val['code'].'" selected>'; |
| 543 | - } |
|
| 544 | - else |
|
| 577 | + } else |
|
| 545 | 578 | { |
| 546 | 579 | $out.= '<option value="'.$val['code'].'">'; |
| 547 | 580 | } |
@@ -551,15 +584,16 @@ discard block |
||
| 551 | 584 | } |
| 552 | 585 | } |
| 553 | 586 | $out.= '</select>'; |
| 554 | - if ($user->admin) $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 587 | + if ($user->admin) { |
|
| 588 | + $out.= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 589 | + } |
|
| 555 | 590 | |
| 556 | 591 | // Make select dynamic |
| 557 | 592 | include_once DOL_DOCUMENT_ROOT . '/core/lib/ajax.lib.php'; |
| 558 | 593 | $out .= ajax_combobox($htmlname); |
| 559 | 594 | |
| 560 | 595 | $out.= '</div>'; |
| 561 | - } |
|
| 562 | - else |
|
| 596 | + } else |
|
| 563 | 597 | { |
| 564 | 598 | dol_print_error($this->db); |
| 565 | 599 | } |
@@ -611,7 +645,8 @@ discard block |
||
| 611 | 645 | // To refresh contacts list on thirdparty list change |
| 612 | 646 | $events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php',1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled')); |
| 613 | 647 | |
| 614 | - if (count($events)) // If there is some ajax events to run once selection is done, we add code here to run events |
|
| 648 | + if (count($events)) { |
|
| 649 | + // If there is some ajax events to run once selection is done, we add code here to run events |
|
| 615 | 650 | { |
| 616 | 651 | print '<script type="text/javascript"> |
| 617 | 652 | jQuery(document).ready(function() { |
@@ -662,13 +697,13 @@ discard block |
||
| 662 | 697 | }); |
| 663 | 698 | </script>'; |
| 664 | 699 | } |
| 700 | + } |
|
| 665 | 701 | |
| 666 | 702 | print "\n".'<!-- Input text for third party with Ajax.Autocompleter (selectCompaniesForNewContact) -->'."\n"; |
| 667 | 703 | print '<input type="text" size="30" id="search_'.$htmlname.'" name="search_'.$htmlname.'" value="'.$name.'" />'; |
| 668 | 704 | print ajax_autocompleter(($socid?$socid:-1), $htmlname, DOL_URL_ROOT.'/societe/ajaxcompanies.php', '', $minLength, 0); |
| 669 | 705 | return $socid; |
| 670 | - } |
|
| 671 | - else |
|
| 706 | + } else |
|
| 672 | 707 | { |
| 673 | 708 | // Search to list thirdparties |
| 674 | 709 | $sql = "SELECT s.rowid, s.nom as name FROM"; |
@@ -698,20 +733,27 @@ discard block |
||
| 698 | 733 | while ($i < $num) |
| 699 | 734 | { |
| 700 | 735 | $obj = $this->db->fetch_object($resql); |
| 701 | - if ($i == 0) $firstCompany = $obj->rowid; |
|
| 736 | + if ($i == 0) { |
|
| 737 | + $firstCompany = $obj->rowid; |
|
| 738 | + } |
|
| 702 | 739 | $disabled=0; |
| 703 | - if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) $disabled=1; |
|
| 740 | + if (is_array($limitto) && count($limitto) && ! in_array($obj->rowid,$limitto)) { |
|
| 741 | + $disabled=1; |
|
| 742 | + } |
|
| 704 | 743 | if ($selected > 0 && $selected == $obj->rowid) |
| 705 | 744 | { |
| 706 | 745 | print '<option value="'.$obj->rowid.'"'; |
| 707 | - if ($disabled) print ' disabled'; |
|
| 746 | + if ($disabled) { |
|
| 747 | + print ' disabled'; |
|
| 748 | + } |
|
| 708 | 749 | print ' selected>'.dol_trunc($obj->name,24).'</option>'; |
| 709 | 750 | $firstCompany = $obj->rowid; |
| 710 | - } |
|
| 711 | - else |
|
| 751 | + } else |
|
| 712 | 752 | { |
| 713 | 753 | print '<option value="'.$obj->rowid.'"'; |
| 714 | - if ($disabled) print ' disabled'; |
|
| 754 | + if ($disabled) { |
|
| 755 | + print ' disabled'; |
|
| 756 | + } |
|
| 715 | 757 | print '>'.dol_trunc($obj->name,24).'</option>'; |
| 716 | 758 | } |
| 717 | 759 | $i ++; |
@@ -719,8 +761,7 @@ discard block |
||
| 719 | 761 | } |
| 720 | 762 | print "</select>\n"; |
| 721 | 763 | return $firstCompany; |
| 722 | - } |
|
| 723 | - else |
|
| 764 | + } else |
|
| 724 | 765 | { |
| 725 | 766 | dol_print_error($this->db); |
| 726 | 767 | print 'Error sql'; |
@@ -748,15 +789,21 @@ discard block |
||
| 748 | 789 | { |
| 749 | 790 | $lesTypes = $object->liste_type_contact($source, $sortorder, 0, 1); |
| 750 | 791 | print '<select class="flat valignmiddle'.($morecss?' '.$morecss:'').'" name="'.$htmlname.'" id="'.$htmlname.'">'; |
| 751 | - if ($showempty) print '<option value="0"></option>'; |
|
| 792 | + if ($showempty) { |
|
| 793 | + print '<option value="0"></option>'; |
|
| 794 | + } |
|
| 752 | 795 | foreach($lesTypes as $key=>$value) |
| 753 | 796 | { |
| 754 | 797 | print '<option value="'.$key.'"'; |
| 755 | - if ($key == $selected) print ' selected'; |
|
| 798 | + if ($key == $selected) { |
|
| 799 | + print ' selected'; |
|
| 800 | + } |
|
| 756 | 801 | print '>'.$value.'</option>'; |
| 757 | 802 | } |
| 758 | 803 | print "</select>"; |
| 759 | - if ($user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 804 | + if ($user->admin) { |
|
| 805 | + print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1); |
|
| 806 | + } |
|
| 760 | 807 | print "\n"; |
| 761 | 808 | } |
| 762 | 809 | } |
@@ -782,7 +829,9 @@ discard block |
||
| 782 | 829 | $out=''; |
| 783 | 830 | |
| 784 | 831 | $size=''; |
| 785 | - if (!empty($fieldsize)) $size='size="'.$fieldsize.'"'; |
|
| 832 | + if (!empty($fieldsize)) { |
|
| 833 | + $size='size="'.$fieldsize.'"'; |
|
| 834 | + } |
|
| 786 | 835 | |
| 787 | 836 | if ($conf->use_javascript_ajax && empty($disableautocomplete)) |
| 788 | 837 | { |
@@ -815,27 +864,51 @@ discard block |
||
| 815 | 864 | if ($country_code == 'FR') |
| 816 | 865 | { |
| 817 | 866 | if (isset($idprof)) { |
| 818 | - if ($idprof==1) $formlength=9; |
|
| 819 | - else if ($idprof==2) $formlength=14; |
|
| 820 | - else if ($idprof==3) $formlength=5; // 4 chiffres et 1 lettre depuis janvier |
|
| 821 | - else if ($idprof==4) $formlength=32; // No maximum as we need to include a town name in this id |
|
| 867 | + if ($idprof==1) { |
|
| 868 | + $formlength=9; |
|
| 869 | + } else if ($idprof==2) { |
|
| 870 | + $formlength=14; |
|
| 871 | + } else if ($idprof==3) { |
|
| 872 | + $formlength=5; |
|
| 873 | + } |
|
| 874 | + // 4 chiffres et 1 lettre depuis janvier |
|
| 875 | + else if ($idprof==4) { |
|
| 876 | + $formlength=32; |
|
| 877 | + } |
|
| 878 | + // No maximum as we need to include a town name in this id |
|
| 822 | 879 | } |
| 823 | - } |
|
| 824 | - else if ($country_code == 'ES') |
|
| 880 | + } else if ($country_code == 'ES') |
|
| 825 | 881 | { |
| 826 | - if ($idprof==1) $formlength=9; //CIF/NIF/NIE 9 digits |
|
| 827 | - if ($idprof==2) $formlength=12; //NASS 12 digits without / |
|
| 828 | - if ($idprof==3) $formlength=5; //CNAE 5 digits |
|
| 829 | - if ($idprof==4) $formlength=32; //depend of college |
|
| 882 | + if ($idprof==1) { |
|
| 883 | + $formlength=9; |
|
| 884 | + } |
|
| 885 | + //CIF/NIF/NIE 9 digits |
|
| 886 | + if ($idprof==2) { |
|
| 887 | + $formlength=12; |
|
| 888 | + } |
|
| 889 | + //NASS 12 digits without / |
|
| 890 | + if ($idprof==3) { |
|
| 891 | + $formlength=5; |
|
| 892 | + } |
|
| 893 | + //CNAE 5 digits |
|
| 894 | + if ($idprof==4) { |
|
| 895 | + $formlength=32; |
|
| 896 | + } |
|
| 897 | + //depend of college |
|
| 830 | 898 | } |
| 831 | 899 | } |
| 832 | 900 | |
| 833 | 901 | $selected=$preselected; |
| 834 | 902 | if (! $selected && isset($idprof)) { |
| 835 | - if ($idprof==1 && ! empty($this->idprof1)) $selected=$this->idprof1; |
|
| 836 | - else if ($idprof==2 && ! empty($this->idprof2)) $selected=$this->idprof2; |
|
| 837 | - else if ($idprof==3 && ! empty($this->idprof3)) $selected=$this->idprof3; |
|
| 838 | - else if ($idprof==4 && ! empty($this->idprof4)) $selected=$this->idprof4; |
|
| 903 | + if ($idprof==1 && ! empty($this->idprof1)) { |
|
| 904 | + $selected=$this->idprof1; |
|
| 905 | + } else if ($idprof==2 && ! empty($this->idprof2)) { |
|
| 906 | + $selected=$this->idprof2; |
|
| 907 | + } else if ($idprof==3 && ! empty($this->idprof3)) { |
|
| 908 | + $selected=$this->idprof3; |
|
| 909 | + } else if ($idprof==4 && ! empty($this->idprof4)) { |
|
| 910 | + $selected=$this->idprof4; |
|
| 911 | + } |
|
| 839 | 912 | } |
| 840 | 913 | |
| 841 | 914 | $maxlength=$formlength; |
@@ -875,8 +948,7 @@ discard block |
||
| 875 | 948 | if ($selected == $valors[$i]) |
| 876 | 949 | { |
| 877 | 950 | print '<option value="'.$valors[$i].'" selected>'; |
| 878 | - } |
|
| 879 | - else |
|
| 951 | + } else |
|
| 880 | 952 | { |
| 881 | 953 | print '<option value="'.$valors[$i].'">'; |
| 882 | 954 | } |
@@ -545,8 +545,7 @@ |
||
| 545 | 545 | $ret = $this->InitPrinter($printerid); |
| 546 | 546 | if ($ret>0) { |
| 547 | 547 | setEventMessages($this->error, $this->errors, 'errors'); |
| 548 | - } |
|
| 549 | - else |
|
| 548 | + } else |
|
| 550 | 549 | { |
| 551 | 550 | $nboflines = count($vals); |
| 552 | 551 | for ($line=0; $line < $nboflines; $line++) |
@@ -300,8 +300,9 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | function setErrorsTo($_strErrorsTo) |
| 302 | 302 | { |
| 303 | - if ( $_strErrorsTo ) |
|
| 304 | - $this->_errorsTo = $this->_strip_email($_strErrorsTo); |
|
| 303 | + if ( $_strErrorsTo ) { |
|
| 304 | + $this->_errorsTo = $this->_strip_email($_strErrorsTo); |
|
| 305 | + } |
|
| 305 | 306 | } |
| 306 | 307 | |
| 307 | 308 | /** |
@@ -314,10 +315,11 @@ discard block |
||
| 314 | 315 | { |
| 315 | 316 | $_retValue = ''; |
| 316 | 317 | |
| 317 | - if ( $_part === true ) |
|
| 318 | - $_retValue = $this->_errorsTo; |
|
| 319 | - else |
|
| 320 | - $_retValue = $this->_errorsTo[$_part]; |
|
| 318 | + if ( $_part === true ) { |
|
| 319 | + $_retValue = $this->_errorsTo; |
|
| 320 | + } else { |
|
| 321 | + $_retValue = $this->_errorsTo[$_part]; |
|
| 322 | + } |
|
| 321 | 323 | |
| 322 | 324 | return $_retValue; |
| 323 | 325 | } |
@@ -373,8 +375,7 @@ discard block |
||
| 373 | 375 | { |
| 374 | 376 | $this->_setErr(99, $host . ' is either offline or is an invalid host name.'); |
| 375 | 377 | $_retVal = false; |
| 376 | - } |
|
| 377 | - else |
|
| 378 | + } else |
|
| 378 | 379 | { |
| 379 | 380 | //See if we can connect to the SMTP server |
| 380 | 381 | if ($this->socket = @fsockopen( |
@@ -383,23 +384,28 @@ discard block |
||
| 383 | 384 | $this->errno, // actual system level error |
| 384 | 385 | $this->errstr, // and any text that goes with the error |
| 385 | 386 | $this->_smtpTimeout |
| 386 | - )) // timeout for reading/writing data over the socket |
|
| 387 | + )) { |
|
| 388 | + // timeout for reading/writing data over the socket |
|
| 387 | 389 | { |
| 388 | 390 | // Fix from PHP SMTP class by 'Chris Ryan' |
| 389 | 391 | // Sometimes the SMTP server takes a little longer to respond |
| 390 | 392 | // so we will give it a longer timeout for the first read |
| 391 | 393 | // Windows still does not have support for this timeout function |
| 392 | 394 | if (function_exists('stream_set_timeout')) stream_set_timeout($this->socket, $this->_smtpTimeout, 0); |
| 395 | + } |
|
| 393 | 396 | |
| 394 | 397 | // Check response from Server |
| 395 | - if ( $_retVal = $this->server_parse($this->socket, "220") ) |
|
| 396 | - $_retVal = $this->socket; |
|
| 398 | + if ( $_retVal = $this->server_parse($this->socket, "220") ) { |
|
| 399 | + $_retVal = $this->socket; |
|
| 400 | + } |
|
| 397 | 401 | } |
| 398 | 402 | // This connection attempt failed. |
| 399 | 403 | else |
| 400 | 404 | { |
| 401 | 405 | // @CHANGE LDR |
| 402 | - if (empty($this->errstr)) $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); |
|
| 406 | + if (empty($this->errstr)) { |
|
| 407 | + $this->errstr='Failed to connect with fsockopen host='.$this->getHost().' port='.$this->getPort(); |
|
| 408 | + } |
|
| 403 | 409 | $this->_setErr($this->errno, $this->errstr); |
| 404 | 410 | $_retVal = false; |
| 405 | 411 | } |
@@ -429,7 +435,9 @@ discard block |
||
| 429 | 435 | $host=preg_replace('@ssl://@i','',$host); // Remove prefix |
| 430 | 436 | $host=preg_replace('@tls://@i','',$host); // Remove prefix |
| 431 | 437 | |
| 432 | - if ($usetls) $host='tls://'.$host; |
|
| 438 | + if ($usetls) { |
|
| 439 | + $host='tls://'.$host; |
|
| 440 | + } |
|
| 433 | 441 | |
| 434 | 442 | $hosth = $host; |
| 435 | 443 | |
@@ -506,10 +514,10 @@ discard block |
||
| 506 | 514 | |
| 507 | 515 | // The error here just means the ID/password combo doesn't work. |
| 508 | 516 | // There is not a method to determine which is the problem, ID or password |
| 509 | - if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) |
|
| 510 | - $this->_setErr(130, 'Invalid Authentication Credentials.'); |
|
| 511 | - } |
|
| 512 | - else |
|
| 517 | + if ( ! $_retVal = $this->socket_send_str(base64_encode($this->_smtpsPW), '235') ) { |
|
| 518 | + $this->_setErr(130, 'Invalid Authentication Credentials.'); |
|
| 519 | + } |
|
| 520 | + } else |
|
| 513 | 521 | { |
| 514 | 522 | $this->_setErr(126, '"' . $host . '" does not support authenticated connections.'); |
| 515 | 523 | } |
@@ -672,14 +680,17 @@ discard block |
||
| 672 | 680 | { |
| 673 | 681 | // Set these properties ONLY if they are set in the php.ini file. |
| 674 | 682 | // Otherwise the default values will be used. |
| 675 | - if ( $_host = ini_get('SMTPs') ) |
|
| 676 | - $this->setHost($_host); |
|
| 683 | + if ( $_host = ini_get('SMTPs') ) { |
|
| 684 | + $this->setHost($_host); |
|
| 685 | + } |
|
| 677 | 686 | |
| 678 | - if ( $_port = ini_get('smtp_port') ) |
|
| 679 | - $this->setPort($_port); |
|
| 687 | + if ( $_port = ini_get('smtp_port') ) { |
|
| 688 | + $this->setPort($_port); |
|
| 689 | + } |
|
| 680 | 690 | |
| 681 | - if ( $_from = ini_get('sendmail_from') ) |
|
| 682 | - $this->setFrom($_from); |
|
| 691 | + if ( $_from = ini_get('sendmail_from') ) { |
|
| 692 | + $this->setFrom($_from); |
|
| 693 | + } |
|
| 683 | 694 | } |
| 684 | 695 | |
| 685 | 696 | // Send back what we have |
@@ -698,8 +709,9 @@ discard block |
||
| 698 | 709 | function setTransportType($_type = 0) |
| 699 | 710 | { |
| 700 | 711 | if ( ( is_numeric($_type) ) && |
| 701 | - ( ( $_type >= 0 ) && ( $_type <= 3 ) ) ) |
|
| 702 | - $this->_transportType = $_type; |
|
| 712 | + ( ( $_type >= 0 ) && ( $_type <= 3 ) ) ) { |
|
| 713 | + $this->_transportType = $_type; |
|
| 714 | + } |
|
| 703 | 715 | } |
| 704 | 716 | |
| 705 | 717 | /** |
@@ -740,8 +752,9 @@ discard block |
||
| 740 | 752 | */ |
| 741 | 753 | function setHost($_strHost) |
| 742 | 754 | { |
| 743 | - if ( $_strHost ) |
|
| 744 | - $this->_smtpsHost = $_strHost; |
|
| 755 | + if ( $_strHost ) { |
|
| 756 | + $this->_smtpsHost = $_strHost; |
|
| 757 | + } |
|
| 745 | 758 | } |
| 746 | 759 | |
| 747 | 760 | /** |
@@ -766,8 +779,9 @@ discard block |
||
| 766 | 779 | function setPort($_intPort) |
| 767 | 780 | { |
| 768 | 781 | if ( ( is_numeric($_intPort) ) && |
| 769 | - ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) |
|
| 770 | - $this->_smtpsPort = $_intPort; |
|
| 782 | + ( ( $_intPort >= 1 ) && ( $_intPort <= 65536 ) ) ) { |
|
| 783 | + $this->_smtpsPort = $_intPort; |
|
| 784 | + } |
|
| 771 | 785 | } |
| 772 | 786 | |
| 773 | 787 | /** |
@@ -832,8 +846,9 @@ discard block |
||
| 832 | 846 | */ |
| 833 | 847 | function setCharSet($_strCharSet) |
| 834 | 848 | { |
| 835 | - if ( $_strCharSet ) |
|
| 836 | - $this->_smtpsCharSet = $_strCharSet; |
|
| 849 | + if ( $_strCharSet ) { |
|
| 850 | + $this->_smtpsCharSet = $_strCharSet; |
|
| 851 | + } |
|
| 837 | 852 | } |
| 838 | 853 | |
| 839 | 854 | /** |
@@ -863,8 +878,9 @@ discard block |
||
| 863 | 878 | */ |
| 864 | 879 | function setTransEncode($_strTransEncode) |
| 865 | 880 | { |
| 866 | - if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) |
|
| 867 | - $this->_smtpsTransEncode = $_strTransEncode; |
|
| 881 | + if (array_search($_strTransEncode, $this->_smtpsTransEncodeTypes)) { |
|
| 882 | + $this->_smtpsTransEncode = $_strTransEncode; |
|
| 883 | + } |
|
| 868 | 884 | } |
| 869 | 885 | |
| 870 | 886 | /** |
@@ -895,8 +911,9 @@ discard block |
||
| 895 | 911 | */ |
| 896 | 912 | function setTransEncodeType($_strTransEncodeType) |
| 897 | 913 | { |
| 898 | - if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) |
|
| 899 | - $this->_smtpsTransEncodeType = $_strTransEncodeType; |
|
| 914 | + if (array_search($_strTransEncodeType, $this->_smtpsTransEncodeTypes)) { |
|
| 915 | + $this->_smtpsTransEncodeType = $_strTransEncodeType; |
|
| 916 | + } |
|
| 900 | 917 | } |
| 901 | 918 | |
| 902 | 919 | /** |
@@ -920,8 +937,9 @@ discard block |
||
| 920 | 937 | */ |
| 921 | 938 | function setFrom($_strFrom) |
| 922 | 939 | { |
| 923 | - if ( $_strFrom ) |
|
| 924 | - $this->_msgFrom = $this->_strip_email($_strFrom); |
|
| 940 | + if ( $_strFrom ) { |
|
| 941 | + $this->_msgFrom = $this->_strip_email($_strFrom); |
|
| 942 | + } |
|
| 925 | 943 | } |
| 926 | 944 | |
| 927 | 945 | /** |
@@ -934,10 +952,11 @@ discard block |
||
| 934 | 952 | { |
| 935 | 953 | $_retValue = ''; |
| 936 | 954 | |
| 937 | - if ( $_part === true ) |
|
| 938 | - $_retValue = $this->_msgFrom; |
|
| 939 | - else |
|
| 940 | - $_retValue = $this->_msgFrom[$_part]; |
|
| 955 | + if ( $_part === true ) { |
|
| 956 | + $_retValue = $this->_msgFrom; |
|
| 957 | + } else { |
|
| 958 | + $_retValue = $this->_msgFrom[$_part]; |
|
| 959 | + } |
|
| 941 | 960 | |
| 942 | 961 | return $_retValue; |
| 943 | 962 | } |
@@ -950,8 +969,9 @@ discard block |
||
| 950 | 969 | */ |
| 951 | 970 | function setReplyTo($_strReplyTo) |
| 952 | 971 | { |
| 953 | - if ( $_strReplyTo ) |
|
| 954 | - $this->_msgReplyTo = $this->_strip_email($_strReplyTo); |
|
| 972 | + if ( $_strReplyTo ) { |
|
| 973 | + $this->_msgReplyTo = $this->_strip_email($_strReplyTo); |
|
| 974 | + } |
|
| 955 | 975 | } |
| 956 | 976 | |
| 957 | 977 | /** |
@@ -964,10 +984,11 @@ discard block |
||
| 964 | 984 | { |
| 965 | 985 | $_retValue = ''; |
| 966 | 986 | |
| 967 | - if ( $_part === true ) |
|
| 968 | - $_retValue = $this->_msgReplyTo; |
|
| 969 | - else |
|
| 970 | - $_retValue = $this->_msgReplyTo[$_part]; |
|
| 987 | + if ( $_part === true ) { |
|
| 988 | + $_retValue = $this->_msgReplyTo; |
|
| 989 | + } else { |
|
| 990 | + $_retValue = $this->_msgReplyTo[$_part]; |
|
| 991 | + } |
|
| 971 | 992 | |
| 972 | 993 | return $_retValue; |
| 973 | 994 | } |
@@ -996,13 +1017,15 @@ discard block |
||
| 996 | 1017 | if ( is_string($_addrList) ) |
| 997 | 1018 | { |
| 998 | 1019 | // This could be a COMMA delimited string |
| 999 | - if ( strstr($_addrList, ',') ) |
|
| 1000 | - // "explode "list" into an array |
|
| 1020 | + if ( strstr($_addrList, ',') ) { |
|
| 1021 | + // "explode "list" into an array |
|
| 1001 | 1022 | $_addrList = explode(',', $_addrList); |
| 1023 | + } |
|
| 1002 | 1024 | |
| 1003 | 1025 | // Stick it in an array |
| 1004 | - else |
|
| 1005 | - $_addrList = array($_addrList); |
|
| 1026 | + else { |
|
| 1027 | + $_addrList = array($_addrList); |
|
| 1028 | + } |
|
| 1006 | 1029 | } |
| 1007 | 1030 | |
| 1008 | 1031 | // take the array of addresses and split them further |
@@ -1076,13 +1099,14 @@ discard block |
||
| 1076 | 1099 | if ( count($_tmpAry) == 2 ) |
| 1077 | 1100 | { |
| 1078 | 1101 | // We may not really have a "Real Name" |
| 1079 | - if ( $_tmpAry[0]) |
|
| 1080 | - $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); |
|
| 1102 | + if ( $_tmpAry[0]) { |
|
| 1103 | + $_aryEmail['real'] = trim($_tmpAry[0], ' ">'); |
|
| 1104 | + } |
|
| 1081 | 1105 | |
| 1082 | 1106 | $_aryEmail['addr'] = $_tmpAry[1]; |
| 1107 | + } else { |
|
| 1108 | + $_aryEmail['addr'] = $_tmpAry[0]; |
|
| 1083 | 1109 | } |
| 1084 | - else |
|
| 1085 | - $_aryEmail['addr'] = $_tmpAry[0]; |
|
| 1086 | 1110 | |
| 1087 | 1111 | // Pull User Name and Host.tld apart |
| 1088 | 1112 | list($_aryEmail['user'], $_aryEmail['host'] ) = explode('@', $_aryEmail['addr']); |
@@ -1149,12 +1173,13 @@ discard block |
||
| 1149 | 1173 | { |
| 1150 | 1174 | foreach ( $this->_msgRecipients[$_host][$_which] as $_addr => $_realName ) |
| 1151 | 1175 | { |
| 1152 | - if ( $_realName ) // @CHANGE LDR |
|
| 1176 | + if ( $_realName ) { |
|
| 1177 | + // @CHANGE LDR |
|
| 1153 | 1178 | { |
| 1154 | 1179 | $_realName = '"' . $_realName . '"'; |
| 1155 | - $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; |
|
| 1156 | 1180 | } |
| 1157 | - else |
|
| 1181 | + $_RCPT_list[] = $_realName . ' <' . $_addr . '@' . $_host . '>'; |
|
| 1182 | + } else |
|
| 1158 | 1183 | { |
| 1159 | 1184 | $_RCPT_list[] = $_addr . '@' . $_host; |
| 1160 | 1185 | } |
@@ -1163,14 +1188,12 @@ discard block |
||
| 1163 | 1188 | } |
| 1164 | 1189 | |
| 1165 | 1190 | return implode(', ', $_RCPT_list); |
| 1166 | - } |
|
| 1167 | - else |
|
| 1191 | + } else |
|
| 1168 | 1192 | { |
| 1169 | 1193 | $this->_setErr(101, 'No eMail Address for message to be sent to.'); |
| 1170 | 1194 | return false; |
| 1171 | 1195 | } |
| 1172 | - } |
|
| 1173 | - else |
|
| 1196 | + } else |
|
| 1174 | 1197 | { |
| 1175 | 1198 | $this->_setErr(102, 'eMail type not defined.'); |
| 1176 | 1199 | return false; |
@@ -1185,8 +1208,9 @@ discard block |
||
| 1185 | 1208 | */ |
| 1186 | 1209 | function setTO($_addrTo) |
| 1187 | 1210 | { |
| 1188 | - if ( $_addrTo ) |
|
| 1189 | - $this->_buildAddrList('to', $_addrTo); |
|
| 1211 | + if ( $_addrTo ) { |
|
| 1212 | + $this->_buildAddrList('to', $_addrTo); |
|
| 1213 | + } |
|
| 1190 | 1214 | } |
| 1191 | 1215 | |
| 1192 | 1216 | /** |
@@ -1207,8 +1231,9 @@ discard block |
||
| 1207 | 1231 | */ |
| 1208 | 1232 | function setCC($_strCC) |
| 1209 | 1233 | { |
| 1210 | - if ( $_strCC ) |
|
| 1211 | - $this->_buildAddrList('cc', $_strCC); |
|
| 1234 | + if ( $_strCC ) { |
|
| 1235 | + $this->_buildAddrList('cc', $_strCC); |
|
| 1236 | + } |
|
| 1212 | 1237 | } |
| 1213 | 1238 | |
| 1214 | 1239 | /** |
@@ -1229,8 +1254,9 @@ discard block |
||
| 1229 | 1254 | */ |
| 1230 | 1255 | function setBCC($_strBCC) |
| 1231 | 1256 | { |
| 1232 | - if ( $_strBCC ) |
|
| 1233 | - $this->_buildAddrList('bcc', $_strBCC); |
|
| 1257 | + if ( $_strBCC ) { |
|
| 1258 | + $this->_buildAddrList('bcc', $_strBCC); |
|
| 1259 | + } |
|
| 1234 | 1260 | } |
| 1235 | 1261 | |
| 1236 | 1262 | /** |
@@ -1251,8 +1277,9 @@ discard block |
||
| 1251 | 1277 | */ |
| 1252 | 1278 | function setSubject($_strSubject = '') |
| 1253 | 1279 | { |
| 1254 | - if ( $_strSubject ) |
|
| 1255 | - $this->_msgSubject = $_strSubject; |
|
| 1280 | + if ( $_strSubject ) { |
|
| 1281 | + $this->_msgSubject = $_strSubject; |
|
| 1282 | + } |
|
| 1256 | 1283 | } |
| 1257 | 1284 | |
| 1258 | 1285 | /** |
@@ -1277,8 +1304,9 @@ discard block |
||
| 1277 | 1304 | $_header = 'From: ' . $this->getFrom('org') . "\r\n" |
| 1278 | 1305 | . 'To: ' . $this->getTO() . "\r\n"; |
| 1279 | 1306 | |
| 1280 | - if ( $this->getCC() ) |
|
| 1281 | - $_header .= 'Cc: ' . $this->getCC() . "\r\n"; |
|
| 1307 | + if ( $this->getCC() ) { |
|
| 1308 | + $_header .= 'Cc: ' . $this->getCC() . "\r\n"; |
|
| 1309 | + } |
|
| 1282 | 1310 | |
| 1283 | 1311 | /* Note: |
| 1284 | 1312 | * BCC email addresses must be listed in the RCPT TO command list, |
@@ -1311,33 +1339,41 @@ discard block |
||
| 1311 | 1339 | $_header .= 'Message-ID: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; |
| 1312 | 1340 | $_header .= 'References: <' . time() . '.SMTPs-dolibarr-'.$trackid.'@' . $host . ">\r\n"; |
| 1313 | 1341 | $_header .= 'X-Dolibarr-TRACKID: ' . $trackid . '@' . $host . "\r\n"; |
| 1314 | - } |
|
| 1315 | - else |
|
| 1342 | + } else |
|
| 1316 | 1343 | { |
| 1317 | 1344 | $_header .= 'Message-ID: <' . time() . '.SMTPs@' . $host . ">\r\n"; |
| 1318 | 1345 | } |
| 1319 | - if (! empty($_SERVER['REMOTE_ADDR'])) $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n"; |
|
| 1320 | - if ( $this->getMoreInHeader() ) |
|
| 1321 | - $_header .= $this->getMoreInHeader(); // Value must include the "\r\n"; |
|
| 1346 | + if (! empty($_SERVER['REMOTE_ADDR'])) { |
|
| 1347 | + $_header .= "X-RemoteAddr: " . $_SERVER['REMOTE_ADDR']. "\r\n"; |
|
| 1348 | + } |
|
| 1349 | + if ( $this->getMoreInHeader() ) { |
|
| 1350 | + $_header .= $this->getMoreInHeader(); |
|
| 1351 | + } |
|
| 1352 | + // Value must include the "\r\n"; |
|
| 1322 | 1353 | |
| 1323 | 1354 | //$_header .= |
| 1324 | 1355 | // 'Read-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n" |
| 1325 | 1356 | // 'Return-Receipt-To: ' . $this->getFrom( 'org' ) . "\r\n"; |
| 1326 | 1357 | |
| 1327 | - if ( $this->getSensitivity() ) |
|
| 1328 | - $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; |
|
| 1358 | + if ( $this->getSensitivity() ) { |
|
| 1359 | + $_header .= 'Sensitivity: ' . $this->getSensitivity() . "\r\n"; |
|
| 1360 | + } |
|
| 1329 | 1361 | |
| 1330 | - if ( $this->_msgPriority != 3 ) |
|
| 1331 | - $_header .= $this->getPriority(); |
|
| 1362 | + if ( $this->_msgPriority != 3 ) { |
|
| 1363 | + $_header .= $this->getPriority(); |
|
| 1364 | + } |
|
| 1332 | 1365 | |
| 1333 | 1366 | |
| 1334 | 1367 | // @CHANGE LDR |
| 1335 | - if ( $this->getDeliveryReceipt() ) |
|
| 1336 | - $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; |
|
| 1337 | - if ( $this->getErrorsTo() ) |
|
| 1338 | - $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; |
|
| 1339 | - if ( $this->getReplyTo() ) |
|
| 1340 | - $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; |
|
| 1368 | + if ( $this->getDeliveryReceipt() ) { |
|
| 1369 | + $_header .= 'Disposition-Notification-To: '.$this->getFrom('addr') . "\r\n"; |
|
| 1370 | + } |
|
| 1371 | + if ( $this->getErrorsTo() ) { |
|
| 1372 | + $_header .= 'Errors-To: '.$this->getErrorsTo('addr') . "\r\n"; |
|
| 1373 | + } |
|
| 1374 | + if ( $this->getReplyTo() ) { |
|
| 1375 | + $_header .= "Reply-To: ".$this->getReplyTo('addr') ."\r\n"; |
|
| 1376 | + } |
|
| 1341 | 1377 | |
| 1342 | 1378 | $_header .= 'X-Mailer: Dolibarr version ' . DOL_VERSION .' (using SMTPs Mailer)' . "\r\n"; |
| 1343 | 1379 | $_header .= 'X-Dolibarr-Option: '.($conf->global->MAIN_MAIL_USE_MULTI_PART?'MAIN_MAIL_USE_MULTI_PART':'No MAIN_MAIL_USE_MULTI_PART') . "\r\n"; |
@@ -1358,10 +1394,11 @@ discard block |
||
| 1358 | 1394 | { |
| 1359 | 1395 | //if ( $strContent ) |
| 1360 | 1396 | //{ |
| 1361 | - if ( $strType == 'html' ) |
|
| 1362 | - $strMimeType = 'text/html'; |
|
| 1363 | - else |
|
| 1364 | - $strMimeType = 'text/plain'; |
|
| 1397 | + if ( $strType == 'html' ) { |
|
| 1398 | + $strMimeType = 'text/html'; |
|
| 1399 | + } else { |
|
| 1400 | + $strMimeType = 'text/plain'; |
|
| 1401 | + } |
|
| 1365 | 1402 | |
| 1366 | 1403 | // Make RFC821 Compliant, replace bare linefeeds |
| 1367 | 1404 | $strContent = preg_replace("/(?<!\r)\n/si", "\r\n", $strContent); |
@@ -1385,8 +1422,9 @@ discard block |
||
| 1385 | 1422 | $this->_msgContent[$strType]['data'] = $strContent; |
| 1386 | 1423 | $this->_msgContent[$strType]['dataText'] = $strContentAltText; |
| 1387 | 1424 | |
| 1388 | - if ( $this->getMD5flag() ) |
|
| 1389 | - $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); |
|
| 1425 | + if ( $this->getMD5flag() ) { |
|
| 1426 | + $this->_msgContent[$strType]['md5'] = dol_hash($strContent, 3); |
|
| 1427 | + } |
|
| 1390 | 1428 | //} |
| 1391 | 1429 | } |
| 1392 | 1430 | |
@@ -1409,8 +1447,9 @@ discard block |
||
| 1409 | 1447 | $keyCount = count($_types); |
| 1410 | 1448 | |
| 1411 | 1449 | // If we have ZERO, we have a problem |
| 1412 | - if( $keyCount === 0 ) |
|
| 1413 | - die ("Sorry, no content"); |
|
| 1450 | + if( $keyCount === 0 ) { |
|
| 1451 | + die ("Sorry, no content"); |
|
| 1452 | + } |
|
| 1414 | 1453 | |
| 1415 | 1454 | // If we have ONE, we can use the simple format |
| 1416 | 1455 | else if( $keyCount === 1 && empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) |
@@ -1423,8 +1462,9 @@ discard block |
||
| 1423 | 1462 | . 'Content-Disposition: inline' . "\r\n" |
| 1424 | 1463 | . 'Content-Description: Message' . "\r\n"; |
| 1425 | 1464 | |
| 1426 | - if ( $this->getMD5flag() ) |
|
| 1427 | - $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; |
|
| 1465 | + if ( $this->getMD5flag() ) { |
|
| 1466 | + $content .= 'Content-MD5: ' . $_msgData['md5'] . "\r\n"; |
|
| 1467 | + } |
|
| 1428 | 1468 | |
| 1429 | 1469 | $content .= "\r\n" |
| 1430 | 1470 | . $_msgData['data'] . "\r\n"; |
@@ -1447,9 +1487,11 @@ discard block |
||
| 1447 | 1487 | |
| 1448 | 1488 | $content .= "--" . $this->_getBoundary('mixed') . "\r\n"; |
| 1449 | 1489 | |
| 1450 | - if (key_exists('image', $this->_msgContent)) // If inline image found |
|
| 1490 | + if (key_exists('image', $this->_msgContent)) { |
|
| 1491 | + // If inline image found |
|
| 1451 | 1492 | { |
| 1452 | 1493 | $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; |
| 1494 | + } |
|
| 1453 | 1495 | $content .= "\r\n"; |
| 1454 | 1496 | $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; |
| 1455 | 1497 | } |
@@ -1472,8 +1514,9 @@ discard block |
||
| 1472 | 1514 | . 'Content-Transfer-Encoding: base64' . "\r\n" |
| 1473 | 1515 | . 'Content-Description: ' . $_data['fileName'] ."\r\n"; |
| 1474 | 1516 | |
| 1475 | - if ( $this->getMD5flag() ) |
|
| 1476 | - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
| 1517 | + if ( $this->getMD5flag() ) { |
|
| 1518 | + $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
| 1519 | + } |
|
| 1477 | 1520 | |
| 1478 | 1521 | $content .= "\r\n" . $_data['data'] . "\r\n\r\n"; |
| 1479 | 1522 | } |
@@ -1491,8 +1534,9 @@ discard block |
||
| 1491 | 1534 | . 'Content-Disposition: inline; filename="' . $_data['imageName'] . '"' . "\r\n" |
| 1492 | 1535 | . 'Content-ID: <' . $_data['cid'] . '> ' . "\r\n"; |
| 1493 | 1536 | |
| 1494 | - if ( $this->getMD5flag() ) |
|
| 1495 | - $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
| 1537 | + if ( $this->getMD5flag() ) { |
|
| 1538 | + $content .= 'Content-MD5: ' . $_data['md5'] . "\r\n"; |
|
| 1539 | + } |
|
| 1496 | 1540 | |
| 1497 | 1541 | $content .= "\r\n" |
| 1498 | 1542 | . $_data['data'] . "\r\n"; |
@@ -1502,8 +1546,7 @@ discard block |
||
| 1502 | 1546 | $content.= "--" . $this->_getBoundary('related') . "--" . "\r\n"; |
| 1503 | 1547 | $content.= "\r\n" . "--" . $this->_getBoundary('alternative') . "--" . "\r\n"; |
| 1504 | 1548 | $content.= "\r\n"; |
| 1505 | - } |
|
| 1506 | - else |
|
| 1549 | + } else |
|
| 1507 | 1550 | { |
| 1508 | 1551 | if (key_exists('image', $this->_msgContent)) |
| 1509 | 1552 | { |
@@ -1515,9 +1558,11 @@ discard block |
||
| 1515 | 1558 | $content.= "--" . $this->_getBoundary('related') . "\r\n"; |
| 1516 | 1559 | } |
| 1517 | 1560 | |
| 1518 | - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part before html part |
|
| 1561 | + if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { |
|
| 1562 | + // Add plain text message part before html part |
|
| 1519 | 1563 | { |
| 1520 | 1564 | $content.= 'Content-Type: multipart/alternative; boundary="'.$this->_getBoundary('alternative').'"' . "\r\n"; |
| 1565 | + } |
|
| 1521 | 1566 | $content .= "\r\n"; |
| 1522 | 1567 | $content .= "--" . $this->_getBoundary('alternative') . "\r\n"; |
| 1523 | 1568 | |
@@ -1538,15 +1583,18 @@ discard block |
||
| 1538 | 1583 | // . 'Content-Disposition: inline' . "\r\n" |
| 1539 | 1584 | // . 'Content-Description: ' . $type . ' message' . "\r\n"; |
| 1540 | 1585 | |
| 1541 | - if ( $this->getMD5flag() ) |
|
| 1542 | - $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; |
|
| 1586 | + if ( $this->getMD5flag() ) { |
|
| 1587 | + $content .= 'Content-MD5: ' . $_content['md5'] . "\r\n"; |
|
| 1588 | + } |
|
| 1543 | 1589 | |
| 1544 | 1590 | $content .= "\r\n" . $_content['data'] . "\r\n"; |
| 1545 | 1591 | |
| 1546 | - if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) // Add plain text message part after html part |
|
| 1592 | + if (! key_exists('image', $this->_msgContent) && $_content['dataText'] && ! empty($conf->global->MAIN_MAIL_USE_MULTI_PART)) { |
|
| 1593 | + // Add plain text message part after html part |
|
| 1547 | 1594 | { |
| 1548 | 1595 | $content.= "--" . $this->_getBoundary('alternative') . "--". "\r\n"; |
| 1549 | 1596 | } |
| 1597 | + } |
|
| 1550 | 1598 | |
| 1551 | 1599 | $content .= "\r\n"; |
| 1552 | 1600 | } |
@@ -1579,8 +1627,9 @@ discard block |
||
| 1579 | 1627 | $this->_msgContent['attachment'][$strFileName]['fileName'] = $strFileName; |
| 1580 | 1628 | $this->_msgContent['attachment'][$strFileName]['data'] = $strContent; |
| 1581 | 1629 | |
| 1582 | - if ( $this->getMD5flag() ) |
|
| 1583 | - $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); |
|
| 1630 | + if ( $this->getMD5flag() ) { |
|
| 1631 | + $this->_msgContent['attachment'][$strFileName]['md5'] = dol_hash($strContent, 3); |
|
| 1632 | + } |
|
| 1584 | 1633 | } |
| 1585 | 1634 | } |
| 1586 | 1635 | |
@@ -1606,8 +1655,9 @@ discard block |
||
| 1606 | 1655 | $this->_msgContent['image'][$strImageName]['cid'] = $strImageCid; |
| 1607 | 1656 | $this->_msgContent['image'][$strImageName]['data'] = $strContent; |
| 1608 | 1657 | |
| 1609 | - if ( $this->getMD5flag() ) |
|
| 1610 | - $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); |
|
| 1658 | + if ( $this->getMD5flag() ) { |
|
| 1659 | + $this->_msgContent['image'][$strImageName]['md5'] = dol_hash($strContent, 3); |
|
| 1660 | + } |
|
| 1611 | 1661 | } |
| 1612 | 1662 | } |
| 1613 | 1663 | // END @CHANGE LDR |
@@ -1627,8 +1677,9 @@ discard block |
||
| 1627 | 1677 | function setSensitivity($_value = 0) |
| 1628 | 1678 | { |
| 1629 | 1679 | if ( ( is_numeric($_value) ) && |
| 1630 | - ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) |
|
| 1631 | - $this->_msgSensitivity = $_value; |
|
| 1680 | + ( ( $_value >= 0 ) && ( $_value <= 3 ) ) ) { |
|
| 1681 | + $this->_msgSensitivity = $_value; |
|
| 1682 | + } |
|
| 1632 | 1683 | } |
| 1633 | 1684 | |
| 1634 | 1685 | /** |
@@ -1662,8 +1713,9 @@ discard block |
||
| 1662 | 1713 | function setPriority( $_value = 3 ) |
| 1663 | 1714 | { |
| 1664 | 1715 | if ( ( is_numeric($_value) ) && |
| 1665 | - ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) |
|
| 1666 | - $this->_msgPriority = $_value; |
|
| 1716 | + ( ( $_value >= 0 ) && ( $_value <= 5 ) ) ) { |
|
| 1717 | + $this->_msgPriority = $_value; |
|
| 1718 | + } |
|
| 1667 | 1719 | } |
| 1668 | 1720 | |
| 1669 | 1721 | /** |
@@ -1716,8 +1768,9 @@ discard block |
||
| 1716 | 1768 | */ |
| 1717 | 1769 | function setXheader($strXdata) |
| 1718 | 1770 | { |
| 1719 | - if ( $strXdata ) |
|
| 1720 | - $this->_msgXheader[] = $strXdata; |
|
| 1771 | + if ( $strXdata ) { |
|
| 1772 | + $this->_msgXheader[] = $strXdata; |
|
| 1773 | + } |
|
| 1721 | 1774 | } |
| 1722 | 1775 | |
| 1723 | 1776 | /** |
@@ -1750,9 +1803,13 @@ discard block |
||
| 1750 | 1803 | */ |
| 1751 | 1804 | function _getBoundary($type='mixed') |
| 1752 | 1805 | { |
| 1753 | - if ($type == 'mixed') return $this->_smtpsBoundary; |
|
| 1754 | - else if ($type == 'related') return $this->_smtpsRelatedBoundary; |
|
| 1755 | - else if ($type == 'alternative') return $this->_smtpsAlternativeBoundary; |
|
| 1806 | + if ($type == 'mixed') { |
|
| 1807 | + return $this->_smtpsBoundary; |
|
| 1808 | + } else if ($type == 'related') { |
|
| 1809 | + return $this->_smtpsRelatedBoundary; |
|
| 1810 | + } else if ($type == 'alternative') { |
|
| 1811 | + return $this->_smtpsAlternativeBoundary; |
|
| 1812 | + } |
|
| 1756 | 1813 | } |
| 1757 | 1814 | |
| 1758 | 1815 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps |
@@ -1810,12 +1867,18 @@ discard block |
||
| 1810 | 1867 | function socket_send_str( $_strSend, $_returnCode = null, $CRLF = "\r\n" ) |
| 1811 | 1868 | { |
| 1812 | 1869 | // phpcs:enable |
| 1813 | - if ($this->_debug) $this->log.=$_strSend; // @CHANGE LDR for log |
|
| 1870 | + if ($this->_debug) { |
|
| 1871 | + $this->log.=$_strSend; |
|
| 1872 | + } |
|
| 1873 | + // @CHANGE LDR for log |
|
| 1814 | 1874 | fputs($this->socket, $_strSend . $CRLF); |
| 1815 | - if ($this->_debug) $this->log.=' ('.$_returnCode.')' . $CRLF; |
|
| 1875 | + if ($this->_debug) { |
|
| 1876 | + $this->log.=' ('.$_returnCode.')' . $CRLF; |
|
| 1877 | + } |
|
| 1816 | 1878 | |
| 1817 | - if ( $_returnCode ) |
|
| 1818 | - return $this->server_parse($this->socket, $_returnCode); |
|
| 1879 | + if ( $_returnCode ) { |
|
| 1880 | + return $this->server_parse($this->socket, $_returnCode); |
|
| 1881 | + } |
|
| 1819 | 1882 | } |
| 1820 | 1883 | |
| 1821 | 1884 | // ============================================================= |
@@ -82,8 +82,7 @@ |
||
| 82 | 82 | $label = $res[$label_type]; |
| 83 | 83 | $this->db->free($resql); |
| 84 | 84 | return $label; |
| 85 | - } |
|
| 86 | - else |
|
| 85 | + } else |
|
| 87 | 86 | { |
| 88 | 87 | $this->error=$this->db->error().' sql='.$sql; |
| 89 | 88 | dol_syslog(get_class($this)."::getLabelOfUnit Error ".$this->error, LOG_ERR); |
@@ -137,15 +137,13 @@ discard block |
||
| 137 | 137 | { |
| 138 | 138 | $this->db->commit(); |
| 139 | 139 | return $this->id; |
| 140 | - } |
|
| 141 | - else |
|
| 140 | + } else |
|
| 142 | 141 | { |
| 143 | 142 | $this->error=$this->db->lasterror(); |
| 144 | 143 | $this->db->rollback(); |
| 145 | 144 | return $result; |
| 146 | 145 | } |
| 147 | - } |
|
| 148 | - else |
|
| 146 | + } else |
|
| 149 | 147 | { |
| 150 | 148 | $this->error=$this->db->lasterror()." sql=".$sql; |
| 151 | 149 | $this->db->rollback(); |
@@ -187,8 +185,7 @@ discard block |
||
| 187 | 185 | { |
| 188 | 186 | $this->db->commit(); |
| 189 | 187 | return 1; |
| 190 | - } |
|
| 191 | - else |
|
| 188 | + } else |
|
| 192 | 189 | { |
| 193 | 190 | $this->error=$this->db->lasterror(); |
| 194 | 191 | dol_syslog($this->error, LOG_ERR); |
@@ -223,8 +220,7 @@ discard block |
||
| 223 | 220 | $this->statut = $obj->statut; |
| 224 | 221 | |
| 225 | 222 | return 1; |
| 226 | - } |
|
| 227 | - else |
|
| 223 | + } else |
|
| 228 | 224 | { |
| 229 | 225 | $this->error=$this->db->lasterror(); |
| 230 | 226 | return -1; |
@@ -249,8 +245,7 @@ discard block |
||
| 249 | 245 | { |
| 250 | 246 | $this->db->commit(); |
| 251 | 247 | return 1; |
| 252 | - } |
|
| 253 | - else |
|
| 248 | + } else |
|
| 254 | 249 | { |
| 255 | 250 | $this->error=$this->db->lasterror(); |
| 256 | 251 | $this->db->rollback(); |
@@ -285,30 +280,37 @@ discard block |
||
| 285 | 280 | if ($mode == 0) |
| 286 | 281 | { |
| 287 | 282 | return $langs->trans($this->statuts[$statut]); |
| 288 | - } |
|
| 289 | - elseif ($mode == 1) |
|
| 283 | + } elseif ($mode == 1) |
|
| 290 | 284 | { |
| 291 | 285 | return $langs->trans($this->statuts_short[$statut]); |
| 292 | - } |
|
| 293 | - elseif ($mode == 2) |
|
| 286 | + } elseif ($mode == 2) |
|
| 294 | 287 | { |
| 295 | - if ($statut==0) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]); |
|
| 296 | - elseif ($statut==1) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts_short[$statut]); |
|
| 297 | - } |
|
| 298 | - elseif ($mode == 3) |
|
| 288 | + if ($statut==0) { |
|
| 289 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts_short[$statut]); |
|
| 290 | + } elseif ($statut==1) { |
|
| 291 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts_short[$statut]); |
|
| 292 | + } |
|
| 293 | + } elseif ($mode == 3) |
|
| 299 | 294 | { |
| 300 | - if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); |
|
| 301 | - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8'); |
|
| 302 | - } |
|
| 303 | - elseif ($mode == 4) |
|
| 295 | + if ($statut==0 && ! empty($this->statuts_short[$statut])) { |
|
| 296 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); |
|
| 297 | + } elseif ($statut==1 && ! empty($this->statuts_short[$statut])) { |
|
| 298 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut8'); |
|
| 299 | + } |
|
| 300 | + } elseif ($mode == 4) |
|
| 304 | 301 | { |
| 305 | - if ($statut==0 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); |
|
| 306 | - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]); |
|
| 307 | - } |
|
| 308 | - elseif ($mode == 5) |
|
| 302 | + if ($statut==0 && ! empty($this->statuts_short[$statut])) { |
|
| 303 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut4').' '.$langs->trans($this->statuts[$statut]); |
|
| 304 | + } elseif ($statut==1 && ! empty($this->statuts_short[$statut])) { |
|
| 305 | + return img_picto($langs->trans($this->statuts_short[$statut]),'statut8').' '.$langs->trans($this->statuts[$statut]); |
|
| 306 | + } |
|
| 307 | + } elseif ($mode == 5) |
|
| 309 | 308 | { |
| 310 | - if ($statut==0 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); |
|
| 311 | - elseif ($statut==1 && ! empty($this->statuts_short[$statut])) return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); |
|
| 309 | + if ($statut==0 && ! empty($this->statuts_short[$statut])) { |
|
| 310 | + return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut4'); |
|
| 311 | + } elseif ($statut==1 && ! empty($this->statuts_short[$statut])) { |
|
| 312 | + return $langs->trans($this->statuts_short[$statut]).' '.img_picto($langs->trans($this->statuts_short[$statut]),'statut6'); |
|
| 313 | + } |
|
| 312 | 314 | } |
| 313 | 315 | } |
| 314 | 316 | |
@@ -350,8 +352,7 @@ discard block |
||
| 350 | 352 | $this->date_modification = $this->db->jdate($obj->tms); |
| 351 | 353 | } |
| 352 | 354 | $this->db->free($result); |
| 353 | - } |
|
| 354 | - else |
|
| 355 | + } else |
|
| 355 | 356 | { |
| 356 | 357 | dol_print_error($this->db); |
| 357 | 358 | } |
@@ -377,8 +378,9 @@ discard block |
||
| 377 | 378 | { |
| 378 | 379 | $obj = $this->db->fetch_object($resql); |
| 379 | 380 | $nb = $obj->nb; |
| 381 | + } else { |
|
| 382 | + dol_print_error($this->db); |
|
| 380 | 383 | } |
| 381 | - else dol_print_error($this->db); |
|
| 382 | 384 | |
| 383 | 385 | return $nb; |
| 384 | 386 | } |
@@ -403,8 +405,9 @@ discard block |
||
| 403 | 405 | { |
| 404 | 406 | $obj = $this->db->fetch_object($resql); |
| 405 | 407 | $nb = $obj->nb; |
| 408 | + } else { |
|
| 409 | + dol_print_error($this->db); |
|
| 406 | 410 | } |
| 407 | - else dol_print_error($this->db); |
|
| 408 | 411 | |
| 409 | 412 | return $nb; |
| 410 | 413 | } |
@@ -83,11 +83,21 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | // Clean parameters |
| 85 | 85 | |
| 86 | - if (isset($this->id)) $this->id=trim($this->id); |
|
| 87 | - if (isset($this->code)) $this->code=trim($this->code); |
|
| 88 | - if (isset($this->libelle)) $this->libelle=trim($this->libelle); |
|
| 89 | - if (isset($this->active)) $this->active=trim($this->active); |
|
| 90 | - if (isset($this->module)) $this->module=trim($this->module); |
|
| 86 | + if (isset($this->id)) { |
|
| 87 | + $this->id=trim($this->id); |
|
| 88 | + } |
|
| 89 | + if (isset($this->code)) { |
|
| 90 | + $this->code=trim($this->code); |
|
| 91 | + } |
|
| 92 | + if (isset($this->libelle)) { |
|
| 93 | + $this->libelle=trim($this->libelle); |
|
| 94 | + } |
|
| 95 | + if (isset($this->active)) { |
|
| 96 | + $this->active=trim($this->active); |
|
| 97 | + } |
|
| 98 | + if (isset($this->module)) { |
|
| 99 | + $this->module=trim($this->module); |
|
| 100 | + } |
|
| 91 | 101 | |
| 92 | 102 | |
| 93 | 103 | |
@@ -149,8 +159,7 @@ discard block |
||
| 149 | 159 | } |
| 150 | 160 | $this->db->rollback(); |
| 151 | 161 | return -1*$error; |
| 152 | - } |
|
| 153 | - else |
|
| 162 | + } else |
|
| 154 | 163 | { |
| 155 | 164 | $this->db->commit(); |
| 156 | 165 | return $this->id; |
@@ -177,9 +186,13 @@ discard block |
||
| 177 | 186 | $sql.= " t.active,"; |
| 178 | 187 | $sql.= " t.module"; |
| 179 | 188 | $sql.= " FROM ".MAIN_DB_PREFIX."c_typent as t"; |
| 180 | - if ($id) $sql.= " WHERE t.id = ".$id; |
|
| 181 | - elseif ($code) $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; |
|
| 182 | - elseif ($label) $sql.= " WHERE t.libelle = '".$this->db->escape($label)."'"; |
|
| 189 | + if ($id) { |
|
| 190 | + $sql.= " WHERE t.id = ".$id; |
|
| 191 | + } elseif ($code) { |
|
| 192 | + $sql.= " WHERE t.code = '".$this->db->escape($code)."'"; |
|
| 193 | + } elseif ($label) { |
|
| 194 | + $sql.= " WHERE t.libelle = '".$this->db->escape($label)."'"; |
|
| 195 | + } |
|
| 183 | 196 | |
| 184 | 197 | $resql=$this->db->query($sql); |
| 185 | 198 | if ($resql) |
@@ -198,8 +211,7 @@ discard block |
||
| 198 | 211 | $this->db->free($resql); |
| 199 | 212 | |
| 200 | 213 | return 1; |
| 201 | - } |
|
| 202 | - else |
|
| 214 | + } else |
|
| 203 | 215 | { |
| 204 | 216 | $this->error="Error ".$this->db->lasterror(); |
| 205 | 217 | return -1; |
@@ -220,10 +232,18 @@ discard block |
||
| 220 | 232 | $error=0; |
| 221 | 233 | |
| 222 | 234 | // Clean parameters |
| 223 | - if (isset($this->code)) $this->code=trim($this->code); |
|
| 224 | - if (isset($this->libelle)) $this->libelle=trim($this->libelle); |
|
| 225 | - if (isset($this->active)) $this->active=trim($this->active); |
|
| 226 | - if (isset($this->module)) $this->module=trim($this->module); |
|
| 235 | + if (isset($this->code)) { |
|
| 236 | + $this->code=trim($this->code); |
|
| 237 | + } |
|
| 238 | + if (isset($this->libelle)) { |
|
| 239 | + $this->libelle=trim($this->libelle); |
|
| 240 | + } |
|
| 241 | + if (isset($this->active)) { |
|
| 242 | + $this->active=trim($this->active); |
|
| 243 | + } |
|
| 244 | + if (isset($this->module)) { |
|
| 245 | + $this->module=trim($this->module); |
|
| 246 | + } |
|
| 227 | 247 | |
| 228 | 248 | |
| 229 | 249 | // Check parameters |
@@ -269,8 +289,7 @@ discard block |
||
| 269 | 289 | } |
| 270 | 290 | $this->db->rollback(); |
| 271 | 291 | return -1*$error; |
| 272 | - } |
|
| 273 | - else |
|
| 292 | + } else |
|
| 274 | 293 | { |
| 275 | 294 | $this->db->commit(); |
| 276 | 295 | return 1; |
@@ -325,8 +344,7 @@ discard block |
||
| 325 | 344 | } |
| 326 | 345 | $this->db->rollback(); |
| 327 | 346 | return -1*$error; |
| 328 | - } |
|
| 329 | - else |
|
| 347 | + } else |
|
| 330 | 348 | { |
| 331 | 349 | $this->db->commit(); |
| 332 | 350 | return 1; |
@@ -118,8 +118,12 @@ discard block |
||
| 118 | 118 | global $conf; |
| 119 | 119 | |
| 120 | 120 | // Server |
| 121 | - if (! empty($conf->global->LDAP_SERVER_HOST)) $this->server[] = $conf->global->LDAP_SERVER_HOST; |
|
| 122 | - if (! empty($conf->global->LDAP_SERVER_HOST_SLAVE)) $this->server[] = $conf->global->LDAP_SERVER_HOST_SLAVE; |
|
| 121 | + if (! empty($conf->global->LDAP_SERVER_HOST)) { |
|
| 122 | + $this->server[] = $conf->global->LDAP_SERVER_HOST; |
|
| 123 | + } |
|
| 124 | + if (! empty($conf->global->LDAP_SERVER_HOST_SLAVE)) { |
|
| 125 | + $this->server[] = $conf->global->LDAP_SERVER_HOST_SLAVE; |
|
| 126 | + } |
|
| 123 | 127 | $this->serverPort = $conf->global->LDAP_SERVER_PORT; |
| 124 | 128 | $this->ldapProtocolVersion = $conf->global->LDAP_SERVER_PROTOCOLVERSION; |
| 125 | 129 | $this->dn = $conf->global->LDAP_SERVER_DN; |
@@ -185,13 +189,18 @@ discard block |
||
| 185 | 189 | // Loop on each ldap server |
| 186 | 190 | foreach ($this->server as $key => $host) |
| 187 | 191 | { |
| 188 | - if ($connected) break; |
|
| 189 | - if (empty($host)) continue; |
|
| 192 | + if ($connected) { |
|
| 193 | + break; |
|
| 194 | + } |
|
| 195 | + if (empty($host)) { |
|
| 196 | + continue; |
|
| 197 | + } |
|
| 190 | 198 | |
| 191 | 199 | if ($this->serverPing($host, $this->serverPort) === true) { |
| 192 | 200 | $this->connection = ldap_connect($host, $this->serverPort); |
| 201 | + } else { |
|
| 202 | + continue; |
|
| 193 | 203 | } |
| 194 | - else continue; |
|
| 195 | 204 | |
| 196 | 205 | if (is_resource($this->connection)) |
| 197 | 206 | { |
@@ -221,13 +230,11 @@ discard block |
||
| 221 | 230 | $this->bind=$this->result; |
| 222 | 231 | $connected=2; |
| 223 | 232 | break; |
| 224 | - } |
|
| 225 | - else |
|
| 233 | + } else |
|
| 226 | 234 | { |
| 227 | 235 | $this->error=ldap_errno($this->connection).' '.ldap_error($this->connection); |
| 228 | 236 | } |
| 229 | - } |
|
| 230 | - else |
|
| 237 | + } else |
|
| 231 | 238 | { |
| 232 | 239 | // Try in auth mode |
| 233 | 240 | if ($this->searchUser && $this->searchPassword) |
@@ -239,8 +246,7 @@ discard block |
||
| 239 | 246 | $this->bind=$this->result; |
| 240 | 247 | $connected=2; |
| 241 | 248 | break; |
| 242 | - } |
|
| 243 | - else |
|
| 249 | + } else |
|
| 244 | 250 | { |
| 245 | 251 | $this->error=ldap_errno($this->connection).' '.ldap_error($this->connection); |
| 246 | 252 | } |
@@ -255,8 +261,7 @@ discard block |
||
| 255 | 261 | $this->bind=$this->result; |
| 256 | 262 | $connected=1; |
| 257 | 263 | break; |
| 258 | - } |
|
| 259 | - else |
|
| 264 | + } else |
|
| 260 | 265 | { |
| 261 | 266 | $this->error=ldap_errno($this->connection).' '.ldap_error($this->connection); |
| 262 | 267 | } |
@@ -264,7 +269,9 @@ discard block |
||
| 264 | 269 | } |
| 265 | 270 | } |
| 266 | 271 | |
| 267 | - if (! $connected) $this->close(); |
|
| 272 | + if (! $connected) { |
|
| 273 | + $this->close(); |
|
| 274 | + } |
|
| 268 | 275 | } |
| 269 | 276 | } |
| 270 | 277 | |
@@ -272,8 +279,7 @@ discard block |
||
| 272 | 279 | { |
| 273 | 280 | $return=$connected; |
| 274 | 281 | dol_syslog(get_class($this)."::connect_bind return=".$return, LOG_DEBUG); |
| 275 | - } |
|
| 276 | - else |
|
| 282 | + } else |
|
| 277 | 283 | { |
| 278 | 284 | $this->error='Failed to connect to LDAP'.($this->error?': '.$this->error:''); |
| 279 | 285 | $return=-1; |
@@ -295,8 +301,7 @@ discard block |
||
| 295 | 301 | if ($this->connection && ! @ldap_close($this->connection)) |
| 296 | 302 | { |
| 297 | 303 | return false; |
| 298 | - } |
|
| 299 | - else |
|
| 304 | + } else |
|
| 300 | 305 | { |
| 301 | 306 | return true; |
| 302 | 307 | } |
@@ -316,8 +321,7 @@ discard block |
||
| 316 | 321 | $this->ldapErrorText = ldap_error($this->connection); |
| 317 | 322 | $this->error=$this->ldapErrorCode." ".$this->ldapErrorText; |
| 318 | 323 | return false; |
| 319 | - } |
|
| 320 | - else |
|
| 324 | + } else |
|
| 321 | 325 | { |
| 322 | 326 | return true; |
| 323 | 327 | } |
@@ -341,8 +345,7 @@ discard block |
||
| 341 | 345 | $this->ldapErrorText = ldap_error($this->connection); |
| 342 | 346 | $this->error=$this->ldapErrorCode." ".$this->ldapErrorText; |
| 343 | 347 | return false; |
| 344 | - } |
|
| 345 | - else |
|
| 348 | + } else |
|
| 346 | 349 | { |
| 347 | 350 | return true; |
| 348 | 351 | } |
@@ -432,7 +435,9 @@ discard block |
||
| 432 | 435 | $dn=$this->convFromOutputCharset($dn,$this->ldapcharset); |
| 433 | 436 | foreach($info as $key => $val) |
| 434 | 437 | { |
| 435 | - if (! is_array($val)) $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset); |
|
| 438 | + if (! is_array($val)) { |
|
| 439 | + $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset); |
|
| 440 | + } |
|
| 436 | 441 | } |
| 437 | 442 | |
| 438 | 443 | $this->dump($dn,$info); |
@@ -444,8 +449,7 @@ discard block |
||
| 444 | 449 | { |
| 445 | 450 | dol_syslog(get_class($this)."::add successfull", LOG_DEBUG); |
| 446 | 451 | return 1; |
| 447 | - } |
|
| 448 | - else |
|
| 452 | + } else |
|
| 449 | 453 | { |
| 450 | 454 | $this->ldapErrorCode = @ldap_errno($this->connection); |
| 451 | 455 | $this->ldapErrorText = @ldap_error($this->connection); |
@@ -486,7 +490,9 @@ discard block |
||
| 486 | 490 | $dn=$this->convFromOutputCharset($dn,$this->ldapcharset); |
| 487 | 491 | foreach($info as $key => $val) |
| 488 | 492 | { |
| 489 | - if (! is_array($val)) $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset); |
|
| 493 | + if (! is_array($val)) { |
|
| 494 | + $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset); |
|
| 495 | + } |
|
| 490 | 496 | } |
| 491 | 497 | |
| 492 | 498 | $this->dump($dn,$info); |
@@ -498,8 +504,7 @@ discard block |
||
| 498 | 504 | { |
| 499 | 505 | dol_syslog(get_class($this)."::modify successfull", LOG_DEBUG); |
| 500 | 506 | return 1; |
| 501 | - } |
|
| 502 | - else |
|
| 507 | + } else |
|
| 503 | 508 | { |
| 504 | 509 | $this->error=@ldap_error($this->connection); |
| 505 | 510 | dol_syslog(get_class($this)."::modify failed: ".$this->error, LOG_ERR); |
@@ -548,8 +553,7 @@ discard block |
||
| 548 | 553 | { |
| 549 | 554 | dol_syslog(get_class($this)."::rename successfull", LOG_DEBUG); |
| 550 | 555 | return 1; |
| 551 | - } |
|
| 552 | - else |
|
| 556 | + } else |
|
| 553 | 557 | { |
| 554 | 558 | $this->error=@ldap_error($this->connection); |
| 555 | 559 | dol_syslog(get_class($this)."::rename failed: ".$this->error, LOG_ERR); |
@@ -593,15 +597,16 @@ discard block |
||
| 593 | 597 | { |
| 594 | 598 | // This function currently only works with LDAPv3 |
| 595 | 599 | $result = $this->rename($olddn, $newrdn, $newparent, $user, true); |
| 596 | - } |
|
| 597 | - else |
|
| 600 | + } else |
|
| 598 | 601 | { |
| 599 | 602 | // If change we make is rename the key of LDAP record, we create new one and if ok, we delete old one. |
| 600 | 603 | $result = $this->add($dn, $info, $user); |
| 601 | - if ($result > 0 && $olddn && $olddn != $dn) $result = $this->delete($olddn); // If add fails, we do not try to delete old one |
|
| 604 | + if ($result > 0 && $olddn && $olddn != $dn) { |
|
| 605 | + $result = $this->delete($olddn); |
|
| 606 | + } |
|
| 607 | + // If add fails, we do not try to delete old one |
|
| 602 | 608 | } |
| 603 | - } |
|
| 604 | - else |
|
| 609 | + } else |
|
| 605 | 610 | { |
| 606 | 611 | //$result = $this->delete($olddn); |
| 607 | 612 | $result = $this->add($dn, $info, $user); // If record has been deleted from LDAP, we recreate it. We ignore error if it already exists. |
@@ -613,8 +618,7 @@ discard block |
||
| 613 | 618 | dol_syslog(get_class($this)."::update ".$this->error,LOG_ERR); |
| 614 | 619 | //print_r($info); |
| 615 | 620 | return -1; |
| 616 | - } |
|
| 617 | - else |
|
| 621 | + } else |
|
| 618 | 622 | { |
| 619 | 623 | dol_syslog(get_class($this)."::update done successfully"); |
| 620 | 624 | return 1; |
@@ -652,7 +656,9 @@ discard block |
||
| 652 | 656 | |
| 653 | 657 | $result=@ldap_delete($this->connection, $dn); |
| 654 | 658 | |
| 655 | - if ($result) return 1; |
|
| 659 | + if ($result) { |
|
| 660 | + return 1; |
|
| 661 | + } |
|
| 656 | 662 | return -1; |
| 657 | 663 | } |
| 658 | 664 | |
@@ -673,23 +679,23 @@ discard block |
||
| 673 | 679 | if (preg_match('/^ldap/',$this->server[0])) |
| 674 | 680 | { |
| 675 | 681 | $target="-H ".join(',',$this->server); |
| 676 | - } |
|
| 677 | - else |
|
| 682 | + } else |
|
| 678 | 683 | { |
| 679 | 684 | $target="-h ".join(',',$this->server)." -p ".$this->serverPort; |
| 680 | 685 | } |
| 681 | 686 | $content.="# ldapadd $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n"; |
| 682 | 687 | $content.="# ldapmodify $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n"; |
| 683 | 688 | $content.="# ldapdelete $target -c -v -D ".$this->searchUser." -W -f ldapinput.in\n"; |
| 684 | - if (in_array('localhost',$this->server)) $content.="# If commands fails to connect, try without -h and -p\n"; |
|
| 689 | + if (in_array('localhost',$this->server)) { |
|
| 690 | + $content.="# If commands fails to connect, try without -h and -p\n"; |
|
| 691 | + } |
|
| 685 | 692 | $content.="dn: ".$dn."\n"; |
| 686 | 693 | foreach($info as $key => $value) |
| 687 | 694 | { |
| 688 | 695 | if (! is_array($value)) |
| 689 | 696 | { |
| 690 | 697 | $content.="$key: $value\n"; |
| 691 | - } |
|
| 692 | - else |
|
| 698 | + } else |
|
| 693 | 699 | { |
| 694 | 700 | foreach($value as $valuekey => $valuevalue) |
| 695 | 701 | { |
@@ -723,11 +729,11 @@ discard block |
||
| 723 | 729 | { |
| 724 | 730 | fputs($fp, $content); |
| 725 | 731 | fclose($fp); |
| 726 | - if (! empty($conf->global->MAIN_UMASK)) |
|
| 727 | - @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
| 732 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 733 | + @chmod($outputfile, octdec($conf->global->MAIN_UMASK)); |
|
| 734 | + } |
|
| 728 | 735 | return 1; |
| 729 | - } |
|
| 730 | - else |
|
| 736 | + } else |
|
| 731 | 737 | { |
| 732 | 738 | return -1; |
| 733 | 739 | } |
@@ -752,7 +758,10 @@ discard block |
||
| 752 | 758 | $host = $regs[1]; |
| 753 | 759 | } |
| 754 | 760 | $op = @fsockopen($host, $port, $errno, $errstr, $timeout); |
| 755 | - if (!$op) return false; //DC is N/A |
|
| 761 | + if (!$op) { |
|
| 762 | + return false; |
|
| 763 | + } |
|
| 764 | + //DC is N/A |
|
| 756 | 765 | else { |
| 757 | 766 | fclose($op); //explicitly close open socket connection |
| 758 | 767 | return true; //DC is up & running, we can safely connect with ldap_connect |
@@ -793,7 +802,9 @@ discard block |
||
| 793 | 802 | $dn=$this->convFromOutputCharset($dn,$this->ldapcharset); |
| 794 | 803 | foreach($info as $key => $val) |
| 795 | 804 | { |
| 796 | - if (! is_array($val)) $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset); |
|
| 805 | + if (! is_array($val)) { |
|
| 806 | + $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset); |
|
| 807 | + } |
|
| 797 | 808 | } |
| 798 | 809 | |
| 799 | 810 | $this->dump($dn,$info); |
@@ -805,8 +816,7 @@ discard block |
||
| 805 | 816 | { |
| 806 | 817 | dol_syslog(get_class($this)."::add_attribute successfull", LOG_DEBUG); |
| 807 | 818 | return 1; |
| 808 | - } |
|
| 809 | - else |
|
| 819 | + } else |
|
| 810 | 820 | { |
| 811 | 821 | $this->error=@ldap_error($this->connection); |
| 812 | 822 | dol_syslog(get_class($this)."::add_attribute failed: ".$this->error, LOG_ERR); |
@@ -845,7 +855,9 @@ discard block |
||
| 845 | 855 | $dn=$this->convFromOutputCharset($dn,$this->ldapcharset); |
| 846 | 856 | foreach($info as $key => $val) |
| 847 | 857 | { |
| 848 | - if (! is_array($val)) $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset); |
|
| 858 | + if (! is_array($val)) { |
|
| 859 | + $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset); |
|
| 860 | + } |
|
| 849 | 861 | } |
| 850 | 862 | |
| 851 | 863 | $this->dump($dn,$info); |
@@ -857,8 +869,7 @@ discard block |
||
| 857 | 869 | { |
| 858 | 870 | dol_syslog(get_class($this)."::updateAttribute successfull", LOG_DEBUG); |
| 859 | 871 | return 1; |
| 860 | - } |
|
| 861 | - else |
|
| 872 | + } else |
|
| 862 | 873 | { |
| 863 | 874 | $this->error=@ldap_error($this->connection); |
| 864 | 875 | dol_syslog(get_class($this)."::updateAttribute failed: ".$this->error, LOG_ERR); |
@@ -897,7 +908,9 @@ discard block |
||
| 897 | 908 | $dn=$this->convFromOutputCharset($dn,$this->ldapcharset); |
| 898 | 909 | foreach($info as $key => $val) |
| 899 | 910 | { |
| 900 | - if (! is_array($val)) $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset); |
|
| 911 | + if (! is_array($val)) { |
|
| 912 | + $info[$key]=$this->convFromOutputCharset($val,$this->ldapcharset); |
|
| 913 | + } |
|
| 901 | 914 | } |
| 902 | 915 | |
| 903 | 916 | $this->dump($dn,$info); |
@@ -909,8 +922,7 @@ discard block |
||
| 909 | 922 | { |
| 910 | 923 | dol_syslog(get_class($this)."::deleteAttribute successfull", LOG_DEBUG); |
| 911 | 924 | return 1; |
| 912 | - } |
|
| 913 | - else |
|
| 925 | + } else |
|
| 914 | 926 | { |
| 915 | 927 | $this->error=@ldap_error($this->connection); |
| 916 | 928 | dol_syslog(get_class($this)."::deleteAttribute failed: ".$this->error, LOG_ERR); |
@@ -1034,17 +1046,14 @@ discard block |
||
| 1034 | 1046 | if (((string) $activefilter == '1' || (string) $activefilter == 'user') && $this->filter) |
| 1035 | 1047 | { |
| 1036 | 1048 | $filter = '('.$this->filter.')'; |
| 1037 | - } |
|
| 1038 | - elseif (((string) $activefilter == 'member') && $this->filter) |
|
| 1049 | + } elseif (((string) $activefilter == 'member') && $this->filter) |
|
| 1039 | 1050 | { |
| 1040 | 1051 | $filter = '('.$this->filtermember.')'; |
| 1041 | - } |
|
| 1042 | - else // If this->filter is empty, make fiter on * (all) |
|
| 1052 | + } else // If this->filter is empty, make fiter on * (all) |
|
| 1043 | 1053 | { |
| 1044 | 1054 | $filter = '('.$useridentifier.'=*)'; |
| 1045 | 1055 | } |
| 1046 | - } |
|
| 1047 | - else |
|
| 1056 | + } else |
|
| 1048 | 1057 | { |
| 1049 | 1058 | $filter = '('.$useridentifier.'='.$search.')'; |
| 1050 | 1059 | } |
@@ -1056,8 +1065,7 @@ discard block |
||
| 1056 | 1065 | dol_syslog(get_class($this)."::getRecords connection=".$this->connection." userDn=".$userDn." filter=".$filter. " attributeArray=(".join(',',$attributeArray).")"); |
| 1057 | 1066 | //var_dump($attributeArray); |
| 1058 | 1067 | $this->result = @ldap_search($this->connection, $userDn, $filter, $attributeArray); |
| 1059 | - } |
|
| 1060 | - else |
|
| 1068 | + } else |
|
| 1061 | 1069 | { |
| 1062 | 1070 | // Return list with fields selected by default |
| 1063 | 1071 | dol_syslog(get_class($this)."::getRecords connection=".$this->connection." userDn=".$userDn." filter=".$filter); |
@@ -1095,8 +1103,7 @@ discard block |
||
| 1095 | 1103 | { |
| 1096 | 1104 | $objectsid = $this->getObjectSid($recordid); |
| 1097 | 1105 | $fulllist[$recordid][$attributeArray[$j]] = $objectsid; |
| 1098 | - } |
|
| 1099 | - else |
|
| 1106 | + } else |
|
| 1100 | 1107 | { |
| 1101 | 1108 | if(in_array($attributeArray[$j], $attributeAsArray) && is_array($info[$i][$keyattributelower])) { |
| 1102 | 1109 | $valueTab = array(); |
@@ -1170,8 +1177,7 @@ discard block |
||
| 1170 | 1177 | // Si pas de resultat on cherche dans le domaine |
| 1171 | 1178 | $searchDN = $this->domain; |
| 1172 | 1179 | $i++; |
| 1173 | - } |
|
| 1174 | - else |
|
| 1180 | + } else |
|
| 1175 | 1181 | { |
| 1176 | 1182 | $i++; |
| 1177 | 1183 | $i++; |
@@ -1183,8 +1189,7 @@ discard block |
||
| 1183 | 1189 | $ldapBinary = ldap_get_values_len($this->connection, $entry, "objectsid"); |
| 1184 | 1190 | $SIDText = $this->binSIDtoText($ldapBinary[0]); |
| 1185 | 1191 | return $SIDText; |
| 1186 | - } |
|
| 1187 | - else |
|
| 1192 | + } else |
|
| 1188 | 1193 | { |
| 1189 | 1194 | $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection); |
| 1190 | 1195 | return '?'; |
@@ -1243,8 +1248,7 @@ discard block |
||
| 1243 | 1248 | { |
| 1244 | 1249 | $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection); |
| 1245 | 1250 | return -1; |
| 1246 | - } |
|
| 1247 | - else |
|
| 1251 | + } else |
|
| 1248 | 1252 | { |
| 1249 | 1253 | ldap_free_result($this->result); |
| 1250 | 1254 | return $result; |
@@ -1280,11 +1284,13 @@ discard block |
||
| 1280 | 1284 | if ($this->result) |
| 1281 | 1285 | { |
| 1282 | 1286 | $result = @ldap_get_entries($this->connection, $this->result); |
| 1283 | - if ($result['count'] > 0) dol_syslog('Ldap::fetch search found '.$result['count'].' records'); |
|
| 1284 | - else dol_syslog('Ldap::fetch search returns but found no records'); |
|
| 1287 | + if ($result['count'] > 0) { |
|
| 1288 | + dol_syslog('Ldap::fetch search found '.$result['count'].' records'); |
|
| 1289 | + } else { |
|
| 1290 | + dol_syslog('Ldap::fetch search returns but found no records'); |
|
| 1291 | + } |
|
| 1285 | 1292 | //var_dump($result);exit; |
| 1286 | - } |
|
| 1287 | - else |
|
| 1293 | + } else |
|
| 1288 | 1294 | { |
| 1289 | 1295 | $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection); |
| 1290 | 1296 | dol_syslog(get_class($this)."::fetch search fails"); |
@@ -1296,8 +1302,7 @@ discard block |
||
| 1296 | 1302 | // Si pas de resultat on cherche dans le domaine |
| 1297 | 1303 | $searchDN = $this->domain; |
| 1298 | 1304 | $i++; |
| 1299 | - } |
|
| 1300 | - else |
|
| 1305 | + } else |
|
| 1301 | 1306 | { |
| 1302 | 1307 | break; |
| 1303 | 1308 | } |
@@ -1307,8 +1312,7 @@ discard block |
||
| 1307 | 1312 | { |
| 1308 | 1313 | $this->error = ldap_errno($this->connection)." ".ldap_error($this->connection); |
| 1309 | 1314 | return -1; |
| 1310 | - } |
|
| 1311 | - else |
|
| 1315 | + } else |
|
| 1312 | 1316 | { |
| 1313 | 1317 | $this->name = $this->convToOutputCharset($result[0][$this->attr_name][0],$this->ldapcharset); |
| 1314 | 1318 | $this->firstname = $this->convToOutputCharset($result[0][$this->attr_firstname][0],$this->ldapcharset); |
@@ -1320,15 +1324,18 @@ discard block |
||
| 1320 | 1324 | $this->mobile = $this->convToOutputCharset($result[0][$this->attr_mobile][0],$this->ldapcharset); |
| 1321 | 1325 | |
| 1322 | 1326 | $this->uacf = $this->parseUACF($this->convToOutputCharset($result[0]["useraccountcontrol"][0],$this->ldapcharset)); |
| 1323 | - if (isset($result[0]["pwdlastset"][0])) // If expiration on password exists |
|
| 1327 | + if (isset($result[0]["pwdlastset"][0])) { |
|
| 1328 | + // If expiration on password exists |
|
| 1324 | 1329 | { |
| 1325 | 1330 | $this->pwdlastset = ($result[0]["pwdlastset"][0] != 0)?$this->convert_time($this->convToOutputCharset($result[0]["pwdlastset"][0],$this->ldapcharset)):0; |
| 1326 | 1331 | } |
| 1327 | - else |
|
| 1332 | + } else |
|
| 1328 | 1333 | { |
| 1329 | 1334 | $this->pwdlastset = -1; |
| 1330 | 1335 | } |
| 1331 | - if (!$this->name && !$this->login) $this->pwdlastset = -1; |
|
| 1336 | + if (!$this->name && !$this->login) { |
|
| 1337 | + $this->pwdlastset = -1; |
|
| 1338 | + } |
|
| 1332 | 1339 | $this->badpwdtime = $this->convert_time($this->convToOutputCharset($result[0]["badpasswordtime"][0],$this->ldapcharset)); |
| 1333 | 1340 | |
| 1334 | 1341 | // FQDN domain |
@@ -1433,7 +1440,9 @@ discard block |
||
| 1433 | 1440 | break; |
| 1434 | 1441 | } |
| 1435 | 1442 | } |
| 1436 | - if (empty($retval)) $retval = "UNKNOWN_TYPE_" . $samtype; |
|
| 1443 | + if (empty($retval)) { |
|
| 1444 | + $retval = "UNKNOWN_TYPE_" . $samtype; |
|
| 1445 | + } |
|
| 1437 | 1446 | |
| 1438 | 1447 | return($retval); |
| 1439 | 1448 | } |
@@ -1466,8 +1475,12 @@ discard block |
||
| 1466 | 1475 | private function convToOutputCharset($str,$pagecodefrom='UTF-8') |
| 1467 | 1476 | { |
| 1468 | 1477 | global $conf; |
| 1469 | - if ($pagecodefrom == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') $str=utf8_encode($str); |
|
| 1470 | - if ($pagecodefrom == 'UTF-8' && $conf->file->character_set_client == 'ISO-8859-1') $str=utf8_decode($str); |
|
| 1478 | + if ($pagecodefrom == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') { |
|
| 1479 | + $str=utf8_encode($str); |
|
| 1480 | + } |
|
| 1481 | + if ($pagecodefrom == 'UTF-8' && $conf->file->character_set_client == 'ISO-8859-1') { |
|
| 1482 | + $str=utf8_decode($str); |
|
| 1483 | + } |
|
| 1471 | 1484 | return $str; |
| 1472 | 1485 | } |
| 1473 | 1486 | |
@@ -1481,8 +1494,12 @@ discard block |
||
| 1481 | 1494 | function convFromOutputCharset($str,$pagecodeto='UTF-8') |
| 1482 | 1495 | { |
| 1483 | 1496 | global $conf; |
| 1484 | - if ($pagecodeto == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') $str=utf8_decode($str); |
|
| 1485 | - if ($pagecodeto == 'UTF-8' && $conf->file->character_set_client == 'ISO-8859-1') $str=utf8_encode($str); |
|
| 1497 | + if ($pagecodeto == 'ISO-8859-1' && $conf->file->character_set_client == 'UTF-8') { |
|
| 1498 | + $str=utf8_decode($str); |
|
| 1499 | + } |
|
| 1500 | + if ($pagecodeto == 'UTF-8' && $conf->file->character_set_client == 'ISO-8859-1') { |
|
| 1501 | + $str=utf8_encode($str); |
|
| 1502 | + } |
|
| 1486 | 1503 | return $str; |
| 1487 | 1504 | } |
| 1488 | 1505 | |
@@ -1497,7 +1514,9 @@ discard block |
||
| 1497 | 1514 | { |
| 1498 | 1515 | global $conf; |
| 1499 | 1516 | |
| 1500 | - if (empty($keygroup)) $keygroup='LDAP_KEY_GROUPS'; |
|
| 1517 | + if (empty($keygroup)) { |
|
| 1518 | + $keygroup='LDAP_KEY_GROUPS'; |
|
| 1519 | + } |
|
| 1501 | 1520 | |
| 1502 | 1521 | $search='('.$conf->global->$keygroup.'=*)'; |
| 1503 | 1522 | $result = $this->search($this->groups,$search); |
@@ -129,15 +129,19 @@ discard block |
||
| 129 | 129 | dol_syslog("AntiVir::dol_avscan_file Result return_var=".$return_var." output=".join(',',$output)); |
| 130 | 130 | |
| 131 | 131 | $returncodevirus=1; |
| 132 | - if ($return_var == $returncodevirus) // Virus found |
|
| 132 | + if ($return_var == $returncodevirus) { |
|
| 133 | + // Virus found |
|
| 133 | 134 | { |
| 134 | 135 | $this->errors=$output; |
| 136 | + } |
|
| 135 | 137 | return -99; |
| 136 | 138 | } |
| 137 | 139 | |
| 138 | - if ($return_var > 0) // If other error |
|
| 140 | + if ($return_var > 0) { |
|
| 141 | + // If other error |
|
| 139 | 142 | { |
| 140 | 143 | $this->errors=$output; |
| 144 | + } |
|
| 141 | 145 | return -98; |
| 142 | 146 | } |
| 143 | 147 | |
@@ -173,10 +177,14 @@ discard block |
||
| 173 | 177 | $param=preg_replace('/%maxfilesize/',$maxfilesize,$param); |
| 174 | 178 | $param=preg_replace('/%file/',trim($file),$param); |
| 175 | 179 | |
| 176 | - if (! preg_match('/%file/',$conf->global->MAIN_ANTIVIRUS_PARAM)) |
|
| 177 | - $param=$param." ".escapeshellarg(trim($file)); |
|
| 180 | + if (! preg_match('/%file/',$conf->global->MAIN_ANTIVIRUS_PARAM)) { |
|
| 181 | + $param=$param." ".escapeshellarg(trim($file)); |
|
| 182 | + } |
|
| 178 | 183 | |
| 179 | - if (preg_match("/\s/",$command)) $command=escapeshellarg($command); // Use quotes on command. Using escapeshellcmd fails. |
|
| 184 | + if (preg_match("/\s/",$command)) { |
|
| 185 | + $command=escapeshellarg($command); |
|
| 186 | + } |
|
| 187 | + // Use quotes on command. Using escapeshellcmd fails. |
|
| 180 | 188 | |
| 181 | 189 | $ret=$command.' '.$param; |
| 182 | 190 | //$ret=$command.' '.$param.' 2>&1'; |