Beispiel #1
0
        private void AppendChildsComments(ref List <CommentInfo> commentsInfo, IList <Comment> comments)
        {
            foreach (var comment in comments)
            {
                var info = new CommentInfo
                {
                    CommentID             = comment.Id.ToString(),
                    UserID                = new Guid(comment.UserID),
                    TimeStampStr          = comment.Timestamp.Ago(),
                    IsRead                = SecurityContext.DemoMode || comment.IsRead,
                    Inactive              = comment.Inactive,
                    CommentBody           = comment.Text,
                    UserFullName          = DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)),
                    UserAvatar            = ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)),
                    UserPost              = CoreContext.UserManager.GetUsers(new Guid(comment.UserID)).Title,
                    IsEditPermissions     = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment),
                    IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment)
                };

                // postParser.Parse(comment.Text);

                var tempComments = new List <CommentInfo>();

                AppendChildsComments(ref tempComments, comment.Comments);

                info.CommentList = tempComments;

                commentsInfo.Add(info);
            }
        }
Beispiel #2
0
 private static object PrepareUserInfo(UserInfo userInfo)
 {
     return(new
     {
         id = userInfo.ID,
         displayName = DisplayUserSettings.GetFullUserName(userInfo),
         title = userInfo.Title,
         avatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID),
         avatarBig = UserPhotoManager.GetBigPhotoURL(userInfo.ID),
         profileUrl = CommonLinkUtility.ToAbsolute(CommonLinkUtility.GetUserProfile(userInfo.ID.ToString(), false)),
         groups = CoreContext.UserManager.GetUserGroupsId(userInfo.ID),
         isPending = userInfo.ActivationStatus == EmployeeActivationStatus.Pending,
         isActivated = userInfo.ActivationStatus.HasFlag(EmployeeActivationStatus.Activated),
         isVisitor = userInfo.IsVisitor(),
         isOutsider = userInfo.IsOutsider(),
         isAdmin = userInfo.IsAdmin(),
         isOwner = userInfo.IsOwner(),
         contacts = GetContacts(userInfo),
         created = userInfo.CreateDate,
         email = userInfo.Email,
         isLDAP = userInfo.IsLDAP(),
         isSSO = userInfo.IsSSO(),
         isTerminated = userInfo.Status == EmployeeStatus.Terminated
     });
 }
Beispiel #3
0
        public static CommentInfo ConvertComment(Comment comment, IList <Comment> commentList)
        {
            var userID = comment.UserID;

            CommentInfo c = new CommentInfo();

            c.CommentID    = comment.ID.ToString();
            c.UserID       = userID;
            c.TimeStamp    = comment.Datetime;
            c.TimeStampStr = comment.Datetime.Ago();

            c.Inactive              = comment.Inactive;
            c.CommentBody           = comment.Content;
            c.UserFullName          = DisplayUserSettings.GetFullUserName(userID);
            c.UserAvatar            = BookmarkingServiceHelper.GetHTMLUserAvatar(userID);
            c.IsEditPermissions     = BookmarkingPermissionsCheck.PermissionCheckEditComment(comment);
            c.IsResponsePermissions = BookmarkingPermissionsCheck.PermissionCheckCreateComment();

            c.UserPost = BookmarkingServiceHelper.GetUserInfo(userID).Title;

            var commentsList = new List <CommentInfo>();

            var childComments = GetChildComments(comment, commentList);

            if (childComments != null)
            {
                foreach (var item in childComments)
                {
                    commentsList.Add(ConvertComment(item, commentList));
                }
            }
            c.CommentList = commentsList;
            return(c);
        }
Beispiel #4
0
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var info = new CommentInfo
            {
                CommentID    = comment.Id.ToString(),
                UserID       = new Guid(comment.UserID),
                TimeStamp    = comment.Timestamp,
                TimeStampStr = comment.Timestamp.Ago(),
                IsRead       = true,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Text,
                UserFullName = DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)),
                UserAvatar   = ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)),
                UserPost     = CoreContext.UserManager.GetUsers(new Guid(comment.UserID)).Title
            };

            if (!isPreview)
            {
                info.IsEditPermissions = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment);

                info.IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment);
            }

            var defComment = new CommentsList();

            ConfigureCommentsList(defComment, null);

            return(Web.Controls.CommentInfoHelper.CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, comment.ParentId <= 0, false));
        }
Beispiel #5
0
        private List <BlogInfo> GetBlogsStatistic(BlogsEngine engine, int filedID, bool sortDirection)
        {
            var sort = new CMPSort(filedID, sortDirection ? SortDirection.Ascending : SortDirection.Descending);

            this.sortedFiledID = filedID;
            this.direction     = sortDirection ? SortDirection.Ascending : SortDirection.Descending;

            var stat = engine.GetAuthorsStatistic();

            var listBlogs = new List <BlogInfo>(stat.Count);

            foreach (var blog in stat)
            {
                listBlogs.Add(new BlogInfo()
                {
                    ID            = blog.Value1,
                    BlogsCount    = blog.Value2,
                    CommentsCount = blog.Value3,
                    ReviewCount   = blog.Value4,

                    Name = DisplayUserSettings.GetFullUserName(blog.Value1)
                });
            }

            listBlogs.Sort(sort);

            return(listBlogs);
        }
 private static TagValue CreateSendFromTag()
 {
     return(new TagValue(CommonTags.SendFrom,
                         SecurityContext.IsAuthenticated && SecurityContext.CurrentAccount is IUserAccount ?
                         DisplayUserSettings.GetFullUserName(CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID), false).Replace(">", "&#62").Replace("<", "&#60") :
                         CoreContext.TenantManager.GetCurrentTenant().Name));
 }
