function opigno_in_house_training_app_install in Opigno in house training app 7
Implements hook_install()
File
- ./
opigno_in_house_training_app.install, line 12 - Contains install instructions and logic @ Carrard Cédric
Code
function opigno_in_house_training_app_install() {
$type = node_type_load("in_house_training");
//Check if content type exists
if (empty($type)) {
$type = node_type_set_defaults(array(
'type' => 'in_house_training',
'name' => st('In house training'),
'base' => 'node_content',
'description' => st('A Training, special content type'),
'has_title' => '1',
'title_label' => st('Title'),
'help' => '',
));
node_type_save($type);
}
variable_set('node_submitted_in_house_training', 0);
if (module_exists('print')) {
variable_set('print_display_in_house_training', 0);
variable_set('print_display_urllist_in_house_training', 0);
variable_set('print_pdf_display_in_house_training', 0);
variable_set('print_pdf_display_urllist_in_house_training', 0);
}
if (module_exists('comment')) {
variable_set('comment_in_house_training', COMMENT_NODE_CLOSED);
}
include_once drupal_get_path('module', 'og') . '/og_ui/og_ui.module';
if (function_exists('og_ui_node_type_save')) {
variable_set('og_group_content_type_in_house_training', TRUE);
og_ui_node_type_save('in_house_training');
opigno_in_house_training_app_update_og_group_ref();
if (module_exists('og_access')) {
og_create_field(OG_CONTENT_ACCESS_FIELD, 'node', 'in_house_training');
}
}
/////////////////////////////////////////////
// //
// CREATE FIELD //
// //
/////////////////////////////////////////
$field = field_info_field('opigno_iht_dates');
if (empty($field)) {
field_create_field(array(
'active' => 1,
'cardinality' => -1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'opigno_iht_dates',
'foreign keys' => array(),
'indexes' => array(),
'locked' => 0,
'module' => 'date',
'settings' => array(
'cache_count' => 4,
'cache_enabled' => 0,
'granularity' => array(
'day' => 'day',
'hour' => 'hour',
'minute' => 'minute',
'month' => 'month',
'second' => 0,
'year' => 'year',
),
'repeat' => 1,
'timezone_db' => 'UTC',
'todate' => 'required',
'tz_handling' => 'site',
),
'translatable' => 0,
'type' => 'datetime',
));
}
// if not empty create field_address
$field = field_info_field('opigno_iht_address');
if (empty($field)) {
field_create_field(array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'opigno_iht_address',
'foreign keys' => array(
'format' => array(
'columns' => array(
'format' => 'format',
),
'table' => 'filter_format',
),
),
'indexes' => array(
'format' => array(
0 => 'format',
),
),
'locked' => 0,
'module' => 'text',
'settings' => array(
'max_length' => 255,
),
'translatable' => 0,
'type' => 'text',
));
}
// if not empty create field_comment
$field = field_info_field('opigno_iht_comment');
if (empty($field)) {
field_create_field(array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'opigno_iht_comment',
'foreign keys' => array(
'format' => array(
'columns' => array(
'format' => 'format',
),
'table' => 'filter_format',
),
),
'indexes' => array(
'format' => array(
0 => 'format',
),
),
'locked' => 0,
'module' => 'text',
'settings' => array(),
'translatable' => 0,
'type' => 'text_long',
));
}
// if not empty create field_status
$field = field_info_field('opigno_iht_status');
if (empty($field)) {
field_create_field(array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'opigno_iht_status',
'foreign keys' => array(),
'indexes' => array(
'value' => array(
0 => 'value',
),
),
'locked' => 0,
'module' => 'list',
'settings' => array(
'allowed_values' => array(
'pending' => 'Pending',
'completed' => 'Completed',
'cancelled' => 'Cancelled',
'rescheduled' => 'Rescheduled',
),
'allowed_values_function' => '',
),
'translatable' => 0,
'type' => 'list_text',
));
}
// if not empty create field_status
$field = field_info_field('opigno_calendar_date');
if (empty($field)) {
field_create_field(array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'opigno_calendar_date',
'foreign keys' => array(),
'indexes' => array(),
'locked' => 0,
'module' => 'date',
'settings' => array(
'cache_count' => 4,
'cache_enabled' => 0,
'granularity' => array(
'day' => 'day',
'hour' => 'hour',
'minute' => 'minute',
'month' => 'month',
'second' => 0,
'year' => 'year',
),
'timezone_db' => 'UTC',
'todate' => 'optional',
'tz_handling' => 'site',
),
'translatable' => 0,
'type' => 'datetime',
));
}
///////////////////////////////////////////////
// //
// CREATE INSTANCE //
// //
///////////////////////////////////////////
$instance = field_info_instance('node', 'opigno_iht_dates', 'in_house_training');
if (empty($instance)) {
field_create_instance(array(
'bundle' => 'in_house_training',
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'date',
'settings' => array(),
'type' => 'hidden',
'weight' => 8,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'opigno_iht_dates',
'label' => 'In house training dates',
'required' => 0,
'settings' => array(
'default_value' => 'now',
'default_value2' => 'same',
'default_value_code' => '',
'default_value_code2' => '',
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'date',
'settings' => array(
'increment' => 15,
'input_format' => 'm/d/Y - H:i:s',
'input_format_custom' => '',
'label_position' => 'above',
'repeat_collapsed' => 1,
'text_parts' => array(),
'year_range' => '-3:+3',
),
'type' => 'date_popup',
'weight' => 32,
),
));
}
// if not empty create instance field_address
$instance = field_info_instance('node', 'opigno_iht_address', 'in_house_training');
if (empty($instance)) {
field_create_instance(array(
'bundle' => 'in_house_training',
'default_value' => NULL,
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'simple_gmap',
'settings' => array(
'iframe_height' => 200,
'iframe_width' => 200,
'include_link' => 0,
'include_map' => 1,
'include_static_map' => 0,
'include_text' => 1,
'information_bubble' => 1,
'langcode' => 'en',
'link_text' => 'View larger map',
'map_type' => 'm',
'zoom_level' => 14,
),
'type' => 'simple_gmap',
'weight' => 2,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'opigno_iht_address',
'label' => 'Address',
'required' => 1,
'settings' => array(
'text_processing' => 0,
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'text',
'settings' => array(
'size' => 60,
),
'type' => 'text_textfield',
'weight' => 5,
),
));
}
// if not empty create instance field_comment
$instance = field_info_instance('node', 'opigno_iht_comment', 'in_house_training');
if (empty($instance)) {
field_create_instance(array(
'bundle' => 'in_house_training',
'default_value' => NULL,
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'text',
'settings' => array(),
'type' => 'text_default',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'opigno_iht_comment',
'label' => 'Comment',
'required' => TRUE,
'settings' => array(
'text_processing' => 1,
'user_register_form' => FALSE,
),
'widget' => array(
'module' => 'text',
'settings' => array(
'rows' => 5,
),
'type' => 'text_textarea',
'weight' => 0,
),
));
}
// if not empty create instance field_status
$instance = field_info_instance('node', 'opigno_iht_status', 'in_house_training');
if (empty($instance)) {
field_create_instance(array(
'bundle' => 'in_house_training',
'default_value' => NULL,
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'list',
'settings' => array(),
'type' => 'list_default',
'weight' => 6,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'opigno_iht_status',
'label' => 'Status',
'required' => 1,
'settings' => array(
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'options',
'settings' => array(),
'type' => 'options_select',
'weight' => 4,
),
));
}
// if not empty create instance opigno_calendar_date
$instance = field_info_instance('node', 'opigno_calendar_date', 'in_house_training');
if (empty($instance)) {
field_create_instance(array(
'bundle' => 'in_house_training',
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'above',
'module' => 'date',
'settings' => array(
'format_type' => 'long',
'fromto' => 'both',
'multiple_from' => '',
'multiple_number' => '',
'multiple_to' => '',
),
'type' => 'date_default',
'weight' => 4,
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'opigno_calendar_date',
'label' => 'In house training date',
'required' => 0,
'settings' => array(
'default_value' => 'now',
'default_value2' => 'same',
'default_value_code' => '',
'default_value_code2' => '',
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'date',
'settings' => array(
'increment' => 15,
'input_format' => 'm/d/Y - H:i:s',
'input_format_custom' => '',
'label_position' => 'above',
'text_parts' => array(),
'year_range' => '-3:+3',
),
'type' => 'date_popup',
'weight' => 2,
),
));
}
if (function_exists('opigno_lms_refresh_strings_and_import')) {
opigno_lms_refresh_strings_and_import(array(
'field',
));
}
opigno_in_house_app_install_default_permissions();
}