function certificate_install in Certificate 7.3
Same name and namespace in other branches
- 8.3 certificate.install \certificate_install()
- 6.2 certificate.install \certificate_install()
- 6 certificate.install \certificate_install()
- 7.2 certificate.install \certificate_install()
- 3.x certificate.install \certificate_install()
Implements hook_install().
This hook is called the first time the module is installed. Unless it is explicitly uninstalled, disabling and re-enabling will not trigger this hook a second time.
File
- ./
certificate.install, line 282 - Install the Certificate module.
Code
function certificate_install() {
// Set certificate variables.
variable_set('node_options_certificate', array(
0 => 'revision',
));
variable_set('comment_certificate', 0);
// Add a body field to Certificate entity
$body = field_info_field('certificate_body');
$body_inst = field_info_instance('certificate', 'certificate_body', 'certificate');
if (empty($body)) {
$field = array(
'field_name' => 'certificate_body',
'type' => 'text_with_summary',
'entity_types' => array(
'certificate',
),
);
$field = field_create_field($field);
}
if (empty($body_inst)) {
$instance = array(
'field_name' => 'certificate_body',
'entity_type' => 'certificate',
'bundle' => 'certificate',
'label' => 'Body',
'widget' => array(
'type' => 'text_textarea_with_summary',
'weight' => 4,
),
'settings' => array(
'display_summary' => TRUE,
),
'display' => array(
'default' => array(
'label' => 'hidden',
'type' => 'text_default',
),
'teaser' => array(
'label' => 'hidden',
'type' => 'text_summary_or_trimmed',
),
),
);
field_create_instance($instance);
}
// Default certificate bundle.
$certificate_type = entity_create('certificate_type', array(
'type' => 'certificate',
'label' => t('Certificate'),
));
$certificate_type
->save();
}