示例#1
0
        public ActionResult _EditAlbum(string spaceKey, long albumId = 0, string callBack = null)
        {
            IUser user  = userService.GetUser(spaceKey);
            Album album = null;

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

            if (albumId == 0)
            {
                if (!authorizer.Album_Create())
                {
                    return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                    {
                        Body = "没有创建相册的权限",
                        Title = "没有权限",
                        StatusMessageType = StatusMessageType.Hint
                    })));
                }
                album = Album.New();
                album.PrivacyStatus = PrivacyStatus.Public;
            }
            else
            {
                album = photoService.GetAlbum(albumId);
                if (album == null)
                {
                    return(HttpNotFound());
                }
                if (!authorizer.Album_Edit(album))
                {
                    return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                    {
                        Body = "没有编辑相册的权限",
                        Title = "没有权限",
                        StatusMessageType = StatusMessageType.Hint
                    })));
                }
                Dictionary <int, IEnumerable <ContentPrivacySpecifyObject> > privacySpecifyObjects = contentPrivacyService.GetPrivacySpecifyObjects(TenantTypeIds.Instance().Album(), album.AlbumId);
                if (privacySpecifyObjects.ContainsKey(SpecifyObjectTypeIds.Instance().User()))
                {
                    IEnumerable <ContentPrivacySpecifyObject> userPrivacySpecifyObjects = privacySpecifyObjects[SpecifyObjectTypeIds.Instance().User()];
                    ViewData["userPrivacySpecifyObjects"] = string.Join(",", userPrivacySpecifyObjects.Select(n => n.SpecifyObjectId));
                }
                if (privacySpecifyObjects.ContainsKey(SpecifyObjectTypeIds.Instance().UserGroup()))
                {
                    IEnumerable <ContentPrivacySpecifyObject> userGroupPrivacySpecifyObjects = privacySpecifyObjects[SpecifyObjectTypeIds.Instance().UserGroup()];
                    ViewData["userGroupPrivacySpecifyObjects"] = string.Join(",", userGroupPrivacySpecifyObjects.Select(n => n.SpecifyObjectId));
                }
            }

            AlbumEditModel albumEditModel = album.AsEditModel();

            return(View(albumEditModel));
        }
示例#2
0
        public ActionResult Edit(string spaceKey, long?threadId, long?ownerId)
        {
            BlogThreadEditModel model      = null;
            BlogThread          blogThread = null;

            //日志用户分类下拉列表
            IEnumerable <Category> ownerCategories = null;

            //写日志
            if (!threadId.HasValue)
            {
                string errorMessage = string.Empty;
                if (!authorizer.BlogThread_Create(spaceKey, out errorMessage))
                {
                    return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                    {
                        Title = "没有权限",
                        Body = errorMessage,
                        StatusMessageType = StatusMessageType.Error
                    })));
                }

                model = new BlogThreadEditModel()
                {
                    PrivacyStatus = PrivacyStatus.Public
                };
                if (ownerId.HasValue)
                {
                    model.OwnerId = ownerId;
                }

                //获取所有者分类
                if (ownerId.HasValue)
                {
                    ownerCategories = categoryService.GetOwnerCategories(ownerId.Value, TenantTypeIds.Instance().BlogThread());
                }
                else
                {
                    ownerCategories = categoryService.GetOwnerCategories(UserContext.CurrentUser.UserId, TenantTypeIds.Instance().BlogThread());
                }

                pageResourceManager.InsertTitlePart("写日志");
            }

            //编辑日志
            else
            {
                blogThread = blogService.Get(threadId.Value);
                if (blogThread == null)
                {
                    return(HttpNotFound());
                }

                if (!authorizer.BlogThread_Edit(blogThread))
                {
                    return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                    {
                        Title = "没有权限",
                        Body = "没有权限编辑" + blogThread.Subject + "!",
                        StatusMessageType = StatusMessageType.Error
                    })));
                }

                Dictionary <int, IEnumerable <ContentPrivacySpecifyObject> > privacySpecifyObjects = contentPrivacyService.GetPrivacySpecifyObjects(TenantTypeIds.Instance().BlogThread(), blogThread.ThreadId);
                if (privacySpecifyObjects.ContainsKey(SpecifyObjectTypeIds.Instance().User()))
                {
                    IEnumerable <ContentPrivacySpecifyObject> userPrivacySpecifyObjects = privacySpecifyObjects[SpecifyObjectTypeIds.Instance().User()];
                    ViewData["userPrivacySpecifyObjects"] = string.Join(",", userPrivacySpecifyObjects.Select(n => n.SpecifyObjectId));
                }
                if (privacySpecifyObjects.ContainsKey(SpecifyObjectTypeIds.Instance().UserGroup()))
                {
                    IEnumerable <ContentPrivacySpecifyObject> userGroupPrivacySpecifyObjects = privacySpecifyObjects[SpecifyObjectTypeIds.Instance().UserGroup()];
                    ViewData["userGroupPrivacySpecifyObjects"] = string.Join(",", userGroupPrivacySpecifyObjects.Select(n => n.SpecifyObjectId));
                }

                model = blogThread.AsEditModel();

                //获取所有者分类
                ownerCategories = categoryService.GetOwnerCategories(blogThread.OwnerId, TenantTypeIds.Instance().BlogThread());

                IEnumerable <Category>      selectedOwnerCategories = blogThread.OwnerCategories;
                Dictionary <long, Category> ownerCategoryDic        = new Dictionary <long, Category>();
                if (selectedOwnerCategories != null && selectedOwnerCategories.Count() > 0)
                {
                    ownerCategoryDic = selectedOwnerCategories.ToDictionary(n => n.CategoryId, n => n);
                }
                ViewData["ownerCategoryDic"] = ownerCategoryDic;

                pageResourceManager.InsertTitlePart("编辑日志");
            }

            ViewData["ownerCategories"] = ownerCategories;

            //日志站点分类下拉列表(投稿到)
            if (blogSettings.AllowSetSiteCategory)
            {
                IEnumerable <Category> siteCategories = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().BlogThread());
                ViewData["siteCategories"] = new SelectList(siteCategories, "CategoryId", "CategoryName", blogThread == null ? null : blogThread.SiteCategoryId);
            }

            return(View(model));
        }
