diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php index 11e2e36dcfe..861f5208f5e 100644 --- a/htdocs/core/lib/admin.lib.php +++ b/htdocs/core/lib/admin.lib.php @@ -218,8 +218,7 @@ function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler if (!count($versionrequest) || !count($versionarray) || versioncompare($versionrequest, $versionarray) > 0) { $qualified = 0; } - } else // This is a test on a constant. For example when we have -- VMYSQLUTF8UNICODE, we test constant $conf->global->UTF8UNICODE - { + } else { // This is a test on a constant. For example when we have -- VMYSQLUTF8UNICODE, we test constant $conf->global->UTF8UNICODE $dbcollation = strtoupper(preg_replace('/_/', '', $conf->db->dolibarr_main_db_collation)); //var_dump($reg[2]); //var_dump($dbcollation); @@ -243,7 +242,9 @@ function run_sql($sqlfile, $silent = 1, $entity = 0, $usesavepoint = 1, $handler if (empty($nocommentremoval)) { $buf = preg_replace('/([,;ERLT\)])\s*--.*$/i', '\1', $buf); //remove comment from a line that not start with -- before add it to the buffer } - if ($buffer) $buffer .= ' '; + if ($buffer) { + $buffer .= ' '; + } $buffer .= trim($buf); } @@ -1231,7 +1232,7 @@ function activateModule($value, $withdeps = 1, $noconfverification = 0) if (!count($ret['errors'])) { $ret['nbmodules']++; - $ret['nbperms'] += (is_array($objMod->rights)?count($objMod->rights):0); + $ret['nbperms'] += (is_array($objMod->rights) ? count($objMod->rights) : 0); } return $ret; @@ -1278,8 +1279,7 @@ function unActivateModule($value, $requiredby = 1) if ($result <= 0) { $ret = $objMod->error; } - } else // We come here when we try to unactivate a module when module does not exists anymore in sources - { + } else { // We come here when we try to unactivate a module when module does not exists anymore in sources //print $dir.$modFile;exit; // TODO Replace this after DolibarrModules is moved as abstract class with a try catch to show module we try to disable has not been found or could not be loaded include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php'; @@ -1746,7 +1746,7 @@ function form_constantes($tableau, $strictw3c = 0, $helptext = '', $text = 'Valu if (!empty($tableau[$key]['tooltip'])) { print $form->textwithpicto($label ? $label : $langs->trans('Desc'.$const), $tableau[$key]['tooltip']); } else { - print ($label ? $label : $langs->trans('Desc'.$const)); + print($label ? $label : $langs->trans('Desc'.$const)); } if ($const == 'ADHERENT_MAILMAN_URL') { diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 17b639f0c2d..50e803c78c0 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -438,7 +438,7 @@ function actions_prepare_head($object) $head[$h][0] = DOL_URL_ROOT.'/resource/element_resource.php?element=action&element_id='.$object->id; $listofresourcelinked = $resource->getElementResources($object->element, $object->id); - $nbResources = (is_array($listofresourcelinked) ?count($listofresourcelinked) : 0); + $nbResources = (is_array($listofresourcelinked) ? count($listofresourcelinked) : 0); $head[$h][1] = $langs->trans("Resources"); if ($nbResources > 0) { $head[$h][1] .= (!getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER') ? ''.($nbResources).'' : ''); diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 3f152cf404e..17c41adf6d4 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -405,7 +405,7 @@ function ajax_dialog($title, $message, $w = 350, $h = 150) { global $langs; - $newtitle = dol_textishtml($title) ?dol_string_nohtmltag($title, 1) : $title; + $newtitle = dol_textishtml($title) ? dol_string_nohtmltag($title, 1) : $title; $msg = '
bar
' that wrongly ends up, without the trick, with 'bar
' // like 'abc' that wrongly ends up, without the trick, with 'abc
' @@ -7664,7 +7674,8 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = ' // No need to use a loop here, this step is not to sanitize (this is done at next step, this is to try to save chars, even if they are // using a non coventionnel way to be encoded, to not have them sanitized just after) $out = preg_replace_callback('/(x?[0-9][0-9a-f]+;?)/i', function ($m) { - return realCharForNumericEntities($m); }, $out); + return realCharForNumericEntities($m); + }, $out); // Now we remove all remaining HTML entities starting with a number. We don't want such entities. @@ -7994,9 +8005,9 @@ function dol_textishtml($msg, $option = 0) function dol_concatdesc($text1, $text2, $forxml = false, $invert = false) { if (!empty($invert)) { - $tmp = $text1; - $text1 = $text2; - $text2 = $tmp; + $tmp = $text1; + $text1 = $text2; + $text2 = $tmp; } $ret = ''; @@ -8409,7 +8420,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = $object->array_options['options_'.$key]; $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'_FORMATED__'] = price($object->array_options['options_'.$key]); } elseif ($extrafields->attributes[$object->table_element]['type'][$key] != 'separator') { - $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = !empty($object->array_options['options_'.$key]) ? $object->array_options['options_'.$key] :''; + $substitutionarray['__EXTRAFIELD_'.strtoupper($key).'__'] = !empty($object->array_options['options_'.$key]) ? $object->array_options['options_'.$key] : ''; } } } @@ -8451,7 +8462,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, } if ($object->id > 0) { - $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)) : ''); + $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ? str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)) : ''); $substitutionarray['__ONLINE_PAYMENT_URL__'] = $paymenturl; if (getDolGlobalString('PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD') && is_object($object) && $object->element == 'propal') { @@ -11381,7 +11392,7 @@ function dolGetBadge($label, $html = '', $type = 'primary', $mode = '', $url = ' $TCompiledAttr[] = $key.'="'.$value.'"'; } - $compiledAttributes = !empty($TCompiledAttr) ?implode(' ', $TCompiledAttr) : ''; + $compiledAttributes = !empty($TCompiledAttr) ? implode(' ', $TCompiledAttr) : ''; $tag = !empty($url) ? 'a' : 'span'; @@ -11555,9 +11566,9 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = // Here, $url is a simple link - if (!empty($params['isDropdown'])) + if (!empty($params['isDropdown'])) { $class = "dropdown-item"; - else { + } else { $class = 'butAction'; if ($actionType == 'danger' || $actionType == 'delete') { $class = 'butActionDelete'; @@ -11662,7 +11673,9 @@ function dolGetButtonAction($label, $text = '', $actionType = 'default', $url = ); $reshook = $hookmanager->executeHooks('dolGetButtonAction', $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 (dol_textishtml($text)) { // If content already HTML encoded @@ -12458,7 +12471,8 @@ function dolCheckFilters($sqlfilters, &$error = '') //$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)'; //$tmp=preg_replace_all('/'.$regexstring.'/', '', $sqlfilters); $tmp = $sqlfilters; - $i = 0; $nb = strlen($tmp); + $i = 0; + $nb = strlen($tmp); $counter = 0; while ($i < $nb) { if ($tmp[$i] == '(') { @@ -12538,7 +12552,7 @@ function dolForgeCriteriaCallback($matches) if ($operator == 'IN') { // IN is allowed for list of ID or code only //if (!preg_match('/^\(.*\)$/', $tmpescaped)) { - $tmpescaped = '('.$db->escape($db->sanitize($tmpescaped, 1, 0)).')'; + $tmpescaped = '('.$db->escape($db->sanitize($tmpescaped, 1, 0)).')'; //} else { // $tmpescaped = $db->escape($db->sanitize($tmpescaped, 1)); //} @@ -13398,7 +13412,9 @@ function GETPOSTDATE($prefix, $hourTime = '', $gm = 'auto') */ function buildParamDate($prefix, $timestamp = null, $hourTime = '', $gm = 'auto') { - if ($timestamp === null) $timestamp = GETPOSTDATE($prefix, $hourTime, $gm); + if ($timestamp === null) { + $timestamp = GETPOSTDATE($prefix, $hourTime, $gm); + } $TParam = array( $prefix . 'day' => intval(dol_print_date($timestamp, '%d')), $prefix . 'month' => intval(dol_print_date($timestamp, '%m')), diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 847009dbace..f102ecdd14b 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -1146,8 +1146,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ if (dol_strlen($reg[$posy]) < 2) { return 'ErrorCantUseRazWithYearOnOneDigit'; } - } else // if reset is for a specific month in year, we need year - { + } else { // if reset is for a specific month in year, we need year if (preg_match('/^(.*)\{(m+)\}\{(y+)\}/i', $maskwithonlyymcode, $reg)) { $posy = 3; $posm = 2; @@ -1162,8 +1161,8 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ } } // Define length - $yearlen = $posy ?dol_strlen($reg[$posy]) : 0; - $monthlen = $posm ?dol_strlen($reg[$posm]) : 0; + $yearlen = $posy ? dol_strlen($reg[$posy]) : 0; + $monthlen = $posm ? dol_strlen($reg[$posm]) : 0; // Define pos $yearpos = (dol_strlen($reg[1]) + 1); $monthpos = ($yearpos + $yearlen); @@ -1435,8 +1434,7 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date) + $yearoffset, $numFinal); $numFinal = preg_replace('/\{yy\}/i', date("y", $date) + $yearoffset, $numFinal); $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1) + $yearoffset, $numFinal); - } else // we want yyyy to be current year - { + } else { // we want yyyy to be current year $numFinal = preg_replace('/\{yyyy\}/i', date("Y", $date), $numFinal); $numFinal = preg_replace('/\{yy\}/i', date("y", $date), $numFinal); $numFinal = preg_replace('/\{y\}/i', substr(date("y", $date), 1, 1), $numFinal); @@ -1491,13 +1489,13 @@ function get_next_value($db, $mask, $table, $field, $where = '', $objsoc = '', $ function get_string_between($string, $start, $end) { $string = " ".$string; - $ini = strpos($string, $start); + $ini = strpos($string, $start); if ($ini == 0) { return ""; } - $ini += strlen($start); - $len = strpos($string, $end, $ini) - $ini; - return substr($string, $ini, $len); + $ini += strlen($start); + $len = strpos($string, $end, $ini) - $ini; + return substr($string, $ini, $len); } /** @@ -1707,15 +1705,14 @@ function numero_semaine($time) $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (4 - date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)))) * 24 * 60 * 60; } elseif (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) > 4) { // du Vendredi au Samedi $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)) + (7 - (date("w", mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine))) - 4)) * 24 * 60 * 60; - } else // Jeudi - { + } else { // Jeudi $premierJeudiAnnee = mktime(12, 0, 0, 1, 1, date("Y", $jeudiSemaine)); } // Definition du numero de semaine: nb de jours entre "premier Jeudi de l'annee" et "Jeudi de la semaine"; $numeroSemaine = ( - ( - date("z", mktime(12, 0, 0, date("m", $jeudiSemaine), date("d", $jeudiSemaine), date("Y", $jeudiSemaine))) + ( + date("z", mktime(12, 0, 0, date("m", $jeudiSemaine), date("d", $jeudiSemaine), date("Y", $jeudiSemaine))) - date("z", mktime(12, 0, 0, date("m", $premierJeudiAnnee), date("d", $premierJeudiAnnee), date("Y", $premierJeudiAnnee))) ) / 7 @@ -2078,11 +2075,11 @@ function getSoapParams() global $conf; $params = array(); - $proxyuse = (!getDolGlobalString('MAIN_PROXY_USE') ?false:true); - $proxyhost = (!getDolGlobalString('MAIN_PROXY_USE') ?false:$conf->global->MAIN_PROXY_HOST); - $proxyport = (!getDolGlobalString('MAIN_PROXY_USE') ?false:$conf->global->MAIN_PROXY_PORT); - $proxyuser = (!getDolGlobalString('MAIN_PROXY_USE') ?false:$conf->global->MAIN_PROXY_USER); - $proxypass = (!getDolGlobalString('MAIN_PROXY_USE') ?false:$conf->global->MAIN_PROXY_PASS); + $proxyuse = (!getDolGlobalString('MAIN_PROXY_USE') ? false : true); + $proxyhost = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_HOST); + $proxyport = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_PORT); + $proxyuser = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_USER); + $proxypass = (!getDolGlobalString('MAIN_PROXY_USE') ? false : $conf->global->MAIN_PROXY_PASS); $timeout = (!getDolGlobalString('MAIN_USE_CONNECT_TIMEOUT') ? 10 : $conf->global->MAIN_USE_CONNECT_TIMEOUT); // Connection timeout $response_timeout = (!getDolGlobalString('MAIN_USE_RESPONSE_TIMEOUT') ? 30 : $conf->global->MAIN_USE_RESPONSE_TIMEOUT); // Response timeout //print extension_loaded('soap'); @@ -2485,8 +2482,7 @@ function colorAgressiveness($hex, $ratio = -50, $brightness = 0) if ($color < 128) { $color -= ($color * ($ratio / 100)); } - } else // We decrease agressiveness - { + } else { // We decrease agressiveness if ($color > 128) { $color -= (($color - 128) * (abs($ratio) / 100)); } @@ -2934,7 +2930,8 @@ function removeGlobalParenthesis($string) } $nbofchars = dol_strlen($string); - $i = 0; $g = 0; + $i = 0; + $g = 0; $countparenthesis = 0; while ($i < $nbofchars) { $char = dol_substr($string, $i, 1); diff --git a/htdocs/core/lib/geturl.lib.php b/htdocs/core/lib/geturl.lib.php index c594b5b43b0..bd49d2fe9ce 100644 --- a/htdocs/core/lib/geturl.lib.php +++ b/htdocs/core/lib/geturl.lib.php @@ -212,7 +212,7 @@ function getURLContent($url, $postorget = 'GET', $param = '', $followlocation = if ($iptocheck) { // Set CURLOPT_CONNECT_TO so curl will not try another resolution that may give a different result. Possible only on PHP v7+ if (defined('CURLOPT_CONNECT_TO')) { - $connect_to = array(sprintf("%s:%d:%s:%d", $newUrlArray['host'], empty($newUrlArray['port'])?'':$newUrlArray['port'], $iptocheck, empty($newUrlArray['port'])?'':$newUrlArray['port'])); + $connect_to = array(sprintf("%s:%d:%s:%d", $newUrlArray['host'], empty($newUrlArray['port']) ? '' : $newUrlArray['port'], $iptocheck, empty($newUrlArray['port']) ? '' : $newUrlArray['port'])); //var_dump($newUrlArray); //var_dump($connect_to); curl_setopt($ch, CURLOPT_CONNECT_TO, $connect_to); diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index 3a9712ba58f..0bf4e5fecc4 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -255,10 +255,10 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte // Charge un document PDF depuis un fichier. $pagecount = $pdf->setSourceFile($file); for ($i = 1; $i <= $pagecount; $i++) { - $tplidx = $pdf->importPage($i); - $s = $pdf->getTemplatesize($tplidx); - $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); - $pdf->useTemplate($tplidx); + $tplidx = $pdf->importPage($i); + $s = $pdf->getTemplatesize($tplidx); + $pdf->AddPage($s['h'] > $s['w'] ? 'P' : 'L'); + $pdf->useTemplate($tplidx); } } diff --git a/htdocs/core/lib/member.lib.php b/htdocs/core/lib/member.lib.php index de14221c282..778379e84a2 100644 --- a/htdocs/core/lib/member.lib.php +++ b/htdocs/core/lib/member.lib.php @@ -53,7 +53,7 @@ function member_prepare_head(Adherent $object) } if ($user->hasRight('adherent', 'cotisation', 'lire')) { - $nbSubscription = is_array($object->subscriptions) ?count($object->subscriptions) : 0; + $nbSubscription = is_array($object->subscriptions) ? count($object->subscriptions) : 0; $head[$h][0] = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$object->id; $head[$h][1] = $langs->trans("Subscriptions"); $head[$h][2] = 'subscription'; diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index 321f3028e92..bd07f0d745a 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -129,7 +129,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir = } $texttoinsert .= ' "enabled"=>"'.($val['enabled'] !== '' ? dol_escape_php($val['enabled']) : 1).'",'; $texttoinsert .= " 'position'=>".($val['position'] !== '' ? (int) $val['position'] : 50).","; - $texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 :(int) $val['notnull']).","; + $texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : (int) $val['notnull']).","; $texttoinsert .= ' "visible"=>"'.($val['visible'] !== '' ? dol_escape_js($val['visible']) : -1).'",'; if (!empty($val['noteditable'])) { $texttoinsert .= ' "noteditable"=>"'.dol_escape_php($val['noteditable']).'",'; @@ -464,7 +464,6 @@ function dolGetListOfObjectClasses($destdir) */ function checkExistComment($file, $number) { - if (!file_exists($file)) { return -1; } @@ -598,8 +597,8 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $ $permissions[$i][4] = "\$this->rights[\$r][4] = '".$permissions[$i][4]."'"; $permissions[$i][5] = "\$this->rights[\$r][5] = '".$permissions[$i][5]."';\n\t\t"; } - // for group permissions by object - $perms_grouped = array(); + // for group permissions by object + $perms_grouped = array(); foreach ($permissions as $perms) { $object = $perms[4]; if (!isset($perms_grouped[$object])) { @@ -658,7 +657,6 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $ */ function parsePropertyString($string) { - $string = str_replace("'", '', $string); // Uses a regular expression to capture keys and values @@ -707,7 +705,7 @@ function writePropsInAsciiDoc($file, $objectname, $destfile) { // stock all properties in array - $attributesUnique = array ('type','label', 'enabled', 'position', 'notnull', 'visible', 'noteditable', 'index', 'default' , 'foreignkey', 'arrayofkeyval', 'alwayseditable','validate', 'searchall','comment', 'isameasure', 'css', 'cssview','csslist', 'help', 'showoncombobox','picto' ); + $attributesUnique = array('type','label', 'enabled', 'position', 'notnull', 'visible', 'noteditable', 'index', 'default' , 'foreignkey', 'arrayofkeyval', 'alwayseditable','validate', 'searchall','comment', 'isameasure', 'css', 'cssview','csslist', 'help', 'showoncombobox','picto' ); $start = "public \$fields=array("; $end = ");"; @@ -1136,7 +1134,8 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) dolReplaceInFile($file, array($beginMenu => $beginMenu."\n".$str_menu."\n")); return 1; - }return -1; + } + return -1; } /** @@ -1149,7 +1148,6 @@ function reWriteAllMenus($file, $menus, $menuWantTo, $key, $action) */ function updateDictionaryInFile($module, $file, $dicts) { - $isEmpty = false; $dicData = "\t\t\$this->dictionaries=array(\n"; $module = strtolower($module); @@ -1271,7 +1269,7 @@ function createNewDictionnary($modulename, $file, $namedic, $dictionnaires = nul $dictionnaires['tabhelp'][] = (array_key_exists('code', $columns) ? array('code'=>$langs->trans('CodeTooltipHelp'), 'field2' => 'field2tooltip') : ''); // Build the dictionary string - $writeInfile = updateDictionaryInFile($modulename, $file, $dictionnaires); + $writeInfile = updateDictionaryInFile($modulename, $file, $dictionnaires); if ($writeInfile > 0) { setEventMessages($langs->trans("DictionariesCreated", ucfirst(substr($namedic, 2))), null); } diff --git a/htdocs/core/lib/parsemd.lib.php b/htdocs/core/lib/parsemd.lib.php index 4015227a104..5e72271303e 100644 --- a/htdocs/core/lib/parsemd.lib.php +++ b/htdocs/core/lib/parsemd.lib.php @@ -78,7 +78,7 @@ function dolMd2Asciidoc($content, $parser = 'dolibarr', $replaceimagepath = null } //if ($parser == 'dolibarr') //{ - $content = preg_replace('//msU', '', $content); + $content = preg_replace('//msU', '', $content); //} //else //{ diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 4bf0f062f33..b8c749a3d23 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -205,7 +205,7 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') */ // For TCPDF, we specify permission we want to block - $pdfrights = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_RIGHTS') ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true) : array('modify', 'copy')); // Json format in llx_const + $pdfrights = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_RIGHTS') ? json_decode($conf->global->PDF_SECURITY_ENCRYPTION_RIGHTS, true) : array('modify', 'copy')); // Json format in llx_const // Password for the end user $pdfuserpass = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_USERPASS') ? $conf->global->PDF_SECURITY_ENCRYPTION_USERPASS : ''); @@ -218,7 +218,7 @@ function pdf_getInstance($format = '', $metric = 'mm', $pagetype = 'P') // Array of recipients containing public-key certificates ('c') and permissions ('p'). // For example: array(array('c' => 'file://../examples/data/cert/tcpdf.crt', 'p' => array('print'))) - $pubkeys = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_PUBKEYS') ?json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS, true) : null); // Json format in llx_const + $pubkeys = (getDolGlobalString('PDF_SECURITY_ENCRYPTION_PUBKEYS') ? json_decode($conf->global->PDF_SECURITY_ENCRYPTION_PUBKEYS, true) : null); // Json format in llx_const $pdf->SetProtection($pdfrights, $pdfuserpass, $pdfownerpass, $encstrength, $pubkeys); } @@ -732,9 +732,13 @@ function pdf_pagehead(&$pdf, $outputlangs, $page_height) $filepath = $conf->mycompany->dir_output.'/logos/' . getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF'); if (file_exists($filepath)) { $pdf->SetAutoPageBreak(0, 0); // Disable auto pagebreak before adding image - if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { $pdf->SetAlpha($conf->global->MAIN_USE_BACKGROUND_ON_PDF_ALPHA); } // Option for change opacity of background + if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { + $pdf->SetAlpha($conf->global->MAIN_USE_BACKGROUND_ON_PDF_ALPHA); + } // Option for change opacity of background $pdf->Image($filepath, (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_X) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_X : 0), (isset($conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y) ? $conf->global->MAIN_USE_BACKGROUND_ON_PDF_Y : 0), 0, $page_height); - if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { $pdf->SetAlpha(1); } + if (getDolGlobalString('MAIN_USE_BACKGROUND_ON_PDF_ALPHA')) { + $pdf->SetAlpha(1); + } $pdf->SetPageMark(); // This option avoid to have the images missing on some pages $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } @@ -1234,7 +1238,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } - if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); } // Option for disable auto pagebreak + if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { + $pdf->SetAutoPageBreak(0, 0); + } // Option for disable auto pagebreak if ($line) { // Free text $pdf->SetXY($dims['lm'], -$posy); if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { // by default @@ -1244,7 +1250,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } $posy -= $freetextheight; } - if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); } // Restore pagebreak + if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { + $pdf->SetAutoPageBreak(1, 0); + } // Restore pagebreak $pdf->SetY(-$posy); @@ -1260,9 +1268,13 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $posy--; } - if (getDolGlobalInt('PDF_FOOTER_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); } // Option for disable auto pagebreak + if (getDolGlobalInt('PDF_FOOTER_DISABLE_PAGEBREAK') === 1) { + $pdf->SetAutoPageBreak(0, 0); + } // Option for disable auto pagebreak $pdf->writeHTMLCell($pdf->page_largeur - $pdf->margin_left - $pdf->margin_right, $mycustomfooterheight, $dims['lm'], $dims['hk'] - $posy, dol_htmlentitiesbr($mycustomfooter, 1, 'UTF-8', 0)); - if (getDolGlobalInt('PDF_FOOTER_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); } // Restore pagebreak + if (getDolGlobalInt('PDF_FOOTER_DISABLE_PAGEBREAK') === 1) { + $pdf->SetAutoPageBreak(1, 0); + } // Restore pagebreak $posy -= $mycustomfooterheight - 3; } else { @@ -1278,7 +1290,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $pdf->SetAutoPageBreak(1, 0); // Restore pagebreak } - if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(0, 0); } // Option for disable auto pagebreak + if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { + $pdf->SetAutoPageBreak(0, 0); + } // Option for disable auto pagebreak if ($line) { // Free text $pdf->SetXY($dims['lm'], -$posy); if (!getDolGlobalString('PDF_ALLOW_HTML_FOR_FREE_TEXT')) { // by default @@ -1288,7 +1302,9 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } $posy -= $freetextheight; } - if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { $pdf->SetAutoPageBreak(1, 0); } // Restore pagebreak + if (getDolGlobalInt('PDF_FREETEXT_DISABLE_PAGEBREAK') === 1) { + $pdf->SetAutoPageBreak(1, 0); + } // Restore pagebreak $pdf->SetY(-$posy); @@ -1337,12 +1353,12 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ } // Show page nb only on iso languages (so default Helvetica font) // if (strtolower(pdf_getPDFFont($outputlangs)) == 'helvetica') { - $pdf->SetXY($dims['wk'] - $dims['rm'] - 18 - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_X', 0), -$posy - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_Y', 0)); - // $pdf->MultiCell(18, 2, $pdf->getPageNumGroupAlias().' / '.$pdf->getPageGroupAlias(), 0, 'R', 0); - // $pdf->MultiCell(18, 2, $pdf->PageNo().' / '.$pdf->getAliasNbPages(), 0, 'R', 0); // doesn't works with all fonts - // $pagination = $pdf->getAliasNumPage().' / '.$pdf->getAliasNbPages(); // works with $pdf->Cell - $pagination = $pdf->PageNo().' / '.$pdf->getNumPages(); - $pdf->MultiCell(18, 2, $pagination, 0, 'R', 0); + $pdf->SetXY($dims['wk'] - $dims['rm'] - 18 - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_X', 0), -$posy - getDolGlobalInt('PDF_FOOTER_PAGE_NUMBER_Y', 0)); + // $pdf->MultiCell(18, 2, $pdf->getPageNumGroupAlias().' / '.$pdf->getPageGroupAlias(), 0, 'R', 0); + // $pdf->MultiCell(18, 2, $pdf->PageNo().' / '.$pdf->getAliasNbPages(), 0, 'R', 0); // doesn't works with all fonts + // $pagination = $pdf->getAliasNumPage().' / '.$pdf->getAliasNbPages(); // works with $pdf->Cell + $pagination = $pdf->PageNo().' / '.$pdf->getNumPages(); + $pdf->MultiCell(18, 2, $pagination, 0, 'R', 0); // } // Show Draft Watermark @@ -1550,17 +1566,21 @@ function pdf_getlinedesc($object, $i, $outputlangs, $hideref = 0, $hidedesc = 0, if (getDolGlobalString('MAIN_GENERATE_DOCUMENTS_HIDE_REF')) { foreach ($tmparrayofsubproducts as $subprodval) { - $libelleproduitservice = dol_concatdesc(dol_concatdesc($libelleproduitservice, " * ".$subprodval[3]), + $libelleproduitservice = dol_concatdesc( + dol_concatdesc($libelleproduitservice, " * ".$subprodval[3]), (!empty($qtyText) ? - $outputlangs->trans('Qty').':'.$qtyText.' x '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1].'= '.$outputlangs->trans('QtyTot').':'.$subprodval[1]*$qtyText: - $outputlangs->trans('Qty').' '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1])); + $outputlangs->trans('Qty').':'.$qtyText.' x '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1].'= '.$outputlangs->trans('QtyTot').':'.$subprodval[1]*$qtyText : + $outputlangs->trans('Qty').' '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1]) + ); } } else { foreach ($tmparrayofsubproducts as $subprodval) { - $libelleproduitservice = dol_concatdesc(dol_concatdesc($libelleproduitservice, " * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3]), + $libelleproduitservice = dol_concatdesc( + dol_concatdesc($libelleproduitservice, " * ".$subprodval[5].(($subprodval[5] && $subprodval[3]) ? ' - ' : '').$subprodval[3]), (!empty($qtyText) ? - $outputlangs->trans('Qty').':'.$qtyText.' x '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1].'= '.$outputlangs->trans('QtyTot').':'.$subprodval[1]*$qtyText: - $outputlangs->trans('Qty').' '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1])); + $outputlangs->trans('Qty').':'.$qtyText.' x '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1].'= '.$outputlangs->trans('QtyTot').':'.$subprodval[1]*$qtyText : + $outputlangs->trans('Qty').' '.$outputlangs->trans('AssociatedProducts').':'.$subprodval[1]) + ); } } } @@ -2470,7 +2490,7 @@ function pdf_getLinkedObjects(&$object, $outputlangs) if (count($objects) > 1 && count($objects) <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 10)) { $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("RefOrder").' :'); foreach ($objects as $elementobject) { - $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).(empty($elementobject->ref_client) ?'' : ' ('.$elementobject->ref_client.')').(empty($elementobject->ref_supplier) ? '' : ' ('.$elementobject->ref_supplier.')').' '); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).(empty($elementobject->ref_client) ? '' : ' ('.$elementobject->ref_client.')').(empty($elementobject->ref_supplier) ? '' : ' ('.$elementobject->ref_supplier.')').' '); $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("OrderDate").' : '.dol_print_date($elementobject->date, 'day', '', $outputlangs)); } } elseif (count($objects) == 1) { @@ -2599,8 +2619,7 @@ function pdf_getSizeForImage($realpath) if ($width > $maxwidth) { // Pb with maxheight, so i use maxwidth $width = $maxwidth; $height = (int) round($maxwidth * $tmp['height'] / $tmp['width']); - } else // No pb with maxheight - { + } else { // No pb with maxheight $height = $maxheight; } } diff --git a/htdocs/core/lib/phpsessionindb.lib.php b/htdocs/core/lib/phpsessionindb.lib.php index 9dd806d86fc..7d19730674e 100644 --- a/htdocs/core/lib/phpsessionindb.lib.php +++ b/htdocs/core/lib/phpsessionindb.lib.php @@ -48,12 +48,24 @@ function dolSessionOpen($save_path, $session_name) global $dolibarr_session_db_type, $dolibarr_session_db_host; global $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, $dolibarr_session_db_port; - if (empty($dolibarr_session_db_type)) { $dolibarr_session_db_type = $dolibarr_main_db_type; } - if (empty($dolibarr_session_db_host)) { $dolibarr_session_db_host = $dolibarr_main_db_host; } - if (empty($dolibarr_session_db_user)) { $dolibarr_session_db_user = $dolibarr_main_db_user; } - if (empty($dolibarr_session_db_pass)) { $dolibarr_session_db_pass = $dolibarr_main_db_pass; } - if (empty($dolibarr_session_db_name)) { $dolibarr_session_db_name = $dolibarr_main_db_name; } - if (empty($dolibarr_session_db_port)) { $dolibarr_session_db_port = $dolibarr_main_db_port; } + if (empty($dolibarr_session_db_type)) { + $dolibarr_session_db_type = $dolibarr_main_db_type; + } + if (empty($dolibarr_session_db_host)) { + $dolibarr_session_db_host = $dolibarr_main_db_host; + } + if (empty($dolibarr_session_db_user)) { + $dolibarr_session_db_user = $dolibarr_main_db_user; + } + if (empty($dolibarr_session_db_pass)) { + $dolibarr_session_db_pass = $dolibarr_main_db_pass; + } + if (empty($dolibarr_session_db_name)) { + $dolibarr_session_db_name = $dolibarr_main_db_name; + } + if (empty($dolibarr_session_db_port)) { + $dolibarr_session_db_port = $dolibarr_main_db_port; + } //var_dump('open '.$database_name.' '.$table_name); $dbsession = getDoliDBInstance($dolibarr_session_db_type, $dolibarr_session_db_host, $dolibarr_session_db_user, $dolibarr_session_db_pass, $dolibarr_session_db_name, (int) $dolibarr_session_db_port); diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index 4febb1fbe21..a2e42cde0c9 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -39,11 +39,11 @@ function product_prepare_head($object) $langs->load("products"); $label = $langs->trans('Product'); - $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('product', 'product_advance', 'read_prices'):$user->hasRight('product', 'read'); + $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('product', 'product_advance', 'read_prices') : $user->hasRight('product', 'read'); if ($object->isService()) { $label = $langs->trans('Service'); - $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS')?$user->hasRight('service', 'service_advance', 'read_prices'):$user->hasRight('service', 'read'); + $usercancreadprice = getDolGlobalString('MAIN_USE_ADVANCED_PERMS') ? $user->hasRight('service', 'service_advance', 'read_prices') : $user->hasRight('service', 'read'); } $h = 0; diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index a74df640399..ddcae0393c5 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -230,7 +230,8 @@ function project_prepare_head(Project $project, $moreparam = '') $head[$h][1] = $langs->trans("EventOrganization"); // Enable caching of conf or booth count - $nbConfOrBooth = 0; $nbAttendees = 0; + $nbConfOrBooth = 0; + $nbAttendees = 0; require_once DOL_DOCUMENT_ROOT.'/core/lib/memory.lib.php'; $cachekey = 'count_conferenceorbooth_'.$project->id; $dataretrieved = dol_getcache($cachekey); @@ -823,7 +824,8 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t // Progress calculated (Note: ->duration_effective is time spent) if (count($arrayfields) > 0 && !empty($arrayfields['t.progress_calculated']['checked'])) { - $s = ''; $shtml = ''; + $s = ''; + $shtml = ''; if ($lines[$i]->planned_workload || $lines[$i]->duration_effective) { if ($lines[$i]->planned_workload) { $s = round(100 * $lines[$i]->duration_effective / $lines[$i]->planned_workload, 2).' %'; @@ -2063,7 +2065,9 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ $modeinput = 'hours'; for ($idw = 0; $idw < 7; $idw++) { $tmpday = dol_time_plus_duree($firstdaytoshow, $idw, 'd'); - if (!isset($totalforeachday[$tmpday])) $totalforeachday[$tmpday] = 0; + if (!isset($totalforeachday[$tmpday])) { + $totalforeachday[$tmpday] = 0; + } $cssonholiday = ''; if (!$isavailable[$tmpday]['morning'] && !$isavailable[$tmpday]['afternoon']) { $cssonholiday .= 'onholidayallday '; @@ -2362,7 +2366,9 @@ function projectLinesPerMonth(&$inc, $firstdaytoshow, $fuser, $parent, $lines, & $month = $firstdaytoshowarray['mon']; foreach ($TWeek as $weekIndex => $weekNb) { $weekWorkLoad = !empty($projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id]) ? $projectstatic->monthWorkLoadPerTask[$weekNb][$lines[$i]->id] : 0 ; - if (!isset($totalforeachweek[$weekNb])) $totalforeachweek[$weekNb] = 0; + if (!isset($totalforeachweek[$weekNb])) { + $totalforeachweek[$weekNb] = 0; + } $totalforeachweek[$weekNb] += $weekWorkLoad; $alreadyspent = ''; @@ -2738,14 +2744,14 @@ function print_projecttasks_array($db, $form, $socid, $projectsListId, $mytasks $plannedworkload = $objp->planned_workload; $total_plannedworkload += $plannedworkload; if (!in_array('plannedworkload', $hiddenfields)) { - print '| '; if ($edit) { //print ajax_constantonoff('THEME_TOPMENU_DISABLE_IMAGE', array(), null, 0, 0, 1); - print $form->selectarray('THEME_TOPMENU_DISABLE_IMAGE', $listoftopmenumodes, isset($conf->global->THEME_TOPMENU_DISABLE_IMAGE)?$conf->global->THEME_TOPMENU_DISABLE_IMAGE:0, 0, 0, 0, '', 0, 0, 0, '', 'widthcentpercentminusx maxwidth500'); + print $form->selectarray('THEME_TOPMENU_DISABLE_IMAGE', $listoftopmenumodes, isset($conf->global->THEME_TOPMENU_DISABLE_IMAGE) ? $conf->global->THEME_TOPMENU_DISABLE_IMAGE : 0, 0, 0, 0, '', 0, 0, 0, '', 'widthcentpercentminusx maxwidth500'); } else { $listoftopmenumodes[getDolGlobalString('THEME_TOPMENU_DISABLE_IMAGE')]; //print yn($conf->global->THEME_TOPMENU_DISABLE_IMAGE); diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 904fc9808e3..5f0bfd8915d 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -557,8 +557,7 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri $newurl = $currenturi.'&pageref='.urlencode($containerref); } } - } else // When page called from virtual host server - { + } else { // When page called from virtual host server $newurl = '/'.$containerref.'.php'; } diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 36605571053..144d46d31de 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -103,7 +103,9 @@ function dolSavePageAlias($filealias, $object, $objectpage) $filename = basename($filealias); foreach (explode(',', $object->otherlang) as $sublang) { // Avoid to erase main alias file if $sublang is empty string - if (empty(trim($sublang))) continue; + if (empty(trim($sublang))) { + continue; + } $filealiassub = $dirname.'/'.$sublang.'/'.$filename; $aliascontent = 'otherlang) as $sublang) { // Avoid to erase main alias file if $sublang is empty string - if (empty(trim($sublang))) continue; + if (empty(trim($sublang))) { + continue; + } $fileindexsub = $dirname.'/'.$sublang.'/index.php'; // Same indexcontent than previously but with ../ instead of ./ for master and tpl file include/require_once. diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php index b2b2194246d..bddcce12d72 100644 --- a/htdocs/core/lib/xcal.lib.php +++ b/htdocs/core/lib/xcal.lib.php @@ -330,7 +330,7 @@ function build_rssfile($format, $title, $desc, $events_array, $outputfile, $filt dol_syslog("xcal.lib.php::build_rssfile Build rss file ".$outputfile." to format ".$format); if (empty($outputfile)) { - // -1 = error + // -1 = error return -1; } |