Beispiel #7
0
        private static void NotifyFeed(Feed feed, bool isEdit, FeedType type)
        {
            var initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(feed.Creator, ""));

            try
            {
                NewsNotifyClient.NotifyClient.AddInterceptor(initatorInterceptor);

                if (type == FeedType.Poll && feed is FeedPoll)
                {
                    NewsNotifyClient.NotifyClient.SendNoticeAsync(
                        NewsConst.NewFeed, null, null,
                        new TagValue(NewsConst.TagFEED_TYPE, "poll"),
                        new TagValue(NewsConst.TagAnswers, ((FeedPoll)feed).Variants.ConvertAll(v => v.Name)),
                        new TagValue(NewsConst.TagCaption, feed.Caption),
                        new TagValue(NewsConst.TagText, HtmlUtility.GetFull(feed.Text)),
                        new TagValue(NewsConst.TagDate, feed.Date.ToShortString()),
                        new TagValue(NewsConst.TagURL,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         "~/Products/Community/Modules/News/Default.aspx?docid=" + feed.Id)),
                        new TagValue(NewsConst.TagUserName,
                                     DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID)),
                        new TagValue(NewsConst.TagUserUrl,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID)))
                        );
                }
                else
                {
                    NewsNotifyClient.NotifyClient.SendNoticeAsync(
                        NewsConst.NewFeed, null, null,
                        new TagValue(NewsConst.TagFEED_TYPE, "feed"),
                        new TagValue(NewsConst.TagCaption, feed.Caption),
                        new TagValue(NewsConst.TagText,
                                     HtmlUtility.GetFull(feed.Text)),
                        new TagValue(NewsConst.TagDate, feed.Date.ToShortString()),
                        new TagValue(NewsConst.TagURL,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         "~/Products/Community/Modules/News/Default.aspx?docid=" + feed.Id)),
                        new TagValue(NewsConst.TagUserName,
                                     DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID)),
                        new TagValue(NewsConst.TagUserUrl,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID)))
                        );
                }

                // subscribe to new comments
                var subsciber = NewsNotifySource.Instance.GetSubscriptionProvider();
                var me        = (IDirectRecipient)NewsNotifySource.Instance.GetRecipientsProvider().GetRecipient(SecurityContext.CurrentAccount.ID.ToString());
                if (me != null && !subsciber.IsUnsubscribe(me, NewsConst.NewComment, feed.Id.ToString(CultureInfo.InvariantCulture)))
                {
                    subsciber.Subscribe(NewsConst.NewComment, feed.Id.ToString(CultureInfo.InvariantCulture), me);
                }
            }
            finally
            {
                NewsNotifyClient.NotifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
Beispiel #8
0
        private void NotifyNewComment(FeedComment comment, Feed feed)
        {
            var feedType = feed.FeedType == FeedType.Poll ? "poll" : "feed";

            var initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(comment.Creator, ""));

            try
            {
                NewsNotifyClient.NotifyClient.AddInterceptor(initatorInterceptor);
                NewsNotifyClient.NotifyClient.SendNoticeAsync(
                    NewsConst.NewComment, feed.Id.ToString(CultureInfo.InvariantCulture),
                    null,
                    new TagValue(NewsConst.TagFEED_TYPE, feedType),
                    //new TagValue(NewsConst.TagAnswers, feed.Variants.ConvertAll<string>(v => v.Name)),
                    new TagValue(NewsConst.TagCaption, feed.Caption),
                    new TagValue("CommentBody", HtmlUtility.GetFull(comment.Comment)),
                    new TagValue(NewsConst.TagDate, comment.Date.ToShortString()),
                    new TagValue(NewsConst.TagURL, CommonLinkUtility.GetFullAbsolutePath("~/products/community/modules/news/?docid=" + feed.Id)),
                    new TagValue("CommentURL", CommonLinkUtility.GetFullAbsolutePath("~/products/community/modules/news/?docid=" + feed.Id + "#" + comment.Id.ToString(CultureInfo.InvariantCulture))),
                    new TagValue(NewsConst.TagUserName, DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID)),
                    new TagValue(NewsConst.TagUserUrl, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID))),
                    GetReplyToTag(feed, comment)
                    );
            }
            finally
            {
                NewsNotifyClient.NotifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
Beispiel #9
0
        private string GetHTMLComment(Comment comment, bool isPreview)
        {
            var creator = Global.EngineFactory.GetParticipantEngine().GetByID(comment.CreateBy).UserInfo;
            var info    = new CommentInfo
            {
                CommentID    = comment.ID.ToString(),
                UserID       = comment.CreateBy,
                TimeStamp    = comment.CreateOn,
                TimeStampStr = comment.CreateOn.Ago(),
                UserPost     = creator.Title,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Content,
                UserFullName = DisplayUserSettings.GetFullUserName(creator),
                UserAvatar   = Global.GetHTMLUserAvatar(creator)
            };

            var defComment = new CommentsList();

            ConfigureComments(defComment, null);

            if (!isPreview)
            {
                info.IsRead                = true;
                info.IsEditPermissions     = ProjectSecurity.CanEditComment(Task.Project, comment);
                info.IsResponsePermissions = ProjectSecurity.CanCreateComment();
            }

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment,
                       info,
                       comment.Parent == Guid.Empty,
                       false));
        }
