Presently, Ubercart has a permission to administer product features. However, if this permission is granted, users can administer other user's product features. They could for example delete another user's product feature even though they don't have permission to access that node directly!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

syndicateStorm’s picture

We only need a few changes to allow users to only administer there own product features...

Change (1), add the permission:

/**
 * Implementation of hook_perm().
 */
function uc_product_perm() {
  // syndicateStorm ===
  //$perms = array('administer products', 'administer product classes', 'administer product features');
  $perms = array('administer products', 'administer product classes', 'administer product features', 'administer own product features');
  // End syndicateStorm ===
  ...

Change (2), define the specifics of the permission:

/**
 * Menu access callback for 'node/%node/edit/uc-features'.
 */
function uc_product_feature_access($node) {
  // syndicateStorm ===
  //return uc_product_is_product($node) && user_access('administer product features');
  global $user;
  return uc_product_is_product($node) && 
    ((user_access('administer product features') || (user_access('administer own product features') && ($user->uid == $node->uid))));
  // End syndicateStorm ===
}

The above code should fix the problem.

univate’s picture

Category: bug » feature
Status: Active » Needs review
FileSize
1.1 KB

This is not really a bug, as giving users access to administer product features does exactly what it say, gives them access to administer product features, so this is really a new feature.

I have attached this as a patch.

syndicateStorm’s picture

You're right. Thanks for the patch!

fizk’s picture

This should've been committed by now.

fizk’s picture

FileSize
1.1 KB

There's a typo in #2. "adminster" should be "administer".

longwave’s picture

Version: 6.x-2.x-dev » 7.x-3.x-dev
Status: Needs review » Patch (to be ported)

Committed. Needs porting to 7.x.

longwave’s picture

Status: Patch (to be ported) » Fixed

Committed.

Status: Fixed » Closed (fixed)

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