I would like the ability to give users permission to only clone their own content, rather than all content.

Comments

pwolanin’s picture

easy enough - can you the patch?

jredding’s picture

Assigned: Unassigned » jredding
Status: Active » Needs review
StatusFileSize
new1.18 KB

Not highly tested (read not tested at all) but this does the trick.

If the user has the "Clone node" permission they can clone everything
If the user has the "Clone own nodes" permission they can only clone their nodes. Obviously you wouldn't want to give both permissions together so its possible there is a better way to word/code this.

shawnpetriw’s picture

Cool - I'll give it a shot.

shawnpetriw’s picture

This works great - just as expected. I think it would be good to add to the next release.

I'll let you know if there are any issues on my site.

pwolanin’s picture

for consistency maybe "clone own node"?

jredding’s picture

hhmm...
"clone own content" is more consistent with Drupal..
"clone own node" is consistent with this module.

You make the decision and I'll roll a new patch.

shawnpetriw’s picture

I say stay with the Drupalise version - "clone content."

Also given the issue with CCK image fields and other file attachments (http://drupal.org/node/249049, http://drupal.org/node/200092), I am REALLY glad you offered this granular permission - it keeps from somebody messing up the pictures in someone else's content by cloning and deleting.

pwolanin’s picture

hmm, maybe I should bite the bullet and change the permission name in 6.x?

jredding’s picture

I say change it in 6.

New permission would be
"Clone content"
"Clone own content"

in 5.x leave it as
"clone node"
"clone own nodes"

but we can change it to "clone own node" if you want. I'll roll whatever patch you want just tell me your decision ;)

pwolanin’s picture

@jredding - the fun part is updating the permissions from 5.x to 6.x...

here's how I did it for book module:

    // Fix role permissions to account for the changed names
    // Setup the array holding strings to match and the corresponding
    // strings to replace them with.
    $replace = array(
      'outline posts in books' => 'administer book outlines',
      'create book pages' => 'create book content',
      'edit book pages' => 'edit any book content',
      'edit own book pages' => 'edit own book content',
      'see printer-friendly version' => 'access printer-friendly version',
    );

    // Loop over all the roles, and do the necessary transformations.
    $query = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
    while ($role = db_fetch_object($query)) {
      // Replace all the old permissions with the corresponding new permissions.
      $fixed_perm = strtr($role->perm, $replace);
      // If the user could previously create book pages, they should get the new
      // 'add content to books' permission.
      if (strpos($role->perm, 'create book pages') !== FALSE) {
        $fixed_perm .= ', add content to books';
      }
      // Only save if the permissions have changed.
      if ($fixed_perm != $role->perm) {
        $ret[] = update_sql("UPDATE {permission} SET perm = '$fixed_perm' WHERE rid = $role->rid");
      }
    }

http://api.drupal.org/api/function/book_update_6000/6

pwolanin’s picture

StatusFileSize
new1.29 KB

patch does not apply - here's a new one for 5.x-2.x

pwolanin’s picture

Assigned: jredding » pwolanin
StatusFileSize
new2.04 KB

for the 5x-1x

pwolanin’s picture

Version: 5.x-2.0 » 6.x-1.0-beta1
Status: Needs review » Active
StatusFileSize
new2.12 KB

committed this patch and the previous for the 5.x versions

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new1.85 KB

basic patch for 6.x - please test. Doesn't do permission re-naming, if that's desired.

pwolanin’s picture

Status: Needs review » Fixed

quick test looks ok - committing to HEAD - let me know if anything explodes.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

  • Commit 2dab7c4 on 6.x-1.x, 7.x-1.x, master, 8.x-1.x by pwolanin:
    #231997 add permission 'clone own nodes'