Beispiel #10
0
        private static List <CommentInfo> BuildCommentsList(Post post, List <Comment> loaded, Guid parentId)
        {
            var result = new List <CommentInfo>();

            foreach (var comment in Comment.SelectChildLevel(parentId, loaded))
            {
                var info = new CommentInfo
                {
                    CommentID             = comment.ID.ToString(),
                    UserID                = comment.UserID,
                    TimeStamp             = comment.Datetime,
                    TimeStampStr          = comment.Datetime.Ago(),
                    IsRead                = true,
                    Inactive              = comment.Inactive,
                    CommentBody           = comment.Content,
                    UserFullName          = DisplayUserSettings.GetFullUserName(comment.UserID),
                    UserAvatar            = ImageHTMLHelper.GetHTMLUserAvatar(comment.UserID),
                    UserPost              = CoreContext.UserManager.GetUsers(comment.UserID).Title,
                    IsEditPermissions     = CommunitySecurity.CheckPermissions(comment, Constants.Action_EditRemoveComment),
                    IsResponsePermissions = CommunitySecurity.CheckPermissions(post, Constants.Action_AddComment),
                    CommentList           = BuildCommentsList(post, loaded, comment.ID)
                };

                result.Add(info);
            }
            return(result);
        }
Beispiel #11
0
        private void RenderContentForTimer()
        {
            var participantId = Guid.Empty;

            if (!WebItemSecurity.IsProductAdministrator(EngineFactory.ProductId, SecurityContext.CurrentAccount.ID))
            {
                participantId = Participant.ID;
            }

            UserProjects = EngineFactory.ProjectEngine.GetOpenProjectsWithTasks(participantId);

            if (UserProjects.Any() && (Project == null || !UserProjects.Contains(Project)))
            {
                Project = UserProjects.First();
            }

            var tasks = EngineFactory.TaskEngine.GetByProject(Project.ID, null, Participant.IsVisitor ? participantId : Guid.Empty);

            OpenUserTasks   = tasks.Where(r => r.Status == TaskStatus.Open).OrderBy(r => r.Title);
            ClosedUserTasks = tasks.Where(r => r.Status == TaskStatus.Closed).OrderBy(r => r.Title);

            Users = EngineFactory.ProjectEngine.GetTeam(Project.ID).OrderBy(r => DisplayUserSettings.GetFullUserName(r.UserInfo)).Where(r => r.UserInfo.IsVisitor() != true).ToList();

            if (!string.IsNullOrEmpty(Request.QueryString["taskId"]))
            {
                Target = int.Parse(Request.QueryString["taskId"]);
            }
        }
        public override List <UsageSpaceStatItem> GetStatData()
        {
            using (var mail_db = DbManager.FromHttpContext(MailDatabaseId))
            {
                var query = new SqlQuery("mail_attachment a")
                            .InnerJoin("mail_mail m", Exp.EqColumns("a.id_mail", "m.id"))
                            .Select("m.id_user")
                            .Select("sum(a.size) as size")
                            .Where("a.tenant", TenantProvider.CurrentTenantID)
                            .Where("a.need_remove", 0)
                            .GroupBy(1)
                            .OrderBy(2, false);

                return(mail_db.ExecuteList(query)
                       .Select(r =>
                {
                    var user_id = new Guid(Convert.ToString(r[0]));
                    var user = CoreContext.UserManager.GetUsers(user_id);
                    var item = new UsageSpaceStatItem
                    {
                        Name = DisplayUserSettings.GetFullUserName(user, false),
                        ImgUrl = UserPhotoManager.GetSmallPhotoURL(user.ID),
                        Url = CommonLinkUtility.GetUserProfile(user.ID),
                        SpaceUsage = Convert.ToInt64(r[1]),
                        Disabled = user.Status == EmployeeStatus.Terminated
                    };
                    return item;
                })
                       .ToList());
            }
        }
Beispiel #13
0
 private static object PrepareUserInfo(UserInfo userInfo)
 {
     return(new
     {
         id = userInfo.ID,
         displayName = DisplayUserSettings.GetFullUserName(userInfo),
         title = userInfo.Title,
         avatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID),
         avatarBig = UserPhotoManager.GetBigPhotoURL(userInfo.ID),
         profileUrl = CommonLinkUtility.ToAbsolute(CommonLinkUtility.GetUserProfile(userInfo.ID.ToString(), false)),
         groups = CoreContext.UserManager.GetUserGroups(userInfo.ID).Select(x => new
         {
             id = x.ID,
             name = x.Name,
             manager = CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(x.ID)).UserName
         }).ToList(),
         isPending = userInfo.ActivationStatus == EmployeeActivationStatus.Pending,
         isActivated = userInfo.ActivationStatus == EmployeeActivationStatus.Activated,
         isVisitor = userInfo.IsVisitor(),
         isOutsider = userInfo.IsOutsider(),
         isAdmin = userInfo.IsAdmin(),
         isOwner = userInfo.IsOwner(),
         contacts = GetContacts(userInfo),
         created = userInfo.CreateDate,
         email = userInfo.Email,
         isLDAP = userInfo.Sid != null
     });
 }
        private void InitScript()
        {
            var inlineScript = new StringBuilder();

            inlineScript.AppendFormat("\nASC.Files.Constants.URL_WCFSERVICE = \"{0}\";" +
                                      "ASC.Files.Constants.DocsAPIundefined = \"{1}\";",
                                      PathProvider.GetFileServicePath,
                                      FilesCommonResource.DocsAPIundefined);

            if (!CoreContext.Configuration.Personal)
            {
                inlineScript.AppendFormat("\nASC.Files.Constants.URL_MAIL_ACCOUNTS = \"{0}\";",
                                          CommonLinkUtility.GetFullAbsolutePath("~/addons/mail/#accounts"));
            }

            var docServiceParams = new DocumentServiceParams
            {
                DocKeyForTrack     = _docKeyForTrack,
                EditByUrl          = _editByUrl,
                LinkToEdit         = _linkToEdit,
                OpenHistory        = RequestVersion != -1 && RequestView && !RequestHistoryClose && _configuration.Document.Info.File.Forcesave == ForcesaveType.None && !_configuration.Document.Info.File.Encrypted,
                OpeninigDate       = DateTime.UtcNow.ToString(CultureInfo.InvariantCulture),
                ShareLinkParam     = string.IsNullOrEmpty(RequestShareLinkKey) ? string.Empty : "&" + FilesLinkUtility.DocShareKey + "=" + RequestShareLinkKey,
                ServerErrorMessage = ErrorMessage,
                TabId            = _tabId.ToString(),
                ThirdPartyApp    = _thirdPartyApp,
                CanGetUsers      = SecurityContext.IsAuthenticated && !CoreContext.Configuration.Personal,
                PageTitlePostfix = GetPageTitlePostfix()
            };

            if (_configuration != null)
            {
                docServiceParams.FileId          = _configuration.Document.Info.File.ID.ToString();
                docServiceParams.FileProviderKey = _configuration.Document.Info.File.ProviderKey;
                docServiceParams.FileVersion     = _configuration.Document.Info.File.Version;

                if (!string.IsNullOrEmpty(FileUtility.SignatureSecret))
                {
                    _configuration.EditorConfig.CallbackUrl = DocumentServiceTracker.GetCallbackUrl(_configuration.Document.Info.File.ID.ToString());
                }

                _configuration.Token = DocumentServiceHelper.GetSignature(_configuration);
            }

            if (Request.DesktopApp() && SecurityContext.IsAuthenticated)
            {
                var user = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

                docServiceParams.DisplayName = DisplayUserSettings.GetFullUserName(user);
                docServiceParams.Email       = user.Email;
            }

            inlineScript.AppendFormat("\nASC.Files.Editor.docServiceParams = {0};",
                                      DocumentServiceParams.Serialize(docServiceParams));

            inlineScript.AppendFormat("\nASC.Files.Editor.configurationParams = {0};",
                                      Services.DocumentService.Configuration.Serialize(_configuration));

            InlineScripts.Scripts.Add(new Tuple <string, bool>(inlineScript.ToString(), false));
        }
        protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context)
        {
            var users = CoreContext.UserManager.GetUsers(EmployeeStatus.Active).Select(r => new
            {
                id          = r.ID,
                displayName = DisplayUserSettings.GetFullUserName(r),
                avatarSmall = UserPhotoManager.GetSmallPhotoURL(r.ID),
                groups      = CoreContext.UserManager.GetUserGroups(r.ID).Select(x => new {
                    id      = x.ID,
                    name    = x.Name,
                    manager = CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(x.ID)).UserName
                })
                              .ToList(),
                isVisitor = r.IsVisitor(),
                isAdmin   = r.IsAdmin(),
                isOwner   = r.IsOwner()
            }).ToList();

            var groups = CoreContext.UserManager.GetDepartments().Select(x => new
            {
                id   = x.ID,
                name = x.Name
            }).ToList();

            yield return(RegisterObject("ApiResponsesMyProfile", new { response = users.FirstOrDefault(r => r.id.Equals(SecurityContext.CurrentAccount.ID)) }));

            yield return(RegisterObject("ApiResponses_Profiles", new { response = users }));

            yield return(RegisterObject("ApiResponses_Groups", new { response = groups }));
        }
        private static CommentInfo GetCommentInfo(Comment comment, bool isPreview)
        {
            var info = new CommentInfo
            {
                CommentID       = comment.ID.ToString(),
                UserID          = comment.UserID,
                TimeStamp       = comment.Datetime,
                TimeStampStr    = comment.Datetime.Ago(),
                IsRead          = true,
                Inactive        = comment.Inactive,
                CommentBody     = HtmlUtility.GetFull(comment.Content),
                UserFullName    = DisplayUserSettings.GetFullUserName(comment.UserID),
                UserProfileLink = CommonLinkUtility.GetUserProfile(comment.UserID),
                UserAvatarPath  = UserPhotoManager.GetBigPhotoURL(comment.UserID),
                UserPost        = CoreContext.UserManager.GetUsers(comment.UserID).Title
            };

            if (!isPreview)
            {
                info.IsEditPermissions = CommunitySecurity.CheckPermissions(comment, ASC.Blogs.Core.Constants.Action_EditRemoveComment);

                info.IsResponsePermissions = CommunitySecurity.CheckPermissions(comment.Post, ASC.Blogs.Core.Constants.Action_AddComment);
            }

            return(info);
        }
