diff --git a/htdocs/admin/accountant.php b/htdocs/admin/accountant.php index a0dbe4e9838..3ed43f1664f 100644 --- a/htdocs/admin/accountant.php +++ b/htdocs/admin/accountant.php @@ -34,7 +34,9 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adm // Load translation files required by the page $langs->loadLangs(array('admin', 'companies')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $error = 0; @@ -45,11 +47,12 @@ $error = 0; $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} if (($action == 'update' && !GETPOST("cancel", 'alpha')) -|| ($action == 'updateedit')) -{ +|| ($action == 'updateedit')) { dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'nohtml'), 'chaine', 0, '', $conf->entity); @@ -64,8 +67,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha')) dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'restricthtml'), 'chaine', 0, '', $conf->entity); - if ($action != 'updateedit' && !$error) - { + if ($action != 'updateedit' && !$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -131,7 +133,9 @@ print ''; print img_picto('', 'globe-americas', 'class="paddingrightonly"'); print $form->select_country((GETPOSTISSET('country_id') ? GETPOST('country_id', 'int') : (!empty($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY) ? $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY : '')), 'country_id'); -if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); +if ($user->admin) { + print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1); +} print ''."\n"; print ''; diff --git a/htdocs/admin/agenda.php b/htdocs/admin/agenda.php index efdd6213dd5..9829be288a5 100644 --- a/htdocs/admin/agenda.php +++ b/htdocs/admin/agenda.php @@ -28,8 +28,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'agenda')); @@ -45,12 +46,10 @@ $sql = "SELECT a.rowid, a.code, a.label, a.elementtype, a.rang as position"; $sql .= " FROM ".MAIN_DB_PREFIX."c_action_trigger as a"; $sql .= " ORDER BY a.rang ASC"; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $triggers[$i]['rowid'] = $obj->rowid; $triggers[$i]['code'] = $obj->code; @@ -73,36 +72,32 @@ if ($resql) */ // Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $search_event = ''; $action = ''; } -if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) // To avoid the save when we click on search -{ +if (GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { // To avoid the save when we click on search $action = ''; } -if ($action == "save" && empty($cancel)) -{ +if ($action == "save" && empty($cancel)) { $i = 0; $db->begin(); - foreach ($triggers as $trigger) - { + foreach ($triggers as $trigger) { $keyparam = 'MAIN_AGENDA_ACTIONAUTO_'.$trigger['code']; //print "param=".$param." - ".$_POST[$param]; - if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam)) - { + if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $keyparam)) { $res = dolibarr_set_const($db, $keyparam, (GETPOST($keyparam, 'alpha') ?GETPOST($keyparam, 'alpha') : ''), 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); $db->commit(); } else { @@ -155,17 +150,27 @@ print ''.$langs->trans("ActionsEvents").''.$langs->trans("All").'/'.$langs->trans("None").''; print ''."\n"; // Show each trigger (list is in c_action_trigger) -if (!empty($triggers)) -{ - foreach ($triggers as $trigger) - { +if (!empty($triggers)) { + foreach ($triggers as $trigger) { $module = $trigger['element']; - if ($module == 'order_supplier' || $module == 'invoice_supplier') $module = 'fournisseur'; - if ($module == 'shipping') $module = 'expedition_bon'; - if ($module == 'member') $module = 'adherent'; - if ($module == 'project') $module = 'projet'; - if ($module == 'proposal_supplier') $module = 'supplier_proposal'; - if ($module == 'contact') $module = 'societe'; + if ($module == 'order_supplier' || $module == 'invoice_supplier') { + $module = 'fournisseur'; + } + if ($module == 'shipping') { + $module = 'expedition_bon'; + } + if ($module == 'member') { + $module = 'adherent'; + } + if ($module == 'project') { + $module = 'projet'; + } + if ($module == 'proposal_supplier') { + $module = 'supplier_proposal'; + } + if ($module == 'contact') { + $module = 'societe'; + } // If 'element' value is myobject@mymodule instead of mymodule $tmparray = explode('@', $module); @@ -174,14 +179,16 @@ if (!empty($triggers)) } //print 'module='.$module.' code='.$trigger['code'].'
'; - if (!empty($conf->$module->enabled)) - { + if (!empty($conf->$module->enabled)) { // Discard special case: If option FICHINTER_CLASSIFY_BILLED is not set, we discard both trigger FICHINTER_CLASSIFY_BILLED and FICHINTER_CLASSIFY_UNBILLED - if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; - if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) continue; + if ($trigger['code'] == 'FICHINTER_CLASSIFY_BILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { + continue; + } + if ($trigger['code'] == 'FICHINTER_CLASSIFY_UNBILLED' && empty($conf->global->FICHINTER_CLASSIFY_BILLED)) { + continue; + } - if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $trigger['code'])) - { + if ($search_event === '' || preg_match('/'.preg_quote($search_event, '/').'/i', $trigger['code'])) { print ''; print ''.$trigger['code'].''; print ''.$trigger['label'].''; diff --git a/htdocs/admin/agenda_extrafields.php b/htdocs/admin/agenda_extrafields.php index 36c7bc3edf8..f140b207aaf 100644 --- a/htdocs/admin/agenda_extrafields.php +++ b/htdocs/admin/agenda_extrafields.php @@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'agenda')); @@ -43,13 +44,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'actioncomm'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -82,8 +87,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '
'; print "".$langs->trans("NewAttribute").""; print "
"; @@ -96,8 +100,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '
'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -109,8 +112,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index f99c530c7e2..9ce55583d99 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -32,7 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('agenda', 'admin', 'other')); @@ -41,7 +43,9 @@ $def = array(); $actiontest = GETPOST('test', 'alpha'); $actionsave = GETPOST('save', 'alpha'); -if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; +if (empty($conf->global->AGENDA_EXT_NB)) { + $conf->global->AGENDA_EXT_NB = 5; +} $MAXAGENDA = $conf->global->AGENDA_EXT_NB; // List of available colors @@ -52,8 +56,7 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', ' * Actions */ -if ($actionsave) -{ +if ($actionsave) { $db->begin(); $disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha'); @@ -63,17 +66,17 @@ if ($actionsave) $error = 0; // Save agendas - while ($i <= $MAXAGENDA) - { + while ($i <= $MAXAGENDA) { $name = trim(GETPOST('AGENDA_EXT_NAME'.$i, 'alpha')); $src = trim(GETPOST('AGENDA_EXT_SRC'.$i, 'alpha')); $offsettz = trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i, 'alpha')); $color = trim(GETPOST('AGENDA_EXT_COLOR'.$i, 'alpha')); - if ($color == '-1') $color = ''; + if ($color == '-1') { + $color = ''; + } $enabled = trim(GETPOST('AGENDA_EXT_ENABLED'.$i, 'alpha')); - if (!empty($src) && !dol_is_url($src)) - { + if (!empty($src) && !dol_is_url($src)) { setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors'); $error++; $errorsaved++; @@ -82,34 +85,48 @@ if ($actionsave) //print '-name='.$name.'-color='.$color; $res = dolibarr_set_const($db, 'AGENDA_EXT_NAME'.$i, $name, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } $res = dolibarr_set_const($db, 'AGENDA_EXT_SRC'.$i, $src, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } $res = dolibarr_set_const($db, 'AGENDA_EXT_OFFSETTZ'.$i, $offsettz, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } $res = dolibarr_set_const($db, 'AGENDA_EXT_COLOR'.$i, $color, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } $res = dolibarr_set_const($db, 'AGENDA_EXT_ENABLED'.$i, $enabled, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } $i++; } // Save nb of agenda - if (!$error) - { + if (!$error) { $res = dolibarr_set_const($db, 'AGENDA_EXT_NB', trim(GETPOST('AGENDA_EXT_NB', 'int')), 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; - if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB = 5; + if (!($res > 0)) { + $error++; + } + if (empty($conf->global->AGENDA_EXT_NB)) { + $conf->global->AGENDA_EXT_NB = 5; + } $MAXAGENDA = empty($conf->global->AGENDA_EXT_NB) ? 5 : $conf->global->AGENDA_EXT_NB; } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { $db->rollback(); - if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors'); + if (empty($errorsaved)) { + setEventMessages($langs->trans("Error"), null, 'errors'); + } } } @@ -143,7 +160,11 @@ print "
\n"; $selectedvalue = $conf->global->AGENDA_DISABLE_EXT; -if ($selectedvalue == 1) $selectedvalue = 0; else $selectedvalue = 1; +if ($selectedvalue == 1) { + $selectedvalue = 0; +} else { + $selectedvalue = 1; +} print ""; @@ -157,12 +178,10 @@ print ""; print ''; print ""; print ''; print ""; $i = 1; -while ($i <= $MAXAGENDA) -{ +while ($i <= $MAXAGENDA) { $key = $i; $name = 'AGENDA_EXT_NAME'.$key; $src = 'AGENDA_EXT_SRC'.$key; diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index a072869be8c..2b3eaf9be94 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -31,8 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'agenda', 'users')); @@ -52,12 +53,10 @@ $type = 'action'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $reg = array(); -if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) -{ +if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); - if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) - { + if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -65,27 +64,23 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) } } -if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) -{ +if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { + if (dolibarr_del_const($db, $code, $conf->entity) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } } -if ($action == 'set') -{ +if ($action == 'set') { $getDefaultFilter = GETPOST('AGENDA_DEFAULT_FILTER_TYPE'); $defaultfilter = (is_array($getDefaultFilter)) ? implode(',', $getDefaultFilter) : $getDefaultFilter; dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', $defaultfilter, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); -} elseif ($action == 'specimen') // For orders -{ +} elseif ($action == 'specimen') { // For orders $modele = GETPOST('module', 'alpha'); $commande = new CommandeFournisseur($db); @@ -95,25 +90,21 @@ if ($action == 'set') // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { + if ($module->write_file($commande, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); return; } else { @@ -124,27 +115,20 @@ if ($action == 'set') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} - -// Activate a model -elseif ($action == 'setmodel') -{ +} elseif ($action == 'setmodel') { + // Activate a model //print "sssd".$value; $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); + } } -} - -// Set default model -elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + // Set default model + if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->ACTION_EVENT_ADDON_PDF = $value; @@ -152,8 +136,7 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } } @@ -193,12 +176,10 @@ $sql .= " WHERE type = 'action'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -207,8 +188,7 @@ if ($resql) dol_print_error($db); } -if ($conf->global->MAIN_FEATURES_LEVEL >= 2) -{ +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { print load_fiche_titre($langs->trans("AgendaModelModule"), '', ''); print '
".$langs->trans("ExtSitesEnableThisTool")."'; -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print ajax_constantonoff('AGENDA_DISABLE_EXT', array('enabled'=>array(0=>'.hideifnotset')), null, 1); } else { - if (empty($conf->global->AGENDA_DISABLE_EXT)) - { + if (empty($conf->global->AGENDA_DISABLE_EXT)) { print ''.img_picto($langs->trans("Enabled"), 'on').''; } else { print ''.img_picto($langs->trans("Disabled"), 'off').''; @@ -194,8 +213,7 @@ print ''.$langs->trans("Color").'
'."\n"; @@ -223,19 +203,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) clearstatcache(); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/action/doc"); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -249,17 +224,17 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) print "\n"; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print ''."\n"; print ''."\n"; print ''."\n"; -if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) -{ +if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''; print ''."\n"; print ''."\n"; diff --git a/htdocs/admin/agenda_reminder.php b/htdocs/admin/agenda_reminder.php index 373014e417e..b3a85d1fe4b 100644 --- a/htdocs/admin/agenda_reminder.php +++ b/htdocs/admin/agenda_reminder.php @@ -27,8 +27,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; require_once DOL_DOCUMENT_ROOT.'/cron/class/cronjob.class.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array("admin", "other", "agenda")); @@ -47,12 +48,10 @@ $type = 'action'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) -{ +if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; $value = (GETPOST($code, 'alpha') ? GETPOST($code, 'alpha') : 1); - if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) - { + if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -60,25 +59,21 @@ if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) } } -if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) -{ +if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { + if (dolibarr_del_const($db, $code, $conf->entity) > 0) { Header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } } -if ($action == 'set') -{ +if ($action == 'set') { dolibarr_set_const($db, 'AGENDA_USE_EVENT_TYPE_DEFAULT', GETPOST('AGENDA_USE_EVENT_TYPE_DEFAULT'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_TYPE', GETPOST('AGENDA_DEFAULT_FILTER_TYPE'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_FILTER_STATUS', GETPOST('AGENDA_DEFAULT_FILTER_STATUS'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, 'AGENDA_DEFAULT_VIEW', GETPOST('AGENDA_DEFAULT_VIEW'), 'chaine', 0, '', $conf->entity); -} elseif ($action == 'specimen') // For orders -{ +} elseif ($action == 'specimen') { // For orders $modele = GETPOST('module', 'alpha'); $commande = new CommandeFournisseur($db); @@ -88,25 +83,21 @@ if ($action == 'set') // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/action/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db, $commande); - if ($module->write_file($commande, $langs) > 0) - { + if ($module->write_file($commande, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=action&file=SPECIMEN.pdf"); return; } else { @@ -117,27 +108,20 @@ if ($action == 'set') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} - -// Activate a model -elseif ($action == 'setmodel') -{ +} elseif ($action == 'setmodel') { + // Activate a model //print "sssd".$value; $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'ACTION_EVENT_ADDON_PDF', $conf->entity); + } } -} - -// Set default model -elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + // Set default model + if (dolibarr_set_const($db, "ACTION_EVENT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // The constant that has been read in front of the new set // is therefore passed through a variable to have a coherent display $conf->global->ACTION_EVENT_ADDON_PDF = $value; @@ -145,8 +129,7 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } } diff --git a/htdocs/admin/agenda_xcal.php b/htdocs/admin/agenda_xcal.php index 6d77b9f4416..586194375fc 100644 --- a/htdocs/admin/agenda_xcal.php +++ b/htdocs/admin/agenda_xcal.php @@ -29,8 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array("admin", "other", "agenda")); @@ -39,8 +40,7 @@ $def = array(); $actionsave = GETPOST('save', 'alpha'); // Sauvegardes parametres -if ($actionsave) -{ +if ($actionsave) { $i = 0; $db->begin(); @@ -50,8 +50,7 @@ if ($actionsave) $i += dolibarr_set_const($db, 'MAIN_AGENDA_EXPORT_CACHE', trim(GETPOST('MAIN_AGENDA_EXPORT_CACHE', 'alpha')), 'chaine', 0, '', $conf->entity); $i += dolibarr_set_const($db, 'AGENDA_EXPORT_FIX_TZ', trim(GETPOST('AGENDA_EXPORT_FIX_TZ', 'alpha')), 'chaine', 0, '', $conf->entity); - if ($i >= 4) - { + if ($i >= 4) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -66,7 +65,9 @@ if ($actionsave) * View */ -if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100; +if (!isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) { + $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY = 100; +} $wikihelp = 'EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda'; llxHeader('', $langs->trans("AgendaSetup"), $wikihelp); @@ -97,8 +98,9 @@ print ""; print ''; print '"; print ''; print ""; print ""; @@ -183,8 +185,7 @@ $message .= $langs->trans("AgendaUrlOptionsIncludeHolidays", '1', '1').'
'; print info_admin($message); -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print "\n".' - trans("OtherSetup"), '', 'title_setup'); @@ -196,8 +191,7 @@ print getTitleFieldOfList('Name', 0, $_SERVER['PHP_SELF'], 'name', '', $param, ' print getTitleFieldOfList("Value", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print getTitleFieldOfList("Comment", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print getTitleFieldOfList('DateModificationShort', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; -if (!empty($conf->multicompany->enabled) && !$user->entity) -{ +if (!empty($conf->multicompany->enabled) && !$user->entity) { print getTitleFieldOfList('Entity', 0, $_SERVER['PHP_SELF'], 'tms', '', $param, '', $sortfield, $sortorder, 'center ')."\n"; } print getTitleFieldOfList("", 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'center '); @@ -219,8 +213,7 @@ print ''; print ''; // Limit to superadmin -if (!empty($conf->multicompany->enabled) && !$user->entity) -{ +if (!empty($conf->multicompany->enabled) && !$user->entity) { print ''; @@ -245,20 +238,23 @@ $sql .= ", tms"; $sql .= ", entity"; $sql .= " FROM ".MAIN_DB_PREFIX."const"; $sql .= " WHERE entity IN (".$user->entity.",".$conf->entity.")"; -if ((empty($user->entity) || $user->admin) && $debug) {} // to force for superadmin to debug -elseif (!GETPOST('visible') || GETPOST('visible') != 'all') $sql .= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits -if (GETPOST('name')) $sql .= natural_search("name", GETPOST('name')); +if ((empty($user->entity) || $user->admin) && $debug) { +} elseif (!GETPOST('visible') || GETPOST('visible') != 'all') { + // to force for superadmin to debug + $sql .= " AND visible = 1"; // We must always have this. Otherwise, array is too large and submitting data fails due to apache POST or GET limits +} +if (GETPOST('name')) { + $sql .= natural_search("name", GETPOST('name')); +} $sql .= $db->order($sortfield, $sortorder); dol_syslog("Const::listConstant", LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); print "\n"; @@ -284,8 +280,7 @@ if ($result) print ''; // Entity limit to superadmin - if (!empty($conf->multicompany->enabled) && !$user->entity) - { + if (!empty($conf->multicompany->enabled) && !$user->entity) { print ''; @@ -295,8 +290,7 @@ if ($result) print ''; } - if ($conf->use_javascript_ajax) - { + if ($conf->use_javascript_ajax) { print ''; } else { print ''.img_delete().''; @@ -313,8 +307,7 @@ if ($result) print '
\n"; require_once $dir.'/'.$file; $module = new $classname($db, $specimenthirdparty); - if (method_exists($module, 'info')) + if (method_exists($module, 'info')) { print $module->info($langs); - else print $module->description; + } else { + print $module->description; + } print "'."\n"; - if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") - { + if ($conf->global->ACTION_EVENT_ADDON_PDF != "$name") { print 'scandir.'&label='.urlencode($module->name).'&type=action">'; print img_picto($langs->trans("Enabled"), 'switch_on'); print ''; @@ -275,8 +250,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) // Default print ''; - if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") - { + if ($conf->global->ACTION_EVENT_ADDON_PDF == "$name") { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'&type=action"" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -324,8 +298,7 @@ print ''.$langs->trans("AGENDA_USE_EVENT_TYPE").' '."\n"; //print ajax_constantonoff('AGENDA_USE_EVENT_TYPE'); Do not use ajax here, we need to reload page to change other combo list -if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) -{ +if (empty($conf->global->AGENDA_USE_EVENT_TYPE)) { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; @@ -342,8 +315,7 @@ $tmplist = array(''=>' ', 'show_list'=>$langs->trans("ViewList"), 'show_mon print $form->selectarray('AGENDA_DEFAULT_VIEW', $tmplist, $conf->global->AGENDA_DEFAULT_VIEW); print '
'.$langs->trans("AGENDA_USE_EVENT_TYPE_DEFAULT").'
'.$langs->trans("PasswordTogetVCalExport")."'; -if (!empty($conf->use_javascript_ajax)) +if (!empty($conf->use_javascript_ajax)) { print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); +} print ' 
'; print ''; print ''; print ''; print ''; print '
'; print ''; -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print '
'; print '
'; print ''; diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 05330e92b89..30b77f6db8b 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -31,7 +31,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "errors", "contracts")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); @@ -39,8 +41,7 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'contract'; -if (empty($conf->global->CONTRACT_ADDON)) -{ +if (empty($conf->global->CONTRACT_ADDON)) { $conf->global->CONTRACT_ADDON = 'mod_contract_serpis'; } @@ -51,22 +52,23 @@ if (empty($conf->global->CONTRACT_ADDON)) include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'updateMask') -{ +if ($action == 'updateMask') { $maskconst = GETPOST('maskconstcontract', 'alpha'); $maskvalue = GETPOST('maskcontract', 'alpha'); - if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + if ($maskconst) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + } - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') // For contract -{ +} elseif ($action == 'specimen') { // For contract $modele = GETPOST('module', 'alpha'); $contract = new Contrat($db); @@ -75,25 +77,21 @@ if ($action == 'updateMask') // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); - if ($module->write_file($contract, $langs) > 0) - { + if ($module->write_file($contract, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=contract&file=SPECIMEN.pdf"); return; } else { @@ -104,26 +102,19 @@ if ($action == 'updateMask') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} - -// Activate a model -elseif ($action == 'set') -{ +} elseif ($action == 'set') { + // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->CONTRACT_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity); + } } -} - -// Set default model -elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "CONTRACT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + // Set default model + if (dolibarr_set_const($db, "CONTRACT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->CONTRACT_ADDON_PDF = $value; @@ -131,18 +122,15 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } -} elseif ($action == 'setmod') -{ +} elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated dolibarr_set_const($db, "CONTRACT_ADDON", $value, 'chaine', 0, '', $conf->entity); -} elseif ($action == 'set_other') -{ +} elseif ($action == 'set_other') { $freetext = GETPOST('CONTRACT_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $res1 = dolibarr_set_const($db, "CONTRACT_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); @@ -152,10 +140,11 @@ elseif ($action == 'setdoc') $value = GETPOST('activate_hideClosedServiceByDefault', 'alpha'); $res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity); - if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) $error++; + if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -197,19 +186,14 @@ print "\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/contract/"); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php') - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (substr($file, 0, 13) == 'mod_contract_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; @@ -217,11 +201,14 @@ foreach ($dirmodels as $reldir) $module = new $file($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } - if ($module->isEnabled()) - { + if ($module->isEnabled()) { print ''.$module->nom."\n"; print $module->info(); print ''; @@ -232,14 +219,15 @@ foreach ($dirmodels as $reldir) if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; + } elseif ($tmp == 'NotConfigured') { + print $langs->trans($tmp); + } else { + print $tmp; } - elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; print ''."\n"; print ''; - if ($conf->global->CONTRACT_ADDON == "$file") - { + if ($conf->global->CONTRACT_ADDON == "$file") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -258,8 +246,9 @@ foreach ($dirmodels as $reldir) if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { $nextval = $langs->trans($nextval); + } $htmltooltip .= $nextval.'
'; } else { $htmltooltip .= $langs->trans($module->error).'
'; @@ -294,12 +283,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -321,31 +308,23 @@ print "\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ - foreach (array('', '/doc') as $valdir) - { +foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { $realpath = $reldir."core/modules/contract".$valdir; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -353,21 +332,26 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print ''; print (empty($module->name) ? $name : $module->name); print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print ''; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print ''."\n"; print '
'; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -381,8 +365,7 @@ foreach ($dirmodels as $reldir) // Defaut print ''; - if ($conf->global->CONTRACT_ADDON_PDF == $name) - { + if ($conf->global->CONTRACT_ADDON_PDF == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -392,8 +375,7 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; @@ -412,8 +394,7 @@ foreach ($dirmodels as $reldir) // Preview print ''; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -452,15 +433,16 @@ print "\n"; $substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +foreach ($substitutionarray as $key => $val) { + $htmltext .= $key.'
'; +} $htmltext .= '
'; print ''; print $form->textwithpicto($langs->trans("FreeLegalTextOnContracts"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print '
'; $variablename = 'CONTRACT_FREE_TEXT'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) -{ +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/admin/dav.php b/htdocs/admin/dav.php index 4008a3cd7be..3d159801173 100644 --- a/htdocs/admin/dav.php +++ b/htdocs/admin/dav.php @@ -28,8 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/dav/dav.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "other", "agenda")); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Parameters $action = GETPOST('action', 'aZ09'); @@ -71,8 +72,7 @@ $head = dav_admin_prepare_head(); print dol_get_fiche_head($head, 'webdav', '', -1, 'action'); -if ($action == 'edit') -{ +if ($action == 'edit') { print '
'; print ''; print ''; @@ -80,9 +80,10 @@ if ($action == 'edit') print ''; print ''; - foreach ($arrayofparameters as $key => $val) - { - if (isset($val['enabled']) && empty($val['enabled'])) continue; + foreach ($arrayofparameters as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { + continue; + } print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); @@ -93,11 +94,9 @@ if ($action == 'edit') } print $form->textwithpicto($label, $tooltiphelp); print ''; - if ($key == 'DAV_ALLOW_PRIVATE_DIR') - { + if ($key == 'DAV_ALLOW_PRIVATE_DIR') { print $langs->trans("AlwaysActive"); - } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') - { + } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') { print $form->selectyesno($key, $conf->global->$key, 1); } else { print ''; @@ -117,8 +116,7 @@ if ($action == 'edit') print ''; print ''; - foreach ($arrayofparameters as $key => $val) - { + foreach ($arrayofparameters as $key => $val) { print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; $tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : ''); $label = $langs->trans($key); @@ -128,11 +126,9 @@ if ($action == 'edit') } print $form->textwithpicto($label, $tooltiphelp); print ''; - if ($key == 'DAV_ALLOW_PRIVATE_DIR') - { + if ($key == 'DAV_ALLOW_PRIVATE_DIR') { print $langs->trans("AlwaysActive"); - } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') - { + } elseif ($key == 'DAV_ALLOW_PUBLIC_DIR' || $key == 'DAV_ALLOW_ECM_DIR') { print yn($conf->global->$key); } else { print $conf->global->$key; @@ -174,8 +170,7 @@ $message = ''; $url = ''.$urlwithroot.'/dav/fileserver.php'; $message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV', '{url}')); $message .= '
'; -if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) -{ +if (!empty($conf->global->DAV_ALLOW_PUBLIC_DIR)) { $urlEntity = (!empty($conf->multicompany->enabled) ? '?entity='.$conf->entity : ''); $url = ''.$urlwithroot.'/dav/fileserver.php/public/'.$urlEntity.''; $message .= img_picto('', 'globe').' '.str_replace('{url}', $url, $langs->trans("WebDavServer", 'WebDAV public', '{url}')); diff --git a/htdocs/admin/debugbar.php b/htdocs/admin/debugbar.php index 840157d47e0..19a440520b1 100644 --- a/htdocs/admin/debugbar.php +++ b/htdocs/admin/debugbar.php @@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; global $conf; -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array("admin", "other")); @@ -43,19 +45,16 @@ $action = GETPOST('action', 'aZ09'); */ // Set modes -if ($action == 'set') -{ +if ($action == 'set') { $db->begin(); $result1 = dolibarr_set_const($db, "DEBUGBAR_LOGS_LINES_NUMBER", GETPOST('DEBUGBAR_LOGS_LINES_NUMBER', 'int'), 'chaine', 0, '', 0); $result2 = dolibarr_set_const($db, "DEBUGBAR_USE_LOG_FILE", GETPOST('DEBUGBAR_USE_LOG_FILE', 'int'), 'chaine', 0, '', 0); - if ($result1 < 0 || $result2 < 0) - { + if ($result1 < 0 || $result2 < 0) { $error++; } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -76,8 +75,7 @@ $form = new Form($db); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("DebugBarSetup"), $linkback, 'title_setup'); -if (!function_exists('mb_check_encoding')) -{ +if (!function_exists('mb_check_encoding')) { $langs->load("errors"); print info_admin($langs->trans("ErrorPHPNeedModule", 'mbstring'), 0, 0, 'error'); } diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index ae9427d70e0..4a480349bb3 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'products', 'admin', 'sms', 'other', 'errors')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $id = GETPOST('rowid', 'int'); $action = GETPOST('action', 'aZ09'); @@ -46,12 +48,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = 'page,param'; -if (!$sortorder) $sortorder = 'ASC'; +if (!$sortfield) { + $sortfield = 'page,param'; +} +if (!$sortorder) { + $sortorder = 'ASC'; +} $defaulturl = GETPOST('defaulturl', 'alphanohtml'); $defaultkey = GETPOST('defaultkey', 'alphanohtml'); @@ -71,18 +79,23 @@ $hookmanager->initHooks(array('admindefaultvalues', 'globaladmin')); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $defaulturl = ''; $defaultkey = ''; $defaultvalue = ''; @@ -90,60 +103,51 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_array_options = array(); } -if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') -{ - if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity); - else dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity); +if ($action == 'setMAIN_ENABLE_DEFAULT_VALUES') { + if (GETPOST('value')) { + dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 1, 'chaine', 0, '', $conf->entity); + } else { + dolibarr_set_const($db, 'MAIN_ENABLE_DEFAULT_VALUES', 0, 'chaine', 0, '', $conf->entity); + } } -if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) -{ +if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('actionmodify')) { $error = 0; - if (($action == 'add' || (GETPOST('add') && $action != 'update'))) - { - if (empty($defaulturl)) - { + if (($action == 'add' || (GETPOST('add') && $action != 'update'))) { + if (empty($defaulturl)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); $error++; } - if (empty($defaultkey)) - { + if (empty($defaultkey)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); $error++; } } - if (GETPOST('actionmodify')) - { - if (empty($urlpage)) - { + if (GETPOST('actionmodify')) { + if (empty($urlpage)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Url")), null, 'errors'); $error++; } - if (empty($key)) - { + if (empty($key)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Field")), null, 'errors'); $error++; } } - if (!$error) - { + if (!$error) { $db->begin(); - if ($action == 'add' || (GETPOST('add') && $action != 'update')) - { + if ($action == 'add' || (GETPOST('add') && $action != 'update')) { $sql = "INSERT INTO ".MAIN_DB_PREFIX."default_values(type, user_id, page, param, value, entity) VALUES ('".$db->escape($mode)."', 0, '".$db->escape($defaulturl)."','".$db->escape($defaultkey)."','".$db->escape($defaultvalue)."', ".$db->escape($conf->entity).")"; } - if (GETPOST('actionmodify')) - { + if (GETPOST('actionmodify')) { $sql = "UPDATE ".MAIN_DB_PREFIX."default_values SET page = '".$db->escape($urlpage)."', param = '".$db->escape($key)."', value = '".$db->escape($value)."'"; $sql .= " WHERE rowid = ".$id; } $result = $db->query($sql); - if ($result > 0) - { + if ($result > 0) { $db->commit(); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $action = ""; @@ -159,13 +163,11 @@ if (($action == 'add' || (GETPOST('add') && $action != 'update')) || GETPOST('ac } // Delete line from delete picto -if ($action == 'delete') -{ +if ($action == 'delete') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."default_values WHERE rowid = ".$db->escape($id); // Delete const $result = $db->query($sql); - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); } else { dol_print_error($db); @@ -187,8 +189,7 @@ llxHeader('', $langs->trans("Setup"), $wikihelp); $param = '&mode='.$mode; $enabledisablehtml = $langs->trans("EnableDefaultValues").' '; -if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) -{ +if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { // Button off, click to enable $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); @@ -205,16 +206,30 @@ print load_fiche_titre($langs->trans("DefaultValues"), $enabledisablehtml, 'titl print ''.$langs->trans("DefaultValuesDesc")."
\n"; print "
\n"; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); -if ($defaulturl) $param .= '&defaulturl='.urlencode($defaulturl); -if ($defaultkey) $param .= '&defaultkey='.urlencode($defaultkey); -if ($defaultvalue) $param .= '&defaultvalue='.urlencode($defaultvalue); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +if ($defaulturl) { + $param .= '&defaulturl='.urlencode($defaulturl); +} +if ($defaultkey) { + $param .= '&defaultkey='.urlencode($defaultkey); +} +if ($defaultvalue) { + $param .= '&defaultvalue='.urlencode($defaultvalue); +} print 'entity) && !empty($debug)) ? '?debug=1' : '').'" method="POST">'; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -226,12 +241,10 @@ $head = defaultvalues_prepare_head(); print dol_get_fiche_head($head, $mode, '', -1, ''); -if ($mode == 'sortorder') -{ +if ($mode == 'sortorder') { print info_admin($langs->trans("WarningSettingSortOrder")).'
'; } -if ($mode == 'mandatory') -{ +if ($mode == 'mandatory') { print info_admin($langs->trans("FeatureSupportedOnTextFieldsOnly")).'
'; } @@ -244,15 +257,17 @@ print ''; print ''; // Page $texthelp = $langs->trans("PageUrlForDefaultValues"); -if ($mode == 'createform') $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2'); -else $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2'); +if ($mode == 'createform') { + $texthelp .= $langs->trans("PageUrlForDefaultValuesCreate", 'societe/card.php', 'societe/card.php?abc=val1&def=val2'); +} else { + $texthelp .= $langs->trans("PageUrlForDefaultValuesList", 'societe/list.php', 'societe/list.php?abc=val1&def=val2'); +} $texthelp .= '

'.$langs->trans("AlsoDefaultValuesAreEffectiveForActionCreate"); $texturl = $form->textwithpicto($langs->trans("RelativeURL"), $texthelp); print_liste_field_titre($texturl, $_SERVER["PHP_SELF"], 'page,param', '', $param, '', $sortfield, $sortorder); // Field $texthelp = $langs->trans("TheKeyIsTheNameOfHtmlField"); -if ($mode != 'sortorder') -{ +if ($mode != 'sortorder') { $textkey = $form->textwithpicto($langs->trans("Field"), $texthelp); } else { $texthelp = 'field or alias.field'; @@ -260,15 +275,12 @@ if ($mode != 'sortorder') } print_liste_field_titre($textkey, $_SERVER["PHP_SELF"], 'param', '', $param, '', $sortfield, $sortorder); // Value -if ($mode != 'focus' && $mode != 'mandatory') -{ - if ($mode != 'sortorder') - { +if ($mode != 'focus' && $mode != 'mandatory') { + if ($mode != 'sortorder') { $substitutionarray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount')); // Must match list into GETPOST unset($substitutionarray['__USER_SIGNATURE__']); $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
'; - foreach ($substitutionarray as $key => $val) - { + foreach ($substitutionarray as $key => $val) { $texthelp .= $key.' -> '.$val.'
'; } $textvalue = $form->textwithpicto($langs->trans("Value"), $texthelp, 1, 'help', '', 0, 2, 'subsitutiontooltip'); @@ -279,8 +291,11 @@ if ($mode != 'focus' && $mode != 'mandatory') print_liste_field_titre($textvalue, $_SERVER["PHP_SELF"], 'value', '', $param, '', $sortfield, $sortorder); } // Entity -if (!empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder); -else print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); +if (!empty($conf->multicompany->enabled) && !$user->entity) { + print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,page', '', $param, '', $sortfield, $sortorder); +} else { + print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); +} // Actions print_liste_field_titre("", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); print "\n"; @@ -299,15 +314,13 @@ print ''; // Value -if ($mode != 'focus' && $mode != 'mandatory') -{ +if ($mode != 'focus' && $mode != 'mandatory') { print ''; } // Limit to superadmin -if (!empty($conf->multicompany->enabled) && !$user->entity) -{ +if (!empty($conf->multicompany->enabled) && !$user->entity) { print ''; @@ -318,7 +331,9 @@ if (!empty($conf->multicompany->enabled) && !$user->entity) } print '\n"; print ''; @@ -333,13 +348,11 @@ $sql .= $db->order($sortfield, $sortorder); dol_syslog("translation::select from table", LOG_DEBUG); $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); print "\n"; @@ -348,27 +361,35 @@ if ($result) // Page print ''."\n"; // Field print ''."\n"; // Value - if ($mode != 'focus' && $mode != 'mandatory') - { + if ($mode != 'focus' && $mode != 'mandatory') { print ''; } @@ -376,8 +397,7 @@ if ($result) // Actions print '
'; print ''; print ''; print ''; print ''; print ''; // We see environment, but to change it we must switch on other entity print ''; $disabled = ''; -if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) $disabled = ' disabled="disabled"'; +if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { + $disabled = ' disabled="disabled"'; +} print ''; print "
'; - if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) print $obj->page; - else print ''; + if ($action != 'edit' || GETPOST('rowid', 'int') != $obj->rowid) { + print $obj->page; + } else { + print ''; + } print ''; - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print $obj->param; - else print ''; + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) { + print $obj->param; + } else { + print ''; + } print ''; /*print ''; - print ''; - print ''; - print ''; - */ - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) print dol_escape_htmltag($obj->value); - else print ''; + print ''; + print ''; + print ''; + */ + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) { + print dol_escape_htmltag($obj->value); + } else { + print ''; + } print ''; - if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) - { + if ($action != 'edit' || GETPOST('rowid') != $obj->rowid) { print ''.img_edit().''; print ''.img_delete().''; } else { diff --git a/htdocs/admin/delais.php b/htdocs/admin/delais.php index 90ea5f290b6..6c0cd230cc9 100644 --- a/htdocs/admin/delais.php +++ b/htdocs/admin/delais.php @@ -30,134 +30,138 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->load("admin"); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); -if (empty($action)) $action = 'edit'; +if (empty($action)) { + $action = 'edit'; +} // Define list of managed delays $modules = array( - 'agenda' => array( - array( - 'code' => 'MAIN_DELAY_ACTIONS_TODO', - 'img' => 'action' - ) - ), - 'projet' => array( - array( - 'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE', - 'img' => 'project' - ), - array( - 'code' => 'MAIN_DELAY_TASKS_TODO', - 'img' => 'projecttask' - ) - ), - 'propal' => array( - array( - 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE', - 'img' => 'propal' - ), - array( - 'code' => 'MAIN_DELAY_PROPALS_TO_BILL', - 'img' => 'propal' - ) - ), - 'commande' => array( - array( - 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS', - 'img' => 'order' - ) - ), - 'facture' => array( - array( - 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED', - 'img' => 'bill' - ) - ), - 'fournisseur' => array( - array( - 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS', - 'img' => 'order' - ), - array( - 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY', - 'img' => 'bill' - ) - ), - 'service' => array( - array( - 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES', - 'img' => 'service' - ), - array( - 'code' => 'MAIN_DELAY_RUNNING_SERVICES', - 'img' => 'service' - ) - ), - 'banque' => array( - array( - 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE', - 'img' => 'account' - ), - array( - 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT', - 'img' => 'account' - ) - ), - 'adherent' => array( - array( - 'code' => 'MAIN_DELAY_MEMBERS', - 'img' => 'user' - ) - ), - 'expensereport' => array( - array( - 'code' => 'MAIN_DELAY_EXPENSEREPORTS', - 'img' => 'trip' - ), - /* TODO Enable this - array( - 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY', - 'img' => 'trip' - )*/ - ), - 'holiday' => array( - array( - 'code' => 'MAIN_DELAY_HOLIDAYS', - 'img' => 'holiday' - ), - ), + 'agenda' => array( + array( + 'code' => 'MAIN_DELAY_ACTIONS_TODO', + 'img' => 'action' + ) + ), + 'projet' => array( + array( + 'code' => 'MAIN_DELAY_PROJECT_TO_CLOSE', + 'img' => 'project' + ), + array( + 'code' => 'MAIN_DELAY_TASKS_TODO', + 'img' => 'projecttask' + ) + ), + 'propal' => array( + array( + 'code' => 'MAIN_DELAY_PROPALS_TO_CLOSE', + 'img' => 'propal' + ), + array( + 'code' => 'MAIN_DELAY_PROPALS_TO_BILL', + 'img' => 'propal' + ) + ), + 'commande' => array( + array( + 'code' => 'MAIN_DELAY_ORDERS_TO_PROCESS', + 'img' => 'order' + ) + ), + 'facture' => array( + array( + 'code' => 'MAIN_DELAY_CUSTOMER_BILLS_UNPAYED', + 'img' => 'bill' + ) + ), + 'fournisseur' => array( + array( + 'code' => 'MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS', + 'img' => 'order' + ), + array( + 'code' => 'MAIN_DELAY_SUPPLIER_BILLS_TO_PAY', + 'img' => 'bill' + ) + ), + 'service' => array( + array( + 'code' => 'MAIN_DELAY_NOT_ACTIVATED_SERVICES', + 'img' => 'service' + ), + array( + 'code' => 'MAIN_DELAY_RUNNING_SERVICES', + 'img' => 'service' + ) + ), + 'banque' => array( + array( + 'code' => 'MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE', + 'img' => 'account' + ), + array( + 'code' => 'MAIN_DELAY_CHEQUES_TO_DEPOSIT', + 'img' => 'account' + ) + ), + 'adherent' => array( + array( + 'code' => 'MAIN_DELAY_MEMBERS', + 'img' => 'user' + ) + ), + 'expensereport' => array( + array( + 'code' => 'MAIN_DELAY_EXPENSEREPORTS', + 'img' => 'trip' + ), + /* TODO Enable this + array( + 'code' => 'MAIN_DELAY_EXPENSEREPORTS_TO_PAY', + 'img' => 'trip' + )*/ + ), + 'holiday' => array( + array( + 'code' => 'MAIN_DELAY_HOLIDAYS', + 'img' => 'holiday' + ), + ), ); $labelmeteo = array(0=>$langs->trans("No"), 1=>$langs->trans("Yes"), 2=>$langs->trans("OnMobileOnly")); if (!isset($conf->global->MAIN_DELAY_PROJECT_TO_CLOSE)) { - $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php + $conf->global->MAIN_DELAY_PROJECT_TO_CLOSE = 7; // Must be same value than into conf.class.php } if (!isset($conf->global->MAIN_DELAY_TASKS_TODO)) { - $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php + $conf->global->MAIN_DELAY_TASKS_TODO = 7; // Must be same value than into conf.class.php } if (!isset($conf->global->MAIN_DELAY_MEMBERS)) { - $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php + $conf->global->MAIN_DELAY_MEMBERS = 0; // Must be same value than into conf.class.php } if (!isset($conf->global->MAIN_DELAY_ACTIONS_TODO)) { - $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php + $conf->global->MAIN_DELAY_ACTIONS_TODO = 7; // Must be same value than into conf.class.php } if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { - $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; + $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; } if (!isset($conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)) { - $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7; + $conf->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS = 7; } if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { - $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; + $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; } if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { - $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; + $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; } if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { - $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; + $conf->global->MAIN_DELAY_ORDERS_TO_PROCESS = 2; } @@ -166,32 +170,31 @@ if (!isset($conf->global->MAIN_DELAY_ORDERS_TO_PROCESS)) { * Actions */ -if ($action == 'update') -{ - foreach ($modules as $module => $delays) - { - if (!empty($conf->$module->enabled)) - { - foreach ($delays as $delay) - { - if (GETPOST($delay['code']) != '') - { - dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity); - } - } - } - } +if ($action == 'update') { + foreach ($modules as $module => $delays) { + if (!empty($conf->$module->enabled)) { + foreach ($delays as $delay) { + if (GETPOST($delay['code']) != '') { + dolibarr_set_const($db, $delay['code'], GETPOST($delay['code']), 'chaine', 0, '', $conf->entity); + } + } + } + } - dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity); - dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_DISABLE_METEO", $_POST["MAIN_DISABLE_METEO"], 'chaine', 0, '', $conf->entity); + dolibarr_set_const($db, "MAIN_USE_METEO_WITH_PERCENTAGE", GETPOST("MAIN_USE_METEO_WITH_PERCENTAGE"), 'chaine', 0, '', $conf->entity); - // For update value with percentage - $plus = ''; - if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $plus = '_PERCENTAGE'; - // Update values - for ($i = 0; $i < 4; $i++) { - if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); - } + // For update value with percentage + $plus = ''; + if (!empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $plus = '_PERCENTAGE'; + } + // Update values + for ($i = 0; $i < 4; $i++) { + if (GETPOSTISSET('MAIN_METEO'.$plus.'_LEVEL'.$i)) { + dolibarr_set_const($db, 'MAIN_METEO'.$plus.'_LEVEL'.$i, GETPOST('MAIN_METEO'.$plus.'_LEVEL'.$i, 'int'), 'chaine', 0, '', $conf->entity); + } + } setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); @@ -213,158 +216,165 @@ print ''.$langs->transnoentities("DelaysOfToleranceD print " ".$langs->trans("OnlyActiveElementsAreShown", DOL_URL_ROOT.'/admin/modules.php')."
\n"; print "
\n"; -if ($action == 'edit') -{ - print ''; - print ''; - print ''; +if ($action == 'edit') { + print ''; + print ''; + print ''; - print ''; - print ''; + print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'; + print ''; - foreach ($modules as $module => $delays) - { - if (!empty($conf->$module->enabled)) - { - foreach ($delays as $delay) - { - $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); - print ''; - print ''; - print ''; - } - } - } + foreach ($modules as $module => $delays) { + if (!empty($conf->$module->enabled)) { + foreach ($delays as $delay) { + $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); + print ''; + print ''; + print ''; + } + } + } - print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'.img_object('', $delay['img']).''.$langs->trans('Delays_'.$delay['code']).''; - print ' '.$langs->trans("days").'
'.img_object('', $delay['img']).''.$langs->trans('Delays_'.$delay['code']).''; + print ' '.$langs->trans("days").'
'; + print '
'; - print '
'; + print '
'; - // Show if meteo is enabled - print ''; - print ''; + // Show if meteo is enabled + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print ''; - print ''; - print ''; + print ''; + print ''; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_METEO").''; - print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO)); - print '
'.$langs->trans("MAIN_DISABLE_METEO").''; + print $form->selectarray('MAIN_DISABLE_METEO', $labelmeteo, (empty($conf->global->MAIN_DISABLE_METEO) ? 0 : $conf->global->MAIN_DISABLE_METEO)); + print '
'; + print '
'; } else { - /* - * Show parameters - */ + /* + * Show parameters + */ - print ''; - print ''; + print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'; + print ''; - foreach ($modules as $module => $delays) - { - if (!empty($conf->$module->enabled)) - { - foreach ($delays as $delay) - { - $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); - print ''; - print ''; - print ''; - print ''; - } - } - } + foreach ($modules as $module => $delays) { + if (!empty($conf->$module->enabled)) { + foreach ($delays as $delay) { + $value = (!empty($conf->global->{$delay['code']}) ? $conf->global->{$delay['code']}:0); + print ''; + print ''; + print ''; + print ''; + } + } + } - print '
'.$langs->trans("DelaysOfToleranceBeforeWarning").''.$langs->trans("Value").'
'.img_object('', $delay['img']).''.$langs->trans('Delays_'.$delay['code']).''.$value.' '.$langs->trans("days").'
'.img_object('', $delay['img']).''.$langs->trans('Delays_'.$delay['code']).''.$value.' '.$langs->trans("days").'
'; + print '
'; - print '
'; + print '
'; - // Show if meteo is enabled - print ''; - print ''; + // Show if meteo is enabled + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; + print ''; - print ''; - print ''; + print ''; + print ''; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_METEO").''; - print $labelmeteo[$conf->global->MAIN_DISABLE_METEO]; - print '
'.$langs->trans("MAIN_DISABLE_METEO").''; + print $labelmeteo[$conf->global->MAIN_DISABLE_METEO]; + print '
'; + print ''; } print '
'; if ($conf->global->MAIN_DISABLE_METEO != 1) { - // Show logo for weather - print ''.$langs->trans("DescWeather").' '; + // Show logo for weather + print ''.$langs->trans("DescWeather").' '; - if ($action == 'edit') { - $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod')); - $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod')); - if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) $str_mode_enabled = $str_mode_std; - else $str_mode_enabled = $str_mode_percentage; - print ''.$str_mode_enabled.''; - print ''; + if ($action == 'edit') { + $str_mode_std = $langs->trans('MeteoStdModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoPercentageMod')); + $str_mode_percentage = $langs->trans('MeteoPercentageModEnabled').' : '.$langs->trans('MeteoUseMod', $langs->transnoentitiesnoconv('MeteoStdMod')); + if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + $str_mode_enabled = $str_mode_std; + } else { + $str_mode_enabled = $str_mode_percentage; + } + print ''.$str_mode_enabled.''; + print ''; - print '

