Download & Extend

Editing fields without update access (D6)

Project:editablefields
Version:6.x-2.0
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

I have a very simple need to provide access to a group of users to edit some CCK fields, but I don't want to provide them full node edit access. We also have a lot of CCK fields and I am hesitant to work with CCK field permissions for such a simple use case.

Having reviewed the code, my thought was that if there were a permission such as "access all editable fields" that I could assign to my group of users and if this permission were checked, that it would probably do the trick.

There would be 4 changes needed in the code....

Change 1. Add an implementation of hook_perm to add the permission...

/**
* Implementation of hook_perm().
*/
function editablefields_perm() {
  $perms[] = 'access all editable fields'; 
  return $perms; 
}

Changes 2, 3 and 4 are to IF statements to include a check for the new permission

Change 2: affects function theme_editablefields_formatter_editable($element):

  // CHANGE THIS IF STATEMENT
  if (!node_access('update', $node) || !content_access('edit', $field)) {

  // TO THIS IF STATEMENT
  if ((!node_access('update', $node) && !user_access('access all editable fields')) || (!content_access('edit', $field) && !user_access('access all editable fields'))) {

Change 3: affects function editablefields_html():

  // CHANGE THIS IF STATEMENT
  if (node_access('update', $node)) {

  // TO THIS IF STATEMENT
  if (node_access('update', $node) || user_access('access all editable fields')) {

Change 4: affects function editablefields_submit():

  // CHANGE THIS IF STATEMENT
  if (node_access('update', $node)) {

  // TO THIS IF STATEMENT
  if (node_access('update', $node) || user_access('access all editable fields')) {

If you have any thoughts on this, they would be greatly appreciated.

Comments

#1

Subscribe.

Usefull with ubercart products. Product have CCK fileds but not "edit own product content" pemrission option.
So with ubercart marketplace, editablefields does not allow to sellers to edit products cck fields.

My workaround is just to remove test on update line 84:

if (!node_access('update', $node) || !content_access('edit', $field)) {

Content acces edit seems to be suficient for my case (view allow only sellers to access).

#3

Title:Editing fields without update access» Editing fields without update access (D6)

Created #1344634: Editing fields without update access (D7) for D7.