entityform_notifications.install in Entityform 7.2
Same filename and directory in other branches
Update functions for Entityform Notifications
File
entityform_notifications/entityform_notifications.installView source
<?php
/**
* @file
* Update functions for Entityform Notifications
*/
/**
* Implements hook_enable().
*
* Make sure Entityform is enabled from for entity_rules
*/
function entityform_notifications_enable() {
$enabled_types = variable_get('entity_rules_types', explode(',', ENTITY_RULES_DEFAULT_TYPES));
if (!in_array('entityform', $enabled_types, TRUE)) {
$enabled_types[] = 'entityform';
variable_set('entity_rules_types', $enabled_types);
}
}
/**
* Change email variables to use new tokens from Rules.
*/
function entityform_notifications_update_7001(&$sandbox) {
$old_token = '[submitted-entityform';
$new_token = '[entityform';
$var_names = array(
'entityform_notify_submitter_subject',
'entityform_notify_submitter_body',
'entityform_notify_admin_subject',
'entityform_notify_admin_body',
);
$repaced = FALSE;
foreach ($var_names as $var_name) {
$var_value = variable_get($var_name);
if (!empty($var_value) && strstr($var_value, $old_token) !== FALSE) {
$var_value = str_replace($old_token, $new_token, $var_value);
variable_set($var_name, $var_value);
$repaced = TRUE;
}
}
if ($repaced) {
drupal_set_message(t('Replace references to old entityform tokens in variables.'));
}
}
/**
* Enabling new dependencies (entity_rules, entity2text).
*/
function entityform_notifications_update_7002(&$sandbox) {
module_enable(array(
'entity_rules',
'entity2text',
));
drupal_set_message(t('Entityforms Notifications new dependencies: entity_rules and entity2text.'));
}
Functions
Name | Description |
---|---|
entityform_notifications_enable | Implements hook_enable(). |
entityform_notifications_update_7001 | Change email variables to use new tokens from Rules. |
entityform_notifications_update_7002 | Enabling new dependencies (entity_rules, entity2text). |