This permission is just weird and confusing. It has nothing to do with administering images. It only allows access to the image gallery admin pages at 'admin/content/image/...'

'administer image galleries' would be much clearer to site admins.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Why didn't you use the original issue? (#409770: how to create new gallery )

I thought that users would just need to be able to add (or edit/manage) taxonomy terms to create new galleries?

joachim’s picture

Well the original issue's initial post wasn't really explaining the problem. I thought best to start fresh.

Yes, if you can administer taxonomy, then you can change galleries via the regular taxonomy admin.
But image_gallery adds an admin section just for galleries, which is essentially a duplication of the taxonomy admin.
This allows some labelling changes ('galleries' instead of 'terms') and delegation of gallery management to users without site-wide taxo admin access.

pebosi’s picture

Status: Active » Needs review
FileSize
1.86 KB

renamed the permission and created a patch.

regards

joachim’s picture

Status: Needs review » Needs work

Looks good so far, but I think we need to provide an update function to change that permission for existing sites.

pebosi’s picture

Status: Needs work » Needs review
FileSize
724 bytes

added install patch.

regards

joachim’s picture

Regarding the update function: Drupal core does the string replacing in PHP rather than SQL.
I've no idea if there's a reason for this, but my gut feeling is that we should do what core does -- it's probably due to cross-db compatibility.

Eg, in system.install:

function system_update_6039() {
  $ret = array();
  $result = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
  while ($role = db_fetch_object($result)) {
    $renamed_permission = preg_replace('/(?<=^|,\ )edit\ ([a-zA-Z0-9_\-]+)\ content(?=,|$)/', 'edit any $1 content', $role->perm);
    $renamed_permission = preg_replace('/(?<=^|,\ )create\ polls(?=,|$)/', 'create poll content', $renamed_permission);
    if ($renamed_permission != $role->perm) {
      $ret[] = update_sql("UPDATE {permission} SET perm = '$renamed_permission' WHERE rid = $role->rid");
    }
  }
  return $ret;
}

Attaching a combined patch, with the update function changed.
I've tested the updating on a fresh D6.

pebosi’s picture

Your modified patch works for me, too.

sun’s picture

Status: Needs review » Needs work

Invoking the PCRE engine seems needless. A simple str_replace() or strtr() (latter preferred) is sufficient in the update function.

pebosi’s picture

Status: Needs work » Needs review
FileSize
2.9 KB

update joachim's patch to use strtr

regards

pebosi’s picture

Updated to use array syntax for strtr.

sun’s picture

Status: Needs review » Needs work

Same as in the other issue for image.module applies here - quickly looking at image_gallery.test uncovers further instances of the permissions. Please ensure all permissions are updated accordingly.

pebosi’s picture

Updated the core-style permission patch, which includes the change of gallery permission in test files: http://drupal.org/node/44057#comment-1730082

joachim’s picture

Maybe I'm reading it wrong, but it doesn't look like http://uk3.php.net/strtr is the right thing to use...

EDIT: yeah I'm reading it wrong. Carry on :D

sun’s picture

See also this well-known function: http://api.drupal.org/api/function/t/6 ;)

pebosi’s picture

Status: Needs work » Needs review

Patch #10 still need's review. For changes in test files read #12.

regards

salvis’s picture

@sun, @joachim: I just saw your discussion on IRC...

it's never going to work as even if we block galleries you can still go to the regular taxo so it's kinda pointless

You could easily form_alter the image gallery's taxa administration pages to return a 403. However, IMO, 'administer taxonomy' as the more general permission should outweigh 'administer image galleries', so don't do that. I'd say 'administer image galleries' should allow using the image gallery administration pages even if the user does NOT have 'administer taxonomy', so that we can have "gallery administrators," without giving them full access to all vocabularies.

As for

...and the individual nodes will still be accessible

Image Gallery Access takes care of that nicely.

joachim’s picture

@salvis: we were talking about a different issue -- #113629: 'Image galleries' menu item appears without access -- which more or less requests a permission to access /image/tid/$tid. It's this that you can still access at /taxonomy/term/$tid, albeit not formatted the same way.

Though -- interesting module.
I'll point the poster of that other issue to it.
Would you care to add a note about your module to the docs page here: http://drupal.org/handbook/modules/image ?

joachim’s picture

Status: Needs review » Fixed

Tested patch on an installation that had the old permission set. Permission was correctly changed for role that had it assigned. No sign of the old perm string in the module code.
All looks good, committing.

#409974 by pebosi: Changed gallery permission from 'administer images' to 'administer image galleries'.

Thank you pebosi for your hard work on this and other patches :D
Sorry it's taken a while to get it committed.

Status: Fixed » Closed (fixed)

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