function fieldgroup_save_group in Content Construction Kit (CCK) 5
Same name and namespace in other branches
- 6.3 modules/fieldgroup/fieldgroup.module \fieldgroup_save_group()
- 6 modules/fieldgroup/fieldgroup.module \fieldgroup_save_group()
- 6.2 modules/fieldgroup/fieldgroup.module \fieldgroup_save_group()
2 calls to fieldgroup_save_group()
File
- ./
fieldgroup.module, line 163 - Create field groups for CCK fields.
Code
function fieldgroup_save_group($type_name, $group) {
$groups = fieldgroup_groups($type_name);
$old_group = $groups[$group['group_name']];
if (!$old_group) {
// Accept group name from programmed submissions if valid.
if (!empty($group['group_name'])) {
$group_name = $group['group_name'];
}
else {
// Otherwise, find a valid, computer-friendly name.
$group_name = trim($group['label']);
$group_name = drupal_strtolower($group_name);
$group_name = str_replace(array(
' ',
'-',
), '_', $group_name);
$group_name = preg_replace('/[^a-z0-9_]/', '', $group_name);
$group_name = 'group_' . $group_name;
$group_name = substr($group_name, 0, 30);
if (isset($groups[$group_name])) {
$group_name_base = $group_name;
$counter = 0;
while (isset($groups[$group_name])) {
$group_name = $group_name_base . '_' . $counter++;
}
}
}
db_query("INSERT INTO {node_group} (type_name, group_name, label, settings, weight)\n VALUES ('%s', '%s', '%s', '%s', %d)", $type_name, $group_name, $group['label'], serialize($group['settings']), $group['weight']);
return SAVED_NEW;
}
else {
db_query("UPDATE {node_group} SET label = '%s', settings = '%s', weight = %d " . "WHERE type_name = '%s' AND group_name = '%s'", $group['label'], serialize($group['settings']), $group['weight'], $type_name, $group['group_name']);
return SAVED_UPDATED;
}
}