tailieunhanh - Drupal 7 Module Development phần 8

Ngôn ngữ chức năng làm cho nhiệm vụ này dễ dàng bằng cách lấy một đối tượng người dùng và trở về sự lựa chọn ngôn ngữ của người kỳ thông tin tùy chỉnh cần thiết để xây dựng các e-mail nênchức năng gọi lại () qua các hình thức vàTrong trường hợp này, | Node Access Creating the role access module We begin with the standard module .info file and a stub .module file as shown below Id name Role Access description Limit content access by user role. core files Save this as inside a sites default modules role_access directory. Then create a stub file php Id @file Role access module file. Provides a simple content access scheme based on the author s role. Now we are ready to begin building our module. The code in the next sections will all add to this base file. Using hook_node_access_records Enforcing rules with a node access module takes two parts. The first is writing your module s rules to the node_access table. This action is performed with the hook_node_access_records function. This function is called every time a node is created or updated. It is your module s responsibility to respond appropriately to this hook. 1 When creating or updating nodes modules should never perform Tạ direct database queries to node_access . Doing so breaks the API because other modules can no longer rely on the expected behavior of the node access system. 266 Chapter 9 When hook_node_access_records fires it passes a single parameter the node object being acted upon. Our module must respond based on the information in the node object or be able to derive its rules from that information. This last statement may seem obvious but bears repeating. If your business rules rely on special information not found in the default node object it is your responsibility to add that data using hook_node_load . We will look at this in more detail later in this chapter. For Role Access we need to know the roles assigned to the user who authored the node. Implement hook_node_access_records . We want to store a row for each role assigned to the author of the content. function role_access_node_access_records node First get the user record. Note that we avoid using user here since that is the global .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG