You are here

function paypal_donate_install in Paypal Donation 7

Same name and namespace in other branches
  1. 6 paypal_donate.install \paypal_donate_install()

This hook is triggered when the paypal donate module is being installed. This function will run only once and gives us the possibility to install the a required table in the database.

@since 1.1

Return value

void

File

./paypal_donate.install, line 20
Install, update and uninstall functions for the paypal_donate module.

Code

function paypal_donate_install() {

  /**
   * Thanks to pillarsdotnet (http://drupal.org/user/36148).
   * In a later version this will be replaced with the proper
   * update hook. It has todo for now (sorry).
   */
  if (variable_get('paypal_donate_version')) {
    paypal_donate_uninstall();
  }
  variable_set('paypal_donate_version', PAYPAL_DONATE_VERSION);
  node_types_rebuild();
  $types = node_type_get_types();
  node_add_body_field($types['paypal_donate']);
  $body_instance = field_info_instance('node', 'body', 'paypal_donate');
  $body_instance['type'] = 'text_summary_or_trimmed';
  field_update_instance($body_instance);
  foreach (_paypal_donate_installed_fields() as $field) {
    field_create_field($field);
  }
  foreach (_paypal_donate_installed_fields() as $instance) {
    $instance['entity_type'] = 'node';
    $instance['bundle'] = 'paypal_donate';
    field_create_instance($instance);
  }
}