跳转到主要内容
learningxm 提交于 3 September 2013

稍微升级了一下,目前支持7,但是里面的form相关的uc_field_access_form_alter的升级不成功,有感兴趣的可以继续研究一下。

 

功能:

可以控制product分类相关的字段的权限控制

 

 

 

<?php function uc_field_access_get_permissions() { $permissions=array( 'image', 'display_price', 'model', 'list_price', 'cost', 'sell_price', 'weight', 'dimensions', 'add_to_cart', 'grid_title', 'grid_model', 'grid_sell_price', 'grid_add_to_cart', 'grid_attributes' ); return $permissions; } function uc_field_access_get_classes() { $result = db_query("SELECT pcid, name FROM {uc_product_classes}"); foreach ($result as $class) { $classes[$class->pcid] = $class->name; }; $classes['product'] = 'Product'; return $classes; } function uc_field_access_permission() { $permissions=uc_field_access_get_permissions(); $classes=uc_field_access_get_classes(); //$perm=array(); foreach($classes as $cid => $class) { foreach($permissions as $permission) { $perm["view $cid $permission"] = array( 'title' => t('View '.$cid.' '. $permission), 'description' => t('Allow users to view '.$cid.' '. $permission.''), ); } } return($perm); } function uc_field_access_node_view($node,$view_mode, $langcode) { $list = uc_field_access_get_classes(); if(@$list[$node->type]) { if (!user_access('view '. $node->type .' image')) { $node->content["image"]['#access'] = FALSE; } if (!user_access('view '. $node->type .' display_price')) { $node->content["display_price"]['#access'] = FALSE; } if (!user_access('view '. $node->type .' model')) { $node->content["model"]['#access'] = FALSE; } if (!user_access('view '. $node->type .' list_price')) { $node->content["list_price"]['#access'] = FALSE; } if (!user_access('view '. $node->type .' cost')) { $node->content["cost"]['#access'] = FALSE; } if (!user_access('view '. $node->type .' sell_price')) { $node->content["sell_price"]['#access'] = FALSE; } if (!user_access('view '. $node->type .' weight')) { $node->content["weight"]['#access'] = FALSE; } if (!user_access('view '. $node->type .' dimensions')) { $node->content["dimensions"]['#access'] = FALSE; } } } ?>
Drupal 版本