Beispiel #17
0
        public static CommentInfo ConvertComment(Comment comment, IList <Comment> commentList)
        {
            var userID = comment.UserID;

            var c = new CommentInfo
            {
                CommentID             = comment.ID.ToString(),
                UserID                = userID,
                TimeStamp             = comment.Datetime,
                TimeStampStr          = comment.Datetime.Ago(),
                Inactive              = comment.Inactive,
                CommentBody           = HtmlUtility.GetFull(comment.Content),
                UserFullName          = DisplayUserSettings.GetFullUserName(userID),
                UserProfileLink       = CommonLinkUtility.GetUserProfile(userID),
                UserAvatarPath        = UserPhotoManager.GetBigPhotoURL(userID),
                IsEditPermissions     = BookmarkingPermissionsCheck.PermissionCheckEditComment(comment),
                IsResponsePermissions = BookmarkingPermissionsCheck.PermissionCheckCreateComment(),
                UserPost              = BookmarkingServiceHelper.GetUserInfo(userID).Title
            };

            var commentsList = new List <CommentInfo>();

            var childComments = GetChildComments(comment, commentList);

            if (childComments != null)
            {
                foreach (var item in childComments)
                {
                    commentsList.Add(ConvertComment(item, commentList));
                }
            }
            c.CommentList = commentsList;
            return(c);
        }
Beispiel #18
0
        private static string GetHTMLComment(Comment comment, bool isPreview)
        {
            var info = new CommentInfo
            {
                CommentID    = comment.ID.ToString(),
                UserID       = comment.UserID,
                TimeStamp    = comment.Datetime,
                TimeStampStr = comment.Datetime.Ago(),
                IsRead       = true,
                Inactive     = comment.Inactive,
                CommentBody  = comment.Content,
                UserFullName = DisplayUserSettings.GetFullUserName(comment.UserID),
                UserAvatar   = ImageHTMLHelper.GetHTMLUserAvatar(comment.UserID),
                UserPost     = CoreContext.UserManager.GetUsers(comment.UserID).Title
            };

            if (!isPreview)
            {
                info.IsEditPermissions = CommunitySecurity.CheckPermissions(comment, Constants.Action_EditRemoveComment);

                info.IsResponsePermissions = CommunitySecurity.CheckPermissions(comment.Post, Constants.Action_AddComment);
            }
            var defComment = new CommentsList();

            ConfigureComments(defComment, 0, null);

            return(CommentsHelper.GetOneCommentHtmlWithContainer(
                       defComment,
                       info,
                       comment.IsRoot(),
                       false));
        }
        public static string GetAlbumThumb(AlbumItem image, int maxSize, int pad, string link, ASC.Data.Storage.IDataStore store)
        {
            var sb    = new StringBuilder();
            var limit = GetImageSizeLimit(image, maxSize);

            sb.Append("<a style=\"text-align:left;padding:0px;\" href=\"" + link + "\">");
            if (image != null)
            {
                sb.Append("<img " + limit + " class=\"borderBase\" title=\"" + HttpUtility.HtmlEncode(image.Name) + "\" src=\"" + GetImageUrl(image.ExpandedStoreThumb, store) + "\" />");
            }
            sb.Append("</a>");

            var date = image.Album.LastUpdate;

            var caption = (string.IsNullOrEmpty(image.Album.Caption) ? DisplayUserSettings.GetFullUserName(new Guid(image.Album.UserID)) : HttpUtility.HtmlEncode(image.Album.Caption));

            var album_url = PhotoConst.PAGE_PHOTO + "?" + PhotoConst.PARAM_ALBUM + "=" + image.Album.Id;

            return
                ("<span>" +
                 "<table cellpadding='0' cellspacing='0' border='0' class=\"borderBase\"><tr><td><div  style=\"padding:" + pad + "px;background-color:#fff;\">" + sb.ToString() + "</div></td></tr><tr><td class=\"borderBase\" style='border-width:1px 0px 0px 0px;padding-top:1px;background-color:#fff;'></td></tr><tr><td class=\"borderBase\" style='border-width:1px 0px 0px 0px;padding-top:1px;background-color:#fff;'></td></tr></table>" +
                 "<div style='text-align:left;width: 150px;word-wrap: break-word;'><div style=\"padding:10px 5px 6px;width:" + maxSize + "px;\">" +
                 "<a href=\"" + album_url + "\" class=\"linkHeader\">" + caption + "</a></div><div style=\"padding:2px 5px 5px;\"><a href=\"" + album_url + "\">" + Grammatical.PhotosCount(image.Album.ImagesCount) + "</a></div>" +
                 "<div class=\"textMediumDescribe\" style=\"padding:5px\">" + PhotoManagerResource.LastUpdateTitle + ": " + date.ToShortDateString() + "</div></div></span>");
        }
