You are here

function pet_install in Previewable email templates 6

Implementation of hook_install().

File

./pet.install, line 11
Previewable E-mail Template module install/schema/update hooks.

Code

function pet_install() {
  $success = drupal_install_schema('pet');
  if ($success) {

    // Install a couple demonstration templates (you can delete these from the UI if you want).
    include_once drupal_get_path('module', 'pet') . '/pet.module';
    $pet_simple = new stdClass();
    $pet_simple->name = 'simple';
    $pet_simple->title = 'Simple template';
    $pet_simple->subject = 'Simple subject';
    $pet_simple->body = 'Simple body';
    $pet_simple->object_types = '';
    $pet_simple->recipient_callback = '';
    pet_insert($pet_simple);
    $pet_tokens_and_callback = new stdClass();
    $pet_tokens_and_callback->name = 'tokens_and_callback';
    $pet_tokens_and_callback->title = 'Template with custom tokens and recipient list callback';
    $pet_tokens_and_callback->subject = 'Hi [user]';
    $pet_tokens_and_callback->body = 'I want to tell you something about node [title]';
    $pet_tokens_and_callback->object_types = '';
    $pet_tokens_and_callback->recipient_callback = 'pet_test_callback';
    pet_insert($pet_tokens_and_callback);
  }
  if ($success) {
    drupal_set_message(st('Previewable email template module installed successfully.'));
  }
  else {
    drupal_set_message(st('The installation of Previewable email template module failed.'), 'error');
  }
}