summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmitai Burstein2013-03-17 08:01:31 (GMT)
committer Amitai Burstein2013-03-17 08:01:31 (GMT)
commitc1e10fad0e033f1256d0095328d4af9740740662 (patch)
tree34bc242c5205c96988ffdaf3fbdf09250830c6ac
parent33d8650a2978a905346ab4088e1662e6ff6c10c8 (diff)
Issue #1944618 by Amitaibu: Fixed Allow getting values without validation.
-rw-r--r--entityreference_prepopulate.module25
1 files changed, 14 insertions, 11 deletions
diff --git a/entityreference_prepopulate.module b/entityreference_prepopulate.module
index 65f3cc2..c8e88a1 100644
--- a/entityreference_prepopulate.module
+++ b/entityreference_prepopulate.module
@@ -131,7 +131,7 @@ function entityreference_prepopulate_field_attach_form($entity_type, $entity, &$
// Store prepopulated values in the form state to make them persistent,
// in case the form is rebuilt by AJAX requests.
- if ($values = entityreference_prepopulate_get_values($field, $instance)) {
+ if ($values = entityreference_prepopulate_get_values($field, $instance, TRUE)) {
$form_state['entityreference_prepopulate'][$instance['entity_type']][$instance['bundle']][$field['field_name']] = $values;
}
@@ -208,17 +208,17 @@ function entityreference_prepopulate_field_access($op, $field, $entity_type, $en
* TRUE if the group IDs should be sent as a simple array. FALSE, if we
* need to build array suited for field API's $items value.
*/
-function entityreference_prepopulate_get_values($field, $instance, $flat_array = FALSE) {
+function entityreference_prepopulate_get_values($field, $instance, $flat_array = FALSE, $validate = TRUE) {
$settings = $instance['settings']['behaviors']['prepopulate'];
if (!empty($settings['og_context']) && module_exists('og_context')) {
- return entityreference_prepopulate_get_values_from_og_context($field, $instance, $flat_array);
+ return entityreference_prepopulate_get_values_from_og_context($field, $instance, $flat_array, $validate);
}
- return entityreference_prepopulate_get_values_from_url($field, $instance, $flat_array);
+ return entityreference_prepopulate_get_values_from_url($field, $instance, $flat_array, $validate);
}
-function entityreference_prepopulate_get_values_from_og_context($field, $instance, $flat_array = FALSE) {
+function entityreference_prepopulate_get_values_from_og_context($field, $instance, $flat_array = FALSE, $validate = TRUE) {
$field_name = $field['field_name'];
if (!og_is_group_audience_field($field_name) || !$og_context = og_context()) {
@@ -249,7 +249,7 @@ function entityreference_prepopulate_get_values_from_og_context($field, $instanc
* @see
* entityreference_prepopulate_get_values()
*/
-function entityreference_prepopulate_get_values_from_url($field, $instance, $flat_array = FALSE) {
+function entityreference_prepopulate_get_values_from_url($field, $instance, $flat_array = FALSE, $validate = TRUE) {
$cache = &drupal_static(__FUNCTION__, array());
$field_name = $field['field_name'];
$identifier = $instance['entity_type'] . ':' . $instance['bundle'] . ':' . $field_name . ':' . $flat_array;
@@ -284,13 +284,16 @@ function entityreference_prepopulate_get_values_from_url($field, $instance, $fla
}
}
- // Check if the IDs are valid, and filter out the invalid ones.
- $handler = entityreference_get_selection_handler($field, $instance);
- if (!$ids = $handler->validateReferencableEntities($ids)) {
- $cache[$identifier] = FALSE;
- return;
+ // Check if the IDs are valid, and get filter out the ones that are not valid.
+ if ($validate) {
+ $handler = entityreference_get_selection_handler($field, $instance);
+ if (!$ids = $handler->validateReferencableEntities($ids)) {
+ $cache[$identifier] = FALSE;
+ return;
+ }
}
+
// Check access to the provided entities.
$target_type = $field['settings']['target_type'];
entity_load($target_type, $ids);