Example #1
0
        public ActionResult _SetUserRoles(long userId, string returnUrl)
        {
            IEnumerable <Role> AllRoles  = roleService.GetRoles();
            IEnumerable <Role> UserRoles = roleService.GetRolesOfUser(userId);
            IEnumerable <Role> roles     = null;

            if (AllRoles != null && UserRoles != null)
            {
                IUser currentUser = UserContext.CurrentUser;
                IEnumerable <Role> rolesOfUsers = roleService.GetRolesOfUser(currentUser.UserId);

                long FounderId = systemDataService.GetLong("Founder");

                if (FounderId == currentUser.UserId)
                {
                    roles = AllRoles;
                }
                else if (authorizer.IsSuperAdministrator(currentUser))
                {
                    roles = AllRoles.Where(n => n.RoleName != "SuperAdministrator");
                }
                else
                {
                    roles = AllRoles.Where(n => n.RoleName != "SuperAdministrator" || n.RoleName != "ContentAdministrator");
                }
            }

            ViewData["UserRoles"] = UserRoles;
            ViewData["userId"]    = userId;
            ViewData["userName"]  = userService.GetUser(userId).UserName;
            ViewData["returnUrl"] = returnUrl;

            return(View(roles));
        }
Example #2
0
        /// <summary>
        /// 获取展示统计页面的连接
        /// </summary>
        /// <returns></returns>
        public string GetCNZZStatisticsPageLink()
        {
            SystemDataService service = new SystemDataService();
            long siteId   = service.GetLong("CNZZStatisticsSiteId");
            long password = service.GetLong("CNZZStatisticsPassword");

            SiteSettings siteSettings = siteSettingsManager.Get();

            if (siteId <= 0 || password <= 0)
            {
                return(string.Empty);
            }

            return(string.Format("http://wss.cnzz.com/user/companion/spacebuilder_login.php?site_id={0}&password={1}", siteId, password));
        }
Example #3
0
        /// <summary>
        /// 获取统计账户信息
        /// </summary>
        /// <returns></returns>
        public StatisticsAccount GetAccount()
        {
            SystemDataService systemDataService = new SystemDataService();
            StatisticsAccount account           = new StatisticsAccount();
            long siteId   = systemDataService.GetLong("CNZZStatisticsSiteId");
            long password = systemDataService.GetLong("CNZZStatisticsPassword");

            if (siteId <= 0 || password <= 0)
            {
                return(null);
            }

            account.UserName = siteId.ToString();
            account.Password = password.ToString();
            return(account);
        }
Example #4
0
        /// <summary>
        /// 保存统计帐号
        /// <param name="account">被保存的统计帐号</param>
        /// </summary>
        public void SaveStatisticsAccount(StatisticsAccount account)
        {
            if (account == null || string.IsNullOrEmpty(account.Password) || string.IsNullOrEmpty(account.UserName))
            {
                return;
            }

            SystemDataService systemDataService = new SystemDataService();
            long siteId   = systemDataService.GetLong("CNZZStatisticsSiteId");
            long password = systemDataService.GetLong("CNZZStatisticsPassword");

            long accountSiteId = 0;

            if (!long.TryParse(account.UserName, out accountSiteId))
            {
                return;
            }

            long accountPassword = 0;

            if (!long.TryParse(account.Password, out accountPassword))
            {
                return;
            }

            if (accountSiteId != siteId)
            {
                systemDataService.Change("CNZZStatisticsSiteId", accountSiteId - siteId);
            }
            if (accountPassword != password)
            {
                systemDataService.Change("CNZZStatisticsPassword", accountPassword - password);
            }

            Enable = true;

            ISiteSettingsManager siteSettingsManager = DIContainer.Resolve <ISiteSettingsManager>();
            SiteSettings         siteSettings        = siteSettingsManager.Get();

            siteSettings.StatScript = GetStatisticsCode();

            siteSettingsManager.Save(siteSettings);
        }
Example #5
0
        /// <summary>
        /// 获取统计代码
        /// </summary>
        /// <returns></returns>
        public string GetStatisticsCode()
        {
            SystemDataService service = new SystemDataService();
            long siteId = service.GetLong("CNZZStatisticsSiteId");

            if (siteId > 0)
            {
                return(string.Format("<script src='http://pw.cnzz.com/c.php?id={0}&l=2' language='JavaScript' charset='gb2312'></script>", siteId));
            }

            return(string.Empty);
        }
Example #6
0
        /// <summary>
        /// 是否具有管理此用户的权限
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool User_Manage(long userId)
        {
            if (userId == 0)
            {
                return(false);
            }

            IUser user = userService.GetUser(userId);

            if (user == null)
            {
                return(false);
            }

            IUser currentUser = UserContext.CurrentUser;

            if (currentUser == null)
            {
                return(false);
            }

            //判断是否是站点创始人
            long FounderId = systemDataService.GetLong("Founder");

            if (FounderId == currentUser.UserId && FounderId != 0)
            {
                return(true);
            }

            //判断超级管理员是否有权限
            if (AuthorizationService.IsSuperAdministrator(currentUser) && FounderId != userId && !AuthorizationService.IsSuperAdministrator(user))
            {
                return(true);
            }

            //判断内容管理员是否有权限
            if (IsContentAdministrator(currentUser) && FounderId != userId && !AuthorizationService.IsSuperAdministrator(user) && !IsContentAdministrator(user))
            {
                return(true);
            }

            return(false);
        }