@@ -42,8 +42,9 @@ discard block |
||
| 42 | 42 | $langs->loadLangs(array("errors", "admin", "modulebuilder"));
|
| 43 | 43 | |
| 44 | 44 | $mode = GETPOST('mode', 'alpha');
|
| 45 | -if (empty($mode)) |
|
| 46 | - $mode = 'common'; |
|
| 45 | +if (empty($mode)) { |
|
| 46 | + $mode = 'common'; |
|
| 47 | +} |
|
| 47 | 48 | $action = GETPOST('action', 'alpha');
|
| 48 | 49 | //var_dump($_POST);exit; |
| 49 | 50 | $value = GETPOST('value', 'alpha');
|
@@ -64,8 +65,9 @@ discard block |
||
| 64 | 65 | $dolistore = new Dolistore(false); |
| 65 | 66 | |
| 66 | 67 | |
| 67 | -if (!$user->admin) |
|
| 68 | - accessforbidden(); |
|
| 68 | +if (!$user->admin) { |
|
| 69 | + accessforbidden(); |
|
| 70 | +} |
|
| 69 | 71 | |
| 70 | 72 | $specialtostring = array(0 => 'common', 1 => 'interfaces', 2 => 'other', 3 => 'functional', 4 => 'marketplace'); |
| 71 | 73 | |
@@ -86,15 +88,19 @@ discard block |
||
| 86 | 88 | |
| 87 | 89 | $param = ''; |
| 88 | 90 | if (!GETPOST('buttonreset', 'alpha')) {
|
| 89 | - if ($search_keyword) |
|
| 90 | - $param .= '&search_keyword=' . urlencode($search_keyword); |
|
| 91 | - if ($search_status && $search_status != '-1') |
|
| 92 | - $param .= '&search_status=' . urlencode($search_status); |
|
| 93 | - if ($search_nature && $search_nature != '-1') |
|
| 94 | - $param .= '&search_nature=' . urlencode($search_nature); |
|
| 95 | - if ($search_version && $search_version != '-1') |
|
| 96 | - $param .= '&search_version=' . urlencode($search_version); |
|
| 97 | -} |
|
| 91 | + if ($search_keyword) { |
|
| 92 | + $param .= '&search_keyword=' . urlencode($search_keyword); |
|
| 93 | + } |
|
| 94 | + if ($search_status && $search_status != '-1') { |
|
| 95 | + $param .= '&search_status=' . urlencode($search_status); |
|
| 96 | + } |
|
| 97 | + if ($search_nature && $search_nature != '-1') { |
|
| 98 | + $param .= '&search_nature=' . urlencode($search_nature); |
|
| 99 | + } |
|
| 100 | + if ($search_version && $search_version != '-1') { |
|
| 101 | + $param .= '&search_version=' . urlencode($search_version); |
|
| 102 | + } |
|
| 103 | + } |
|
| 98 | 104 | |
| 99 | 105 | $dirins = DOL_DOCUMENT_ROOT . '/custom'; |
| 100 | 106 | $urldolibarrmodules = 'https://www.dolistore.com/'; |
@@ -111,8 +117,9 @@ discard block |
||
| 111 | 117 | |
| 112 | 118 | $parameters = array(); |
| 113 | 119 | $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
| 114 | -if ($reshook < 0) |
|
| 115 | - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 120 | +if ($reshook < 0) { |
|
| 121 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 122 | +} |
|
| 116 | 123 | |
| 117 | 124 | if (GETPOST('buttonreset', 'alpha')) {
|
| 118 | 125 | $search_keyword = ''; |
@@ -206,9 +213,9 @@ discard block |
||
| 206 | 213 | |
| 207 | 214 | if ($action == 'set' && $user->admin) {
|
| 208 | 215 | $resarray = activateModule($value); |
| 209 | - if (!empty($resarray['errors'])) |
|
| 210 | - setEventMessages('', $resarray['errors'], 'errors');
|
|
| 211 | - else {
|
|
| 216 | + if (!empty($resarray['errors'])) { |
|
| 217 | + setEventMessages('', $resarray['errors'], 'errors'); |
|
| 218 | + } else {
|
|
| 212 | 219 | //var_dump($resarray);exit; |
| 213 | 220 | if ($resarray['nbperms'] > 0) {
|
| 214 | 221 | $tmpsql = "SELECT COUNT(rowid) as nb FROM " . MAIN_DB_PREFIX . "user WHERE admin <> 1"; |
@@ -220,15 +227,15 @@ discard block |
||
| 220 | 227 | $msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
|
| 221 | 228 | setEventMessages($msg, null, 'warnings'); |
| 222 | 229 | } |
| 223 | - } else |
|
| 224 | - dol_print_error($db); |
|
| 230 | + } else { |
|
| 231 | + dol_print_error($db); |
|
| 232 | + } |
|
| 225 | 233 | } |
| 226 | 234 | } |
| 227 | 235 | //header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y?'&page_y='.$page_y:''));
|
| 228 | 236 | header("Location: ?controller=admin&method=modules&mode=" . $mode . $param . ($page_y ? '&page_y=' . $page_y : ''));
|
| 229 | 237 | exit; |
| 230 | -} |
|
| 231 | -else if ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') {
|
|
| 238 | +} else if ($action == 'reset' && $user->admin && GETPOST('confirm') == 'yes') {
|
|
| 232 | 239 | $result = unActivateModule($value); |
| 233 | 240 | if ($result) {
|
| 234 | 241 | setEventMessages($result, null, 'errors'); |
@@ -308,16 +315,20 @@ discard block |
||
| 308 | 315 | |
| 309 | 316 | // We discard modules according to features level (PS: if module is activated we always show it) |
| 310 | 317 | $const_name = 'MAIN_MODULE_' . strtoupper(preg_replace('/^mod/i', '', get_class($objMod)));
|
| 311 | - if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) |
|
| 312 | - $modulequalified = 0; |
|
| 313 | - if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) |
|
| 314 | - $modulequalified = 0; |
|
| 315 | - if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0)))
|
|
| 316 | - $modulequalified = 0; |
|
| 318 | + if ($objMod->version == 'development' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 2))) { |
|
| 319 | + $modulequalified = 0; |
|
| 320 | + } |
|
| 321 | + if ($objMod->version == 'experimental' && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL < 1))) { |
|
| 322 | + $modulequalified = 0; |
|
| 323 | + } |
|
| 324 | + if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) { |
|
| 325 | + $modulequalified = 0; |
|
| 326 | + } |
|
| 317 | 327 | |
| 318 | 328 | // We discard modules according to property ->hidden |
| 319 | - if (!empty($objMod->hidden)) |
|
| 320 | - $modulequalified = 0; |
|
| 329 | + if (!empty($objMod->hidden)) { |
|
| 330 | + $modulequalified = 0; |
|
| 331 | + } |
|
| 321 | 332 | |
| 322 | 333 | if ($modulequalified > 0) {
|
| 323 | 334 | $publisher = dol_escape_htmltag($objMod->getPublisher()); |
@@ -363,16 +374,21 @@ discard block |
||
| 363 | 374 | //print $i.'-'.$dirmod[$i].'<br>'; |
| 364 | 375 | // Set categ[$i] |
| 365 | 376 | $specialstring = 'unknown'; |
| 366 | - if ($objMod->version == 'development' || $objMod->version == 'experimental') |
|
| 367 | - $specialstring = 'expdev'; |
|
| 368 | - if (isset($categ[$specialstring])) |
|
| 369 | - $categ[$specialstring] ++; // Array of all different modules categories |
|
| 370 | - else |
|
| 371 | - $categ[$specialstring] = 1; |
|
| 377 | + if ($objMod->version == 'development' || $objMod->version == 'experimental') { |
|
| 378 | + $specialstring = 'expdev'; |
|
| 379 | + } |
|
| 380 | + if (isset($categ[$specialstring])) { |
|
| 381 | + $categ[$specialstring] ++; |
|
| 382 | + } |
|
| 383 | + // Array of all different modules categories |
|
| 384 | + else { |
|
| 385 | + $categ[$specialstring] = 1; |
|
| 386 | + } |
|
| 372 | 387 | $j++; |
| 373 | 388 | $i++; |
| 374 | - } else |
|
| 375 | - dol_syslog("Module " . get_class($objMod) . " not qualified");
|
|
| 389 | + } else { |
|
| 390 | + dol_syslog("Module " . get_class($objMod) . " not qualified"); |
|
| 391 | + } |
|
| 376 | 392 | } catch (Exception $e) {
|
| 377 | 393 | dol_syslog("Failed to load " . $dir . $file . " " . $e->getMessage(), LOG_ERR);
|
| 378 | 394 | } |
@@ -395,8 +411,9 @@ discard block |
||
| 395 | 411 | if (!empty($modules[$value])) {
|
| 396 | 412 | $objMod = $modules[$value]; |
| 397 | 413 | |
| 398 | - if (!empty($objMod->langfiles)) |
|
| 399 | - $langs->loadLangs($objMod->langfiles); |
|
| 414 | + if (!empty($objMod->langfiles)) { |
|
| 415 | + $langs->loadLangs($objMod->langfiles); |
|
| 416 | + } |
|
| 400 | 417 | |
| 401 | 418 | $form = new Form($db); |
| 402 | 419 | $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?value=' . $value . '&mode=' . $mode . $param, $langs->trans('ConfirmUnactivation'), $langs->trans(GETPOST('confirm_message_code')), 'reset', '', 'no', 1);
|
@@ -412,19 +429,24 @@ discard block |
||
| 412 | 429 | |
| 413 | 430 | $nbofactivatedmodules = count($conf->modules); |
| 414 | 431 | $moreinfo = $langs->trans("TotalNumberOfActivatedModules", ($nbofactivatedmodules - 1), count($modules));
|
| 415 | -if ($nbofactivatedmodules <= 1) |
|
| 416 | - $moreinfo .= ' ' . img_warning($langs->trans("YouMustEnableOneModule"));
|
|
| 432 | +if ($nbofactivatedmodules <= 1) { |
|
| 433 | + $moreinfo .= ' ' . img_warning($langs->trans("YouMustEnableOneModule")); |
|
| 434 | +} |
|
| 417 | 435 | print load_fiche_titre($langs->trans("ModulesSetup"), $moreinfo, 'title_setup');
|
| 418 | 436 | |
| 419 | 437 | // Start to show page |
| 420 | -if ($mode == 'common') |
|
| 421 | - print '<span class="opacitymedium">' . $langs->trans("ModulesDesc") . "</span><br>\n";
|
|
| 422 | -if ($mode == 'marketplace') |
|
| 423 | - print '<span class="opacitymedium">' . $langs->trans("ModulesMarketPlaceDesc") . "</span><br>\n";
|
|
| 424 | -if ($mode == 'deploy') |
|
| 425 | - print '<span class="opacitymedium">' . $langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules")) . "</span><br>\n";
|
|
| 426 | -if ($mode == 'develop') |
|
| 427 | - print '<span class="opacitymedium">' . $langs->trans("ModulesDevelopDesc") . "</span><br>\n";
|
|
| 438 | +if ($mode == 'common') { |
|
| 439 | + print '<span class="opacitymedium">' . $langs->trans("ModulesDesc") . "</span><br>\n"; |
|
| 440 | +} |
|
| 441 | +if ($mode == 'marketplace') { |
|
| 442 | + print '<span class="opacitymedium">' . $langs->trans("ModulesMarketPlaceDesc") . "</span><br>\n"; |
|
| 443 | +} |
|
| 444 | +if ($mode == 'deploy') { |
|
| 445 | + print '<span class="opacitymedium">' . $langs->trans("ModulesDeployDesc", $langs->transnoentitiesnoconv("AvailableModules")) . "</span><br>\n"; |
|
| 446 | +} |
|
| 447 | +if ($mode == 'develop') { |
|
| 448 | + print '<span class="opacitymedium">' . $langs->trans("ModulesDevelopDesc") . "</span><br>\n"; |
|
| 449 | +} |
|
| 428 | 450 | |
| 429 | 451 | $head = modules_prepare_head(); |
| 430 | 452 | |
@@ -436,8 +458,9 @@ discard block |
||
| 436 | 458 | dol_set_focus('#search_keyword');
|
| 437 | 459 | |
| 438 | 460 | print '<form method="POST" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">'; |
| 439 | - if ($optioncss != '') |
|
| 440 | - print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
|
| 461 | + if ($optioncss != '') { |
|
| 462 | + print '<input type="hidden" name="optioncss" value="' . $optioncss . '">'; |
|
| 463 | + } |
|
| 441 | 464 | print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">'; |
| 442 | 465 | print '<input type="hidden" name="sortfield" value="' . $sortfield . '">'; |
| 443 | 466 | print '<input type="hidden" name="sortorder" value="' . $sortorder . '">'; |
@@ -454,12 +477,15 @@ discard block |
||
| 454 | 477 | $moreforfilter .= '</div>'; |
| 455 | 478 | if (!empty($conf->global->MAIN_FEATURES_LEVEL)) {
|
| 456 | 479 | $array_version = array('stable' => $langs->transnoentitiesnoconv("Stable"));
|
| 457 | - if ($conf->global->MAIN_FEATURES_LEVEL < 0) |
|
| 458 | - $array_version['deprecated'] = $langs->trans("Deprecated");
|
|
| 459 | - if ($conf->global->MAIN_FEATURES_LEVEL > 0) |
|
| 460 | - $array_version['experimental'] = $langs->trans("Experimental");
|
|
| 461 | - if ($conf->global->MAIN_FEATURES_LEVEL > 1) |
|
| 462 | - $array_version['development'] = $langs->trans("Development");
|
|
| 480 | + if ($conf->global->MAIN_FEATURES_LEVEL < 0) { |
|
| 481 | + $array_version['deprecated'] = $langs->trans("Deprecated"); |
|
| 482 | + } |
|
| 483 | + if ($conf->global->MAIN_FEATURES_LEVEL > 0) { |
|
| 484 | + $array_version['experimental'] = $langs->trans("Experimental"); |
|
| 485 | + } |
|
| 486 | + if ($conf->global->MAIN_FEATURES_LEVEL > 1) { |
|
| 487 | + $array_version['development'] = $langs->trans("Development"); |
|
| 488 | + } |
|
| 463 | 489 | $moreforfilter .= '<div class="divsearchfield">'; |
| 464 | 490 | $moreforfilter .= $langs->trans('Version') . ': ' . $form->selectarray('search_version', $array_version, $search_version, 1);
|
| 465 | 491 | $moreforfilter .= '</div>'; |
@@ -487,8 +513,9 @@ discard block |
||
| 487 | 513 | |
| 488 | 514 | $parameters = array(); |
| 489 | 515 | $reshook = $hookmanager->executeHooks('insertExtraHeader', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
|
| 490 | - if ($reshook < 0) |
|
| 491 | - setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 516 | + if ($reshook < 0) { |
|
| 517 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
| 518 | + } |
|
| 492 | 519 | |
| 493 | 520 | // Show list of modules |
| 494 | 521 | |
@@ -507,8 +534,10 @@ discard block |
||
| 507 | 534 | |
| 508 | 535 | //print $objMod->name." - ".$key." - ".$objMod->version."<br>"; |
| 509 | 536 | //if (($mode != (isset($specialtostring[$special])?$specialtostring[$special]:'unknown') && $mode != 'expdev') |
| 510 | - if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') |
|
| 511 | - continue; // Discard if not for current tab |
|
| 537 | + if ($mode == 'expdev' && $objMod->version != 'development' && $objMod->version != 'experimental') { |
|
| 538 | + continue; |
|
| 539 | + } |
|
| 540 | + // Discard if not for current tab |
|
| 512 | 541 | |
| 513 | 542 | if (!$objMod->getName()) {
|
| 514 | 543 | dol_syslog("Error for module " . $key . " - Property name of module looks empty", LOG_WARNING);
|
@@ -528,40 +557,52 @@ discard block |
||
| 528 | 557 | if ($search_keyword) {
|
| 529 | 558 | $qualified = 0; |
| 530 | 559 | if (preg_match('/' . preg_quote($search_keyword) . '/i', $modulename) || preg_match('/' . preg_quote($search_keyword) . '/i', $moduletechnicalname) || preg_match('/' . preg_quote($search_keyword) . '/i', $moduledesc) || preg_match('/' . preg_quote($search_keyword) . '/i', $moduledesclong) || preg_match('/' . preg_quote($search_keyword) . '/i', $moduleauthor)
|
| 531 | - ) |
|
| 532 | - $qualified = 1; |
|
| 533 | - if (!$qualified) |
|
| 534 | - continue; |
|
| 560 | + ) { |
|
| 561 | + $qualified = 1; |
|
| 562 | + } |
|
| 563 | + if (!$qualified) { |
|
| 564 | + continue; |
|
| 565 | + } |
|
| 535 | 566 | } |
| 536 | 567 | if ($search_status) {
|
| 537 | - if ($search_status == 'active' && empty($conf->global->$const_name)) |
|
| 538 | - continue; |
|
| 539 | - if ($search_status == 'disabled' && !empty($conf->global->$const_name)) |
|
| 540 | - continue; |
|
| 568 | + if ($search_status == 'active' && empty($conf->global->$const_name)) { |
|
| 569 | + continue; |
|
| 570 | + } |
|
| 571 | + if ($search_status == 'disabled' && !empty($conf->global->$const_name)) { |
|
| 572 | + continue; |
|
| 573 | + } |
|
| 541 | 574 | } |
| 542 | 575 | if ($search_nature) {
|
| 543 | - if (preg_match('/^external/', $search_nature) && $objMod->isCoreOrExternalModule() != 'external')
|
|
| 544 | - continue; |
|
| 576 | + if (preg_match('/^external/', $search_nature) && $objMod->isCoreOrExternalModule() != 'external') { |
|
| 577 | + continue; |
|
| 578 | + } |
|
| 545 | 579 | if (preg_match('/^external_(.*)$/', $search_nature, $reg)) {
|
| 546 | 580 | //print $reg[1].'-'.dol_escape_htmltag($objMod->getPublisher()); |
| 547 | 581 | $publisher = dol_escape_htmltag($objMod->getPublisher()); |
| 548 | - if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) |
|
| 549 | - continue; |
|
| 550 | - if (!$reg[1] && !empty($publisher)) |
|
| 551 | - continue; |
|
| 582 | + if ($reg[1] && dol_escape_htmltag($reg[1]) != $publisher) { |
|
| 583 | + continue; |
|
| 584 | + } |
|
| 585 | + if (!$reg[1] && !empty($publisher)) { |
|
| 586 | + continue; |
|
| 587 | + } |
|
| 552 | 588 | } |
| 553 | - if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') |
|
| 554 | - continue; |
|
| 589 | + if ($search_nature == 'core' && $objMod->isCoreOrExternalModule() == 'external') { |
|
| 590 | + continue; |
|
| 591 | + } |
|
| 555 | 592 | } |
| 556 | 593 | if ($search_version) {
|
| 557 | - if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable')
|
|
| 558 | - continue; |
|
| 559 | - if ($objMod->version != 'development' && ($search_version == 'development')) |
|
| 560 | - continue; |
|
| 561 | - if ($objMod->version != 'experimental' && ($search_version == 'experimental')) |
|
| 562 | - continue; |
|
| 563 | - if (!preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated'))
|
|
| 564 | - continue; |
|
| 594 | + if (($objMod->version == 'development' || $objMod->version == 'experimental' || preg_match('/deprecated/', $objMod->version)) && $search_version == 'stable') { |
|
| 595 | + continue; |
|
| 596 | + } |
|
| 597 | + if ($objMod->version != 'development' && ($search_version == 'development')) { |
|
| 598 | + continue; |
|
| 599 | + } |
|
| 600 | + if ($objMod->version != 'experimental' && ($search_version == 'experimental')) { |
|
| 601 | + continue; |
|
| 602 | + } |
|
| 603 | + if (!preg_match('/deprecated/', $objMod->version) && ($search_version == 'deprecated')) { |
|
| 604 | + continue; |
|
| 605 | + } |
|
| 565 | 606 | } |
| 566 | 607 | |
| 567 | 608 | // Load all lang files of module |
@@ -599,12 +640,15 @@ discard block |
||
| 599 | 640 | // Version (with picto warning or not) |
| 600 | 641 | $version = $objMod->getVersion(0); |
| 601 | 642 | $versiontrans = ''; |
| 602 | - if (preg_match('/development/i', $version))
|
|
| 603 | - $versiontrans .= img_warning($langs->trans("Development"), 'style="float: left"');
|
|
| 604 | - if (preg_match('/experimental/i', $version))
|
|
| 605 | - $versiontrans .= img_warning($langs->trans("Experimental"), 'style="float: left"');
|
|
| 606 | - if (preg_match('/deprecated/i', $version))
|
|
| 607 | - $versiontrans .= img_warning($langs->trans("Deprecated"), 'style="float: left"');
|
|
| 643 | + if (preg_match('/development/i', $version)) { |
|
| 644 | + $versiontrans .= img_warning($langs->trans("Development"), 'style="float: left"'); |
|
| 645 | + } |
|
| 646 | + if (preg_match('/experimental/i', $version)) { |
|
| 647 | + $versiontrans .= img_warning($langs->trans("Experimental"), 'style="float: left"'); |
|
| 648 | + } |
|
| 649 | + if (preg_match('/deprecated/i', $version)) { |
|
| 650 | + $versiontrans .= img_warning($langs->trans("Deprecated"), 'style="float: left"'); |
|
| 651 | + } |
|
| 608 | 652 | $versiontrans .= $objMod->getVersion(1); |
| 609 | 653 | |
| 610 | 654 | // Define imginfo |
@@ -614,8 +658,9 @@ discard block |
||
| 614 | 658 | } |
| 615 | 659 | |
| 616 | 660 | print '<tr class="oddeven">' . "\n"; |
| 617 | - if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) |
|
| 618 | - print '<td width="20px">' . ++$linenum . '</td>'; |
|
| 661 | + if (!empty($conf->global->MAIN_MODULES_SHOW_LINENUMBERS)) { |
|
| 662 | + print '<td width="20px">' . ++$linenum . '</td>'; |
|
| 663 | + } |
|
| 619 | 664 | |
| 620 | 665 | // Picto + Name of module |
| 621 | 666 | print ' <td width="200px">'; |
@@ -623,12 +668,12 @@ discard block |
||
| 623 | 668 | //if (is_array($objMod->need_dolibarr_version)) $alttext.=($alttext?' - ':'').'Dolibarr >= '.join('.',$objMod->need_dolibarr_version);
|
| 624 | 669 | //if (is_array($objMod->phpmin)) $alttext.=($alttext?' - ':'').'PHP >= '.join('.',$objMod->phpmin);
|
| 625 | 670 | if (!empty($objMod->picto)) {
|
| 626 | - if (preg_match('/^\//i', $objMod->picto))
|
|
| 627 | - print img_picto($alttext, $objMod->picto, ' width="14px"', 1); |
|
| 628 | - else |
|
| 629 | - print img_object($alttext, $objMod->picto, 'class="valignmiddle" width="14px"'); |
|
| 630 | - } |
|
| 631 | - else {
|
|
| 671 | + if (preg_match('/^\//i', $objMod->picto)) { |
|
| 672 | + print img_picto($alttext, $objMod->picto, ' width="14px"', 1); |
|
| 673 | + } else { |
|
| 674 | + print img_object($alttext, $objMod->picto, 'class="valignmiddle" width="14px"'); |
|
| 675 | + } |
|
| 676 | + } else {
|
|
| 632 | 677 | print img_object($alttext, 'generic', 'class="valignmiddle"'); |
| 633 | 678 | } |
| 634 | 679 | print ' <span class="valignmiddle">' . $objMod->getName() . '</span>'; |
@@ -673,16 +718,16 @@ discard block |
||
| 673 | 718 | if (!empty($objMod->disabled)) {
|
| 674 | 719 | print $langs->trans("Disabled");
|
| 675 | 720 | } else if (!empty($objMod->always_enabled) || ((!empty($conf->multicompany->enabled) && $objMod->core_enabled) && ($user->entity || $conf->entity != 1))) {
|
| 676 | - if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) |
|
| 677 | - print $langs->trans("Used");
|
|
| 678 | - else {
|
|
| 721 | + if (method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) { |
|
| 722 | + print $langs->trans("Used"); |
|
| 723 | + } else {
|
|
| 679 | 724 | print img_picto($langs->trans("Required"), 'switch_on');
|
| 680 | 725 | print $langs->trans("Required");
|
| 681 | 726 | } |
| 682 | - if (!empty($conf->multicompany->enabled) && $user->entity) |
|
| 683 | - $disableSetup++; |
|
| 684 | - } |
|
| 685 | - else {
|
|
| 727 | + if (!empty($conf->multicompany->enabled) && $user->entity) { |
|
| 728 | + $disableSetup++; |
|
| 729 | + } |
|
| 730 | + } else {
|
|
| 686 | 731 | if (!empty($objMod->warnings_unactivation[$mysoc->country_code]) && method_exists($objMod, 'alreadyUsed') && $objMod->alreadyUsed()) {
|
| 687 | 732 | //print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&module_position='.$module_position.'&action=reset_confirm&confirm_message_code='.$objMod->warnings_unactivation[$mysoc->country_code].'&value=' . $modName . '&mode=' . $mode . $param . '">'; |
| 688 | 733 | print '<a class="reposition" href="?controller=admin&method=modules&id=' . $objMod->numero . '&module_position=' . $module_position . '&action=reset_confirm&confirm_message_code=' . $objMod->warnings_unactivation[$mysoc->country_code] . '&value=' . $modName . '&mode=' . $mode . $param . '">'; |
@@ -700,14 +745,19 @@ discard block |
||
| 700 | 745 | // Link config |
| 701 | 746 | if (!empty($objMod->config_page_url) && !$disableSetup) {
|
| 702 | 747 | $backtourlparam = ''; |
| 703 | - if ($search_keyword != '') |
|
| 704 | - $backtourlparam .= ($backtourlparam ? '&' : '?') . 'search_keyword=' . $search_keyword; // No urlencode here, done later |
|
| 705 | - if ($search_nature > -1) |
|
| 706 | - $backtourlparam .= ($backtourlparam ? '&' : '?') . 'search_nature=' . $search_nature; |
|
| 707 | - if ($search_version > -1) |
|
| 708 | - $backtourlparam .= ($backtourlparam ? '&' : '?') . 'search_version=' . $search_version; |
|
| 709 | - if ($search_status > -1) |
|
| 710 | - $backtourlparam .= ($backtourlparam ? '&' : '?') . 'search_status=' . $search_status; |
|
| 748 | + if ($search_keyword != '') { |
|
| 749 | + $backtourlparam .= ($backtourlparam ? '&' : '?') . 'search_keyword=' . $search_keyword; |
|
| 750 | + } |
|
| 751 | + // No urlencode here, done later |
|
| 752 | + if ($search_nature > -1) { |
|
| 753 | + $backtourlparam .= ($backtourlparam ? '&' : '?') . 'search_nature=' . $search_nature; |
|
| 754 | + } |
|
| 755 | + if ($search_version > -1) { |
|
| 756 | + $backtourlparam .= ($backtourlparam ? '&' : '?') . 'search_version=' . $search_version; |
|
| 757 | + } |
|
| 758 | + if ($search_status > -1) { |
|
| 759 | + $backtourlparam .= ($backtourlparam ? '&' : '?') . 'search_status=' . $search_status; |
|
| 760 | + } |
|
| 711 | 761 | $backtourl = $_SERVER["PHP_SELF"] . $backtourlparam; |
| 712 | 762 | |
| 713 | 763 | if (is_array($objMod->config_page_url)) {
|
@@ -766,10 +816,12 @@ discard block |
||
| 766 | 816 | if (preg_match('/^always/', $keycountry) || ($mysoc->country_code && preg_match('/^' . $mysoc->country_code . '/', $keycountry))) {
|
| 767 | 817 | $warningmessage .= ($warningmessage ? "\n" : "") . $langs->trans($cursorwarningmessage, $objMod->getName(), $mysoc->country_code, $modules[$keymodule]->getName()); |
| 768 | 818 | $warningmessage .= ($warningmessage ? "\n" : "") . ($warningmessage ? "\n" : "") . $langs->trans("Module") . ' : ' . $objMod->getName();
|
| 769 | - if (!empty($objMod->editor_name)) |
|
| 770 | - $warningmessage .= ($warningmessage ? "\n" : "") . $langs->trans("Publisher") . ' : ' . $objMod->editor_name;
|
|
| 771 | - if (!empty($objMod->editor_name)) |
|
| 772 | - $warningmessage .= ($warningmessage ? "\n" : "") . $langs->trans("ModuleTriggeringThisWarning") . ' : ' . $modules[$keymodule]->getName();
|
|
| 819 | + if (!empty($objMod->editor_name)) { |
|
| 820 | + $warningmessage .= ($warningmessage ? "\n" : "") . $langs->trans("Publisher") . ' : ' . $objMod->editor_name; |
|
| 821 | + } |
|
| 822 | + if (!empty($objMod->editor_name)) { |
|
| 823 | + $warningmessage .= ($warningmessage ? "\n" : "") . $langs->trans("ModuleTriggeringThisWarning") . ' : ' . $modules[$keymodule]->getName(); |
|
| 824 | + } |
|
| 773 | 825 | } |
| 774 | 826 | } |
| 775 | 827 | } |
@@ -778,8 +830,9 @@ discard block |
||
| 778 | 830 | print '<!-- Message to show: ' . $warningmessage . ' -->' . "\n"; |
| 779 | 831 | //print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$objMod->numero.'&module_position='.$module_position.'&action=set&value=' . $modName . '&mode=' . $mode . $param . '"'; |
| 780 | 832 | print '<a class="reposition" href="?controller=admin&method=modules&id=' . $objMod->numero . '&module_position=' . $module_position . '&action=set&value=' . $modName . '&mode=' . $mode . $param . '"'; |
| 781 | - if ($warningmessage) |
|
| 782 | - print ' onclick="return confirm(\'' . dol_escape_js($warningmessage) . '\');"'; |
|
| 833 | + if ($warningmessage) { |
|
| 834 | + print ' onclick="return confirm(\'' . dol_escape_js($warningmessage) . '\');"'; |
|
| 835 | + } |
|
| 783 | 836 | print '>'; |
| 784 | 837 | print img_picto($langs->trans("Disabled"), 'switch_off');
|
| 785 | 838 | print "</a>\n"; |
@@ -898,8 +951,9 @@ discard block |
||
| 898 | 951 | $dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT);
|
| 899 | 952 | $allowonlineinstall = true; |
| 900 | 953 | $allowfromweb = 1; |
| 901 | - if (dol_is_file($dolibarrdataroot . '/installmodules.lock')) |
|
| 902 | - $allowonlineinstall = false; |
|
| 954 | + if (dol_is_file($dolibarrdataroot . '/installmodules.lock')) { |
|
| 955 | + $allowonlineinstall = false; |
|
| 956 | + } |
|
| 903 | 957 | |
| 904 | 958 | $fullurl = '<a href="' . $urldolibarrmodules . '" target="_blank">' . $urldolibarrmodules . '</a>'; |
| 905 | 959 | $message = ''; |
@@ -958,18 +1012,23 @@ discard block |
||
| 958 | 1012 | |
| 959 | 1013 | $max = $conf->global->MAIN_UPLOAD_DOC; // En Kb |
| 960 | 1014 | $maxphp = @ini_get('upload_max_filesize'); // En inconnu
|
| 961 | - if (preg_match('/k$/i', $maxphp))
|
|
| 962 | - $maxphp = $maxphp * 1; |
|
| 963 | - if (preg_match('/m$/i', $maxphp))
|
|
| 964 | - $maxphp = $maxphp * 1024; |
|
| 965 | - if (preg_match('/g$/i', $maxphp))
|
|
| 966 | - $maxphp = $maxphp * 1024 * 1024; |
|
| 967 | - if (preg_match('/t$/i', $maxphp))
|
|
| 968 | - $maxphp = $maxphp * 1024 * 1024 * 1024; |
|
| 1015 | + if (preg_match('/k$/i', $maxphp)) { |
|
| 1016 | + $maxphp = $maxphp * 1; |
|
| 1017 | + } |
|
| 1018 | + if (preg_match('/m$/i', $maxphp)) { |
|
| 1019 | + $maxphp = $maxphp * 1024; |
|
| 1020 | + } |
|
| 1021 | + if (preg_match('/g$/i', $maxphp)) { |
|
| 1022 | + $maxphp = $maxphp * 1024 * 1024; |
|
| 1023 | + } |
|
| 1024 | + if (preg_match('/t$/i', $maxphp)) { |
|
| 1025 | + $maxphp = $maxphp * 1024 * 1024 * 1024; |
|
| 1026 | + } |
|
| 969 | 1027 | // Now $max and $maxphp are in Kb |
| 970 | 1028 | $maxmin = $max; |
| 971 | - if ($maxphp > 0) |
|
| 972 | - $maxmin = min($max, $maxphp); |
|
| 1029 | + if ($maxphp > 0) { |
|
| 1030 | + $maxmin = min($max, $maxphp); |
|
| 1031 | + } |
|
| 973 | 1032 | |
| 974 | 1033 | if ($maxmin > 0) {
|
| 975 | 1034 | print '<script type="text/javascript"> |
@@ -128,8 +128,10 @@ |
||
| 128 | 128 | } else {
|
| 129 | 129 | $toprightmenu = $hookmanager->resPrint; // replace |
| 130 | 130 | } |
| 131 | -} else |
|
| 132 | - $toprightmenu .= $result; // For backward compatibility |
|
| 131 | +} else { |
|
| 132 | + $toprightmenu .= $result; |
|
| 133 | +} |
|
| 134 | +// For backward compatibility |
|
| 133 | 135 | |
| 134 | 136 | |
| 135 | 137 | |
@@ -247,10 +247,14 @@ discard block |
||
| 247 | 247 | $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database |
| 248 | 248 | } |
| 249 | 249 | } else { // The fetch was forced on an entity
|
| 250 | - if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) |
|
| 251 | - $sql .= " WHERE u.entity IS NOT NULL"; // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database |
|
| 252 | - else |
|
| 253 | - $sql .= " WHERE u.entity IN (0, " . (($entity != '' && $entity >= 0) ? $entity : $conf->entity) . ")"; // search in entity provided in parameter |
|
| 250 | + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { |
|
| 251 | + $sql .= " WHERE u.entity IS NOT NULL"; |
|
| 252 | + } |
|
| 253 | + // multicompany is on in transverse mode or user making fetch is on entity 0, so user is allowed to fetch anywhere into database |
|
| 254 | + else { |
|
| 255 | + $sql .= " WHERE u.entity IN (0, " . (($entity != '' && $entity >= 0) ? $entity : $conf->entity) . ")"; |
|
| 256 | + } |
|
| 257 | + // search in entity provided in parameter |
|
| 254 | 258 | } |
| 255 | 259 | |
| 256 | 260 | if ($sid) { // permet une recherche du user par son SID ActiveDirectory ou Samba
|
@@ -342,16 +346,16 @@ discard block |
||
| 342 | 346 | |
| 343 | 347 | // Protection when module multicompany was set, admin was set to first entity and then, the module was disabled, |
| 344 | 348 | // in such case, this admin user must be admin for ALL entities. |
| 345 | - if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) |
|
| 346 | - $this->entity = 0; |
|
| 349 | + if (empty($conf->multicompany->enabled) && $this->admin && $this->entity == 1) { |
|
| 350 | + $this->entity = 0; |
|
| 351 | + } |
|
| 347 | 352 | |
| 348 | 353 | // Retreive all extrafield |
| 349 | 354 | // fetch optionals attributes and labels |
| 350 | 355 | $this->fetch_optionals(); |
| 351 | 356 | |
| 352 | 357 | $this->db->free($result); |
| 353 | - } |
|
| 354 | - else {
|
|
| 358 | + } else {
|
|
| 355 | 359 | $this->error = "USERNOTFOUND"; |
| 356 | 360 | dol_syslog(get_class($this) . "::fetch user not found", LOG_DEBUG); |
| 357 | 361 | |
@@ -377,13 +381,13 @@ discard block |
||
| 377 | 381 | while ($i < $num) {
|
| 378 | 382 | $obj = $this->db->fetch_object($resql); |
| 379 | 383 | $p = (!empty($obj->param) ? $obj->param : ''); |
| 380 | - if (!empty($p)) |
|
| 381 | - $this->conf->$p = $obj->value; |
|
| 384 | + if (!empty($p)) { |
|
| 385 | + $this->conf->$p = $obj->value; |
|
| 386 | + } |
|
| 382 | 387 | $i++; |
| 383 | 388 | } |
| 384 | 389 | $this->db->free($resql); |
| 385 | - } |
|
| 386 | - else {
|
|
| 390 | + } else {
|
|
| 387 | 391 | $this->error = $this->db->lasterror(); |
| 388 | 392 | return -2; |
| 389 | 393 | } |
@@ -492,12 +496,12 @@ discard block |
||
| 492 | 496 | // Where pour la liste des droits a ajouter |
| 493 | 497 | $whereforadd = "id=" . $this->db->escape($rid); |
| 494 | 498 | // Ajout des droits induits |
| 495 | - if (!empty($subperms)) |
|
| 496 | - $whereforadd .= " OR (module='$module' AND perms='$perms' AND (subperms='lire' OR subperms='read'))"; |
|
| 497 | - else if (!empty($perms)) |
|
| 498 | - $whereforadd .= " OR (module='$module' AND (perms='lire' OR perms='read') AND subperms IS NULL)"; |
|
| 499 | - } |
|
| 500 | - else {
|
|
| 499 | + if (!empty($subperms)) { |
|
| 500 | + $whereforadd .= " OR (module='$module' AND perms='$perms' AND (subperms='lire' OR subperms='read'))"; |
|
| 501 | + } else if (!empty($perms)) { |
|
| 502 | + $whereforadd .= " OR (module='$module' AND (perms='lire' OR perms='read') AND subperms IS NULL)"; |
|
| 503 | + } |
|
| 504 | + } else {
|
|
| 501 | 505 | // On a pas demande un droit en particulier mais une liste de droits |
| 502 | 506 | // sur la base d'un nom de module de de perms |
| 503 | 507 | // Where pour la liste des droits a ajouter |
@@ -506,8 +510,9 @@ discard block |
||
| 506 | 510 | $whereforadd = 'allmodules'; |
| 507 | 511 | } else {
|
| 508 | 512 | $whereforadd = "module='" . $this->db->escape($allmodule) . "'"; |
| 509 | - if (!empty($allperms)) |
|
| 510 | - $whereforadd .= " AND perms='" . $this->db->escape($allperms) . "'"; |
|
| 513 | + if (!empty($allperms)) { |
|
| 514 | + $whereforadd .= " AND perms='" . $this->db->escape($allperms) . "'"; |
|
| 515 | + } |
|
| 511 | 516 | } |
| 512 | 517 | } |
| 513 | 518 | } |
@@ -531,16 +536,17 @@ discard block |
||
| 531 | 536 | $nid = $obj->id; |
| 532 | 537 | |
| 533 | 538 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_rights WHERE fk_user = " . $this->id . " AND fk_id=" . $nid . " AND entity = " . $entity; |
| 534 | - if (!$this->db->query($sql)) |
|
| 535 | - $error++; |
|
| 539 | + if (!$this->db->query($sql)) { |
|
| 540 | + $error++; |
|
| 541 | + } |
|
| 536 | 542 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user_rights (entity, fk_user, fk_id) VALUES (" . $entity . ", " . $this->id . ", " . $nid . ")";
|
| 537 | - if (!$this->db->query($sql)) |
|
| 538 | - $error++; |
|
| 543 | + if (!$this->db->query($sql)) { |
|
| 544 | + $error++; |
|
| 545 | + } |
|
| 539 | 546 | |
| 540 | 547 | $i++; |
| 541 | 548 | } |
| 542 | - } |
|
| 543 | - else {
|
|
| 549 | + } else {
|
|
| 544 | 550 | $error++; |
| 545 | 551 | dol_print_error($this->db); |
| 546 | 552 | } |
@@ -610,12 +616,13 @@ discard block |
||
| 610 | 616 | // Where pour la liste des droits a supprimer |
| 611 | 617 | $wherefordel = "id=" . $this->db->escape($rid); |
| 612 | 618 | // Suppression des droits induits |
| 613 | - if ($subperms == 'lire' || $subperms == 'read') |
|
| 614 | - $wherefordel .= " OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)"; |
|
| 615 | - if ($perms == 'lire' || $perms == 'read') |
|
| 616 | - $wherefordel .= " OR (module='$module')"; |
|
| 617 | - } |
|
| 618 | - else {
|
|
| 619 | + if ($subperms == 'lire' || $subperms == 'read') { |
|
| 620 | + $wherefordel .= " OR (module='$module' AND perms='$perms' AND subperms IS NOT NULL)"; |
|
| 621 | + } |
|
| 622 | + if ($perms == 'lire' || $perms == 'read') { |
|
| 623 | + $wherefordel .= " OR (module='$module')"; |
|
| 624 | + } |
|
| 625 | + } else {
|
|
| 619 | 626 | // On a demande suppression d'un droit sur la base d'un nom de module ou perms |
| 620 | 627 | // Where pour la liste des droits a supprimer |
| 621 | 628 | if (!empty($allmodule)) {
|
@@ -623,8 +630,9 @@ discard block |
||
| 623 | 630 | $wherefordel = 'allmodules'; |
| 624 | 631 | } else {
|
| 625 | 632 | $wherefordel = "module='" . $this->db->escape($allmodule) . "'"; |
| 626 | - if (!empty($allperms)) |
|
| 627 | - $whereforadd .= " AND perms='" . $this->db->escape($allperms) . "'"; |
|
| 633 | + if (!empty($allperms)) { |
|
| 634 | + $whereforadd .= " AND perms='" . $this->db->escape($allperms) . "'"; |
|
| 635 | + } |
|
| 628 | 636 | } |
| 629 | 637 | } |
| 630 | 638 | } |
@@ -650,13 +658,13 @@ discard block |
||
| 650 | 658 | $sql = "DELETE FROM " . MAIN_DB_PREFIX . "user_rights"; |
| 651 | 659 | $sql .= " WHERE fk_user = " . $this->id . " AND fk_id=" . $nid; |
| 652 | 660 | $sql .= " AND entity = " . $entity; |
| 653 | - if (!$this->db->query($sql)) |
|
| 654 | - $error++; |
|
| 661 | + if (!$this->db->query($sql)) { |
|
| 662 | + $error++; |
|
| 663 | + } |
|
| 655 | 664 | |
| 656 | 665 | $i++; |
| 657 | 666 | } |
| 658 | - } |
|
| 659 | - else {
|
|
| 667 | + } else {
|
|
| 660 | 668 | $error++; |
| 661 | 669 | dol_print_error($this->db); |
| 662 | 670 | } |
@@ -734,8 +742,9 @@ discard block |
||
| 734 | 742 | } |
| 735 | 743 | $sql .= " AND ur.fk_user= " . $this->id; |
| 736 | 744 | $sql .= " AND r.perms IS NOT NULL"; |
| 737 | - if ($moduletag) |
|
| 738 | - $sql .= " AND r.module = '" . $this->db->escape($moduletag) . "'"; |
|
| 745 | + if ($moduletag) { |
|
| 746 | + $sql .= " AND r.module = '" . $this->db->escape($moduletag) . "'"; |
|
| 747 | + } |
|
| 739 | 748 | |
| 740 | 749 | $resql = $this->db->query($sql); |
| 741 | 750 | if ($resql) {
|
@@ -749,21 +758,26 @@ discard block |
||
| 749 | 758 | $subperms = $obj->subperms; |
| 750 | 759 | |
| 751 | 760 | if ($perms) {
|
| 752 | - if (!isset($this->rights) || !is_object($this->rights)) |
|
| 753 | - $this->rights = new stdClass(); // For avoid error |
|
| 761 | + if (!isset($this->rights) || !is_object($this->rights)) { |
|
| 762 | + $this->rights = new stdClass(); |
|
| 763 | + } |
|
| 764 | + // For avoid error |
|
| 754 | 765 | if ($module) {
|
| 755 | - if (!isset($this->rights->$module) || !is_object($this->rights->$module)) |
|
| 756 | - $this->rights->$module = new stdClass(); |
|
| 766 | + if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { |
|
| 767 | + $this->rights->$module = new stdClass(); |
|
| 768 | + } |
|
| 757 | 769 | if ($subperms) {
|
| 758 | - if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) |
|
| 759 | - $this->rights->$module->$perms = new stdClass(); |
|
| 760 | - if (empty($this->rights->$module->$perms->$subperms)) |
|
| 761 | - $this->nb_rights++; |
|
| 770 | + if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { |
|
| 771 | + $this->rights->$module->$perms = new stdClass(); |
|
| 772 | + } |
|
| 773 | + if (empty($this->rights->$module->$perms->$subperms)) { |
|
| 774 | + $this->nb_rights++; |
|
| 775 | + } |
|
| 762 | 776 | $this->rights->$module->$perms->$subperms = 1; |
| 763 | - } |
|
| 764 | - else {
|
|
| 765 | - if (empty($this->rights->$module->$perms)) |
|
| 766 | - $this->nb_rights++; |
|
| 777 | + } else {
|
|
| 778 | + if (empty($this->rights->$module->$perms)) { |
|
| 779 | + $this->nb_rights++; |
|
| 780 | + } |
|
| 767 | 781 | $this->rights->$module->$perms = 1; |
| 768 | 782 | } |
| 769 | 783 | } |
@@ -792,8 +806,9 @@ discard block |
||
| 792 | 806 | $sql .= " AND gr.fk_usergroup = gu.fk_usergroup"; |
| 793 | 807 | $sql .= " AND gu.fk_user = " . $this->id; |
| 794 | 808 | $sql .= " AND r.perms IS NOT NULL"; |
| 795 | - if ($moduletag) |
|
| 796 | - $sql .= " AND r.module = '" . $this->db->escape($moduletag) . "'"; |
|
| 809 | + if ($moduletag) { |
|
| 810 | + $sql .= " AND r.module = '" . $this->db->escape($moduletag) . "'"; |
|
| 811 | + } |
|
| 797 | 812 | |
| 798 | 813 | $resql = $this->db->query($sql); |
| 799 | 814 | if ($resql) {
|
@@ -807,23 +822,29 @@ discard block |
||
| 807 | 822 | $subperms = $obj->subperms; |
| 808 | 823 | |
| 809 | 824 | if ($perms) {
|
| 810 | - if (!isset($this->rights) || !is_object($this->rights)) |
|
| 811 | - $this->rights = new stdClass(); // For avoid error |
|
| 812 | - if (!isset($this->rights->$module) || !is_object($this->rights->$module)) |
|
| 813 | - $this->rights->$module = new stdClass(); |
|
| 825 | + if (!isset($this->rights) || !is_object($this->rights)) { |
|
| 826 | + $this->rights = new stdClass(); |
|
| 827 | + } |
|
| 828 | + // For avoid error |
|
| 829 | + if (!isset($this->rights->$module) || !is_object($this->rights->$module)) { |
|
| 830 | + $this->rights->$module = new stdClass(); |
|
| 831 | + } |
|
| 814 | 832 | if ($subperms) {
|
| 815 | - if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) |
|
| 816 | - $this->rights->$module->$perms = new stdClass(); |
|
| 817 | - if (empty($this->rights->$module->$perms->$subperms)) |
|
| 818 | - $this->nb_rights++; |
|
| 833 | + if (!isset($this->rights->$module->$perms) || !is_object($this->rights->$module->$perms)) { |
|
| 834 | + $this->rights->$module->$perms = new stdClass(); |
|
| 835 | + } |
|
| 836 | + if (empty($this->rights->$module->$perms->$subperms)) { |
|
| 837 | + $this->nb_rights++; |
|
| 838 | + } |
|
| 819 | 839 | $this->rights->$module->$perms->$subperms = 1; |
| 820 | - } |
|
| 821 | - else {
|
|
| 822 | - if (empty($this->rights->$module->$perms)) |
|
| 823 | - $this->nb_rights++; |
|
| 840 | + } else {
|
|
| 841 | + if (empty($this->rights->$module->$perms)) { |
|
| 842 | + $this->nb_rights++; |
|
| 843 | + } |
|
| 824 | 844 | // if we have already define a subperm like this $this->rights->$module->level1->level2 with llx_user_rights, we don't want override level1 because the level2 can be not define on user group |
| 825 | - if (!is_object($this->rights->$module->$perms)) |
|
| 826 | - $this->rights->$module->$perms = 1; |
|
| 845 | + if (!is_object($this->rights->$module->$perms)) { |
|
| 846 | + $this->rights->$module->$perms = 1; |
|
| 847 | + } |
|
| 827 | 848 | } |
| 828 | 849 | } |
| 829 | 850 | $i++; |
@@ -832,10 +853,12 @@ discard block |
||
| 832 | 853 | } |
| 833 | 854 | |
| 834 | 855 | // For backward compatibility |
| 835 | - if (isset($this->rights->propale) && !isset($this->rights->propal)) |
|
| 836 | - $this->rights->propal = $this->rights->propale; |
|
| 837 | - if (isset($this->rights->propal) && !isset($this->rights->propale)) |
|
| 838 | - $this->rights->propale = $this->rights->propal; |
|
| 856 | + if (isset($this->rights->propale) && !isset($this->rights->propal)) { |
|
| 857 | + $this->rights->propal = $this->rights->propale; |
|
| 858 | + } |
|
| 859 | + if (isset($this->rights->propal) && !isset($this->rights->propale)) { |
|
| 860 | + $this->rights->propale = $this->rights->propal; |
|
| 861 | + } |
|
| 839 | 862 | |
| 840 | 863 | if (!$moduletag) {
|
| 841 | 864 | // Si module etait non defini, alors on a tout charge, on peut donc considerer |
@@ -860,10 +883,11 @@ discard block |
||
| 860 | 883 | $error = 0; |
| 861 | 884 | |
| 862 | 885 | // Check parameters |
| 863 | - if ($this->statut == $statut) |
|
| 864 | - return 0; |
|
| 865 | - else |
|
| 866 | - $this->statut = $statut; |
|
| 886 | + if ($this->statut == $statut) { |
|
| 887 | + return 0; |
|
| 888 | + } else { |
|
| 889 | + $this->statut = $statut; |
|
| 890 | + } |
|
| 867 | 891 | |
| 868 | 892 | $this->db->begin(); |
| 869 | 893 | |
@@ -1030,8 +1054,10 @@ discard block |
||
| 1030 | 1054 | |
| 1031 | 1055 | // Clean parameters |
| 1032 | 1056 | $this->login = trim($this->login); |
| 1033 | - if (!isset($this->entity)) |
|
| 1034 | - $this->entity = $conf->entity; // If not defined, we use default value |
|
| 1057 | + if (!isset($this->entity)) { |
|
| 1058 | + $this->entity = $conf->entity; |
|
| 1059 | + } |
|
| 1060 | + // If not defined, we use default value |
|
| 1035 | 1061 | |
| 1036 | 1062 | dol_syslog(get_class($this) . "::create login=" . $this->login . ", user=" . (is_object($user) ? $user->id : ''), LOG_DEBUG); |
| 1037 | 1063 | |
@@ -1167,8 +1193,9 @@ discard block |
||
| 1167 | 1193 | $this->country_id = $contact->country_id; |
| 1168 | 1194 | $this->employee = 0; |
| 1169 | 1195 | |
| 1170 | - if (empty($login)) |
|
| 1171 | - $login = strtolower(substr($contact->firstname, 0, 4)) . strtolower(substr($contact->lastname, 0, 4)); |
|
| 1196 | + if (empty($login)) { |
|
| 1197 | + $login = strtolower(substr($contact->firstname, 0, 4)) . strtolower(substr($contact->lastname, 0, 4)); |
|
| 1198 | + } |
|
| 1172 | 1199 | $this->login = $login; |
| 1173 | 1200 | |
| 1174 | 1201 | $this->db->begin(); |
@@ -1178,8 +1205,9 @@ discard block |
||
| 1178 | 1205 | if ($result > 0) {
|
| 1179 | 1206 | $sql = "UPDATE " . MAIN_DB_PREFIX . "user"; |
| 1180 | 1207 | $sql .= " SET fk_socpeople=" . $contact->id; |
| 1181 | - if ($contact->socid) |
|
| 1182 | - $sql .= ", fk_soc=" . $contact->socid; |
|
| 1208 | + if ($contact->socid) { |
|
| 1209 | + $sql .= ", fk_soc=" . $contact->socid; |
|
| 1210 | + } |
|
| 1183 | 1211 | $sql .= " WHERE rowid=" . $this->id; |
| 1184 | 1212 | $resql = $this->db->query($sql); |
| 1185 | 1213 | |
@@ -1240,8 +1268,9 @@ discard block |
||
| 1240 | 1268 | $this->state_id = $member->state_id; |
| 1241 | 1269 | $this->country_id = $member->country_id; |
| 1242 | 1270 | |
| 1243 | - if (empty($login)) |
|
| 1244 | - $login = strtolower(substr($member->firstname, 0, 4)) . strtolower(substr($member->lastname, 0, 4)); |
|
| 1271 | + if (empty($login)) { |
|
| 1272 | + $login = strtolower(substr($member->firstname, 0, 4)) . strtolower(substr($member->lastname, 0, 4)); |
|
| 1273 | + } |
|
| 1245 | 1274 | $this->login = $login; |
| 1246 | 1275 | |
| 1247 | 1276 | $this->db->begin(); |
@@ -1250,8 +1279,9 @@ discard block |
||
| 1250 | 1279 | $result = $this->create($user); |
| 1251 | 1280 | if ($result > 0) {
|
| 1252 | 1281 | $newpass = $this->setPassword($user, $this->pass); |
| 1253 | - if (is_numeric($newpass) && $newpass < 0) |
|
| 1254 | - $result = -2; |
|
| 1282 | + if (is_numeric($newpass) && $newpass < 0) { |
|
| 1283 | + $result = -2; |
|
| 1284 | + } |
|
| 1255 | 1285 | |
| 1256 | 1286 | if ($result > 0 && $member->fk_soc) { // If member is linked to a thirdparty
|
| 1257 | 1287 | $sql = "UPDATE " . MAIN_DB_PREFIX . "user"; |
@@ -1317,8 +1347,9 @@ discard block |
||
| 1317 | 1347 | |
| 1318 | 1348 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "user_rights (fk_user, fk_id) VALUES ($this->id, $rd[$i])"; |
| 1319 | 1349 | $result = $this->db->query($sql); |
| 1320 | - if (!$result) |
|
| 1321 | - return -1; |
|
| 1350 | + if (!$result) { |
|
| 1351 | + return -1; |
|
| 1352 | + } |
|
| 1322 | 1353 | $i++; |
| 1323 | 1354 | } |
| 1324 | 1355 | |
@@ -1403,8 +1434,10 @@ discard block |
||
| 1403 | 1434 | $sql .= ", api_key = " . ($this->api_key ? "'" . $this->db->escape($this->api_key) . "'" : "null"); |
| 1404 | 1435 | $sql .= ", gender = " . ($this->gender != -1 ? "'" . $this->db->escape($this->gender) . "'" : "null"); // 'man' or 'woman' |
| 1405 | 1436 | $sql .= ", birth=" . (strval($this->birth) != '' ? "'" . $this->db->idate($this->birth) . "'" : 'null'); |
| 1406 | - if (!empty($user->admin)) |
|
| 1407 | - $sql .= ", admin = " . $this->admin; // admin flag can be set/unset only by an admin user |
|
| 1437 | + if (!empty($user->admin)) { |
|
| 1438 | + $sql .= ", admin = " . $this->admin; |
|
| 1439 | + } |
|
| 1440 | + // admin flag can be set/unset only by an admin user |
|
| 1408 | 1441 | $sql .= ", address = '" . $this->db->escape($this->address) . "'"; |
| 1409 | 1442 | $sql .= ", zip = '" . $this->db->escape($this->zip) . "'"; |
| 1410 | 1443 | $sql .= ", town = '" . $this->db->escape($this->town) . "'"; |
@@ -1427,14 +1460,18 @@ discard block |
||
| 1427 | 1460 | $sql .= ", photo = " . ($this->photo ? "'" . $this->db->escape($this->photo) . "'" : "null"); |
| 1428 | 1461 | $sql .= ", openid = " . ($this->openid ? "'" . $this->db->escape($this->openid) . "'" : "null"); |
| 1429 | 1462 | $sql .= ", fk_user = " . ($this->fk_user > 0 ? "'" . $this->db->escape($this->fk_user) . "'" : "null"); |
| 1430 | - if (isset($this->thm) || $this->thm != '') |
|
| 1431 | - $sql .= ", thm= " . ($this->thm != '' ? "'" . $this->db->escape($this->thm) . "'" : "null"); |
|
| 1432 | - if (isset($this->tjm) || $this->tjm != '') |
|
| 1433 | - $sql .= ", tjm= " . ($this->tjm != '' ? "'" . $this->db->escape($this->tjm) . "'" : "null"); |
|
| 1434 | - if (isset($this->salary) || $this->salary != '') |
|
| 1435 | - $sql .= ", salary= " . ($this->salary != '' ? "'" . $this->db->escape($this->salary) . "'" : "null"); |
|
| 1436 | - if (isset($this->salaryextra) || $this->salaryextra != '') |
|
| 1437 | - $sql .= ", salaryextra= " . ($this->salaryextra != '' ? "'" . $this->db->escape($this->salaryextra) . "'" : "null"); |
|
| 1463 | + if (isset($this->thm) || $this->thm != '') { |
|
| 1464 | + $sql .= ", thm= " . ($this->thm != '' ? "'" . $this->db->escape($this->thm) . "'" : "null"); |
|
| 1465 | + } |
|
| 1466 | + if (isset($this->tjm) || $this->tjm != '') { |
|
| 1467 | + $sql .= ", tjm= " . ($this->tjm != '' ? "'" . $this->db->escape($this->tjm) . "'" : "null"); |
|
| 1468 | + } |
|
| 1469 | + if (isset($this->salary) || $this->salary != '') { |
|
| 1470 | + $sql .= ", salary= " . ($this->salary != '' ? "'" . $this->db->escape($this->salary) . "'" : "null"); |
|
| 1471 | + } |
|
| 1472 | + if (isset($this->salaryextra) || $this->salaryextra != '') { |
|
| 1473 | + $sql .= ", salaryextra= " . ($this->salaryextra != '' ? "'" . $this->db->escape($this->salaryextra) . "'" : "null"); |
|
| 1474 | + } |
|
| 1438 | 1475 | $sql .= ", weeklyhours= " . ($this->weeklyhours != '' ? "'" . $this->db->escape($this->weeklyhours) . "'" : "null"); |
| 1439 | 1476 | $sql .= ", entity = '" . $this->db->escape($this->entity) . "'"; |
| 1440 | 1477 | $sql .= ", default_range = " . ($this->default_range > 0 ? $this->default_range : 'null'); |
@@ -1452,8 +1489,9 @@ discard block |
||
| 1452 | 1489 | if ($this->pass != $this->pass_indatabase && $this->pass != $this->pass_indatabase_crypted) {
|
| 1453 | 1490 | // Si mot de passe saisi et different de celui en base |
| 1454 | 1491 | $result = $this->setPassword($user, $this->pass, 0, $notrigger, $nosyncmemberpass); |
| 1455 | - if (!$nbrowsaffected) |
|
| 1456 | - $nbrowsaffected++; |
|
| 1492 | + if (!$nbrowsaffected) { |
|
| 1493 | + $nbrowsaffected++; |
|
| 1494 | + } |
|
| 1457 | 1495 | } |
| 1458 | 1496 | } |
| 1459 | 1497 | |
@@ -1679,8 +1717,9 @@ discard block |
||
| 1679 | 1717 | |
| 1680 | 1718 | // Mise a jour |
| 1681 | 1719 | if (!$changelater) {
|
| 1682 | - if (!is_object($this->oldcopy)) |
|
| 1683 | - $this->oldcopy = clone $this; |
|
| 1720 | + if (!is_object($this->oldcopy)) { |
|
| 1721 | + $this->oldcopy = clone $this; |
|
| 1722 | + } |
|
| 1684 | 1723 | |
| 1685 | 1724 | $this->db->begin(); |
| 1686 | 1725 | |
@@ -1798,8 +1837,9 @@ discard block |
||
| 1798 | 1837 | $outputlangs->loadLangs(array("main", "errors", "users", "other"));
|
| 1799 | 1838 | |
| 1800 | 1839 | $appli = constant('DOL_APPLICATION_TITLE');
|
| 1801 | - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) |
|
| 1802 | - $appli = $conf->global->MAIN_APPLICATION_TITLE; |
|
| 1840 | + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { |
|
| 1841 | + $appli = $conf->global->MAIN_APPLICATION_TITLE; |
|
| 1842 | + } |
|
| 1803 | 1843 | |
| 1804 | 1844 | $subject = $outputlangs->transnoentitiesnoconv("SubjectNewPassword", $appli);
|
| 1805 | 1845 | |
@@ -2127,8 +2167,9 @@ discard block |
||
| 2127 | 2167 | $label .= '<br>'; |
| 2128 | 2168 | $label .= '<br><u>' . $langs->trans("Connection") . '</u>';
|
| 2129 | 2169 | $label .= '<br><b>' . $langs->trans("IPAddress") . '</b>: ' . $_SERVER["REMOTE_ADDR"];
|
| 2130 | - if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) |
|
| 2131 | - $label .= '<br><b>' . $langs->trans("ConnectedOnMultiCompany") . ':</b> ' . $conf->entity . ' (user entity ' . $this->entity . ')';
|
|
| 2170 | + if (!empty($conf->global->MAIN_MODULE_MULTICOMPANY)) { |
|
| 2171 | + $label .= '<br><b>' . $langs->trans("ConnectedOnMultiCompany") . ':</b> ' . $conf->entity . ' (user entity ' . $this->entity . ')'; |
|
| 2172 | + } |
|
| 2132 | 2173 | $label .= '<br><b>' . $langs->trans("AuthenticationMode") . ':</b> ' . $_SESSION["dol_authmode"] . (empty($dolibarr_main_demo) ? '' : ' (demo)');
|
| 2133 | 2174 | $label .= '<br><b>' . $langs->trans("ConnectedSince") . ':</b> ' . dol_print_date($this->datelastlogin, "dayhour", 'tzuser');
|
| 2134 | 2175 | $label .= '<br><b>' . $langs->trans("PreviousConnexion") . ':</b> ' . dol_print_date($this->datepreviouslogin, "dayhour", 'tzuser');
|
@@ -2139,13 +2180,16 @@ discard block |
||
| 2139 | 2180 | $label .= '<br><b>' . $langs->trans("Browser") . ':</b> ' . $conf->browser->name . ($conf->browser->version ? ' ' . $conf->browser->version : '') . ' (' . $_SERVER['HTTP_USER_AGENT'] . ')';
|
| 2140 | 2181 | $label .= '<br><b>' . $langs->trans("Layout") . ':</b> ' . $conf->browser->layout;
|
| 2141 | 2182 | $label .= '<br><b>' . $langs->trans("Screen") . ':</b> ' . $_SESSION['dol_screenwidth'] . ' x ' . $_SESSION['dol_screenheight'];
|
| 2142 | - if ($conf->browser->layout == 'phone') |
|
| 2143 | - $label .= '<br><b>' . $langs->trans("Phone") . ':</b> ' . $langs->trans("Yes");
|
|
| 2144 | - if (!empty($_SESSION["disablemodules"])) |
|
| 2145 | - $label .= '<br><b>' . $langs->trans("DisabledModules") . ':</b> <br>' . join(', ', explode(',', $_SESSION["disablemodules"]));
|
|
| 2183 | + if ($conf->browser->layout == 'phone') { |
|
| 2184 | + $label .= '<br><b>' . $langs->trans("Phone") . ':</b> ' . $langs->trans("Yes"); |
|
| 2185 | + } |
|
| 2186 | + if (!empty($_SESSION["disablemodules"])) { |
|
| 2187 | + $label .= '<br><b>' . $langs->trans("DisabledModules") . ':</b> <br>' . join(', ', explode(',', $_SESSION["disablemodules"])); |
|
| 2188 | + } |
|
| 2146 | 2189 | } |
| 2147 | - if ($infologin < 0) |
|
| 2148 | - $label = ''; |
|
| 2190 | + if ($infologin < 0) { |
|
| 2191 | + $label = ''; |
|
| 2192 | + } |
|
| 2149 | 2193 | |
| 2150 | 2194 | // $url = DOL_URL_ROOT . '/user/card.php?id=' . $this->id; |
| 2151 | 2195 | $url = BASE_URI . '?controller=user&method=card&id=' . $this->id; |
@@ -2156,10 +2200,12 @@ discard block |
||
| 2156 | 2200 | if ($option != 'nolink') {
|
| 2157 | 2201 | // Add param to save lastsearch_values or not |
| 2158 | 2202 | $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
| 2159 | - if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"]))
|
|
| 2160 | - $add_save_lastsearch_values = 1; |
|
| 2161 | - if ($add_save_lastsearch_values) |
|
| 2162 | - $url .= '&save_lastsearch_values=1'; |
|
| 2203 | + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { |
|
| 2204 | + $add_save_lastsearch_values = 1; |
|
| 2205 | + } |
|
| 2206 | + if ($add_save_lastsearch_values) { |
|
| 2207 | + $url .= '&save_lastsearch_values=1'; |
|
| 2208 | + } |
|
| 2163 | 2209 | } |
| 2164 | 2210 | |
| 2165 | 2211 | $linkstart = '<a href="' . $url . '"'; |
@@ -2188,25 +2234,31 @@ discard block |
||
| 2188 | 2234 | $result .= (($option == 'nolink') ? '' : $linkstart); |
| 2189 | 2235 | if ($withpictoimg) {
|
| 2190 | 2236 | $paddafterimage = ''; |
| 2191 | - if (abs($withpictoimg) == 1) |
|
| 2192 | - $paddafterimage = 'style="margin-right: 3px;"'; |
|
| 2237 | + if (abs($withpictoimg) == 1) { |
|
| 2238 | + $paddafterimage = 'style="margin-right: 3px;"'; |
|
| 2239 | + } |
|
| 2193 | 2240 | // Only picto |
| 2194 | - if ($withpictoimg > 0) |
|
| 2195 | - $picto = '<!-- picto user --><div class="inline-block nopadding userimg' . ($morecss ? ' ' . $morecss : '') . '">' . img_object('', 'user', $paddafterimage . ' ' . ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1) . '</div>';
|
|
| 2241 | + if ($withpictoimg > 0) { |
|
| 2242 | + $picto = '<!-- picto user --><div class="inline-block nopadding userimg' . ($morecss ? ' ' . $morecss : '') . '">' . img_object('', 'user', $paddafterimage . ' ' . ($notooltip ? '' : 'class="classfortooltip"'), 0, 0, $notooltip ? 0 : 1) . '</div>'; |
|
| 2243 | + } |
|
| 2196 | 2244 | // Picto must be a photo |
| 2197 | - else |
|
| 2198 | - $picto = '<!-- picto photo user --><div class="inline-block nopadding userimg' . ($morecss ? ' ' . $morecss : '') . '"' . ($paddafterimage ? ' ' . $paddafterimage : '') . '>' . Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto' . ($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1) . '</div>';
|
|
| 2245 | + else { |
|
| 2246 | + $picto = '<!-- picto photo user --><div class="inline-block nopadding userimg' . ($morecss ? ' ' . $morecss : '') . '"' . ($paddafterimage ? ' ' . $paddafterimage : '') . '>' . Form::showphoto('userphoto', $this, 0, 0, 0, 'userphoto' . ($withpictoimg == -3 ? 'small' : ''), 'mini', 0, 1) . '</div>'; |
|
| 2247 | + } |
|
| 2199 | 2248 | $result .= $picto; |
| 2200 | 2249 | } |
| 2201 | 2250 | if ($withpictoimg > -2 && $withpictoimg != 2) {
|
| 2202 | - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 2203 | - $result .= '<div class="inline-block nopadding valignmiddle usertext' . ((!isset($this->statut) || $this->statut) ? '' : ' strikefordisabled') . ($morecss ? ' ' . $morecss : '') . '">'; |
|
| 2204 | - if ($mode == 'login') |
|
| 2205 | - $result .= dol_trunc($this->login, $maxlen); |
|
| 2206 | - else |
|
| 2207 | - $result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : -1), $maxlen); |
|
| 2208 | - if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) |
|
| 2209 | - $result .= '</div>'; |
|
| 2251 | + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
|
| 2252 | + $result .= '<div class="inline-block nopadding valignmiddle usertext' . ((!isset($this->statut) || $this->statut) ? '' : ' strikefordisabled') . ($morecss ? ' ' . $morecss : '') . '">'; |
|
| 2253 | + } |
|
| 2254 | + if ($mode == 'login') { |
|
| 2255 | + $result .= dol_trunc($this->login, $maxlen); |
|
| 2256 | + } else { |
|
| 2257 | + $result .= $this->getFullName($langs, '', ($mode == 'firstname' ? 2 : -1), $maxlen); |
|
| 2258 | + } |
|
| 2259 | + if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { |
|
| 2260 | + $result .= '</div>'; |
|
| 2261 | + } |
|
| 2210 | 2262 | } |
| 2211 | 2263 | $result .= (($option == 'nolink') ? '' : $linkend); |
| 2212 | 2264 | //if ($withpictoimg == -1) $result.='</div>'; |
@@ -2244,8 +2296,9 @@ discard block |
||
| 2244 | 2296 | $linkend = '</a>'; |
| 2245 | 2297 | |
| 2246 | 2298 | //Check user's rights to see an other user |
| 2247 | - if ((!$user->rights->user->user->lire && $this->id != $user->id)) |
|
| 2248 | - $option = 'nolink'; |
|
| 2299 | + if ((!$user->rights->user->user->lire && $this->id != $user->id)) { |
|
| 2300 | + $option = 'nolink'; |
|
| 2301 | + } |
|
| 2249 | 2302 | |
| 2250 | 2303 | if ($option == 'xxx') {
|
| 2251 | 2304 | //$linkstart = '<a href="'.DOL_URL_ROOT.'/user/card.php?id='.$this->id.'">'; |
@@ -2259,8 +2312,9 @@ discard block |
||
| 2259 | 2312 | } |
| 2260 | 2313 | |
| 2261 | 2314 | $result .= $linkstart; |
| 2262 | - if ($withpicto) |
|
| 2263 | - $result .= img_object($langs->trans("ShowUser"), 'user', 'class="paddingright"');
|
|
| 2315 | + if ($withpicto) { |
|
| 2316 | + $result .= img_object($langs->trans("ShowUser"), 'user', 'class="paddingright"'); |
|
| 2317 | + } |
|
| 2264 | 2318 | $result .= $this->login; |
| 2265 | 2319 | $result .= $linkend; |
| 2266 | 2320 | return $result; |
@@ -2292,40 +2346,41 @@ discard block |
||
| 2292 | 2346 | $langs->load('users');
|
| 2293 | 2347 | |
| 2294 | 2348 | if ($mode == 0) {
|
| 2295 | - if ($statut == 1) |
|
| 2296 | - return $langs->trans('Enabled');
|
|
| 2297 | - elseif ($statut == 0) |
|
| 2298 | - return $langs->trans('Disabled');
|
|
| 2299 | - } |
|
| 2300 | - elseif ($mode == 1) {
|
|
| 2301 | - if ($statut == 1) |
|
| 2302 | - return $langs->trans('Enabled');
|
|
| 2303 | - elseif ($statut == 0) |
|
| 2304 | - return $langs->trans('Disabled');
|
|
| 2305 | - } |
|
| 2306 | - elseif ($mode == 2) {
|
|
| 2307 | - if ($statut == 1) |
|
| 2308 | - return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"') . ' ' . $langs->trans('Enabled');
|
|
| 2309 | - elseif ($statut == 0) |
|
| 2310 | - return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"') . ' ' . $langs->trans('Disabled');
|
|
| 2311 | - } |
|
| 2312 | - elseif ($mode == 3) {
|
|
| 2313 | - if ($statut == 1) |
|
| 2314 | - return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"');
|
|
| 2315 | - elseif ($statut == 0) |
|
| 2316 | - return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"');
|
|
| 2317 | - } |
|
| 2318 | - elseif ($mode == 4) {
|
|
| 2319 | - if ($statut == 1) |
|
| 2320 | - return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"') . ' ' . $langs->trans('Enabled');
|
|
| 2321 | - elseif ($statut == 0) |
|
| 2322 | - return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"') . ' ' . $langs->trans('Disabled');
|
|
| 2323 | - } |
|
| 2324 | - elseif ($mode == 5) {
|
|
| 2325 | - if ($statut == 1) |
|
| 2326 | - return $langs->trans('Enabled') . ' ' . img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"');
|
|
| 2327 | - elseif ($statut == 0) |
|
| 2328 | - return $langs->trans('Disabled') . ' ' . img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"');
|
|
| 2349 | + if ($statut == 1) { |
|
| 2350 | + return $langs->trans('Enabled'); |
|
| 2351 | + } elseif ($statut == 0) { |
|
| 2352 | + return $langs->trans('Disabled'); |
|
| 2353 | + } |
|
| 2354 | + } elseif ($mode == 1) {
|
|
| 2355 | + if ($statut == 1) { |
|
| 2356 | + return $langs->trans('Enabled'); |
|
| 2357 | + } elseif ($statut == 0) { |
|
| 2358 | + return $langs->trans('Disabled'); |
|
| 2359 | + } |
|
| 2360 | + } elseif ($mode == 2) {
|
|
| 2361 | + if ($statut == 1) { |
|
| 2362 | + return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"') . ' ' . $langs->trans('Enabled'); |
|
| 2363 | + } elseif ($statut == 0) { |
|
| 2364 | + return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"') . ' ' . $langs->trans('Disabled'); |
|
| 2365 | + } |
|
| 2366 | + } elseif ($mode == 3) {
|
|
| 2367 | + if ($statut == 1) { |
|
| 2368 | + return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"'); |
|
| 2369 | + } elseif ($statut == 0) { |
|
| 2370 | + return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"'); |
|
| 2371 | + } |
|
| 2372 | + } elseif ($mode == 4) {
|
|
| 2373 | + if ($statut == 1) { |
|
| 2374 | + return img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"') . ' ' . $langs->trans('Enabled'); |
|
| 2375 | + } elseif ($statut == 0) { |
|
| 2376 | + return img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"') . ' ' . $langs->trans('Disabled'); |
|
| 2377 | + } |
|
| 2378 | + } elseif ($mode == 5) {
|
|
| 2379 | + if ($statut == 1) { |
|
| 2380 | + return $langs->trans('Enabled') . ' ' . img_picto($langs->trans('Enabled'), 'statut4', 'class="pictostatus"'); |
|
| 2381 | + } elseif ($statut == 0) { |
|
| 2382 | + return $langs->trans('Disabled') . ' ' . img_picto($langs->trans('Disabled'), 'statut5', 'class="pictostatus"'); |
|
| 2383 | + } |
|
| 2329 | 2384 | } |
| 2330 | 2385 | } |
| 2331 | 2386 | |
@@ -2344,12 +2399,13 @@ discard block |
||
| 2344 | 2399 | // phpcs:enable |
| 2345 | 2400 | global $conf; |
| 2346 | 2401 | $dn = ''; |
| 2347 | - if ($mode == 0) |
|
| 2348 | - $dn = $conf->global->LDAP_KEY_USERS . "=" . $info[$conf->global->LDAP_KEY_USERS] . "," . $conf->global->LDAP_USER_DN; |
|
| 2349 | - elseif ($mode == 1) |
|
| 2350 | - $dn = $conf->global->LDAP_USER_DN; |
|
| 2351 | - elseif ($mode == 2) |
|
| 2352 | - $dn = $conf->global->LDAP_KEY_USERS . "=" . $info[$conf->global->LDAP_KEY_USERS]; |
|
| 2402 | + if ($mode == 0) { |
|
| 2403 | + $dn = $conf->global->LDAP_KEY_USERS . "=" . $info[$conf->global->LDAP_KEY_USERS] . "," . $conf->global->LDAP_USER_DN; |
|
| 2404 | + } elseif ($mode == 1) { |
|
| 2405 | + $dn = $conf->global->LDAP_USER_DN; |
|
| 2406 | + } elseif ($mode == 2) { |
|
| 2407 | + $dn = $conf->global->LDAP_KEY_USERS . "=" . $info[$conf->global->LDAP_KEY_USERS]; |
|
| 2408 | + } |
|
| 2353 | 2409 | return $dn; |
| 2354 | 2410 | } |
| 2355 | 2411 | |
@@ -2396,38 +2452,51 @@ discard block |
||
| 2396 | 2452 | |
| 2397 | 2453 | // Check if it is the LDAP key and if its value has been changed |
| 2398 | 2454 | if (!empty($conf->global->LDAP_KEY_USERS) && $conf->global->LDAP_KEY_USERS == $conf->global->$constname) {
|
| 2399 | - if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) |
|
| 2400 | - $keymodified = true; // For check if LDAP key has been modified |
|
| 2455 | + if (!empty($this->oldcopy) && $this->$varname != $this->oldcopy->$varname) { |
|
| 2456 | + $keymodified = true; |
|
| 2457 | + } |
|
| 2458 | + // For check if LDAP key has been modified |
|
| 2401 | 2459 | } |
| 2402 | 2460 | } |
| 2403 | 2461 | } |
| 2404 | - if ($this->address && !empty($conf->global->LDAP_FIELD_ADDRESS)) |
|
| 2405 | - $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address; |
|
| 2406 | - if ($this->zip && !empty($conf->global->LDAP_FIELD_ZIP)) |
|
| 2407 | - $info[$conf->global->LDAP_FIELD_ZIP] = $this->zip; |
|
| 2408 | - if ($this->town && !empty($conf->global->LDAP_FIELD_TOWN)) |
|
| 2409 | - $info[$conf->global->LDAP_FIELD_TOWN] = $this->town; |
|
| 2410 | - if ($this->note_public && !empty($conf->global->LDAP_FIELD_DESCRIPTION)) |
|
| 2411 | - $info[$conf->global->LDAP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_public, 2); |
|
| 2462 | + if ($this->address && !empty($conf->global->LDAP_FIELD_ADDRESS)) { |
|
| 2463 | + $info[$conf->global->LDAP_FIELD_ADDRESS] = $this->address; |
|
| 2464 | + } |
|
| 2465 | + if ($this->zip && !empty($conf->global->LDAP_FIELD_ZIP)) { |
|
| 2466 | + $info[$conf->global->LDAP_FIELD_ZIP] = $this->zip; |
|
| 2467 | + } |
|
| 2468 | + if ($this->town && !empty($conf->global->LDAP_FIELD_TOWN)) { |
|
| 2469 | + $info[$conf->global->LDAP_FIELD_TOWN] = $this->town; |
|
| 2470 | + } |
|
| 2471 | + if ($this->note_public && !empty($conf->global->LDAP_FIELD_DESCRIPTION)) { |
|
| 2472 | + $info[$conf->global->LDAP_FIELD_DESCRIPTION] = dol_string_nohtmltag($this->note_public, 2); |
|
| 2473 | + } |
|
| 2412 | 2474 | if ($this->socid > 0) {
|
| 2413 | 2475 | $soc = new Societe($this->db); |
| 2414 | 2476 | $soc->fetch($this->socid); |
| 2415 | 2477 | |
| 2416 | 2478 | $info[$conf->global->LDAP_FIELD_COMPANY] = $soc->name; |
| 2417 | - if ($soc->client == 1) |
|
| 2418 | - $info["businessCategory"] = "Customers"; |
|
| 2419 | - if ($soc->client == 2) |
|
| 2420 | - $info["businessCategory"] = "Prospects"; |
|
| 2421 | - if ($soc->fournisseur == 1) |
|
| 2422 | - $info["businessCategory"] = "Suppliers"; |
|
| 2479 | + if ($soc->client == 1) { |
|
| 2480 | + $info["businessCategory"] = "Customers"; |
|
| 2481 | + } |
|
| 2482 | + if ($soc->client == 2) { |
|
| 2483 | + $info["businessCategory"] = "Prospects"; |
|
| 2484 | + } |
|
| 2485 | + if ($soc->fournisseur == 1) { |
|
| 2486 | + $info["businessCategory"] = "Suppliers"; |
|
| 2487 | + } |
|
| 2423 | 2488 | } |
| 2424 | 2489 | |
| 2425 | 2490 | // When password is modified |
| 2426 | 2491 | if (!empty($this->pass)) {
|
| 2427 | - if (!empty($conf->global->LDAP_FIELD_PASSWORD)) |
|
| 2428 | - $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass; // this->pass = mot de passe non crypte |
|
| 2429 | - if (!empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) |
|
| 2430 | - $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); // Create OpenLDAP MD5 password (TODO add type of encryption) |
|
| 2492 | + if (!empty($conf->global->LDAP_FIELD_PASSWORD)) { |
|
| 2493 | + $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass; |
|
| 2494 | + } |
|
| 2495 | + // this->pass = mot de passe non crypte |
|
| 2496 | + if (!empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) { |
|
| 2497 | + $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass, 4); |
|
| 2498 | + } |
|
| 2499 | + // Create OpenLDAP MD5 password (TODO add type of encryption) |
|
| 2431 | 2500 | } |
| 2432 | 2501 | // Set LDAP password if possible |
| 2433 | 2502 | elseif ($conf->global->LDAP_SERVER_PROTOCOLVERSION !== '3') { // If ldap key is modified and LDAPv3 we use ldap_rename function for avoid lose encrypt password
|
@@ -2441,10 +2510,14 @@ discard block |
||
| 2441 | 2510 | } |
| 2442 | 2511 | // Use $this->pass_indatabase value if exists |
| 2443 | 2512 | elseif (!empty($this->pass_indatabase)) {
|
| 2444 | - if (!empty($conf->global->LDAP_FIELD_PASSWORD)) |
|
| 2445 | - $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass_indatabase; // $this->pass_indatabase = mot de passe non crypte |
|
| 2446 | - if (!empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) |
|
| 2447 | - $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); // md5 for OpenLdap TODO add type of encryption |
|
| 2513 | + if (!empty($conf->global->LDAP_FIELD_PASSWORD)) { |
|
| 2514 | + $info[$conf->global->LDAP_FIELD_PASSWORD] = $this->pass_indatabase; |
|
| 2515 | + } |
|
| 2516 | + // $this->pass_indatabase = mot de passe non crypte |
|
| 2517 | + if (!empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) { |
|
| 2518 | + $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dol_hash($this->pass_indatabase, 4); |
|
| 2519 | + } |
|
| 2520 | + // md5 for OpenLdap TODO add type of encryption |
|
| 2448 | 2521 | } |
| 2449 | 2522 | } |
| 2450 | 2523 | |
@@ -2467,10 +2540,12 @@ discard block |
||
| 2467 | 2540 | |
| 2468 | 2541 | $info["phpgwContactOwner"] = $this->egroupware_id; |
| 2469 | 2542 | |
| 2470 | - if ($this->email) |
|
| 2471 | - $info["rfc822Mailbox"] = $this->email; |
|
| 2472 | - if ($this->phone_mobile) |
|
| 2473 | - $info["phpgwCellTelephoneNumber"] = $this->phone_mobile; |
|
| 2543 | + if ($this->email) { |
|
| 2544 | + $info["rfc822Mailbox"] = $this->email; |
|
| 2545 | + } |
|
| 2546 | + if ($this->phone_mobile) { |
|
| 2547 | + $info["phpgwCellTelephoneNumber"] = $this->phone_mobile; |
|
| 2548 | + } |
|
| 2474 | 2549 | } |
| 2475 | 2550 | |
| 2476 | 2551 | return $info; |
@@ -2595,15 +2670,17 @@ discard block |
||
| 2595 | 2670 | $sql .= " FROM " . MAIN_DB_PREFIX . "user"; |
| 2596 | 2671 | if ($option == 'superadmin') {
|
| 2597 | 2672 | $sql .= " WHERE entity = 0"; |
| 2598 | - if ($admin >= 0) |
|
| 2599 | - $sql .= " AND admin = " . $admin; |
|
| 2600 | - } |
|
| 2601 | - else {
|
|
| 2673 | + if ($admin >= 0) { |
|
| 2674 | + $sql .= " AND admin = " . $admin; |
|
| 2675 | + } |
|
| 2676 | + } else {
|
|
| 2602 | 2677 | $sql .= " WHERE entity IN (" . getEntity('user', 0) . ")";
|
| 2603 | - if ($limitTo == 'active') |
|
| 2604 | - $sql .= " AND statut = 1"; |
|
| 2605 | - if ($admin >= 0) |
|
| 2606 | - $sql .= " AND admin = " . $admin; |
|
| 2678 | + if ($limitTo == 'active') { |
|
| 2679 | + $sql .= " AND statut = 1"; |
|
| 2680 | + } |
|
| 2681 | + if ($admin >= 0) { |
|
| 2682 | + $sql .= " AND admin = " . $admin; |
|
| 2683 | + } |
|
| 2607 | 2684 | } |
| 2608 | 2685 | |
| 2609 | 2686 | $resql = $this->db->query($sql); |
@@ -2756,8 +2833,9 @@ discard block |
||
| 2756 | 2833 | } else {
|
| 2757 | 2834 | $sql .= " WHERE u.entity IN (" . getEntity('user') . ")";
|
| 2758 | 2835 | } |
| 2759 | - if ($filter) |
|
| 2760 | - $sql .= " AND " . $filter; |
|
| 2836 | + if ($filter) { |
|
| 2837 | + $sql .= " AND " . $filter; |
|
| 2838 | + } |
|
| 2761 | 2839 | |
| 2762 | 2840 | dol_syslog(get_class($this) . "::get_full_tree get user list", LOG_DEBUG); |
| 2763 | 2841 | $resql = $this->db->query($sql); |
@@ -2839,14 +2917,16 @@ discard block |
||
| 2839 | 2917 | dol_syslog("Build childid for id = " . $idtoscan);
|
| 2840 | 2918 | foreach ($this->users as $id => $val) {
|
| 2841 | 2919 | //var_dump($val['fullpath']); |
| 2842 | - if (preg_match('/_' . $idtoscan . '_/', $val['fullpath']))
|
|
| 2843 | - $childids[$val['id']] = $val['id']; |
|
| 2920 | + if (preg_match('/_' . $idtoscan . '_/', $val['fullpath'])) { |
|
| 2921 | + $childids[$val['id']] = $val['id']; |
|
| 2922 | + } |
|
| 2844 | 2923 | } |
| 2845 | 2924 | } |
| 2846 | 2925 | $this->cache_childids[$this->id] = $childids; |
| 2847 | 2926 | |
| 2848 | - if ($addcurrentuser) |
|
| 2849 | - $childids[$this->id] = $this->id; |
|
| 2927 | + if ($addcurrentuser) { |
|
| 2928 | + $childids[$this->id] = $this->id; |
|
| 2929 | + } |
|
| 2850 | 2930 | |
| 2851 | 2931 | return $childids; |
| 2852 | 2932 | } |
@@ -2990,8 +3070,9 @@ discard block |
||
| 2990 | 3070 | // phpcs:enable |
| 2991 | 3071 | $user_property = ''; |
| 2992 | 3072 | |
| 2993 | - if (empty($rowid)) |
|
| 2994 | - return ''; |
|
| 3073 | + if (empty($rowid)) { |
|
| 3074 | + return ''; |
|
| 3075 | + } |
|
| 2995 | 3076 | |
| 2996 | 3077 | $sql = "SELECT rowid, email, user_mobile, civility, lastname, firstname"; |
| 2997 | 3078 | $sql .= " FROM " . MAIN_DB_PREFIX . "user"; |
@@ -3004,14 +3085,14 @@ discard block |
||
| 3004 | 3085 | if ($nump) {
|
| 3005 | 3086 | $obj = $this->db->fetch_object($resql); |
| 3006 | 3087 | |
| 3007 | - if ($mode == 'email') |
|
| 3008 | - $user_property = dolGetFirstLastname($obj->firstname, $obj->lastname) . " <" . $obj->email . ">"; |
|
| 3009 | - else if ($mode == 'mobile') |
|
| 3010 | - $user_property = $obj->user_mobile; |
|
| 3088 | + if ($mode == 'email') { |
|
| 3089 | + $user_property = dolGetFirstLastname($obj->firstname, $obj->lastname) . " <" . $obj->email . ">"; |
|
| 3090 | + } else if ($mode == 'mobile') { |
|
| 3091 | + $user_property = $obj->user_mobile; |
|
| 3092 | + } |
|
| 3011 | 3093 | } |
| 3012 | 3094 | return $user_property; |
| 3013 | - } |
|
| 3014 | - else {
|
|
| 3095 | + } else {
|
|
| 3015 | 3096 | dol_print_error($this->db); |
| 3016 | 3097 | } |
| 3017 | 3098 | } |
@@ -3054,8 +3135,9 @@ discard block |
||
| 3054 | 3135 | $sql .= ' AND (' . implode(' ' . $filtermode . ' ', $sqlwhere) . ')';
|
| 3055 | 3136 | } |
| 3056 | 3137 | $sql .= $this->db->order($sortfield, $sortorder); |
| 3057 | - if ($limit) |
|
| 3058 | - $sql .= $this->db->plimit($limit + 1, $offset); |
|
| 3138 | + if ($limit) { |
|
| 3139 | + $sql .= $this->db->plimit($limit + 1, $offset); |
|
| 3140 | + } |
|
| 3059 | 3141 | |
| 3060 | 3142 | dol_syslog(get_class($this) . "::" . __METHOD__, LOG_DEBUG); |
| 3061 | 3143 | |
@@ -31,8 +31,9 @@ |
||
| 31 | 31 | $langs->loadLangs(array("compta", "bills", "other", "accountancy", "loans", "banks", "admin", "dict"));
|
| 32 | 32 | |
| 33 | 33 | // Security check |
| 34 | -if ($user->societe_id > 0) |
|
| 35 | - accessforbidden(); |
|
| 34 | +if ($user->societe_id > 0) { |
|
| 35 | + accessforbidden(); |
|
| 36 | +} |
|
| 36 | 37 | |
| 37 | 38 | /* |
| 38 | 39 | * Actions |