示例#1
0
        public static string GetUploadChunkLocationUrl(string uploadId)
        {
            var queryString = "?uid=" + uploadId;

            return(CommonLinkUtility.GetFullAbsolutePath(GetFileUploaderHandlerVirtualPath() + queryString));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.RegisterBodyScripts("~/UserControls/Management/DefaultPageSettings/js/defaultpage.js");

            DefaultPages = new List <DefaultStartPageWrapper>();

            var defaultPageSettings = StudioDefaultPageSettings.Load();

            DefaultProductID = defaultPageSettings.DefaultProductID;

            var products = WebItemManager.Instance.GetItemsAll <IProduct>().Where(p => p.Visible);

            foreach (var p in products)
            {
                var productInfo = WebItemSecurity.GetSecurityInfo(p.ID.ToString());
                if (productInfo.Enabled)
                {
                    DefaultPages.Add(new DefaultStartPageWrapper
                    {
                        ProductID   = p.ID,
                        DisplayName = p.Name,
                        ProductName = p.GetSysName(),
                        IsSelected  = DefaultProductID.Equals(p.ID)
                    });
                }
            }

            var addons        = WebItemManager.Instance.GetItemsAll <IAddon>().Where(a => a.Visible && a.ID != WebItemManager.VoipModuleID);
            var isEnabledTalk = ConfigurationManagerExtension.AppSettings["web.talk"] ?? "false";

            foreach (var a in addons)
            {
                var productInfo = WebItemSecurity.GetSecurityInfo(a.ID.ToString());
                if (a.GetSysName() == "talk" && isEnabledTalk == "false")
                {
                    continue;
                }
                if (productInfo.Enabled)
                {
                    DefaultPages.Add(new DefaultStartPageWrapper
                    {
                        ProductID   = a.ID,
                        DisplayName = a.Name,
                        ProductName = a.GetSysName(),
                        IsSelected  = DefaultProductID.Equals(a.ID)
                    });
                }
            }

            DefaultPages.Add(new DefaultStartPageWrapper
            {
                ProductID   = defaultPageSettings.FeedModuleID,
                DisplayName = Resources.UserControlsCommonResource.FeedTitle,
                ProductName = "feed",
                IsSelected  = DefaultProductID.Equals(defaultPageSettings.FeedModuleID)
            });

            DefaultPages.Add(new DefaultStartPageWrapper
            {
                ProductID   = Guid.Empty,
                DisplayName = Resources.Resource.DefaultPageSettingsChoiseOfProducts,
                ProductName = string.Empty,
                IsSelected  = DefaultProductID.Equals(Guid.Empty)
            });

            HelpLink = CommonLinkUtility.GetHelpLink();
        }
示例#3
0
 internal string RealUserProfileLinkResolver(string userID)
 {
     return UserProfileUrlResolver != null
                ? UserProfileUrlResolver(userID)
                : CommonLinkUtility.GetUserProfile(userID);
 }
 private static string GetMyStaffLink()
 {
     return(CommonLinkUtility.GetMyStaff(MyStaffType.General));
 }
示例#5
0
        private string GetMoreUrl(ISearchHandlerEx sh, ref Guid productID)
        {
            var path = sh.AbsoluteSearchURL;

            if (sh.ProductID.Equals(Guid.Empty) && !productID.Equals(Guid.Empty))
            {
                path = sh.AbsoluteSearchURL + (sh.AbsoluteSearchURL.IndexOf("?") != -1 ? "&" : "?") + CommonLinkUtility.GetProductParamsPair(productID);
            }

            path = path + (path.IndexOf("?") != -1 ? "&search=" : "?search=") + HttpUtility.UrlEncode(_searchText, Encoding.UTF8);

            return(path);
        }
        protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context)
        {
            return(new List <KeyValuePair <string, object> >(1)
            {
                RegisterObject(
                    new
                {
                    URL_OAUTH_BOX = Box.Location.ToLower(),
                    URL_OAUTH2_GOOGLE = ASC.Web.Studio.ThirdParty.Google.Location.ToLower(),
                    URL_OAUTH_DROPBOXV2 = Dropbox.Location.ToLower(),
                    URL_OAUTH_SKYDRIVE = OneDrive.Location.ToLower(),
                    URL_OAUTH_DOCUSIGN = Studio.ThirdParty.DocuSign.Location.ToLower(),
                    URL_OAUTH_DOCUSIGN_LINK = DocuSignLoginProvider.Instance.DocuSignHost,

                    URL_BASE = FilesLinkUtility.FilesBaseAbsolutePath,
                    URL_WCFSERVICE = PathProvider.GetFileServicePath,
                    URL_TEMPLATES_HANDLER = CommonLinkUtility.ToAbsolute("~/template.ashx") + "?id=" + PathProvider.TemplatePath + "&name=collection&ver=" + ClientSettings.ResetCacheKey,
                    URL_LOADER = CommonLinkUtility.ToAbsolute(FilesLinkUtility.FilesBaseVirtualPath + "loader.html"),

                    ADMIN = Global.IsAdministrator,
                    MAX_NAME_LENGTH = Global.MaxTitle,
                    CHUNK_UPLOAD_SIZE = SetupInfo.ChunkUploadSize,
                    UPLOAD_FILTER = Global.EnableUploadFilter,
                    ENABLE_UPLOAD_CONVERT = FileConverter.EnableAsUploaded,

                    FOLDER_ID_MY_FILES = Global.FolderMy,
                    FOLDER_ID_SHARE = Global.FolderShare,
                    FOLDER_ID_RECENT = Global.FolderRecent,
                    FOLDER_ID_FAVORITES = Global.FolderFavorites,
                    FOLDER_ID_TEMPLATES = Global.FolderTemplates,
                    FOLDER_ID_PRIVACY = Global.FolderPrivacy,
                    FOLDER_ID_COMMON_FILES = Global.FolderCommon,
                    FOLDER_ID_PROJECT = Global.FolderProjects,
                    FOLDER_ID_TRASH = Global.FolderTrash,

                    FileConstant.ShareLinkId,

                    AceStatusEnum = new
                    {
                        FileShare.None,
                        FileShare.ReadWrite,
                        FileShare.CustomFilter,
                        FileShare.Read,
                        FileShare.Restrict,
                        FileShare.Varies,
                        FileShare.Review,
                        FileShare.FillForms,
                        FileShare.Comment
                    },

                    FilterType = new
                    {
                        FilterType.None,
                        FilterType.FilesOnly,
                        FilterType.FoldersOnly,
                        FilterType.DocumentsOnly,
                        FilterType.PresentationsOnly,
                        FilterType.SpreadsheetsOnly,
                        FilterType.ImagesOnly,
                        FilterType.ArchiveOnly,
                        FilterType.ByUser,
                        FilterType.ByDepartment,
                        FilterType.ByExtension,
                        FilterType.MediaOnly
                    },

                    ConflictResolveType = new
                    {
                        FileConflictResolveType.Skip,
                        FileConflictResolveType.Overwrite,
                        FileConflictResolveType.Duplicate
                    },

                    DocuSignFormats = DocuSignHelper.SupportedFormats,
                    SetupInfo.AvailableFileSize,
                })
            });
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var dns   = Request["dns"];
            var alias = Request["alias"];

            _type = GetConfirmType();
            switch (_type)
            {
            case ConfirmType.PortalContinue:
                if (TenantExtra.Enterprise)
                {
                    var countPortals  = TenantExtra.GetTenantQuota().CountPortals;
                    var activePortals = CoreContext.TenantManager.GetTenants().Count();
                    if (countPortals <= activePortals)
                    {
                        _successMessage = UserControlsCommonResource.TariffPortalLimitHeaer;
                        _confirmContentHolder.Visible = false;
                        return;
                    }
                }

                _buttonTitle = Resource.ReactivatePortalButton;
                _title       = Resource.ConfirmReactivatePortalTitle;
                break;

            case ConfirmType.PortalRemove:
                _buttonTitle = Resource.DeletePortalButton;
                _title       = Resource.ConfirmDeletePortalTitle;
                AjaxPro.Utility.RegisterTypeForAjax(GetType());
                break;

            case ConfirmType.PortalSuspend:
                _buttonTitle = Resource.DeactivatePortalButton;
                _title       = Resource.ConfirmDeactivatePortalTitle;
                break;

            case ConfirmType.DnsChange:
                _buttonTitle = Resource.SaveButton;
                var portalAddress = GenerateLink(GetTenantBasePath(alias));
                if (!string.IsNullOrEmpty(dns))
                {
                    portalAddress += string.Format(" ({0})", GenerateLink(dns));
                }
                _title = string.Format(Resource.ConfirmDnsUpdateTitle, portalAddress);
                break;
            }


            if (IsPostBack && _type != ConfirmType.PortalRemove)
            {
                _successMessage = "";

                var curTenant   = CoreContext.TenantManager.GetCurrentTenant();
                var updatedFlag = false;

                var messageAction = MessageAction.None;
                switch (_type)
                {
                case ConfirmType.PortalContinue:
                    curTenant.SetStatus(TenantStatus.Active);
                    _successMessage = string.Format(Resource.ReactivatePortalSuccessMessage, "<br/>", "<a href=\"{0}\">", "</a>");
                    break;

                case ConfirmType.PortalSuspend:
                    curTenant.SetStatus(TenantStatus.Suspended);
                    _successMessage = string.Format(Resource.DeactivatePortalSuccessMessage, "<br/>", "<a href=\"{0}\">", "</a>");
                    messageAction   = MessageAction.PortalDeactivated;
                    break;

                case ConfirmType.DnsChange:
                    if (!string.IsNullOrEmpty(dns))
                    {
                        dns = dns.Trim().TrimEnd('/', '\\');
                    }
                    if (curTenant.MappedDomain != dns)
                    {
                        updatedFlag = true;
                    }
                    curTenant.MappedDomain = dns;
                    if (!string.IsNullOrEmpty(alias))
                    {
                        if (curTenant.TenantAlias != alias)
                        {
                            updatedFlag = true;
                        }
                        curTenant.TenantAlias = alias;
                    }
                    _successMessage = string.Format(Resource.DeactivatePortalSuccessMessage, "<br/>", "<a href=\"{0}\">", "</a>");
                    break;
                }

                bool authed = false;
                try
                {
                    if (!SecurityContext.IsAuthenticated)
                    {
                        SecurityContext.AuthenticateMe(ASC.Core.Configuration.Constants.CoreSystem);
                        authed = true;
                    }

                    #region Alias or dns update

                    if (IsChangeDnsMode)
                    {
                        if (updatedFlag)
                        {
                            CoreContext.TenantManager.SaveTenant(curTenant);
                        }
                        var redirectUrl = dns;
                        if (string.IsNullOrEmpty(redirectUrl))
                        {
                            redirectUrl = GetTenantBasePath(curTenant);
                        }
                        Response.Redirect(AddHttpToUrl(redirectUrl));
                        return;
                    }

                    #endregion


                    CoreContext.TenantManager.SaveTenant(curTenant);
                    if (messageAction != MessageAction.None)
                    {
                        MessageService.Send(HttpContext.Current.Request, messageAction);
                    }
                }
                catch (Exception err)
                {
                    _successMessage = err.Message;
                    LogManager.GetLogger("ASC.Web.Confirm").Error(err);
                }
                finally
                {
                    if (authed)
                    {
                        SecurityContext.Logout();
                    }
                }

                var redirectLink = CommonLinkUtility.GetDefault();
                _successMessage = string.Format(_successMessage, redirectLink);

                _messageHolder.Visible        = true;
                _confirmContentHolder.Visible = false;
            }
            else
            {
                _messageHolder.Visible        = false;
                _confirmContentHolder.Visible = true;

                if (_type == ConfirmType.PortalRemove)
                {
                    _messageHolderPortalRemove.Visible = true;
                }
                else
                {
                    _messageHolderPortalRemove.Visible = false;
                }
            }
        }