Beispiel #20
0
        public override List <UsageSpaceStatItem> GetStatData()
        {
            if (!DbRegistry.IsDatabaseRegistered(MailDatabaseId))
            {
                DbRegistry.RegisterDatabase(MailDatabaseId, ConfigurationManager.ConnectionStrings[MailDatabaseId]);
            }

            using (var mail_db = new DbManager(MailDatabaseId))
            {
                var query = new SqlQuery("mail_attachment a")
                            .InnerJoin("mail_mail m", Exp.EqColumns("a.id_mail", "m.id"))
                            .Select("m.id_user")
                            .Select("sum(a.size) as size")
                            .Where("m.tenant", TenantProvider.CurrentTenantID)
                            .Where("a.need_remove", 0)
                            .GroupBy(1)
                            .OrderBy(2, false);

                return(mail_db.ExecuteList(query)
                       .Select(r =>
                {
                    var user_id = new Guid(Convert.ToString(r[0]));
                    var user = CoreContext.UserManager.GetUsers(user_id);
                    var item = new UsageSpaceStatItem
                    {
                        Name = DisplayUserSettings.GetFullUserName(user, false),
                        ImgUrl = UserPhotoManager.GetSmallPhotoURL(user.ID),
                        Url = CommonLinkUtility.GetUserProfile(user.ID),
                        SpaceUsage = Convert.ToInt64(r[1])
                    };
                    return item;
                })
                       .ToList());
            }
        }
Beispiel #21
0
        protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context)
        {
            var currentProject = "0";

            if (context.Request.GetUrlRewriter() != null)
            {
                currentProject = HttpUtility.ParseQueryString(context.Request.GetUrlRewriter().Query)["prjID"];

                if (string.IsNullOrEmpty(currentProject) && context.Request.UrlReferrer != null)
                {
                    currentProject = HttpUtility.ParseQueryString(context.Request.UrlReferrer.Query)["prjID"];
                }
            }
            using (var scope = DIHelper.Resolve())
            {
                var engineFactory = scope.Resolve <EngineFactory>();

                var team = engineFactory.ProjectEngine.GetTeam(Convert.ToInt32(currentProject))
                           .Select(r => new
                {
                    id          = r.UserInfo.ID,
                    displayName = DisplayUserSettings.GetFullUserName(r.UserInfo.ID),
                    email       = r.UserInfo.Email,
                    userName    = r.UserInfo.UserName,
                    avatarSmall = UserPhotoManager.GetSmallPhotoURL(r.UserInfo.ID),
                    avatar      = UserPhotoManager.GetBigPhotoURL(r.UserInfo.ID),
                    status      = r.UserInfo.Status,
                    groups      = CoreContext.UserManager.GetUserGroups(r.UserInfo.ID).Select(x => new
                    {
                        id      = x.ID,
                        name    = x.Name,
                        manager =
                            CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(x.ID))
                            .UserName
                    }).ToList(),
                    isVisitor         = r.UserInfo.IsVisitor(),
                    isAdmin           = r.UserInfo.IsAdmin(),
                    isOwner           = r.UserInfo.IsOwner(),
                    isManager         = r.IsManager,
                    canReadFiles      = r.CanReadFiles,
                    canReadMilestones = r.CanReadMilestones,
                    canReadMessages   = r.CanReadMessages,
                    canReadTasks      = r.CanReadTasks,
                    canReadContacts   = r.CanReadContacts,
                    title             = r.UserInfo.Title,
                    profileUrl        = r.UserInfo.GetUserProfilePageURL()
                }).OrderBy(r => r.displayName).ToList();

                return(new List <KeyValuePair <string, object> >(1)
                {
                    RegisterObject(
                        new
                    {
                        Team = new { response = team },
                        projectFolder = engineFactory.FileEngine.GetRoot(Convert.ToInt32(currentProject))
                    })
                });
            }
        }
Beispiel #22
0
        public AjaxResponse AddComment(string parrentCommentID, string photoID, string text, string pid)
        {
            var resp = new AjaxResponse {
                rs1 = parrentCommentID
            };

            CommunitySecurity.DemandPermissions(PhotoConst.Action_AddComment);

            var storage = StorageFactory.GetStorage();

            image = storage.GetAlbumItem(Convert.ToInt64(photoID));

            var newComment = new Comment(image.Id)
            {
                Text      = text,
                Timestamp = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                UserID    = SecurityContext.CurrentAccount.ID.ToString()
            };

            if (!string.IsNullOrEmpty(parrentCommentID))
            {
                newComment.ParentId = Convert.ToInt64(parrentCommentID);
            }

            var count = storage.SaveComment(image, newComment);

            storage.ReadAlbumItem(newComment.ItemID, SecurityContext.CurrentAccount.ID.ToString());

            var odd = count % 2 == 1;

            var comment = newComment;

            var info = new CommentInfo
            {
                CommentID             = comment.Id.ToString(),
                UserID                = new Guid(comment.UserID),
                TimeStampStr          = comment.Timestamp.Ago(),
                IsRead                = true,
                Inactive              = comment.Inactive,
                CommentBody           = comment.Text,
                UserFullName          = DisplayUserSettings.GetFullUserName(new Guid(comment.UserID)),
                UserAvatar            = ImageHTMLHelper.GetHTMLImgUserAvatar(new Guid(comment.UserID)),
                UserPost              = CoreContext.UserManager.GetUsers(new Guid(comment.UserID)).Title,
                IsEditPermissions     = CommunitySecurity.CheckPermissions(image, PhotoConst.Action_EditRemoveComment),
                IsResponsePermissions = CommunitySecurity.CheckPermissions(PhotoConst.Action_AddComment)
            };

            //postParser.Parse(comment.Text);

            var defComment = new CommentsList();

            ConfigureCommentsList(defComment, image);

            resp.rs2 = CommentsHelper.GetOneCommentHtmlWithContainer(defComment, info, newComment.ParentId == 0, odd);


            return(resp);
        }
