2012-12-04 68 views
0
更精細的ACO

我的產品表:CakePHP的 - 在ACL

select * from products; 
+------+----------------+ 
| id | name   | 
+------+----------------+ 
| 1 | product XYZ | 
| 2 | product XPTO | 
| 3 | procudt ABC | 
| 4 | procudt QWERTY | 
| 5 | procudt 1234 | 
+------+----------------+ 

我可以允許/拒絕某些用戶組訪問模型「產品」,如:

$group->id = 3; 
$this->Acl->deny($group, 'controllers'); 
$this->Acl->allow($group, 'controllers/Products'); 

$group->id = 4; 
$this->Acl->deny($group, 'controllers'); 
$this->Acl->allow($group, 'controllers/Products/view'); 

但如何允許/拒絕某些組訪問某些特定產品,如:

$group->id = 5; 
$this->Acl->deny($group, 'controllers'); 
$this->Acl->allow($group, 'product XYZ'); 

$group->id = 6; 
$this->Acl->deny($group, 'controllers'); 
$this->Acl->allow($group, 'product XPTO'); 
$this->Acl->allow($group, 'product 1234'); 

回答

1

你想要行級訪問控制。在CakePHP中有幾種方法可以解決這個問題(有些使用Cake的ACL功能,有些使用ACL功能,有些則不使用),所以您應該使用look around並查看最適合您的情況。

但有一點需要記住的是,Cake中開箱即用的ACL功能旨在實現對控制器操作的訪問控制,而不是針對特定的數據庫行。根據您需要檢查的數據量,事情可能會很快失去控制。您可能需要重新考慮您的設計,以查看您是否真的需要在記錄級別檢查訪問權限。