diff options
author | onefang | 2019-05-19 21:24:15 +1000 |
---|---|---|
committer | onefang | 2019-05-19 21:24:15 +1000 |
commit | 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch) | |
tree | a9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Framework/PermissionsUtil.cs | |
parent | Add a build script. (diff) | |
download | opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2 opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz |
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/PermissionsUtil.cs | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/OpenSim/Framework/PermissionsUtil.cs b/OpenSim/Framework/PermissionsUtil.cs index d785a78..e50d4df 100644 --- a/OpenSim/Framework/PermissionsUtil.cs +++ b/OpenSim/Framework/PermissionsUtil.cs | |||
@@ -60,28 +60,57 @@ namespace OpenSim.Framework | |||
60 | str += "C"; | 60 | str += "C"; |
61 | if ((perms & (int)PermissionMask.Transfer) != 0) | 61 | if ((perms & (int)PermissionMask.Transfer) != 0) |
62 | str += "T"; | 62 | str += "T"; |
63 | if ((perms & (int)PermissionMask.Export) != 0) | ||
64 | str += "X"; | ||
63 | if (str == "") | 65 | if (str == "") |
64 | str = "."; | 66 | str = "."; |
65 | return str; | 67 | return str; |
66 | } | 68 | } |
67 | 69 | ||
68 | /// <summary> | 70 | public static void ApplyFoldedPermissions(uint foldedSourcePerms, ref uint targetPerms) |
69 | /// Applies an object's folded permissions to its regular permissions. | 71 | { |
70 | /// </summary> | 72 | uint folded = foldedSourcePerms & (uint)PermissionMask.FoldedMask; |
71 | /// <param name="foldedPerms">The folded permissions. Only the lowest 7 bits are examined.</param> | 73 | if(folded == 0 || folded == (uint)PermissionMask.FoldedMask) // invalid we need to ignore, or nothing to do |
72 | /// <param name="mainPerms">The permissions variable to modify.</param> | 74 | return; |
73 | public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms) | 75 | |
76 | folded <<= (int)PermissionMask.FoldingShift; | ||
77 | folded |= ~(uint)PermissionMask.UnfoldedMask; | ||
78 | |||
79 | uint tmp = targetPerms; | ||
80 | tmp &= folded; | ||
81 | targetPerms = tmp; | ||
82 | } | ||
83 | |||
84 | // do not touch MOD | ||
85 | public static void ApplyNoModFoldedPermissions(uint foldedSourcePerms, ref uint target) | ||
74 | { | 86 | { |
75 | if ((foldedPerms & 7) == 0) | 87 | uint folded = foldedSourcePerms & (uint)PermissionMask.FoldedMask; |
76 | return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded | 88 | if(folded == 0 || folded == (uint)PermissionMask.FoldedMask) // invalid we need to ignore, or nothing to do |
89 | return; | ||
77 | 90 | ||
78 | if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0) | 91 | folded <<= (int)PermissionMask.FoldingShift; |
79 | mainPerms &= ~(uint)PermissionMask.Copy; | 92 | folded |= (~(uint)PermissionMask.UnfoldedMask | (uint)PermissionMask.Modify); |
80 | if ((foldedPerms & ((uint)PermissionMask.Transfer >> 13)) == 0) | 93 | |
81 | mainPerms &= ~(uint)PermissionMask.Transfer; | 94 | uint tmp = target; |
82 | if ((foldedPerms & ((uint)PermissionMask.Modify >> 13)) == 0) | 95 | tmp &= folded; |
83 | mainPerms &= ~(uint)PermissionMask.Modify; | 96 | target = tmp; |
84 | } | 97 | } |
85 | 98 | ||
99 | public static uint FixAndFoldPermissions(uint perms) | ||
100 | { | ||
101 | uint tmp = perms; | ||
102 | |||
103 | // C & T rule | ||
104 | if((tmp & (uint)(PermissionMask.Copy | PermissionMask.Transfer)) == 0) | ||
105 | tmp |= (uint)PermissionMask.Transfer; | ||
106 | |||
107 | // unlock | ||
108 | tmp |= (uint)PermissionMask.Move; | ||
109 | |||
110 | tmp &= ~(uint)PermissionMask.FoldedMask; | ||
111 | tmp |= ((tmp >> (int)PermissionMask.FoldingShift) & (uint)PermissionMask.FoldedMask); | ||
112 | |||
113 | return tmp; | ||
114 | } | ||
86 | } | 115 | } |
87 | } | 116 | } |