mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:50 +01:00
Fix custom field order renumbering to keep at multiples of 10.
This commit is contained in:
parent
99c67eacc7
commit
9bf07631e0
@ -432,7 +432,10 @@ class customfields
|
||||
}
|
||||
|
||||
// Include type-specific value help
|
||||
$content['options'] = lang(self::$type_option_help);
|
||||
foreach(self::$type_option_help as $key => $value)
|
||||
{
|
||||
$content['options'][$key] = lang($value);
|
||||
}
|
||||
$content['statustext'] = $content['options'][$content['cf_type']];
|
||||
$content['attributes'] = self::$type_attribute_flags;
|
||||
|
||||
|
@ -365,6 +365,43 @@ class egw_customfields implements IteratorAggregate
|
||||
{
|
||||
$op = $cf['id'] ? 'update' : 'insert';
|
||||
|
||||
// Check to see if field order needs to be re-done
|
||||
$update = array();
|
||||
|
||||
$cfs = egw_customfields::get($cf['app'], true);
|
||||
$old = $cfs[$cf['name']];
|
||||
|
||||
// Add new one in for numbering
|
||||
if(!$cf['id'])
|
||||
{
|
||||
$cfs[$cf['name']] = $cf;
|
||||
}
|
||||
|
||||
if($old['order'] != $cf['order'] || $cf['order'] % 10 !== 0)
|
||||
{
|
||||
$cfs[$cf['name']]['order'] = $cf['order'];
|
||||
uasort($cfs, function($a1, $a2){
|
||||
return $a1['order'] - $a2['order'];
|
||||
});
|
||||
$n = 0;
|
||||
foreach($cfs as $old_cf)
|
||||
{
|
||||
$n += 10;
|
||||
if($old_cf['order'] != $n)
|
||||
{
|
||||
$old_cf['order'] = $n;
|
||||
if($old_cf['name'] != $cf['name'])
|
||||
{
|
||||
$update[] = $old_cf;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cf['order'] = $n;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self::$db->$op(self::TABLE, array(
|
||||
'cf_label' => $cf['label'],
|
||||
'cf_type' => $cf['type'],
|
||||
@ -383,6 +420,16 @@ class egw_customfields implements IteratorAggregate
|
||||
'cf_app' => $cf['app'],
|
||||
), __LINE__, __FILE__);
|
||||
|
||||
foreach($update as $old_cf)
|
||||
{
|
||||
self::$db->$op(self::TABLE, array(
|
||||
'cf_order' => $old_cf['order'],
|
||||
), array(
|
||||
'cf_name' => $old_cf['name'],
|
||||
'cf_app' => $old_cf['app'],
|
||||
), __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
self::invalidate_cache($cf['app']);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user