function resource_conflict_form_alter in Resource Conflict 7.3
Same name and namespace in other branches
- 5.2 resource_conflict.module \resource_conflict_form_alter()
- 5 resource_conflict.module \resource_conflict_form_alter()
- 6.2 resource_conflict.module \resource_conflict_form_alter()
- 7.2 resource_conflict.module \resource_conflict_form_alter()
Implements hook_form_alter().
File
- ./
resource_conflict.module, line 225 - Provides general functionality for the resource conflict module.
Code
function resource_conflict_form_alter(&$form, $form_state, $form_id) {
if ($form_id != 'node_type_form') {
return;
}
$type = isset($form['old_type']) && isset($form['old_type']['#value']) ? $form['old_type']['#value'] : NULL;
$form['resource_conflict_set'] = array(
'#type' => 'fieldset',
'#title' => t('Resource Conflict'),
'#collapsible' => TRUE,
'#group' => 'additional_settings',
);
$disabled_msg = t('To set up this content type for conflict checking, first add a Date field with a required end date (repeate dates are supported). When the conditions have been met, this section will be enabled for configuration.');
// The user is adding a new content type.
if ($type == NULL) {
$form['resource_conflict_set']['rc_info'] = array(
'#prefix' => '<p>',
'#suffix' => '</p>',
'#markup' => $disabled_msg,
);
return;
}
$date_fields = array();
$fields = field_info_instances('node', $type);
foreach ($fields as $machine_name => $field_instance) {
if (_resource_conflict_check_field_compatibility($field_instance)) {
$date_fields[$machine_name] = $field_instance['label'];
}
}
if (empty($date_fields)) {
$form['resource_conflict_set']['requirements'] = array(
'#prefix' => '<p>',
'#suffix' => '</p>',
'#weight' => -10,
'#markup' => $disabled_msg,
);
}
else {
$form['resource_conflict_set']['rc_type'] = array(
'#type' => 'checkbox',
'#title' => t('Enable resource conflict checking for this content type'),
'#default_value' => variable_get('rc_type_' . $type, 0),
'#weight' => -8,
);
$form['resource_conflict_set']['rc_date_field'] = array(
'#type' => 'select',
'#title' => t('Field to use as the date for conflict checks'),
'#options' => $date_fields,
'#multiple' => FALSE,
'#default_value' => variable_get('rc_date_field_' . $type, FALSE),
'#description' => t("Select the date field to use to check for resource conflicts."),
);
$form['resource_conflict_set']['rc_conflict_buffer_start'] = array(
'#type' => 'textfield',
'#title' => t('Conflict Buffer - Start'),
'#description' => t('Added to the start date of bookings to extend the conflict zone. <a href="@strtotime">strtotime</a> format. Example: "-5 minutes".', array(
'@strtotime' => 'http://us1.php.net/strtotime',
)),
'#default_value' => variable_get('rc_conflict_buffer_start_' . $type, ''),
);
$form['resource_conflict_set']['rc_conflict_buffer_end'] = array(
'#type' => 'textfield',
'#title' => t('Conflict Buffer - End'),
'#description' => t('Added to the end date of bookings to extend the conflict zone. <a href="@strtotime">strtotime</a> format. Example: "+5 minutes".', array(
'@strtotime' => 'http://us1.php.net/strtotime',
)),
'#default_value' => variable_get('rc_conflict_buffer_end_' . $type, ''),
);
}
// Add our custom submission handler so we can manage the RC settings.
$form['#validate'][] = 'resource_conflict_form_validate';
$form['#submit'][] = 'resource_conflict_form_submit';
}