function social_content_picasa_install in Social Content 7.2
Implements hook_install().
File
- modules/
picasa/ social_content_picasa.install, line 10 - Install/uninstall code for Social Content: Picasa.
Code
function social_content_picasa_install() {
$create_bundle = variable_get('social_content_create_bundles', TRUE);
if (!$create_bundle) {
return;
}
$t = get_t();
// Create and save a new content object.
// Machine name of the content type.
$type = 'picasa';
// Define the node type.
$picasa = array(
'type' => $type,
'name' => $t('Picasa picture'),
'base' => 'node_content',
'title_label' => $t('Title'),
'description' => $t('A photo imported from Picasa Web Albums / Google Plus.'),
'custom' => TRUE,
);
// Set other node defaults not declared above.
$content_type = node_type_set_defaults($picasa);
// Add the body field.
node_add_body_field($content_type, $t('Body'));
// Save the content type.
node_type_save($content_type);
// Update persistent variables with settings.
// Add persistent variables that control settings.
variable_set('additional_settings__active_tab_' . $type, 'edit-menu');
// 0 = disabled, 1 = optional, 2 = required.
variable_set('node_preview_' . $type, 0);
// array(0 => 'status', 1 => 'promote', 2 => 'sticky', 3 => 'revision') remove to uncheck.
variable_set('node_options_' . $type, array(
0 => 'status',
));
// 1 = Display author and date information, 0 = none.
variable_set('node_submitted_' . $type, 0);
variable_set('menu_options_' . $type, array());
variable_set('menu_parent_' . $type, 'main-menu:0');
// Create and add instances of new fields.
// Create all the fields we are adding to our content type.
module_load_include('inc', 'social_content_picasa', 'social_content_picasa.fields');
foreach (social_content_picasa_create_fields() as $field_name => $field) {
if (field_info_field($field_name) == NULL) {
field_create_field($field);
}
}
// Create all the instances for our fields.
foreach (social_content_picasa_create_instances() as $field_name => $instance) {
if (field_info_instance('node', $field_name, $type) == NULL) {
$instance['entity_type'] = 'node';
$instance['bundle'] = $picasa['type'];
field_create_instance($instance);
}
}
}