summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Ferran (aka Markus)2009-07-18 00:46:09 (GMT)
committer Marc Ferran (aka Markus)2009-07-18 00:46:09 (GMT)
commitc7d4ceead141717f2d376fca387b69342bd2dbd4 (patch)
treea1a1c431b5ffd5bd6e548d23258a653b5f7e0b61
parent9bbec50713007f335a2acef9075888741ee0aabd (diff)
- #514452 Add new argument $node to content_access() to enhance the context for hook_field_access().
-rw-r--r--CHANGELOG.txt1
-rw-r--r--content.module10
-rw-r--r--includes/content.node_form.inc2
-rw-r--r--includes/panels/content_types/content_field.inc2
-rw-r--r--modules/content_permissions/content_permissions.module2
5 files changed, 10 insertions, 7 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 350244b..c688154 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 7ae3adc..5533355 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 c60e54d..ad27992 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 8ec90a8..a3a2644 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 355d998..7c81d5d 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':