Пример #1
0
        private void RegisterClientScript()
        {
            Page.ClientScript.RegisterClientScriptInclude(
                typeof(string),
                "accessrights_script",
                WebPath.GetPath("usercontrols/management/accessrights/js/accessrights.js")
                );

            Page.ClientScript.RegisterClientScriptBlock(
                GetType(),
                "accessrights_style",
                "<link rel=\"stylesheet\" type=\"text/css\" href=\"" + WebSkin.GetUserSkin().GetAbsoluteWebPath("usercontrols/management/accessrights/css/<theme_folder>/accessrights.css") + "\">",
                false);

            var curTenant    = CoreContext.TenantManager.GetCurrentTenant();
            var currentOwner = CoreContext.UserManager.GetUsers(curTenant.OwnerId);
            var admins       = WebItemSecurity.GetProductAdministrators(Guid.Empty).Where(admin => admin.ID != currentOwner.ID).SortByUserName();

            Page.ClientScript.RegisterClientScriptBlock(
                typeof(AccessRights),
                "54F36EE2-0595-4e01-82BD-35E140D94F5D",
                "adminList = " + JavaScriptSerializer.Serialize(admins.ConvertAll(u => new
            {
                id           = u.ID,
                smallFotoUrl = u.GetSmallPhotoURL(),
                displayName  = u.DisplayUserName(),
                title        = u.Title.HtmlEncode(),
                userUrl      = CommonLinkUtility.GetUserProfile(u.ID, new Guid()),
                accessList   = GetAccessList(u.ID)
            }))
                + "; ", true);
        }
Пример #2
0
        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);
        }
        public static string GetUserPageLink()
        {
            var userInfo     = CoreContext.UserManager.GetUsers(GetCurrentInstanse().GetCurrentUserID());
            var userPageName = CommonLinkUtility.GetUserProfile(userInfo.ID);

            return(string.Format("<a class='linkHeader' href='{0}'>{1}</a>", userPageName, userInfo.DisplayUserName()));
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var username = Request["user"];

            if (!IsAdmin() || string.IsNullOrEmpty(username))
            {
                Response.Redirect("~/products/people/", true);
            }

            UserInfo = CoreContext.UserManager.GetUserByUserName(Request["user"]);

            if (UserInfo.Status != EmployeeStatus.Terminated)
            {
                Response.Redirect("~/products/people/", true);
            }

            PageTitle = UserInfo.DisplayUserName(false) + " - " + PeopleResource.ReassignmentData;

            Title = HeaderStringHelper.GetPageTitle(PageTitle);

            PageTitle = HttpUtility.HtmlEncode(PageTitle);

            HelpLink = CommonLinkUtility.GetHelpLink();

            ProfileLink = CommonLinkUtility.GetUserProfile(UserInfo.ID);

            Page.RegisterInlineScript(string.Format("ASC.People.Reassigns.init(\"{0}\");", UserInfo.ID));
        }
