Ejemplo n.º 1
0
        public IDictionary <int, AppRolePair> GetUserRoles(int id)
        {
            IDictionary <int, AppRolePair> dict = new Dictionary <int, AppRolePair>();
            int appId;
            int flag;

            _userDal.ReadUserRoles(id, rd =>
            {
                while (rd.Read())
                {
                    appId = Convert.ToInt32(rd["app_id"]);
                    flag  = Convert.ToInt32(rd["flag"]);
                    if (dict.ContainsKey(appId))
                    {
                        dict[appId].Flags.Add(flag);
                    }
                    else
                    {
                        var p = new AppRolePair {
                            AppId = appId
                        };
                        p.Flags.Add(flag);
                        dict.Add(appId, p);
                    }
                }
            });
            return(dict);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 判断是否有权限修改文档
        /// </summary>
        /// <param name="p"></param>
        /// <param name="siteId"></param>
        /// <param name="publisherId"></param>
        /// <returns></returns>
        public static bool CanModifyArchive(int siteId, int publisherId)
        {
            UserDto user = UserState.Administrator.Current;

            if (user.Id == publisherId || user.IsMaster)
            {
                return(true);
            }
            AppRolePair pair = user.Roles.GetRole(siteId);

            return(pair != null && (pair.GetFlag() & Role.SiteOwner.Flag) != 0);
        }