function entityform_update_7002 in Entityform 7
Same name and namespace in other branches
- 7.2 entityform.install \entityform_update_7002()
Switch emails settings to Rules invoke settings.
File
- ./
entityform.install, line 149 - Sets up the base table for our entity and a table to store information about the entity types.
Code
function entityform_update_7002(&$sandbox = NULL) {
$ret = array();
if (!module_enable(array(
'rules',
))) {
throw new DrupalUpdateException('This version of Entityforms requires Rules, but it could not be enabled.');
}
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'entityform_type');
$results = $query
->execute();
$ids = isset($results['entityform_type']) ? array_keys($results['entityform_type']) : array();
$entities = $ids ? entity_load('entityform_type', $ids) : array();
foreach ($entities as $eid => $entityform_type) {
$entityform_type->data['notification_text'] = $entityform_type->data['email_body'];
$entityform_type->data['submission_rules'] = array();
if (!empty($entityform_type->data['confirm_email'])) {
$entityform_type->data['submission_rules'][] = 'rules_email_entityform_submitter';
unset($entityform_type->data['confirm_email']);
}
if (!empty($entityform_type->data['notify_emails'])) {
$entityform_type->data['submission_rules'][] = 'rules_email_entityform_admin';
}
$entityform_type
->save();
}
return $ret;
}