'; - } else { - if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) print $langs->trans('MeteoStdModEnabled'); - else print $langs->trans('MeteoPercentageModEnabled'); - print '

'; - } + print '

'; + } else { + if (empty($conf->global->MAIN_USE_METEO_WITH_PERCENTAGE)) { + print $langs->trans('MeteoStdModEnabled'); + } else { + print $langs->trans('MeteoPercentageModEnabled'); + } + print '

'; + } - $offset = 0; - $cursor = 10; // By default - //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET; - //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP; - $level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) $level0 = $conf->global->MAIN_METEO_LEVEL0; - $level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) $level1 = $conf->global->MAIN_METEO_LEVEL1; - $level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) $level2 = $conf->global->MAIN_METEO_LEVEL2; - $level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) $level3 = $conf->global->MAIN_METEO_LEVEL3; - $text = ''; $options = 'class="valignmiddle" height="60px"'; + $offset = 0; + $cursor = 10; // By default + //if (! empty($conf->global->MAIN_METEO_OFFSET)) $offset=$conf->global->MAIN_METEO_OFFSET; + //if (! empty($conf->global->MAIN_METEO_GAP)) $cursor=$conf->global->MAIN_METEO_GAP; + $level0 = $offset; if (!empty($conf->global->MAIN_METEO_LEVEL0)) { + $level0 = $conf->global->MAIN_METEO_LEVEL0; + } + $level1 = $offset + 1 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL1)) { + $level1 = $conf->global->MAIN_METEO_LEVEL1; + } + $level2 = $offset + 2 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL2)) { + $level2 = $conf->global->MAIN_METEO_LEVEL2; + } + $level3 = $offset + 3 * $cursor; if (!empty($conf->global->MAIN_METEO_LEVEL3)) { + $level3 = $conf->global->MAIN_METEO_LEVEL3; + } + $text = ''; $options = 'class="valignmiddle" height="60px"'; - if ($action == 'edit') { - print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>'; + if ($action == 'edit') { + print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? '' : 'style="display:none;"').'>'; - print '
'; - print '
'; - print img_weather($text, 0, $options); - print ' <= '; - print '
'; - print img_weather($text, 1, $options); - print ' <= '; - print '
'; - print img_weather($text, 2, $options); - print ' <= '; - print '
'; - print img_weather($text, 3, $options); - print ' <= '; - print '
'; - print '
'; + print '
'; + print '
'; + print img_weather($text, 0, $options); + print ' <= '; + print '
'; + print img_weather($text, 1, $options); + print ' <= '; + print '
'; + print img_weather($text, 2, $options); + print ' <= '; + print '
'; + print img_weather($text, 3, $options); + print ' <= '; + print '
'; + print '
'; - print '
'; + print '
'; - print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>'; + print '
global->MAIN_USE_METEO_WITH_PERCENTAGE) ? 'style="display:none;"' : '').'>'; - print '
'; - print '
'; - print img_weather($text, 0, $options); - print ' <=  %'; - print '
'; - print img_weather($text, 1, $options); - print ' <=  %'; - print '
'; - print img_weather($text, 2, $options); - print ' <=  %'; - print '
'; - print img_weather($text, 3, $options); - print ' <=  %'; - print '
'; - print '
'; + print '
'; + print '
'; + print img_weather($text, 0, $options); + print ' <=  %'; + print '
'; + print img_weather($text, 1, $options); + print ' <=  %'; + print '
'; + print img_weather($text, 2, $options); + print ' <=  %'; + print '
'; + print img_weather($text, 3, $options); + print ' <=  %'; + print '
'; + print '
'; - print '
'; + print '
'; - ?> + ?> '."\n"; @@ -545,8 +545,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; // List filters - foreach ($object->filters as $rulefilter) - { + foreach ($object->filters as $rulefilter) { $rulefilterobj = new EmailCollectorFilter($db); $rulefilterobj->fetch($rulefilter['id']); @@ -580,9 +579,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea 'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")), 'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")), 'recordevent'=>'RecordEvent'); - if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty'; - if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; - if ($conf->recruitment->enabled) $arrayoftypes['candidature'] = 'CreateCandidature'; + if ($conf->projet->enabled) { + $arrayoftypes['project'] = 'CreateLeadAndThirdParty'; + } + if ($conf->ticket->enabled) { + $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty'; + } + if ($conf->recruitment->enabled) { + $arrayoftypes['candidature'] = 'CreateCandidature'; + } // support hook for add action $parameters = array('arrayoftypes' => $arrayoftypes); @@ -591,7 +596,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($res) { $arrayoftypes = $hookmanager->resArray; } else { - foreach ($hookmanager->resArray as $k=>$desc) { + foreach ($hookmanager->resArray as $k => $desc) { $arrayoftypes[$k] = $desc; } } @@ -611,8 +616,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $table_element_line = 'emailcollector_emailcollectoraction'; $fk_element = 'position'; $i = 0; - foreach ($object->actions as $ruleaction) - { + foreach ($object->actions as $ruleaction) { $ruleactionobj = new EmailcollectorAction($db); $ruleactionobj->fetch($ruleaction['id']); @@ -620,16 +624,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; print ''; print $langs->trans($arrayoftypes[$ruleaction['type']]); - if (in_array($ruleaction['type'], array('recordevent'))) - { + if (in_array($ruleaction['type'], array('recordevent'))) { print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked')); } elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) { print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp')); } print ''; print ''; - if ($action == 'editoperation' && $ruleaction['id'] == $operationid) - { + if ($action == 'editoperation' && $ruleaction['id'] == $operationid) { print '
'; print '
'; print ''; @@ -640,8 +642,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print ''; // Move up/down print ''; - if ($i > 0) - { + if ($i > 0) { print ''.img_up('default', 0, 'imgupforline').''; } if ($i < count($object->actions) - 1) { @@ -681,10 +682,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'."\n"; $parameters = array(); $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + } - if (empty($reshook)) - { + if (empty($reshook)) { // Edit print ''; @@ -703,8 +705,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea print '
'."\n"; } - if (!empty($debuginfo)) - { + if (!empty($debuginfo)) { print info_admin($debuginfo); } } diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index e85a9652075..09a790a9f68 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -51,7 +51,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -70,13 +72,16 @@ $extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) -if (!$sortfield) $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. -if (!$sortorder) $sortorder = "ASC"; +if (!$sortfield) { + $sortfield = "t.".key($object->fields); // Set here default search field. By default 1st field in definition. +} +if (!$sortorder) { + $sortorder = "ASC"; +} // Security check $socid = 0; -if ($user->socid > 0) // Protection if external user -{ +if ($user->socid > 0) { // Protection if external user //$socid = $user->socid; accessforbidden(); } @@ -85,22 +90,23 @@ if ($user->socid > 0) // Protection if external user // Initialize array of search criterias $search_all = GETPOST("search_all", 'alphanohtml'); $search = array(); -foreach ($object->fields as $key => $val) -{ - if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); +foreach ($object->fields as $key => $val) { + if (GETPOST('search_'.$key, 'alpha') !== '') { + $search[$key] = GETPOST('search_'.$key, 'alpha'); + } } // List of fields to search into when doing a "search in all" $fieldstosearchall = array(); -foreach ($object->fields as $key => $val) -{ - if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; +foreach ($object->fields as $key => $val) { + if ($val['searchall']) { + $fieldstosearchall['t.'.$key] = $val['label']; + } } // Definition of array of fields for columns $arrayfields = array(); -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { // If $val['visible']==0, then we never show the field if (!empty($val['visible'])) { $visible = dol_eval($val['visible'], 1); @@ -113,10 +119,8 @@ foreach ($object->fields as $key => $val) } } // Extra fields -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) - { +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { if (!empty($extrafields->attributes[$object->table_element]['list'][$key])) { $arrayfields["ef.".$key] = array( 'label'=>$extrafields->attributes[$object->table_element]['label'][$key], @@ -138,8 +142,12 @@ $permissiontoread = $user->admin; $permissiontoadd = $user->admin; $permissiontodelete = $user->admin; -if (!$user->admin) accessforbidden(); -if (empty($conf->emailcollector->enabled)) accessforbidden('Module not enabled'); +if (!$user->admin) { + accessforbidden(); +} +if (empty($conf->emailcollector->enabled)) { + accessforbidden('Module not enabled'); +} @@ -147,31 +155,33 @@ if (empty($conf->emailcollector->enabled)) accessforbidden('Module not enabled') * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ +if (empty($reshook)) { // Selection of new fields include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria - if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers - { - foreach ($object->fields as $key => $val) - { + if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers + foreach ($object->fields as $key => $val) { $search[$key] = ''; } $toselect = ''; $search_array_options = array(); } if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') - || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) - { + || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) { $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation } @@ -197,13 +207,14 @@ $title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("EmailCollector") // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $sql .= 't.'.$key.', '; } // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { - foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + } } // Add fields from hooks $parameters = array(); @@ -211,20 +222,32 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters, $obje $sql .= preg_replace('/^,/', '', $hookmanager->resPrint); $sql = preg_replace('/,\s*$/', '', $sql); $sql .= " FROM ".MAIN_DB_PREFIX.$object->table_element." as t"; -if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; -if ($object->ismultientitymanaged == 1) $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; -else $sql .= " WHERE 1 = 1"; -foreach ($search as $key => $val) -{ - if ($key == 'status' && $search[$key] == -1) continue; +if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) { + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (t.rowid = ef.fk_object)"; +} +if ($object->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($object->element).")"; +} else { + $sql .= " WHERE 1 = 1"; +} +foreach ($search as $key => $val) { + if ($key == 'status' && $search[$key] == -1) { + continue; + } $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); if (strpos($object->fields[$key]['type'], 'integer:') === 0) { - if ($search[$key] == '-1') $search[$key] = ''; + if ($search[$key] == '-1') { + $search[$key] = ''; + } $mode_search = 2; } - if ($search[$key] != '') $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + if ($search[$key] != '') { + $sql .= natural_search($key, $search[$key], (($key == 'status') ? 2 : $mode_search)); + } +} +if ($search_all) { + $sql .= natural_search(array_keys($fieldstosearchall), $search_all); } -if ($search_all) $sql .= natural_search(array_keys($fieldstosearchall), $search_all); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -253,26 +276,24 @@ $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; -if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) -{ +if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $resql = $db->query($sql); $nbtotalofrecords = $db->num_rows($resql); - if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 - { + if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0 $page = 0; $offset = 0; } } // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. -if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) -{ +if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) { $num = $nbtotalofrecords; } else { - if ($limit) $sql .= $db->plimit($limit + 1, $offset); + if ($limit) { + $sql .= $db->plimit($limit + 1, $offset); + } $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { dol_print_error($db); exit; } @@ -281,8 +302,7 @@ if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit } // Direct jump if only one record found -if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) -{ +if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $search_all && !$page) { $obj = $db->fetch_object($resql); $id = $obj->rowid; header("Location: ".DOL_URL_ROOT.'/emailcollector/emailcollector_card.php?id='.$id); @@ -313,14 +333,24 @@ jQuery(document).ready(function() { $arrayofselected = is_array($toselect) ? $toselect : array(); $param = ''; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -foreach ($search as $key => $val) -{ - if (is_array($search[$key]) && count($search[$key])) foreach ($search[$key] as $skey) $param .= '&search_'.$key.'[]='.urlencode($skey); - else $param .= '&search_'.$key.'='.urlencode($search[$key]); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +foreach ($search as $key => $val) { + if (is_array($search[$key]) && count($search[$key])) { + foreach ($search[$key] as $skey) { + $param .= '&search_'.$key.'[]='.urlencode($skey); + } + } else { + $param .= '&search_'.$key.'='.urlencode($search[$key]); + } +} +if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); } -if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; @@ -329,12 +359,18 @@ $arrayofmassactions = array( //'presend'=>$langs->trans("SendByMail"), //'builddoc'=>$langs->trans("PDFMerge"), ); -if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); +if ($permissiontodelete) { + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { + $arrayofmassactions = array(); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); print ''; -if ($optioncss != '') print ''; +if ($optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -363,11 +399,13 @@ $moreforfilter.= '
';*/ $parameters = array(); $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook -if (empty($reshook)) $moreforfilter .= $hookmanager->resPrint; -else $moreforfilter = $hookmanager->resPrint; +if (empty($reshook)) { + $moreforfilter .= $hookmanager->resPrint; +} else { + $moreforfilter = $hookmanager->resPrint; +} -if (!empty($moreforfilter)) -{ +if (!empty($moreforfilter)) { print '
'; print $moreforfilter; print '
'; @@ -384,20 +422,26 @@ print ''; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; } } @@ -419,15 +463,18 @@ print ''."\n"; // Fields title label // -------------------------------------------------------------------- print ''; -foreach ($object->fields as $key => $val) -{ +foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') $cssforfield .= ($cssforfield ? ' ' : '').'right'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && $val['label'] != 'TechnicalID') { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } + if (!empty($arrayfields['t.'.$key]['checked'])) { print getTitleFieldOfList($arrayfields['t.'.$key]['label'], 0, $_SERVER['PHP_SELF'], 't.'.$key, '', $param, ($cssforfield ? 'class="'.$cssforfield.'"' : ''), $sortfield, $sortorder, ($cssforfield ? $cssforfield.' ' : ''))."\n"; } } @@ -444,11 +491,11 @@ print ''."\n"; // Detect if we need a fetch on each output line $needToFetchEachLine = 0; -if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) -{ - foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) - { - if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object +if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) { + foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) { + if (preg_match('/\$object/', $val)) { + $needToFetchEachLine++; // There is at least one compute field that use $object + } } } @@ -457,38 +504,51 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co // -------------------------------------------------------------------- $i = 0; $totalarray = array(); -while ($i < ($limit ? min($num, $limit) : $num)) -{ +while ($i < ($limit ? min($num, $limit) : $num)) { $obj = $db->fetch_object($resql); - if (empty($obj)) break; // Should not happen + if (empty($obj)) { + break; // Should not happen + } // Store properties in $object $object->setVarsFromFetchObj($obj); // Show here line of result print ''; - foreach ($object->fields as $key => $val) - { + foreach ($object->fields as $key => $val) { $cssforfield = (empty($val['css']) ? '' : $val['css']); - if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'center'; - elseif ($key == 'status') $cssforfield .= ($cssforfield ? ' ' : '').'center'; + if (in_array($val['type'], array('date', 'datetime', 'timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } elseif ($key == 'status') { + $cssforfield .= ($cssforfield ? ' ' : '').'center'; + } - if (in_array($val['type'], array('timestamp'))) $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; - elseif ($key == 'ref') $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + if (in_array($val['type'], array('timestamp'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } elseif ($key == 'ref') { + $cssforfield .= ($cssforfield ? ' ' : '').'nowrap'; + } - if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) $cssforfield .= ($cssforfield ? ' ' : '').'right'; + if (in_array($val['type'], array('double(24,8)', 'double(6,3)', 'integer', 'real', 'price')) && !in_array($key, array('rowid', 'status'))) { + $cssforfield .= ($cssforfield ? ' ' : '').'right'; + } //if (in_array($key, array('fk_soc', 'fk_user', 'fk_warehouse'))) $cssforfield = 'tdoverflowmax100'; - if (!empty($arrayfields['t.'.$key]['checked'])) - { + if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if ($key == 'status') print $object->getLibStatut(5); - else print $object->showOutputField($val, $key, $object->$key, ''); + if ($key == 'status') { + print $object->getLibStatut(5); + } else { + print $object->showOutputField($val, $key, $object->$key, ''); + } print ''; - if (!$i) $totalarray['nbfield']++; - if (!empty($val['isameasure'])) - { - if (!$i) $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + if (!$i) { + $totalarray['nbfield']++; + } + if (!empty($val['isameasure'])) { + if (!$i) { + $totalarray['pos'][$totalarray['nbfield']] = 't.'.$key; + } $totalarray['val']['t.'.$key] += $object->$key; } } @@ -501,14 +561,17 @@ while ($i < ($limit ? min($num, $limit) : $num)) print $hookmanager->resPrint; // Action column print ''; - if (!$i) $totalarray['nbfield']++; + if (!$i) { + $totalarray['nbfield']++; + } print ''."\n"; @@ -520,10 +583,13 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php'; // If no record found -if ($num == 0) -{ +if ($num == 0) { $colspan = 1; - foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } + foreach ($arrayfields as $key => $val) { + if (!empty($val['checked'])) { + $colspan++; + } + } print ''; } @@ -539,10 +605,11 @@ print ''."\n"; print ''."\n"; -if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) -{ +if (in_array('builddoc', $arrayofmassactions) && ($nbtotalofrecords === '' || $nbtotalofrecords)) { $hidegeneratedfilelistifempty = 1; - if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) $hidegeneratedfilelistifempty = 0; + if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files) { + $hidegeneratedfilelistifempty = 0; + } require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new FormFile($db); diff --git a/htdocs/admin/eventorganization_confbooth_extrafields.php b/htdocs/admin/eventorganization_confbooth_extrafields.php index 349fe33e9cc..4e45b0fddc3 100644 --- a/htdocs/admin/eventorganization_confbooth_extrafields.php +++ b/htdocs/admin/eventorganization_confbooth_extrafields.php @@ -34,13 +34,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'actioncomm'; -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -73,8 +77,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '
'; print "".$langs->trans("NewAttribute").""; print "
"; @@ -84,8 +87,7 @@ if ($action != 'create' && $action != 'edit') /* * Creation of an optional field */ -if ($action == 'create') -{ +if ($action == 'create') { print '
'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -95,8 +97,7 @@ if ($action == 'create') /* * Edition of an optional field */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/events.php b/htdocs/admin/events.php index 66099eb3a30..6216820166e 100644 --- a/htdocs/admin/events.php +++ b/htdocs/admin/events.php @@ -44,7 +44,9 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters +if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -57,17 +59,18 @@ $eventstolog = $securityevent->eventstolog; * Actions */ -if ($action == "save") -{ +if ($action == "save") { $i = 0; $db->begin(); - foreach ($eventstolog as $key => $arr) - { + foreach ($eventstolog as $key => $arr) { $param = 'MAIN_LOGEVENTS_'.$arr['id']; - if (GETPOST($param, 'alphanohtml')) dolibarr_set_const($db, $param, GETPOST($param, 'alphanohtml'), 'chaine', 0, '', $conf->entity); - else dolibarr_del_const($db, $param, $conf->entity); + if (GETPOST($param, 'alphanohtml')) { + dolibarr_set_const($db, $param, GETPOST($param, 'alphanohtml'), 'chaine', 0, '', $conf->entity); + } else { + dolibarr_del_const($db, $param, $conf->entity); + } } $db->commit(); @@ -110,10 +113,8 @@ print getTitleFieldOfList("LogEvents", 0, $_SERVER["PHP_SELF"], '', '', '', '', print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n"; print "\n"; // Loop on each event type -foreach ($eventstolog as $key => $arr) -{ - if ($arr['id']) - { +foreach ($eventstolog as $key => $arr) { + if ($arr['id']) { print ''; print ''; print '\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/expedition/"); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { if (preg_match('/^mod_expedition_([a-z0-9_]*)\.php$/', $file)) { $file = substr($file, 0, dol_strlen($file) - 4); @@ -219,11 +198,14 @@ foreach ($dirmodels as $reldir) $module = new $file; - if ($module->isEnabled()) - { + if ($module->isEnabled()) { // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } print '\n"; print ''."\n"; print '\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ - foreach (array('', '/doc') as $valdir) - { +foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/expedition".$valdir); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -357,21 +332,26 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print ''; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print '"; $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +foreach ($substitutionarray as $key => $val) { + $htmltext .= $key.'
'; +} $htmltext .= '
'; print ''; @@ -629,24 +619,20 @@ print "\n"; print ''; print ""; print "'; // Limit to superadmin /*if (! empty($conf->multicompany->enabled) && !$user->entity) - { - print ''; - print ''; + print ''; @@ -477,18 +506,29 @@ if ($mode == 'searchkey') print ''; print ''; - if ($sortfield == 'transkey' && strtolower($sortorder) == 'asc') ksort($recordtoshow); - if ($sortfield == 'transkey' && strtolower($sortorder) == 'desc') krsort($recordtoshow); - if ($sortfield == 'transvalue' && strtolower($sortorder) == 'asc') asort($recordtoshow); - if ($sortfield == 'transvalue' && strtolower($sortorder) == 'desc') arsort($recordtoshow); + if ($sortfield == 'transkey' && strtolower($sortorder) == 'asc') { + ksort($recordtoshow); + } + if ($sortfield == 'transkey' && strtolower($sortorder) == 'desc') { + krsort($recordtoshow); + } + if ($sortfield == 'transvalue' && strtolower($sortorder) == 'asc') { + asort($recordtoshow); + } + if ($sortfield == 'transvalue' && strtolower($sortorder) == 'desc') { + arsort($recordtoshow); + } // Show result $i = 0; - foreach ($recordtoshow as $key => $val) - { + foreach ($recordtoshow as $key => $val) { $i++; - if ($i <= $offset) continue; - if ($i > ($offset + $limit)) break; + if ($i <= $offset) { + continue; + } + if ($i > ($offset + $limit)) { + break; + } print ''; - }*/ + { + print ''; + }*/ print ''."\n"; } @@ -543,8 +581,7 @@ print dol_get_fiche_end(); print "\n"; -if (!empty($langcode)) -{ +if (!empty($langcode)) { dol_set_focus('#transvalue'); } diff --git a/htdocs/admin/triggers.php b/htdocs/admin/triggers.php index ce7f525e8b3..5ea74205c9c 100644 --- a/htdocs/admin/triggers.php +++ b/htdocs/admin/triggers.php @@ -26,7 +26,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; // Load translation files required by the page $langs->load("admin"); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $sortfield = 'file'; $sortorder = 'ASC'; @@ -66,8 +68,7 @@ print getTitleFieldOfList($langs->trans("Active"), 0, $_SERVER["PHP_SELF"], 'act print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], 'none', "", $param, ($align ? 'align="'.$align.'"' : ''), $sortfield, $sortorder, '', 1)."\n"; print ''; -foreach ($triggers as $trigger) -{ +foreach ($triggers as $trigger) { print ''; print ''; print ''; diff --git a/htdocs/admin/user.php b/htdocs/admin/user.php index ea6cdf2b6f8..0dccf65e5e7 100644 --- a/htdocs/admin/user.php +++ b/htdocs/admin/user.php @@ -35,7 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'members', 'users')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $extrafields = new ExtraFields($db); @@ -54,25 +56,20 @@ $type = 'user'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'set_default') -{ +if ($action == 'set_default') { $ret = addDocumentModel($value, $type, $label, $scandir); $res = true; -} elseif ($action == 'del_default') -{ +} elseif ($action == 'del_default') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->USER_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USER_ADDON_PDF_ODT', $conf->entity); + if ($ret > 0) { + if ($conf->global->USER_ADDON_PDF_ODT == "$value") { + dolibarr_del_const($db, 'USER_ADDON_PDF_ODT', $conf->entity); + } } $res = true; -} - -// Set default model -elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "USER_ADDON_PDF_ODT", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + // Set default model + if (dolibarr_set_const($db, "USER_ADDON_PDF_ODT", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->USER_ADDON_PDF_ODT = $value; @@ -80,39 +77,31 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } $res = true; -} elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) -{ +} elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } -} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) -{ +} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { + if (dolibarr_del_const($db, $code, $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } -} -//Set hide closed customer into combox or select -elseif ($action == 'sethideinactiveuser') -{ +} elseif ($action == 'sethideinactiveuser') { + //Set hide closed customer into combox or select $status = GETPOST('status', 'alpha'); - if (dolibarr_set_const($db, "USER_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) - { + if (dolibarr_set_const($db, "USER_HIDE_INACTIVE_IN_COMBOBOX", $status, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -152,12 +141,10 @@ print ''; print ''; print ''; print ''; print '\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ - foreach (array('', '/doc') as $valdir) - { +foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/user".$valdir); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -256,21 +231,26 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print ''; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print '\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ - foreach (array('', '/doc') as $valdir) - { +foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { $dir = dol_buildpath($reldir."core/modules/usergroup".$valdir); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -185,21 +167,26 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print ''; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print '
'; - if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); - elseif (strpos($val['type'], 'integer:') === 0) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + print $form->selectarray('search_'.$key, $val['arrayofkeyval'], $search[$key], $val['notnull'], 0, 0, '', 1, 0, 0, '', 'maxwidth100', 1); + } elseif (strpos($val['type'], 'integer:') === 0) { print $object->showInputField($val, $key, $search[$key], '', '', 'search_', 'maxwidth150', 1); - } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) print ''; + } elseif (!preg_match('/^(date|timestamp)/', $val['type'])) { + print ''; + } print '
'; - if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined - { + if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined $selected = 0; - if (in_array($object->id, $arrayofselected)) $selected = 1; + if (in_array($object->id, $arrayofselected)) { + $selected = 1; + } print ''; } print '
'.$langs->trans("NoRecordFound").'
'.$arr['id'].''; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 9a09c62b818..8be9aeee0bc 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -37,8 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "sendings", "deliveries", "other")); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); @@ -46,8 +47,7 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'shipping'; -if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) -{ +if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) { $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor'; } @@ -58,43 +58,39 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'updateMask') -{ +if ($action == 'updateMask') { $maskconst = GETPOST('maskconstexpedition', 'alpha'); $maskvalue = GETPOST('maskexpedition', 'alpha'); - if (!empty($maskconst)) + if (!empty($maskconst)) { $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); - - if (isset($res)) - { - if ($res > 0) - setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); - else setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'set_param') -{ + + if (isset($res)) { + if ($res > 0) { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } else { + setEventMessages($langs->trans("Error"), null, 'errors'); + } + } +} elseif ($action == 'set_param') { $freetext = GETPOST('SHIPPING_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if ($res <= 0) - { + if ($res <= 0) { $error++; setEventMessages($langs->trans("Error"), null, 'errors'); } $draft = GETPOST('SHIPPING_DRAFT_WATERMARK', 'alpha'); $res = dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if ($res <= 0) - { + if ($res <= 0) { $error++; setEventMessages($langs->trans("Error"), null, 'errors'); } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } -} elseif ($action == 'specimen') -{ +} elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); $exp = new Expedition($db); @@ -103,25 +99,21 @@ if ($action == 'updateMask') // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); - if ($module->write_file($exp, $langs) > 0) - { + if ($module->write_file($exp, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=expedition&file=SPECIMEN.pdf"); return; } else { @@ -132,26 +124,19 @@ if ($action == 'updateMask') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} - -// Activate a model -elseif ($action == 'set') -{ +} elseif ($action == 'set') { + // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->EXPEDITION_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity); + } } -} - -// Set default model -elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + // Set default model + if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->EXPEDITION_ADDON_PDF = $value; @@ -159,12 +144,10 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } -} elseif ($action == 'setmodel') -{ +} elseif ($action == 'setmodel') { dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER", $value, 'chaine', 0, '', $conf->entity); } @@ -201,17 +184,13 @@ print "
'.$module->name."'; @@ -236,13 +218,15 @@ foreach ($dirmodels as $reldir) if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; + } elseif ($tmp == 'NotConfigured') { + print $langs->trans($tmp); + } else { + print $tmp; + } print '
'; - if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") - { + if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print 'scandir.'&label='.urlencode($module->name).'">'; @@ -261,8 +245,9 @@ foreach ($dirmodels as $reldir) if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { $nextval = $langs->trans($nextval); + } $htmltooltip .= $nextval.'
'; } else { $htmltooltip .= $langs->trans($module->error).'
'; @@ -300,12 +285,10 @@ $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -326,30 +309,22 @@ print "
'; print (empty($module->name) ? $name : $module->name); print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print ''."\n"; print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -385,8 +365,7 @@ foreach ($dirmodels as $reldir) // Defaut print ''; - if ($conf->global->EXPEDITION_ADDON_PDF == $name) - { + if ($conf->global->EXPEDITION_ADDON_PDF == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -396,8 +375,7 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; @@ -413,8 +391,7 @@ foreach ($dirmodels as $reldir) // Preview print '
'; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print 'scandir.'&label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -453,14 +430,15 @@ print "
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'SHIPPING_FREE_TEXT'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) -{ +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/admin/expedition_extrafields.php b/htdocs/admin/expedition_extrafields.php index 901caf58c00..70a9629e1d6 100644 --- a/htdocs/admin/expedition_extrafields.php +++ b/htdocs/admin/expedition_extrafields.php @@ -32,8 +32,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'sendings', 'deliveries')); @@ -45,13 +46,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'expedition'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -84,8 +89,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '"; @@ -98,8 +102,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '
'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -111,8 +114,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/expeditiondet_extrafields.php b/htdocs/admin/expeditiondet_extrafields.php index 6f917618bf2..7df27d0d84b 100644 --- a/htdocs/admin/expeditiondet_extrafields.php +++ b/htdocs/admin/expeditiondet_extrafields.php @@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/expedition.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('admin', 'other', 'sendings')); @@ -46,13 +47,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'expeditiondet'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -85,8 +90,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '"; @@ -99,8 +103,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '
'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -112,8 +115,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/expensereport_extrafields.php b/htdocs/admin/expensereport_extrafields.php index ac88ec78912..716ba5d1a03 100644 --- a/htdocs/admin/expensereport_extrafields.php +++ b/htdocs/admin/expensereport_extrafields.php @@ -30,8 +30,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/expensereport.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'trips', 'other')); @@ -42,13 +43,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'expensereport'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -78,8 +83,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '"; @@ -92,8 +96,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '
'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -105,8 +108,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index 968833b764c..bdaaa5845f3 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -33,7 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php' // Load translation files required by the page $langs->loadLangs(array("admin", "trips", "errors", "other", "dict")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $error = 0; @@ -45,13 +47,13 @@ $coef = GETPOST('coef', 'int'); $fk_c_exp_tax_cat = GETPOST('fk_c_exp_tax_cat'); $fk_range = GETPOST('fk_range'); -if ($action == 'updateik') -{ +if ($action == 'updateik') { $expIk = new ExpenseReportIk($db); - if ($id > 0) - { + if ($id > 0) { $result = $expIk->fetch($id); - if ($result < 0) dol_print_error('', $expIk->error, $expIk->errors); + if ($result < 0) { + dol_print_error('', $expIk->error, $expIk->errors); + } } $expIk->setValues($_POST); @@ -64,13 +66,13 @@ if ($action == 'updateik') } else { setEventMessages($expIk->error, $expIk->errors, 'errors'); } -} elseif ($action == 'delete') // TODO add confirm -{ +} elseif ($action == 'delete') { // TODO add confirm $expIk = new ExpenseReportIk($db); - if ($id > 0) - { + if ($id > 0) { $result = $expIk->fetch($id); - if ($result < 0) dol_print_error('', $expIk->error, $expIk->errors); + if ($result < 0) { + dol_print_error('', $expIk->error, $expIk->errors); + } $expIk->delete($user); } @@ -102,8 +104,7 @@ print '