示例#8
0
 public string GeInviteLink(EmployeeType employeeType)
 {
     return(CommonLinkUtility.GetConfirmationUrl(string.Empty, ConfirmType.LinkInvite, (int)employeeType, SecurityContext.CurrentAccount.ID)
            + String.Format("&emplType={0}", (int)employeeType));
 }
示例#9
0
 public string GetFullAbsolutePath(string virtualPath)
 {
     return(CommonLinkUtility.GetFullAbsolutePath(virtualPath));
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            LoginMessage = Auth.GetAuthMessage(Request["am"]);

            Page.RegisterStyle("~/UserControls/Common/AuthorizeDocs/css/authorizedocs.less", "~/UserControls/Common/AuthorizeDocs/css/slick.less")
            .RegisterBodyScripts("~/js/third-party/lodash.min.js", "~/js/third-party/masonry.pkgd.min.js", "~/UserControls/Common/AuthorizeDocs/js/reviews.js", "~/UserControls/Common/AuthorizeDocs/js/review_builder_script.js", "~/UserControls/Common/AuthorizeDocs/js/authorizedocs.js", "~/UserControls/Common/Authorize/js/authorize.js", "~/js/third-party/slick.min.js");

            if (CoreContext.Configuration.CustomMode)
            {
                Page.RegisterStyle("~/UserControls/Common/AuthorizeDocs/css/custom-mode.less");
            }

            ThirdpartyEnable = SetupInfo.ThirdPartyAuthEnabled && AccountLinkControl.IsNotEmpty;
            if (Request.DesktopApp() &&
                PrivacyRoomSettings.Available &&
                PrivacyRoomSettings.Enabled)
            {
                ThirdpartyEnable = false;
                Page
                .RegisterBodyScripts("~/UserControls/Common/Authorize/js/desktop.js");
            }

            Page.Title           = CoreContext.Configuration.CustomMode ? CustomModeResource.TitlePageNewCustomMode : PersonalResource.AuthDocsTitlePage;
            Page.MetaDescription = CoreContext.Configuration.CustomMode ? CustomModeResource.AuthDocsMetaDescriptionCustomMode.HtmlEncode() : PersonalResource.AuthDocsMetaDescription.HtmlEncode();
            Page.MetaKeywords    = CoreContext.Configuration.CustomMode ? CustomModeResource.AuthDocsMetaKeywordsCustomMode : PersonalResource.AuthDocsMetaKeywords;

            HelpLink = GetHelpLink();

            PersonalFooterHolder.Controls.Add(LoadControl(CoreContext.Configuration.CustomMode
                                                              ? PersonalFooter.PersonalFooter.LocationCustomMode
                                                              : PersonalFooter.PersonalFooter.Location));

            if (ThirdpartyEnable)
            {
                var loginWithThirdParty = (LoginWithThirdParty)LoadControl(LoginWithThirdParty.Location);
                loginWithThirdParty.RenderDisabled = true;
                HolderLoginWithThirdParty.Controls.Add(loginWithThirdParty);
                var loginWithThirdPartySocial = (LoginWithThirdParty)LoadControl(LoginWithThirdParty.Location);
                loginWithThirdPartySocial.RenderDisabled = true;
                LoginSocialNetworks.Controls.Add(loginWithThirdPartySocial);
            }
            pwdReminderHolder.Controls.Add(LoadControl(PwdTool.Location));

            if (IsPostBack)
            {
                var loginCounter = 0;
                ShowRecaptcha = false;
                try
                {
                    Login = Request["login"].Trim();
                    var passwordHash = Request["passwordHash"];

                    if (string.IsNullOrEmpty(Login) || string.IsNullOrEmpty(passwordHash))
                    {
                        if (AccountLinkControl.IsNotEmpty &&
                            (Request.Url.GetProfile() != null ||
                             Request["__EVENTTARGET"] == "thirdPartyLogin"))
                        {
                            return;
                        }
                        throw new InvalidCredentialException(Resource.InvalidUsernameOrPassword);
                    }

                    if (!SetupInfo.IsSecretEmail(Login))
                    {
                        int.TryParse(cache.Get <string>("loginsec/" + Login), out loginCounter);

                        loginCounter++;

                        if (!RecaptchaEnable)
                        {
                            if (loginCounter > SetupInfo.LoginThreshold)
                            {
                                throw new Authorize.BruteForceCredentialException();
                            }
                        }
                        else
                        {
                            if (loginCounter > SetupInfo.LoginThreshold - 1)
                            {
                                ShowRecaptcha = true;
                            }
                            if (loginCounter > SetupInfo.LoginThreshold)
                            {
                                var ip = Request.Headers["X-Forwarded-For"] ?? Request.UserHostAddress;

                                var recaptchaResponse = Request["g-recaptcha-response"];
                                if (String.IsNullOrEmpty(recaptchaResponse) ||
                                    !Authorize.ValidateRecaptcha(recaptchaResponse, ip))
                                {
                                    throw new Authorize.RecaptchaException();
                                }
                            }
                        }

                        cache.Insert("loginsec/" + Login, loginCounter.ToString(CultureInfo.InvariantCulture), DateTime.UtcNow.Add(TimeSpan.FromMinutes(1)));
                    }

                    var session = string.IsNullOrEmpty(Request["remember"]);

                    var cookiesKey = SecurityContext.AuthenticateMe(Login, passwordHash);
                    CookiesManager.SetCookies(CookiesType.AuthKey, cookiesKey, session);
                    MessageService.Send(HttpContext.Current.Request, MessageAction.LoginSuccess);

                    cache.Insert("loginsec/" + Login, (--loginCounter).ToString(CultureInfo.InvariantCulture), DateTime.UtcNow.Add(TimeSpan.FromMinutes(1)));
                }
                catch (InvalidCredentialException ex)
                {
                    Auth.ProcessLogout();
                    MessageAction messageAction;

                    if (ex is Authorize.BruteForceCredentialException)
                    {
                        LoginMessage  = Resource.LoginWithBruteForce;
                        messageAction = MessageAction.LoginFailBruteForce;
                    }
                    else if (ex is Authorize.RecaptchaException)
                    {
                        LoginMessage  = Resource.RecaptchaInvalid;
                        messageAction = MessageAction.LoginFailRecaptcha;
                    }
                    else
                    {
                        LoginMessage     = Resource.InvalidUsernameOrPassword;
                        messageAction    = MessageAction.LoginFailInvalidCombination;
                        DontShowMainPage = true;
                    }

                    var loginName = string.IsNullOrWhiteSpace(Login) ? AuditResource.EmailNotSpecified : Login;

                    MessageService.Send(HttpContext.Current.Request, loginName, messageAction);

                    return;
                }
                catch (System.Security.SecurityException)
                {
                    Auth.ProcessLogout();
                    LoginMessage = Resource.ErrorDisabledProfile;
                    MessageService.Send(HttpContext.Current.Request, Login, MessageAction.LoginFailDisabledProfile);
                    return;
                }
                catch (Exception ex)
                {
                    Auth.ProcessLogout();
                    LoginMessage = ex.Message;
                    MessageService.Send(HttpContext.Current.Request, Login, MessageAction.LoginFail);
                    return;
                }

                if (loginCounter > 0)
                {
                    cache.Insert("loginsec/" + Login, (--loginCounter).ToString(CultureInfo.InvariantCulture), DateTime.UtcNow.Add(TimeSpan.FromMinutes(1)));
                }

                var refererURL = (string)Session["refererURL"];

                if (string.IsNullOrEmpty(refererURL))
                {
                    Response.Redirect(CommonLinkUtility.GetDefault());
                }
                else
                {
                    Session["refererURL"] = null;
                    Response.Redirect(refererURL);
                }
            }
            else
            {
                var confirmedEmail = (Request.QueryString["confirmed-email"] ?? "").Trim();

                if (String.IsNullOrEmpty(confirmedEmail) || !confirmedEmail.TestEmailRegex())
                {
                    return;
                }

                Login            = confirmedEmail;
                LoginMessage     = Resource.MessageEmailConfirmed + " " + Resource.MessageAuthorize;
                LoginMessageType = 1;
            }
        }
        private void PageLoad()
        {
            var editPossible = !RequestEmbedded;
            var isExtenral   = false;

            File file;
            var  fileUri = string.Empty;

            try
            {
                if (string.IsNullOrEmpty(RequestFileUrl))
                {
                    var app = ThirdPartySelector.GetAppByFileId(RequestFileId);
                    if (app == null)
                    {
                        file = DocumentServiceHelper.GetParams(RequestFileId, RequestVersion, RequestShareLinkKey, editPossible, !RequestView, true, out _configuration);
                        if (_valideShareLink)
                        {
                            _configuration.Document.SharedLinkKey += RequestShareLinkKey;

                            if (CoreContext.Configuration.Personal && !SecurityContext.IsAuthenticated)
                            {
                                var user    = CoreContext.UserManager.GetUsers(file.CreateBy);
                                var culture = CultureInfo.GetCultureInfo(user.CultureName);
                                Thread.CurrentThread.CurrentCulture   = culture;
                                Thread.CurrentThread.CurrentUICulture = culture;
                            }
                        }
                    }
                    else
                    {
                        isExtenral = true;

                        bool editable;
                        _thirdPartyApp = true;
                        file           = app.GetFile(RequestFileId, out editable);
                        file           = DocumentServiceHelper.GetParams(file, true, editPossible ? FileShare.ReadWrite : FileShare.Read, false, editable, editable, editable, true, out _configuration);

                        _configuration.Document.Url = app.GetFileStreamUrl(file);
                        _configuration.EditorConfig.Customization.GobackUrl = string.Empty;
                    }
                }
                else
                {
                    isExtenral = true;

                    fileUri = RequestFileUrl;
                    var fileTitle = Request[FilesLinkUtility.FileTitle];
                    if (string.IsNullOrEmpty(fileTitle))
                    {
                        fileTitle = Path.GetFileName(HttpUtility.UrlDecode(fileUri)) ?? "";
                    }

                    file = new File
                    {
                        ID    = RequestFileUrl,
                        Title = Global.ReplaceInvalidCharsAndTruncate(fileTitle)
                    };

                    file = DocumentServiceHelper.GetParams(file, true, FileShare.Read, false, false, false, false, false, out _configuration);
                    _configuration.Document.Permissions.Edit          = editPossible && !CoreContext.Configuration.Standalone;
                    _configuration.Document.Permissions.Rename        = false;
                    _configuration.Document.Permissions.Review        = false;
                    _configuration.Document.Permissions.FillForms     = false;
                    _configuration.Document.Permissions.ChangeHistory = false;
                    _editByUrl = true;

                    _configuration.Document.Url = fileUri;
                }
                ErrorMessage = _configuration.ErrorMessage;
            }
            catch (Exception ex)
            {
                Global.Logger.Warn("DocEditor", ex);
                ErrorMessage = ex.Message;
                return;
            }

            if (_configuration.EditorConfig.ModeWrite && FileConverter.MustConvert(file))
            {
                try
                {
                    file = FileConverter.ExecSync(file, RequestShareLinkKey);
                }
                catch (Exception ex)
                {
                    _configuration = null;
                    Global.Logger.Error("DocEditor", ex);
                    ErrorMessage = ex.Message;
                    return;
                }

                var comment = "#message/" + HttpUtility.UrlEncode(string.Format(FilesCommonResource.ConvertForEdit, file.Title));

                Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment);
                return;
            }

            Title = file.Title;

            if (_configuration.EditorConfig.Customization.Goback == null || string.IsNullOrEmpty(_configuration.EditorConfig.Customization.Goback.Url))
            {
                _configuration.EditorConfig.Customization.GobackUrl = Request[FilesLinkUtility.FolderUrl] ?? "";
            }

            _configuration.EditorConfig.Customization.IsRetina = TenantLogoManager.IsRetina(Request);

            if (RequestEmbedded)
            {
                _configuration.Type = Services.DocumentService.Configuration.EditorType.Embedded;

                _configuration.EditorConfig.Embedded.ShareLinkParam = string.IsNullOrEmpty(RequestShareLinkKey) ? string.Empty : "&" + FilesLinkUtility.DocShareKey + "=" + RequestShareLinkKey;
            }
            else
            {
                _configuration.Type = IsMobile ? Services.DocumentService.Configuration.EditorType.Mobile : Services.DocumentService.Configuration.EditorType.Desktop;

                if (FileSharing.CanSetAccess(file) &&
                    !(file.Encrypted &&
                      (!Request.DesktopApp() ||
                       CoreContext.Configuration.Personal)))
                {
                    _configuration.EditorConfig.SharingSettingsUrl = CommonLinkUtility.GetFullAbsolutePath(
                        Share.Location
                        + "?" + FilesLinkUtility.FileId + "=" + HttpUtility.UrlEncode(file.ID.ToString())
                        + (Request.DesktopApp() ? "&desktop=true" : string.Empty));
                }
            }

            if (!isExtenral)
            {
                _docKeyForTrack = DocumentServiceHelper.GetDocKey(file.ID, -1, DateTime.MinValue);

                FileMarker.RemoveMarkAsNew(file);
            }

            if (SecurityContext.IsAuthenticated)
            {
                _configuration.EditorConfig.SaveAsUrl = _configuration.EditorConfig.MergeFolderUrl = CommonLinkUtility.GetFullAbsolutePath(SaveAs.GetUrl);
            }

            if (_configuration.EditorConfig.ModeWrite)
            {
                _tabId = FileTracker.Add(file.ID);

                Global.SocketManager.FilesChangeEditors(file.ID);

                if (SecurityContext.IsAuthenticated)
                {
                    _configuration.EditorConfig.FileChoiceUrl = CommonLinkUtility.GetFullAbsolutePath(FileChoice.GetUrlForEditor);
                }
            }
            else
            {
                _linkToEdit = _editByUrl
                                  ? CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorExternalUrl(fileUri, file.Title))
                                  : CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.GetFileWebEditorUrl(file.ID));

                if (FileConverter.MustConvert(_configuration.Document.Info.File))
                {
                    _editByUrl = true;
                }
            }

            var actionAnchor = Request[FilesLinkUtility.Anchor];

            if (!string.IsNullOrEmpty(actionAnchor))
            {
                _configuration.EditorConfig.ActionLinkString = actionAnchor;
            }
        }
