summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgundalo2015-11-02 15:18:02 (GMT)
committerAaron Bauman2015-11-02 15:18:02 (GMT)
commit5af46aa450d60387b2c72a581c3b65cec7d1d9d5 (patch)
tree6a3c2e99db48a36eaf09fe146153d2c6d9e76e8a
parente771b10a2e99a94221b68a3e5b486ba5c5a2b526 (diff)
Issue #2079807 by wodenx, Jon Pugh: Preserve compatibility with Webform 4: don't use variable "webform_node_types"
-rw-r--r--webform_entity.migrate.inc2
-rw-r--r--webform_entity.module39
-rw-r--r--webform_entity_pages/webform_entity_pages.module2
3 files changed, 27 insertions, 16 deletions
diff --git a/webform_entity.migrate.inc b/webform_entity.migrate.inc
index e840d89..4ad6594 100644
--- a/webform_entity.migrate.inc
+++ b/webform_entity.migrate.inc
@@ -62,7 +62,7 @@ class MigrateDestinationWebformSubmissionEntity extends MigrateDestinationEntity
}
// Make sure the node type is on webform's list.
- $types = webform_variable_get('webform_node_types');
+ $types = webform_entity_node_types();
if (!in_array($this->node->type, $types)) {
throw new Exception(t("You need to provide either a node object or string node type that is configured to accept webform submissions. We found %type wanting.", array('%type' => $this->node->type)));
}
diff --git a/webform_entity.module b/webform_entity.module
index 62bc8b0..5330fc5 100644
--- a/webform_entity.module
+++ b/webform_entity.module
@@ -81,15 +81,12 @@ function webform_entity_entity_info() {
->fetchAllAssoc('type');
// Add existing node types.
- $node_types = array_keys(node_type_get_names());
- foreach ($node_types as $type) {
- if (in_array($type, webform_variable_get('webform_node_types'))) {
- $webform_submission_entity_type = new stdClass;
- $webform_submission_entity_type->id = 'new';
- $webform_submission_entity_type->type = $type;
-
- $types[$type] = $webform_submission_entity_type;
- }
+ foreach (webform_entity_node_types() as $type) {
+ $webform_submission_entity_type = new stdClass;
+ $webform_submission_entity_type->id = 'new';
+ $webform_submission_entity_type->type = $type;
+
+ $types[$type] = $webform_submission_entity_type;
}
if (!empty($types)) {
@@ -388,13 +385,27 @@ function webform_entity_form_alter(&$form, &$form_state, $form_id) {
}
/**
+ * Returns the list of webform-enabled node types.
+ * Works for webform 3.x and 4.x.
+ * @return array|null
+ */
+function webform_entity_node_types() {
+ if (function_exists('webform_node_types')) {
+ return webform_node_types();
+ }
+ else {
+ return webform_variable_get('webform_node_types');
+ }
+}
+
+/**
* Implements hook_form_[form_id]_alter().
*
* Here we link the node content types to on the webform admin pages to
* the field configuration pages for provided for our entity bundles.
*/
function webform_entity_form_webform_admin_settings_alter(&$form, &$form_state) {
- $webform_types = webform_variable_get('webform_node_types');
+ $webform_types = webform_entity_node_types();
$existing_entity_types = webform_entity_get_types();
foreach ($form['node_types']['#options'] as $option_name => &$option) {
if (in_array($option_name, $webform_types)) {
@@ -577,7 +588,7 @@ function webform_entity_node_load($nodes, $types) {
// by adding a fake component.
if ((arg(2) != 'webform' && arg(2) != 'submission') || arg(4) == 'edit') {
foreach ($nodes as $node) {
- if (!in_array($node->type, webform_variable_get('webform_node_types'))) {
+ if (!in_array($node->type, webform_entity_node_types())) {
return;
}
if (!is_array($nodes[$node->nid]->webform['components']) || empty($nodes[$node->nid]->webform['components'])) {
@@ -620,7 +631,7 @@ function webform_entity_node_save($node) {
* Implements hook_node_insert().
*/
function webform_entity_node_insert($node) {
- if (!in_array($node->type, webform_variable_get('webform_node_types'))) {
+ if (!in_array($node->type, webform_entity_node_types())) {
return;
}
@@ -631,7 +642,7 @@ function webform_entity_node_insert($node) {
// Always add a row to {webform} when adding a webform node. This is needed so that
// webform_submission_insert reliably has a nid.
- if ($node->webform == webform_node_defaults() && !in_array($node->type, webform_variable_get('webform_node_types_primary'))) {
+ if ($node->webform == webform_node_defaults() && !in_array($node->type, webform_entity_node_types())) {
$node->webform['nid'] = $node->nid;
webform_node_insert($node);
}
@@ -655,7 +666,7 @@ function webform_entity_get_types($type_name = null) {
// If we have a node type of this type but no webform_submission_entity_type,
// create one.
if (!isset($types[$type_name]) && in_array($type_name, array_keys(node_type_get_names()))) {
- if (in_array($type_name, webform_variable_get('webform_node_types'))) {
+ if (in_array($type_name, webform_entity_node_types())) {
$return = new stdClass;
$return->id = 'new';
$return->type = $type_name;
diff --git a/webform_entity_pages/webform_entity_pages.module b/webform_entity_pages/webform_entity_pages.module
index c006553..5b3ee28 100644
--- a/webform_entity_pages/webform_entity_pages.module
+++ b/webform_entity_pages/webform_entity_pages.module
@@ -59,7 +59,7 @@ function webform_entity_pages_pathauto($op) {
$settings['patterndefault'] = '[webform_submission_entity:node:url:path]/submission/[webform_submission_entity:sid]';
$settings['batch_update_callback'] = 'webform_entity_pages_pathauto_bulk_update_batch_process';
$settings['batch_file'] = drupal_get_path('module', 'webform_entity_pages') . '/webform_entity_pages.pathauto.inc';
- $webform_types = webform_variable_get('webform_node_types');
+ $webform_types = webform_entity_node_types();
if (count($webform_types)) {
$settings['patternitems'] = array();
foreach ($webform_types as $type) {