Esempio n. 1
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));
            }
        }
Esempio n. 2
0
        public static SideNavigator GetEmployeeNavigation()
        {
            var navigator = new SideNavigator();

            navigator.Controls.Add(new NavigationItem()
            {
                Name = CustomNamingPeople.Substitute <Resources.Resource>("ActiveEmployeesTitle"),
                URL  = CommonLinkUtility.GetEmployees(CommonLinkUtility.GetProductID())
            });

            navigator.Controls.Add(new NavigationItem()
            {
                Name = CustomNamingPeople.Substitute <Resources.Resource>("DisableEmployeesTitle"),
                URL  = CommonLinkUtility.GetEmployees(CommonLinkUtility.GetProductID(), EmployeeStatus.Terminated)
            });

            navigator.Controls.Add(new NavigationItem()
            {
                Name = CustomNamingPeople.Substitute <Resources.Resource>("PendingEmployeesTitle"),
                URL  = CommonLinkUtility.GetEmployees(CommonLinkUtility.GetProductID(), EmployeeActivationStatus.Pending)
            });



            return(navigator);
        }
Esempio n. 3
0
        protected string GetMasterRenderLink(GroupInfo group)
        {
            var pid     = CommonLinkUtility.GetProductID();
            var dephead = CoreContext.UserManager.GetUsers((CoreContext.UserManager.GetDepartmentManager(group.ID)));

            return(dephead == null || dephead == Constants.LostUser ? "" : dephead.RenderProfileLink(pid));
        }
Esempio n. 4
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (AutoFill)
            {
                if (string.IsNullOrEmpty(ProductId))
                {
                    ProductId = CommonLinkUtility.GetProductID().ToString("D");
                }
                if (string.IsNullOrEmpty(ModuleId))
                {
                    IProduct product;
                    IModule  module;
                    CommonLinkUtility.GetLocationByRequest(out product, out module);
                    if (module != null)
                    {
                        ModuleId = module.ID.ToString("D");
                    }
                }
            }

            writer.Write(Services.WhatsNew.feed.RenderRssMeta(
                             Title,
                             ProductId,
                             ModuleId,
                             ContentOnly? new int?(UserActivityConstants.ContentActionType): null,
                             ContainerId));
        }
Esempio n. 5
0
        protected string GetEmployeeSectorUrl(UserInfo ui)
        {
            if (ui == null)
            {
                return("");
            }
            var pid = CommonLinkUtility.GetProductID();

            return(CommonLinkUtility.GetUserDepartment(ui.ID, pid));
        }
        private void InitProductSettingsInlineScript()
        {
            var isAdmin = WebItemSecurity.IsProductAdministrator(CommonLinkUtility.GetProductID(), SecurityContext.CurrentAccount.ID);

            var script = new StringBuilder();

            script.AppendFormat("window.ASC.Resources.Master.IsProductAdmin={0};", isAdmin.ToString().ToLowerInvariant());

            Page.RegisterInlineScript(script.ToString(), true, false);
        }
Esempio n. 7
0
        private void InitProductSettingsInlineScript()
        {
            var isAdmin = WebItemSecurity.IsProductAdministrator(CommonLinkUtility.GetProductID(), SecurityContext.CurrentAccount.ID);

            if (!isAdmin)
            {
                isAdmin = WebItemSecurity.IsProductAdministrator(CommonLinkUtility.GetAddonID(), SecurityContext.CurrentAccount.ID);
            }

            RegisterInlineScript(string.Format("window.ASC.Resources.Master.IsProductAdmin={0};", isAdmin.ToString().ToLowerInvariant()), true, false);
        }
