diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 350244b9ddd81bbb9871adc29828c87c541469d7..c688154c8368155107318e76edf813d551441a0a 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -12,6 +12,7 @@ Features: - #495582 Reviewed Panels 3 integration (prep work for combo / multigroups). Implementation of fieldgroup_view_group() that can be used to render field groups. - #417122 by quicksketch: allow drupal_alter on field and widget settings. +- #514452 Add new argument $node to content_access() to enhance the context for hook_field_access(). Bugfixes: - #482774 Update breaks when CCK is disabled. diff --git a/content.module b/content.module index 7ae3adccd2dfb848b21060596a4d73082f42ed24..553335505a3ac21c4d4ba0dbea1087a589993722 100644 --- a/content.module +++ b/content.module @@ -787,7 +787,7 @@ function content_field($op, &$node, $field, &$items, $teaser, $page) { '#type' => 'content_field', '#title' => check_plain(t($field['widget']['label'])), '#field_name' => $field['field_name'], - '#access' => $formatter_name != 'hidden' && content_access('view', $field), + '#access' => $formatter_name != 'hidden' && content_access('view', $field, NULL, $node), '#label_display' => $label_display, '#node' => $node, '#teaser' => $teaser, @@ -1780,7 +1780,7 @@ function content_format($field, $item, $formatter_name = 'default', $node = NULL $field = content_fields($field); } - if (content_access('view', $field) && $formatter = _content_get_formatter($formatter_name, $field['type'])) { + if (content_access('view', $field, NULL, $node) && $formatter = _content_get_formatter($formatter_name, $field['type'])) { $theme = $formatter['module'] .'_formatter_'. $formatter_name; $element = array( @@ -2185,18 +2185,20 @@ function content_default_value(&$form, &$form_state, $field, $delta) { * The field on which the operation is to be performed. * @param $account * (optional) The account to check, if not given use currently logged in user. + * @param $node + * (optional) The node on which the operation is to be performed. * @return * TRUE if the operation is allowed; * FALSE if the operation is denied. */ -function content_access($op, $field, $account = NULL) { +function content_access($op, $field, $account = NULL, $node = NULL) { global $user; if (is_null($account)) { $account = $user; } - $access = module_invoke_all('field_access', $op, $field, $account); + $access = module_invoke_all('field_access', $op, $field, $account, $node); foreach ($access as $value) { if ($value === FALSE) { return FALSE; diff --git a/includes/content.node_form.inc b/includes/content.node_form.inc index c60e54d04985c59eb0e5dac58e7b02b885e0b863..ad2799232d85b1eab751feed7ae04ebee182aa22 100644 --- a/includes/content.node_form.inc +++ b/includes/content.node_form.inc @@ -77,7 +77,7 @@ function content_field_form(&$form, &$form_state, $field, $get_delta = NULL) { // See if access to this form element is restricted, // if so, skip widget processing and just set the value. - $access = content_access('edit', $field); + $access = content_access('edit', $field, NULL, $node); if (!$access) { $addition[$field_name] = array( '#access' => $access, diff --git a/includes/panels/content_types/content_field.inc b/includes/panels/content_types/content_field.inc index 8ec90a8d8d69df77b9e8a6d85ec9a671665cf73e..a3a264410287b3ae24638d4e2ba0ec6a2c713eac 100644 --- a/includes/panels/content_types/content_field.inc +++ b/includes/panels/content_types/content_field.inc @@ -80,7 +80,7 @@ function content_content_field_content_type_render($subtype, $conf, $panel_args, $formatter = $conf['formatter']; // Check view access to the field. - if (!content_access('view', $field)) { + if (!content_access('view', $field, NULL, $node)) { return; } diff --git a/modules/content_permissions/content_permissions.module b/modules/content_permissions/content_permissions.module index 355d9981b33c7e6a26302ee6f29075d3bad2561c..7c81d5d53a28e0f60d1fac00537d8fd5783baede 100644 --- a/modules/content_permissions/content_permissions.module +++ b/modules/content_permissions/content_permissions.module @@ -18,7 +18,7 @@ function content_permissions_perm() { * * @see content_access(). */ -function content_permissions_field_access($op, $field, $account) { +function content_permissions_field_access($op, $field, $account, $node = NULL) { switch ($op) { case 'view': case 'edit':