protected override void Render(HtmlTextWriter writer) { if (EmployeeInfo != null) { var isRetina = TenantLogoManager.IsRetina(HttpContext.Current.Request); StringBuilder sb = new StringBuilder(); sb.AppendFormat("<div {1} style=\"width: {0}px;overflow:hidden;\"><table cellpadding=\"0\" border=\"0\" cellspacing=\"0\" width=\"100%\" >", Width.Value, EmployeeInfo.ActivationStatus == EmployeeActivationStatus.Pending ? "class=\"pending\"" : ""); sb.Append("<tr valign='top'>"); sb.Append("<td align=\"left\" style=\"width:56px; padding-right:10px;\">"); sb.AppendFormat("<a class=\"borderBase\" {1} href=\"{0}\">", EmployeeUrl, "style=\"position:relative; text-decoration:none; display:block; height:48px; width:48px;\""); sb.Append("<img align=\"center\" alt=\"\" style='display:block;margin:0; position:relative;width:48px;' border=0 src=\"" + (isRetina ? EmployeeInfo.GetBigPhotoURL() : EmployeeInfo.GetMediumPhotoURL()) + "\"/>"); if (EmployeeInfo.ActivationStatus == EmployeeActivationStatus.Pending) { sb.Append("<div class=\"pendingInfo borderBase tintMedium\"><div>" + Resource.PendingTitle + "</div></div>"); } sb.Append("</a>"); sb.Append("</td>"); sb.Append("<td>"); if (!EmployeeInfo.ID.Equals(ASC.Core.Users.Constants.LostUser.ID)) { sb.Append("<div>"); sb.AppendFormat("<a class=\"link header-base middle bold\" data-id=\"{2}\" href=\"{0}\" title=\"{1}\">{1}</a>", EmployeeUrl, EmployeeInfo.DisplayUserName(), EmployeeInfo.ID); sb.Append("</div>"); //department sb.Append("<div style=\"padding-top: 6px;\">"); if (EmployeeInfo.Status != EmployeeStatus.Terminated) { var removecoma = false; foreach (var g in CoreContext.UserManager.GetUserGroups(EmployeeInfo.ID)) { sb.AppendFormat("<a class=\"link\" href=\"{0}\">", CommonLinkUtility.GetDepartment(g.ID)); sb.Append(HttpUtility.HtmlEncode(g.Name)); sb.Append("</a>, "); removecoma = true; } if (removecoma) { sb.Remove(sb.Length - 2, 2); } } sb.Append(" </div>"); sb.Append("<div style=\"padding-top: 6px;\">"); sb.Append(HttpUtility.HtmlEncode(EmployeeInfo.Title) ?? ""); sb.Append(" </div>"); } sb.Append("</td>"); sb.Append("</tr>"); sb.Append("</table></div>"); writer.Write(sb.ToString()); } base.Render(writer); }
public object AddAdmin(Guid id) { var isRetina = TenantLogoManager.IsRetina(HttpContext.Current.Request); SecurityContext.DemandPermissions(SecutiryConstants.EditPortalSettings); var user = CoreContext.UserManager.GetUsers(id); if (user.IsVisitor()) { throw new System.Security.SecurityException("Collaborator can not be an administrator"); } WebItemSecurity.SetProductAdministrator(Guid.Empty, id, true); MessageService.Send(HttpContext.Current.Request, MessageAction.AdministratorAdded, MessageTarget.Create(user.ID), user.DisplayUserName(false)); InitLdapRights(); return(new { id = user.ID, smallFotoUrl = user.GetSmallPhotoURL(), bigFotoUrl = isRetina ? user.GetBigPhotoURL() : "", displayName = user.DisplayUserName(), title = user.Title.HtmlEncode(), userUrl = CommonLinkUtility.GetUserProfile(user.ID), accessList = GetAccessList(user.ID, true) }); }
protected void Page_Load(object sender, EventArgs e) { TenantName = CoreContext.TenantManager.GetCurrentTenant().Name; Page.Title = TenantName; Master.DisabledSidePanel = true; if (Request.DesktopApp()) { Master.DisabledTopStudioPanel = true; } withHelpBlock = false; if (CoreContext.Configuration.Personal) { Master.DisabledLayoutMedia = true; Master.TopStudioPanel.TopLogo = TenantLogoManager.IsRetina(Request) ? WebImageSupplier.GetAbsoluteWebPath("personal_logo/[email protected]") : WebImageSupplier.GetAbsoluteWebPath("personal_logo/logo_personal_auth.png"); AutorizeDocuments.Controls.Add(CoreContext.Configuration.CustomMode ? LoadControl(AuthorizeDocs.LocationCustomMode) : LoadControl(AuthorizeDocs.Location)); } else { var authControl = (Authorize)LoadControl(Authorize.Location); authControl.IsLogout = IsLogout; AuthorizeHolder.Controls.Add(authControl); CommunitationsHolder.Controls.Add(LoadControl(AuthCommunications.Location)); withHelpBlock = true; } }
protected string GetAbsoluteCompanyTopLogoPath() { var general = !TenantLogoManager.IsRetina(Request); return (CoreContext.Configuration.Personal ? WebImageSupplier.GetAbsoluteWebPath("personal_logo/logo_personal_auth.png") : TenantLogoManager.WhiteLabelEnabled ? TenantLogoManager.GetLogoDark(general) : TenantWhiteLabelSettings.GetAbsoluteDefaultLogoPath(WhiteLabelLogoTypeEnum.Dark, general)); }
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; _configuration.Document.Info.Favorite = null; 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; _configuration.Document.Info.Favorite = null; } } 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; _configuration.Document.Permissions.ModifyFilter = false; _editByUrl = true; _configuration.Document.Url = fileUri; _configuration.Document.Info.Favorite = null; } ErrorMessage = _configuration.ErrorMessage; } catch (Exception ex) { Global.Logger.Warn("DocEditor", ex); ErrorMessage = ex.Message; return; } var userAgent = Request.UserAgent.ToString().ToLower(); HttpCookie deeplinkCookie = Request.Cookies.Get("deeplink"); var deepLink = ConfigurationManagerExtension.AppSettings["deeplink.documents.url"]; if (!_valideShareLink && deepLink != null && MobileDetector.IsMobile && ((!userAgent.Contains("version/") && userAgent.Contains("android")) || !userAgent.Contains("android")) && //check webkit ((Request[DeepLinking.WithoutDeeplinkRedirect] == null && deeplinkCookie == null) || Request[DeepLinking.WithoutDeeplinkRedirect] == null && deeplinkCookie != null && deeplinkCookie.Value == "app")) { var currentUser = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID); DeepLinkData deepLinkData = new DeepLinkData { Email = currentUser.Email, Portal = CoreContext.TenantManager.GetCurrentTenant().TenantDomain, File = new DeepLinkDataFile { Id = file.ID.ToString(), Title = file.Title, Extension = file.ConvertedExtension }, Folder = new DeepLinkDataFolder { Id = file.FolderID.ToString(), ParentId = file.RootFolderId.ToString(), RootFolderType = (int)file.RootFolderType }, OriginalUrl = Request.GetUrlRewriter().ToString() }; var jsonDeeplinkData = JsonConvert.SerializeObject(deepLinkData); string base64DeeplinkData = Convert.ToBase64String(Encoding.UTF8.GetBytes(jsonDeeplinkData)); Response.Redirect("~/DeepLink.aspx?data=" + HttpUtility.UrlEncode(base64DeeplinkData)); } 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; } var fileSecurity = Global.GetFilesSecurity(); if (_configuration.EditorConfig.ModeWrite && FileUtility.CanWebRestrictedEditing(file.Title) && fileSecurity.CanFillForms(file) && !fileSecurity.CanEdit(file)) { if (!file.IsFillFormDraft) { FileMarker.RemoveMarkAsNew(file); Folder folderIfNew; try { file = EntryManager.GetFillFormDraft(file, out folderIfNew); } catch (Exception ex) { _configuration = null; Global.Logger.Error("DocEditor", ex); ErrorMessage = ex.Message; return; } var comment = folderIfNew == null ? string.Empty : "#message/" + HttpUtility.UrlEncode(string.Format(FilesCommonResource.MessageFillFormDraftCreated, folderIfNew.Title)); Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment); return; } else if (!EntryManager.CheckFillFormDraft(file)) { var comment = "#message/" + HttpUtility.UrlEncode(FilesCommonResource.MessageFillFormDraftDiscard); Response.Redirect(FilesLinkUtility.GetFileWebEditorUrl(file.ID) + comment); return; } } Title = file.Title + GetPageTitlePostfix(); 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 (file.RootFolderType == FolderType.Privacy) { if (!PrivacyRoomSettings.Enabled) { _configuration = null; ErrorMessage = FilesCommonResource.ErrorMassage_FileNotFound; return; } else { if (Request.DesktopApp()) { var keyPair = EncryptionKeyPair.GetKeyPair(); if (keyPair != null) { _configuration.EditorConfig.EncryptionKeys = new Services.DocumentService.Configuration.EditorConfiguration.EncryptionKeysConfig { PrivateKeyEnc = keyPair.PrivateKeyEnc, PublicKey = keyPair.PublicKey, }; } } } } } if (!isExtenral) { _docKeyForTrack = DocumentServiceHelper.GetDocKey(file.ID, -1, DateTime.MinValue); FileMarker.RemoveMarkAsNew(file); if (!file.Encrypted && !file.ProviderEntry) { EntryManager.MarkAsRecent(file); } if (RequestView) { FilesMessageService.Send(file, MessageInitiator.DocsService, MessageAction.FileReaded, file.Title); } else { FilesMessageService.Send(file, MessageInitiator.DocsService, MessageAction.FileOpenedForChange, file.Title); } } if (SecurityContext.IsAuthenticated) { var saveAsUrl = SaveAs.GetUrl; using (var folderDao = Global.DaoFactory.GetFolderDao()) { var folder = folderDao.GetFolder(file.FolderID); if (folder != null && Global.GetFilesSecurity().CanCreate(folder)) { saveAsUrl = SaveAs.GetUrlToFolder(file.FolderID); } } _configuration.EditorConfig.SaveAsUrl = CommonLinkUtility.GetFullAbsolutePath(saveAsUrl); } 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 (Request.DesktopApp()) { _linkToEdit += "&desktop=true"; } if (FileConverter.MustConvert(_configuration.Document.Info.File)) { _editByUrl = true; } } var actionAnchor = Request[FilesLinkUtility.Anchor]; if (!string.IsNullOrEmpty(actionAnchor)) { _configuration.EditorConfig.ActionLinkString = actionAnchor; } }
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) { var ver = string.IsNullOrEmpty(Request[FilesLinkUtility.Version]) ? -1 : Convert.ToInt32(Request[FilesLinkUtility.Version]); file = DocumentServiceHelper.GetParams(RequestFileId, ver, RequestShareLinkKey, editPossible, !RequestView, true, out _configuration); } 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)) ?? ""; } if (CoreContext.Configuration.Standalone) { try { var webRequest = (HttpWebRequest)WebRequest.Create(RequestFileUrl); // hack. http://ubuntuforums.org/showthread.php?t=1841740 if (WorkContext.IsMono) { ServicePointManager.ServerCertificateValidationCallback += (s, ce, ca, p) => true; } using (var response = webRequest.GetResponse()) using (var responseStream = new ResponseStream(response)) { var externalFileKey = DocumentServiceConnector.GenerateRevisionId(RequestFileUrl); fileUri = DocumentServiceConnector.GetExternalUri(responseStream, MimeMapping.GetMimeMapping(fileTitle), externalFileKey); } } catch (Exception error) { Global.Logger.Error("Cannot receive external url for \"" + RequestFileUrl + "\"", error); } } 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.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.ExecDuplicate(file, RequestShareLinkKey); } catch (Exception ex) { _configuration = null; Global.Logger.Error("DocEditor", ex); ErrorMessage = ex.Message; return; } var comment = "#message/" + HttpUtility.UrlEncode(FilesCommonResource.CopyForEdit); 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)) { _configuration.EditorConfig.SharingSettingsUrl = CommonLinkUtility.GetFullAbsolutePath(Share.Location + "?" + FilesLinkUtility.FileId + "=" + file.ID); } } if (!isExtenral) { _docKeyForTrack = DocumentServiceHelper.GetDocKey(file.ID, -1, DateTime.MinValue); FileMarker.RemoveMarkAsNew(file); } if (_configuration.EditorConfig.ModeWrite) { _tabId = FileTracker.Add(file.ID); if (SecurityContext.IsAuthenticated) { _configuration.EditorConfig.FileChoiceUrl = CommonLinkUtility.GetFullAbsolutePath(FileChoice.Location) + "?" + FileChoice.ParamFilterExt + "=xlsx&" + FileChoice.MailMergeParam + "=true"; _configuration.EditorConfig.MergeFolderUrl = CommonLinkUtility.GetFullAbsolutePath(MailMerge.GetUrl); } } 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; } } }
private void RegisterClientScript() { var isRetina = TenantLogoManager.IsRetina(HttpContext.Current.Request); Page.RegisterBodyScripts("~/usercontrols/management/accessrights/js/accessrights.js") .RegisterStyle("~/usercontrols/management/accessrights/css/accessrights.less"); var curTenant = CoreContext.TenantManager.GetCurrentTenant(); var currentOwner = CoreContext.UserManager.GetUsers(curTenant.OwnerId); var admins = WebItemSecurity.GetProductAdministrators(Guid.Empty).ToList(); admins = admins .GroupBy(admin => admin.ID) .Select(group => group.First()) .Where(admin => admin.ID != currentOwner.ID) .SortByUserName(); InitLdapRights(); var sb = new StringBuilder(); sb.AppendFormat("ownerId = \"{0}\";", curTenant.OwnerId); sb.AppendFormat("adminList = {0};", JsonConvert.SerializeObject(admins.ConvertAll(u => new { id = u.ID, smallFotoUrl = u.GetSmallPhotoURL(), bigFotoUrl = isRetina ? u.GetBigPhotoURL() : "", displayName = u.DisplayUserName(), title = u.Title.HtmlEncode(), userUrl = CommonLinkUtility.GetUserProfile(u.ID), accessList = GetAccessList(u.ID, WebItemSecurity.IsProductAdministrator(Guid.Empty, u.ID)), ldap = LdapRights.Contains(u.ID.ToString()) }))); sb.AppendFormat("imageHelper = {0};", JsonConvert.SerializeObject(new { PeopleImgSrc = WebImageSupplier.GetAbsoluteWebPath("user_12.png"), GroupImgSrc = WebImageSupplier.GetAbsoluteWebPath("group_12.png"), TrashImgSrc = WebImageSupplier.GetAbsoluteWebPath("trash_12.png"), TrashImgTitle = Resource.DeleteButton })); var managementPage = Page as Studio.Management; var tenantAccess = managementPage != null ? managementPage.TenantAccess : TenantAccessSettings.Load(); if (!tenantAccess.Anyone) { var productItemList = GetProductItemListForSerialization(); foreach (var productItem in productItemList.Where(productItem => !productItem.CanNotBeDisabled)) { sb.AppendFormat("ASC.Settings.AccessRights.initProduct('{0}');", Convert.ToBase64String( Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(productItem)))); } } sb.AppendFormat("ASC.Settings.AccessRights.init({0});", JsonConvert.SerializeObject(Products.Select(p => p.GetSysName()).ToArray())); Page.RegisterInlineScript(sb.ToString()); }
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; } }
private void InitScript() { var inlineScript = new StringBuilder(); inlineScript.AppendFormat("\nASC.Files.Constants.URL_WCFSERVICE = \"{0}\";", PathProvider.GetFileServicePath); if (!CoreContext.Configuration.Personal) { inlineScript.AppendFormat("\nASC.Files.Constants.URL_MAIL_ACCOUNTS = \"{0}\";", CommonLinkUtility.GetFullAbsolutePath("~/addons/mail/#accounts")); } if (SecurityContext.IsAuthenticated && !CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor()) { inlineScript.AppendFormat("ASC.Files.Constants.URL_HANDLER_CREATE = \"{0}\";" + "ASC.Files.Constants.TitleNewFileText = \"{1}\";" + "ASC.Files.Constants.TitleNewFileSpreadsheet = \"{2}\";" + "ASC.Files.Constants.TitleNewFilePresentation = \"{3}\";", CommonLinkUtility.GetFullAbsolutePath(FilesLinkUtility.FileHandlerPath), FilesJSResource.TitleNewFileText, FilesJSResource.TitleNewFileSpreadsheet, FilesJSResource.TitleNewFilePresentation); } var isRetina = TenantLogoManager.IsRetina(Request); inlineScript.AppendFormat("\nASC.Files.Editor.brandingLogoUrl = \"{0}\";" + "ASC.Files.Editor.brandingLogoEmbeddedUrl = \"{1}\";" + "ASC.Files.Editor.brandingCustomerLogo = \"{2}\";" + "ASC.Files.Editor.brandingCustomer = \"{3}\";" + "ASC.Files.Editor.brandingSite = \"{4}\";", CommonLinkUtility.GetFullAbsolutePath(TenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.DocsEditor, !isRetina)), CommonLinkUtility.GetFullAbsolutePath(TenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.Dark, !isRetina)), CommonLinkUtility.GetFullAbsolutePath(TenantLogoHelper.GetLogo(WhiteLabelLogoTypeEnum.Dark, !isRetina)), (SettingsManager.Instance.LoadSettings <TenantWhiteLabelSettings>(TenantProvider.CurrentTenantID).LogoText ?? "").Replace("\\", "\\\\").Replace("\"", "\\\"").Replace("/", "\\/"), CompanyWhiteLabelSettings.Instance.Site); inlineScript.AppendFormat("\nASC.Files.Editor.docKeyForTrack = \"{0}\";" + "ASC.Files.Editor.shareLinkParam = \"{1}\";" + "ASC.Files.Editor.serverErrorMessage = \"{2}\";" + "ASC.Files.Editor.editByUrl = ({3} == true);" + "ASC.Files.Editor.fixedVersion = ({4} == true);" + "ASC.Files.Editor.tabId = \"{5}\";" + "ASC.Files.Editor.thirdPartyApp = ({6} == true);" + "ASC.Files.Editor.openinigDate = \"{7}\";", _docKeyForTrack, string.IsNullOrEmpty(RequestShareLinkKey) ? string.Empty : "&" + FilesLinkUtility.DocShareKey + "=" + RequestShareLinkKey, (_errorMessage ?? "").Replace("\n", "\\n").Replace("\r", "").Replace("\"", "\\\""), _editByUrl.ToString().ToLower(), _fixedVersion.ToString().ToLower(), _tabId, _thirdPartyApp.ToString().ToLower(), DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)); if (!CoreContext.Configuration.Standalone) { inlineScript.AppendFormat("\nASC.Files.Editor.showAbout = true;" + "ASC.Files.Editor.feedbackUrl = \"{0}\";", AdditionalWhiteLabelSettings.Instance.FeedbackAndSupportEnabled ? CommonLinkUtility.GetRegionalUrl( AdditionalWhiteLabelSettings.Instance.FeedbackAndSupportUrl, CultureInfo.CurrentCulture.TwoLetterISOLanguageName) : string.Empty); } else if (_docParams != null) { inlineScript.AppendFormat("\nASC.Files.Editor.licenseUrl = \"{0}\";" + "ASC.Files.Editor.customerId = \"{1}\";", PathProvider.GetLicenseUrl(_docParams.File), LicenseReader.CustomerId); } inlineScript.Append(BuildOptions()); inlineScript.AppendFormat("\nASC.Files.Editor.docServiceParams = {0};", DocumentServiceParams.Serialize(_docParams)); InlineScripts.Scripts.Add(new Tuple <string, bool>(inlineScript.ToString(), false)); }