'; echo '
'; -if ($action == 'edit') -{ +if ($action == 'edit') { echo ''; echo ''; echo ''; @@ -114,8 +115,7 @@ echo ''; echo ''; -foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) -{ +foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) { $title = ($Tab['active'] == 1) ? $langs->trans($Tab['label']) : $form->textwithpicto($langs->trans($Tab['label']), $langs->trans('expenseReportCatDisabled'), 1, 'help', '', 0, 3); echo ''; echo ''; @@ -125,16 +125,22 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) echo ''; echo ''; - if ($Tab['active'] == 0) continue; + if ($Tab['active'] == 0) { + continue; + } $tranche = 1; - foreach ($Tab['ranges'] as $k => $range) - { - if (isset($Tab['ranges'][$k + 1])) $label = $langs->trans('expenseReportRangeFromTo', $range->range_ik, ($Tab['ranges'][$k + 1]->range_ik - 1)); - else $label = $langs->trans('expenseReportRangeMoreThan', $range->range_ik); + foreach ($Tab['ranges'] as $k => $range) { + if (isset($Tab['ranges'][$k + 1])) { + $label = $langs->trans('expenseReportRangeFromTo', $range->range_ik, ($Tab['ranges'][$k + 1]->range_ik - 1)); + } else { + $label = $langs->trans('expenseReportRangeMoreThan', $range->range_ik); + } - if ($range->range_active == 0) $label = $form->textwithpicto($label, $langs->trans('expenseReportRangeDisabled'), 1, 'help', '', 0, 3); + if ($range->range_active == 0) { + $label = $form->textwithpicto($label, $langs->trans('expenseReportRangeDisabled'), 1, 'help', '', 0, 3); + } echo ''; @@ -143,15 +149,19 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) // Offset echo ''; // Coef echo ''; // Total for one @@ -159,15 +169,15 @@ foreach ($rangesbycateg as $fk_c_exp_tax_cat => $Tab) // Action echo ''; print ""; print ""; print ''."\n"; // Logo - if ($result > 0 && empty($rss->error)) - { + if ($result > 0 && empty($rss->error)) { print ''; print ""; print ''; print ''."\n"; } @@ -336,10 +334,8 @@ $db->close(); */ function _isInBoxList($idrss, array $boxlist) { - foreach ($boxlist as $box) - { - if ($box->boxcode === "lastrssinfos" && strpos($box->note, $idrss) !== false) - { + foreach ($boxlist as $box) { + if ($box->boxcode === "lastrssinfos" && strpos($box->note, $idrss) !== false) { return true; } } diff --git a/htdocs/admin/facture.php b/htdocs/admin/facture.php index c5b8262c4be..a16df0d7fc4 100644 --- a/htdocs/admin/facture.php +++ b/htdocs/admin/facture.php @@ -36,7 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'other', 'bills')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); @@ -51,8 +53,7 @@ $type = 'invoice'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'updateMask') -{ +if ($action == 'updateMask') { $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha'); $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha'); $maskconstcredit = GETPOST('maskconstcredit', 'alpha'); @@ -61,21 +62,29 @@ if ($action == 'updateMask') $maskreplacement = GETPOST('maskreplacement', 'alpha'); $maskcredit = GETPOST('maskcredit', 'alpha'); $maskdeposit = GETPOST('maskdeposit', 'alpha'); - if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); - if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); - if ($maskconstcredit) $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); - if ($maskconstdeposit) $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); + if ($maskconstinvoice) { + $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity); + } + if ($maskconstreplacement) { + $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity); + } + if ($maskconstcredit) { + $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity); + } + if ($maskconstdeposit) { + $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity); + } - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') -{ +} elseif ($action == 'specimen') { $modele = GETPOST('module', 'alpha'); $facture = new Facture($db); @@ -84,25 +93,21 @@ if ($action == 'updateMask') // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); - if ($module->write_file($facture, $langs) > 0) - { + if ($module->write_file($facture, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf"); return; } else { @@ -113,24 +118,19 @@ if ($action == 'updateMask') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} -// Activate a model -elseif ($action == 'set') -{ +} elseif ($action == 'set') { + // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->FACTURE_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity); + } } -} -// Set default model -elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "FACTURE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + // Set default model + if (dolibarr_set_const($db, "FACTURE_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->FACTURE_ADDON_PDF = $value; @@ -138,90 +138,86 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } -} elseif ($action == 'setmod') -{ +} elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity); -} elseif ($action == 'setribchq') -{ +} elseif ($action == 'setribchq') { $rib = GETPOST('rib', 'alpha'); $chq = GETPOST('chq', 'alpha'); $res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity); $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') -{ +} elseif ($action == 'set_FACTURE_DRAFT_WATERMARK') { $draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha'); $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'set_INVOICE_FREE_TEXT') -{ +} elseif ($action == 'set_INVOICE_FREE_TEXT') { $freetext = GETPOST('INVOICE_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'setforcedate') -{ +} elseif ($action == 'setforcedate') { $forcedate = GETPOST('forcedate', 'alpha'); $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'setDefaultPDFModulesByType') -{ +} elseif ($action == 'setDefaultPDFModulesByType') { $invoicetypemodels = GETPOST('invoicetypemodels'); - if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) - { + if (!empty($invoicetypemodels) && is_array($invoicetypemodels)) { $error = 0; - foreach ($invoicetypemodels as $type => $value) - { + foreach ($invoicetypemodels as $type => $value) { $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -264,44 +260,42 @@ print ''."\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/facture/"); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')) { $filebis = $file; $classname = preg_replace('/\.php$/', '', $file); // For compatibility - if (!is_file($dir.$filebis)) - { + if (!is_file($dir.$filebis)) { $filebis = $file."/".$file.".modules.php"; $classname = "mod_facture_".$file; } // Check if there is a filter on country preg_match('/\-(.*)_(.*)$/', $classname, $reg); - if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue; + if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) { + continue; + } $classname = preg_replace('/\-.*$/', '', $classname); - if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') - { + if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php') { // Charging the numbering class require_once $dir.$filebis; $module = new $classname($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } - if ($module->isEnabled()) - { + if ($module->isEnabled()) { print ''."\n"; print ''; @@ -426,12 +427,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -454,31 +453,23 @@ clearstatcache(); $activatedModels = array(); -foreach ($dirmodels as $reldir) -{ - foreach (array('', '/doc') as $valdir) - { +foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { $realpath = $reldir."core/modules/facture".$valdir; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -486,21 +477,26 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print ''; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print '
'.$title.' 
'; - if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; - else { + if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) { + echo ''; + } else { echo $range->ik->ikoffset; } echo ''; - if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) echo ''; - else echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined')); + if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) { + echo ''; + } else { + echo ($range->ik->id > 0 ? $range->ik->coef : $langs->trans('expenseReportCoefUndefined')); + } echo ''; - if ($range->range_active == 1) - { - if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) - { + if ($range->range_active == 1) { + if ($action == 'edit' && $range->ik->id == $id && $range->rowid == $fk_range && $range->fk_c_exp_tax_cat == $fk_c_exp_tax_cat) { echo ''; echo ''; } else { echo ''.img_edit().''; - if (!empty($range->ik->id)) echo ''.img_delete().''; + if (!empty($range->ik->id)) { + echo ''.img_delete().''; + } // TODO add delete link } } diff --git a/htdocs/admin/export.php b/htdocs/admin/export.php index 5dd541b34b5..b83b15571b8 100644 --- a/htdocs/admin/export.php +++ b/htdocs/admin/export.php @@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'exports', 'other')); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); diff --git a/htdocs/admin/external_rss.php b/htdocs/admin/external_rss.php index 48db3ee4429..bbb0f212707 100644 --- a/htdocs/admin/external_rss.php +++ b/htdocs/admin/external_rss.php @@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; $langs->load("admin"); // Security check -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $def = array(); $lastexternalrss = 0; @@ -53,59 +55,56 @@ $sql = "SELECT ".$db->decrypt('name')." as name FROM ".MAIN_DB_PREFIX."const"; $sql .= " WHERE ".$db->decrypt('name')." LIKE 'EXTERNAL_RSS_URLRSS_%'"; //print $sql; $result = $db->query($sql); // We can't use SELECT MAX() because EXTERNAL_RSS_URLRSS_10 is lower than EXTERNAL_RSS_URLRSS_9 -if ($result) -{ - while ($obj = $db->fetch_object($result)) - { +if ($result) { + while ($obj = $db->fetch_object($result)) { preg_match('/([0-9]+)$/i', $obj->name, $reg); - if ($reg[1] && $reg[1] > $lastexternalrss) $lastexternalrss = $reg[1]; + if ($reg[1] && $reg[1] > $lastexternalrss) { + $lastexternalrss = $reg[1]; + } } } else { dol_print_error($db); } -if ($action == 'add' || GETPOST("modify")) -{ +if ($action == 'add' || GETPOST("modify")) { $external_rss_title = "external_rss_title_".GETPOST("norss", 'int'); $external_rss_urlrss = "external_rss_urlrss_".GETPOST("norss", 'int'); - if (!empty($_POST[$external_rss_urlrss])) - { + if (!empty($_POST[$external_rss_urlrss])) { $boxlabel = '(ExternalRSSInformations)'; //$external_rss_url = "external_rss_url_" . $_POST["norss"]; $db->begin(); - if ($_POST["modify"]) - { + if ($_POST["modify"]) { // Supprime boite box_external_rss de definition des boites /* $sql = "UPDATE ".MAIN_DB_PREFIX."boxes_def"; $sql.= " SET name = '".$db->escape($boxlabel)."'"; - $sql.= " WHERE file ='box_external_rss.php' AND note like '".$db->escape($_POST["norss"])." %'"; + $sql.= " WHERE file ='box_external_rss.php' AND note like '".$db->escape($_POST["norss"])." %'"; $resql=$db->query($sql); if (! $resql) - { + { dol_print_error($db,"sql=$sql"); exit; - } - */ + } + */ } else { // Ajoute boite box_external_rss dans definition des boites $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)"; $sql .= " VALUES ('box_external_rss.php','".$db->escape(GETPOST("norss", 'int').' ('.GETPOST($external_rss_title, 'alpha')).")')"; - if (!$db->query($sql)) - { + if (!$db->query($sql)) { dol_print_error($db); $err++; } } $result1 = dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), GETPOST($external_rss_title, 'alpha'), 'chaine', 0, '', $conf->entity); - if ($result1) $result2 = dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), GETPOST($external_rss_urlrss, 'alpha'), 'chaine', 0, '', $conf->entity); + if ($result1) { + $result2 = dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), GETPOST($external_rss_urlrss, 'alpha'), 'chaine', 0, '', $conf->entity); + } - if ($result1 && $result2) - { + if ($result1 && $result2) { $db->commit(); header("Location: ".$_SERVER["PHP_SELF"]); exit; @@ -116,10 +115,8 @@ if ($action == 'add' || GETPOST("modify")) } } -if ($_POST["delete"]) -{ - if (GETPOST("norss", 'int')) - { +if ($_POST["delete"]) { + if (GETPOST("norss", 'int')) { $db->begin(); // Supprime boite box_external_rss de definition des boites @@ -127,12 +124,10 @@ if ($_POST["delete"]) $sql .= " WHERE file = 'box_external_rss.php' AND note LIKE '".$db->escape(GETPOST("norss", 'int'))." %'"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes"; @@ -144,8 +139,7 @@ if ($_POST["delete"]) $sql .= " WHERE rowid = ".$obj->rowid; $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { $db->rollback(); dol_print_error($db, "sql=".$sql); exit; @@ -163,10 +157,11 @@ if ($_POST["delete"]) $result1 = dolibarr_del_const($db, "EXTERNAL_RSS_TITLE_".GETPOST("norss", 'int'), $conf->entity); - if ($result1) $result2 = dolibarr_del_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), $conf->entity); + if ($result1) { + $result2 = dolibarr_del_const($db, "EXTERNAL_RSS_URLRSS_".GETPOST("norss", 'int'), $conf->entity); + } - if ($result1 && $result2) - { + if ($result1 && $result2) { $db->commit(); header("Location: external_rss.php"); exit; @@ -228,14 +223,12 @@ $sql .= " ORDER BY note"; dol_syslog("select rss boxes", LOG_DEBUG); $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $boxlist = InfoBox::listBoxes($db, 'activated', -1, null); $num = $db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); preg_match('/^([0-9]+)/i', $obj->note, $reg); @@ -279,29 +272,34 @@ if ($resql) print '
".$langs->trans("Status").""; - if ($result > 0 && empty($rss->error)) - { + if ($result > 0 && empty($rss->error)) { print ''.$langs->trans("Online").''; } else { print ''.$langs->trans("Offline"); $langs->load("errors"); - if ($rssparser->error) print ' - '.$langs->trans($rssparser->error); + if ($rssparser->error) { + print ' - '.$langs->trans($rssparser->error); + } print ''; } print "
".$langs->trans("Logo")."'; $imageurl = $rssparser->getImageUrl(); $linkrss = $rssparser->getLink(); - if (!preg_match('/^http/', $imageurl)) $imageurl = $linkrss.$imageurl; - if ($imageurl) print ''; - else print $langs->trans("None"); + if (!preg_match('/^http/', $imageurl)) { + $imageurl = $linkrss.$imageurl; + } + if ($imageurl) { + print ''; + } else { + print $langs->trans("None"); + } print '
'; echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file))); print "\n"; @@ -316,14 +310,16 @@ foreach ($dirmodels as $reldir) if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; + } elseif ($tmp == 'NotConfigured') { + print $langs->trans($tmp); + } else { + print $tmp; + } print '
'; //print "> ".$conf->global->FACTURE_ADDON." - ".$file; - if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file) - { + if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; @@ -341,8 +337,9 @@ foreach ($dirmodels as $reldir) if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= $langs->trans("NextValueForInvoices").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { $nextval = $langs->trans($nextval); + } $htmltooltip .= $nextval.'
'; } else { $htmltooltip .= $langs->trans($module->error).'
'; @@ -354,8 +351,9 @@ foreach ($dirmodels as $reldir) if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= $langs->trans("NextValueForReplacements").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { $nextval = $langs->trans($nextval); + } $htmltooltip .= $nextval.'
'; } else { $htmltooltip .= $langs->trans($module->error).'
'; @@ -368,8 +366,9 @@ foreach ($dirmodels as $reldir) if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= $langs->trans("NextValueForCreditNotes").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { $nextval = $langs->trans($nextval); + } $htmltooltip .= $nextval.'
'; } else { $htmltooltip .= $langs->trans($module->error).'
'; @@ -381,8 +380,9 @@ foreach ($dirmodels as $reldir) if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= $langs->trans("NextValueForDeposit").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { $nextval = $langs->trans($nextval); + } $htmltooltip .= $nextval; } else { $htmltooltip .= $langs->trans($module->error); @@ -392,9 +392,10 @@ foreach ($dirmodels as $reldir) print '
'; print $form->textwithpicto('', $htmltooltip, 1, 0); - if ($conf->global->FACTURE_ADDON.'.php' == $file) // If module is the one used, we show existing errors - { - if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1); + if ($conf->global->FACTURE_ADDON.'.php' == $file) { // If module is the one used, we show existing errors + if (!empty($module->error)) { + dol_htmloutput_mesg($module->error, '', 'error', 1); + } } print '
'; print (empty($module->name) ? $name : $module->name); print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print ''."\n"; print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -514,8 +510,7 @@ foreach ($dirmodels as $reldir) // Defaut print ''; - if ($conf->global->FACTURE_ADDON_PDF == "$name") - { + if ($conf->global->FACTURE_ADDON_PDF == "$name") { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').''; @@ -525,8 +520,7 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; @@ -547,8 +541,7 @@ foreach ($dirmodels as $reldir) // Preview print '
'; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -566,11 +559,10 @@ foreach ($dirmodels as $reldir) } print '
'; -if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf -{ +if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) { // Hidden conf /* - * Document templates generators - */ + * Document templates generators + */ print '
'; print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', ''); print ''; @@ -589,13 +581,11 @@ if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"), Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"), ); - if (!empty($conf->global->INVOICE_USE_SITUATION)) - { + if (!empty($conf->global->INVOICE_USE_SITUATION)) { $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation"); } - foreach ($listtype as $type => $trans) - { + foreach ($listtype as $type => $trans) { $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type; $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF; print '
".$langs->trans("SuggestPaymentByRIBOnAccount").""; -if (!empty($conf->banque->enabled)) -{ +if (!empty($conf->banque->enabled)) { $sql = "SELECT rowid, label"; $sql .= " FROM ".MAIN_DB_PREFIX."bank_account"; $sql .= " WHERE clos = 0"; $sql .= " AND courant = 1"; $sql .= " AND entity IN (".getEntity('bank_account').")"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num > 0) - { + if ($num > 0) { print ''; print '
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'INVOICE_FREE_TEXT'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) -{ +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/admin/facture_situation.php b/htdocs/admin/facture_situation.php index 364297712e7..ffe1680c80f 100644 --- a/htdocs/admin/facture_situation.php +++ b/htdocs/admin/facture_situation.php @@ -36,7 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'other', 'bills')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); @@ -60,7 +62,8 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); llxHeader( - "", $langs->trans("BillsSetup"), + "", + $langs->trans("BillsSetup"), 'EN:Invoice_Configuration|FR:Configuration_module_facture|ES:ConfiguracionFactura' ); diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index 6523ec833b3..0671783615c 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -41,7 +41,9 @@ $action = GETPOST('action', 'aZ09'); // Full (not sure this one is used) $mode = GETPOST('mode') ?GETPOST('mode', 'alpha') : 'dolibarr_notes'; -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Constant and translation of the module description $modules = array( @@ -86,29 +88,24 @@ $picto = array( * Actions */ -foreach ($modules as $const => $desc) -{ - if ($action == 'activate_'.strtolower($const)) - { +foreach ($modules as $const => $desc) { + if ($action == 'activate_'.strtolower($const)) { dolibarr_set_const($db, "FCKEDITOR_ENABLE_".$const, "1", 'chaine', 0, '', $conf->entity); // If fckeditor is active in the product/service description, it is activated in the forms - if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM)) - { + if ($const == 'PRODUCTDESC' && !empty($conf->global->PRODUIT_DESC_IN_FORM)) { dolibarr_set_const($db, "FCKEDITOR_ENABLE_DETAILS", "1", 'chaine', 0, '', $conf->entity); } header("Location: ".$_SERVER["PHP_SELF"]); exit; } - if ($action == 'disable_'.strtolower($const)) - { + if ($action == 'disable_'.strtolower($const)) { dolibarr_del_const($db, "FCKEDITOR_ENABLE_".$const, $conf->entity); header("Location: ".$_SERVER["PHP_SELF"]); exit; } } -if (GETPOST('save', 'alpha')) -{ +if (GETPOST('save', 'alpha')) { $error = 0; $fckeditor_skin = GETPOST('fckeditor_skin', 'alpha'); @@ -129,8 +126,7 @@ if (GETPOST('save', 'alpha')) $error++; } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -147,8 +143,7 @@ $linkback = ''; -if (empty($conf->use_javascript_ajax)) -{ +if (empty($conf->use_javascript_ajax)) { setEventMessages(array($langs->trans("NotAvailable"), $langs->trans("JavascriptDisabled")), null, 'errors'); } else { print ''; @@ -158,10 +153,11 @@ if (empty($conf->use_javascript_ajax)) print "\n"; // Modules - foreach ($modules as $const => $desc) - { + foreach ($modules as $const => $desc) { // If this condition is not met, the option is not offered - if (!$conditions[$const]) continue; + if (!$conditions[$const]) { + continue; + } print ''; print ''; @@ -169,11 +165,9 @@ if (empty($conf->use_javascript_ajax)) print '\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/fichinter/"); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/^(mod_.*)\.php$/i', $file, $reg)) { $file = $reg[1]; $classname = substr($file, 4); @@ -277,11 +262,14 @@ foreach ($dirmodels as $reldir) $module = new $file; - if ($module->isEnabled()) - { + if ($module->isEnabled()) { // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } print ''."\n"; print '\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { $realpath = $reldir."core/modules/fichinter/doc"; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -411,21 +393,26 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print ''; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print "\n"; $substitutionarray = pdf_getSubstitutionArray($langs, null, null, 2); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +foreach ($substitutionarray as $key => $val) { + $htmltext .= $key.'
'; +} $htmltext .= '
'; print ''; @@ -509,8 +496,7 @@ print ''; print ''; print ''; print ''; print '\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ +foreach ($dirmodels as $reldir) { $dir = dol_buildpath($reldir."core/modules/holiday/"); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { - if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file) - 3, 3) == 'php') - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file) - 3, 3) == 'php') { $file = substr($file, 0, dol_strlen($file) - 4); require_once $dir.$file.'.php'; @@ -217,11 +201,14 @@ foreach ($dirmodels as $reldir) $module = new $file($db); // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + continue; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + continue; + } - if ($module->isEnabled()) - { + if ($module->isEnabled()) { print ''; @@ -232,13 +219,15 @@ foreach ($dirmodels as $reldir) if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; + } elseif ($tmp == 'NotConfigured') { + print $langs->trans($tmp); + } else { + print $tmp; + } print ''."\n"; print '\n"; clearstatcache(); -foreach ($dirmodels as $reldir) -{ - foreach (array('', '/doc') as $valdir) - { +foreach ($dirmodels as $reldir) { + foreach (array('', '/doc') as $valdir) { $realpath = $reldir."core/modules/holiday".$valdir; $dir = dol_buildpath($realpath); - if (is_dir($dir)) - { + if (is_dir($dir)) { $handle = opendir($dir); - if (is_resource($handle)) - { - while (($file = readdir($handle)) !== false) - { + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { $filelist[] = $file; } closedir($handle); arsort($filelist); - foreach ($filelist as $file) - { - if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) - { - if (file_exists($dir.'/'.$file)) - { + foreach ($filelist as $file) { + if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) { + if (file_exists($dir.'/'.$file)) { $name = substr($file, 4, dol_strlen($file) - 16); $classname = substr($file, 0, dol_strlen($file) - 12); @@ -365,21 +345,26 @@ foreach ($dirmodels as $reldir) $module = new $classname($db); $modulequalified = 1; - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) { + $modulequalified = 0; + } + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) { + $modulequalified = 0; + } - if ($modulequalified) - { + if ($modulequalified) { print ''; // Active - if (in_array($name, $def)) - { + if (in_array($name, $def)) { print '\n"; $substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); $substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation"); $htmltext = ''.$langs->trans("AvailableVariables").':
'; -foreach ($substitutionarray as $key => $val) $htmltext .= $key.'
'; +foreach ($substitutionarray as $key => $val) { + $htmltext .= $key.'
'; +} $htmltext .= '
'; print ''."\n"; print ''; // Synchro contact active -if (!empty($conf->societe->enabled)) -{ +if (!empty($conf->societe->enabled)) { print ''; // Port print ''; // Pass print ''; print ''; print "\n"; -foreach ($list as $key) -{ +foreach ($list as $key) { print ''; // Param @@ -102,8 +104,7 @@ foreach ($list as $key) // Value print ''; - if (!empty($arrayfields['e.user_agent']['checked'])) - { + if (!empty($arrayfields['e.user_agent']['checked'])) { print ''; } - if (!empty($arrayfields['e.prefix_session']['checked'])) - { + if (!empty($arrayfields['e.prefix_session']['checked'])) { print ''; @@ -312,19 +361,16 @@ if ($result) print_liste_field_titre("IP", $_SERVER["PHP_SELF"], "e.ip", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("User", $_SERVER["PHP_SELF"], "u.login", "", $param, '', $sortfield, $sortorder); print_liste_field_titre("Description", $_SERVER["PHP_SELF"], "e.description", "", $param, '', $sortfield, $sortorder); - if (!empty($arrayfields['e.user_agent']['checked'])) - { + if (!empty($arrayfields['e.user_agent']['checked'])) { print_liste_field_titre("UserAgent", $_SERVER["PHP_SELF"], "e.user_agent", "", $param, '', $sortfield, $sortorder); } - if (!empty($arrayfields['e.prefix_session']['checked'])) - { + if (!empty($arrayfields['e.prefix_session']['checked'])) { print_liste_field_titre("PrefixSession", $_SERVER["PHP_SELF"], "e.prefix_session", "", $param, '', $sortfield, $sortorder); } print_liste_field_titre(''); print "\n"; - while ($i < min($num, $limit)) - { + while ($i < min($num, $limit)) { $obj = $db->fetch_object($result); print ''; @@ -342,8 +388,7 @@ if ($result) // Login print ''; // Description print ''; - if (!empty($arrayfields['e.user_agent']['checked'])) - { + if (!empty($arrayfields['e.user_agent']['checked'])) { // User agent print ''; } - if (!empty($arrayfields['e.prefix_session']['checked'])) - { + if (!empty($arrayfields['e.prefix_session']['checked'])) { // User agent print ''; - else print ''; + if ($num == 0) { + if ($usefilter) { + print ''; + } else { + print ''; + } } print "
'.img_object("", $picto[$const]).''; $constante = 'FCKEDITOR_ENABLE_'.$const; $value = (isset($conf->global->$constante) ? $conf->global->$constante : 0); - if ($value == 0) - { + if ($value == 0) { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; - } elseif ($value == 1) - { + } elseif ($value == 1) { print ''.img_picto($langs->trans("Enabled"), 'switch_on').''; } @@ -194,20 +188,24 @@ if (empty($conf->use_javascript_ajax)) $listofmodes = array('dolibarr_mailings', 'dolibarr_notes', 'dolibarr_details', 'dolibarr_readonly', 'Full', 'Full_inline'); $linkstomode = ''; - foreach ($listofmodes as $newmode) - { - if ($linkstomode) $linkstomode .= ' - '; + foreach ($listofmodes as $newmode) { + if ($linkstomode) { + $linkstomode .= ' - '; + } $linkstomode .= ''; - if ($mode == $newmode) $linkstomode .= ''; + if ($mode == $newmode) { + $linkstomode .= ''; + } $linkstomode .= $newmode; - if ($mode == $newmode) $linkstomode .= ''; + if ($mode == $newmode) { + $linkstomode .= ''; + } $linkstomode .= ''; } $linkstomode .= ''; print load_fiche_titre($langs->trans("TestSubmitForm"), $linkstomode, ''); print ''; - if ($mode != 'Full_inline') - { + if ($mode != 'Full_inline') { $uselocalbrowser = true; $readonly = ($mode == 'dolibarr_readonly' ? 1 : 0); $editor = new DolEditor('formtestfield', isset($conf->global->FCKEDITOR_TEST) ? $conf->global->FCKEDITOR_TEST : 'Test', '', 200, $mode, 'In', true, $uselocalbrowser, 1, 120, 8, $readonly); @@ -224,20 +222,20 @@ if (empty($conf->use_javascript_ajax)) // Add env of ckeditor // This is to show how CKEditor detect browser to understand why editor is disabled or not. To help debug. /* - print '
'; - } - */ + jsdump(CKEDITOR.env, "divforlog"); + '; + } + */ } // End of page diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index afe6bc2239c..b0dcf2f39c4 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -37,7 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'interventions', 'other')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); @@ -52,22 +54,23 @@ $type = 'ficheinter'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'updateMask') -{ +if ($action == 'updateMask') { $maskconst = GETPOST('maskconst', 'alpha'); $maskvalue = GETPOST('maskvalue', 'alpha'); - if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + if ($maskconst) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + } - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') // For fiche inter -{ +} elseif ($action == 'specimen') { // For fiche inter $modele = GETPOST('module', 'alpha'); $inter = new Fichinter($db); @@ -76,25 +79,21 @@ if ($action == 'updateMask') // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/fichinter/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); - if ($module->write_file($inter, $langs) > 0) - { + if ($module->write_file($inter, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=ficheinter&file=SPECIMEN.pdf"); return; } else { @@ -105,26 +104,19 @@ if ($action == 'updateMask') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} - -// Activate a model -elseif ($action == 'set') -{ +} elseif ($action == 'set') { + // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->FICHEINTER_ADDON_PDF == "$value") dolibarr_del_const($db, 'FICHEINTER_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->FICHEINTER_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'FICHEINTER_ADDON_PDF', $conf->entity); + } } -} - -// Set default model -elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + // Set default model + if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->FICHEINTER_ADDON_PDF = $value; @@ -132,51 +124,49 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } -} elseif ($action == 'setmod') -{ +} elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated dolibarr_set_const($db, "FICHEINTER_ADDON", $value, 'chaine', 0, '', $conf->entity); -} elseif ($action == 'set_FICHINTER_FREE_TEXT') -{ +} elseif ($action == 'set_FICHINTER_FREE_TEXT') { $freetext = GETPOST('FICHINTER_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'set_FICHINTER_DRAFT_WATERMARK') -{ +} elseif ($action == 'set_FICHINTER_DRAFT_WATERMARK') { $draft = GETPOST('FICHINTER_DRAFT_WATERMARK', 'alpha'); $res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS') -{ +} elseif ($action == 'set_FICHINTER_PRINT_PRODUCTS') { $val = GETPOST('FICHINTER_PRINT_PRODUCTS', 'alpha'); $res = dolibarr_set_const($db, "FICHINTER_PRINT_PRODUCTS", ($val == 'on' ? 1 : 0), 'bool', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -257,19 +247,14 @@ print "
'.$module->nom."\n"; @@ -294,13 +282,15 @@ foreach ($dirmodels as $reldir) if (preg_match('/^Error/', $tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; - } elseif ($tmp == 'NotConfigured') print $langs->trans($tmp); - else print $tmp; + } elseif ($tmp == 'NotConfigured') { + print $langs->trans($tmp); + } else { + print $tmp; + } print '
'; - if ($conf->global->FICHEINTER_ADDON == $classname) - { + if ($conf->global->FICHEINTER_ADDON == $classname) { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''.img_picto($langs->trans("Disabled"), 'switch_off').''; @@ -317,8 +307,9 @@ foreach ($dirmodels as $reldir) if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { $nextval = $langs->trans($nextval); + } $htmltooltip .= $nextval.'
'; } else { $htmltooltip .= $langs->trans($module->error).'
'; @@ -354,12 +345,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -381,29 +370,22 @@ print "
'; print (empty($module->name) ? $name : $module->name); print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print '\n"; print 'scandir.'&label='.urlencode($module->name).'">'; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -439,8 +426,7 @@ foreach ($dirmodels as $reldir) // Default print ""; - if ($conf->global->FICHEINTER_ADDON_PDF == "$name") - { + if ($conf->global->FICHEINTER_ADDON_PDF == "$name") { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -465,8 +451,7 @@ foreach ($dirmodels as $reldir) // Preview print ''; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -500,7 +485,9 @@ print "
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnInterventions"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'
'; $variablename = 'FICHINTER_FREE_TEXT'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) -{ +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -541,8 +527,9 @@ print '' print '
'; print $langs->trans("PrintProductsOnFichinter").' ('.$langs->trans("PrintProductsOnFichinterDetails").')global->FICHINTER_PRINT_PRODUCTS) +if ($conf->global->FICHINTER_PRINT_PRODUCTS) { print 'checked '; +} print '/>'; print ''; print ''; diff --git a/htdocs/admin/geoipmaxmind.php b/htdocs/admin/geoipmaxmind.php index 63d15169da2..109bd6b388d 100644 --- a/htdocs/admin/geoipmaxmind.php +++ b/htdocs/admin/geoipmaxmind.php @@ -28,8 +28,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/dolgeoip.class.php'; // Security check -if (!$user->admin) -accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array("admin", "errors")); @@ -41,8 +42,7 @@ $action = GETPOST('action', 'aZ09'); * Actions */ -if ($action == 'set') -{ +if ($action == 'set') { $error = 0; $gimcdf = GETPOST("GEOIPMAXMIND_COUNTRY_DATAFILE"); @@ -52,22 +52,23 @@ if ($action == 'set') $error++; } - if (!$error && $gimcdf && !file_exists($gimcdf)) - { + if (!$error && $gimcdf && !file_exists($gimcdf)) { setEventMessages($langs->trans("ErrorFileNotFound", $gimcdf), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $res1 = dolibarr_set_const($db, "GEOIP_VERSION", GETPOST('geoipversion', 'aZ09'), 'chaine', 0, '', $conf->entity); - if (!$res1 > 0) $error++; + if (!$res1 > 0) { + $error++; + } $res2 = dolibarr_set_const($db, "GEOIPMAXMIND_COUNTRY_DATAFILE", $gimcdf, 'chaine', 0, '', $conf->entity); - if (!$res2 > 0) $error++; + if (!$res2 > 0) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -75,7 +76,9 @@ if ($action == 'set') } } -if (!isset($conf->global->GEOIP_VERSION)) $conf->global->GEOIP_VERSION = '2'; +if (!isset($conf->global->GEOIP_VERSION)) { + $conf->global->GEOIP_VERSION = '2'; +} /* @@ -92,8 +95,7 @@ print '
'; $version = ''; $geoip = ''; -if (!empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) -{ +if (!empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) { $geoip = new DolGeoIP('country', $conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE); } @@ -113,11 +115,11 @@ print '
'.$langs->trans("GeoIPLibVersion").'< print ''; $arrayofvalues = array('php' => 'Native PHP functions', '1' => 'Embedded GeoIP v1', '2' => 'Embedded GeoIP v2'); print $form->selectarray('geoipversion', $arrayofvalues, (isset($conf->global->GEOIP_VERSION) ? $conf->global->GEOIP_VERSION : '2')); -if ($conf->global->GEOIP_VERSION == 'php') -{ - if ($geoip) $version = $geoip->getVersion(); - if ($version) - { +if ($conf->global->GEOIP_VERSION == 'php') { + if ($geoip) { + $version = $geoip->getVersion(); + } + if ($version) { print '
'.$langs->trans("Version").': '.$version; } } @@ -127,8 +129,7 @@ print '
'.$langs->trans("PathToGeoIPMaxmindCountryDataFile").''; -if ($conf->global->GEOIP_VERSION == 'php') -{ +if ($conf->global->GEOIP_VERSION == 'php') { print 'Using geoip PHP internal functions. Value must be '.geoip_db_filename(GEOIP_COUNTRY_EDITION).' or '.geoip_db_filename(GEOIP_CITY_EDITION_REV1).' or /pathtodatafile/GeoLite2-Country.mmdb
'; } print ''; @@ -150,22 +151,27 @@ print '
'; $url2 = 'http://www.maxmind.com/en/city?rId=awstats'; print $langs->trans("YouCanDownloadAdvancedDatFileTo", ''.$url2.''); -if ($geoip) -{ +if ($geoip) { print '

'; print '
'.$langs->trans("TestGeoIPResult", $ip).':'; $ip = '24.24.24.24'; print '
'.$ip.' -> '; $result = dol_print_ip($ip, 1); - if ($result) print $result; - else print $langs->trans("Error"); + if ($result) { + print $result; + } else { + print $langs->trans("Error"); + } $ip = '2a01:e0a:7e:4a60:429a:23ff:f7b8:dc8a'; // should be France print '
'.$ip.' -> '; $result = dol_print_ip($ip, 1); - if ($result) print $result; - else print $langs->trans("Error"); + if ($result) { + print $result; + } else { + print $langs->trans("Error"); + } /* We disable this test because dol_print_ip need an ip as input @@ -179,17 +185,22 @@ if ($geoip) $ip = getUserRemoteIP(); //$ip='91.161.249.43'; $isip = is_ip($ip); - if ($isip == 1) - { + if ($isip == 1) { print '
'.$ip.' -> '; $result = dol_print_ip($ip, 1); - if ($result) print $result; - else print $langs->trans("Error"); + if ($result) { + print $result; + } else { + print $langs->trans("Error"); + } } else { print '
'.$ip.' -> '; $result = dol_print_ip($ip, 1); - if ($result) print $result; - else print $langs->trans("NotAPublicIp"); + if ($result) { + print $result; + } else { + print $langs->trans("NotAPublicIp"); + } } $geoip->close(); diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php index d8de2dd847d..28fbeba9063 100644 --- a/htdocs/admin/holiday.php +++ b/htdocs/admin/holiday.php @@ -33,7 +33,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "errors", "holiday")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); @@ -41,8 +43,7 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'contract'; -if (empty($conf->global->HOLIDAY_ADDON)) -{ +if (empty($conf->global->HOLIDAY_ADDON)) { $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna'; } @@ -53,22 +54,23 @@ if (empty($conf->global->HOLIDAY_ADDON)) include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'updateMask') -{ +if ($action == 'updateMask') { $maskconst = GETPOST('maskconstholiday', 'alpha'); $maskvalue = GETPOST('maskholiday', 'alpha'); - if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + if ($maskconst) { + $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity); + } - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); } -} elseif ($action == 'specimen') // For contract -{ +} elseif ($action == 'specimen') { // For contract $modele = GETPOST('module', 'alpha'); $holiday = new Holiday($db); @@ -77,25 +79,21 @@ if ($action == 'updateMask') // Search template files $file = ''; $classname = ''; $filefound = 0; $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); - foreach ($dirmodels as $reldir) - { + foreach ($dirmodels as $reldir) { $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0); - if (file_exists($file)) - { + if (file_exists($file)) { $filefound = 1; $classname = "pdf_".$modele; break; } } - if ($filefound) - { + if ($filefound) { require_once $file; $module = new $classname($db); - if ($module->write_file($holiday, $langs) > 0) - { + if ($module->write_file($holiday, $langs) > 0) { header("Location: ".DOL_URL_ROOT."/document.php?modulepart=holiday&file=SPECIMEN.pdf"); return; } else { @@ -106,26 +104,19 @@ if ($action == 'updateMask') setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } -} - -// Activate a model -elseif ($action == 'set') -{ +} elseif ($action == 'set') { + // Activate a model $ret = addDocumentModel($value, $type, $label, $scandir); -} elseif ($action == 'del') -{ +} elseif ($action == 'del') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity); + if ($ret > 0) { + if ($conf->global->HOLIDAY_ADDON_PDF == "$value") { + dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity); + } } -} - -// Set default model -elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "HOLIDAY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + // Set default model + if (dolibarr_set_const($db, "HOLIDAY_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->HOLIDAY_ADDON_PDF = $value; @@ -133,28 +124,26 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } -} elseif ($action == 'setmod') -{ +} elseif ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated dolibarr_set_const($db, "HOLIDAY_ADDON", $value, 'chaine', 0, '', $conf->entity); -} elseif ($action == 'set_other') -{ +} elseif ($action == 'set_other') { $freetext = GETPOST('HOLIDAY_FREE_TEXT', 'restricthtml'); // No alpha here, we want exact string $res1 = dolibarr_set_const($db, "HOLIDAY_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity); $draft = GETPOST('HOLIDAY_DRAFT_WATERMARK', 'alpha'); $res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity); - if (!$res1 > 0 || !$res2 > 0) $error++; + if (!$res1 > 0 || !$res2 > 0) { + $error++; + } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -197,19 +186,14 @@ print "
'.$module->nom."\n"; print $module->info(); print ''; - if ($conf->global->HOLIDAY_ADDON == "$file") - { + if ($conf->global->HOLIDAY_ADDON == "$file") { print img_picto($langs->trans("Activated"), 'switch_on'); } else { print ''; @@ -257,8 +246,9 @@ foreach ($dirmodels as $reldir) if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval $htmltooltip .= ''.$langs->trans("NextValue").': '; if ($nextval) { - if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') + if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured') { $nextval = $langs->trans($nextval); + } $htmltooltip .= $nextval.'
'; } else { $htmltooltip .= $langs->trans($module->error).'
'; @@ -305,12 +295,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -333,31 +321,23 @@ print "
'; print (empty($module->name) ? $name : $module->name); print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print ''."\n"; print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -393,8 +378,7 @@ foreach ($dirmodels as $reldir) // Default print ''; - if ($conf->global->HOLIDAY_ADDON_PDF == $name) - { + if ($conf->global->HOLIDAY_ADDON_PDF == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -404,8 +388,7 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '
'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file; @@ -424,8 +407,7 @@ foreach ($dirmodels as $reldir) // Preview print '
'; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); @@ -467,15 +449,16 @@ print "
'; print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); print '
'; $variablename = 'HOLIDAY_FREE_TEXT'; -if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) -{ +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) { print ''; } else { include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; diff --git a/htdocs/admin/holiday_extrafields.php b/htdocs/admin/holiday_extrafields.php index 077ad08a12a..732eb0997d7 100644 --- a/htdocs/admin/holiday_extrafields.php +++ b/htdocs/admin/holiday_extrafields.php @@ -30,8 +30,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array('admin', 'errors', 'holiday', 'other')); @@ -42,13 +43,17 @@ $form = new Form($db); // List of supported format $tmptype2label = ExtraFields::$type2label; $type2label = array(''); -foreach ($tmptype2label as $key => $val) $type2label[$key] = $langs->transnoentitiesnoconv($val); +foreach ($tmptype2label as $key => $val) { + $type2label[$key] = $langs->transnoentitiesnoconv($val); +} $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); $elementtype = 'holiday'; //Must be the $table_element of the class that manage extrafield -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} /* @@ -78,8 +83,7 @@ print dol_get_fiche_end(); // Buttons -if ($action != 'create' && $action != 'edit') -{ +if ($action != 'create' && $action != 'edit') { print '"; @@ -92,8 +96,7 @@ if ($action != 'create' && $action != 'edit') /* */ /* ************************************************************************** */ -if ($action == 'create') -{ +if ($action == 'create') { print '
'; print load_fiche_titre($langs->trans('NewAttribute')); @@ -105,8 +108,7 @@ if ($action == 'create') /* Edition of an optional field */ /* */ /* ************************************************************************** */ -if ($action == 'edit' && !empty($attrname)) -{ +if ($action == 'edit' && !empty($attrname)) { print "
"; print load_fiche_titre($langs->trans("FieldEdition", $attrname)); diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php index bebb9f7d0bd..81263cba82e 100644 --- a/htdocs/admin/ihm.php +++ b/htdocs/admin/ihm.php @@ -36,12 +36,16 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'languages', 'other', 'companies', 'products', 'members', 'projects', 'hrm', 'agenda')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminihm'; // To manage different context of search -if (!defined("MAIN_MOTD")) define("MAIN_MOTD", ""); +if (!defined("MAIN_MOTD")) { + define("MAIN_MOTD", ""); +} @@ -51,22 +55,25 @@ if (!defined("MAIN_MOTD")) define("MAIN_MOTD", ""); $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (GETPOST('cancel', 'alpha')) -{ +if (GETPOST('cancel', 'alpha')) { $action = ''; } // Convert action set_XXX and del_XXX to set var (this is used when no javascript on for ajax_constantonoff) $regs = array(); if (preg_match('/^(set|del)_([A-Z_]+)$/', $action, $regs)) { - if ($regs[1] == 'set') dolibarr_set_const($db, $regs[2], 1, 'chaine', 0, '', $conf->entity); - else dolibarr_del_const($db, $regs[2], $conf->entity); + if ($regs[1] == 'set') { + dolibarr_set_const($db, $regs[2], 1, 'chaine', 0, '', $conf->entity); + } else { + dolibarr_del_const($db, $regs[2], $conf->entity); + } } -if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKGROUND)) -{ +if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKGROUND)) { dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; @@ -76,18 +83,17 @@ if ($action == 'removebackgroundlogin' && !empty($conf->global->MAIN_LOGIN_BACKG $mysoc->logo = ''; /*$logosmallfile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_small; - dol_delete_file($logosmallfile); - dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$conf->entity); - $mysoc->logo_small=''; + dol_delete_file($logosmallfile); + dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_SMALL",$conf->entity); + $mysoc->logo_small=''; - $logominifile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini; - dol_delete_file($logominifile); - dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$conf->entity); - $mysoc->logo_mini='';*/ + $logominifile=$conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini; + dol_delete_file($logominifile); + dolibarr_del_const($db, "MAIN_INFO_SOCIETE_LOGO_MINI",$conf->entity); + $mysoc->logo_mini='';*/ } -if ($action == 'update') -{ +if ($action == 'update') { dolibarr_set_const($db, "MAIN_LANG_DEFAULT", GETPOST("MAIN_LANG_DEFAULT", 'aZ09'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity); //dolibarr_set_const($db, "MAIN_MULTILANGS", $_POST["MAIN_MULTILANGS"], 'chaine', 0, '', $conf->entity); @@ -99,58 +105,100 @@ if ($action == 'update') else dolibarr_set_const($db, 'THEME_TOPMENU_DISABLE_IMAGE', GETPOST('THEME_TOPMENU_DISABLE_IMAGE'), 'chaine', 0, '', $conf->entity);*/ $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKBODY'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_BACKBODY', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_BACKBODY', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TOPMENU_BACK1'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_TOPMENU_BACK1', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_TOPMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_VERMENU_BACK1'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_VERMENU_BACK1', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_VERMENU_BACK1', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLENOTAB'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLENOTAB', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_BACKTITLE1'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_BACKTITLE1', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_BACKTITLE1', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLE'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLE', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLE', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTTITLELINK'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLELINK', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLELINK', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_TEXTTITLELINK', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_TEXTTITLELINK', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR1', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR1', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEIMPAIR1'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_LINEIMPAIR2', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_LINEIMPAIR2', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR1', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR1', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_LINEPAIR1'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_LINEPAIR2', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_LINEPAIR2', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_TEXTLINK'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity); - else dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_TEXTLINK', $conf->entity); + } else { + dolibarr_set_const($db, 'THEME_ELDY_TEXTLINK', $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_HOVER'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_HOVER', $conf->entity); - else dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_USE_HOVER', $conf->entity); + } else { + dolibarr_set_const($db, "THEME_ELDY_USE_HOVER", $val, 'chaine', 0, '', $conf->entity); + } $val = (implode(',', (colorStringToArray(GETPOST('THEME_ELDY_USE_CHECKED'), array())))); - if ($val == '') dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity); - else dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity); + if ($val == '') { + dolibarr_del_const($db, 'THEME_ELDY_USE_CHECKED', $conf->entity); + } else { + dolibarr_set_const($db, "THEME_ELDY_USE_CHECKED", $val, 'chaine', 0, '', $conf->entity); + } dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", GETPOST("main_size_liste_limit", 'int'), 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, "MAIN_SIZE_SHORTLIST_LIMIT", GETPOST("main_size_shortliste_limit", 'int'), 'chaine', 0, '', $conf->entity); @@ -171,27 +219,21 @@ if ($action == 'update') //dolibarr_set_const($db, "MAIN_HELP_DISABLELINK", GETPOST("MAIN_HELP_DISABLELINK", 'aZ09'), 'chaine', 0, '', 0); // Param for all entities $varforimage = 'imagebackground'; $dirforimage = $conf->mycompany->dir_output.'/logos/'; - if ($_FILES[$varforimage]["tmp_name"]) - { + if ($_FILES[$varforimage]["tmp_name"]) { $reg = array(); - if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) - { + if (preg_match('/([^\\/:]+)$/i', $_FILES[$varforimage]["name"], $reg)) { $original_file = $reg[1]; $isimage = image_format_supported($original_file); - if ($isimage >= 0) - { + if ($isimage >= 0) { dol_syslog("Move file ".$_FILES[$varforimage]["tmp_name"]." to ".$dirforimage.$original_file); - if (!is_dir($dirforimage)) - { + if (!is_dir($dirforimage)) { dol_mkdir($dirforimage); } $result = dol_move_uploaded_file($_FILES[$varforimage]["tmp_name"], $dirforimage.$original_file, 1, 0, $_FILES[$varforimage]['error']); - if ($result > 0) - { + if ($result > 0) { dolibarr_set_const($db, "MAIN_LOGIN_BACKGROUND", $original_file, 'chaine', 0, '', $conf->entity); - } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) - { + } elseif (preg_match('/^ErrorFileIsInfectedWithAVirus/', $result)) { $error++; $langs->load("errors"); $tmparray = explode(':', $result); @@ -380,8 +422,7 @@ complete_substitutions_array($substitutionarray, $langs); print '
'; $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
'; -foreach ($substitutionarray as $key => $val) -{ +foreach ($substitutionarray as $key => $val) { $texthelp .= $key.'
'; } print $form->textwithpicto($langs->trans("MessageOfDay"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessageofday'); @@ -417,8 +458,7 @@ $substitutionarray = getCommonSubstitutionArray($langs, 0, array('object', 'obje complete_substitutions_array($substitutionarray, $langs); print '
'; $texthelp = $langs->trans("FollowingConstantsWillBeSubstituted").'
'; -foreach ($substitutionarray as $key => $val) -{ +foreach ($substitutionarray as $key => $val) { $texthelp .= $key.'
'; } print $form->textwithpicto($langs->trans("MessageLogin"), $texthelp, 1, 'help', '', 0, 2, 'tooltipmessagelogin'); @@ -431,10 +471,11 @@ print '
'; print '
'; $disabled = ''; -if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) $disabled = ' disabled="disabled"'; +if (!empty($conf->global->ADD_UNSPLASH_LOGIN_BACKGROUND)) { + $disabled = ' disabled="disabled"'; +} print ''; -if ($disabled) -{ +if ($disabled) { print '('.$langs->trans("DisabledByOptionADD_UNSPLASH_LOGIN_BACKGROUND").') '; } if (!empty($conf->global->MAIN_LOGIN_BACKGROUND)) { diff --git a/htdocs/admin/import.php b/htdocs/admin/import.php index e70d8eadbba..38f8ae7554b 100644 --- a/htdocs/admin/import.php +++ b/htdocs/admin/import.php @@ -35,8 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'exports', 'other')); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $value = GETPOST('value', 'alpha'); diff --git a/htdocs/admin/index.php b/htdocs/admin/index.php index 44bfd678fb4..c16a01e5816 100644 --- a/htdocs/admin/index.php +++ b/htdocs/admin/index.php @@ -27,7 +27,9 @@ require '../main.inc.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'companies')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('homesetup')); @@ -45,16 +47,15 @@ llxHeader('', $langs->trans("Setup"), $wikihelp); print load_fiche_titre($langs->trans("SetupArea"), '', 'tools'); -if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) -{ +if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('//i', '
', $conf->global->MAIN_MOTD_SETUPPAGE); - if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) - { + if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) { $i = 0; - while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100) - { + while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100) { $tmp = explode('|', $reg[1]); - if (!empty($tmp[1])) $langs->load($tmp[1]); + if (!empty($tmp[1])) { + $langs->load($tmp[1]); + } $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/__\('.preg_quote($reg[1]).'\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_MOTD_SETUPPAGE); $i++; } @@ -77,10 +78,11 @@ print ''; print '
'; // Show info setup company -if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) $setupcompanynotcomplete = 1; +if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) { + $setupcompanynotcomplete = 1; +} print img_picto('', 'puce').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); -if (!empty($setupcompanynotcomplete)) -{ +if (!empty($setupcompanynotcomplete)) { $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"'); print '
'; @@ -91,8 +93,7 @@ print '
'; // Show info setup module print img_picto('', 'puce').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); -if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) // If only user module enabled -{ +if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) { // If only user module enabled $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"'); print '
'; @@ -106,8 +107,7 @@ print '
'; $parameters = array(); $reshook = $hookmanager->executeHooks('addHomeSetup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks print $hookmanager->resPrint; -if (empty($reshook)) -{ +if (empty($reshook)) { // Show into other print ''.$langs->trans("SetupDescription5")."
"; print "
"; diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index b8c207644c6..18399894ad0 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -34,8 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; // Load translation files required by the page $langs->load("admin"); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -48,32 +49,57 @@ $hookmanager->initHooks(array('adminldap', 'globaladmin')); $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} -if (empty($reshook)) -{ - if ($action == 'setvalue' && $user->admin) - { +if (empty($reshook)) { + if ($action == 'setvalue' && $user->admin) { $error = 0; $db->begin(); - if (!dolibarr_set_const($db, 'LDAP_SERVER_TYPE', GETPOST("type", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION', GETPOST("LDAP_SERVER_PROTOCOLVERSION", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST', GETPOST("host", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE', GETPOST("slave", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_SERVER_PORT', GETPOST("port", 'int'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_SERVER_DN', GETPOST("dn", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_ADMIN_DN', GETPOST("admin", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_ADMIN_PASS', GETPOST("pass", 'none'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS', GETPOST("usetls", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE', GETPOST("activesynchro", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE', GETPOST("activecontact", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE', GETPOST("activemembers", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes", 'aZ09'), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_SERVER_TYPE', GETPOST("type", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_SERVER_PROTOCOLVERSION', GETPOST("LDAP_SERVER_PROTOCOLVERSION", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST', GETPOST("host", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_SERVER_HOST_SLAVE', GETPOST("slave", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_SERVER_PORT', GETPOST("port", 'int'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_SERVER_DN', GETPOST("dn", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_ADMIN_DN', GETPOST("admin", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_ADMIN_PASS', GETPOST("pass", 'none'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_SERVER_USE_TLS', GETPOST("usetls", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_SYNCHRO_ACTIVE', GETPOST("activesynchro", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_ACTIVE', GETPOST("activecontact", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_ACTIVE', GETPOST("activemembers", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + $error++; + } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -96,8 +122,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (!function_exists("ldap_connect")) -{ +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -126,15 +151,13 @@ $arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr"); $arraylist['dolibarr2ldap'] = $langs->trans("DolibarrToLDAP"); print $form->selectarray('activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE); print '
'.$langs->trans("LDAPDnSynchroActiveExample"); -if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN) -{ +if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN) { print '
'.$langs->trans("LDAPSetupNotComplete").''; } print '
'.$langs->trans("LDAPDnContactActive").''; $arraylist = array(); $arraylist['0'] = $langs->trans("No"); @@ -144,8 +167,7 @@ if (!empty($conf->societe->enabled)) } // Synchro member active -if (!empty($conf->adherent->enabled)) -{ +if (!empty($conf->adherent->enabled)) { print '
'.$langs->trans("LDAPDnMemberActive").''; $arraylist = array(); $arraylist['0'] = $langs->trans("No"); @@ -156,8 +178,7 @@ if (!empty($conf->adherent->enabled)) } // Synchro member type active -if (!empty($conf->adherent->enabled)) -{ +if (!empty($conf->adherent->enabled)) { print '
'.$langs->trans("LDAPDnMemberTypeActive").''; $arraylist = array(); $arraylist['0'] = $langs->trans("No"); @@ -209,8 +230,7 @@ print ''.$langs->trans("LDAPServerExample").'
'.$langs->trans("LDAPServerPort").''; -if (!empty($conf->global->LDAP_SERVER_PORT)) -{ +if (!empty($conf->global->LDAP_SERVER_PORT)) { print ''; } else { print ''; @@ -241,8 +261,7 @@ print ''.$langs->trans("LDAPAdminDnExample").'
'.$langs->trans("LDAPPassword").''; -if (!empty($conf->global->LDAP_ADMIN_PASS)) -{ +if (!empty($conf->global->LDAP_ADMIN_PASS)) { print ''; // je le met en visible pour test } else { print ''; @@ -263,29 +282,23 @@ print '
'; /* * Test de la connexion */ -if (function_exists("ldap_connect")) -{ - if (!empty($conf->global->LDAP_SERVER_HOST)) - { +if (function_exists("ldap_connect")) { + if (!empty($conf->global->LDAP_SERVER_HOST)) { print ''.$langs->trans("LDAPTestConnect").'

'; } - if ($_GET["action"] == 'test') - { + if ($_GET["action"] == 'test') { $ldap = new Ldap(); // Les parametres sont passes et recuperes via $conf $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { // Test ldap connect and bind print img_picto('', 'info').' '; print ''.$langs->trans("LDAPTCPConnectOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT).''; print '
'; - if ($conf->global->LDAP_ADMIN_DN && !empty($conf->global->LDAP_ADMIN_PASS)) - { - if ($result == 2) - { + if ($conf->global->LDAP_ADMIN_DN && !empty($conf->global->LDAP_ADMIN_PASS)) { + if ($result == 2) { print img_picto('', 'info').' '; print ''.$langs->trans("LDAPBindOK", $conf->global->LDAP_SERVER_HOST, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; print '
'; @@ -304,8 +317,7 @@ if (function_exists("ldap_connect")) // Test ldap_getversion - if (($ldap->getVersion() == 3)) - { + if (($ldap->getVersion() == 3)) { print img_picto('', 'info').' '; print ''.$langs->trans("LDAPSetupForVersion3").''; print '
'; diff --git a/htdocs/admin/ldap_contacts.php b/htdocs/admin/ldap_contacts.php index b29fa00e49e..d21c95405a2 100644 --- a/htdocs/admin/ldap_contacts.php +++ b/htdocs/admin/ldap_contacts.php @@ -35,8 +35,9 @@ require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "errors")); -if (!$user->admin) - accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -44,38 +45,72 @@ $action = GETPOST('action', 'aZ09'); * Actions */ -if ($action == 'setvalue' && $user->admin) -{ +if ($action == 'setvalue' && $user->admin) { $error = 0; $db->begin(); - if (!dolibarr_set_const($db, 'LDAP_CONTACT_DN', GETPOST("contactdn"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_DN', GETPOST("contactdn"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) { + $error++; + } - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE', GETPOST("fieldhomephone"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_HOMEPHONE', GETPOST("fieldhomephone"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_CONTACT_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) { + $error++; + } // This one must be after the others $valkey = ''; $key = GETPOST("key"); - if ($key) $valkey = $conf->global->$key; - if (!dolibarr_set_const($db, 'LDAP_KEY_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + if ($key) { + $valkey = $conf->global->$key; + } + if (!dolibarr_set_const($db, 'LDAP_KEY_CONTACTS', $valkey, 'chaine', 0, '', $conf->entity)) { + $error++; + } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -100,8 +135,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (!function_exists("ldap_connect")) -{ +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -265,10 +299,8 @@ $objectclass = $conf->global->LDAP_CONTACT_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); -if (function_exists("ldap_connect")) -{ - if ($_GET["action"] == 'test') - { +if (function_exists("ldap_connect")) { + if ($_GET["action"] == 'test') { // Creation objet $object = new Contact($db); $object->initAsSpecimen(); @@ -277,8 +309,7 @@ if (function_exists("ldap_connect")) $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -286,8 +317,7 @@ if (function_exists("ldap_connect")) $result2 = $ldap->add($dn, $info, $user); // Now the test $result3 = $ldap->delete($dn); // Clean what we did - if ($result2 > 0) - { + if ($result2 > 0) { print img_picto('', 'info').' '; print ''.$langs->trans("LDAPSynchroOK").'
'; } else { diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 61d2e8b69e9..0cd05a53a74 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -36,8 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "errors")); -if (!$user->admin) - accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -46,28 +47,42 @@ $action = GETPOST('action', 'aZ09'); * Actions */ -if ($action == 'setvalue' && $user->admin) -{ +if ($action == 'setvalue' && $user->admin) { $error = 0; $db->begin(); - if (!dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_DN', GETPOST("group", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_GROUP_OBJECT_CLASS', GETPOST("objectclass", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { + $error++; + } - if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_FULLNAME', GETPOST("fieldfullname", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { + $error++; + } //if (! dolibarr_set_const($db, 'LDAP_GROUP_FIELD_NAME',GETPOST("fieldname", 'alphanohtml'),'chaine',0,'',$conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_DESCRIPTION', GETPOST("fielddescription", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPMEMBERS', GETPOST("fieldgroupmembers", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_GROUP_FIELD_GROUPID', GETPOST("fieldgroupid", 'alphanohtml'), 'chaine', 0, '', $conf->entity)) { + $error++; + } // This one must be after the others $valkey = ''; $key = GETPOST("key"); - if ($key) $valkey = $conf->global->$key; - if (!dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + if ($key) { + $valkey = $conf->global->$key; + } + if (!dolibarr_set_const($db, 'LDAP_KEY_GROUPS', $valkey, 'chaine', 0, '', $conf->entity)) { + $error++; + } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -90,8 +105,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (!function_exists("ldap_connect")) -{ +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -190,8 +204,7 @@ print ''; /* * Test de la connexion */ -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') -{ +if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { $butlabel = $langs->trans("LDAPTestSynchroGroup"); $testlabel = 'testgroup'; $key = $conf->global->LDAP_KEY_GROUPS; @@ -201,10 +214,8 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } -if (function_exists("ldap_connect")) -{ - if ($_GET["action"] == 'testgroup') - { +if (function_exists("ldap_connect")) { + if ($_GET["action"] == 'testgroup') { // Creation objet $object = new UserGroup($db); $object->initAsSpecimen(); @@ -213,8 +224,7 @@ if (function_exists("ldap_connect")) $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -227,8 +237,7 @@ if (function_exists("ldap_connect")) $result2 = $ldap->add($dn, $info, $user); // Now the test $result3 = $ldap->delete($dn); // Clean what we did - if ($result2 > 0) - { + if ($result2 > 0) { print img_picto('', 'info').' '; print ''.$langs->trans("LDAPSynchroOK").'
'; } else { diff --git a/htdocs/admin/ldap_members.php b/htdocs/admin/ldap_members.php index 214a4f2cb9b..d64628516ca 100644 --- a/htdocs/admin/ldap_members.php +++ b/htdocs/admin/ldap_members.php @@ -36,8 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors')); -if (!$user->admin) - accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -45,54 +46,116 @@ $action = GETPOST('action', 'aZ09'); * Actions */ -if ($action == 'setvalue' && $user->admin) -{ +if ($action == 'setvalue' && $user->admin) { $error = 0; $db->begin(); - if (!dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FILTER', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) { + $error++; + } // Members - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_PHONE_PERSO', GETPOST("fieldphoneperso"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_NOTE_PUBLIC', GETPOST("fieldnotepublic"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_FIELD_BIRTHDATE', GETPOST("fieldbirthdate"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_STATUS', GETPOST("fieldstatus"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION', GETPOST("fieldendlastsubscription"), 'chaine', 0, '', $conf->entity)) { + $error++; + } // Subscriptions - if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE', GETPOST("fieldfirstsubscriptiondate"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT', GETPOST("fieldfirstsubscriptionamount"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE', GETPOST("fieldlastsubscriptiondate"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT', GETPOST("fieldlastsubscriptionamount"), 'chaine', 0, '', $conf->entity)) { + $error++; + } // This one must be after the others $valkey = ''; $key = GETPOST("key"); - if ($key) $valkey = $conf->global->$key; - if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + if ($key) { + $valkey = $conf->global->$key; + } + if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS', $valkey, 'chaine', 0, '', $conf->entity)) { + $error++; + } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -117,8 +180,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (!function_exists("ldap_connect")) -{ +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -377,8 +439,7 @@ print ''; /* * Test de la connexion */ -if (!empty($conf->global->LDAP_MEMBER_ACTIVE)) -{ +if (!empty($conf->global->LDAP_MEMBER_ACTIVE)) { $butlabel = $langs->trans("LDAPTestSynchroMember"); $testlabel = 'testmember'; $key = $conf->global->LDAP_KEY_MEMBERS; @@ -388,10 +449,8 @@ if (!empty($conf->global->LDAP_MEMBER_ACTIVE)) show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } -if (function_exists("ldap_connect")) -{ - if ($_GET["action"] == 'testmember') - { +if (function_exists("ldap_connect")) { + if ($_GET["action"] == 'testmember') { // Creation objet $object = new Adherent($db); $object->initAsSpecimen(); @@ -400,8 +459,7 @@ if (function_exists("ldap_connect")) $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -409,8 +467,7 @@ if (function_exists("ldap_connect")) $result2 = $ldap->add($dn, $info, $user); // Now the test $result3 = $ldap->delete($dn); // Clean what we did - if ($result2 > 0) - { + if ($result2 > 0) { print img_picto('', 'info').' '; print ''.$langs->trans("LDAPSynchroOK").'
'; } else { diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 489e6047f9b..75ed864ecf0 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -36,8 +36,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors')); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -46,26 +47,38 @@ $action = GETPOST('action', 'aZ09'); * Actions */ -if ($action == 'setvalue' && $user->admin) -{ +if ($action == 'setvalue' && $user->admin) { $error = 0; $db->begin(); - if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN', GETPOST("membertype"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_DN', GETPOST("membertype"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) { + $error++; + } - if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS', GETPOST("fieldmembertypemembers"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_FIELD_GROUPMEMBERS', GETPOST("fieldmembertypemembers"), 'chaine', 0, '', $conf->entity)) { + $error++; + } // This one must be after the others $valkey = ''; $key = GETPOST("key"); - if ($key) $valkey = $conf->global->$key; - if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + if ($key) { + $valkey = $conf->global->$key; + } + if (!dolibarr_set_const($db, 'LDAP_KEY_MEMBERS_TYPES', $valkey, 'chaine', 0, '', $conf->entity)) { + $error++; + } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -88,8 +101,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (!function_exists("ldap_connect")) -{ +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -172,8 +184,7 @@ print ''; /* * Test de la connexion */ -if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') -{ +if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { $butlabel = $langs->trans("LDAPTestSynchroMemberType"); $testlabel = 'testmembertype'; $key = $conf->global->LDAP_KEY_MEMBERS_TYPES; @@ -183,10 +194,8 @@ if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } -if (function_exists("ldap_connect")) -{ - if ($_GET["action"] == 'testmembertype') - { +if (function_exists("ldap_connect")) { + if ($_GET["action"] == 'testmembertype') { // Creation objet $object = new AdherentType($db); $object->initAsSpecimen(); @@ -195,8 +204,7 @@ if (function_exists("ldap_connect")) $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -209,8 +217,7 @@ if (function_exists("ldap_connect")) $result2 = $ldap->add($dn, $info, $user); // Now the test $result3 = $ldap->delete($dn); // Clean what we did - if ($result2 > 0) - { + if ($result2 > 0) { print img_picto('', 'info').' '; print ''.$langs->trans("LDAPSynchroOK").'
'; } else { diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index efb34cca413..7e53eebc9ce 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -37,8 +37,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; // Load translation files required by the page $langs->loadLangs(array('admin', 'errors')); -if (!$user->admin) - accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -46,47 +47,103 @@ $action = GETPOST('action', 'aZ09'); * Actions */ -if ($action == 'setvalue' && $user->admin) -{ +if ($action == 'setvalue' && $user->admin) { $error = 0; $db->begin(); - if (!dolibarr_set_const($db, 'LDAP_USER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_SID', GETPOST("fieldsid"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_TITLE', GETPOST("fieldtitle"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_USERID', GETPOST("fielduserid"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORY', GETPOST("fieldhomedirectory"), 'chaine', 0, '', $conf->entity)) $error++; - if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORYPREFIX', GETPOST("fieldhomedirectoryprefix"), 'chaine', 0, '', $conf->entity)) $error++; + if (!dolibarr_set_const($db, 'LDAP_USER_DN', GETPOST("user"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_USER_OBJECT_CLASS', GETPOST("objectclass"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FILTER_CONNECTION', GETPOST("filterconnection"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_FULLNAME', GETPOST("fieldfullname"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN', GETPOST("fieldlogin"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_LOGIN_SAMBA', GETPOST("fieldloginsamba"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD', GETPOST("fieldpassword"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_PASSWORD_CRYPTED', GETPOST("fieldpasswordcrypted"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_NAME', GETPOST("fieldname"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_FIRSTNAME', GETPOST("fieldfirstname"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_MAIL', GETPOST("fieldmail"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_PHONE', GETPOST("fieldphone"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_MOBILE', GETPOST("fieldmobile"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_SKYPE', GETPOST("fieldskype"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_FAX', GETPOST("fieldfax"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_COMPANY', GETPOST("fieldcompany"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_ADDRESS', GETPOST("fieldaddress"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_ZIP', GETPOST("fieldzip"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_TOWN', GETPOST("fieldtown"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_COUNTRY', GETPOST("fieldcountry"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_DESCRIPTION', GETPOST("fielddescription"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_SID', GETPOST("fieldsid"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_TITLE', GETPOST("fieldtitle"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_GROUPID', GETPOST("fieldgroupid"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_USERID', GETPOST("fielduserid"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORY', GETPOST("fieldhomedirectory"), 'chaine', 0, '', $conf->entity)) { + $error++; + } + if (!dolibarr_set_const($db, 'LDAP_FIELD_HOMEDIRECTORYPREFIX', GETPOST("fieldhomedirectoryprefix"), 'chaine', 0, '', $conf->entity)) { + $error++; + } // This one must be after the others $valkey = ''; $key = GETPOST("key"); - if ($key) $valkey = $conf->global->$key; - if (!dolibarr_set_const($db, 'LDAP_KEY_USERS', $valkey, 'chaine', 0, '', $conf->entity)) $error++; + if ($key) { + $valkey = $conf->global->$key; + } + if (!dolibarr_set_const($db, 'LDAP_KEY_USERS', $valkey, 'chaine', 0, '', $conf->entity)) { + $error++; + } - if (!$error) - { + if (!$error) { $db->commit(); setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { @@ -111,8 +168,7 @@ print load_fiche_titre($langs->trans("LDAPSetup"), $linkback, 'title_setup'); $head = ldap_prepare_head(); // Test si fonction LDAP actives -if (!function_exists("ldap_connect")) -{ +if (!function_exists("ldap_connect")) { setEventMessages($langs->trans("LDAPFunctionsNotAvailableOnPHP"), null, 'errors'); } @@ -346,8 +402,7 @@ print ''; /* * Test de la connexion */ -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') -{ +if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { $butlabel = $langs->trans("LDAPTestSynchroUser"); $testlabel = 'testuser'; $key = $conf->global->LDAP_KEY_USERS; @@ -355,8 +410,7 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') $objectclass = $conf->global->LDAP_USER_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); -} elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') -{ +} elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { $butlabel = $langs->trans("LDAPTestSearch"); $testlabel = 'testsearchuser'; $key = $conf->global->LDAP_KEY_USERS; @@ -365,10 +419,8 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); } -if (function_exists("ldap_connect")) -{ - if ($action == 'testuser') - { +if (function_exists("ldap_connect")) { + if ($action == 'testuser') { // Creation objet $object = new User($db); $object->initAsSpecimen(); @@ -379,8 +431,7 @@ if (function_exists("ldap_connect")) $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $info = $object->_load_ldap_info(); $dn = $object->_load_ldap_dn($info); @@ -388,8 +439,7 @@ if (function_exists("ldap_connect")) $result2 = $ldap->add($dn, $info, $user); // Now the test $result3 = $ldap->delete($dn); // Clean what we did - if ($result2 > 0) - { + if ($result2 > 0) { print img_picto('', 'info').' '; print ''.$langs->trans("LDAPSynchroOK").'
'; } else { @@ -413,8 +463,7 @@ if (function_exists("ldap_connect")) } } - if ($action == 'testsearchuser') - { + if ($action == 'testsearchuser') { // Creation objet $object = new User($db); $object->initAsSpecimen(); @@ -425,8 +474,7 @@ if (function_exists("ldap_connect")) $ldap = new Ldap(); $result = $ldap->connect_bind(); - if ($result > 0) - { + if ($result > 0) { $required_fields = array( $conf->global->LDAP_KEY_USERS, $conf->global->LDAP_FIELD_FULLNAME, @@ -453,17 +501,13 @@ if (function_exists("ldap_connect")) $ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, $required_fields, 1); //$ldapusers = $ldap->getRecords('*', $conf->global->LDAP_USER_DN, $conf->global->LDAP_KEY_USERS, '', 1); - if (is_array($ldapusers)) - { + if (is_array($ldapusers)) { $liste = array(); - foreach ($ldapusers as $key => $ldapuser) - { + foreach ($ldapusers as $key => $ldapuser) { // Define the label string for this user $label = ''; - foreach ($required_fields as $value) - { - if ($value) - { + foreach ($required_fields as $value) { + if ($value) { $label .= $value."=".$ldapuser[$value]." "; } } diff --git a/htdocs/admin/limits.php b/htdocs/admin/limits.php index 08c19091caa..4a599499053 100644 --- a/htdocs/admin/limits.php +++ b/htdocs/admin/limits.php @@ -29,7 +29,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; // Load translation files required by the page $langs->loadLangs(array('companies', 'products', 'admin')); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $currencycode = GETPOST('currencycode', 'alpha'); @@ -49,39 +51,33 @@ $valmainmaxdecimalstot = GETPOST($mainmaxdecimalstot, 'int'); $valmainmaxdecimalsshown = GETPOST($mainmaxdecimalsshown, 'int'); $valmainroundingruletot = price2num(GETPOST($mainroundingruletot, 'alpha')); -if ($action == 'update') -{ +if ($action == 'update') { $error = 0; $MAXDEC = 8; if ($_POST[$mainmaxdecimalsunit] > $MAXDEC || $_POST[$mainmaxdecimalstot] > $MAXDEC - || $_POST[$mainmaxdecimalsshown] > $MAXDEC) - { + || $_POST[$mainmaxdecimalsshown] > $MAXDEC) { $error++; setEventMessages($langs->trans("ErrorDecimalLargerThanAreForbidden", $MAXDEC), null, 'errors'); } if ($_POST[$mainmaxdecimalsunit].(!empty($currencycode) ? '_'.$currencycode : '') < 0 || $_POST[$mainmaxdecimalstot] < 0 - || $_POST[$mainmaxdecimalsshown] < 0) - { + || $_POST[$mainmaxdecimalsshown] < 0) { $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorNegativeValueNotAllowed"), null, 'errors'); } - if ($valmainroundingruletot) - { - if ($valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1) - { + if ($valmainroundingruletot) { + if ($valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1) { $langs->load("errors"); $error++; setEventMessages($langs->trans("ErrorMAIN_ROUNDING_RULE_TOTCanMAIN_MAX_DECIMALS_TOT"), null, 'errors'); } } - if (!$error) - { + if (!$error) { dolibarr_set_const($db, $mainmaxdecimalsunit, $valmainmaxdecimalsunit, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $mainmaxdecimalstot, $valmainmaxdecimalstot, 'chaine', 0, '', $conf->entity); dolibarr_set_const($db, $mainmaxdecimalsshown, $valmainmaxdecimalsshown, 'chaine', 0, '', $conf->entity); @@ -109,24 +105,20 @@ print load_fiche_titre($title, '', 'title_setup'); $aCurrencies = array($conf->currency); // Default currency always first position -if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) -{ +if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { require_once DOL_DOCUMENT_ROOT.'/core/lib/multicurrency.lib.php'; $sql = 'SELECT rowid, code FROM '.MAIN_DB_PREFIX.'multicurrency'; $sql .= ' WHERE entity = '.$conf->entity; $sql .= ' AND code != "'.$conf->currency.'"'; // Default currency always first position $resql = $db->query($sql); - if ($resql) - { - while ($obj = $db->fetch_object($resql)) - { + if ($resql) { + while ($obj = $db->fetch_object($resql)) { $aCurrencies[] = $obj->code; } } - if (!empty($aCurrencies) && count($aCurrencies) > 1) - { + if (!empty($aCurrencies) && count($aCurrencies) > 1) { $head = multicurrencyLimitPrepareHead($aCurrencies); print dol_get_fiche_head($head, $currencycode, '', -1, ''); @@ -136,8 +128,7 @@ if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY print ''.$langs->trans("LimitsDesc")."
\n"; print "
\n"; -if ($action == 'edit') -{ +if ($action == 'edit') { print '
'; print ''; print ''; @@ -203,16 +194,13 @@ if ($action == 'edit') print ''; } -if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) -{ - if (!empty($aCurrencies) && count($aCurrencies) > 1) - { +if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) { + if (!empty($aCurrencies) && count($aCurrencies) > 1) { print dol_get_fiche_end(); } } -if (empty($mysoc->country_code)) -{ +if (empty($mysoc->country_code)) { $langs->load("errors"); $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete")); print '
'.$warnpicto.' '.$langs->trans("WarningMandatorySetupNotComplete").''; @@ -252,26 +240,22 @@ if (empty($mysoc->country_code)) $sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$db->escape($mysoc->country_code)."' AND (t.taux <> 0 OR t.localtax1 <>0 OR t.localtax2 <>0)"; $sql .= " ORDER BY t.taux ASC"; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); - if ($num) - { - for ($i = 0; $i < $num; $i++) - { + if ($num) { + for ($i = 0; $i < $num; $i++) { $obj = $db->fetch_object($resql); $vat_rates[] = array('vat_rate'=>$obj->vat_rate, 'code'=>$obj->vat_code, 'localtax_rate1'=>$obj->localtax_rate1, 'locltax_rate2'=>$obj->localtax_rate2); } } - } else dol_print_error($db); + } else { + dol_print_error($db); + } - if (count($vat_rates)) - { - foreach ($vat_rates as $vatarray) - { + if (count($vat_rates)) { + foreach ($vat_rates as $vatarray) { $vat = $vatarray['vat_rate']; - for ($qty = 1; $qty <= 2; $qty++) - { + for ($qty = 1; $qty <= 2; $qty++) { $vattxt = $vat.($vatarray['code'] ? ' ('.$vatarray['code'].')' : ''); $localtax_array = getLocalTaxesFromRate($vattxt, 0, $mysoc, $mysoc); diff --git a/htdocs/admin/loan.php b/htdocs/admin/loan.php index ee358300ca4..94b0da08d4f 100644 --- a/htdocs/admin/loan.php +++ b/htdocs/admin/loan.php @@ -26,14 +26,17 @@ require '../main.inc.php'; // Class require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +if (!empty($conf->accounting->enabled)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; +} // Load translation files required by the page $langs->loadLangs(array('admin', 'loan')); // Security check -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -48,8 +51,7 @@ $list = array( * Actions */ -if ($action == 'update') -{ +if ($action == 'update') { $error = 0; foreach ($list as $constname) { @@ -60,8 +62,7 @@ if ($action == 'update') } } - if (!$error) - { + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -75,7 +76,9 @@ if ($action == 'update') llxHeader(); $form = new Form($db); -if (!empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db); +if (!empty($conf->accounting->enabled)) { + $formaccounting = new FormAccounting($db); +} $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans('ConfigLoan'), $linkback, 'title_setup'); @@ -92,8 +95,7 @@ print '
'.$langs->trans('Options').'
'; - if (!empty($conf->accounting->enabled)) - { + if (!empty($conf->accounting->enabled)) { print $formaccounting->select_account($conf->global->$key, $key, 1, '', 1, 1); } else { print ''; diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index 4ea5db1cecd..1b0df5843f3 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "mails")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $action = GETPOST('action', 'aZ09'); @@ -41,8 +43,7 @@ $form = new Form($db); * Actions */ -if ($action == 'setvalue') -{ +if ($action == 'setvalue') { $db->begin(); $mailfrom = GETPOST('MAILING_EMAIL_FROM', 'alpha'); @@ -53,17 +54,27 @@ if ($action == 'setvalue') $contactbulkdefault = GETPOST('MAILING_CONTACT_DEFAULT_BULK_STATUS', 'int'); $res = dolibarr_set_const($db, "MAILING_EMAIL_FROM", $mailfrom, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } $res = dolibarr_set_const($db, "MAILING_EMAIL_ERRORSTO", $mailerror, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } $res = dolibarr_set_const($db, "MAILING_DELAY", $mailingdelay, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } $res = dolibarr_set_const($db, "MAILING_CONTACT_DEFAULT_BULK_STATUS", $contactbulkdefault, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } // Create temporary encryption key if nedded $res = dolibarr_set_const($db, "MAILING_EMAIL_UNSUBSCRIBE_KEY", $checkread_key, 'chaine', 0, '', $conf->entity); - if (!($res > 0)) $error++; + if (!($res > 0)) { + $error++; + } if (!$error) { @@ -77,9 +88,10 @@ if ($action == 'setvalue') if ($action == 'setonsearchandlistgooncustomerorsuppliercard') { $setonsearchandlistgooncustomerorsuppliercard = GETPOST('value', 'int'); $res = dolibarr_set_const($db, "SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD", $setonsearchandlistgooncustomerorsuppliercard, 'yesno', 0, '', $conf->entity); - if (!($res > 0)) $error++; - if (!$error) - { + if (!($res > 0)) { + $error++; + } + if (!$error) { setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); } else { setEventMessages($langs->trans("Error"), null, 'errors'); @@ -95,8 +107,7 @@ llxHeader('', $langs->trans("MailingSetup")); $linkback = ''.$langs->trans("BackToModuleList").''; print load_fiche_titre($langs->trans("MailingSetup"), $linkback, 'title_setup'); -if (!empty($conf->use_javascript_ajax)) -{ +if (!empty($conf->use_javascript_ajax)) { print "\n".' @@ -96,23 +101,21 @@ print $langs->trans("RestoreDesc3", $dolibarr_main_db_name).'

';
trans("ImportMethod"); ?> - -
- /> - -
- + /> + +
+ -
- /> - -
- + /> + + + trans("RestoreDesc3", $dolibarr_main_db_name).'

';
'; print ''.$langs->trans('RestoreMySQL').''; print '
'; // Parameteres execution $command = $db->getPathOfRestore(); - if (preg_match("/\s/", $command)) $command = $command = escapeshellarg($command); // Use quotes on command + if (preg_match("/\s/", $command)) { + $command = $command = escapeshellarg($command); // Use quotes on command + } $param = $dolibarr_main_db_name; $param .= " -h ".$dolibarr_main_db_host; - if (!empty($dolibarr_main_db_port)) $param .= " -P ".$dolibarr_main_db_port; + if (!empty($dolibarr_main_db_port)) { + $param .= " -P ".$dolibarr_main_db_port; + } $param .= " -u ".$dolibarr_main_db_user; $paramcrypted = $param; $paramclear = $param; - if (!empty($dolibarr_main_db_pass)) - { + if (!empty($dolibarr_main_db_pass)) { $paramcrypted .= " -p".preg_replace('/./i', '*', $dolibarr_main_db_pass); $paramclear .= " -p".$dolibarr_main_db_pass; } @@ -158,26 +163,29 @@ if (in_array($type, array('mysql', 'mysqli'))) //else print '
'.$langs->trans("HidePassword").''; print '
'; print ''; -} elseif (in_array($type, array('pgsql'))) -{ +} elseif (in_array($type, array('pgsql'))) { print '
'; print 'Restore PostgreSQL'; print '
'; // Parameteres execution $command = $db->getPathOfRestore(); - if (preg_match("/\s/", $command)) $command = $command = escapeshellarg($command); // Use quotes on command + if (preg_match("/\s/", $command)) { + $command = $command = escapeshellarg($command); // Use quotes on command + } $param = " -d ".$dolibarr_main_db_name; $param .= " -h ".$dolibarr_main_db_host; - if (!empty($dolibarr_main_db_port)) $param .= " -p ".$dolibarr_main_db_port; + if (!empty($dolibarr_main_db_port)) { + $param .= " -p ".$dolibarr_main_db_port; + } $param .= " -U ".$dolibarr_main_db_user; $paramcrypted = $param; $paramclear = $param; /*if (! empty($dolibarr_main_db_pass)) - { - $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass); - $paramclear.=" -p".$dolibarr_main_db_pass; - }*/ + { + $paramcrypted.=" -p".preg_replace('/./i','*',$dolibarr_main_db_pass); + $paramclear.=" -p".$dolibarr_main_db_pass; + }*/ $paramcrypted .= " -W"; $paramclear .= " -W"; // With psql: diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index b2fd7f5c2ee..0fe8be7d50c 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -40,15 +40,22 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action +if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { + $page = 0; +} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action $offset = $limit * $page; -if (!$sortorder) $sortorder = "DESC"; -if (!$sortfield) $sortfield = "date"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "date"; +} -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} -if ($file && !$what) -{ +if ($file && !$what) { //print DOL_URL_ROOT.'/dolibarr_export.php'; header("Location: ".DOL_URL_ROOT.'/admin/tools/dolibarr_export.php?msg='.urlencode($langs->trans("ErrorFieldRequired", $langs->transnoentities("ExportMethod"))).(GETPOST('page_y', 'int') ? '&page_y='.GETPOST('page_y', 'int') : '')); exit; @@ -61,12 +68,14 @@ $errormsg = ''; * Actions */ -if ($action == 'delete') -{ +if ($action == 'delete') { $file = $conf->admin->dir_output.'/'.GETPOST('urlfile'); $ret = dol_delete_file($file, 1); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); + } $action = ''; } @@ -81,8 +90,7 @@ $_SESSION["commandbackupresult"] = ''; // Increase limit of time. Works only if we are not in safe mode $ExecTimeLimit = 600; // Set it to 0 to not use a forced time limit -if (!empty($ExecTimeLimit)) -{ +if (!empty($ExecTimeLimit)) { $err = error_reporting(); error_reporting(0); // Disable all errors //error_reporting(E_ALL); @@ -90,8 +98,7 @@ if (!empty($ExecTimeLimit)) error_reporting($err); } $MemoryLimit = 0; -if (!empty($MemoryLimit)) -{ +if (!empty($MemoryLimit)) { @ini_set('memory_limit', $MemoryLimit); } @@ -118,29 +125,24 @@ $utils = new Utils($db); // MYSQL -if ($what == 'mysql') -{ +if ($what == 'mysql') { $cmddump = GETPOST("mysqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump = dol_sanitizePathName($cmddump); - if (!empty($dolibarr_main_restrict_os_commands)) - { + if (!empty($dolibarr_main_restrict_os_commands)) { $arrayofallowedcommand = explode(',', $dolibarr_main_restrict_os_commands); dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); $basenamecmddump = basename($cmddump); - if (!in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command - { + if (!in_array($basenamecmddump, $arrayofallowedcommand)) { // the provided command $cmddump must be an allowed command $errormsg = $langs->trans('CommandIsNotInsideAllowedCommands'); } } - if (!$errormsg && $cmddump) - { + if (!$errormsg && $cmddump) { dolibarr_set_const($db, 'SYSTEMTOOLS_MYSQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); } - if (!$errormsg) - { + if (!$errormsg) { $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); $errormsg = $utils->error; $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; @@ -149,8 +151,7 @@ if ($what == 'mysql') } // MYSQL NO BIN -if ($what == 'mysqlnobin') -{ +if ($what == 'mysqlnobin') { $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); $errormsg = $utils->error; @@ -159,30 +160,27 @@ if ($what == 'mysqlnobin') } // POSTGRESQL -if ($what == 'postgresql') -{ +if ($what == 'postgresql') { $cmddump = GETPOST("postgresqldump", 'none'); // Do not sanitize here with 'alpha', will be sanitize later by dol_sanitizePathName and escapeshellarg $cmddump = dol_sanitizePathName($cmddump); /* Not required, the command is output on screen but not ran for pgsql - if (! empty($dolibarr_main_restrict_os_commands)) - { - $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); - dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); - $basenamecmddump=basename($cmddump); - if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command - { - $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); - } - } */ - - if (!$errormsg && $cmddump) + if (! empty($dolibarr_main_restrict_os_commands)) { + $arrayofallowedcommand=explode(',', $dolibarr_main_restrict_os_commands); + dol_syslog("Command are restricted to ".$dolibarr_main_restrict_os_commands.". We check that one of this command is inside ".$cmddump); + $basenamecmddump=basename($cmddump); + if (! in_array($basenamecmddump, $arrayofallowedcommand)) // the provided command $cmddump must be an allowed command + { + $errormsg=$langs->trans('CommandIsNotInsideAllowedCommands'); + } + } */ + + if (!$errormsg && $cmddump) { dolibarr_set_const($db, 'SYSTEMTOOLS_POSTGRESQLDUMP', $cmddump, 'chaine', 0, '', $conf->entity); } - if (!$errormsg) - { + if (!$errormsg) { $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); $errormsg = $utils->error; $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; @@ -193,8 +191,7 @@ if ($what == 'postgresql') } -if ($errormsg) -{ +if ($errormsg) { setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); $resultstring = ''; @@ -202,8 +199,7 @@ if ($errormsg) $_SESSION["commandbackupresult"] = $resultstring; } else { - if ($what) - { + if ($what) { setEventMessages($langs->trans("BackupFileSuccessfullyCreated").'.
'.$langs->trans("YouCanDownloadBackupFile"), null, 'mesgs'); $resultstring = '
'; diff --git a/htdocs/admin/tools/export_files.php b/htdocs/admin/tools/export_files.php index 6e0b0508a07..f68bc7382b5 100644 --- a/htdocs/admin/tools/export_files.php +++ b/htdocs/admin/tools/export_files.php @@ -42,13 +42,23 @@ $file = preg_replace('/(\.zip|\.tar|\.tgz|\.gz|\.tar\.gz|\.bz2)$/i', '', $file); $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (!$sortorder) $sortorder = "DESC"; -if (!$sortfield) $sortfield = "date"; -if ($page < 0) { $page = 0; } elseif (empty($page)) $page = 0; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "date"; +} +if ($page < 0) { + $page = 0; +} elseif (empty($page)) { + $page = 0; +} $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $errormsg = ''; @@ -57,13 +67,15 @@ $errormsg = ''; * Actions */ -if ($action == 'delete') -{ +if ($action == 'delete') { $filerelative = dol_sanitizeFileName(GETPOST('urlfile', 'alpha')); $filepath = $conf->admin->dir_output.'/'.$filerelative; $ret = dol_delete_file($filepath, 1); - if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filerelative), null, 'mesgs'); - else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filerelative), null, 'errors'); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", $filerelative), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", $filerelative), null, 'errors'); + } $action = ''; } @@ -74,8 +86,7 @@ if ($action == 'delete') // Increase limit of time. Works only if we are not in safe mode $ExecTimeLimit = 1800; // 30mn -if (!empty($ExecTimeLimit)) -{ +if (!empty($ExecTimeLimit)) { $err = error_reporting(); error_reporting(0); // Disable all errors //error_reporting(E_ALL); @@ -83,8 +94,7 @@ if (!empty($ExecTimeLimit)) error_reporting($err); } $MemoryLimit = 0; -if (!empty($MemoryLimit)) -{ +if (!empty($MemoryLimit)) { @ini_set('memory_limit', $MemoryLimit); } @@ -110,12 +120,10 @@ $result = dol_mkdir($outputdir); $utils = new Utils($db); -if ($compression == 'zip') -{ +if ($compression == 'zip') { $file .= '.zip'; $ret = dol_compress_dir(DOL_DATA_ROOT, $outputdir."/".$file, $compression, '/(\.back|\.old|\.log|[\\\/]temp[\\\/]|documents[\\\/]admin[\\\/]documents[\\\/])/i'); - if ($ret < 0) - { + if ($ret < 0) { if ($ret == -2) { $langs->load("errors"); $errormsg = $langs->trans("ErrNoZipEngine"); @@ -124,8 +132,7 @@ if ($compression == 'zip') $errormsg = $langs->trans("ErrorFailedToWriteInDir", $outputdir); } } -} elseif (in_array($compression, array('gz', 'bz'))) -{ +} elseif (in_array($compression, array('gz', 'bz'))) { $userlogin = ($user->login ? $user->login : 'unknown'); $outputfile = $conf->admin->dir_temp.'/export_files.'.$userlogin.'.out'; // File used with popen method @@ -137,34 +144,29 @@ if ($compression == 'zip') $result = $utils->executeCLI($cmd, $outputfile); $retval = $result['error']; - if ($result['result'] || !empty($retval)) - { + if ($result['result'] || !empty($retval)) { $langs->load("errors"); dol_syslog("Documents tar retval after exec=".$retval, LOG_ERR); $errormsg = 'Error tar generation return '.$retval; } else { - if ($compression == 'gz') - { + if ($compression == 'gz') { $cmd = "gzip -f ".$outputdir."/".$file; } - if ($compression == 'bz') - { + if ($compression == 'bz') { $cmd = "bzip2 -f ".$outputdir."/".$file; } $result = $utils->executeCLI($cmd, $outputfile); $retval = $result['error']; - if ($result['result'] || !empty($retval)) - { + if ($result['result'] || !empty($retval)) { $errormsg = 'Error '.$compression.' generation return '.$retval; unlink($outputdir."/".$file); } } } -if ($errormsg) -{ +if ($errormsg) { setEventMessages($langs->trans("Error")." : ".$errormsg, null, 'errors'); } diff --git a/htdocs/admin/tools/index.php b/htdocs/admin/tools/index.php index 06de5cc285c..4c89ab60989 100644 --- a/htdocs/admin/tools/index.php +++ b/htdocs/admin/tools/index.php @@ -27,8 +27,9 @@ require '../../main.inc.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "admin")); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} /* diff --git a/htdocs/admin/tools/listevents.php b/htdocs/admin/tools/listevents.php index 5a7a60bee2f..f49886594a7 100644 --- a/htdocs/admin/tools/listevents.php +++ b/htdocs/admin/tools/listevents.php @@ -28,15 +28,15 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -49,12 +49,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = "dateevent"; -if (!$sortorder) $sortorder = "DESC"; +if (!$sortfield) { + $sortfield = "dateevent"; +} +if (!$sortorder) { + $sortorder = "DESC"; +} $search_code = GETPOST("search_code", "alpha"); $search_ip = GETPOST("search_ip", "alpha"); @@ -63,23 +69,29 @@ $search_desc = GETPOST("search_desc", "alpha"); $search_ua = GETPOST("search_ua", "restricthtml"); $search_prefix_session = GETPOST("search_prefix_session", "restricthtml"); -if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); -else $date_start = -1; -if (GETPOST("date_endmonth") == '' || GETPOST("date_endmonth") > 0) $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); -else $date_end = -1; +if (GETPOST("date_startmonth") == '' || GETPOST("date_startmonth") > 0) { + $date_start = dol_mktime(0, 0, 0, GETPOST("date_startmonth"), GETPOST("date_startday"), GETPOST("date_startyear")); +} else { + $date_start = -1; +} +if (GETPOST("date_endmonth") == '' || GETPOST("date_endmonth") > 0) { + $date_end = dol_mktime(23, 59, 59, GETPOST("date_endmonth"), GETPOST("date_endday"), GETPOST("date_endyear")); +} else { + $date_end = -1; +} // checks:if date_start>date_end then date_end=date_start + 24 hours -if ($date_start > 0 && $date_end > 0 && $date_start > $date_end) $date_end = $date_start + 86400; +if ($date_start > 0 && $date_end > 0 && $date_start > $date_end) { + $date_end = $date_start + 86400; +} $now = dol_now(); $nowarray = dol_getdate($now); -if (empty($date_start)) // We define date_start and date_end -{ +if (empty($date_start)) { // We define date_start and date_end $date_start = dol_get_first_day($nowarray['year'], $nowarray['mon'], false); } -if (empty($date_end)) -{ +if (empty($date_end)) { $date_end = dol_mktime(23, 59, 59, $nowarray['mon'], $nowarray['mday'], $nowarray['year']); } // Set $date_startmonth... @@ -110,8 +122,7 @@ $arrayfields = array( $now = dol_now(); // Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $date_start = -1; $date_end = -1; $search_code = ''; @@ -123,8 +134,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' } // Purge audit events -if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) -{ +if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) { $error = 0; $db->begin(); @@ -136,8 +146,7 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) dol_syslog("listevents purge", LOG_DEBUG); $resql = $db->query($sql); - if (!$resql) - { + if (!$resql) { $error++; setEventMessages($db->lasterror(), null, 'errors'); } @@ -150,8 +159,7 @@ if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) $securityevent->description = $text; $result = $securityevent->create($user); - if ($result > 0) - { + if ($result > 0) { $db->commit(); dol_syslog($text, LOG_WARNING); } else { @@ -180,57 +188,101 @@ $sql .= " u.login, u.admin, u.entity, u.firstname, u.lastname, u.statut as statu $sql .= " FROM ".MAIN_DB_PREFIX."events as e"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid = e.fk_user"; $sql .= " WHERE e.entity IN (".getEntity('event').")"; -if ($date_start > 0) $sql .= " AND e.dateevent >= '".$db->idate($date_start)."'"; -if ($date_end > 0) $sql .= " AND e.dateevent <= '".$db->idate($date_end)."'"; -if ($search_code) { $usefilter++; $sql .= natural_search("e.type", $search_code, 0); } -if ($search_ip) { $usefilter++; $sql .= natural_search("e.ip", $search_ip, 0); } -if ($search_user) { $usefilter++; $sql .= natural_search("u.login", $search_user, 0); } -if ($search_desc) { $usefilter++; $sql .= natural_search("e.description", $search_desc, 0); } -if ($search_ua) { $usefilter++; $sql .= natural_search("e.user_agent", $search_ua, 0); } -if ($search_prefix_session) { $usefilter++; $sql .= natural_search("e.prefix_session", $search_prefix_session, 0); } +if ($date_start > 0) { + $sql .= " AND e.dateevent >= '".$db->idate($date_start)."'"; +} +if ($date_end > 0) { + $sql .= " AND e.dateevent <= '".$db->idate($date_end)."'"; +} +if ($search_code) { + $usefilter++; $sql .= natural_search("e.type", $search_code, 0); +} +if ($search_ip) { + $usefilter++; $sql .= natural_search("e.ip", $search_ip, 0); +} +if ($search_user) { + $usefilter++; $sql .= natural_search("u.login", $search_user, 0); +} +if ($search_desc) { + $usefilter++; $sql .= natural_search("e.description", $search_desc, 0); +} +if ($search_ua) { + $usefilter++; $sql .= natural_search("e.user_agent", $search_ua, 0); +} +if ($search_prefix_session) { + $usefilter++; $sql .= natural_search("e.prefix_session", $search_prefix_session, 0); +} $sql .= $db->order($sortfield, $sortorder); // Count total nb of records $nbtotalofrecords = ''; /*if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - $nbtotalofrecords = $db->num_rows($result); - if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 - { - $page = 0; - $offset = 0; - } + $result = $db->query($sql); + $nbtotalofrecords = $db->num_rows($result); + if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0 + { + $page = 0; + $offset = 0; + } }*/ $sql .= $db->plimit($conf->liste_limit + 1, $offset); //print $sql; $result = $db->query($sql); -if ($result) -{ +if ($result) { $num = $db->num_rows($result); $i = 0; $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); - if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); - if ($search_code) $param .= '&search_code='.urlencode($search_code); - if ($search_ip) $param .= '&search_ip='.urlencode($search_ip); - if ($search_user) $param .= '&search_user='.urlencode($search_user); - if ($search_desc) $param .= '&search_desc='.urlencode($search_desc); - if ($search_ua) $param .= '&search_ua='.urlencode($search_ua); - if ($search_prefix_session) $param .= '&search_prefix_session='.urlencode($search_prefix_session); - if ($date_startmonth) $param .= "&date_startmonth=".urlencode($date_startmonth); - if ($date_startday) $param .= "&date_startday=".urlencode($date_startday); - if ($date_startyear) $param .= "&date_startyear=".urlencode($date_startyear); - if ($date_endmonth) $param .= "&date_endmonth=".urlencode($date_endmonth); - if ($date_endday) $param .= "&date_endday=".urlencode($date_endday); - if ($date_endyear) $param .= "&date_endyear=".urlencode($date_endyear); + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); + } + if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); + } + if ($optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); + } + if ($search_code) { + $param .= '&search_code='.urlencode($search_code); + } + if ($search_ip) { + $param .= '&search_ip='.urlencode($search_ip); + } + if ($search_user) { + $param .= '&search_user='.urlencode($search_user); + } + if ($search_desc) { + $param .= '&search_desc='.urlencode($search_desc); + } + if ($search_ua) { + $param .= '&search_ua='.urlencode($search_ua); + } + if ($search_prefix_session) { + $param .= '&search_prefix_session='.urlencode($search_prefix_session); + } + if ($date_startmonth) { + $param .= "&date_startmonth=".urlencode($date_startmonth); + } + if ($date_startday) { + $param .= "&date_startday=".urlencode($date_startday); + } + if ($date_startyear) { + $param .= "&date_startyear=".urlencode($date_startyear); + } + if ($date_endmonth) { + $param .= "&date_endmonth=".urlencode($date_endmonth); + } + if ($date_endday) { + $param .= "&date_endday=".urlencode($date_endday); + } + if ($date_endyear) { + $param .= "&date_endyear=".urlencode($date_endyear); + } $langs->load('withdrawals'); - if ($num) - { + if ($num) { $center = ''.$langs->trans("Purge").''; } @@ -239,8 +291,7 @@ if ($result) print_barre_liste($langs->trans("ListOfSecurityEvents"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $nbtotalofrecords, 'setup', 0, '', '', $limit); - if ($action == 'purge') - { + if ($action == 'purge') { $formquestion = array(); print $form->formconfirm($_SERVER["PHP_SELF"].'?noparam=noparam', $langs->trans('PurgeAuditEvents'), $langs->trans('ConfirmPurgeAuditEvents'), 'confirm_purge', $formquestion, 'no', 1); } @@ -284,15 +335,13 @@ if ($result) //print ''; print '
'; print ''; print ''; print ''; print '
'; - if ($obj->fk_user) - { + if ($obj->fk_user) { $userstatic->id = $obj->fk_user; $userstatic->login = $obj->login; $userstatic->admin = $obj->admin; @@ -351,39 +396,38 @@ if ($result) $userstatic->status = $obj->status; print $userstatic->getLoginUrl(1); - if (!empty($conf->multicompany->enabled) && $userstatic->admin && !$userstatic->entity) - { + if (!empty($conf->multicompany->enabled) && $userstatic->admin && !$userstatic->entity) { print img_picto($langs->trans("SuperAdministrator"), 'redstar', 'class="valignmiddle paddingleft"'); - } elseif ($userstatic->admin) - { + } elseif ($userstatic->admin) { print img_picto($langs->trans("Administrator"), 'star', 'class="valignmiddle paddingleft"'); } - } else print ' '; + } else { + print ' '; + } print ''; $text = $langs->trans($obj->description); $reg = array(); - if (preg_match('/\((.*)\)(.*)/i', $obj->description, $reg)) - { + if (preg_match('/\((.*)\)(.*)/i', $obj->description, $reg)) { $val = explode(',', $reg[1]); $text = $langs->trans($val[0], isset($val[1]) ? $val[1] : '', isset($val[2]) ? $val[2] : '', isset($val[3]) ? $val[3] : '', isset($val[4]) ? $val[4] : ''); - if (!empty($reg[2])) $text .= $reg[2]; + if (!empty($reg[2])) { + $text .= $reg[2]; + } } print dol_escape_htmltag($text); print ''; print $obj->user_agent; print ''; print $obj->prefix_session; @@ -401,10 +445,12 @@ if ($result) $i++; } - if ($num == 0) - { - if ($usefilter) print '
'.$langs->trans("NoEventFoundWithCriteria").'
'.$langs->trans("NoEventOrNoAuditSetup").'
'.$langs->trans("NoEventFoundWithCriteria").'
'.$langs->trans("NoEventOrNoAuditSetup").'
"; print ""; diff --git a/htdocs/admin/tools/listsessions.php b/htdocs/admin/tools/listsessions.php index d8e0a0383a2..61d2b1cea58 100644 --- a/htdocs/admin/tools/listsessions.php +++ b/htdocs/admin/tools/listsessions.php @@ -28,15 +28,15 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "install", "users", "other")); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); // Security check -if ($user->socid > 0) -{ +if ($user->socid > 0) { $action = ''; $socid = $user->socid; } @@ -45,12 +45,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortorder) $sortorder = "DESC"; -if (!$sortfield) $sortfield = "dateevent"; +if (!$sortorder) { + $sortorder = "DESC"; +} +if (!$sortfield) { + $sortfield = "dateevent"; +} /* @@ -58,25 +64,20 @@ if (!$sortfield) $sortfield = "dateevent"; */ // Purge sessions -if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) -{ +if ($action == 'confirm_purge' && $confirm == 'yes' && $user->admin) { $res = purgeSessions(session_id()); } // Lock new sessions -if ($action == 'confirm_lock' && $confirm == 'yes' && $user->admin) -{ - if (dolibarr_set_const($db, 'MAIN_ONLY_LOGIN_ALLOWED', $user->login, 'text', 1, 'Logon is restricted to a particular user', 0) < 0) - { +if ($action == 'confirm_lock' && $confirm == 'yes' && $user->admin) { + if (dolibarr_set_const($db, 'MAIN_ONLY_LOGIN_ALLOWED', $user->login, 'text', 1, 'Logon is restricted to a particular user', 0) < 0) { dol_print_error($db); } } // Unlock new sessions -if ($action == 'confirm_unlock' && $user->admin) -{ - if (dolibarr_del_const($db, 'MAIN_ONLY_LOGIN_ALLOWED', -1) < 0) - { +if ($action == 'confirm_unlock' && $user->admin) { + if (dolibarr_del_const($db, 'MAIN_ONLY_LOGIN_ALLOWED', -1) < 0) { dol_print_error($db); } } @@ -107,22 +108,23 @@ $suhosin = empty($phparray['suhosin']["suhosin.session.encrypt"]["local"]) ? '' print ''.$langs->trans("SessionSaveHandler").': '.$savehandler.'
'; print ''.$langs->trans("SessionSavePath").': '.$savepath.'
'; -if ($openbasedir) print ''.$langs->trans("OpenBaseDir").': '.$openbasedir.'
'; -if ($suhosin) print ''.$langs->trans("SuhosinSessionEncrypt").': '.$suhosin.'
'; +if ($openbasedir) { + print ''.$langs->trans("OpenBaseDir").': '.$openbasedir.'
'; +} +if ($suhosin) { + print ''.$langs->trans("SuhosinSessionEncrypt").': '.$suhosin.'
'; +} print '
'; -if ($action == 'purge') -{ +if ($action == 'purge') { $formquestion = array(); print $form->formconfirm($_SERVER["PHP_SELF"].'?noparam=noparam', $langs->trans('PurgeSessions'), $langs->trans('ConfirmPurgeSessions'), 'confirm_purge', $formquestion, 'no', 2); -} elseif ($action == 'lock') -{ +} elseif ($action == 'lock') { $formquestion = array(); print $form->formconfirm($_SERVER["PHP_SELF"].'?noparam=noparam', $langs->trans('LockNewSessions'), $langs->trans('ConfirmLockNewSessions', $user->login), 'confirm_lock', $formquestion, 'no', 1); } -if ($savehandler == 'files') -{ +if ($savehandler == 'files') { print ''; print ''; print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "login", "", "", 'align="left"', $sortfield, $sortorder); @@ -134,8 +136,7 @@ if ($savehandler == 'files') print_liste_field_titre(''); print "\n"; - foreach ($listofsessions as $key => $sessionentry) - { + foreach ($listofsessions as $key => $sessionentry) { print ''; // Login @@ -143,8 +144,11 @@ if ($savehandler == 'files') // ID print ''; // Date creation @@ -165,8 +169,7 @@ if ($savehandler == 'files') $i++; } - if (count($listofsessions) == 0) - { + if (count($listofsessions) == 0) { print ''; } print "
'; - if ("$key" == session_id()) print $form->textwithpicto($key, $langs->trans("YourSession")); - else print $key; + if ("$key" == session_id()) { + print $form->textwithpicto($key, $langs->trans("YourSession")); + } else { + print $key; + } print '
'.$langs->trans("NoSessionFound", $savepath, $openbasedir).'
"; @@ -181,17 +184,14 @@ if ($savehandler == 'files') print '
'; -if (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) -{ +if (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) { print ''.$langs->trans("LockNewSessions").''; } else { print ''.$langs->trans("UnlockNewSessions").''; } -if ($savehandler == 'files') -{ - if (count($listofsessions)) - { +if ($savehandler == 'files') { + if (count($listofsessions)) { print ''.$langs->trans("PurgeSessions").''; } } diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index f3266a8c5d0..e20b9c2b13a 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -26,8 +26,9 @@ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->load("admin"); -if (!$user->admin) +if (!$user->admin) { accessforbidden(); +} $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); @@ -36,8 +37,7 @@ $choice = GETPOST('choice', 'aZ09'); // Define filelog to discard it from purge $filelog = ''; -if (!empty($conf->syslog->enabled)) -{ +if (!empty($conf->syslog->enabled)) { $filelog = $conf->global->SYSLOG_FILE; $filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog); } @@ -46,12 +46,10 @@ if (!empty($conf->syslog->enabled)) /* * Actions */ -if ($action == 'purge' && !preg_match('/^confirm/i', $choice) && ($choice != 'allfiles' || $confirm == 'yes')) -{ +if ($action == 'purge' && !preg_match('/^confirm/i', $choice) && ($choice != 'allfiles' || $confirm == 'yes')) { // Increase limit of time. Works only if we are not in safe mode $ExecTimeLimit = 600; - if (!empty($ExecTimeLimit)) - { + if (!empty($ExecTimeLimit)) { $err = error_reporting(); error_reporting(0); // Disable all errors //error_reporting(E_ALL); diff --git a/htdocs/admin/tools/update.php b/htdocs/admin/tools/update.php index f39766818f3..5a6ff94ce57 100644 --- a/htdocs/admin/tools/update.php +++ b/htdocs/admin/tools/update.php @@ -32,7 +32,9 @@ $langs->loadLangs(array("admin", "other")); $action = GETPOST('action', 'aZ09'); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} if (GETPOST('msg', 'alpha')) { setEventMessages(GETPOST('msg', 'alpha'), null, 'errors'); @@ -52,8 +54,7 @@ $version = '0.0'; * Actions */ -if ($action == 'getlastversion') -{ +if ($action == 'getlastversion') { $result = getURLContent('https://sourceforge.net/projects/dolibarr/rss'); //var_dump($result['content']); $sfurl = simplexml_load_string($result['content']); @@ -73,25 +74,22 @@ print '
'; print $langs->trans("CurrentVersion").' : '.DOL_VERSION.'
'; -if (function_exists('curl_init')) -{ +if (function_exists('curl_init')) { $conf->global->MAIN_USE_RESPONSE_TIMEOUT = 10; - if ($action == 'getlastversion') - { - if ($sfurl) - { + if ($action == 'getlastversion') { + if ($sfurl) { $i = 0; - while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) - { + while (!empty($sfurl->channel[0]->item[$i]->title) && $i < 10000) { $title = $sfurl->channel[0]->item[$i]->title; - if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) - { + if (preg_match('/([0-9]+\.([0-9\.]+))/', $title, $reg)) { $newversion = $reg[1]; $newversionarray = explode('.', $newversion); $versionarray = explode('.', $version); //var_dump($newversionarray);var_dump($versionarray); - if (versioncompare($newversionarray, $versionarray) > 0) $version = $newversion; + if (versioncompare($newversionarray, $versionarray) > 0) { + $version = $newversion; + } } $i++; } diff --git a/htdocs/admin/translation.php b/htdocs/admin/translation.php index dfaa8e576de..d6b8b2f9f66 100644 --- a/htdocs/admin/translation.php +++ b/htdocs/admin/translation.php @@ -30,7 +30,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php'; // Load translation files required by the page $langs->loadLangs(array("companies", "products", "admin", "sms", "other", "errors")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $id = GETPOST('rowid', 'int'); $action = GETPOST('action', 'aZ09'); @@ -46,12 +48,18 @@ $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (!$sortfield) $sortfield = 'lang,transkey'; -if (!$sortorder) $sortorder = 'ASC'; +if (!$sortfield) { + $sortfield = 'lang,transkey'; +} +if (!$sortorder) { + $sortorder = 'ASC'; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('admintranslation', 'globaladmin')); @@ -61,45 +69,48 @@ $hookmanager->initHooks(array('admintranslation', 'globaladmin')); * Actions */ -if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; } -if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; } +if (GETPOST('cancel', 'alpha')) { + $action = 'list'; $massaction = ''; +} +if (!GETPOST('confirmmassaction', 'alpha') && !empty($massaction) && $massaction != 'presend' && $massaction != 'confirm_presend') { + $massaction = ''; +} $parameters = array(); $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks -if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); +} include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; // Purge search criteria -if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers -{ +if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers $transkey = ''; $transvalue = ''; $toselect = ''; $search_array_options = array(); } -if ($action == 'setMAIN_ENABLE_OVERWRITE_TRANSLATION') -{ - if (GETPOST('value')) dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, 'chaine', 0, '', $conf->entity); - else dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 0, 'chaine', 0, '', $conf->entity); +if ($action == 'setMAIN_ENABLE_OVERWRITE_TRANSLATION') { + if (GETPOST('value')) { + dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 1, 'chaine', 0, '', $conf->entity); + } else { + dolibarr_set_const($db, 'MAIN_ENABLE_OVERWRITE_TRANSLATION', 0, 'chaine', 0, '', $conf->entity); + } } -if ($action == 'update') -{ - if ($transvalue == '') - { +if ($action == 'update') { + if ($transvalue == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."overwrite_trans set transvalue = '".$db->escape($transvalue)."' WHERE rowid = ".GETPOST('rowid', 'int'); $result = $db->query($sql); - if ($result > 0) - { + if ($result > 0) { $db->commit(); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $action = ""; @@ -107,8 +118,7 @@ if ($action == 'update') $transvalue = ""; } else { $db->rollback(); - if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings'); } else { setEventMessages($db->lasterror(), null, 'errors'); @@ -118,33 +128,27 @@ if ($action == 'update') } } -if ($action == 'add') -{ +if ($action == 'add') { $error = 0; - if (empty($langcode)) - { + if (empty($langcode)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Language")), null, 'errors'); $error++; } - if ($transkey == '') - { + if ($transkey == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Key")), null, 'errors'); $error++; } - if ($transvalue == '') - { + if ($transvalue == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("NewTranslationStringToShow")), null, 'errors'); $error++; } - if (!$error) - { + if (!$error) { $db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."overwrite_trans(lang, transkey, transvalue, entity) VALUES ('".$db->escape($langcode)."','".$db->escape($transkey)."','".$db->escape($transvalue)."', ".$db->escape($conf->entity).")"; $result = $db->query($sql); - if ($result > 0) - { + if ($result > 0) { $db->commit(); setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $action = ""; @@ -152,8 +156,7 @@ if ($action == 'add') $transvalue = ""; } else { $db->rollback(); - if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { + if ($db->lasterrno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { setEventMessages($langs->trans("WarningAnEntryAlreadyExistForTransKey"), null, 'warnings'); } else { setEventMessages($db->lasterror(), null, 'errors'); @@ -164,12 +167,10 @@ if ($action == 'add') } // Delete line from delete picto -if ($action == 'delete') -{ +if ($action == 'delete') { $sql = "DELETE FROM ".MAIN_DB_PREFIX."overwrite_trans WHERE rowid = ".$db->escape($id); $result = $db->query($sql); - if ($result >= 0) - { + if ($result >= 0) { setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs'); } else { dol_print_error($db); @@ -194,8 +195,7 @@ $param = '&mode='.urlencode($mode); $enabledisablehtml = ''; $enabledisablehtml .= $langs->trans("EnableOverwriteTranslation").' '; -if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) -{ +if (empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { // Button off, click to enable $enabledisablehtml .= ''; $enabledisablehtml .= img_picto($langs->trans("Disabled"), 'switch_off'); @@ -215,16 +215,30 @@ print $form->textwithpicto(''.$langs->trans("Current print '
'; -if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); -if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); -if (isset($optioncss) && $optioncss != '') $param .= '&optioncss='.urlencode($optioncss); -if ($langcode) $param .= '&langcode='.urlencode($langcode); -if ($transkey) $param .= '&transkey='.urlencode($transkey); -if ($transvalue) $param .= '&transvalue='.urlencode($transvalue); +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { + $param .= '&contextpage='.urlencode($contextpage); +} +if ($limit > 0 && $limit != $conf->liste_limit) { + $param .= '&limit='.urlencode($limit); +} +if (isset($optioncss) && $optioncss != '') { + $param .= '&optioncss='.urlencode($optioncss); +} +if ($langcode) { + $param .= '&langcode='.urlencode($langcode); +} +if ($transkey) { + $param .= '&transkey='.urlencode($transkey); +} +if ($transvalue) { + $param .= '&transvalue='.urlencode($transvalue); +} print 'entity) && !empty($debug)) ? '?debug=1' : '').'" method="POST">'; -if (isset($optioncss) && $optioncss != '') print ''; +if (isset($optioncss) && $optioncss != '') { + print ''; +} print ''; print ''; print ''; @@ -234,14 +248,17 @@ $head = translation_prepare_head(); print dol_get_fiche_head($head, $mode, '', -1, ''); -if ($mode == 'overwrite') -{ +if ($mode == 'overwrite') { print ''; $disabled = ''; - if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disabled = ' disabled="disabled"'; + if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { + $disabled = ' disabled="disabled"'; + } $disablededit = ''; - if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) $disablededit = ' disabled'; + if ($action == 'edit' || empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION)) { + $disablededit = ' disabled'; + } print '
'; print img_info().' '.$langs->trans("SomeTranslationAreUncomplete"); @@ -281,14 +298,14 @@ if ($mode == 'overwrite') print '
'; - print ''; - print ''; - } - else - {*/ + { + print ''; + print ''; + print ''; + } + else + {*/ print ''; print ''; //} @@ -306,13 +323,11 @@ if ($mode == 'overwrite') dol_syslog("translation::select from table", LOG_DEBUG); $result = $db->query($sql); - if ($result) - { + if ($result) { $num = $db->num_rows($result); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($result); print "\n"; @@ -325,12 +340,11 @@ if ($mode == 'overwrite') // Value print ''; /*print ''; - print ''; - print ''; - print ''; - */ - if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) - { + print ''; + print ''; + print ''; + */ + if ($action == 'edit' && $obj->rowid == GETPOST('rowid', 'int')) { print ''; } else { print dol_escape_htmltag($obj->transvalue); @@ -360,8 +374,7 @@ if ($mode == 'overwrite') print ''; } -if ($mode == 'searchkey') -{ +if ($mode == 'searchkey') { $langcode = GETPOSTISSET('langcode') ? GETPOST('langcode') : $langs->defaultlang; $newlang = new Translate('', $conf); @@ -378,18 +391,23 @@ if ($mode == 'searchkey') $nbtotaloffiles = 0; $nbempty = 0; /*var_dump($langcode); - var_dump($transkey); - var_dump($transvalue);*/ - if (empty($langcode) || $langcode == '-1') $nbempty++; - if (empty($transkey)) $nbempty++; - if (empty($transvalue)) $nbempty++; + var_dump($transkey); + var_dump($transvalue);*/ + if (empty($langcode) || $langcode == '-1') { + $nbempty++; + } + if (empty($transkey)) { + $nbempty++; + } + if (empty($transvalue)) { + $nbempty++; + } if ($action == 'search' && ($nbempty > 999)) { // 999 to disable this setEventMessages($langs->trans("WarningAtLeastKeyOrTranslationRequired"), null, 'warnings'); } else { // Search into dir of modules (the $modulesdir is already a list that loop on $conf->file->dol_document_root) $i = 0; - foreach ($modulesdir as $keydir => $tmpsearchdir) - { + foreach ($modulesdir as $keydir => $tmpsearchdir) { $searchdir = $tmpsearchdir; // $searchdir can be '.../htdocs/core/modules/' or '.../htdocs/custom/mymodule/core/modules/' // Directory of translation files @@ -397,29 +415,36 @@ if ($mode == 'searchkey') $dir_lang_osencoded = dol_osencode($dir_lang); $filearray = dol_dir_list($dir_lang_osencoded, 'files', 0, '', '', $sortfield, (strtolower($sortorder) == 'asc' ?SORT_ASC:SORT_DESC), 1); - foreach ($filearray as $file) - { + foreach ($filearray as $file) { $tmpfile = preg_replace('/.lang/i', '', basename($file['name'])); $moduledirname = (basename(dirname(dirname($dir_lang)))); $langkey = $tmpfile; - if ($i > 0) $langkey .= '@'.$moduledirname; + if ($i > 0) { + $langkey .= '@'.$moduledirname; + } //var_dump($i.' - '.$keydir.' - '.$dir_lang_osencoded.' -> '.$moduledirname . ' / ' . $tmpfile.' -> '.$langkey); $result = $newlang->load($langkey, 0, 0, '', 0); // Load translation files + database overwrite $result = $newlangfileonly->load($langkey, 0, 0, '', 1); // Load translation files only - if ($result < 0) print 'Failed to load language file '.$tmpfile.'
'."\n"; - else $nbtotaloffiles++; + if ($result < 0) { + print 'Failed to load language file '.$tmpfile.'
'."\n"; + } else { + $nbtotaloffiles++; + } //print 'After loading lang '.$langkey.', newlang has '.count($newlang->tab_translate).' records
'."\n"; } $i++; } // Now search into translation array - foreach ($newlang->tab_translate as $key => $val) - { - if ($transkey && !preg_match('/'.preg_quote($transkey, '/').'/i', $key)) continue; - if ($transvalue && !preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) continue; + foreach ($newlang->tab_translate as $key => $val) { + if ($transkey && !preg_match('/'.preg_quote($transkey, '/').'/i', $key)) { + continue; + } + if ($transvalue && !preg_match('/'.preg_quote($transvalue, '/').'/i', $val)) { + continue; + } $recordtoshow[$key] = $val; } } @@ -428,11 +453,15 @@ if ($mode == 'searchkey') $nbtotalofrecordswithoutfilters = count($newlang->tab_translate); $nbtotalofrecords = count($recordtoshow); $num = $limit + 1; - if (($offset + $num) > $nbtotalofrecords) $num = $limit; + if (($offset + $num) > $nbtotalofrecords) { + $num = $limit; + } //print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder; $title = $langs->trans("TranslationKeySearch"); - if ($nbtotalofrecords > 0) $title .= ' ('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')'; + if ($nbtotalofrecords > 0) { + $title .= ' ('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')'; + } print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit, 0, 0, 1); print ''; @@ -461,12 +490,12 @@ if ($mode == 'searchkey') print ''; // Limit to superadmin /*if (! empty($conf->multicompany->enabled) && !$user->entity) - { - print '
'; - print ''; - } - else - {*/ + { + print ''; + print ''; + } + else + {*/ print ''; //} print '
'.$langcode.''.$key.''; print dol_escape_htmltag($val); print ''; @@ -501,8 +541,7 @@ if ($mode == 'searchkey') $sql .= " AND entity IN (".getEntity('overwrite_trans').")"; dol_syslog("translation::select from table", LOG_DEBUG); $result = $db->query($sql); - if ($result) - { + if ($result) { $obj = $db->fetch_object($result); } print ''.img_edit().''; @@ -516,8 +555,7 @@ if ($mode == 'searchkey') print ''.img_edit_add($langs->trans("Overwrite")).''; } - if (!empty($conf->global->MAIN_FEATURES_LEVEL)) - { + if (!empty($conf->global->MAIN_FEATURES_LEVEL)) { $transifexlangfile = '$'; // $ means 'All' //$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key; $transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key; @@ -529,9 +567,9 @@ if ($mode == 'searchkey') print $form->textwithpicto('', $htmltext, 1, 'warning'); } /*if (! empty($conf->multicompany->enabled) && !$user->entity) - { - print ''.$val.''.$val.'
'.$trigger['picto'].''.$trigger['file'].''.$langs->trans("UserMailRequired").' '; -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print ajax_constantonoff('USER_MAIL_REQUIRED'); } else { - if (empty($conf->global->USER_MAIL_REQUIRED)) - { + if (empty($conf->global->USER_MAIL_REQUIRED)) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; @@ -172,12 +159,10 @@ print ''.$langs->trans("UserHideInactive").' '; -if ($conf->use_javascript_ajax) -{ +if ($conf->use_javascript_ajax) { print ajax_constantonoff('USER_HIDE_INACTIVE_IN_COMBOBOX'); } else { - if (empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) - { + if (empty($conf->global->USER_HIDE_INACTIVE_IN_COMBOBOX)) { print ''.img_picto($langs->trans("Disabled"), 'off').''; } else { print ''.img_picto($langs->trans("Enabled"), 'on').''; @@ -198,12 +183,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -226,29 +209,21 @@ print "
'; print (empty($module->name) ? $name : $module->name); print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print ''."\n"; print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -284,8 +264,7 @@ foreach ($dirmodels as $reldir) // Defaut print ''; - if ($conf->global->USER_ADDON_PDF == $name) - { + if ($conf->global->USER_ADDON_PDF == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -295,8 +274,7 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; @@ -310,8 +288,7 @@ foreach ($dirmodels as $reldir) // Preview print '
'; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); diff --git a/htdocs/admin/usergroup.php b/htdocs/admin/usergroup.php index 0725cc83f18..b73d3ce4f22 100644 --- a/htdocs/admin/usergroup.php +++ b/htdocs/admin/usergroup.php @@ -34,7 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page $langs->loadLangs(array("admin", "members", "users")); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $extrafields = new ExtraFields($db); @@ -48,25 +50,20 @@ $type = 'group'; include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; -if ($action == 'set_default') -{ +if ($action == 'set_default') { $ret = addDocumentModel($value, $type, $label, $scandir); $res = true; -} elseif ($action == 'del_default') -{ +} elseif ($action == 'del_default') { $ret = delDocumentModel($value, $type); - if ($ret > 0) - { - if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity); + if ($ret > 0) { + if ($conf->global->USERGROUP_ADDON_PDF_ODT == "$value") { + dolibarr_del_const($db, 'USERGROUP_ADDON_PDF_ODT', $conf->entity); + } } $res = true; -} - -// Set default model -elseif ($action == 'setdoc') -{ - if (dolibarr_set_const($db, "USERGROUP_ADDON_PDF_ODT", $value, 'chaine', 0, '', $conf->entity)) - { +} elseif ($action == 'setdoc') { + // Set default model + if (dolibarr_set_const($db, "USERGROUP_ADDON_PDF_ODT", $value, 'chaine', 0, '', $conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent $conf->global->USERGROUP_ADDON_PDF_ODT = $value; @@ -74,26 +71,21 @@ elseif ($action == 'setdoc') // On active le modele $ret = delDocumentModel($value, $type); - if ($ret > 0) - { + if ($ret > 0) { $ret = addDocumentModel($value, $type, $label, $scandir); } $res = true; -} elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) -{ +} elseif (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) - { + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { dol_print_error($db); } -} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) -{ +} elseif (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) { $code = $reg[1]; - if (dolibarr_del_const($db, $code, $conf->entity) > 0) - { + if (dolibarr_del_const($db, $code, $conf->entity) > 0) { header("Location: ".$_SERVER["PHP_SELF"]); exit; } else { @@ -127,12 +119,10 @@ $sql .= " FROM ".MAIN_DB_PREFIX."document_model"; $sql .= " WHERE type = '".$db->escape($type)."'"; $sql .= " AND entity = ".$conf->entity; $resql = $db->query($sql); -if ($resql) -{ +if ($resql) { $i = 0; $num_rows = $db->num_rows($resql); - while ($i < $num_rows) - { + while ($i < $num_rows) { $array = $db->fetch_array($resql); array_push($def, $array[0]); $i++; @@ -155,29 +145,21 @@ print "
'; print (empty($module->name) ? $name : $module->name); print "\n"; - if (method_exists($module, 'info')) print $module->info($langs); - else print $module->description; + if (method_exists($module, 'info')) { + print $module->info($langs); + } else { + print $module->description; + } print ''."\n"; print ''; print img_picto($langs->trans("Enabled"), 'switch_on'); @@ -213,8 +200,7 @@ foreach ($dirmodels as $reldir) // Defaut print ''; - if ($conf->global->USERGROUP_ADDON_PDF == $name) - { + if ($conf->global->USERGROUP_ADDON_PDF == $name) { print img_picto($langs->trans("Default"), 'on'); } else { print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').''; @@ -224,8 +210,7 @@ foreach ($dirmodels as $reldir) // Info $htmltooltip = ''.$langs->trans("Name").': '.$module->name; $htmltooltip .= '
'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown")); - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { $htmltooltip .= '
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; } $htmltooltip .= '

'.$langs->trans("FeaturesSupported").':'; @@ -239,8 +224,7 @@ foreach ($dirmodels as $reldir) // Preview print '
'; - if ($module->type == 'pdf') - { + if ($module->type == 'pdf') { print ''.img_object($langs->trans("Preview"), 'pdf').''; } else { print img_object($langs->trans("PreviewNotAvailable"), 'generic'); diff --git a/htdocs/admin/website.php b/htdocs/admin/website.php index 09225a6e4a8..311b67c21f2 100644 --- a/htdocs/admin/website.php +++ b/htdocs/admin/website.php @@ -42,7 +42,9 @@ $rowid = GETPOST('rowid', 'alpha'); $id = 1; -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $acts[0] = "activate"; $acts[1] = "disable"; @@ -54,13 +56,19 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; -if (empty($sortfield)) $sortfield = 'position, ref'; -if (empty($sortorder)) $sortorder = 'ASC'; +if (empty($sortfield)) { + $sortfield = 'position, ref'; +} +if (empty($sortorder)) { + $sortorder = 'ASC'; +} // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('website')); @@ -122,8 +130,7 @@ $sourceList = array(); */ // Actions add or modify a website -if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) -{ +if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) { $listfield = explode(',', $tabfield[$id]); $listfieldinsert = explode(',', $tabfieldinsert[$id]); $listfieldmodify = explode(',', $tabfieldinsert[$id]); @@ -131,10 +138,8 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) // Check that all fields are filled $ok = 1; - foreach ($listfield as $f => $value) - { - if ($value == 'ref' && (!GETPOSTISSET($value) || GETPOST($value) == '')) - { + foreach ($listfield as $f => $value) { + if ($value == 'ref' && (!GETPOSTISSET($value) || GETPOST($value) == '')) { $ok = 0; $fieldnamekey = $listfield[$f]; setEventMessages($langs->transnoentities("ErrorFieldRequired", $langs->transnoentities($fieldnamekey)), null, 'errors'); @@ -153,16 +158,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) } // Si verif ok et action add, on ajoute la ligne - if ($ok && GETPOST('actionadd', 'alpha')) - { - if ($tabrowid[$id]) - { + if ($ok && GETPOST('actionadd', 'alpha')) { + if ($tabrowid[$id]) { // Recupere id libre pour insertion $newid = 0; $sql = "SELECT max(".$tabrowid[$id].") newid from ".$tabname[$id]; $result = $db->query($sql); - if ($result) - { + if ($result) { $obj = $db->fetch_object($result); $newid = ($obj->newid + 1); } else { @@ -171,43 +173,48 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) } /* $website=new Website($db); - $website->ref= - $website->description= - $website->virtualhost= - $website->create($user); */ + $website->ref= + $website->description= + $website->virtualhost= + $website->create($user); */ // Add new entry $sql = "INSERT INTO ".$tabname[$id]." ("; // List of fields - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) { $sql .= $tabrowid[$id].","; + } $sql .= $tabfieldinsert[$id]; $sql .= ",status)"; $sql .= " VALUES("; // List of values - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldinsert)) { $sql .= $newid.","; + } $i = 0; - foreach ($listfieldinsert as $f => $value) - { + foreach ($listfieldinsert as $f => $value) { if ($value == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } if ($value == 'ref') { $_POST[$listfieldvalue[$i]] = strtolower($_POST[$listfieldvalue[$i]]); } - if ($i) $sql .= ","; - if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; - else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + if ($i) { + $sql .= ","; + } + if ($_POST[$listfieldvalue[$i]] == '') { + $sql .= "null"; + } else { + $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + } $i++; } $sql .= ",1)"; dol_syslog("actionadd", LOG_DEBUG); $result = $db->query($sql); - if ($result) // Add is ok - { + if ($result) { // Add is ok setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs'); unset($_POST); // Clean $_POST array, we keep only } else { @@ -220,9 +227,12 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) } // Si verif ok et action modify, on modifie la ligne - if ($ok && GETPOST('actionmodify', 'alpha')) - { - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } + if ($ok && GETPOST('actionmodify', 'alpha')) { + if ($tabrowid[$id]) { + $rowidcol = $tabrowid[$id]; + } else { + $rowidcol = "rowid"; + } $db->begin(); @@ -233,21 +243,24 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) // Modify entry $sql = "UPDATE ".$tabname[$id]." SET "; // Modifie valeur des champs - if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) - { + if ($tabrowid[$id] && !in_array($tabrowid[$id], $listfieldmodify)) { $sql .= $tabrowid[$id]."="; $sql .= "'".$db->escape($rowid)."', "; } $i = 0; - foreach ($listfieldmodify as $field) - { + foreach ($listfieldmodify as $field) { if ($field == 'entity') { $_POST[$listfieldvalue[$i]] = $conf->entity; } - if ($i) $sql .= ","; + if ($i) { + $sql .= ","; + } $sql .= $field."="; - if ($_POST[$listfieldvalue[$i]] == '') $sql .= "null"; - else $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + if ($_POST[$listfieldvalue[$i]] == '') { + $sql .= "null"; + } else { + $sql .= "'".$db->escape($_POST[$listfieldvalue[$i]])."'"; + } $i++; } $sql .= " WHERE ".$rowidcol." = ".((int) $rowid); @@ -255,16 +268,13 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) dol_syslog("actionmodify", LOG_DEBUG); //print $sql; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $newname = dol_sanitizeFileName(GETPOST('ref', 'aZ09')); - if ($newname != $website->ref) - { + if ($newname != $website->ref) { $srcfile = DOL_DATA_ROOT.'/website/'.$website->ref; $destfile = DOL_DATA_ROOT.'/website/'.$newname; - if (dol_is_dir($destfile)) - { + if (dol_is_dir($destfile)) { $error++; setEventMessages($langs->trans('ErrorDirAlreadyExists', $destfile), null, 'errors'); } else { @@ -273,8 +283,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) // We must now rename $website->ref into $newname inside files $arrayreplacement = array($website->ref.'/htmlheader.html' => $newname.'/htmlheader.html'); $listofilestochange = dol_dir_list($destfile, 'files', 0, '\.php$'); - foreach ($listofilestochange as $key => $value) - { + foreach ($listofilestochange as $key => $value) { dolReplaceInFile($value['fullname'], $arrayreplacement); } } @@ -284,8 +293,7 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) setEventMessages($db->lasterror(), null, 'errors'); } - if (!$error) - { + if (!$error) { $db->commit(); } else { $db->rollback(); @@ -294,20 +302,21 @@ if (GETPOST('actionadd', 'alpha') || GETPOST('actionmodify', 'alpha')) //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } -if (GETPOST('actioncancel', 'alpha')) -{ +if (GETPOST('actioncancel', 'alpha')) { //$_GET["id"]=GETPOST('id', 'int'); // Force affichage dictionnaire en cours d'edition } -if ($action == 'confirm_delete' && $confirm == 'yes') // delete -{ - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } +if ($action == 'confirm_delete' && $confirm == 'yes') { // delete + if ($tabrowid[$id]) { + $rowidcol = $tabrowid[$id]; + } else { + $rowidcol = "rowid"; + } $website = new Website($db); $website->fetch($rowid); - if ($website->id > 0) - { + if ($website->id > 0) { $sql = "DELETE from ".MAIN_DB_PREFIX."website_account WHERE fk_website = ".((int) $rowid); $result = $db->query($sql); @@ -319,18 +328,15 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete $sql = "DELETE from ".MAIN_DB_PREFIX."website WHERE rowid = ".((int) $rowid); $result = $db->query($sql); - if (!$result) - { - if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') - { + if (!$result) { + if ($db->errno() == 'DB_ERROR_CHILD_EXISTS') { setEventMessages($langs->transnoentities("ErrorRecordIsUsedByChild"), null, 'errors'); } else { dol_print_error($db); } } - if ($website->ref) - { + if ($website->ref) { dol_delete_dir_recursive($conf->website->dir_output.'/'.$website->ref); } } else { @@ -339,33 +345,37 @@ if ($action == 'confirm_delete' && $confirm == 'yes') // delete } // activate -if ($action == $acts[0]) -{ - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } +if ($action == $acts[0]) { + if ($tabrowid[$id]) { + $rowidcol = $tabrowid[$id]; + } else { + $rowidcol = "rowid"; + } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET status = 1 WHERE rowid = ".((int) $rowid); } $result = $db->query($sql); - if (!$result) - { + if (!$result) { dol_print_error($db); } } // disable -if ($action == $acts[1]) -{ - if ($tabrowid[$id]) { $rowidcol = $tabrowid[$id]; } else { $rowidcol = "rowid"; } +if ($action == $acts[1]) { + if ($tabrowid[$id]) { + $rowidcol = $tabrowid[$id]; + } else { + $rowidcol = "rowid"; + } if ($rowid) { $sql = "UPDATE ".$tabname[$id]." SET status = 0 WHERE rowid = ".((int) $rowid); } $result = $db->query($sql); - if (!$result) - { + if (!$result) { dol_print_error($db); } } @@ -407,8 +417,7 @@ print "
\n"; // Confirmation de la suppression de la ligne -if ($action == 'delete') -{ +if ($action == 'delete') { print $form->formconfirm($_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.$rowid, $langs->trans('DeleteWebsite'), $langs->trans('ConfirmDeleteWebsite'), 'confirm_delete', '', 0, 1, 220); } //var_dump($elementList); @@ -416,8 +425,7 @@ if ($action == 'delete') /* * Show website list */ -if ($id) -{ +if ($id) { // Complete requete recherche valeurs avec critere de tri $sql = $tabsql[$id]; $sql .= $db->order($sortfield, $sortorder); @@ -431,31 +439,37 @@ if ($id) print ''; // Form to add a new line - if ($tabname[$id]) - { + if ($tabname[$id]) { $fieldlist = explode(',', $tabfield[$id]); // Line for title print ''; - foreach ($fieldlist as $field => $value) - { - if ($fieldlist[$field] == 'date_creation') continue; + foreach ($fieldlist as $field => $value) { + if ($fieldlist[$field] == 'date_creation') { + continue; + } // Determine le nom du champ par rapport aux noms possibles // dans les dictionnaires de donnees $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate $align = ''; - if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } - if ($valuetoshow != '') - { + if ($fieldlist[$field] == 'lang') { + $valuetoshow = $langs->trans("Language"); + } + if ($valuetoshow != '') { print ''; } } @@ -469,20 +483,18 @@ if ($id) $obj = new stdClass(); // If data was already input, we define them in obj to populate input fields. - if (GETPOST('actionadd', 'alpha')) - { - foreach ($fieldlist as $key=>$val) - { - if (GETPOST($val, 'alpha')) + if (GETPOST('actionadd', 'alpha')) { + foreach ($fieldlist as $key => $val) { + if (GETPOST($val, 'alpha')) { $obj->$val = GETPOST($val); + } } } fieldListWebsites($fieldlist, $obj, $tabname[$id], 'add'); print ''; @@ -497,12 +509,10 @@ if ($id) // List of websites in database $resql = $db->query($sql); - if ($resql) - { + if ($resql) { $num = $db->num_rows($resql); $i = 0; - if ($num) - { + if ($num) { print '
'; print ''; @@ -514,8 +524,7 @@ if ($id) // Title of lines print ''; - foreach ($fieldlist as $field => $value) - { + foreach ($fieldlist as $field => $value) { // Determine le nom du champ par rapport aux noms possibles // dans les dictionnaires de donnees $showfield = 1; // Par defaut @@ -523,22 +532,29 @@ if ($id) $sortable = 1; $valuetoshow = ''; /* - $tmparray=getLabelOfField($fieldlist[$field]); - $showfield=$tmp['showfield']; - $valuetoshow=$tmp['valuetoshow']; - $align=$tmp['align']; - $sortable=$tmp['sortable']; + $tmparray=getLabelOfField($fieldlist[$field]); + $showfield=$tmp['showfield']; + $valuetoshow=$tmp['valuetoshow']; + $align=$tmp['align']; + $sortable=$tmp['sortable']; */ $valuetoshow = ucfirst($fieldlist[$field]); // Par defaut $valuetoshow = $langs->trans($valuetoshow); // try to translate - if ($fieldlist[$field] == 'lang') { $valuetoshow = $langs->trans("Language"); } - if ($fieldlist[$field] == 'type') { $valuetoshow = $langs->trans("Type"); } - if ($fieldlist[$field] == 'code') { $valuetoshow = $langs->trans("Code"); } - if ($fieldlist[$field] == 'date_creation') { $valuetoshow = $langs->trans("DateCreation"); } + if ($fieldlist[$field] == 'lang') { + $valuetoshow = $langs->trans("Language"); + } + if ($fieldlist[$field] == 'type') { + $valuetoshow = $langs->trans("Type"); + } + if ($fieldlist[$field] == 'code') { + $valuetoshow = $langs->trans("Code"); + } + if ($fieldlist[$field] == 'date_creation') { + $valuetoshow = $langs->trans("DateCreation"); + } // Affiche nom du champ - if ($showfield) - { + if ($showfield) { print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable ? $fieldlist[$field] : ''), ($page ? 'page='.$page.'&' : ''), "", "align=".$align, $sortfield, $sortorder); } } @@ -549,46 +565,48 @@ if ($id) print ''; // Lines with values - while ($i < $num) - { + while ($i < $num) { $obj = $db->fetch_object($resql); //print_r($obj); print ''; - if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) - { + if ($action == 'edit' && ($rowid == (!empty($obj->rowid) ? $obj->rowid : $obj->code))) { $tmpaction = 'edit'; $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook = $hookmanager->executeHooks('editWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; $errors = $hookmanager->errors; - if (empty($reshook)) fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit'); + if (empty($reshook)) { + fieldListWebsites($fieldlist, $obj, $tabname[$id], 'edit'); + } print ''; } else { - $tmpaction = 'view'; + $tmpaction = 'view'; $parameters = array('fieldlist'=>$fieldlist, 'tabname'=>$tabname[$id]); $reshook = $hookmanager->executeHooks('viewWebsiteFieldlist', $parameters, $obj, $tmpaction); // Note that $action and $object may have been modified by some hooks $error = $hookmanager->error; $errors = $hookmanager->errors; - if (empty($reshook)) - { - foreach ($fieldlist as $field => $value) - { + if (empty($reshook)) { + foreach ($fieldlist as $field => $value) { $showfield = 1; $align = "left"; $fieldname = $fieldlist[$field]; $valuetoshow = $obj->$fieldname; // Show value for field - if ($showfield) print ''; + if ($showfield) { + print ''; + } } } // Can an entry be erased or disabled ? $iserasable = 1; $isdisable = 1; // true by default - if ($obj->status) $iserasable = 0; // We can't delete a website on. Disable it first. + if ($obj->status) { + $iserasable = 0; // We can't delete a website on. Disable it first. + } $url = $_SERVER["PHP_SELF"].'?'.($page ? 'page='.$page.'&' : '').'sortfield='.$sortfield.'&sortorder='.$sortorder.'&rowid='.(!empty($obj->rowid) ? $obj->rowid : (!empty($obj->code) ? $obj->code : '')).'&code='.(!empty($obj->code) ?urlencode($obj->code) : '').'&'; @@ -601,8 +619,11 @@ if ($id) print ''; // Delete link - if ($iserasable) print ''; - else print ''; + if ($iserasable) { + print ''; + } else { + print ''; + } print "\n"; } @@ -644,27 +665,37 @@ function fieldListWebsites($fieldlist, $obj = '', $tabname = '', $context = '') $formadmin = new FormAdmin($db); - foreach ($fieldlist as $field => $value) - { + foreach ($fieldlist as $field => $value) { $fieldname = $fieldlist[$field]; - if ($fieldlist[$field] == 'lang') - { + if ($fieldlist[$field] == 'lang') { print ''; } elseif ($fieldlist[$field] == 'code' && isset($obj->$fieldname)) { print ''; } else { - if ($fieldlist[$field] == 'date_creation') continue; + if ($fieldlist[$field] == 'date_creation') { + continue; + } print ''; } diff --git a/htdocs/admin/website_options.php b/htdocs/admin/website_options.php index 8c803defb37..f72235eb8b0 100644 --- a/htdocs/admin/website_options.php +++ b/htdocs/admin/website_options.php @@ -40,7 +40,9 @@ $backtopage = GETPOST('backtopage', 'alpha'); $rowid = GETPOST('rowid', 'alpha'); -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} $status = 1; @@ -49,7 +51,9 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); -if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +if (empty($page) || $page == -1) { + $page = 0; +} // If $page is not defined, or '' or -1 $offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; @@ -97,8 +101,7 @@ $h++; print dol_get_fiche_head($head, 'options', '', -1); -if ($action == 'edit') -{ +if ($action == 'edit') { print ''; print ''; print ''; @@ -106,8 +109,7 @@ if ($action == 'edit') print '
'; - if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; - elseif (!empty($tabhelp[$id][$value])) - { - if ($value == 'virtualhost') print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual'); - else print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); - } else print $valuetoshow; + if (!empty($tabhelp[$id][$value]) && preg_match('/^http(s*):/i', $tabhelp[$id][$value])) { + print ''.$valuetoshow.' '.img_help(1, $valuetoshow).''; + } elseif (!empty($tabhelp[$id][$value])) { + if ($value == 'virtualhost') { + print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value], 1, 'help', '', 0, 2, 'tooltipvirtual'); + } else { + print $form->textwithpicto($valuetoshow, $tabhelp[$id][$value]); + } + } else { + print $valuetoshow; + } print ''; - if ($action != 'edit') - { + if ($action != 'edit') { print ''; } print '
 '; print ' '.$valuetoshow.''.$valuetoshow.''.img_edit().''.img_delete().''.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').''.img_delete().''.img_delete($langs->trans("DisableSiteFirst"), 'class="opacitymedium"').'
'; print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'lang'); print ''; $size = ''; - if ($fieldlist[$field] == 'code') $size = 'size="8" '; - if ($fieldlist[$field] == 'position') $size = 'size="4" '; - if ($fieldlist[$field] == 'libelle') $size = 'size="32" '; - if ($fieldlist[$field] == 'tracking') $size = 'size="92" '; - if ($fieldlist[$field] == 'sortorder') $size = 'size="2" '; + if ($fieldlist[$field] == 'code') { + $size = 'size="8" '; + } + if ($fieldlist[$field] == 'position') { + $size = 'size="4" '; + } + if ($fieldlist[$field] == 'libelle') { + $size = 'size="32" '; + } + if ($fieldlist[$field] == 'tracking') { + $size = 'size="92" '; + } + if ($fieldlist[$field] == 'sortorder') { + $size = 'size="2" '; + } print ''; print '
'; print ''; - foreach ($arrayofparameters as $key => $val) - { + foreach ($arrayofparameters as $key => $val) { print ''; @@ -125,8 +127,7 @@ if ($action == 'edit') print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); print '
'; print ''; - foreach ($arrayofparameters as $key => $val) - { + foreach ($arrayofparameters as $key => $val) { print ''; diff --git a/htdocs/admin/workflow.php b/htdocs/admin/workflow.php index 3997d007f97..916c54f4fb3 100644 --- a/htdocs/admin/workflow.php +++ b/htdocs/admin/workflow.php @@ -28,7 +28,9 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; // security check -if (!$user->admin) accessforbidden(); +if (!$user->admin) { + accessforbidden(); +} // Load translation files required by the page $langs->loadLangs(array("admin", "workflow", "propal", "workflow", "orders", "supplier_proposal", "receptions", "errors", 'sendings')); @@ -148,7 +150,8 @@ if (!empty($conf->modules_parts['workflow']) && is_array($conf->modules_parts['w // remove not available workflows (based on activated modules and global defined keys) $workflowcodes = array_filter($workflowcodes, function ($var) { - return $var['enabled']; }); + return $var['enabled']; +}); /* * View @@ -194,12 +197,24 @@ foreach ($workflowcodes as $key => $params) { $header = $langs->trans("AutomaticCreation"); } elseif (preg_match('/classify_(.*)/', $params['family'], $reg)) { $header = $langs->trans("AutomaticClassification"); - if ($reg[1] == 'proposal') $header .= ' - '.$langs->trans('Proposal'); - if ($reg[1] == 'order') $header .= ' - '.$langs->trans('Order'); - if ($reg[1] == 'supplier_proposal') $header .= ' - '.$langs->trans('SupplierProposal'); - if ($reg[1] == 'supplier_order') $header .= ' - '.$langs->trans('SupplierOrder'); - if ($reg[1] == 'reception') $header .= ' - '.$langs->trans('Reception'); - if ($reg[1] == 'shipping') $header .= ' - '.$langs->trans('Shipment'); + if ($reg[1] == 'proposal') { + $header .= ' - '.$langs->trans('Proposal'); + } + if ($reg[1] == 'order') { + $header .= ' - '.$langs->trans('Order'); + } + if ($reg[1] == 'supplier_proposal') { + $header .= ' - '.$langs->trans('SupplierProposal'); + } + if ($reg[1] == 'supplier_order') { + $header .= ' - '.$langs->trans('SupplierOrder'); + } + if ($reg[1] == 'reception') { + $header .= ' - '.$langs->trans('Reception'); + } + if ($reg[1] == 'shipping') { + $header .= ' - '.$langs->trans('Shipment'); + } } else { $header = $langs->trans("Description"); }
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; print $form->textwithpicto($langs->trans($key), $langs->trans($key.'Tooltip')); print ''.$conf->global->$key.'