• <bdo id='66Eme'></bdo><ul id='66Eme'></ul>
      <i id='66Eme'><tr id='66Eme'><dt id='66Eme'><q id='66Eme'><span id='66Eme'><b id='66Eme'><form id='66Eme'><ins id='66Eme'></ins><ul id='66Eme'></ul><sub id='66Eme'></sub></form><legend id='66Eme'></legend><bdo id='66Eme'><pre id='66Eme'><center id='66Eme'></center></pre></bdo></b><th id='66Eme'></th></span></q></dt></tr></i><div id='66Eme'><tfoot id='66Eme'></tfoot><dl id='66Eme'><fieldset id='66Eme'></fieldset></dl></div>
      <legend id='66Eme'><style id='66Eme'><dir id='66Eme'><q id='66Eme'></q></dir></style></legend>

    1. <tfoot id='66Eme'></tfoot>
    2. <small id='66Eme'></small><noframes id='66Eme'>

        实施基于声誉的权限

        时间:2023-10-12

          <small id='RxteD'></small><noframes id='RxteD'>

            • <i id='RxteD'><tr id='RxteD'><dt id='RxteD'><q id='RxteD'><span id='RxteD'><b id='RxteD'><form id='RxteD'><ins id='RxteD'></ins><ul id='RxteD'></ul><sub id='RxteD'></sub></form><legend id='RxteD'></legend><bdo id='RxteD'><pre id='RxteD'><center id='RxteD'></center></pre></bdo></b><th id='RxteD'></th></span></q></dt></tr></i><div id='RxteD'><tfoot id='RxteD'></tfoot><dl id='RxteD'><fieldset id='RxteD'></fieldset></dl></div>

                <tbody id='RxteD'></tbody>
            • <tfoot id='RxteD'></tfoot>
                <bdo id='RxteD'></bdo><ul id='RxteD'></ul>
                  <legend id='RxteD'><style id='RxteD'><dir id='RxteD'><q id='RxteD'></q></dir></style></legend>
                  本文介绍了实施基于声誉的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在创建一个网站,其中有每个用户或用户组的项目、用户和权限.这是一个社区协作工具,我有 4 个不同的权限:

                  I'm creating a website in which there are projects, users, and permissions for each user or groups of users. What this is is a community collaboration tool, and I have 4 different permissions:

                  • 创建者 - 进行更改、接受更改、更改权限
                  • 接受更改
                  • 进行更改
                  • 查看

                  如何在数据库中为用户组实现这种权限系统?

                  How could I implement, in a database, this kind of permission system, for groups of users?

                  组/权限由声誉定义,就像在 StackOverflow 上一样.

                  Groups/permissions are defined by reputation, like on StackOverflow.

                  编辑2 - 更详细:每个文件都需要有权限,项目需要新创建的文件的默认权限,我还需要设置MySQL数据库权限.

                  Edit 2 - more in detail: Each file needs to have a permission, projects need default permissions for newly created files, and I also need to set up MySQL database permissions.

                  推荐答案

                  user_table
                  id, etc
                  
                  permission table
                  id, user_id, permission_type
                  

                  通过这种结构,每个用户都可以拥有多种与其帐户相关联的权限类型,他们可以访问的每组功能都对应一种权限类型.您永远不需要为了添加新类型的权限而更改表结构.

                  with this structure, each user could have several permission types associated with their account, one for each set of features they could have access to. you would never need to change the table structure in order to add new types of permissions.

                  更进一步,您可以将每种类型的权限设为二进制数.通过这种方式,您可以使用按位运算符将一组权限用一个整数表示.

                  to take this a step further, you could make each type of permission a binary number. this way you could make a set of permissions be represented by one integer by using bitwise operators.

                  例如如果你有常量

                  PERMISSION_CHANGE_PERMISSIONS = bindec('001') = 1
                  PERMISSION_MAKE_CHANGES = bindec('010') = 2
                  PERMISSION_ACCEPT_CHANGES = bindec('100') = 4
                  

                  您可以使用按位运算符|"将这些值组合成一个整数

                  you could combine these values into one integer using a bitwise operator "|"

                  (PERMISSION_CHANGE_PERMISSIONS | PERMISSION_MAKE_CHANGES) = bindec('011') = 3 = $users_combined_permissions
                  

                  然后检查他们是否有特定的权限,使用按位运算符&"

                  then to check if they have a specific permission, use the bitwise operator "&"

                  ($users_combined_permissions & PERMISSION_MAKE_CHANGES) = true
                  

                  如果你这样做了,你将只需要为每组权限创建一个数据库记录.

                  if you did that, you would only need one db record for each set of permissions.

                  这篇关于实施基于声誉的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何设计一个基于层次角色的访问控制系统 下一篇:PHP 和文件写入权限

                  相关文章

                  <i id='1ryr1'><tr id='1ryr1'><dt id='1ryr1'><q id='1ryr1'><span id='1ryr1'><b id='1ryr1'><form id='1ryr1'><ins id='1ryr1'></ins><ul id='1ryr1'></ul><sub id='1ryr1'></sub></form><legend id='1ryr1'></legend><bdo id='1ryr1'><pre id='1ryr1'><center id='1ryr1'></center></pre></bdo></b><th id='1ryr1'></th></span></q></dt></tr></i><div id='1ryr1'><tfoot id='1ryr1'></tfoot><dl id='1ryr1'><fieldset id='1ryr1'></fieldset></dl></div>

                    <bdo id='1ryr1'></bdo><ul id='1ryr1'></ul>
                  1. <tfoot id='1ryr1'></tfoot>
                  2. <legend id='1ryr1'><style id='1ryr1'><dir id='1ryr1'><q id='1ryr1'></q></dir></style></legend>
                  3. <small id='1ryr1'></small><noframes id='1ryr1'>