diff --git a/entityreference.module b/entityreference.module index ab36ceb..8d1dbed 100644 --- a/entityreference.module +++ b/entityreference.module @@ -783,7 +783,7 @@ function entityreference_autocomplete_callback($type, $field_name, $entity_type, // Loop through the products and convert them into autocomplete output. foreach ($entity_labels as $entity_id => $label) { $key = "$label ($entity_id)"; - $key = preg_replace('/\s\s+/', ' ', str_replace("\n", '', trim(decode_entities(strip_tags($key))))); + $key = preg_replace('/\s\s+/', ' ', str_replace("\n", '', trim(decode_entities(strip_tags($key))))); // Names containing commas or quotes must be wrapped in quotes. if (strpos($key, ',') !== FALSE || strpos($key, '"') !== FALSE) { $key = '"' . str_replace('"', '""', $key) . '"'; diff --git a/plugins/selection/EntityReference_SelectionHandler_Views.class.php b/plugins/selection/EntityReference_SelectionHandler_Views.class.php index 1c2dade..40168b7 100644 --- a/plugins/selection/EntityReference_SelectionHandler_Views.class.php +++ b/plugins/selection/EntityReference_SelectionHandler_Views.class.php @@ -79,7 +79,8 @@ class EntityReference_SelectionHandler_Views implements EntityReference_Selectio // Check that the view is valid and the display still exists. $this->view = views_get_view($view_name); - if (!$this->view || !isset($this->view->display[$display_name])) { + if (!$this->view || !isset($this->view->display[$display_name]) || !$this->view->access($display_name)) { + watchdog('entityreference', 'The view %view_name is no longer eligible.', array('%view_name' => $view_name), WATCHDOG_WARNING); return FALSE; } $this->view->set_display($display_name); @@ -95,6 +96,7 @@ class EntityReference_SelectionHandler_Views implements EntityReference_Selectio 'ids' => $ids, ); $this->view->display_handler->set_option('entityreference_options', $entityreference_options); + return TRUE; } /** @@ -103,10 +105,10 @@ class EntityReference_SelectionHandler_Views implements EntityReference_Selectio public function getReferencableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) { $display_name = $this->field['settings']['handler_settings']['view']['display_name']; $args = $this->field['settings']['handler_settings']['view']['args']; - $this->initializeView($match, $match_operator, $limit); - - // Get the results. - return $this->view->execute_display($display_name, $args); + if ($this->initializeView($match, $match_operator, $limit)) { + // Get the results. + return $this->view->execute_display($display_name, $args); + } } /** @@ -120,11 +122,11 @@ class EntityReference_SelectionHandler_Views implements EntityReference_Selectio function validateReferencableEntities(array $ids) { $display_name = $this->field['settings']['handler_settings']['view']['display_name']; $args = $this->field['settings']['handler_settings']['view']['args']; - $this->initializeView(NULL, 'CONTAINS', 0, $ids); - - // Get the results. - $entities = $this->view->execute_display($display_name, $args); - return array_keys($entities); + if ($this->initializeView(NULL, 'CONTAINS', 0, $ids)) { + // Get the results. + $entities = $this->view->execute_display($display_name, $args); + return array_keys($entities); + } } /** @@ -161,4 +163,4 @@ function entityreference_view_settings_validate($element, &$form_state, $form) { $value = array('view_name' => $view, 'display_name' => $display, 'args' => $args); form_set_value($element, $value, $form_state); -} \ No newline at end of file +}