示例#12
0
        private void InitProductSettingsInlineScript()
        {
            var isAdmin = WebItemSecurity.IsProductAdministrator(CommonLinkUtility.GetProductID(), SecurityContext.CurrentAccount.ID);

            RegisterInlineScript(string.Format("window.ASC.Resources.Master.IsProductAdmin={0};", isAdmin.ToString().ToLowerInvariant()), true, false);
        }
 /// <summary>
 /// return absolute profile link
 /// </summary>
 /// <param name="userInfo"></param>
 /// <returns></returns>
 private static string GetUserProfilePageURLGeneral(this UserInfo userInfo)
 {
     return(CommonLinkUtility.GetUserProfile(userInfo.ID));
 }
 private void RegisterRedirect()
 {
     Page.ClientScript.RegisterStartupScript(GetType(), "redirect",
                                             string.Format("setTimeout('location.href = \"{0}\";',10000);",
                                                           CommonLinkUtility.GetFullAbsolutePath("~/")), true);
 }
示例#15
0
 public RequestItem(string url)
 {
     Url      = CommonLinkUtility.GetFullAbsolutePath(url);
     TenantId = CoreContext.TenantManager.GetCurrentTenant().TenantId;
 }
示例#16
0
        public object UpdatePortalName(string alias)
        {
            var enabled = SetupInfo.IsVisibleSettings("PortalRename");

            if (!enabled)
            {
                throw new SecurityException(Resource.PortalAccessSettingsTariffException);
            }

            if (CoreContext.Configuration.Personal)
            {
                throw new Exception(Resource.ErrorAccessDenied);
            }

            SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings);

            if (String.IsNullOrEmpty(alias))
            {
                throw new ArgumentException();
            }


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

            var newAlias           = alias.ToLowerInvariant();
            var oldAlias           = tenant.TenantAlias;
            var oldVirtualRootPath = CommonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/');

            if (!String.Equals(newAlias, oldAlias, StringComparison.InvariantCultureIgnoreCase))
            {
                var hostedSolution = new HostedSolution(ConfigurationManager.ConnectionStrings["default"]);
                if (!String.IsNullOrEmpty(ApiSystemHelper.ApiSystemUrl))
                {
                    ApiSystemHelper.ValidatePortalName(newAlias);
                }
                else
                {
                    hostedSolution.CheckTenantAddress(newAlias.Trim());
                }


                if (!String.IsNullOrEmpty(ApiSystemHelper.ApiCacheUrl))
                {
                    ApiSystemHelper.AddTenantToCache(newAlias);
                }

                tenant.TenantAlias = alias;
                tenant             = hostedSolution.SaveTenant(tenant);


                if (!String.IsNullOrEmpty(ApiSystemHelper.ApiCacheUrl))
                {
                    ApiSystemHelper.RemoveTenantFromCache(oldAlias);
                }

                var newVirtualRootPath = CommonLinkUtility.GetFullAbsolutePath("~").TrimEnd('/');
                if (!string.Equals(oldVirtualRootPath, newVirtualRootPath, StringComparison.InvariantCultureIgnoreCase))
                {
                    StudioNotifyService.Instance.PortalRenameNotify(oldVirtualRootPath);
                }
            }
            else
            {
                throw new Exception(ResourceJS.ErrorPortalNameWasNotChanged);
            }

            var reference = CreateReference(Request, tenant.TenantDomain, tenant.TenantId, user.Email);

            return(new {
                message = Resource.SuccessfullyPortalRenameMessage,
                reference = reference
            });
        }
