function uc_product_update_7001 in Ubercart 7.3
Use actual node permissions for product types.
File
- uc_product/
uc_product.install, line 301 - Install, update and uninstall functions for the uc_product module.
Code
function uc_product_update_7001() {
$types = db_query("SELECT pcid FROM {uc_product_classes}")
->fetchCol();
array_unshift($types, 'product');
foreach ($types as $type) {
$node_perms = array_keys(node_list_permissions($type));
foreach ($node_perms as $node_perm) {
$product_perm = str_replace(array(
'any',
'content',
), array(
'all',
'products',
), $node_perm);
foreach (user_roles(FALSE, $product_perm) as $rid => $role) {
db_merge('role_permission')
->key(array(
'rid' => $rid,
'permission' => $node_perm,
))
->fields(array(
'module' => 'node',
))
->execute();
}
// Clean up.
db_delete('role_permission')
->condition('permission', $product_perm)
->execute();
}
}
return t('Changed product node permissions to the actual node permissions.');
}