'{$option_name}',"; $output[] = " 'name' => t('{$pub_types[$option_name]['name']}'),"; $output[] = " 'node_types' => array("; foreach ($option_node_types as $node_type => $node_name) { $output[] = " '{$node_type}' => t('{$node_name}'),"; } $output[] = " ),"; $output[] = " );"; $output[] = ""; } } $output[] = ' return $options;'; $output = implode("\n", $output); return array('custom_pub_defaults' => $output); } /** * Implements hook_features_revert(). * * @param $module * Name of module to revert content for. */ function custom_pub_features_revert($module = NULL) { if ($default_options = features_get_default('custom_pub', $module)) { $pub_types = variable_get('custom_pub_types', array()); foreach ($default_options as $option_name => $option_info) { if (isset($pub_types[$option_name])) { unset($pub_types[$option_name]); } } variable_set('custom_pub_types', $pub_types); custom_pub_types_rebuild(); } } /** * Implements hook_features_disable_feature(). * * @param $module * Name of module that has been disabled. */ function custom_pub_features_disable_feature($module) { if ($default_options = features_get_default('custom_pub', $module)) { $pub_types = variable_get('custom_pub_types', array()); foreach ($default_options as $option_name => $option_info) { if (isset($pub_types[$option_name])) { unset($pub_types[$option_name]['default']); } } variable_set('custom_pub_types', $pub_types); // Rebuild schema cache_clear_all('schema', 'cache'); } } /** * Implements hook_features_enable_feature(). * * @param $module * Name of module that has been enabled. */ function custom_pub_features_enable_feature($module) { if ($default_options = features_get_default('custom_pub', $module)) { $spec = array( 'type' => 'int', 'not null' => TRUE, 'default' => 0 ); // Add fields in database foreach ($default_options as $option_name => $option_info) { if (!db_field_exists('node', $option_name)) { $spec['description'] = "Custom publishing option $option_name"; db_add_field('node', $option_name, $spec); } } custom_pub_types_rebuild(); // Rebuild schema cache_clear_all('schema', 'cache'); } }