示例#17
0
 public static String GetFileControlPath(String fileName)
 {
     return(CommonLinkUtility.ToAbsolute("~/products/files/controls/" + fileName).ToLowerInvariant());
 }
        public static void SendMsgWhatsNew(DateTime scheduleDate, INotifyClient client)
        {
            var log = LogManager.GetLogger("ASC.Notify.WhatsNew");

            if (WebItemManager.Instance.GetItemsAll <IProduct>().Count == 0)
            {
                log.Info("No products. Return from function");
                return;
            }

            log.Info("Start send whats new.");

            var products = WebItemManager.Instance.GetItemsAll().ToDictionary(p => p.GetSysName());

            foreach (var tenantid in GetChangedTenants(scheduleDate))
            {
                try
                {
                    var tenant = CoreContext.TenantManager.GetTenant(tenantid);
                    if (tenant == null ||
                        tenant.Status != TenantStatus.Active ||
                        !TimeToSendWhatsNew(TenantUtil.DateTimeFromUtc(tenant.TimeZone, scheduleDate)) ||
                        TariffState.NotPaid <= CoreContext.PaymentManager.GetTariff(tenantid).State)
                    {
                        continue;
                    }

                    CoreContext.TenantManager.SetCurrentTenant(tenant);

                    log.InfoFormat("Start send whats new in {0} ({1}).", tenant.TenantDomain, tenantid);
                    foreach (var user in CoreContext.UserManager.GetUsers(tenant))
                    {
                        if (!StudioNotifyHelper.IsSubscribedToNotify(tenant, user, Actions.SendWhatsNew))
                        {
                            continue;
                        }

                        SecurityContext.AuthenticateMe(CoreContext.Authentication.GetAccountByID(tenant.TenantId, user.ID));

                        var culture = string.IsNullOrEmpty(user.CultureName) ? tenant.GetCulture() : user.GetCulture();

                        Thread.CurrentThread.CurrentCulture   = culture;
                        Thread.CurrentThread.CurrentUICulture = culture;

                        var feeds = FeedAggregateDataProvider.GetFeeds(new FeedApiFilter
                        {
                            From = scheduleDate.Date.AddDays(-1),
                            To   = scheduleDate.Date.AddSeconds(-1),
                            Max  = 100,
                        });

                        var feedMinWrappers = feeds.ConvertAll(f => f.ToFeedMin());

                        var feedMinGroupedWrappers = feedMinWrappers
                                                     .Where(f =>
                                                            (f.CreatedDate == DateTime.MaxValue || f.CreatedDate >= scheduleDate.Date.AddDays(-1)) && //'cause here may be old posts with new comments
                                                            products.ContainsKey(f.Product) &&
                                                            !f.Id.StartsWith("participant")
                                                            )
                                                     .GroupBy(f => products[f.Product]);

                        var ProjectsProductName = products["projects"]?.Name; //from ASC.Feed.Aggregator.Modules.ModulesHelper.ProjectsProductName

                        var activities = feedMinGroupedWrappers
                                         .Where(f => f.Key.Name != ProjectsProductName) //not for project product
                                         .ToDictionary(
                            g => g.Key.Name,
                            g => g.Select(f => new WhatsNewUserActivity
                        {
                            Date            = f.CreatedDate,
                            UserName        = f.Author != null && f.Author.UserInfo != null ? f.Author.UserInfo.DisplayUserName() : string.Empty,
                            UserAbsoluteURL = f.Author != null && f.Author.UserInfo != null ? CommonLinkUtility.GetFullAbsolutePath(f.Author.UserInfo.GetUserProfilePageURL()) : string.Empty,
                            Title           = HtmlUtil.GetText(f.Title, 512),
                            URL             = CommonLinkUtility.GetFullAbsolutePath(f.ItemUrl),
                            BreadCrumbs     = new string[0],
                            Action          = getWhatsNewActionText(f)
                        }).ToList());


                        var projectActivities = feedMinGroupedWrappers
                                                .Where(f => f.Key.Name == ProjectsProductName) // for project product
                                                .SelectMany(f => f);

                        var projectActivitiesWithoutBreadCrumbs = projectActivities.Where(p => string.IsNullOrEmpty(p.ExtraLocation));

                        var whatsNewUserActivityGroupByPrjs = new List <WhatsNewUserActivity>();

                        foreach (var prawbc in projectActivitiesWithoutBreadCrumbs)
                        {
                            whatsNewUserActivityGroupByPrjs.Add(
                                new WhatsNewUserActivity
                            {
                                Date            = prawbc.CreatedDate,
                                UserName        = prawbc.Author != null && prawbc.Author.UserInfo != null ? prawbc.Author.UserInfo.DisplayUserName() : string.Empty,
                                UserAbsoluteURL = prawbc.Author != null && prawbc.Author.UserInfo != null ? CommonLinkUtility.GetFullAbsolutePath(prawbc.Author.UserInfo.GetUserProfilePageURL()) : string.Empty,
                                Title           = HtmlUtil.GetText(prawbc.Title, 512),
                                URL             = CommonLinkUtility.GetFullAbsolutePath(prawbc.ItemUrl),
                                BreadCrumbs     = new string[0],
                                Action          = getWhatsNewActionText(prawbc)
                            });
                        }

                        var groupByPrjs = projectActivities.Where(p => !string.IsNullOrEmpty(p.ExtraLocation)).GroupBy(f => f.ExtraLocation);
                        foreach (var gr in groupByPrjs)
                        {
                            var grlist = gr.ToList();
                            for (var i = 0; i < grlist.Count(); i++)
                            {
                                var ls = grlist[i];
                                whatsNewUserActivityGroupByPrjs.Add(
                                    new WhatsNewUserActivity
                                {
                                    Date            = ls.CreatedDate,
                                    UserName        = ls.Author != null && ls.Author.UserInfo != null ? ls.Author.UserInfo.DisplayUserName() : string.Empty,
                                    UserAbsoluteURL = ls.Author != null && ls.Author.UserInfo != null ? CommonLinkUtility.GetFullAbsolutePath(ls.Author.UserInfo.GetUserProfilePageURL()) : string.Empty,
                                    Title           = HtmlUtil.GetText(ls.Title, 512),
                                    URL             = CommonLinkUtility.GetFullAbsolutePath(ls.ItemUrl),
                                    BreadCrumbs     = i == 0 ? new string[1] {
                                        gr.Key
                                    } : new string[0],
                                    Action = getWhatsNewActionText(ls)
                                });
                            }
                        }

                        if (whatsNewUserActivityGroupByPrjs.Count > 0)
                        {
                            activities.Add(ProjectsProductName, whatsNewUserActivityGroupByPrjs);
                        }

                        if (activities.Count > 0)
                        {
                            log.InfoFormat("Send whats new to {0}", user.Email);
                            client.SendNoticeAsync(
                                Actions.SendWhatsNew, null, user,
                                new TagValue(Tags.Activities, activities),
                                new TagValue(Tags.Date, DateToString(scheduleDate.AddDays(-1), culture)),
                                new TagValue(CommonTags.Priority, 1)
                                );
                        }
                    }
                }
                catch (Exception error)
                {
                    log.Error(error);
                }
            }
        }
