Example #1
0
        //public static object GetGridValue(PermissionState state)
        //{
        //    if (state == PermissionState.FULL_CONTROL)
        //        return FULL_ACCESS_ICON;
        //    else if (state == PermissionState.NO_ACCESS)
        //        return NO_ACCESS_ICON;
        //    else if (state == PermissionState.READ_ONLY)
        //        return READ_ICON;
        //    else if (state == PermissionState.READ_WRITE)
        //        return READ_WRITE_ICON;
        //    else
        //        throw new Exception("Unknown permission state");
        //}

        public static void SetUserPermissions(_UserInfo user, List <long> permissions)
        {
            if (permissions == null)
            {
                return;
            }

            foreach (long permission in permissions)
            {
                if (permission == 6) // file read
                {
                    user._Permissions[0] = true;
                }
                else if (permission == 8) // file check out
                {
                    user._Permissions[1] = true;
                }
                else if (permission == 5) // file delete conditional
                {
                    user._Permissions[2] = true;
                }
                else if (permission == 81) // admin user write
                {
                    user._IsAdmin = true;
                }
            }
        }
Example #2
0
        public static PermissionState DecodePermissions(int[] permissions, _UserInfo user)
        {
            // a value of 1 means that access has been granted.
            // a value of 0 (not set) or 2 (denied) results i no access.

            // we assume no read also means no write or delete
            if (permissions[0] != 1 || !user._Permissions[0])
            {
                if (user._IsAdmin)
                {
                    return(PermissionState.READ_ONLY);   // administrators can always read.
                }
                else
                {
                    return(PermissionState.NO_ACCESS);
                }
            }

            // read is granted but not write.  Assume delete is also not granted
            if (permissions[1] != 1 || !user._Permissions[1])
            {
                return(PermissionState.READ_ONLY);
            }

            // read and write granted, but not delete
            if (permissions[2] != 1 || !user._Permissions[2])
            {
                return(PermissionState.READ_WRITE);
            }

            // if we got this far, it means everything was granted
            return(PermissionState.FULL_CONTROL);
        }
Example #3
0
        public static _UserInfo[] Convert(UserInfo[] inputArray)
        {
            if (inputArray == null)
            {
                return(null);
            }

            _UserInfo[] retval = new _UserInfo[inputArray.Length];

            for (int i = 0; i < inputArray.Length; i++)
            {
                retval[i] = _UserInfo.Convert(inputArray[i]);
            }

            return(retval);
        }
Example #4
0
 public static PermissionState DecodePermissions(_UserInfo user)
 {
     return(DecodePermissions(new int[] { 1, 1, 1 }, user));
 }