function opigno_og_access_install in Opigno 7
@file Install, update, and uninstall functions for the Organic groups access module.
File
- modules/
opigno_og_access/ opigno_og_access.install, line 10 - Install, update, and uninstall functions for the Organic groups access module.
Code
function opigno_og_access_install() {
db_update('system')
->fields(array(
'weight' => 20,
))
->condition('name', 'opigno_og_access')
->execute();
$field = field_info_field('group_access');
if (empty($field)) {
field_create_field(array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'allowed_values' => array(
'Public (World-wide open, for example for demo courses)',
'Semi-public (registered users can subscribe to the course)',
'Private (users can only be subscribed by a course administrator or a teacher, the course is hidden from course catalogue)',
),
'allowed_values_function' => '',
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_group_access' => array(
'value' => 'group_access_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_group_access' => array(
'value' => 'group_access_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
'value',
),
),
'field_name' => 'group_access',
'type' => 'list_integer',
'module' => 'list',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
'course',
),
),
));
}
$instance = field_info_instance('node', 'group_access', 'course');
if (empty($instance)) {
field_create_instance(array(
'label' => 'Group visibility',
'widget' => array(
'weight' => '1',
'type' => 'options_buttons',
'module' => 'options',
'active' => 1,
'settings' => array(),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'list_default',
'settings' => array(),
'module' => 'list',
'weight' => 12,
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 1,
'description' => '',
'default_value' => NULL,
'field_name' => 'group_access',
'entity_type' => 'node',
'bundle' => 'course',
'deleted' => '0',
));
}
$field = field_info_field('requires_validation');
if (empty($field)) {
field_create_field(array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'allowed_values' => array(
'0',
'1',
),
'allowed_values_function' => '',
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_requires_validation' => array(
'value' => 'requires_validation_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_requires_validation' => array(
'value' => 'requires_validation_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
'value',
),
),
'field_name' => 'requires_validation',
'type' => 'list_boolean',
'module' => 'list',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
'course',
),
),
));
}
$instance = field_info_instance('node', 'requires_validation', 'course');
if (empty($instance)) {
field_create_instance(array(
'label' => 'Requires validation',
'widget' => array(
'weight' => '2',
'type' => 'options_onoff',
'module' => 'options',
'active' => 1,
'settings' => array(
'display_label' => 1,
),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'list_default',
'settings' => array(),
'module' => 'list',
'weight' => 11,
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 0,
'description' => '',
'default_value' => array(
array(
'value' => 0,
),
),
'field_name' => 'requires_validation',
'entity_type' => 'node',
'bundle' => 'course',
'deleted' => '0',
));
}
$field = field_info_field('anomymous_visibility');
if (empty($field)) {
field_create_field(array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'allowed_values' => array(
'0',
'1',
),
'allowed_values_function' => '',
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_anomymous_visibility' => array(
'value' => 'anomymous_visibility_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_anomymous_visibility' => array(
'value' => 'anomymous_visibility_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
'value',
),
),
'field_name' => 'anomymous_visibility',
'type' => 'list_boolean',
'module' => 'list',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
'course',
),
),
));
}
$instance = field_info_instance('node', 'anomymous_visibility', 'course');
if (empty($instance)) {
field_create_instance(array(
'label' => 'Hide for anonymous users',
'widget' => array(
'weight' => '2',
'type' => 'options_onoff',
'module' => 'options',
'active' => 1,
'settings' => array(
'display_label' => 1,
),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'list_default',
'settings' => array(),
'module' => 'list',
'weight' => 10,
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 0,
'description' => '',
'default_value' => array(
array(
'value' => 0,
),
),
'field_name' => 'anomymous_visibility',
'entity_type' => 'node',
'bundle' => 'course',
'deleted' => '0',
));
}
$field = field_info_field('catalogue_visibility');
if (empty($field)) {
field_create_field(array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'allowed_values' => array(
'0',
'1',
),
'allowed_values_function' => '',
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_catalogue_visibility' => array(
'value' => 'catalogue_visibility_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_catalogue_visibility' => array(
'value' => 'catalogue_visibility_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
'value',
),
),
'field_name' => 'catalogue_visibility',
'type' => 'list_boolean',
'module' => 'list',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
'course',
),
),
));
}
$instance = field_info_instance('node', 'catalogue_visibility', 'course');
if (empty($instance)) {
field_create_instance(array(
'label' => 'Hide from Catalogue',
'widget' => array(
'weight' => '36',
'type' => 'options_onoff',
'module' => 'options',
'active' => 1,
'settings' => array(
'display_label' => 1,
),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'list_default',
'settings' => array(),
'module' => 'list',
'weight' => 13,
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 0,
'description' => '',
'default_value' => array(
array(
'value' => 0,
),
),
'field_name' => 'catalogue_visibility',
'entity_type' => 'node',
'bundle' => 'course',
'deleted' => '0',
));
}
og_create_field(OG_DEFAULT_ACCESS_FIELD, 'node', "course");
$field = field_info_field('group_access');
if (empty($field)) {
field_create_field(array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'allowed_values' => array(
'Public (World-wide open, for example for demo courses)',
'Semi-public (registered users can subscribe to the course)',
'Private (users can only be subscribed by a course administrator or a teacher, the course is hidden from course catalogue)',
),
'allowed_values_function' => '',
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_group_access' => array(
'value' => 'group_access_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_group_access' => array(
'value' => 'group_access_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
'value',
),
),
'field_name' => 'group_access',
'type' => 'list_integer',
'module' => 'list',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
'class',
),
),
));
}
$instance = field_info_instance('node', 'group_access', 'class');
if (empty($instance)) {
field_create_instance(array(
'label' => 'Group visibility',
'widget' => array(
'weight' => '35',
'type' => 'options_buttons',
'module' => 'options',
'active' => 1,
'settings' => array(),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'list_default',
'settings' => array(),
'module' => 'list',
'weight' => 12,
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 1,
'description' => '',
'default_value' => NULL,
'field_name' => 'group_access',
'entity_type' => 'node',
'bundle' => 'class',
'deleted' => '0',
));
}
$field = field_info_field('requires_validation');
if (empty($field)) {
field_create_field(array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'allowed_values' => array(
'0',
'1',
),
'allowed_values_function' => '',
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_requires_validation' => array(
'value' => 'requires_validation_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_requires_validation' => array(
'value' => 'requires_validation_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
'value',
),
),
'field_name' => 'requires_validation',
'type' => 'list_boolean',
'module' => 'list',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
'class',
),
),
));
}
$instance = field_info_instance('node', 'requires_validation', 'class');
if (empty($instance)) {
field_create_instance(array(
'label' => 'Requires validation',
'widget' => array(
'weight' => '37',
'type' => 'options_onoff',
'module' => 'options',
'active' => 1,
'settings' => array(
'display_label' => 1,
),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'list_default',
'settings' => array(),
'module' => 'list',
'weight' => 14,
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 0,
'description' => '',
'default_value' => array(
array(
'value' => 0,
),
),
'field_name' => 'requires_validation',
'entity_type' => 'node',
'bundle' => 'class',
'deleted' => '0',
));
}
$field = field_info_field('anomymous_visibility');
if (empty($field)) {
field_create_field(array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'allowed_values' => array(
'0',
'1',
),
'allowed_values_function' => '',
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_anomymous_visibility' => array(
'value' => 'anomymous_visibility_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_anomymous_visibility' => array(
'value' => 'anomymous_visibility_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
'value',
),
),
'field_name' => 'anomymous_visibility',
'type' => 'list_boolean',
'module' => 'list',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
'class',
),
),
));
}
$instance = field_info_instance('node', 'anomymous_visibility', 'class');
if (empty($instance)) {
field_create_instance(array(
'label' => 'Hide for anonymous users',
'widget' => array(
'weight' => '36',
'type' => 'options_onoff',
'module' => 'options',
'active' => 1,
'settings' => array(
'display_label' => 1,
),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'list_default',
'settings' => array(),
'module' => 'list',
'weight' => 13,
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 0,
'description' => '',
'default_value' => array(
array(
'value' => 0,
),
),
'field_name' => 'anomymous_visibility',
'entity_type' => 'node',
'bundle' => 'class',
'deleted' => '0',
));
}
$field = field_info_field('catalogue_visibility');
if (empty($field)) {
field_create_field(array(
'translatable' => '0',
'entity_types' => array(),
'settings' => array(
'allowed_values' => array(
'0',
'1',
),
'allowed_values_function' => '',
),
'storage' => array(
'type' => 'field_sql_storage',
'settings' => array(),
'module' => 'field_sql_storage',
'active' => '1',
'details' => array(
'sql' => array(
'FIELD_LOAD_CURRENT' => array(
'field_data_catalogue_visibility' => array(
'value' => 'catalogue_visibility_value',
),
),
'FIELD_LOAD_REVISION' => array(
'field_revision_catalogue_visibility' => array(
'value' => 'catalogue_visibility_value',
),
),
),
),
),
'foreign keys' => array(),
'indexes' => array(
'value' => array(
'value',
),
),
'field_name' => 'catalogue_visibility',
'type' => 'list_boolean',
'module' => 'list',
'active' => '1',
'locked' => '0',
'cardinality' => '1',
'deleted' => '0',
'columns' => array(
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
'bundles' => array(
'node' => array(
'class',
),
),
));
}
$instance = field_info_instance('node', 'catalogue_visibility', 'class');
if (empty($instance)) {
field_create_instance(array(
'label' => 'Hide from Catalogue',
'widget' => array(
'weight' => '36',
'type' => 'options_onoff',
'module' => 'options',
'active' => 1,
'settings' => array(
'display_label' => 1,
),
),
'settings' => array(
'user_register_form' => FALSE,
),
'display' => array(
'default' => array(
'label' => 'above',
'type' => 'list_default',
'settings' => array(),
'module' => 'list',
'weight' => 13,
),
'teaser' => array(
'type' => 'hidden',
'label' => 'above',
'settings' => array(),
'weight' => 0,
),
),
'required' => 0,
'description' => '',
'default_value' => array(
array(
'value' => 0,
),
),
'field_name' => 'catalogue_visibility',
'entity_type' => 'node',
'bundle' => 'class',
'deleted' => '0',
));
}
og_create_field(OG_DEFAULT_ACCESS_FIELD, 'node', "class");
}