Beispiel #23
0
        protected override void PageLoad()
        {
            Guid?userId = null;

            if (!String.IsNullOrEmpty(UserID))
            {
                userId = Guid.NewGuid();
                try
                {
                    userId = new Guid(UserID);
                }
                catch
                {
                }
            }

            var postsQuery = new PostsQuery();

            mainContainer.BreadCrumbs.Add(new BreadCrumb {
                Caption = BlogsResource.AddonName, NavigationUrl = VirtualPathUtility.ToAbsolute(ASC.Blogs.Core.Constants.BaseVirtualPath)
            });
            if (userId.HasValue)
            {
                mainContainer.BreadCrumbs.Add(new BreadCrumb {
                    Caption = DisplayUserSettings.GetFullUserName(userId.Value, false)
                });
                postsQuery.SetUser(userId.Value);
            }
            else if (!String.IsNullOrEmpty(TagName))
            {
                mainContainer.BreadCrumbs.Add(new BreadCrumb {
                    Caption = HeaderStringHelper.GetHTMLSearchHeader(TagName)
                });
                postsQuery.SetTag(TagName);
            }
            else if (!String.IsNullOrEmpty(Search))
            {
                mainContainer.BreadCrumbs.Add(new BreadCrumb {
                    Caption = HeaderStringHelper.GetHTMLSearchHeader(Search)
                });
                postsQuery.SetSearch(Search);
            }

            if (!IsPostBack)
            {
                var engine = BasePage.GetEngine();
                FillPosts(postsQuery, engine);

                InitSidePanel(engine, TagCloud);
                sideRecentActivity.TenantId  = TenantProvider.CurrentTenantID;
                sideRecentActivity.ProductId = Product.CommunityProduct.ID;
                sideRecentActivity.ModuleId  = ASC.Blogs.Core.Constants.ModuleID;

                base.InitSubscribers(actions);
            }

            this.Title = HeaderStringHelper.GetPageTitle(BlogsResource.AddonName, mainContainer.BreadCrumbs);
        }
Beispiel #24
0
 public EmployeeWraper(UserInfo userInfo)
 {
     Id          = userInfo.ID;
     DisplayName = DisplayUserSettings.GetFullUserName(userInfo);
     if (!string.IsNullOrEmpty(userInfo.Title))
     {
         Title = userInfo.Title;
     }
     AvatarSmall = UserPhotoManager.GetSizedPhotoUrl(userInfo.ID, 64, 64);
 }
        protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context)
        {
            var userInfoList = new List <UserInfo> {
                CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID)
            };
            var groupInfoList = new List <GroupInfo>();

            if (SecurityContext.IsAuthenticated && !CoreContext.Configuration.Personal)
            {
                userInfoList = CoreContext.UserManager.GetUsers(EmployeeStatus.Active).ToList();

                groupInfoList = CoreContext.UserManager.GetDepartments().ToList();
            }

            var users = userInfoList.Select(r => new
            {
                id          = r.ID,
                displayName = DisplayUserSettings.GetFullUserName(r),
                avatarSmall = UserPhotoManager.GetSmallPhotoURL(r.ID),
                groups      = CoreContext.UserManager.GetUserGroups(r.ID).Select(x => new
                {
                    id      = x.ID,
                    name    = x.Name,
                    manager = CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(x.ID)).UserName
                })
                              .ToList(),
                isPending = r.ActivationStatus == EmployeeActivationStatus.Pending,
                isVisitor = r.IsVisitor(),
                isAdmin   = r.IsAdmin(),
                isOwner   = r.IsOwner()
            }).ToList();

            var groups = groupInfoList.Select(x => new
            {
                id   = x.ID,
                name = x.Name
            }).ToList();

            var currentTenant = CoreContext.TenantManager.GetCurrentTenant();
            var hubToken      = Common.Utils.Signature.Create(string.Join(",", currentTenant.TenantId, SecurityContext.CurrentAccount.ID, currentTenant.TenantAlias));
            var hubUrl        = ConfigurationManager.AppSettings["web.hub"] ?? "https://signalr.teamlab.info";

            if (!hubUrl.EndsWith("/"))
            {
                hubUrl += "/";
            }

            yield return(RegisterObject("Hub", new { Token = hubToken, Url = hubUrl + "signalr" }));

            yield return(RegisterObject("ApiResponsesMyProfile", new { response = users.FirstOrDefault(r => r.id.Equals(SecurityContext.CurrentAccount.ID)) }));

            yield return(RegisterObject("ApiResponses_Profiles", new { response = users }));

            yield return(RegisterObject("ApiResponses_Groups", new { response = groups }));
        }
