Fix update field when visilbity is 4 or -4
This commit is contained in:
parent
fc49583efe
commit
807d3b99c9
@ -60,7 +60,10 @@ if ($action == 'add' && !empty($permissiontoadd))
|
|||||||
if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited
|
if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited
|
||||||
}
|
}
|
||||||
// Ignore special fields
|
// Ignore special fields
|
||||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
if (in_array($key, array('rowid', 'entity', 'import_key'))) continue;
|
||||||
|
if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) {
|
||||||
|
if (!in_array(abs($val['visible']), array(1, 3))) continue; // Only 1 and 3 that are case to create
|
||||||
|
}
|
||||||
|
|
||||||
// Set value to insert
|
// Set value to insert
|
||||||
if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
|
if (in_array($object->fields[$key]['type'], array('text', 'html'))) {
|
||||||
@ -141,7 +144,10 @@ if ($action == 'update' && !empty($permissiontoadd))
|
|||||||
if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited
|
if (!GETPOSTISSET($key)) continue; // The field was not submited to be edited
|
||||||
}
|
}
|
||||||
// Ignore special fields
|
// Ignore special fields
|
||||||
if (in_array($key, array('rowid', 'entity', 'date_creation', 'tms', 'fk_user_creat', 'fk_user_modif', 'import_key'))) continue;
|
if (in_array($key, array('rowid', 'entity', 'import_key'))) continue;
|
||||||
|
if (in_array($key, array('date_creation', 'tms', 'fk_user_creat', 'fk_user_modif'))) {
|
||||||
|
if (!in_array(abs($val['visible']), array(1, 3, 4))) continue; // Only 1 and 3 and 4 that are case to update
|
||||||
|
}
|
||||||
|
|
||||||
// Set value to update
|
// Set value to update
|
||||||
if (preg_match('/^(text|html)/', $object->fields[$key]['type'])) {
|
if (preg_match('/^(text|html)/', $object->fields[$key]['type'])) {
|
||||||
|
|||||||
@ -7512,8 +7512,7 @@ abstract class CommonObject
|
|||||||
// Depending on field type ('datetime', ...)
|
// Depending on field type ('datetime', ...)
|
||||||
if ($this->isDate($info))
|
if ($this->isDate($info))
|
||||||
{
|
{
|
||||||
if (empty($this->{$field}))
|
if (empty($this->{$field})) {
|
||||||
{
|
|
||||||
$queryarray[$field] = null;
|
$queryarray[$field] = null;
|
||||||
} else {
|
} else {
|
||||||
$queryarray[$field] = $this->db->idate($this->{$field});
|
$queryarray[$field] = $this->db->idate($this->{$field});
|
||||||
@ -7928,6 +7927,7 @@ abstract class CommonObject
|
|||||||
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update.
|
unset($fieldvalues['rowid']); // The field 'rowid' is reserved field name for autoincrement field so we don't need it into update.
|
||||||
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data
|
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data
|
||||||
|
|
||||||
|
// Add quotes and escape on fields with type string
|
||||||
$keys = array();
|
$keys = array();
|
||||||
$values = array();
|
$values = array();
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
@ -7938,7 +7938,7 @@ abstract class CommonObject
|
|||||||
$tmp[] = $k.'='.$this->quote($v, $this->fields[$k]);
|
$tmp[] = $k.'='.$this->quote($v, $this->fields[$k]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean and check mandatory
|
// Clean and check mandatory fields
|
||||||
foreach ($keys as $key)
|
foreach ($keys as $key)
|
||||||
{
|
{
|
||||||
if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = ''; // This is an implicit foreign key field
|
if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = ''; // This is an implicit foreign key field
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user