Пример #5
0
        public static void NotifyAboutSharingEvent(ASC.Api.Calendar.BusinessObjects.Event calendarEvent, ASC.Api.Calendar.BusinessObjects.Event oldCalendarEvent)
        {
            var initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), SecurityContext.CurrentAccount.Name));

            try
            {
                var usr      = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
                var userLink = PerformUrl(CommonLinkUtility.GetUserProfile(usr.ID.ToString(), false));

                foreach (var item in calendarEvent.SharingOptions.PublicItems)
                {
                    if (oldCalendarEvent != null && oldCalendarEvent.SharingOptions.PublicItems.Exists(i => i.Id.Equals(item.Id)))
                    {
                        continue;
                    }

                    var r = CalendarNotifySource.Instance.GetRecipientsProvider().GetRecipient(item.Id.ToString());
                    if (r != null)
                    {
                        _notifyClient.SendNoticeAsync(CalendarNotifySource.CalendarSharing, null, r, true,
                                                      new TagValue("SharingType", "event"),
                                                      new TagValue("UserName", usr.DisplayUserName()),
                                                      new TagValue("UserLink", userLink),
                                                      new TagValue("EventName", calendarEvent.Name));
                    }
                }
                _notifyClient.EndSingleRecipientEvent(_syncName);
            }
            finally
            {
                _notifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var username = Request["user"];

            if (!IsAdmin() || string.IsNullOrEmpty(username))
            {
                Response.Redirect("~/Products/People/", true);
            }

            UserInfo = CoreContext.UserManager.GetUserByUserName(Request["user"]);

            if (UserInfo.Status != EmployeeStatus.Terminated)
            {
                Response.Redirect("~/Products/People/", true);
            }

            RemoveData = string.Equals(Request["remove"], bool.TrueString, StringComparison.InvariantCultureIgnoreCase);

            DeleteProfile = string.Equals(Request["delete"], bool.TrueString, StringComparison.InvariantCultureIgnoreCase);

            PageTitle = UserInfo.DisplayUserName(false) + " - " + (RemoveData ? PeopleResource.RemovingData : PeopleResource.ReassignmentData);

            Title = HeaderStringHelper.GetPageTitle(PageTitle);

            PageTitle = HttpUtility.HtmlEncode(PageTitle);

            HelpLink = CommonLinkUtility.GetHelpLink();

            ProfileLink = CommonLinkUtility.GetUserProfile(UserInfo.ID);

            Page.RegisterInlineScript(string.Format("ASC.People.Reassigns.init(\"{0}\", {1});", UserInfo.ID, RemoveData.ToString().ToLowerInvariant()));
        }
Пример #7
0
        public object ValidateTfaCode(string query, string code)
        {
            var  user = GetUser(query);
            bool newBackupCodes;

            try
            {
                newBackupCodes = user.ValidateAuthCode(code, !Activation);

                MessageService.Send(HttpContext.Current.Request, MessageAction.LoginSuccesViaTfaApp);
            }
            catch (Authorize.BruteForceCredentialException)
            {
                MessageService.Send(HttpContext.Current.Request, user.DisplayUserName(false), MessageAction.LoginFailBruteForce);
                throw;
            }
            catch
            {
                MessageService.Send(HttpContext.Current.Request, user.DisplayUserName(false), MessageAction.LoginFailViaTfaApp, MessageTarget.Create(user.ID));
                throw;
            }

            var refererUrl = GetRefererURL();

            if (newBackupCodes)
            {
                MessageService.Send(HttpContext.Current.Request, MessageAction.UserConnectedTfaApp, MessageTarget.Create(user.ID));

                refererUrl = CommonLinkUtility.GetUserProfile(user.ID) + "#codes";
            }

            return(new { RefererURL = refererUrl });
        }
Пример #8
0
        public object AddAdmin(Guid id)
        {
            var isRetina = TenantLogoManager.IsRetina(HttpContext.Current.Request);

            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var user = CoreContext.UserManager.GetUsers(id);

            if (user.IsVisitor())
            {
                throw new System.Security.SecurityException("Collaborator can not be an administrator");
            }

            WebItemSecurity.SetProductAdministrator(Guid.Empty, id, true);

            MessageService.Send(HttpContext.Current.Request, MessageAction.AdministratorAdded, MessageTarget.Create(user.ID), user.DisplayUserName(false));

            InitLdapRights();

            return(new
            {
                id = user.ID,
                smallFotoUrl = user.GetSmallPhotoURL(),
                bigFotoUrl = isRetina ? user.GetBigPhotoURL() : "",
                displayName = user.DisplayUserName(),
                title = user.Title.HtmlEncode(),
                userUrl = CommonLinkUtility.GetUserProfile(user.ID),
                accessList = GetAccessList(user.ID, true)
            });
        }
Пример #9
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
     });
 }
Пример #10
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);
            }
        }
Пример #11
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
     });
 }
Пример #12
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),
                    UserProfileLink       = CommonLinkUtility.GetUserProfile(comment.UserID),
                    UserAvatarPath        = UserPhotoManager.GetBigPhotoURL(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);
        }
Пример #13
0
        static void NotifyEngine_BeforeTransferRequest(ASC.Notify.Engine.NotifyEngine sender, ASC.Notify.Engine.NotifyRequest request)
        {
            request.Properties.Add("asc.web.product_id", CommonLinkUtility.GetProductID());

            Guid   aid   = Guid.Empty;
            string aname = "";

            if (SecurityContext.IsAuthenticated)
            {
                aid = SecurityContext.CurrentAccount.ID;
                if (CoreContext.UserManager.UserExists(aid))
                {
                    aname = CoreContext.UserManager.GetUsers(aid).DisplayUserName();
                }
            }

            //__AuthorID
            request.Arguments.Add(new TagValue(CommonTags.AuthorID, aid));
            //__AuthorName
            request.Arguments.Add(new TagValue(CommonTags.AuthorName, aname));
            //__AuthorUrl
            request.Arguments.Add(new TagValue(CommonTags.AuthorUrl, CommonLinkUtility.GetUserProfile(aid, CommonLinkUtility.GetProductID())));

            if (!request.Arguments.Any(x => CommonTags.SendFrom.Equals(x.Tag.Name)))//If none add current
            {
                request.Arguments.Add(new TagValue(CommonTags.SendFrom, CoreContext.TenantManager.GetCurrentTenant(false).Name));
            }
        }
Пример #14
0
        private void RegisterClientScript()
        {
            Page.RegisterBodyScripts(ResolveUrl("~/usercontrols/management/accessrights/js/accessrights.js"));
            Page.RegisterStyleControl(VirtualPathUtility.ToAbsolute("~/usercontrols/management/accessrights/css/accessrights.less"));

            var curTenant    = CoreContext.TenantManager.GetCurrentTenant();
            var currentOwner = CoreContext.UserManager.GetUsers(curTenant.OwnerId);
            var admins       = WebItemSecurity.GetProductAdministrators(Guid.Empty).Where(admin => admin.ID != currentOwner.ID).SortByUserName();

            var sb = new StringBuilder();

            sb.AppendFormat("ownerId = {0};", JavaScriptSerializer.Serialize(curTenant.OwnerId));

            sb.AppendFormat("adminList = {0};",
                            JavaScriptSerializer.Serialize(admins.ConvertAll(u => new
            {
                id           = u.ID,
                smallFotoUrl = u.GetSmallPhotoURL(),
                displayName  = u.DisplayUserName(),
                title        = u.Title.HtmlEncode(),
                userUrl      = CommonLinkUtility.GetUserProfile(u.ID),
                accessList   = GetAccessList(u.ID)
            }))
                            );
            sb.AppendFormat("ASC.Settings.AccessRights.init({0},\"{1}\");",
                            JavaScriptSerializer.Serialize(Products.Select(p => p.GetSysName()).ToArray()),
                            CustomNamingPeople.Substitute <Resource>("AccessRightsAddGroup").HtmlEncode()
                            );

            Page.RegisterInlineScript(sb.ToString());
        }
Пример #15
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);
        }
Пример #16
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());
            }
        }
Пример #17
0
        public object AddAdmin(Guid id)
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var user = CoreContext.UserManager.GetUsers(id);

            if (user.IsVisitor())
            {
                throw new System.Security.SecurityException("Collaborator can not be an administrator");
            }

            WebItemSecurity.SetProductAdministrator(Guid.Empty, id, true);

            var result = new
            {
                id           = user.ID,
                smallFotoUrl = user.GetSmallPhotoURL(),
                displayName  = user.DisplayUserName(),
                title        = user.Title.HtmlEncode(),
                userUrl      = CommonLinkUtility.GetUserProfile(user.ID),
                accessList   = GetAccessList(user.ID)
            };

            AdminLog.PostAction("Settings: added portal administrator ID=\"{0}\"", id);

            return(result);
        }
        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());
            }
        }
