Hello. Lovely little module - I like. Because I had different roles administering the products and fulfilling them, I needed a more detailed permissions access to the administering of fees. It was easy to edit the module in this respect, and if anyone else wants to do this, I attach the instructions below. Whether or not the lack of permission control is desirable or not is a worthy point of discussion.
First, add this into uc_fee.module:
/*
* Permissions hook
*/
function uc_fee_perm() {
return array('administer fees');
}
Which defines a new permission (remember to check them against relevant roles in 'admin/user/permissions')
Then, you need to edit the function uc_fee_menu() to check the user's permission for the administration pages. You need to make sure that the relevant 'access arguments' point to the permission we just defined. Below is the entire function that you can use to replace the existing function in uc_fee.module
/**
* Implementation of hook_menu().
*/
function uc_fee_menu() {
$items['admin/store/fees'] = array(
'title' => 'Fees',
'description' => 'Create and edit fees.',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_fee_admin_form'),
'access arguments' => array('administer fees'),
'type' => MENU_NORMAL_ITEM,
'weight' => -1,
'file' => 'uc_fee.admin.inc',
);
$items['admin/store/fees/overview'] = array(
'title' => 'Overview',
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => 0,
);
$items['admin/store/fees/add'] = array(
'title' => 'Add a fee',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_fee_form'),
'access arguments' => array('administer fees'),
'type' => MENU_LOCAL_TASK,
'weight' => 5,
'file' => 'uc_fee.admin.inc',
);
$items['admin/store/fees/%uc_fee/edit'] = array(
'title' => 'Edit fee',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_fee_form', 3),
'access arguments' => array('administer fees'),
'type' => MENU_CALLBACK,
'file' => 'uc_fee.admin.inc',
);
$items['admin/store/fees/%uc_fee/delete'] = array(
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_fee_delete_confirm', 3),
'access arguments' => array('administer fees'),
'type' => MENU_CALLBACK,
'file' => 'uc_fee.admin.inc',
);
// Menu items for default product class fees.
$items['admin/store/products/classes/%uc_product_class/fees'] = array(
'title' => 'Fees',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_object_fees_form', 4, 'class'),
'access arguments' => array('administer product classes'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'file' => 'uc_fee.admin.inc',
);
// Insert subitems into the edit node page for product types.
$items['node/%node/edit/fees'] = array(
'title' => 'Fees',
'page callback' => 'drupal_get_form',
'page arguments' => array('uc_object_fees_form', 1, 'product', 'overview'),
'access callback' => 'uc_fee_product_fee_access',
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
'file' => 'uc_fee.admin.inc',
);
$items['fee/calculate'] = array(
'page callback' => 'uc_fee_javascript',
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
That's it!
Sorry, I don't know how to do patches...