示例#19
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.RegisterStyle("~/UserControls/Common/Authorize/css/authorize.less")
            .RegisterBodyScripts("~/UserControls/Common/Authorize/js/authorize.js");

            if (RecaptchaEnable)
            {
                Page
                .RegisterBodyScripts("~/usercontrols/common/authorize/js/recaptchacontroller.js");
            }

            Login    = "";
            Password = "";
            HashId   = "";

            //Account link control
            bool withAccountLink = false;

            if (SetupInfo.ThirdPartyAuthEnabled && AccountLinkControl.IsNotEmpty)
            {
                var accountLink = (AccountLinkControl)LoadControl(AccountLinkControl.Location);
                accountLink.Visible        = true;
                accountLink.ClientCallback = "authCallback";
                accountLink.SettingsView   = false;
                signInPlaceholder.Controls.Add(accountLink);

                withAccountLink = true;
            }

            //top panel
            var master = Page.Master as BaseTemplate;

            if (master != null)
            {
                master.TopStudioPanel.DisableProductNavigation = true;
                master.TopStudioPanel.DisableSearch            = true;
            }

            Page.Title = HeaderStringHelper.GetPageTitle(Resource.Authorization);

            pwdReminderHolder.Controls.Add(LoadControl(PwdTool.Location));

            var msg      = Request["m"];
            var urlError = Request.QueryString["error"];

            if (!string.IsNullOrEmpty(msg))
            {
                ErrorMessage = msg;
            }
            else if (urlError == "ipsecurity")
            {
                ErrorMessage = Resource.LoginFailIPSecurityMsg;
            }

            var thirdPartyProfile = Request.Url.GetProfile();

            if ((IsPostBack || thirdPartyProfile != null) && !SecurityContext.IsAuthenticated)
            {
                if (!AuthProcess(thirdPartyProfile, withAccountLink))
                {
                    return;
                }

                CookiesManager.ClearCookies(CookiesType.SocketIO);
                var refererURL = (string)Session["refererURL"];
                if (string.IsNullOrEmpty(refererURL))
                {
                    Response.Redirect(CommonLinkUtility.GetDefault(), true);
                }
                else
                {
                    Session["refererURL"] = null;
                    Response.Redirect(refererURL, true);
                }
            }
            ProcessConfirmedEmailCondition();
            ProcessConfirmedEmailLdap();
        }
示例#20
0
        private static string CreateEnvelope(string accountId, Document document, DocuSignData docuSignData, DocuSign.eSign.Client.Configuration configuration)
        {
            var eventNotification = new EventNotification
            {
                EnvelopeEvents = new List <EnvelopeEvent>
                {
                    //new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Sent.ToString()},
                    //new EnvelopeEvent {EnvelopeEventStatusCode = DocuSignStatus.Delivered.ToString()},
                    new EnvelopeEvent {
                        EnvelopeEventStatusCode = DocuSignStatus.Completed.ToString()
                    },
                    new EnvelopeEvent {
                        EnvelopeEventStatusCode = DocuSignStatus.Declined.ToString()
                    },
                    new EnvelopeEvent {
                        EnvelopeEventStatusCode = DocuSignStatus.Voided.ToString()
                    },
                },
                IncludeDocumentFields = "true",
                //RecipientEvents = new List<RecipientEvent>
                //    {
                //        new RecipientEvent {RecipientEventStatusCode = "Sent"},
                //        new RecipientEvent {RecipientEventStatusCode = "Delivered"},
                //        new RecipientEvent {RecipientEventStatusCode = "Completed"},
                //        new RecipientEvent {RecipientEventStatusCode = "Declined"},
                //        new RecipientEvent {RecipientEventStatusCode = "AuthenticationFailed"},
                //        new RecipientEvent {RecipientEventStatusCode = "AutoResponded"},
                //    },
                Url = CommonLinkUtility.GetFullAbsolutePath(DocuSignHandler.Path + "?" + FilesLinkUtility.Action + "=webhook"),
            };

            Global.Logger.Debug("DocuSign hook url: " + eventNotification.Url);

            var signers = new List <Signer>();

            docuSignData.Users.ForEach(uid =>
            {
                try
                {
                    var user = CoreContext.UserManager.GetUsers(uid);
                    signers.Add(new Signer
                    {
                        Email       = user.Email,
                        Name        = user.DisplayUserName(false),
                        RecipientId = user.ID.ToString(),
                    });
                }
                catch (Exception ex)
                {
                    Log.Error("Signer is undefined", ex);
                }
            });

            var envelopeDefinition = new EnvelopeDefinition
            {
                CustomFields = new CustomFields
                {
                    TextCustomFields = new List <TextCustomField>
                    {
                        new TextCustomField {
                            Name = UserField, Value = SecurityContext.CurrentAccount.ID.ToString()
                        },
                    }
                },
                Documents = new List <Document> {
                    document
                },
                EmailBlurb        = docuSignData.Message,
                EmailSubject      = docuSignData.Name,
                EventNotification = eventNotification,
                Recipients        = new Recipients
                {
                    Signers = signers,
                },
                Status = "created",
            };

            var envelopesApi    = new EnvelopesApi(configuration);
            var envelopeSummary = envelopesApi.CreateEnvelope(accountId, envelopeDefinition);

            Global.Logger.Debug("DocuSign createdEnvelope: " + envelopeSummary.EnvelopeId);

            var envelopeId = envelopeSummary.EnvelopeId;
            var url        = envelopesApi.CreateSenderView(accountId, envelopeId, new ReturnUrlRequest
            {
                ReturnUrl = CommonLinkUtility.GetFullAbsolutePath(DocuSignHandler.Path + "?" + FilesLinkUtility.Action + "=redirect")
            });

            Global.Logger.Debug("DocuSign senderView: " + url.Url);

            return(url.Url);
        }
 internal string GetUserProfileLink(Guid userID)
 {
     return(CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(userID, CommonLinkUtility.GetProductID())));
 }
示例#22
0
 public UrlShortener(IConfiguration configuration, ConsumerFactory consumerFactory, CommonLinkUtility commonLinkUtility)
 {
     Configuration     = configuration;
     ConsumerFactory   = consumerFactory;
     CommonLinkUtility = commonLinkUtility;
 }
 private string GetEcho(string method, bool user = true)
 {
     return(new TwilioResponseHelper(this, CommonLinkUtility.GetFullAbsolutePath("")).GetEcho(method, user));
 }
示例#24
0
        public VoipUpload DeleteUploadedFile(AudioType audioType, string fileName)
        {
            if (!CRMSecurity.IsAdmin)
            {
                throw CRMSecurity.CreateSecurityException();
            }

            var store  = Global.GetStore();
            var path   = Path.Combine(audioType.ToString().ToLower(), fileName);
            var result = new VoipUpload
            {
                AudioType = audioType,
                Name      = fileName,
                Path      = CommonLinkUtility.GetFullAbsolutePath(store.GetUri(path).ToString())
            };

            if (!store.IsFile("voip", path))
            {
                throw new ItemNotFoundException();
            }
            store.Delete("voip", path);

            var dao     = DaoFactory.VoipDao;
            var numbers = dao.GetNumbers();

            var defAudio = StorageFactory.GetStorage("", "crm").ListFiles("voip", "default/" + audioType.ToString().ToLower(), "*.*", true).FirstOrDefault();

            if (defAudio == null)
            {
                return(result);
            }

            foreach (var number in numbers)
            {
                switch (audioType)
                {
                case AudioType.Greeting:
                    if (number.Settings.GreetingAudio == result.Path)
                    {
                        number.Settings.GreetingAudio = CommonLinkUtility.GetFullAbsolutePath(defAudio.ToString());
                    }
                    break;

                case AudioType.HoldUp:
                    if (number.Settings.HoldAudio == result.Path)
                    {
                        number.Settings.HoldAudio = CommonLinkUtility.GetFullAbsolutePath(defAudio.ToString());
                    }
                    break;

                case AudioType.Queue:
                    var queue = number.Settings.Queue;
                    if (queue != null && queue.WaitUrl == result.Path)
                    {
                        queue.WaitUrl = CommonLinkUtility.GetFullAbsolutePath(defAudio.ToString());
                    }
                    break;

                case AudioType.VoiceMail:
                    if (number.Settings.VoiceMail == result.Path)
                    {
                        number.Settings.VoiceMail = CommonLinkUtility.GetFullAbsolutePath(defAudio.ToString());
                    }
                    break;
                }

                dao.SaveOrUpdateNumber(number);
            }

            return(result);
        }
示例#25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var master = Master as IStudioMaster;

            if (master == null)
            {
                return;
            }

            AjaxPro.Utility.RegisterTypeForAjax(this.GetType());

            //top navigator
            if (master is StudioTemplate)
            {
                (master as StudioTemplate).TopNavigationPanel.CustomTitle        = Resources.Resource.Search;
                (master as StudioTemplate).TopNavigationPanel.CustomTitleIconURL = WebImageSupplier.GetAbsoluteWebPath("search.png");
            }

            master.DisabledSidePanel = true;

            Guid productID;

            if (!String.IsNullOrEmpty(Request["productID"]))
            {
                productID = new Guid(Request["productID"]);
            }
            else
            {
                productID = GetProductID();
            }



            _searchText = Request["search"] ?? "";
            var data = SearchAll(_searchText, productID);

            var container = new Container {
                Body = new PlaceHolder(), Header = new PlaceHolder()
            };

            container.BreadCrumbs.Add(new BreadCrumb {
                Caption = Resources.Resource.MainTitle, NavigationUrl = productID.Equals(Guid.Empty) ? CommonLinkUtility.GetDefault() : VirtualPathUtility.ToAbsolute(ProductManager.Instance[productID].StartURL)
            });
            container.BreadCrumbs.Add(new BreadCrumb {
                Caption = HeaderStringHelper.GetHTMLSearchHeader(_searchText)
            });
            master.ContentHolder.Controls.Add(container);

            Title = HeaderStringHelper.GetPageTitle(Resources.Resource.Search, container.BreadCrumbs);

            if (data.Count <= 0)
            {
                var emptyScreenControl = new EmptyScreenControl
                {
                    ImgSrc   = WebImageSupplier.GetAbsoluteWebPath("empty_search.png"),
                    Header   = Resources.Resource.SearchNotFoundMessage,
                    Describe = Resources.Resource.SearchNotFoundDescript
                };
                container.Body.Controls.Add(emptyScreenControl);
            }
            else
            {
                var oSearchView = (SearchResults)LoadControl(SearchResults.Location);
                //data.Sort(new SearchComparer());
                oSearchView.DataSourceObj = data;
                container.Body.Controls.Add(oSearchView);
            }
        }
示例#26
0
        private void NotifyNewComment(FeedComment comment, Feed feed)
        {
            var feedType = feed.FeedType == FeedType.Poll ? "poll" : "feed";

            var tags = new ITagValue[]
            {
                new TagValue(NewsConst.TagFEED_TYPE, feedType),
                //new TagValue(NewsConst.TagAnswers, feed.Variants.ConvertAll<string>(v => v.Name)),
                new TagValue(NewsConst.TagCaption, feed.Caption),
                new TagValue("CommentBody", HtmlUtility.GetFull(comment.Comment)),
                new TagValue(NewsConst.TagDate, comment.Date.ToShortString()),
                new TagValue(NewsConst.TagURL, CommonLinkUtility.GetFullAbsolutePath("~/Products/Community/Modules/News/Default.aspx?docid=" + feed.Id)),
                new TagValue("CommentURL", CommonLinkUtility.GetFullAbsolutePath("~/Products/Community/Modules/News/Default.aspx?docid=" + feed.Id + "#container_" + comment.Id.ToString(CultureInfo.InvariantCulture))),
                new TagValue(NewsConst.TagUserName, DisplayUserSettings.GetFullUserName(SecurityContext.CurrentAccount.ID)),
                new TagValue(NewsConst.TagUserUrl, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetUserProfile(SecurityContext.CurrentAccount.ID)))
            };

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

            try
            {
                NewsNotifyClient.NotifyClient.AddInterceptor(initatorInterceptor);

                var mentionedUsers   = MentionProvider.GetMentionedUsers(comment.Comment);
                var mentionedUserIds = mentionedUsers.Select(u => u.ID.ToString());

                var provider = NewsNotifySource.Instance.GetSubscriptionProvider();

                var objectID = feed.Id.ToString(CultureInfo.InvariantCulture);

                var recipients = provider
                                 .GetRecipients(NewsConst.NewComment, objectID)
                                 .Where(r => !mentionedUserIds.Contains(r.ID))
                                 .ToArray();

                NewsNotifyClient.NotifyClient.SendNoticeToAsync(NewsConst.NewComment, objectID, recipients, false, tags);

                if (mentionedUsers.Length > 0)
                {
                    NewsNotifyClient.NotifyClient.SendNoticeToAsync(NewsConst.MentionForFeedComment, objectID, mentionedUsers, false, tags);
                }
            }
            finally
            {
                NewsNotifyClient.NotifyClient.RemoveInterceptor(initatorInterceptor.Name);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (UserProfileHelper == null)
            {
                UserProfileHelper = new ProfileHelper(SecurityContext.CurrentAccount.ID.ToString());
            }
            UserInfo         = UserProfileHelper.UserInfo;
            ShowSocialLogins = UserInfo.IsMe();

            IsAdmin   = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsAdmin();
            IsVisitor = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor();

            if (!IsAdmin && (UserInfo.Status != EmployeeStatus.Active))
            {
                Response.Redirect(CommonLinkUtility.GetFullAbsolutePath("~/products/people/"), true);
            }

            Actions = new AllowedActions(UserInfo);

            HappyBirthday = CheckHappyBirthday();

            ContactPhones.DataSource = UserProfileHelper.Phones;
            ContactPhones.DataBind();

            ContactEmails.DataSource = UserProfileHelper.Emails;
            ContactEmails.DataBind();

            ContactMessengers.DataSource = UserProfileHelper.Messengers;
            ContactMessengers.DataBind();

            ContactSoccontacts.DataSource = UserProfileHelper.Contacts;
            ContactSoccontacts.DataBind();

            _deleteProfileContainer.Options.IsPopup = true;

            Page.RegisterStyle("~/usercontrols/users/userprofile/css/userprofilecontrol_style.less");
            Page.RegisterBodyScripts(VirtualPathUtility.ToAbsolute("~/usercontrols/users/userprofile/js/userprofilecontrol.js"));

            if (Actions.AllowEdit)
            {
                _editControlsHolder.Controls.Add(LoadControl(PwdTool.Location));
            }
            if (Actions.AllowEdit || (UserInfo.IsOwner() && IsAdmin))
            {
                var control = (UserEmailChange)LoadControl(UserEmailChange.Location);
                control.UserInfo = UserInfo;
                userEmailChange.Controls.Add(control);
            }

            if (!MobileDetector.IsMobile)
            {
                var thumbnailEditorControl = (ThumbnailEditor)LoadControl(ThumbnailEditor.Location);
                thumbnailEditorControl.Title            = Resource.TitleThumbnailPhoto;
                thumbnailEditorControl.BehaviorID       = "UserPhotoThumbnail";
                thumbnailEditorControl.JcropMinSize     = UserPhotoManager.SmallFotoSize;
                thumbnailEditorControl.JcropAspectRatio = 1;
                thumbnailEditorControl.SaveFunctionType = typeof(SavePhotoThumbnails);
                _editControlsHolder.Controls.Add(thumbnailEditorControl);
            }

            if (ShowSocialLogins && AccountLinkControl.IsNotEmpty)
            {
                var accountLink = (AccountLinkControl)LoadControl(AccountLinkControl.Location);
                accountLink.ClientCallback = "loginCallback";
                accountLink.SettingsView   = true;
                _accountPlaceholder.Controls.Add(accountLink);
            }

            var emailControl = (UserEmailControl)LoadControl(UserEmailControl.Location);

            emailControl.User   = UserInfo;
            emailControl.Viewer = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID);
            _phEmailControlsHolder.Controls.Add(emailControl);

            var photoControl = (LoadPhotoControl)LoadControl(LoadPhotoControl.Location);

            loadPhotoWindow.Controls.Add(photoControl);

            if (UserInfo.IsMe())
            {
                _phLanguage.Controls.Add(LoadControl(UserLanguage.Location));
            }

            if (StudioSmsNotificationSettings.IsVisibleSettings && (Actions.AllowEdit && !String.IsNullOrEmpty(UserInfo.MobilePhone) || UserInfo.IsMe()))
            {
                ShowPrimaryMobile = true;
                var changeMobile = (ChangeMobileNumber)LoadControl(ChangeMobileNumber.Location);
                changeMobile.User = UserInfo;
                ChangeMobileHolder.Controls.Add(changeMobile);
            }

            if (UserInfo.BirthDate.HasValue)
            {
                switch (HappyBirthday)
                {
                case 0:
                    BirthDayText = Resource.DrnToday;
                    break;

                case 1:
                    BirthDayText = Resource.DrnTomorrow;
                    break;

                case 2:
                    BirthDayText = Resource.In + " " + DateTimeExtension.Yet(2);
                    break;

                case 3:
                    BirthDayText = Resource.In + " " + DateTimeExtension.Yet(3);
                    break;

                default:
                    BirthDayText = String.Empty;
                    break;
                }
            }

            if (UserInfo.Status != EmployeeStatus.Terminated)
            {
                var groups = CoreContext.UserManager.GetUserGroups(UserInfo.ID).ToList();
                if (!groups.Any())
                {
                    DepartmentsRepeater.Visible = false;
                }

                DepartmentsRepeater.DataSource = groups;
                DepartmentsRepeater.DataBind();
            }
        }