Пример #19
0
        private void NotifyAboutNewPost(Post post)
        {
            string url       = VirtualPathUtility.ToAbsolute("~/");
            int    numb_page = Convert.ToInt32(Math.Ceiling(Topic.PostCount / (_settings.PostCountOnPage * 1.0)));

            string hostUrl = CommonLinkUtility.ServerRootPath;

            string topicURL  = hostUrl + _settings.LinkProvider.PostList(Topic.ID);
            string postURL   = hostUrl + _settings.LinkProvider.Post(post.ID, Topic.ID, numb_page);
            string threadURL = hostUrl + _settings.LinkProvider.TopicList(Topic.ThreadID);
            string userURL   = hostUrl + CommonLinkUtility.GetUserProfile(post.PosterID, _settings.ProductID);

            string postText = HtmlUtility.GetFull(post.Text, _settings.ProductID);

            var initatorInterceptor = new InitiatorInterceptor(new DirectRecipient(SecurityContext.CurrentAccount.ID.ToString(), SecurityContext.CurrentAccount.Name));

            try
            {
                SubscriptionConstants.NotifyClient.AddInterceptor(initatorInterceptor);

                var poster = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

                _forumManager.PresenterFactory.GetPresenter <INotifierView>().SetView(this);
                SubscriptionConstants.NotifyClient.BeginSingleRecipientEvent(SubscriptionConstants.SyncName);
                if (SendNotify != null)
                {
                    if (PostType == NewPostType.Poll || PostType == NewPostType.Topic)
                    {
                        SendNotify(this, new NotifyEventArgs(SubscriptionConstants.NewTopicInForum,
                                                             null)
                        {
                            ThreadTitle = Topic.ThreadTitle, TopicId = Topic.ID, TopicTitle = Topic.Title, Poster = poster, Date = post.CreateDate.ToShortString(), PostURL = postURL, TopicURL = topicURL, ThreadURL = threadURL, UserURL = userURL, PostText = postText
                        });
                    }


                    SendNotify(this, new NotifyEventArgs(SubscriptionConstants.NewPostInThread,
                                                         Topic.ThreadID.ToString())
                    {
                        ThreadTitle = Topic.ThreadTitle, TopicTitle = Topic.Title, Poster = poster, Date = post.CreateDate.ToShortString(), PostURL = postURL, TopicURL = topicURL, ThreadURL = threadURL, UserURL = userURL, PostText = postText, TopicId = Topic.ID, PostId = post.ID, TenantId = Topic.TenantID
                    });

                    SendNotify(this, new NotifyEventArgs(SubscriptionConstants.NewPostInTopic,
                                                         Topic.ID.ToString())
                    {
                        ThreadTitle = Topic.ThreadTitle, TopicTitle = Topic.Title, Poster = poster, Date = post.CreateDate.ToShortString(), PostURL = postURL, TopicURL = topicURL, ThreadURL = threadURL, UserURL = userURL, PostText = postText, TopicId = Topic.ID, PostId = post.ID, TenantId = Topic.TenantID
                    });
                }
                SubscriptionConstants.NotifyClient.EndSingleRecipientEvent(SubscriptionConstants.SyncName);
            }
            finally
            {
                SubscriptionConstants.NotifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
Пример #20
0
        public static VelocityContext PrepareContext(UserActivity userActivity, UserInfo user)
        {
            var velocitycontext = new VelocityContext();

            velocitycontext.Put("activity", userActivity);
            velocitycontext.Put("url", CommonLinkUtility.GetFullAbsolutePath(userActivity.URL));
            velocitycontext.Put("user", user);
            velocitycontext.Put("displayName", user.DisplayUserName());
            velocitycontext.Put("userLink", CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(user.ID, userActivity.ProductID)));
            velocitycontext.Put("moduleName", GetModuleName(userActivity));
            velocitycontext.Put("productName", GetProductName(userActivity));
            velocitycontext.Put("additionalData", userActivity.AdditionalData);
            return(velocitycontext);
        }
Пример #21
0
        public IList <WhatsNewUserActivity> GetUserActivities(Guid?userID, DateTime startDate, DateTime endDate)
        {
            var result = new List <WhatsNewUserActivity>();

            var activities = UserActivityManager.GetUserActivities(TenantProvider.CurrentTenantID, null, ProductEntryPoint.ID, new[] { ProductEntryPoint.ID }, UserActivityConstants.ContentActionType, null, startDate, endDate).ToList();

            if (userID.HasValue)
            {
                var ids = Global.EngineFactory.GetProjectEngine()
                          .GetByParticipant(userID.Value)
                          .Select(p => p.ID)
                          .Union(Global.EngineFactory.GetParticipantEngine().GetFollowingProjects(userID.Value));
                activities = activities.FindAll(a => ids.Contains(Convert.ToInt32(a.ContainerID)));
            }

            if (activities.Count != 0)
            {
                activities.Sort((x, y) =>
                {
                    var proj1   = int.Parse(x.ContainerID);
                    var proj2   = int.Parse(y.ContainerID);
                    var compare = proj1.CompareTo(proj2);
                    return(compare != 0 ? compare : DateTime.Compare(x.Date, y.Date));
                });

                activities.ForEach(a =>
                {
                    var parts = a.AdditionalData.Split(new[] { '|' });
                    if (3 <= parts.Length)
                    {
                        var projectTitle = parts[2];
                        var timeLineType = (EntityType)Enum.Parse(typeof(EntityType), parts[0]);

                        result.Add(new WhatsNewUserActivity
                        {
                            Title           = a.Title,
                            Date            = a.Date,
                            URL             = CommonLinkUtility.GetFullAbsolutePath(a.URL),
                            UserAbsoluteURL = CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(a.UserID, CommonLinkUtility.GetProductID())),
                            UserName        = DisplayUserSettings.GetFullUserName(a.UserID),
                            BreadCrumbs     = new List <String> {
                                string.Format("[{0}]", projectTitle), ResourceEnumConverter.ConvertToString(timeLineType)
                            }
                        });
                    }
                });
            }
            return(result);
        }
