Pro Zend Framework Techniques Build a Full CMS Project phần 8

Tiếp theo nó chạy deleteItem (). Sau đó, nó thiết lập các tham số đơn và chuyển tiếp indexAction (). Ví dụ 7-46 cho thấy phương pháp hoàn giờ các thành phần quản lý menu là hoàn tất, bạn đã sẵn sàng để làm cho các menu. Để làm điều này, tạo ra một hành động mới trong renderAction tên là MenuController (). Bạn có thể làm | CHAPTER 8 HANDLING SECURITY IN A ZEND FRAMEWORK PROJECT 164 Figure 8-3. The updated home page with login logout links Controlling Access with Zend_Acl Zend_Acl provides a simple and straightforward implementation of access control lists ACLs . ACL consists of two lists One list of resources pages in your application One list of roles access roles such as administrator Download at CHAPTER 8 HANDLING SECURITY IN A ZEND FRAMEWORK PROJECT Zend_Acl manages these lists as well as the relationships between the two. It then provides a method isAllowed which you use to query the lists. Using Zend_Acl The first thing you need to do to use Zend_Acl is set up the roles. These roles represent the users in your application. You add these roles with the addRole method which you pass a new instance of Zend_Acl_Role. These roles also support inheritance so you more easily manage your user hierarchy. For example you may have authors and publishers in a model. Say the authors have access to manage content but not publish it. Then the publishers are authors themselves but they also have the authority to publish content to the site. In this example the publishers would extend the authors. Next you set up the resources which represent the modules controllers and actions in your application. You add resources to Zend_Acl using the add method to which you pass a new instance of Zend_Acl_Resource. Now that you have the roles and resources set you can define the ACL rules-in other words who can access which resources. You do this with the allow and deny methods. Once these rules are set up your instance of ACL is ready to query as shown in the simplistic example in Listing 8-37. Listing 8-37. Sample Zend_Acl Usage acl new Zend_Acl create the user role acl- addRole new Zend_Acl_Role user create the admin role which inherits all of the user s permissions acl- addRole new Zend_Acl_Role admin user add a new resource acl- add new Zend_Acl_Resource cms set access rules acl- allow .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.