Zend ACL 是否适合所有者对内容的权限

发布于 2024-09-28 08:27:30 字数 110 浏览 3 评论 0原文

我认为 Zend ACL 用于向用户类型(学生、教师)授予权限。它可以用于根据内容授予权限吗?我的意思是这篇博文是由该用户撰写的,他们可以对其进行编辑。其他人无法编辑。 Zend ACL 可以满足此要求吗?

I think Zend ACL is used to give permissions to user types (student, teacher). Can it be used to give permissions on per content basis. What I mean is this blog post was written by this user and they can edit it. Others can't edit it. Can Zend ACL work with this requirement?

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

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

发布评论

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

评论(2

没有心的人 2024-10-05 08:27:30

是的,ZF 中的 Zend ACL 可用于确定所有者权限和设置,以允许内容所有者编辑自己的帖子等。我不确定这个地方是否有您想要的具体示例,但您可以查看一些 Zend ACL 教程zftutorials.com

更新

设置 ACL 可以在有很多不同的方式,具体取决于您的组等的设置方式。因此,很难提供明确的方法来执行此操作,但其要点是获得每个所有者可以执行的操作的权限设置。然后,在发生该操作的控制器中,您将看到类似以下内容:

if (!$this->_helper->acl->isAllowedOwn($author->user_id, 'content', 'edit')) {

这将告诉作者是否允许编辑他们自己的内容。这些规则需要以某种方式设置,要么通过配置文件,要么通过 xml 文件,zftutorials 可能会对此有所说明。

如果我有时间编写教程,我会在这里更新。但是,是的,与采埃孚一起编写教程是一个相当乏味的过程,因为每个人都有不同的处理项目和偏好的方式,更不用说设置它所需的所有内部工作了。

Yes the Zend ACL in ZF can be used to determine owner rights and setup to allow content owner to edit their own posts etc. I am not sure if this place has specific examples for what you want, but you can checkout some Zend ACL Tutorials from zftutorials.com

UPDATE

Setting up the ACL can be done in many different ways depending on how your groups etc are setup. Because of that it is hard to provide a clear cut way of how to do this, but the gist of it is to get the permissions setup on what each owner can do. Then in your Controller where that Action takes place you would have something like:

if (!$this->_helper->acl->isAllowedOwn($author->user_id, 'content', 'edit')) {

This would tell if that author is allowed to edit their own content. Those rules would need to be setup in some way, either via a config file or xml file, which the zftutorials place may shed some light on.

If I get time to work up a tutorial I will update it here. But yea, it is a pretty tedious process to work up a tutorial with ZF given that everyone has different ways of doing items and preferences, not to mention all the inner workings required to set it up.

困倦 2024-10-05 08:27:30

您可以为 Zend_Acl 创建自定义断言。这些自定义断言可以作为第四个参数传递给常规的allow()方法,例如

$acl->allow(null, null, null, new MyCustomAssertion());

断言可以包含您想要的任何代码。它必须返回一个布尔值,任何 ACL 检查都会考虑该值,例如,此用户 ID 是否允许使用该权限访问此资源,并且那个自定义检查

You can create custom assertions for Zend_Acl. These custom assertions can be passed to the regular allow() method as the fourth param, e.g.

$acl->allow(null, null, null, new MyCustomAssertion());

The assertion can contain any code you want. It has to return a Boolean which will be considered for any ACL checks then, e.g. is this userid allowed access to this resource with that privilege and that custom check?

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