示例#28
0
        private UserInfo SyncLDAPUser(UserInfo ldapUserInfo, List <UserInfo> ldapUsers, out LdapChangeCollection changes, bool onlyGetChanges = false)
        {
            UserInfo result;

            changes = new LdapChangeCollection();

            UserInfo userToUpdate;

            var userBySid = CoreContext.UserManager.GetUserBySid(ldapUserInfo.Sid);

            if (Equals(userBySid, Constants.LostUser))
            {
                var userByEmail = CoreContext.UserManager.GetUserByEmail(ldapUserInfo.Email);

                if (Equals(userByEmail, Constants.LostUser))
                {
                    if (ldapUserInfo.Status != EmployeeStatus.Active)
                    {
                        if (onlyGetChanges)
                        {
                            changes.SetSkipUserChange(ldapUserInfo);
                        }

                        _log.DebugFormat("SyncUserLDAP(SID: {0}, Username: '******') ADD failed: Status is {2}",
                                         ldapUserInfo.Sid, ldapUserInfo.UserName,
                                         Enum.GetName(typeof(EmployeeStatus), ldapUserInfo.Status));

                        return(Constants.LostUser);
                    }

                    if (!TryAddLDAPUser(ldapUserInfo, onlyGetChanges, out result))
                    {
                        if (onlyGetChanges)
                        {
                            changes.SetSkipUserChange(ldapUserInfo);
                        }

                        return(Constants.LostUser);
                    }

                    if (onlyGetChanges)
                    {
                        changes.SetAddUserChange(result, _log);
                    }

                    if (!onlyGetChanges && LdapSettings.Load().SendWelcomeEmail&&
                        (ldapUserInfo.ActivationStatus != EmployeeActivationStatus.AutoGenerated))
                    {
                        var client = LdapNotifyHelper.StudioNotifyClient;

                        var confirmLink = CommonLinkUtility.GetConfirmationUrl(ldapUserInfo.Email, ConfirmType.EmailActivation);

                        client.SendNoticeToAsync(
                            NotifyConstants.ActionLdapActivation,
                            null,
                            new[] { new DirectRecipient(ldapUserInfo.Email, null, new[] { ldapUserInfo.Email }, false) },
                            new[] { ASC.Core.Configuration.Constants.NotifyEMailSenderSysName },
                            null,
                            new TagValue(NotifyConstants.TagUserName, ldapUserInfo.DisplayUserName()),
                            new TagValue(NotifyConstants.TagUserEmail, ldapUserInfo.Email),
                            new TagValue(NotifyConstants.TagMyStaffLink, CommonLinkUtility.GetFullAbsolutePath(CommonLinkUtility.GetMyStaff())),
                            NotifyConstants.TagGreenButton(Resource.NotifyButtonJoin, confirmLink),
                            new TagValue(NotifyCommonTags.WithoutUnsubscribe, true));
                    }

                    return(result);
                }

                if (userByEmail.IsLDAP())
                {
                    if (ldapUsers == null || ldapUsers.Any(u => u.Sid.Equals(userByEmail.Sid)))
                    {
                        if (onlyGetChanges)
                        {
                            changes.SetSkipUserChange(ldapUserInfo);
                        }

                        _log.DebugFormat(
                            "SyncUserLDAP(SID: {0}, Username: '******') ADD failed: Another ldap user with email '{2}' already exists",
                            ldapUserInfo.Sid, ldapUserInfo.UserName, ldapUserInfo.Email);

                        return(Constants.LostUser);
                    }
                }

                userToUpdate = userByEmail;
            }
            else
            {
                userToUpdate = userBySid;
            }

            UpdateLdapUserContacts(ldapUserInfo, userToUpdate.Contacts);

            if (!NeedUpdateUser(userToUpdate, ldapUserInfo))
            {
                _log.DebugFormat("SyncUserLDAP(SID: {0}, Username: '******') No need to update, skipping", ldapUserInfo.Sid, ldapUserInfo.UserName);
                if (onlyGetChanges)
                {
                    changes.SetNoneUserChange(ldapUserInfo);
                }

                return(userBySid);
            }

            _log.DebugFormat("SyncUserLDAP(SID: {0}, Username: '******') Userinfo is outdated, updating", ldapUserInfo.Sid, ldapUserInfo.UserName);
            if (!TryUpdateUserWithLDAPInfo(userToUpdate, ldapUserInfo, onlyGetChanges, out result))
            {
                if (onlyGetChanges)
                {
                    changes.SetSkipUserChange(ldapUserInfo);
                }

                return(Constants.LostUser);
            }

            if (onlyGetChanges)
            {
                changes.SetUpdateUserChange(ldapUserInfo, result, _log);
            }

            return(result);
        }
示例#29
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.RegisterClientLocalizationScript(typeof(ClientScripts.FilesLocalizationResources));
     Page.RegisterClientScript(typeof(ClientScripts.FilesConstantsResources));
     Page.RegisterInlineScript("if (typeof ZeroClipboard != 'undefined') {ZeroClipboard.setMoviePath('" + CommonLinkUtility.ToAbsolute("~/js/flash/zeroclipboard/zeroclipboard10.swf") + "');}");
 }
示例#30
0
        protected override void PageLoad()
        {
            var mainContent = (MainContent)LoadControl(MainContent.Location);

            mainContent.FolderIDCurrentRoot = Project == null ? Files.Classes.Global.FolderProjects : FileEngine2.GetRoot(Project.ID);
            mainContent.TitlePage           = ProjectsCommonResource.ModuleName;
            CommonContainerHolder.Controls.Add(mainContent);

            Master.DisabledEmptyScreens = true;

            Title = HeaderStringHelper.GetPageTitle(ProjectsFileResource.Files);

            Page.RegisterStyleControl(LoadControl(VirtualPathUtility.ToAbsolute("~/products/files/masters/styles.ascx")));
            Page.RegisterBodyScripts(LoadControl(VirtualPathUtility.ToAbsolute("~/products/files/masters/FilesScripts.ascx")));
            Page.RegisterClientLocalizationScript(typeof(Files.Masters.ClientScripts.FilesLocalizationResources));
            Page.RegisterClientScript(typeof(Files.Masters.ClientScripts.FilesConstantsResources));
            Page.RegisterInlineScript("if (typeof ZeroClipboard != 'undefined') {ZeroClipboard.setMoviePath('" + CommonLinkUtility.ToAbsolute("~/js/flash/zeroclipboard/zeroclipboard10.swf") + "');}");
        }