You are here

function redhen_engagement_install in RedHen CRM 7

Implements hook_install().

File

modules/redhen_engagement/redhen_engagement.install, line 155
RedhenEngagement install file.

Code

function redhen_engagement_install() {

  // Add an engagement score field to redhen_contact.
  $field = array(
    'description' => 'The total engagement score for a contact.',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
  );
  db_add_field('redhen_contact', 'engagement_score', $field);

  // Hide engagement_score in non-default view modes for RedHen Contact.
  $field_settings = array(
    'extra_fields' => array(
      'display' => array(
        'engagement_score' => array(
          'default' => array(
            'weight' => 0,
            'visible' => TRUE,
          ),
        ),
      ),
    ),
  );
  $entity_info = entity_get_info('redhen_contact');
  foreach (array_keys($entity_info['view modes']) as $view_mode) {
    $field_settings['extra_fields']['display']['engagement_score'][$view_mode] = array(
      'weight' => 0,
      'visible' => FALSE,
    );
  }
  field_bundle_settings('redhen_contact', 'contact', $field_settings);
}