示例#3
0
        /// <summary>
        /// 获取隐私的特别类型的
        /// </summary>
        /// <param name="PrivacySpecifyUsers">隐私的用户的id字符串</param>
        /// <param name="PrivacySpecifyUserGroup">隐私的分组的id字符串</param>
        /// <param name="tenantTypeId">类型id</param>
        /// <param name="contentId">对象id</param>
        /// <returns>隐私特别对象集合</returns>
        public static Dictionary <int, IEnumerable <ContentPrivacySpecifyObject> > GetContentPrivacySpecifyObjects(string PrivacySpecifyUsers, string PrivacySpecifyUserGroup, string tenantTypeId, long contentId)
        {
            IUserService    userService     = DIContainer.Resolve <IUserService>();
            CategoryService categoryService = new CategoryService();
            Dictionary <int, IEnumerable <ContentPrivacySpecifyObject> > privacySpecifyObjects = new Dictionary <int, IEnumerable <ContentPrivacySpecifyObject> >();

            if (!string.IsNullOrEmpty(PrivacySpecifyUsers))
            {
                string[]           userIds = PrivacySpecifyUsers.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
                IEnumerable <User> users   = userService.GetFullUsers(userIds.Select(n => long.Parse(n)));
                List <ContentPrivacySpecifyObject> contentPrivacySpecifyObjects = new List <ContentPrivacySpecifyObject>();
                foreach (User user in users)
                {
                    ContentPrivacySpecifyObject contentPrivacySpecifyObject = ContentPrivacySpecifyObject.New();
                    contentPrivacySpecifyObject.TenantTypeId        = tenantTypeId;
                    contentPrivacySpecifyObject.ContentId           = contentId;
                    contentPrivacySpecifyObject.SpecifyObjectId     = user.UserId;
                    contentPrivacySpecifyObject.SpecifyObjectName   = user.DisplayName;
                    contentPrivacySpecifyObject.SpecifyObjectTypeId = SpecifyObjectTypeIds.Instance().User();

                    contentPrivacySpecifyObjects.Add(contentPrivacySpecifyObject);
                }

                privacySpecifyObjects[SpecifyObjectTypeIds.Instance().User()] = contentPrivacySpecifyObjects;
            }

            if (!string.IsNullOrEmpty(PrivacySpecifyUserGroup))
            {
                List <ContentPrivacySpecifyObject> contentPrivacySpecifyObjects = new List <ContentPrivacySpecifyObject>();
                if (PrivacySpecifyUserGroup.Contains("-1"))
                {
                    ContentPrivacySpecifyObject contentPrivacySpecifyObject = ContentPrivacySpecifyObject.New();
                    contentPrivacySpecifyObject.TenantTypeId        = tenantTypeId;
                    contentPrivacySpecifyObject.ContentId           = contentId;
                    contentPrivacySpecifyObject.SpecifyObjectId     = -1;
                    contentPrivacySpecifyObject.SpecifyObjectName   = "我关注的所有人";
                    contentPrivacySpecifyObject.SpecifyObjectTypeId = SpecifyObjectTypeIds.Instance().UserGroup();

                    contentPrivacySpecifyObjects.Add(contentPrivacySpecifyObject);
                }
                else
                {
                    string[] userGroupIds = PrivacySpecifyUserGroup.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);
                    foreach (string categoryId in userGroupIds)
                    {
                        ContentPrivacySpecifyObject contentPrivacySpecifyObject = ContentPrivacySpecifyObject.New();
                        contentPrivacySpecifyObject.TenantTypeId        = tenantTypeId;
                        contentPrivacySpecifyObject.ContentId           = contentId;
                        contentPrivacySpecifyObject.SpecifyObjectTypeId = SpecifyObjectTypeIds.Instance().UserGroup();

                        if (categoryId == "-2")
                        {
                            contentPrivacySpecifyObject.SpecifyObjectId   = -2;
                            contentPrivacySpecifyObject.SpecifyObjectName = "相互关注";

                            contentPrivacySpecifyObjects.Add(contentPrivacySpecifyObject);
                        }
                        else
                        {
                            Category category = categoryService.Get(long.Parse(categoryId));
                            contentPrivacySpecifyObject.SpecifyObjectId   = category.CategoryId;
                            contentPrivacySpecifyObject.SpecifyObjectName = category.CategoryName;

                            contentPrivacySpecifyObjects.Add(contentPrivacySpecifyObject);
                        }
                    }
                }

                privacySpecifyObjects[SpecifyObjectTypeIds.Instance().UserGroup()] = contentPrivacySpecifyObjects;
            }

            return(privacySpecifyObjects);
        }