Hi :)

I've done a quick search in the forum, but it seems that this "problem" has not been discussed yet.

When a user creates a node, it is possibile to edit it for him and for a group with appropriate permissions.

What I need is to create multiple authors for some nodes.
It should work in this way:
- user1 creates a node, for example page1
- user1 creates another author for page1, that is user2
- user2 now can edit page2 and page2 is listed in his content list (using view for example)

:) I hope I was clear with my explanation ^^

thank you by now

Comments

danielb’s picture

I have a solution for this, which required a combination of user permissions, CCK, and one function in a custom module.

- Firstly allow all your users permission to edit the node, whether they are a permitted author or not. What I mean by this is access control/permissions should not deny access to editing the content type.

- Create a CCK userreference field and allow multiple values (I prefer to use autocomplete widget btw)

- Create a custom module for your website to throw this function into.

The code I've posted below is for Drupal 5 so keep this in mind when developing for D6.

My userrerference field is 'field_allowed_authors', my content type is 'district'

<?php



/* implementation of hook_nodeapi */

function YOURMODULE_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
  // assumes the user already has access to edit the node (by user role permissions)
  // this will boot out the people who are not listed in the node under the userreference field allowed_authors.
  if ($node->type == 'district') {

    global $user;

    switch ($op) {
      case 'delete':
      case 'delete revision':
      case 'insert':
      case 'prepare':
      case 'update':
      case 'submit':
      case 'validate':

        //drupal_set_message("<pre>".print_r($node,true));
        if (!user_access('administer nodes')) {
          $is_allowed = FALSE;
          if ($user->uid == $node->uid) {
            $is_allowed = TRUE;
          }
          else {
            foreach ($node->field_allowed_authors as $author) {
              if ($user->uid == $author['uid']) {
                $is_allowed = TRUE;
                break;
              }
            }
          }
          if (!$is_allowed) {
            drupal_set_message(t('Sorry, you are not permitted to edit that district.'), 'error');
            if (referer_uri()) {
              drupal_goto(referer_uri());
            }
            else {
              drupal_access_denied();
            }
          }
          else {
            drupal_set_message("access granted");
          }
        }

        break;

    }
  }
}




?>
jrpowell01’s picture

is there a module for us people who dont understand all the drupal jargon?

francewhoa’s picture

Loving back your Drupal community result in multiple benefits for you  
WorldFallz’s picture

One other one I just heard about, but haven't had a chance to try: http://drupal.org/project/shared_edit. I like the way it looks-- dead simple and very lightweight.

jpdaley’s picture

Thanks danielb!
This is exactly what I needed. I little modification and this fit perfectly into my application.

THANKS A MILLION!