Пример #22
0
        public override SearchResultItem[] Search(string text)
        {
            var users = new List <UserInfo>();

            users.AddRange(CoreContext.UserManager.Search(text, EmployeeStatus.Active));

            return(users.Select(user => new SearchResultItem
            {
                Name = user.DisplayUserName(false),
                Description = string.Format("{2}{1} {0}", user.Department, !String.IsNullOrEmpty(user.Department) ? "," : String.Empty, user.Title),
                URL = CommonLinkUtility.GetUserProfile(user.ID),
                Date = user.WorkFromDate,
                Additional = new Dictionary <string, object> {
                    { "imageRef", user.GetSmallPhotoURL() }, { "showIcon", true }, { "Hint", Resources.PeopleResource.ProductName }
                }
            }).ToArray());
        }
Пример #23
0
        public AjaxResponse Preview(string text, Guid settingsID)
        {
            _settings = ForumManager.GetSettings(settingsID);
            UserInfo      currentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            StringBuilder sb          = new StringBuilder();

            sb.Append("<div class=\"tintLight borderBase clearFix\" style=\"padding:10px 0px; border-top:none; border-left:none; border-right:none;\">");
            sb.Append("<table cellpadding=\"0\" cellspacing=\"0\" style='width:100%;'>");
            sb.Append("<tr valign=\"top\">");

            sb.Append("<td align=\"center\" style='width:180px; padding:0px 5px;'>");

            sb.Append("<div class=\"forum_postBoxUserSection\" style=\"overflow: hidden; width:150px;\">");
            sb.Append("<a class=\"linkHeader\"  href=\"" + CommonLinkUtility.GetUserProfile(currentUser.ID, _settings.ProductID) + "\">" + currentUser.DisplayUserName() + "</a>");

            sb.Append("<div style=\"margin:5px 0px;\" class=\"textMediumDescribe\">");
            sb.Append(HttpUtility.HtmlEncode(currentUser.Title));
            sb.Append("</div>");

            sb.Append("<a href=" + CommonLinkUtility.GetUserProfile(currentUser.ID, _settings.ProductID) + ">");
            sb.Append(_settings.ForumManager.GetHTMLImgUserAvatar(currentUser.ID));
            sb.Append("</a>");
            sb.Append("</div>");
            sb.Append("</td>");

            //post
            sb.Append("<td>");
            sb.Append("<div style='margin-bottom:5px; padding:0px 5px;'>");
            sb.Append(DateTimeService.DateTime2StringPostStyle(DateTimeService.CurrentDate()));
            sb.Append("</div>");

            var previewID = Guid.NewGuid().ToString();

            sb.Append("<div id=\"forum_message_" + previewID + "\" class=\"forum_mesBox\" style=\"width:550px;\">");
            sb.Append(text);
            sb.Append("</div>");

            sb.Append("</td></tr></table>");
            sb.Append("</div>");

            AjaxResponse resp = new AjaxResponse();

            resp.rs1 = sb.ToString();
            return(resp);
        }
        private void InitProfile(ProfileHelper profileHelper)
        {
            Profile = profileHelper.UserInfo;

            ProfileIsMe    = Profile.IsMe();
            ProfileIsOwner = Profile.IsOwner();
            ProfileIsAdmin = Profile.IsAdmin();

            ProfileIsAnyModuleAdmin = Profile.GetListAdminModules().Any();

            ProfileIsVisitor = Profile.IsVisitor();
            ProfileIsLdap    = Profile.IsLDAP();
            ProfileIsSso     = Profile.IsSSO();

            ProfilePath = CommonLinkUtility.GetUserProfile(Profile.ID);

            ProfileRole = GetRole();
        }
Пример #25
0
        private List <object> GetAdminsData(List <UserInfo> users)
        {
            var data = new List <object>();

            foreach (var ui in users)
            {
                GroupInfo dep = ui.GetUserDepartment();
                data.Add(new
                {
                    UserName = ui.DisplayUserName(),
                    UserPost = EncodeElement(ui.Title),
                    UserUrl  = CommonLinkUtility.GetUserProfile(ui.ID, ProductID),
                    PhotoUrl = ui.GetSmallPhotoURL(),
                    DepName  = (dep == null ? "" : EncodeElement(dep.Name)),
                    DepUrl   = (dep == null ? "" : CommonLinkUtility.GetDepartment(ProductID, dep.ID))
                });
            }
            return(data);
        }
Пример #26
0
        private void BindUserList()
        {
            var master = CoreContext.UserManager.GetUsers((CoreContext.UserManager.GetDepartmentManager(DepId)));

            ucMasterUserCard.EmployeeInfo          = master;
            ucMasterUserCard.EmployeeUrl           = CommonLinkUtility.GetUserProfile(master.ID, _productID);
            ucMasterUserCard.EmployeeDepartmentUrl = CommonLinkUtility.GetUserDepartment(master.ID, _productID);
            ucMasterUserCard.Height = new Unit("100%");


            List <UserInfo> list = new List <UserInfo>();

            list.AddRange(CoreContext.UserManager.GetUsersByGroup(DepId));
            list = list.SortByUserName();

            _userSelector.SelectedUsers.AddRange(list.ConvertAll <Guid>(u => u.ID));

            rptEmployeesList.DataSource = list;
            rptEmployeesList.DataBind();
        }
Пример #27
0
        public object AddAdmin(Guid id)
        {
            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            var user = CoreContext.UserManager.GetUsers(id);

            WebItemSecurity.SetProductAdministrator(Guid.Empty, id, true);

            var result = new
            {
                id           = user.ID,
                smallFotoUrl = user.GetSmallPhotoURL(),
                displayName  = user.DisplayUserName(),
                title        = user.Title.HtmlEncode(),
                userUrl      = CommonLinkUtility.GetUserProfile(user.ID, new Guid()),
                accessList   = GetAccessList(user.ID)
            };

            return(result);
        }
Пример #28
0
        private static CommentInfo GetCommentInfo(Comment comment)
        {
            var info = new CommentInfo
            {
                CommentID             = comment.Id.ToString(),
                UserID                = comment.UserId,
                TimeStamp             = comment.Date,
                TimeStampStr          = comment.Date.Ago(),
                IsRead                = true,
                Inactive              = comment.Inactive,
                CommentBody           = HtmlUtility.GetFull(comment.Body),
                UserFullName          = DisplayUserSettings.GetFullUserName(comment.UserId),
                UserProfileLink       = CommonLinkUtility.GetUserProfile(comment.UserId),
                UserAvatarPath        = UserPhotoManager.GetBigPhotoURL(comment.UserId),
                IsEditPermissions     = CommunitySecurity.CheckPermissions(new WikiObjectsSecurityObject(comment), ASC.Web.Community.Wiki.Common.Constants.Action_EditRemoveComment),
                IsResponsePermissions = CommunitySecurity.CheckPermissions(ASC.Web.Community.Wiki.Common.Constants.Action_AddComment),
                UserPost              = CoreContext.UserManager.GetUsers(comment.UserId).Title
            };

            return(info);
        }
Пример #29
0
        private static CommentInfo GetCommentInfo(FeedComment comment)
        {
            var info = new CommentInfo
            {
                CommentID             = comment.Id.ToString(CultureInfo.CurrentCulture),
                UserID                = new Guid(comment.Creator),
                TimeStamp             = comment.Date,
                TimeStampStr          = comment.Date.Ago(),
                IsRead                = true,
                Inactive              = comment.Inactive,
                CommentBody           = comment.Comment,
                UserFullName          = DisplayUserSettings.GetFullUserName(new Guid(comment.Creator)),
                UserProfileLink       = CommonLinkUtility.GetUserProfile(comment.Creator),
                UserAvatarPath        = UserPhotoManager.GetBigPhotoURL(new Guid(comment.Creator)),
                IsEditPermissions     = CommunitySecurity.CheckPermissions(comment, NewsConst.Action_Edit),
                IsResponsePermissions = CommunitySecurity.CheckPermissions(NewsConst.Action_Comment),
                UserPost              = CoreContext.UserManager.GetUsers((new Guid(comment.Creator))).Title
            };

            return(info);
        }
Пример #30
0
        public EmployeeWraper(UserInfo userInfo, ApiContext httpContext)
        {
            Id          = userInfo.ID;
            DisplayName = DisplayUserSettings.GetFullUserName(userInfo);
            if (!string.IsNullOrEmpty(userInfo.Title))
            {
                Title = userInfo.Title;
            }

            var userInfoLM = userInfo.LastModified.GetHashCode();

            if (httpContext.Check("avatarSmall"))
            {
                AvatarSmall = UserPhotoManager.GetSmallPhotoURL(httpContext.Tenant.TenantId, userInfo.ID, out var isdef) + (isdef ? "" : $"?_={userInfoLM}");
            }

            if (Id != Guid.Empty)
            {
                var profileUrl = CommonLinkUtility.GetUserProfile(userInfo, false);
                ProfileUrl = CommonLinkUtility.GetFullAbsolutePath(httpContext.HttpContext, profileUrl);
            }
        }