FIX again and again

This commit is contained in:
Regis Houssin 2020-12-29 17:48:52 +01:00
parent acabb045fb
commit aec01a95fc
12 changed files with 97 additions and 40 deletions

View File

@ -51,15 +51,39 @@ if (isset($title))
// Check PHP setup is OK
$maxphp = @ini_get('upload_max_filesize'); // In unknown
if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1;
if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024;
if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024;
if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024;
if (preg_match('/k$/i', $maxphp)) {
$maxphp = preg_replace('/k$/i', '', $maxphp);
$maxphp = $maxphp * 1;
}
if (preg_match('/m$/i', $maxphp)) {
$maxphp = preg_replace('/m$/i', '', $maxphp);
$maxphp = $maxphp * 1024;
}
if (preg_match('/g$/i', $maxphp)) {
$maxphp = preg_replace('/g$/i', '', $maxphp);
$maxphp = $maxphp * 1024 * 1024;
}
if (preg_match('/t$/i', $maxphp)) {
$maxphp = preg_replace('/t$/i', '', $maxphp);
$maxphp = $maxphp * 1024 * 1024 * 1024;
}
$maxphp2 = @ini_get('post_max_size'); // In unknown
if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1;
if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024;
if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024;
if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
if (preg_match('/k$/i', $maxphp2)) {
$maxphp2 = preg_replace('/k$/i', '', $maxphp2);
$maxphp2 = $maxphp2 * 1;
}
if (preg_match('/m$/i', $maxphp2)) {
$maxphp2 = preg_replace('/m$/i', '', $maxphp2);
$maxphp2 = $maxphp2 * 1024;
}
if (preg_match('/g$/i', $maxphp2)) {
$maxphp2 = preg_replace('/g$/i', '', $maxphp2);
$maxphp2 = $maxphp2 * 1024 * 1024;
}
if (preg_match('/t$/i', $maxphp2)) {
$maxphp2 = preg_replace('/t$/i', '', $maxphp2);
$maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
}
if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2)
{
$langs->load("errors");

View File

@ -87,7 +87,7 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$hookmanager->initHooks(array('thirdpartycomm', 'globalcard'));
// Security check
$result = restrictedArea($user, 'societe', $socid, '&societe', '', 'fk_soc', 'rowid', 0);
$result = restrictedArea($user, 'societe', $id, '&societe', '', 'fk_soc', 'rowid', 0);
if ($object->id > 0) {
if (!($object->client > 0) || empty($user->rights->societe->lire)) {

View File

@ -601,7 +601,7 @@ abstract class CommonObject
if (empty($lastname)) $lastname = (isset($this->lastname) ? $this->lastname : (isset($this->name) ? $this->name : (isset($this->nom) ? $this->nom : (isset($this->societe) ? $this->societe : (isset($this->company) ? $this->company : '')))));
$ret = '';
if ($option && $this->civility_code)
if (!empty($option) && !empty($this->civility_code))
{
if ($langs->transnoentitiesnoconv("Civility".$this->civility_code) != "Civility".$this->civility_code) $ret .= $langs->transnoentitiesnoconv("Civility".$this->civility_code).' ';
else $ret .= $this->civility_code.' ';
@ -720,7 +720,7 @@ abstract class CommonObject
$out = '';
$outdone = 0;
$coords = $this->getFullAddress(1, ', ', $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT);
$coords = $this->getFullAddress(1, ', ', (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) ? $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT : 0));
if ($coords)
{
if (!empty($conf->use_javascript_ajax))
@ -1407,7 +1407,7 @@ abstract class CommonObject
} elseif (strpos($obj->element, 'supplier') !== false && $obj->element != 'supplier_proposal') {
$modulename = 'fournisseur';
}
if ($conf->{$modulename}->enabled) {
if (!empty($conf->{$modulename}->enabled)) {
$libelle_element = $langs->trans('ContactDefault_'.$obj->element);
$transkey = "TypeContact_".$obj->element."_".$source."_".$obj->code;
$libelle_type = ($langs->trans($transkey) != $transkey ? $langs->trans($transkey) : $obj->libelle);
@ -6846,7 +6846,7 @@ abstract class CommonObject
$value = $getposttemp;
}
} else {
$value = $this->array_options["options_".$key]; // No GET, no POST, no default value, so we take value of object.
$value = (!empty($this->array_options["options_".$key]) ? $this->array_options["options_".$key] : ''); // No GET, no POST, no default value, so we take value of object.
}
//var_dump($keyprefix.' - '.$key.' - '.$keysuffix.' - '.$keyprefix.'options_'.$key.$keysuffix.' - '.$this->array_options["options_".$key.$keysuffix].' - '.$getposttemp.' - '.$value);
break;

View File

@ -1097,7 +1097,12 @@ class ExtraFields
foreach ($param['options'] as $key => $val)
{
if ((string) $key == '') continue;
list($val, $parent) = explode('|', $val);
$valarray = explode('|', $val);
$val = $valarray[0];
$parent = '';
if (!empty($valarray[1])) {
$parent = $valarray[1];
}
$out .= '<option value="'.$key.'"';
$out .= (((string) $value == (string) $key) ? ' selected' : '');
$out .= (!empty($parent) ? ' parent="'.$parent.'"' : '');
@ -2063,7 +2068,7 @@ class ExtraFields
{
global $_POST;
if (is_string($extrafieldsobjectkey) && is_array($this->attributes[$extrafieldsobjectkey]['label']))
if (is_string($extrafieldsobjectkey) && !empty($this->attributes[$extrafieldsobjectkey]['label']) && is_array($this->attributes[$extrafieldsobjectkey]['label']))
{
$extralabels = $this->attributes[$extrafieldsobjectkey]['label'];
} else {

View File

@ -202,7 +202,7 @@ class FormActions
$newcardbutton = '';
if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create))
{
$newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')).'&amp;origin='.urlencode($typeelement).'&amp;originid='.$object->id.($object->socid > 0 ? '&amp;socid='.$object->socid : ($socid > 0 ? '&amp;socid='.$socid : '')).($projectid > 0 ? '&amp;projectid='.$projectid : '').'&amp;backtopage='.urlencode($urlbacktopage));
$newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&amp;datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')).'&amp;origin='.urlencode($typeelement).'&amp;originid='.$object->id.((!empty($object->socid) && $object->socid > 0) ? '&amp;socid='.$object->socid : ((!empty($socid) && $socid > 0) ? '&amp;socid='.$socid : '')).($projectid > 0 ? '&amp;projectid='.$projectid : '').'&amp;backtopage='.urlencode($urlbacktopage));
}
@ -244,7 +244,7 @@ class FormActions
print '<td class="nowraponall tdoverflowmax125">';
if (!empty($actioncomm->userownerid))
{
if (is_object($cacheusers[$actioncomm->userownerid]))
if (isset($cacheusers[$actioncomm->userownerid]) && is_object($cacheusers[$actioncomm->userownerid]))
{
$tmpuser = $cacheusers[$actioncomm->userownerid];
} else {

View File

@ -135,15 +135,39 @@ class FormFile
$max = $conf->global->MAIN_UPLOAD_DOC; // In Kb
$maxphp = @ini_get('upload_max_filesize'); // In unknown
if (preg_match('/k$/i', $maxphp)) $maxphp = $maxphp * 1;
if (preg_match('/m$/i', $maxphp)) $maxphp = $maxphp * 1024;
if (preg_match('/g$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024;
if (preg_match('/t$/i', $maxphp)) $maxphp = $maxphp * 1024 * 1024 * 1024;
if (preg_match('/k$/i', $maxphp)) {
$maxphp = preg_replace('/k$/i', '', $maxphp);
$maxphp = $maxphp * 1;
}
if (preg_match('/m$/i', $maxphp)) {
$maxphp = preg_replace('/m$/i', '', $maxphp);
$maxphp = $maxphp * 1024;
}
if (preg_match('/g$/i', $maxphp)) {
$maxphp = preg_replace('/g$/i', '', $maxphp);
$maxphp = $maxphp * 1024 * 1024;
}
if (preg_match('/t$/i', $maxphp)) {
$maxphp = preg_replace('/t$/i', '', $maxphp);
$maxphp = $maxphp * 1024 * 1024 * 1024;
}
$maxphp2 = @ini_get('post_max_size'); // In unknown
if (preg_match('/k$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1;
if (preg_match('/m$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024;
if (preg_match('/g$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024;
if (preg_match('/t$/i', $maxphp2)) $maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
if (preg_match('/k$/i', $maxphp2)) {
$maxphp2 = preg_replace('/k$/i', '', $maxphp2);
$maxphp2 = $maxphp2 * 1;
}
if (preg_match('/m$/i', $maxphp2)) {
$maxphp2 = preg_replace('/m$/i', '', $maxphp2);
$maxphp2 = $maxphp2 * 1024;
}
if (preg_match('/g$/i', $maxphp2)) {
$maxphp2 = preg_replace('/g$/i', '', $maxphp2);
$maxphp2 = $maxphp2 * 1024 * 1024;
}
if (preg_match('/t$/i', $maxphp2)) {
$maxphp2 = preg_replace('/t$/i', '', $maxphp2);
$maxphp2 = $maxphp2 * 1024 * 1024 * 1024;
}
// Now $max and $maxphp and $maxphp2 are in Kb
$maxmin = $max;
$maxphptoshow = $maxphptoshowparam = '';

View File

@ -302,7 +302,7 @@ function societe_prepare_head(Societe $object)
}
$head[$h][0] = DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id;
$head[$h][1] .= $langs->trans("Events");
$head[$h][1] = $langs->trans("Events");
if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read))) {
$head[$h][1] .= '/';
$head[$h][1] .= $langs->trans("Agenda");
@ -862,7 +862,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
// Definition of fields for list
$arrayfields = array(
't.rowid'=>array('label'=>"TechnicalID", 'checked'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'enabled'=>($conf->global->MAIN_SHOW_TECHNICAL_ID ? 1 : 0), 'position'=>1),
't.rowid'=>array('label'=>"TechnicalID", 'checked'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) ? 1 : 0), 'enabled'=>(!empty($conf->global->MAIN_SHOW_TECHNICAL_ID) ? 1 : 0), 'position'=>1),
't.name'=>array('label'=>"Name", 'checked'=>1, 'position'=>10),
't.poste'=>array('label'=>"PostOrFunction", 'checked'=>1, 'position'=>20),
't.address'=>array('label'=>(empty($conf->dol_optimize_smallscreen) ? $langs->trans("Address").' / '.$langs->trans("Phone").' / '.$langs->trans("Email") : $langs->trans("Address")), 'checked'=>1, 'position'=>30),
@ -870,7 +870,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
't.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>50, 'class'=>'center'),
);
// Extra fields
if (is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) {
if (!empty($extrafields->attributes[$contactstatic->table_element]['label']) && is_array($extrafields->attributes[$contactstatic->table_element]['label']) && count($extrafields->attributes[$contactstatic->table_element]['label'])) {
foreach ($extrafields->attributes[$contactstatic->table_element]['label'] as $key => $val) {
if (!empty($extrafields->attributes[$contactstatic->table_element]['list'][$key])) {
$arrayfields["ef.".$key] = array(
@ -989,7 +989,7 @@ function show_contacts($conf, $langs, $db, $object, $backtopage = '')
} elseif (in_array($key, array('role'))) {
print $formcompany->showRoles("search_roles", $contactstatic, 'edit', $search_roles);
} else {
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.dol_escape_htmltag($search[$key]).'">';
print '<input type="text" class="flat maxwidth75" name="search_'.$key.'" value="'.(!empty($search[$key]) ? dol_escape_htmltag($search[$key]) : '').'">';
}
print '</td>';
}
@ -1204,14 +1204,17 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
{
global $user, $conf;
global $form;
global $param, $massactionbutton;
$start_year = GETPOST('dateevent_startyear');
$start_month = GETPOST('dateevent_startmonth');
$start_day = GETPOST('dateevent_startday');
$end_year = GETPOST('dateevent_endyear');
$end_month = GETPOST('dateevent_endmonth');
$end_day = GETPOST('dateevent_endday');
$tms_start = '';
$tms_end = '';
if (!empty($start_year) && !empty($start_month) && !empty($start_day)) {
$search_start = $start_year.'-'.$start_month.'-'.$start_day;
$tms_start = strtotime($search_start);
@ -1391,7 +1394,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
//if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
//elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
$tododone = '';
if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && $obj->datep > $now)) $tododone = 'todo';
if (($obj->percent >= 0 and $obj->percent < 100) || ($obj->percent == -1 && (!empty($obj->datep) && $obj->datep > $now))) $tododone = 'todo';
$histo[$numaction] = array(
'type'=>$obj->type,

View File

@ -14,7 +14,7 @@ if (empty($extrafieldsobjectkey) && is_object($object)) $extrafieldsobjectkey =
// Loop to show all columns of extrafields for the search title line
if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
{
if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
if (!empty($extrafields->attributes[$extrafieldsobjectkey]['label']) && is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
{
if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.';
if (empty($search_options_pattern)) $search_options_pattern = 'search_options_';

View File

@ -13,7 +13,7 @@ if (!isset($disablesortlink)) $disablesortlink = 0;
// Loop to show all columns of extrafields for the title line
if (!empty($extrafieldsobjectkey)) // $extrafieldsobject is the $object->table_element like 'societe', 'socpeople', ...
{
if (is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
if (!empty($extrafields->attributes[$extrafieldsobjectkey]['label']) && is_array($extrafields->attributes[$extrafieldsobjectkey]['label']) && count($extrafields->attributes[$extrafieldsobjectkey]['label']))
{
if (empty($extrafieldsobjectprefix)) $extrafieldsobjectprefix = 'ef.';

View File

@ -87,7 +87,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
{
$value = (GETPOSTISSET("options_".$tmpkeyextra) ? GETPOST("options_".$tmpkeyextra) : $object->array_options["options_".$tmpkeyextra]);
} else {
$value = $object->array_options["options_".$tmpkeyextra];
$value = (!empty($object->array_options["options_".$tmpkeyextra]) ? $object->array_options["options_".$tmpkeyextra] : '');
//var_dump($tmpkeyextra.' - '.$value);
}
@ -165,7 +165,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
$html_id = !empty($object->id) ? $object->element.'_extras_'.$tmpkeyextra.'_'.$object->id : '';
print '<td id="'.$html_id.'" class="'.$object->element.'_extras_'.$tmpkeyextra.' wordbreak"'.($cols ? ' colspan="'.$cols.'"' : '').'>';
print '<td id="'.$html_id.'" class="'.$object->element.'_extras_'.$tmpkeyextra.' wordbreak"'.(!empty($cols) ? ' colspan="'.$cols.'"' : '').'>';
// Convert date into timestamp format
if (in_array($extrafields->attributes[$object->table_element]['type'][$tmpkeyextra], array('date', 'datetime')))

View File

@ -148,7 +148,7 @@ if ($object->client)
if ($conf->contrat->enabled && $user->rights->contrat->lire) $elementTypeArray['contract'] = $langs->transnoentitiesnoconv('Contracts');
}
if ($conf->ficheinter->enabled && $user->rights->ficheinter->lire) $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
if (!empty($conf->ficheinter->enabled) && !empty($user->rights->ficheinter->lire)) $elementTypeArray['fichinter'] = $langs->transnoentitiesnoconv('Interventions');
if ($object->fournisseur)
{
@ -606,9 +606,10 @@ if ($sql_select)
print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num);
}
$db->free($resql);
} elseif (empty($type_element) || $type_element == -1)
}
elseif (empty($type_element) || $type_element == -1)
{
print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, '', '');
print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', (!empty($num) ? $num : 0), '', '');
print '<table class="liste centpercent">'."\n";
// Titles with sort buttons

View File

@ -99,7 +99,7 @@ if ($cancel)
$action = '';
}
$parameters = array('id'=>$socid, 'objcanvas'=>$objcanvas);
$parameters = array('id'=>$socid);
$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');
@ -937,7 +937,7 @@ if ($socid && $action != 'edit' && $action != 'create' && $action != 'editcard'
{
try {
$customerstripe = $stripe->customerStripe($object, $stripeacc, $servicestatus);
if ($customerstripe->id) {
if (!empty($customerstripe->id)) {
// When using the Charge API architecture
if (empty($conf->global->STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION))
{