Esempio n. 8
0
        static object GetCurrentProductUrl()
        {
            var product = ProductManager.Instance[CommonLinkUtility.GetProductID()];

            if (product == null)
            {
                return(CommonLinkUtility.GetFullAbsolutePath("~"));
            }
            else
            {
                return(product.StartURL);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            EmployeeSiteNavigator.HeaderCSSClass = "studioSideBoxActionsHeader";
            EmployeeSiteNavigator.BodyCSSClass   = "studioSideBoxNavigationBody";
            EmployeeSiteNavigator.ImageURL       = WebImageSupplier.GetAbsoluteWebPath("home.png");
            EmployeeSiteNavigator.Title          = CustomNamingPeople.Substitute <Resources.Resource>("Departments");

            _productID = CommonLinkUtility.GetProductID();
            if (!Page.IsPostBack)
            {
                categoryTree.ShowExpandCollapse = false;
                FillTree();
            }
        }
Esempio n. 10
0
 //new department
 private static void WriteAddDepartmentAction(Page page, SideActions actionsControl)
 {
     if (SecurityContext.CheckPermissions(ASC.Core.Users.Constants.Action_EditGroups))
     {
         var depAddControl = (DepartmentAdd)page.LoadControl(DepartmentAdd.Location);
         depAddControl.ProductID = CommonLinkUtility.GetProductID();
         actionsControl.Controls.Add(depAddControl);
         actionsControl.Controls.Add(new NavigationItem()
         {
             Name    = CustomNamingPeople.Substitute <Resources.Resource>("RegistryNewDepartmentButton"),
             URL     = "javascript:StudioManagement.AddDepartmentOpenDialog();",
             IsPromo = (SetupInfo.WorkMode == WorkMode.Promo)
         });
     }
 }
Esempio n. 11
0
        protected string RenderDepartment()
        {
            if (UserInfo.Status == EmployeeStatus.Terminated)
            {
                return(HttpUtility.HtmlEncode(UserInfo.Department ?? ""));
            }

            var dep = UserInfo.GetUserDepartment();

            if (dep != null)
            {
                return("<a href=\"" + CommonLinkUtility.GetDepartment(CommonLinkUtility.GetProductID(), dep.ID) + "\">" + HttpUtility.HtmlEncode(dep.Name) + "</a>");
            }

            return(HttpUtility.HtmlEncode(UserInfo.Department ?? ""));
        }
Esempio n. 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _productID = CommonLinkUtility.GetProductID();

            _userSelector            = Page.LoadControl(UserSelector.Location) as UserSelector;
            _userSelector.BehaviorID = "empSelector";
            var depName = CoreContext.GroupManager.GetGroupInfo(DepId).Name;

            if (depName.Length > 30)
            {
                depName = depName.Substring(0, 27) + "...";
            }
            _userSelector.SelectedUserListTitle = depName;

            if (!Page.IsPostBack)
            {
                BindUserList();
            }

            _userSelectorHolder.Controls.Add(_userSelector);
        }
Esempio n. 13
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (AutoFill)
            {
                if (string.IsNullOrEmpty(ProductId))
                {
                    ProductId = CommonLinkUtility.GetProductID().ToString("D");
                }
                if (string.IsNullOrEmpty(ModuleId))
                {
                    IProduct product;
                    IModule  module;
                    CommonLinkUtility.GetLocationByRequest(out product, out module);
                    if (module != null)
                    {
                        ModuleId = module.ID.ToString("D");
                    }
                }
            }

            writer.Write(Services.WhatsNew.feed.RenderRssMeta(Title, ProductId));
        }
Esempio n. 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (DebugInfo.ShowDebugInfo)
            {
                debugInfoPopUpContainer.Options.IsPopup = true;
            }

            if (Page is Auth || Page is _Default)
            {
                CurrentProductID = Guid.Empty;
            }
            else
            {
                CurrentProductID =
                    !String.IsNullOrEmpty(Request["productID"])
                        ? new Guid(Request["productID"])
                        : CommonLinkUtility.GetProductID();

                if (!String.IsNullOrEmpty(Request["moduleID"]))
                {
                    CurrentModuleID = new Guid(Request["moduleID"]);
                }
            }

            CurrentProduct = (IProduct)WebItemManager.Instance[CurrentProductID];

            if (SecurityContext.CurrentAccount.IsAuthenticated && !TenantStatisticsProvider.IsNotPaid())
            {
                Page.RegisterBodyScripts(ResolveUrl("~/UserControls/Common/TopStudioPanel/js/FeedReaderScripts.js"));
            }

            RenderVideoHandlers();

            if (!DisableSearch)
            {
                RenderSearchProducts();
                DisableSearch = DisableSearch || !SearchProducts.Any() || CoreContext.Configuration.YourDocs;
            }

            _guestInfoHolder.Visible = false;
            _userInfoHolder.Visible  =
                (!DisableUserInfo.HasValue || !DisableUserInfo.Value) &&
                SecurityContext.IsAuthenticated &&
                !(Page is Wizard);

            ShowTopPanelNavigation = SecurityContext.IsAuthenticated && !(Page is Wizard);

            if (SecurityContext.IsAuthenticated)
            {
                CurrentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            }

            TariffNotify = TenantExtra.GetTariffNotify();
            if (!SecurityContext.IsAuthenticated || !TenantExtra.EnableTarrifSettings || CoreContext.Configuration.YourDocs || CurrentUser.IsVisitor())
            {
                DisableTariffNotify = true;
                DisableTariff       = true;
            }
            else if (string.IsNullOrEmpty(TariffNotify))
            {
                DisableTariffNotify = true;
            }
            _customNavItems = WebItemManager.Instance.GetItems(WebZoneType.CustomProductList, ItemAvailableState.Normal);

            if (CurrentUser.IsVisitor())
            {
                _customNavItems.RemoveAll(item => item.ID == WebItemManager.MailProductID); // remove mail for guest
            }

            if (DisableProductNavigation)
            {
                _productListHolder.Visible = false;
            }
            else
            {
                var productsList = WebItemManager.Instance.GetItems(WebZoneType.TopNavigationProductList, ItemAvailableState.Normal); //.Where(pr => !CurrentProductID.Equals(pr.ID));
                DisplayModuleList           = productsList.Any() && !CoreContext.Configuration.YourDocs;
                _productRepeater.DataSource = productsList;

                _productRepeater.DataBind();

                var addons = _customNavItems.Where(pr => ((pr.ID == WebItemManager.CalendarProductID || pr.ID == WebItemManager.TalkProductID || pr.ID == WebItemManager.MailProductID)));
                //if (GetCurrentWebItem != null)
                //    _addons = _addons.Where(pr => pr.ID != GetCurrentWebItem.ID);
                _addonRepeater.DataSource = addons.ToList();
                _addonRepeater.DataBind();

                MoreProductsRepeater.DataBind();
            }

            foreach (var item in _customNavItems)
            {
                var render = WebItemManager.Instance[item.ID] as IRenderCustomNavigation;
                if (render == null)
                {
                    continue;
                }

                try
                {
                    var control = render.LoadCustomNavigationControl(Page);
                    if (control != null)
                    {
                        _customNavControls.Controls.Add(control);
                    }
                }
                catch (Exception ex)
                {
                    log4net.LogManager.GetLogger("ASC.Web.Studio").Error(ex);
                }
            }
        }
Esempio n. 15
0
        private ITagValue[] GetNotifyTags(string pageName, string patternType, Comment comment)
        {
            var page = GetPage(pageName);

            if (page == null)
            {
                return(null);
            }

            var user    = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            var defPage = VirtualPathUtility.ToAbsolute(WikiManager.ViewVirtualPath);

            var tags = new List <ITagValue>
            {
                new TagValue(Constants.TagPageName, String.IsNullOrEmpty(page.PageName) ? WikiResource.MainWikiCaption : page.PageName),
                new TagValue(Constants.TagURL, CommonLinkUtility.GetFullAbsolutePath(ActionHelper.GetViewPagePath(defPage, page.PageName))),
                new TagValue(Constants.TagUserName, user.DisplayUserName()),
                new TagValue(Constants.TagUserURL, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(user.ID, CommonLinkUtility.GetProductID()))),
                new TagValue(Constants.TagDate, TenantUtil.DateTimeNow()),
                new TagValue(Constants.TagPostPreview, HtmlUtility.GetText(EditPage.ConvertWikiToHtml(page.PageName, page.Body, defPage, WikiSection.Section.ImageHangler.UrlFormat, CoreContext.TenantManager.GetCurrentTenant().TenantId), 120)),
            };

            if (comment != null && !string.IsNullOrEmpty(pageName))
            {
                ReplyToTagProvider.Comment("wiki", pageName, comment.Id.ToString());
            }

            if (!string.IsNullOrEmpty(patternType))
            {
                tags.Add(new TagValue(Constants.TagChangePageType, patternType));
            }
            if (comment != null)
            {
                tags.Add(new TagValue(Constants.TagCommentBody, comment.Body));
            }

            return(tags.ToArray());
        }
Esempio n. 16
0
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (CheckWizardCompleted)
            {
                var s = WizardSettings.Load();
                if (!s.Completed)
                {
                    Response.Redirect("~/Wizard.aspx");
                }
            }

            //check auth
            if (!SecurityContext.IsAuthenticated &&
                !AuthByCookies() &&
                !MayNotAuth)
            {
                if (TenantAccessSettings.Load().Anyone)
                {
                    OutsideAuth();
                }
                else
                {
                    var refererURL = GetRefererUrl();
                    Session["refererURL"] = refererURL;
                    var authUrl = "~/Auth.aspx";
                    if (Request.DesktopApp())
                    {
                        authUrl += "?desktop=" + Request["desktop"];
                    }
                    Response.Redirect(authUrl, true);
                }
            }

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

            if (!MayNotPaid &&
                TenantExtra.EnableTarrifSettings &&
                (TenantStatisticsProvider.IsNotPaid() || TenantExtra.UpdatedWithoutLicense) &&
                WarmUp.Instance.CheckCompleted() && Request.QueryString["warmup"] != "true")
            {
                if (TariffSettings.HidePricingPage && !user.IsAdmin())
                {
                    Response.StatusCode = (int)HttpStatusCode.PaymentRequired;
                    Response.End();
                }
                else
                {
                    Response.Redirect(TenantExtra.GetTariffPageLink() + (Request.DesktopApp() ? "?desktop=true" : ""), true);
                }
            }

            if (!MayPhoneNotActivate &&
                SecurityContext.IsAuthenticated)
            {
                if (StudioSmsNotificationSettings.IsVisibleSettings && StudioSmsNotificationSettings.Enable &&
                    (string.IsNullOrEmpty(user.MobilePhone) || user.MobilePhoneActivationStatus == MobilePhoneActivationStatus.NotActivated))
                {
                    Response.Redirect(CommonLinkUtility.GetConfirmationUrl(user.Email, ConfirmType.PhoneActivation), true);
                }

                if (TfaAppAuthSettings.IsVisibleSettings && TfaAppAuthSettings.Enable &&
                    !TfaAppUserSettings.EnableForUser(user.ID))
                {
                    Response.Redirect(CommonLinkUtility.GetConfirmationUrl(user.Email, ConfirmType.TfaActivation), true);
                }
            }

            //check disable and public
            var webitem          = CommonLinkUtility.GetWebItemByUrl(Request.Url.ToString());
            var parentIsDisabled = false;

            if (webitem != null && webitem.IsSubItem())
            {
                var parentItemID = WebItemManager.Instance.GetParentItemID(webitem.ID);
                parentIsDisabled = WebItemManager.Instance[parentItemID].IsDisabled();
            }

            if (webitem != null && (webitem.IsDisabled() || parentIsDisabled) && !MayNotAuth)
            {
                if (webitem.ID == WebItemManager.PeopleProductID &&
                    string.Equals(GetType().BaseType.FullName, "ASC.Web.People.Profile"))
                {
                    Response.Redirect("~/My.aspx", true);
                }

                Response.Redirect("~/", true);
            }

            if (SecurityContext.IsAuthenticated && !CoreContext.Configuration.Personal)
            {
                try
                {
                    StatisticManager.SaveUserVisit(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID, CommonLinkUtility.GetProductID());
                }
                catch (Exception exc)
                {
                    Log.Error("failed save user visit", exc);
                }
            }
        }
Esempio n. 17
0
        private void SendRecentBookmarkUpdates(Bookmark b)
        {
            var url  = ModifyBookmarkUrl(b);
            var tags = new[] {
                new TagValue(BookmarkSubscriptionConstants.BookmarkTitle, b.Name),
                new TagValue(BookmarkSubscriptionConstants.BookmarkUrl, url),
                new TagValue(BookmarkSubscriptionConstants.UserURL, string.Format("\"{0}\":\"{1}\"", CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(b.UserCreatorID, CommonLinkUtility.GetProductID())), DisplayUserSettings.GetFullUserName(b.UserCreatorID))),//TODO: Rewrite patterns
                new TagValue(BookmarkSubscriptionConstants.Date, b.Date.ToShortString()),
                new TagValue(BookmarkSubscriptionConstants.BookmarkDescription, b.Description), GetReplyToTag(b, null)
            };

            string objectID = BookmarkingBusinessConstants.SubscriptionRecentBookmarkID;

            var action = BookmarkingBusinessConstants.NotifyActionNewBookmark;

            SendBookmarkNoticeAsync(action, objectID, tags);
        }
Esempio n. 18
0
 protected string GetEmployeeUrl(UserInfo ui)
 {
     return(ui == null ? "" : CommonLinkUtility.GetUserProfile(ui.ID, CommonLinkUtility.GetProductID()));
 }
Esempio n. 19
0
        private ITagValue[] GetCategoryNotifyTags(string objectId, string pageName)
        {
            var page = GetPage(pageName);

            if (page == null)
            {
                return(null);
            }

            var user        = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            var defPageHref = VirtualPathUtility.ToAbsolute(WikiManager.ViewVirtualPath);

            var tags = new List <ITagValue>
            {
                new TagValue(Constants.TagPageName, page.PageName),
                new TagValue(Constants.TagURL, CommonLinkUtility.GetFullAbsolutePath(ActionHelper.GetViewPagePath(defPageHref, page.PageName))),
                new TagValue(Constants.TagUserName, user.DisplayUserName()),
                new TagValue(Constants.TagUserURL, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(user.ID, CommonLinkUtility.GetProductID()))),
                new TagValue(Constants.TagDate, TenantUtil.DateTimeNow()),
                new TagValue(Constants.TagPostPreview, HtmlUtility.GetText(EditPage.ConvertWikiToHtml(page.PageName, page.Body, defPageHref, WikiSection.Section.ImageHangler.UrlFormat, CoreContext.TenantManager.GetCurrentTenant().TenantId), 120)),
                new TagValue(Constants.TagCatName, objectId),
                ReplyToTagProvider.Comment("wiki", pageName)
            };

            return(tags.ToArray());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var currentProductId = string.IsNullOrEmpty(Request["productID"]) ? CommonLinkUtility.GetProductID() : new Guid(Request["productID"]);

            CurrentProduct = WebItemManager.Instance[currentProductId] as IProduct;

            if (CurrentProduct != null)
            {
                CurrentProductClassName = CurrentProduct.ProductClassName;
                CurrentProductName      = CurrentProduct.Name;
            }
            else
            {
                GetAddonNameAndClass();
            }

            if (!DisableSearch)
            {
                RenderSearchProducts();
                DisableSearch = DisableSearch || !SearchProducts.Any() || CoreContext.Configuration.Personal;
            }

            if (SecurityContext.IsAuthenticated)
            {
                CurrentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

                if (CurrentUser.IsOutsider())
                {
                    DisableUserInfo = true;
                }

                UserInfoVisible = !DisableUserInfo.HasValue || !DisableUserInfo.Value;
            }

            if (!SecurityContext.IsAuthenticated ||
                !TenantExtra.EnableTariffSettings ||
                CoreContext.Configuration.Personal ||
                CurrentUser.IsVisitor() ||
                (!CurrentUser.IsAdmin() && (TariffSettings.HidePricingPage || CoreContext.Configuration.Standalone)))
            {
                DisableTariff = true;
            }

            _customNavItems = WebItemManager.Instance.GetItems(WebZoneType.CustomProductList, ItemAvailableState.Normal);

            if (DisableProductNavigation && SecurityContext.IsAuthenticated)
            {
                _productListHolder.Visible = false;
            }
            else
            {
                var productsList = WebItemManager.Instance.GetItems(WebZoneType.TopNavigationProductList, ItemAvailableState.Normal);

                DisplayModuleList = productsList.Any() && !CoreContext.Configuration.Personal;

                Modules       = new List <IWebItem>();
                CustomModules = new List <IWebItem>();

                foreach (var webItem in productsList)
                {
                    if (webItem.ID != WebItemManager.DocumentsProductID &&
                        webItem.ID != WebItemManager.ProjectsProductID &&
                        webItem.ID != WebItemManager.CRMProductID &&
                        webItem.ID != WebItemManager.PeopleProductID &&
                        webItem.ID != WebItemManager.CommunityProductID)
                    {
                        CustomModules.Add(webItem);
                    }
                }

                var currentItem = productsList.Find(r => r.ID == WebItemManager.DocumentsProductID);
                if (currentItem != null)
                {
                    Modules.Add(currentItem);
                    productsList.Remove(currentItem);
                }
                currentItem = productsList.Find(r => r.ID == WebItemManager.ProjectsProductID);
                if (currentItem != null)
                {
                    Modules.Add(currentItem);
                    productsList.Remove(currentItem);
                }
                currentItem = productsList.Find(r => r.ID == WebItemManager.CRMProductID);
                if (currentItem != null)
                {
                    Modules.Add(currentItem);
                    productsList.Remove(currentItem);
                }
                if (CurrentUser != null && !CurrentUser.IsOutsider())
                {
                    currentItem = _customNavItems.Find(r => r.ID == WebItemManager.MailProductID);
                    if (currentItem != null)
                    {
                        Modules.Add(currentItem);
                    }
                }
                currentItem = productsList.Find(r => r.ID == WebItemManager.PeopleProductID);
                if (currentItem != null)
                {
                    Modules.Add(currentItem);
                    productsList.Remove(currentItem);
                }
                currentItem = productsList.Find(r => r.ID == WebItemManager.CommunityProductID);
                if (currentItem != null)
                {
                    Modules.Add(currentItem);
                    productsList.Remove(currentItem);
                }

                var isEnabledTalk = ConfigurationManagerExtension.AppSettings["web.talk"] ?? "false";
                Addons = _customNavItems
                         .Where(item =>
                                (item.ID == WebItemManager.CalendarProductID ||
                                 (item.ID == WebItemManager.TalkProductID && isEnabledTalk == "true")))
                         .OrderBy(item => item.Context.DefaultSortOrder);

                CustomNavigationItems = CustomNavigationSettings.Load().Items.Where(x => x.ShowInMenu);
            }

            foreach (var item in _customNavItems)
            {
                var render = WebItemManager.Instance[item.ID] as IRenderCustomNavigation;
                if (render == null)
                {
                    continue;
                }

                try
                {
                    var control = render.LoadCustomNavigationControl(Page);
                    if (control != null)
                    {
                        _customNavControls.Controls.Add(control);
                    }
                }
                catch (Exception ex)
                {
                    LogManager.GetLogger("ASC.Web.Studio").Error(ex);
                }
            }

            if (!DisableTariff)
            {
                var tariff = TenantExtra.GetCurrentTariff();
                TariffDays = tariff.DueDate.Date.Subtract(DateTime.Today).Days;

                if (tariff.State == TariffState.Trial && TariffDays >= 0)
                {
                    DisplayTrialCountDays = true;
                }
            }

            Settings = CompanyWhiteLabelSettings.Instance;

            ShowAppsNavItem = SetupInfo.IsVisibleSettings("AppsNavItem");

            ShowDesktopNavItem = !CoreContext.Configuration.CustomMode;

            if (!DisableGift)
            {
                DisableGift = !SecurityContext.IsAuthenticated ||
                              CoreContext.Configuration.Personal ||
                              !TenantExtra.Opensource ||
                              string.IsNullOrEmpty(SetupInfo.ControlPanelUrl) ||
                              OpensourceGiftSettings.LoadForCurrentUser().Readed;
            }

            Startup = !CoreContext.Configuration.CustomMode && TenantExtra.Saas && TenantExtra.GetTenantQuota().Free;
        }
Esempio n. 21
0
 protected Guid GetProductID()
 {
     return(CommonLinkUtility.GetProductID());
 }
Esempio n. 22
0
        protected void Page_PreInit(object sender, EventArgs e)
        {
            if (CoreContext.Configuration.Standalone && !(this is Wizard))
            {
                var s = SettingsManager.Instance.LoadSettings <WizardSettings>(TenantProvider.CurrentTenantID);
                if (!s.Completed)
                {
                    Response.Redirect("~/wizard.aspx");
                }
            }

            //check auth
            if (!SecurityContext.IsAuthenticated &&
                !AuthByCookies() &&
                !MayNotAuth)
            {
                var refererURL = GetRefererUrl();
                Session["refererURL"] = refererURL;
                Response.Redirect("~/auth.aspx", true);
            }

            if (!MayNotPaid && TenantStatisticsProvider.IsNotPaid())
            {
                Response.Redirect(TenantExtra.GetTariffPageLink(), true);
            }
            else if (SecurityContext.IsAuthenticated &&
                     StudioSmsNotificationSettings.IsVisibleSettings &&
                     StudioSmsNotificationSettings.Enable &&
                     !MayPhoneNotActivate)
            {
                var user = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);

                if (!CoreContext.UserManager.IsUserInGroup(SecurityContext.CurrentAccount.ID, Constants.GroupAdmin.ID) &&
                    (string.IsNullOrEmpty(user.MobilePhone) ||
                     user.MobilePhoneActivationStatus == MobilePhoneActivationStatus.NotActivated))
                {
                    Response.Redirect(CommonLinkUtility.GetConfirmationUrl(user.Email, ConfirmType.PhoneActivation));
                }
            }

            //check disable and public
            var webitem          = CommonLinkUtility.GetWebItemByUrl(Request.Url.ToString());
            var parentIsDisabled = false;

            if (webitem != null && webitem.IsSubItem())
            {
                var parentItemID = WebItemManager.Instance.GetParentItemID(webitem.ID);
                parentIsDisabled = WebItemManager.Instance[parentItemID].IsDisabled();
            }

            if (webitem != null && (webitem.IsDisabled() || parentIsDisabled) && !MayNotAuth)
            {
                if (webitem.ID == new Guid("{F4D98AFD-D336-4332-8778-3C6945C81EA0}") &&
                    string.Equals(GetType().BaseType.FullName, "ASC.Web.People.Profile"))
                {
                    Response.Redirect("~/my.aspx", true);
                }

                Response.Redirect("~/", true);
            }

            if (SecurityContext.IsAuthenticated)
            {
                try
                {
                    StatisticManager.SaveUserVisit(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID, CommonLinkUtility.GetProductID());
                }
                catch (Exception exc)
                {
                    Log.Error("failed save user visit", exc);
                }
            }
        }
Esempio n. 23
0
 internal string GetUserProfileLink(Guid userID)
 {
     return(CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(userID, CommonLinkUtility.GetProductID())));
 }
Esempio n. 24
0
        public void SavePost(Post post, bool isNew, bool notifyComments)
        {
            if (isNew)
            {
                CommunitySecurity.DemandPermissions(
                    new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(post.UserID)),
                    ASC.Blogs.Core.Constants.Action_AddPost);
            }
            else
            {
                CommunitySecurity.DemandPermissions(
                    new PersonalBlogSecObject(CoreContext.UserManager.GetUsers(post.UserID)),
                    Constants.Action_EditRemovePost);
            }

            _storage.GetPostDao().SavePost(post);
            if (isNew)
            {
                var initiatorInterceptor = new InitiatorInterceptor(new DirectRecipient(post.UserID.ToString(), ""));
                try
                {
                    NotifyClient.BeginSingleRecipientEvent("asc_blog");
                    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(post.UserID)),
                        new TagValue(ASC.Blogs.Core.Constants.TagUserURL,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         CommonLinkUtility.GetUserProfile(post.UserID,
                                                                          CommonLinkUtility.GetProductID()))),
                        new TagValue(ASC.Blogs.Core.Constants.TagDate,
                                     string.Format("{0:d} {0:t}", post.Datetime)),
                        new TagValue(ASC.Blogs.Core.Constants.TagURL,
                                     CommonLinkUtility.GetFullAbsolutePath(
                                         ASC.Blogs.Core.Constants.ViewBlogPageUrl +
                                         "?blogid=" + post.ID.ToString())),
                        GetReplyToTag(Guid.Empty, post)
                    };

                    NotifyClient.SendNoticeAsync(
                        ASC.Blogs.Core.Constants.NewPost,
                        null,
                        null,
                        tags.ToArray());


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

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

                BlogUserActivityPublisher.AddPost(post); //TODO:
            }
            else
            {
                BlogUserActivityPublisher.EditPost(post, SecurityContext.CurrentAccount.ID);
            }
            if (notifyComments)
            {
                ASC.Notify.Model.ISubscriptionProvider subscriptionProvider = NotifySource.GetSubscriptionProvider();

                subscriptionProvider.Subscribe(
                    ASC.Blogs.Core.Constants.NewComment,
                    post.ID.ToString(),
                    NotifySource.GetRecipientsProvider().
                    GetRecipient(post.UserID.ToString())
                    );
            }
        }
Esempio n. 25
0
 public static string GetUserProfilePageURL(this UserInfo userInfo)
 {
     return(CommonLinkUtility.GetUserProfile(userInfo.ID, CommonLinkUtility.GetProductID()));
 }
Esempio n. 26
0
 public static string RenderRssMeta(string title)
 {
     return(RenderRssMeta(title, CommonLinkUtility.GetProductID().ToString("D")));
 }
Esempio n. 27
0
 protected string GetEmployeeUrl(UserInfo ui)
 {
     return(ui.GetUserProfilePageURL(CommonLinkUtility.GetProductID()));
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (this.Page is Auth || this.Page is _Default)
            {
                _currentProductID = Guid.Empty;
            }
            else
            {
                _currentProductID = CommonLinkUtility.GetProductID();
            }

            CurrentProduct = ProductManager.Instance[_currentProductID];

            InitScripts();

            if (!DisableUserInfo.HasValue)
            {
                _guestInfoHolder.Visible = !(Page is Auth) && CoreContext.TenantManager.GetCurrentTenant().Public&& !SecurityContext.IsAuthenticated;
                _userInfoHolder.Visible  = SecurityContext.IsAuthenticated && !(Page is Wizard);
            }
            else
            {
                _guestInfoHolder.Visible = !DisableUserInfo.Value && !(Page is Auth) && CoreContext.TenantManager.GetCurrentTenant().Public&& !SecurityContext.IsAuthenticated;
                _userInfoHolder.Visible  = !DisableUserInfo.Value && SecurityContext.IsAuthenticated && !(Page is Wizard);
            }

            if (SecurityContext.IsAuthenticated)
            {
                CurrentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            }

            if (this.Page is Auth || this.Page is _Default)
            {
                DisableProductNavigation = true;
            }

            var tariff      = CoreContext.TenantManager.GetTariff(CoreContext.TenantManager.GetCurrentTenant().TenantId);
            var tenantState = tariff.State;

            if ((this.Page is Auth) || ((tenantState.Equals(TariffState.Trial) == false) && (tenantState.Equals(TariffState.NotPaid) == false)))
            {
                DisableTrialPeriod = true;
            }

            if (((tenantState.Equals(TariffState.Trial)) && (!IsAdministrator)))
            {
                DisableTrialPeriod = true;
            }
            _customNavItems = WebItemManager.Instance.GetItems(WebZoneType.CustomProductList);

            if (DisableProductNavigation)
            {
                _productListHolder.Visible = false;
            }
            else
            {
                var productsList = WebItemManager.Instance.GetItems(WebZoneType.TopNavigationProductList);
                DisplayModuleList           = productsList.Any();
                _productRepeater.DataSource = productsList;
                _productRepeater.DataBind();

                var _addons = _customNavItems.Where(pr => ((pr.ID == new Guid("{32D24CB5-7ECE-4606-9C94-19216BA42086}") || pr.ID == new Guid("{2A923037-8B2D-487b-9A22-5AC0918ACF3F}"))));
                //if (GetCurrentWebItem != null)
                //    _addons = _addons.Where(pr => pr.ID != GetCurrentWebItem.ID);
                _addonRepeater.DataSource = _addons.ToList();
                _addonRepeater.DataBind();


                MoreProductsRepeater.DataBind();
            }

            DisableSearch         = (DisableSearch || _handlerItems == null || _handlerItems.Count == 0);
            _searchHolder.Visible = !DisableSearch;

            if (NavigationItems.Count == 0)
            {
                _navItemRepeater.Visible = false;
            }
            else
            {
                _navItemRepeater.DataSource = NavigationItems;
                _navItemRepeater.DataBind();
            }

            if (String.IsNullOrEmpty(_title) && DisableSearch)
            {
                _contentSectionHolder.Visible = false;
            }

            foreach (var item in _customNavItems)
            {
                var render = WebItemManager.Instance[item.ID] as IRenderCustomNavigation;
                if (render != null)
                {
                    try
                    {
                        var control = render.LoadCustomNavigationControl(this.Page);
                        if (control != null)
                        {
                            _customNavControls.Controls.Add(control);
                        }
                    }
                    catch (Exception ex)
                    {
                        log4net.LogManager.GetLogger("ASC.Web.Studio").Error(ex);
                    }
                }
            }

            myToolsItemRepeater.DataSource = WebItemManager.Instance.GetItems(WebZoneType.MyTools).OfType <IRenderMyTools>();
            myToolsItemRepeater.DataBind();
        }
Esempio n. 29
0
        protected void Page_PreInit(object sender, EventArgs e)
        {
            //check if cookie from this portal
            if (SecurityContext.CurrentAccount is IUserAccount &&
                ((IUserAccount)SecurityContext.CurrentAccount).Tenant != CoreContext.TenantManager.GetCurrentTenant().TenantId)
            {
                SecurityContext.Logout();
                Response.Redirect("~/");
            }

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

            if (currentUser == Constants.LostUser || currentUser.Status != EmployeeStatus.Active)
            {
                SecurityContext.Logout();
                Response.Redirect("~/");
            }

            ProcessSecureFilter();

            var wizardSettings = SettingsManager.Instance.LoadSettings <WizardSettings>(TenantProvider.CurrentTenantID);

            if (Request["first"] == "1" && !string.IsNullOrEmpty(Request["id"]) && wizardSettings.Completed)
            {
                // wizardSettings.Completed - open source, Request["first"] - cloud
                wizardSettings.Completed = false;
                SettingsManager.Instance.SaveSettings(wizardSettings, TenantProvider.CurrentTenantID);
            }

            var smsAuthSettings = SettingsManager.Instance.LoadSettings <StudioSmsNotificationSettings>(TenantProvider.CurrentTenantID);

            if (!wizardSettings.Completed && !(this is confirm))
            {
                var successAuth = SecurityContext.IsAuthenticated;
                if (!successAuth)
                {
                    var cookie = Request["id"] ?? CookiesManager.GetCookies(CookiesType.AuthKey);
                    if (!string.IsNullOrEmpty(cookie))
                    {
                        successAuth = AuthByCookies(cookie);
                    }
                    if (!successAuth)
                    {
                        try
                        {
                            cookie      = SecurityContext.AuthenticateMe(UserManagerWrapper.AdminID.ToString(), "admin");
                            successAuth = true;
                        }
                        catch (System.Security.SecurityException)
                        {
                        }
                    }
                    if (successAuth)
                    {
                        CookiesManager.SetCookies(CookiesType.AuthKey, cookie);
                        WebItemManager.Instance.ItemGlobalHandlers.Login(SecurityContext.CurrentAccount.ID);
                    }
                }
                if (!successAuth && !(this is Auth))
                {
                    Response.Redirect("~/auth.aspx");
                }
                if (successAuth && !(this is Wizard))
                {
                    Response.Redirect("~/wizard.aspx");
                }
            }
            else if (smsAuthSettings.Enable && Session["UserTransferData"] != null && !(this is confirm))
            {
                Response.Redirect(String.Format("~/Confirm.aspx?type={0}", ((UserTransferData)Session["UserTransferData"]).MobilePhoneActivationStatus == MobilePhoneActivationStatus.NotActivated ? ConfirmType.PhoneActivation : ConfirmType.PhoneAuth));
            }

            else if (!SecurityContext.IsAuthenticated && wizardSettings.Completed && !(this is confirm))
            {
                //for demo
                if (SetupInfo.WorkMode == WorkMode.Promo)
                {
                    if (AutoAuthByPromo())
                    {
                        UserOnlineManager.Instance.RegistryOnlineUser(SecurityContext.CurrentAccount.ID);

                        Response.Redirect("~/");
                        return;
                    }
                }

                if (this is Auth && Session["refererURL"] == null && !string.IsNullOrEmpty(HttpContext.Current.Request.Params["id"]))
                {
                    var authCookie = HttpContext.Current.Request.Params["id"];
                    if (AuthByCookies(authCookie))
                    {
                        CookiesManager.SetCookies(CookiesType.AuthKey, authCookie);
                        var first = Request["first"] == "1";
                        if (first)
                        {
                            try
                            {
                                var tenant = CoreContext.TenantManager.GetCurrentTenant(false);
                                tenant.Name = Resources.Resource.StudioWelcomeHeader;
                                CoreContext.TenantManager.SaveTenant(tenant);
                            }
                            catch
                            {
                            }
                        }
                        Response.Redirect(VirtualPathUtility.ToAbsolute("~/") + (first ? "?first=1" : ""));
                        return;
                    }
                }

                if (!(this is Auth))
                {
                    var refererURL = Request.Url.AbsoluteUri;
                    if (!ValidateRefererUrl(refererURL))
                    {
                        refererURL = (string)Session["refererURL"];
                    }

                    if (!AutoAuthByCookies() && !CoreContext.TenantManager.GetCurrentTenant().Public)
                    {
                        Session["refererURL"] = refererURL;
                        Response.Redirect("~/auth.aspx");
                        return;
                    }
                }
            }

            else if (SecurityContext.IsAuthenticated && this is Auth && !this.IsLogout)
            {
                Response.Redirect("~/");
                return;
            }

            else if (this is Wizard && wizardSettings.Completed)
            {
                Response.Redirect("~/");
                return;
            }

            //check disable and public
            var webitem = CommonLinkUtility.GetWebItemByUrl(Request.Url.ToString());

            if (webitem != null && webitem.IsDisabled())
            {
                Response.Redirect("~/");
                return;
            }


            if (SecurityContext.IsAuthenticated)
            {
                UserOnlineManager.Instance.RegistryOnlineUser(SecurityContext.CurrentAccount.ID);

                try
                {
                    StatisticManager.SaveUserVisit(TenantProvider.CurrentTenantID, SecurityContext.CurrentAccount.ID, CommonLinkUtility.GetProductID());
                }
                catch (Exception exc)
                {
                    Log.Error("failed save user visit", exc);
                }
            }

            CurrentSkin = WebSkin.GetUserSkin();
            Theme       = CurrentSkin.ASPTheme;


            #region Init common javascript resources

            var commonJavascriptResources = "CommonJavascriptResources";
            if (!Page.ClientScript.IsClientScriptBlockRegistered(commonJavascriptResources))
            {
                var script = string.Format(@"
var CommonJavascriptResources = {{
	CancelConfirmMessage : '{0}'
}};", Resources.Resource.CancelConfirmMessage.ReplaceSingleQuote());
                Page.ClientScript.RegisterClientScriptBlock(typeof(string), commonJavascriptResources, script, true);
            }

            #endregion

            PersonalHelper.TransferRequest(this);
        }
Esempio n. 30
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())
                    );
            }
        }