Make compatible with Entity Reference

parent ad113706
...@@ -31,7 +31,7 @@ function webform_results_access_webform_access ($node, $account = NULL) { ...@@ -31,7 +31,7 @@ function webform_results_access_webform_access ($node, $account = NULL) {
global $user; global $user;
$account = isset($account) ? $account : $user; $account = isset($account) ? $account : $user;
$access = false; $access = false;
if (isset($node->field_webform_results_access['und'][0]['uid'])) { // Drupal 6 if (isset($node->field_webform_results_access)) {
// This webform has user(s) specified for submission results access control. // This webform has user(s) specified for submission results access control.
if (user_access("administer nodes") || user_access("edit any webform content")) { if (user_access("administer nodes") || user_access("edit any webform content")) {
$access = true; $access = true;
...@@ -39,8 +39,14 @@ function webform_results_access_webform_access ($node, $account = NULL) { ...@@ -39,8 +39,14 @@ function webform_results_access_webform_access ($node, $account = NULL) {
else { else {
// For each user specified, make sure the current user is one of them, // For each user specified, make sure the current user is one of them,
// otherwise don't show the results. // otherwise don't show the results.
foreach ($node->field_webform_results_access['und'] as $i => $user_reference) { foreach ($node->field_webform_results_access['und'] as $i => $ref) {
if ($user_reference['uid'] == $account->uid) { // User Reference
if (isset($ref['uid']) && (($ref['uid'] == $account->uid))) {
$access = true;
break;
}
// Entity Reference
if (isset($ref['target_id']) && (($ref['target_id'] == $account->uid))) {
$access = true; $access = true;
break; break;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment