zend_acl:动态添加额外资源并获取参数预调度

发布于 2024-08-27 06:14:34 字数 303 浏览 8 评论 0原文

首先对华夫饼感到抱歉,因为我不知道如何最好地描述它。基本上我不确定如何在加载控制器之前在引导程序中获取参数,但这是冗长的版本...

我有一个 acl 类存储我所有的默认资源。我的所有页面/帖子内容都是数据库,我希望管理员能够选择页面可用的角色。

我知道可以循环遍历数据库表并将它们一次性添加到其中,但我担心这会消耗资源。我让它工作,我的访问检查插件可以调用动态权限函数,但我需要获取当前页面 ID 的参数以及在加载控制器之前设置它的权限。

这是有道理的还是我什么都不担心,我应该立即获取所有页面的资源?

预先感谢您阅读我的乱码!

First sorry about the woffle as I'm not sure how best to describe this. Basically I am not sure how I can get param in the bootstrap before the controller is loaded, but here is the long winded version...

I have got an acl class storing all my default resources in. All my page/post content is a database and I want the admin the ability to choose who which role the page would become available.

I know it is possible just to loop through the database table and add them all in at once, but I am concerned that this is a drain on resources. I have it working whereby my access check plugin can call a dynamic permission function, but I need to get the parameter of the current page ID and it's permission to set it before the controller is loaded.

Does that make sense or am I worry over nothing and I should just get the resources of all the pages at once?

thanks in advance for reading my garble!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

衣神在巴黎 2024-09-03 06:14:34

通过实际阅读 zend 手册,我实际上已经找到了我需要的东西!卫生部!

我只需要使用 $request->getParams() 这将允许我从 url 获取帖子 id

然后我可以使用以下方法设置权限

下面进入访问检查插件

$params =  $request->getParams();    
$this->_acl->setDynamicPermissions($params['post_id']);

然后在 Acl 类中

 public function setDynamicPermissions($id) {

    $id             = (int)$id;
    $page_id        =  "page-" . $id;

    $post           = new Model_DbTable_Post();
    $restriction    = $post->getPostRestriction($id);


    $this->add(new Zend_Acl_Resource($page_id));
    $this->allow($restriction, $page_id);

}

I've actually managed to find out what I need by actually reading the zend manual! DOH!

I simply needed to use to the $request->getParams() which would allow me to get post id from the url

Then I could set the permission with the following method

Below goes in the access check pluging

$params =  $request->getParams();    
$this->_acl->setDynamicPermissions($params['post_id']);

And then this in the Acl class

 public function setDynamicPermissions($id) {

    $id             = (int)$id;
    $page_id        =  "page-" . $id;

    $post           = new Model_DbTable_Post();
    $restriction    = $post->getPostRestriction($id);


    $this->add(new Zend_Acl_Resource($page_id));
    $this->allow($restriction, $page_id);

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文