party_log.install in Party 7
Install hooks for the Party Logging module.
File
modules/party_log/party_log.installView source
<?php
/**
* @file
* Install hooks for the Party Logging module.
*/
/**
* Implements hook_install().
*/
function party_log_install() {
$t = get_t();
if (!field_info_instance('message_type', MESSAGE_FIELD_MESSAGE_TEXT, 'party_log')) {
$instance = array(
'field_name' => MESSAGE_FIELD_MESSAGE_TEXT,
'bundle' => 'party_log',
'entity_type' => 'message_type',
'label' => $t('Message text'),
'description' => $t('This is the text of all messages of this type.'),
'required' => TRUE,
'settings' => array(
'text_processing' => 1,
),
);
field_create_instance($instance);
}
// Add a field for the other parties.
if (!field_info_field('other_party')) {
$field = array(
'field_name' => 'other_party',
'type' => 'entityreference',
'cardinality' => 1,
'settings' => array(
'target_type' => 'party',
'handler' => 'base',
'handler_settings' => array(
'sort' => array(
'type' => 'none',
),
),
),
);
field_create_field($field);
}
foreach (array(
'party_merged_into',
'party_had_other_merged_in',
) as $bundle) {
if (!field_info_instance('message', 'other_party', $bundle)) {
$instance = array(
'field_name' => 'other_party',
'entity_type' => 'message',
'bundle' => $bundle,
'label' => t('Other Party'),
'required' => TRUE,
'settings' => array(
'default_value' => '',
),
'widget' => array(
'type' => 'entityreference_autocomplete',
'settings' => array(
'size' => '60',
'match_operator' => 'CONTAINS',
),
),
);
field_create_instance($instance);
}
}
}
/**
* Implements hook_uninstall().
*/
function party_log_uninstall() {
$instance = field_info_instance('message_type', MESSAGE_FIELD_MESSAGE_TEXT, 'party_log');
field_delete_instance($instance);
}
/**
* Add the Message Text field to our message_type bundle.
*/
function party_log_update_7001() {
if (!field_info_instance('message_type', MESSAGE_FIELD_MESSAGE_TEXT, 'party_log')) {
$instance = array(
'field_name' => MESSAGE_FIELD_MESSAGE_TEXT,
'bundle' => 'party_log',
'entity_type' => 'message_type',
'label' => t('Message text'),
'description' => t('This is the text of all messages of this type.'),
'required' => TRUE,
'settings' => array(
'text_processing' => 1,
),
);
field_create_instance($instance);
}
}
/**
* Add a field for the storing of the other party.
*/
function party_log_update_7002() {
// Add a field for the other parties.
if (!field_info_field('other_party')) {
$field = array(
'field_name' => 'other_party',
'type' => 'entityreference',
'cardinality' => 1,
'settings' => array(
'target_type' => 'party',
'handler' => 'base',
'handler_settings' => array(
'sort' => array(
'type' => 'none',
),
),
),
);
field_create_field($field);
}
foreach (array(
'party_merged_into',
'party_had_other_merged_in',
) as $bundle) {
if (!field_info_instance('message', 'other_party', $bundle)) {
$instance = array(
'field_name' => 'other_party',
'entity_type' => 'message',
'bundle' => $bundle,
'label' => t('Other Party'),
'required' => TRUE,
'settings' => array(
'default_value' => '',
),
'widget' => array(
'type' => 'entityreference_autocomplete',
'settings' => array(
'size' => '60',
'match_operator' => 'CONTAINS',
),
),
);
field_create_instance($instance);
}
}
}Functions
|
Name |
Description |
|---|---|
| party_log_install | Implements hook_install(). |
| party_log_uninstall | Implements hook_uninstall(). |
| party_log_update_7001 | Add the Message Text field to our message_type bundle. |
| party_log_update_7002 | Add a field for the storing of the other party. |