I'm using the new 6.x version of node images and the new feature to add directly upload images while adding the node it's a killer feature for this module!

The actual permissions are:

add node images to any XXX content
add node images to own XXX content
administer node images
delete any node image
delete own node images
edit any node image
edit own node images

I think that could be interesting to add more granular permission and separate "add images in the node creation" and "add images in the node images tab".

Why????

There are several cases of use, especially when you are working with workflows. For example, if you have users than can create nodes but not publish, and administrators that have to revise and publish the nodes could be interesting the both permissions. The users only would have the permission to "add images in the node creation", they could add images when create a node and all the images will be revised by administrators, but when the node was revised and published the users could not add new images without the administrators validation because they don't have the "add images in the node images tab" permission.

This is just an idea that could make this module more powerful with other modules like workflow, rules...

Comments

oriol_e9g’s picture

Title: More permissions » More granular permissions

To new permission would be something like this:

/**
 * Implementation of hook_perm().
 */
function node_images_perm() {
  $perms = array('administer node images', 'edit own node images', 'edit any node image', 'delete own node images', 'delete any node image');

  foreach (node_get_types() as $type) {
    $name = strtolower(check_plain($type->type));
    $perms[] = 'add node images to own '. $name .' content';
    $perms[] = 'add node images to any '. $name .' content';
    $perms[] = 'add node images to new '. $name .' content';
  }

  return $perms;
}

and... for example...

/**
 * Check access to add, edit or delete node images.
 */
function _node_images_access($op, $node, $file = NULL) {
  global $user;

  $type = node_get_types('type', $node);
  if (!isset($type->type)) return FALSE;

  $type = strtolower($type->type);
  if ($op == 'create') {
    return ((user_access('add node images to any '. $type .' content') && isset($node->nid))|| (user_access('add node images to own '. $type .' content') && ($user->uid == $node->uid) && isset($node->nid)) || (user_access('add node images to new '. $type .' content') && !isset($node->nid))
  );
  }
  if ($op == 'update') {
    return (user_access('edit any node_image') || (user_access('edit own node images') && ($user->uid == $file->uid)));
  }
  if ($op == 'delete') {
    return (user_access('delete any node_image') || (user_access('delete own node images') && ($user->uid == $file->uid)));
  }

  return FALSE;
}
oriol_e9g’s picture

Tested and works.

add node images to own XXX content --> add node images to own created content
add node images to any XXX content --> add node images to any created content
add node images to new XXX content --> add node images to new content

masterminder’s picture

I used the new permission by "oriol_e9g" but still only admin can upload images to created node. Where should be problem?