Beispiel #26
0
        public void SaveComment(Comment comment, Post post)
        {
            CommunitySecurity.DemandPermissions(post, ASC.Blogs.Core.Constants.Action_AddComment);
            SaveComment(comment);

            var initiatorInterceptor = new InitiatorInterceptor(new DirectRecipient(comment.UserID.ToString(), ""));

            try
            {
                NotifyClient.BeginSingleRecipientEvent("asc_blog_c");
                NotifyClient.AddInterceptor(initiatorInterceptor);

                List <ITagValue> tags = new List <ITagValue>
                {
                    new TagValue(ASC.Blogs.Core.Constants.TagPostSubject, post.Title),
                    new TagValue(ASC.Blogs.Core.Constants.TagPostPreview, post.GetPreviewText(500)),
                    new TagValue(ASC.Blogs.Core.Constants.TagUserName, DisplayUserSettings.GetFullUserName(comment.UserID)),
                    new TagValue(ASC.Blogs.Core.Constants.TagUserURL, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(comment.UserID, CommonLinkUtility.GetProductID()))),
                    new TagValue(ASC.Blogs.Core.Constants.TagDate, string.Format("{0:d} {0:t}", comment.Datetime)),
                    new TagValue(ASC.Blogs.Core.Constants.TagCommentBody, comment.Content),

                    new TagValue(ASC.Blogs.Core.Constants.TagURL, CommonLinkUtility.GetFullAbsolutePath(ASC.Blogs.Core.Constants.ViewBlogPageUrl + "?blogID=" + post.ID.ToString())),
                    new TagValue(ASC.Blogs.Core.Constants.TagCommentURL, CommonLinkUtility.GetFullAbsolutePath(ASC.Blogs.Core.Constants.ViewBlogPageUrl + "?blogID=" + post.ID.ToString() + "#" + comment.ID.ToString())),
                    GetReplyToTag(comment.ID, post)
                };

                NotifyClient.SendNoticeAsync(
                    ASC.Blogs.Core.Constants.NewComment,
                    post.ID.ToString(),
                    null,
                    tags.ToArray());

                NotifyClient.EndSingleRecipientEvent("asc_blog_c");
            }
            finally
            {
                NotifyClient.RemoveInterceptor(initiatorInterceptor.Name);
            }

            BlogUserActivityPublisher.AddComment(comment, post);

            ASC.Notify.Model.ISubscriptionProvider subscriptionProvider = NotifySource.GetSubscriptionProvider();

            if (!subscriptionProvider.IsUnsubscribe((IDirectRecipient)NotifySource.GetRecipientsProvider().
                                                    GetRecipient(SecurityContext.CurrentAccount.ID.ToString()), ASC.Blogs.Core.Constants.NewComment, post.ID.ToString()))
            {
                subscriptionProvider.Subscribe(
                    ASC.Blogs.Core.Constants.NewComment,
                    post.ID.ToString(),
                    NotifySource.GetRecipientsProvider().
                    GetRecipient(SecurityContext.CurrentAccount.ID.ToString())
                    );
            }
        }
Beispiel #27
0
            public ParticipiantWrapper(string id, Message message)
            {
                ID = id;

                var participant = Global.EngineFactory.GetParticipantEngine().GetByID(new Guid(id));

                Link         = participant.UserInfo.RenderProfileLink(ProductEntryPoint.ID);
                FullUserName = DisplayUserSettings.GetFullUserName(participant.UserInfo);
                Title        = HttpUtility.HtmlEncode(participant.UserInfo.Title);
                Department   = HttpUtility.HtmlEncode(participant.UserInfo.Department);
                CanRead      = ProjectSecurity.CanRead(message, new Guid(id));
            }
 public void SendMsgRemoveUserDataFailed(Guid recipientId, Guid fromUserId, string fromUserName, string message)
 {
     client.SendNoticeToAsync(
         Actions.RemoveUserDataFailed,
         null,
         new[] { StudioNotifyHelper.ToRecipient(recipientId) },
         new[] { EMailSenderName },
         null,
         new TagValue(Tags.UserName, DisplayUserSettings.GetFullUserName(recipientId)),
         new TagValue(Tags.FromUserName, fromUserName.HtmlEncode()),
         new TagValue(Tags.FromUserLink, GetUserProfileLink(fromUserId)),
         new TagValue(Tags.Message, message));
 }
        public EmployeeWraper(UserInfo userInfo, ApiContext context)
        {
            Id          = userInfo.ID;
            DisplayName = DisplayUserSettings.GetFullUserName(userInfo);
            if (!string.IsNullOrEmpty(userInfo.Title))
            {
                Title = userInfo.Title;
            }

            if (EmployeeWraperFull.CheckContext(context, "avatarSmall"))
            {
                AvatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID) + "?_=" + userInfo.LastModified.GetHashCode();
            }
        }
 public void SendMsgReassignsCompleted(Guid recipientId, UserInfo fromUser, UserInfo toUser)
 {
     client.SendNoticeToAsync(
         Actions.ReassignsCompleted,
         null,
         new[] { StudioNotifyHelper.ToRecipient(recipientId) },
         new[] { EMailSenderName },
         null,
         new TagValue(Tags.UserName, DisplayUserSettings.GetFullUserName(recipientId)),
         new TagValue(Tags.FromUserName, fromUser.DisplayUserName()),
         new TagValue(Tags.FromUserLink, GetUserProfileLink(fromUser.ID)),
         new TagValue(Tags.ToUserName, toUser.DisplayUserName()),
         new TagValue(Tags.ToUserLink, GetUserProfileLink(toUser.ID)));
 }