Skip to content

Commit

Permalink
Merge pull request #12425 from Dolibarr/scrutinizer-patch-2
Browse files Browse the repository at this point in the history
Scrutinizer Auto-Fixes
  • Loading branch information
eldy committed Nov 13, 2019
2 parents 65dc46d + 16c50c2 commit f7ebba3
Show file tree
Hide file tree
Showing 12 changed files with 3,584 additions and 3,584 deletions.
634 changes: 317 additions & 317 deletions htdocs/adherents/card.php

Large diffs are not rendered by default.

78 changes: 39 additions & 39 deletions htdocs/core/actions_addupdatedelete.inc.php
Expand Up @@ -78,91 +78,91 @@
}
}

if (! $error)
if (!$error)
{
$result=$object->create($user);
$result = $object->create($user);
if ($result > 0)
{
// Creation OK
$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
header("Location: ".$urltogo);
exit;
}
else
{
// Creation KO
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
$action='create';
$action = 'create';
}
}
else
{
$action='create';
$action = 'create';
}
}

// Action to update record
if ($action == 'update' && ! empty($permissiontoadd))
if ($action == 'update' && !empty($permissiontoadd))
{
foreach ($object->fields as $key => $val)
{
if (! GETPOSTISSET($key)) continue; // The field was not submited to be edited
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue; // Ignore special fields
// Set value to update
if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
$value = GETPOST($key, 'none');
} elseif ($object->fields[$key]['type']=='date') {
} elseif ($object->fields[$key]['type'] == 'date') {
$value = dol_mktime(12, 0, 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
} elseif ($object->fields[$key]['type']=='datetime') {
} elseif ($object->fields[$key]['type'] == 'datetime') {
$value = dol_mktime(GETPOST($key.'hour'), GETPOST($key.'min'), 0, GETPOST($key.'month'), GETPOST($key.'day'), GETPOST($key.'year'));
} elseif (in_array($object->fields[$key]['type'], array('price', 'real'))) {
$value = price2num(GETPOST($key));
} else {
$value = GETPOST($key, 'alpha');
}
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value=''; // This is an implicit foreign key field
if (! empty($object->fields[$key]['foreignkey']) && $value == '-1') $value=''; // This is an explicit foreign key field
if (preg_match('/^integer:/i', $object->fields[$key]['type']) && $value == '-1') $value = ''; // This is an implicit foreign key field
if (!empty($object->fields[$key]['foreignkey']) && $value == '-1') $value = ''; // This is an explicit foreign key field

$object->$key=$value;
$object->$key = $value;
if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
{
$error++;
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val['label'])), null, 'errors');
}
}

if (! $error)
if (!$error)
{
$result=$object->update($user);
$result = $object->update($user);
if ($result > 0)
{
$action='view';
$action = 'view';
}
else
{
// Creation KO
setEventMessages($object->error, $object->errors, 'errors');
$action='edit';
$action = 'edit';
}
}
else
{
$action='edit';
$action = 'edit';
}
}

// Action to update one extrafield
if ($action == "update_extras" && ! empty($permissiontoadd))
if ($action == "update_extras" && !empty($permissiontoadd))
{
$object->fetch(GETPOST('id', 'int'));

$attributekey = GETPOST('attribute', 'alpha');
$attributekeylong = 'options_'.$attributekey;
$object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha');

$result = $object->insertExtraFields(empty($triggermodname)?'':$triggermodname, $user);
$result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
if ($result > 0)
{
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
Expand All @@ -176,15 +176,15 @@
}

// Action to delete
if ($action == 'confirm_delete' && ! empty($permissiontodelete))
if ($action == 'confirm_delete' && !empty($permissiontodelete))
{
if (! ($object->id > 0))
if (!($object->id > 0))
{
dol_print_error('', 'Error, object must be fetched before being deleted');
exit;
}

$result=$object->delete($user);
$result = $object->delete($user);
if ($result > 0)
{
// Delete OK
Expand All @@ -194,13 +194,13 @@
}
else
{
if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
if (!empty($object->errors)) setEventMessages(null, $object->errors, 'errors');
else setEventMessages($object->error, null, 'errors');
}
}

// Remove a line
if ($action == 'confirm_deleteline' && $confirm == 'yes' && ! empty($permissiontoadd))
if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd))
{
$result = $object->deleteline($user, $lineid);
if ($result > 0)
Expand All @@ -216,7 +216,7 @@
{
$newlang = $object->thirdparty->default_lang;
}
if (! empty($newlang)) {
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
Expand Down Expand Up @@ -248,11 +248,11 @@
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records

$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
Expand All @@ -277,11 +277,11 @@
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records

$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
Expand Down Expand Up @@ -320,11 +320,11 @@
$newlang = '';
if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id', 'aZ09')) $newlang = GETPOST('lang_id', 'aZ09');
if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
if (! empty($newlang)) {
if (!empty($newlang)) {
$outputlangs = new Translate("", $conf);
$outputlangs->setDefaultLang($newlang);
}
$model=$object->modelpdf;
$model = $object->modelpdf;
$ret = $object->fetch($id); // Reload to get new records

$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
Expand All @@ -337,30 +337,30 @@
}

// Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes' && ! empty($permissiontoadd))
if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd))
{
if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
if (1 == 0 && !GETPOST('clone_content') && !GETPOST('clone_receivers'))
{
setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
}
else
{
$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
//$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
// ...
$result=$objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
$result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
if (is_object($result) || $result > 0)
{
$newid = 0;
if (is_object($result)) $newid = $result->id;
else $newid = $result;
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
exit;
}
else
{
setEventMessages($objectutil->error, $objectutil->errors, 'errors');
$action='';
$action = '';
}
}
}

0 comments on commit f7ebba3

Please sign in to comment.