/// <summary> /// Creates workflow scope. Called when the "Create scope" button is pressed. /// Expects the "CreateWorkflow" method to be run first. /// </summary> private bool CreateWorkflowScope() { // Get the workflow WorkflowInfo workflow = WorkflowInfoProvider.GetWorkflowInfo("MyNewWorkflow"); if (workflow != null) { // Create new workflow scope object WorkflowScopeInfo newScope = new WorkflowScopeInfo(); // Get the site default culture from settings string cultureCode = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSDefaultCultureCode"); CultureInfo culture = CultureInfoProvider.GetCultureInfo(cultureCode); // Get root document type class ID int classID = DataClassInfoProvider.GetDataClassInfo("CMS.Root").ClassID; // Set the properties newScope.ScopeStartingPath = "/"; newScope.ScopeCultureID = culture.CultureID; newScope.ScopeClassID = classID; newScope.ScopeWorkflowID = workflow.WorkflowID; newScope.ScopeSiteID = SiteContext.CurrentSiteID; // Save the workflow scope WorkflowScopeInfoProvider.SetWorkflowScopeInfo(newScope); return(true); } return(false); }
/// <summary> /// Expects the "CreateDocumentStructure" method to be run first. /// </summary> private bool SetRolePermissions() { // Create an instance of the Tree provider TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Get default culture code string culture = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSDefaultCultureCode"); // Get the API Example document TreeNode node = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/API-Example", culture); if (node != null) { // Get the role ID RoleInfo role = RoleInfoProvider.GetRoleInfo("CMSDeskAdmin", SiteContext.CurrentSiteName); if (role != null) { // Prepare allowed / denied permissions int allowed = 0; int denied = 0; allowed += Convert.ToInt32(Math.Pow(2, Convert.ToInt32(NodePermissionsEnum.Modify))); // Set role permissions AclItemInfoProvider.SetRolePermissions(node, allowed, denied, role); return(true); } } return(false); }
/// <summary> /// Indicates if there is needed fallback to root document. /// </summary> /// <param name="selectedNode">Selected node</param> private bool UseFallbackToRoot(TreeNode selectedNode) { if (selectedNode != null) { bool useFallback = false; string currentAliasPath = selectedNode.NodeAliasPath; // Check user's starting path string userStartingPath = CurrentUser.UserStartingAliasPath; if (!String.IsNullOrEmpty(userStartingPath)) { useFallback = !currentAliasPath.StartsWithCSafe(userStartingPath, true) && (TreePathUtils.GetNodeIdByAliasPath(selectedNode.NodeSiteName, userStartingPath) > 0); } if (IsProductTree) { // Check products starting path if in Products UI string productsStartingPath = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSStoreProductsStartingPath"); if (!String.IsNullOrEmpty(productsStartingPath)) { useFallback |= !currentAliasPath.StartsWithCSafe(productsStartingPath, true) && (TreePathUtils.GetNodeIdByAliasPath(selectedNode.NodeSiteName, productsStartingPath) > 0); } } return(useFallback); } return(true); }
/// <summary> /// Makes permission check for specified node - provides check in its ACLs, document type and Content module /// Expects the "CreateDocumentStructure" method to be run first. /// </summary> private bool CheckDocumentPermissions() { // Create an instance of the Tree provider TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Get default culture code string culture = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSDefaultCultureCode"); // Get the API Example document TreeNode node = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/API-Example", culture); if (node != null) { // Get the user UserInfo user = UserInfoProvider.GetUserInfo("Andy"); if (user != null) { // Check permissions and perform an action according to the result if (TreeSecurityProvider.IsAuthorizedPerNode(node, NodePermissionsEnum.ModifyPermissions, user) == AuthorizationResultEnum.Allowed) { apiCheckDocumentPermissions.InfoMessage = "User 'Andy' is allowed to modify permissions for the page 'API Example'."; } else { apiCheckDocumentPermissions.InfoMessage = "User 'Andy' is not allowed to modify permissions for the page 'API Example'."; } return(true); } } return(false); }
protected void Page_Load(object sender, EventArgs e) { // Load allowed extensions if (!chkInehrit.Checked) { // User defined extensions if (ContainsColumn("allowed_extensions")) { txtAllowedExtensions.Text = ValidationHelper.GetString(Form.Data.GetValue("allowed_extensions"), null); } } // Site extensions else { txtAllowedExtensions.Text = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSUploadExtensions"); } // Registred scripts ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "DocAttachments_EnableDisableForm", GetScriptEnableDisableForm()); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "DocAttachments_ReceiveExtensions", GetScriptReceiveExtensions()); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "DocAttachments_LoadSiteSettings", ScriptHelper.GetScript("function GetExtensions(txtAllowedExtensions){ return " + Page.ClientScript.GetCallbackEventReference(this, "txtAllowedExtensions", "ReceiveExtensions", null) + " } \n")); // Initialize form chkInehrit.Attributes.Add("onclick", GetEnableDisableFormDefinition()); EnableDisableForm(); }
/// <summary> /// Runs the update procedure. /// </summary> public static void Update() { if (DatabaseHelper.IsDatabaseAvailable) { try { string version = SettingsKeyInfoProvider.GetStringValue("CMSDataVersion"); switch (version.ToLowerCSafe()) { case "8.0": using (var context = new CMSActionContext()) { context.LogLicenseWarnings = false; UpgradeApplication(Upgrade80To81, "8.1", "Upgrade_80_81.zip"); } break; } } catch (Exception ex) { EventLogProvider.LogException(EventLogSource, "Upgrade", ex); } } }
protected void Page_Load(object sender, EventArgs e) { //lblOgoneUrl.Text = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".OgoneUrl"); //lblOgoneID.Text = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".OgonePSPID"); //lblOgoneSHA.Text = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".OgoneShaHandshake"); //lblTest.Text = URLHelper.ResolveUrl("~/Webshop/ShoppingCart.aspx"); if (Request.UrlReferrer == null) { ShowPageCallError(); return; } var path = Request.UrlReferrer.AbsolutePath; var pathArray = path.Split('/'); if (pathArray.Length < 2 || !pathArray[pathArray.Length - 1].Equals("Shoppingcart.aspx") || !pathArray[pathArray.Length - 2].Equals("Shopping")) { ShowPageCallError(); return; } var orderId = QueryHelper.GetInteger("orderid", 0); if (orderId == 0) { ShowPageCallError(); return; } body.Attributes.Add("onload", "window.document.forms[0].submit();"); paymentForm.Action = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".OgoneUrl"); LoadValues(orderId); SetFields(); }
/// <summary> /// Returns the filter parameter. /// </summary> private string GetFilterParameters() { string filter = null; if (String.IsNullOrEmpty(AllowedExtensions)) { if (MediaLibraryID > 0) { filter = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSMediaFileAllowedExtensions"); } else { filter = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSUploadExtensions"); } } else { filter = AllowedExtensions; } if (!string.IsNullOrEmpty(filter)) { // Append hash to list of allowed extensions string hash = ValidationHelper.GetHashString(filter, false); filter = String.Format("Filter=Allowed files|*.{0}{1}Hash{1}{2}", filter.Replace(";", "; *."), PARAMETER_SEPARATOR, hash); } return(filter); }
protected void Page_Load(object sender, EventArgs e) { // Set trimming ability from form controls parameters Trim = ValidationHelper.GetBoolean(GetValue("trim"), false); CheckMinMaxLength = true; CheckRegularExpression = true; string watermark = null; // Get default value if (!String.IsNullOrEmpty(WatermarkValueKey)) { switch (WatermarkValueSourceType) { // Get value from settings case ValueSourceType.Settings: watermark = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + "." + WatermarkValueKey); break; // Get value from resource strings case ValueSourceType.ResourceString: watermark = ResHelper.GetString(WatermarkValueKey); break; } } // Set default value as watermark if (!String.IsNullOrEmpty(watermark)) { txtValue.WatermarkText = watermark; } }
/// <summary> /// SignOut click event handler. /// </summary> protected void btnSignOut_Click(object sender, EventArgs e) { if (currentUser == null) { currentUser = MembershipContext.AuthenticatedUser; } if (AuthenticationHelper.IsAuthenticated()) { string redirectUrl = SignOutPath != "" ? GetUrl(SignOutPath) : RequestContext.CurrentURL; // If the user is Windows Live user if (!string.IsNullOrEmpty(currentUser.UserSettings.WindowsLiveID)) { string siteName = SiteContext.CurrentSiteName; // Get LiveID settings string appId = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSApplicationID"); string secret = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSApplicationSecret"); // Check valid Windows LiveID parameters if ((appId != string.Empty) && (secret != string.Empty)) { WindowsLiveLogin wll = new WindowsLiveLogin(appId, secret); // Redirect to Windows Live redirectUrl = wll.GetLogoutUrl(); } } AuthenticationHelper.SignOut(); Response.Cache.SetNoStore(); URLHelper.Redirect(redirectUrl); } }
/// <summary> /// OnLoad event. /// </summary> /// <param name="e">Event arguments</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); repItem.ItemDataBound += repItem_ItemDataBound; currentUser = MembershipContext.AuthenticatedUser; string script = ""; // Join the group script += "function ContextJoinTheGroup(id) { \n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/JoinTheGroup.aspx") + "?groupid=' + id, 'joinTheGroup', 500, 180); \n" + " } \n"; // Leave the group script += "function ContextLeaveTheGroup(id) { \n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/LeaveTheGroup.aspx") + "?groupid=' + id , 'leaveTheGroup', 500, 180); \n" + " } \n"; // Redirect to sign in URL string signInUrl = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSSecuredAreasLogonPage"); if (!string.IsNullOrEmpty(signInUrl)) { signInUrl = "window.location.replace('" + URLHelper.AddParameterToUrl(ResolveUrl(signInUrl), "ReturnURL", Server.UrlEncode(RequestContext.CurrentURL)) + "');"; } script += "function ContextRedirectToSignInUrl() { \n" + signInUrl + "} \n"; script += "function ReloadPage(){ window.location.replace(window.location.href); }"; // Register menu management scripts ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "GroupContextMenuManagement", ScriptHelper.GetScript(script)); // Register the dialog script ScriptHelper.RegisterDialogScript(Page); }
public void RaiseCallbackEvent(string eventArgument) { // Get site settings extensions = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSUploadExtensions"); // Returns site settings back to the client extensions = string.Format("{0}|{1}", extensions, eventArgument); }
/// <summary> /// Ensures the physical file. /// </summary> /// <param name="file">Output file</param> public bool EnsurePhysicalFile(CMSOutputMediaFile file) { if (file == null) { return(false); } // Try to link to file system if (String.IsNullOrEmpty(file.Watermark) && (file.MediaFile != null) && (file.MediaFile.FileID > 0)) { SiteInfo si = SiteInfoProvider.GetSiteInfo(file.MediaFile.FileSiteID); if (si != null) { bool generateThumbnails = ValidationHelper.GetBoolean(SettingsKeyInfoProvider.GetStringValue(si.SiteName + ".CMSGenerateThumbnails"), true); string filePath = null; string libraryFolder = Path.EnsureEndBackslash(MediaLibraryInfoProvider.GetMediaLibraryFolderPath(file.MediaFile.FileLibraryID)); if (file.Resized && generateThumbnails) { filePath = libraryFolder + MediaFileInfoProvider.EnsureThumbnailFile(file.MediaFile, file.SiteName, Width, Height, MaxSideSize, file.UsePreview); } else { if (file.UsePreview) { // Get file path string path = MediaFileInfoProvider.GetMediaFilePath(file.MediaFile.FileLibraryID, file.MediaFile.FilePath); string pathDirectory = Path.GetDirectoryName(path); string hiddenFolderPath = MediaLibraryHelper.GetMediaFileHiddenFolder(CurrentSiteName); string folderPath = String.Format("{0}\\{1}", pathDirectory, hiddenFolderPath); // Ensure hidden folder exists DirectoryHelper.EnsureDiskPath(folderPath, pathDirectory); // Get preview file string[] files = Directory.GetFiles(folderPath, MediaLibraryHelper.GetPreviewFileName(file.MediaFile.FileName, file.MediaFile.FileExtension, ".*", CurrentSiteName)); if (files.Length > 0) { filePath = files[0]; } } else { filePath = libraryFolder + file.MediaFile.FilePath; } } if (filePath != null) { // Link to the physical file file.PhysicalFile = filePath; return(true); } } } file.PhysicalFile = ""; return(false); }
/// <summary> /// OnLoad event. /// </summary> /// <param name="e">Event arguments</param> protected override void OnLoad(EventArgs e) { base.OnLoad(e); repItem.ItemDataBound += repItem_ItemDataBound; currentUser = MembershipContext.AuthenticatedUser; string script = ""; // Friendship request script += "function ContextFriendshipRequest(id) { \n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Friends/CMSPages/Friends_Request.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id,'requestFriend', 810, 460); \n" + " } \n"; // Friendship rejection script += "function ContextFriendshipReject(id) { \n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Friends/CMSPages/Friends_Reject.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'rejectFriend', 720, 320); \n" + " } \n"; // Send private message script += "function ContextPrivateMessage(id) { \n" + "modalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Messaging/CMSPages/SendMessage.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'sendMessage', 700, 650); \n" + " } \n"; // Add to contact list script += "function ContextAddToContactList(usertoadd) { \n" + "if(confirm(" + ScriptHelper.GetString(ResHelper.GetString("messaging.contactlist.addconfirmation")) + "))" + "{" + Page.ClientScript.GetPostBackEventReference(this, "addtocontactlist", false) + "} } \n"; // Add to ignore list script += "function ContextAddToIgnoretList(usertoadd) { \n" + "if(confirm(" + ScriptHelper.GetString(ResHelper.GetString("messaging.ignorelist.addconfirmation")) + "))" + "{" + Page.ClientScript.GetPostBackEventReference(this, "addtoignorelist", false) + "} } \n"; // Group invitation script += "function ContextGroupInvitation(id) { \nmodalDialog('" + AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?invitedid=' + id , 'inviteToGroup', 500, 450); \n } \n"; // Redirect to sign in URL string signInUrl = MacroResolver.Resolve(SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSSecuredAreasLogonPage")); if (signInUrl != "") { signInUrl = "window.location.replace('" + URLHelper.AddParameterToUrl(ResolveUrl(signInUrl), "ReturnURL", Server.UrlEncode(RequestContext.CurrentURL)) + "');"; } script += "function ContextRedirectToSignInUrl() { \n" + signInUrl + "} \n"; // Register menu management scripts ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "UserContextMenuManagement", ScriptHelper.GetScript(script)); // Register the dialog script ScriptHelper.RegisterDialogScript(Page); }
protected void InitializeProperties() { string autoresize = ValidationHelper.GetString(FieldInfo.Settings["autoresize"], "").ToLowerCSafe(); // Set custom settings if (autoresize == "custom") { if (FieldInfo.Settings["autoresize_width"] != null) { ResizeToWidth = ValidationHelper.GetInteger(FieldInfo.Settings["autoresize_width"], 0); } if (FieldInfo.Settings["autoresize_height"] != null) { ResizeToHeight = ValidationHelper.GetInteger(FieldInfo.Settings["autoresize_height"], 0); } if (FieldInfo.Settings["autoresize_maxsidesize"] != null) { ResizeToMaxSideSize = ValidationHelper.GetInteger(FieldInfo.Settings["autoresize_maxsidesize"], 0); } } // Set site settings else if (autoresize == "") { string siteName = SiteContext.CurrentSiteName; ResizeToWidth = ImageHelper.GetAutoResizeToWidth(siteName); ResizeToHeight = ImageHelper.GetAutoResizeToHeight(siteName); ResizeToMaxSideSize = ImageHelper.GetAutoResizeToMaxSideSize(siteName); } if (UseFileUploader) { string siteName = SiteContext.CurrentSiteName; string siteExtensions = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSUploadExtensions"); string allExtensions = siteExtensions; string customExtensions = ValidationHelper.GetString(FieldInfo.Settings["allowed_extensions"], ""); if (!string.IsNullOrEmpty(customExtensions)) { allExtensions += ";" + customExtensions; } AllowedExtensions = allExtensions; } else { if (ValidationHelper.GetString(FieldInfo.Settings["extensions"], "") == "custom") { // Load allowed extensions AllowedExtensions = ValidationHelper.GetString(FieldInfo.Settings["allowed_extensions"], ""); } else { // Use site settings string siteName = SiteContext.CurrentSiteName; AllowedExtensions = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSUploadExtensions"); } } }
protected void Page_Load(object sender, EventArgs e) { PageTitle title = PageTitle; title.TitleText = ResHelper.GetString("mem.reg.approvaltext"); // Set administrator e-mail registrationApproval.AdministratorEmail = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSAdminEmailAddress"); registrationApproval.FromAddress = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSNoreplyEmailAddress"); }
/// <summary> /// Fills check box list with current values /// </summary> private void FillItems() { Dictionary <String, bool> items = OutputCache ? CacheHelper.GetCombinedCacheItems(SettingsKeyInfoProvider.GetStringValue("CMSOutputCacheItems"), OutputHelper.AvailableCacheItemNames) : CacheHelper.GetCombinedCacheItems(SettingsKeyInfoProvider.GetStringValue("CMSPartialCacheItems"), CMSAbstractWebPart.AvailableCacheItemNames); foreach (var item in items) { ListItem li = new ListItem(item.Key, item.Key); chkList.Items.Add(li); li.Selected = item.Value; } }
private void SendMail(string mail, IEnumerable <ProductBookModel> list) { SiteInfo currentSite = SiteContext.CurrentSite; ContextResolver resolver = MacroContext.CurrentResolver; string emailSubject = null; EmailTemplateInfo template = null; template = EmailTemplateProvider.GetEmailTemplate("SendProductLinkDownload", currentSite.SiteName); emailSubject = EmailHelper.GetSubject(template, "Demande de contact"); //mail type if (template != null) { ev.LogEvent("I", DateTime.Now, "Template!=null ", (template != null).ToString()); resolver.SourceParameters = null; EmailMessage email = new EmailMessage(); email.EmailFormat = EmailFormatEnum.Default; email.From = EmailHelper.GetSender(template, SettingsKeyInfoProvider.GetStringValue(currentSite.SiteName + ".CMSAdminEmailAddress")); email.Recipients = mail; StringBuilder sb = new StringBuilder(); foreach (var produit in list) { string str = "<br/> <b>" + produit.productname + "</b> (" + produit.fileUrl + ")"; sb = sb.AppendLine(str); } ev.LogEvent("I", DateTime.Now, "Template ", sb.ToString()); string templatetext = template.TemplateText.Replace("#Product", sb.ToString()); email.Body = resolver.ResolveMacros(templatetext); resolver.EncodeResolvedValues = false; email.PlainTextBody = resolver.ResolveMacros(template.TemplatePlainText); email.Subject = resolver.ResolveMacros(emailSubject); email.CcRecipients = template.TemplateCc; email.BccRecipients = template.TemplateBcc; try { MetaFileInfoProvider.ResolveMetaFileImages(email, template.TemplateID, EmailObjectType.EMAILTEMPLATE, MetaFileInfoProvider.OBJECT_CATEGORY_TEMPLATE); // Send the e-mail immediately EmailSender.SendEmail(currentSite.SiteName, email, true); } catch (Exception ex) { ev.LogEvent("E", DateTime.Now, "SendMail ", ex.Message); } } }
/// <summary> /// Returns true if given path is excluded from URL rewriting. /// </summary> /// <param name="requestPath">Path to be checked</param> public static bool IsExcluded(string requestPath) { string customExcludedPaths = ""; // Get Custom excluded URLs path if (SiteContext.CurrentSite != null && SiteContext.CurrentSiteName != null && SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSExcludedURLs") != null) { customExcludedPaths = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSExcludedURLs"); } return(URLHelper.IsExcluded(requestPath, customExcludedPaths)); }
protected void btnLogin_Click(object sender, EventArgs e) { // Get the logon page URL string logonPage = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSSecuredAreasLogonPage"); if (logonPage == string.Empty) { logonPage = "../CMSPages/Logon.aspx"; } ltlScript.Text = ScriptHelper.GetScript("window.top.location.href = '" + ResolveUrl(logonPage) + "';"); }
/// <summary> /// Sets base and unsubscription URLs. /// </summary> private void SetUrls() { // Get base and unsubscription url from settings baseUrl = ValidationHelper.GetString(SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSForumBaseUrl"), ""); unsubscriptionUrl = ValidationHelper.GetString(SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSForumUnsubscriptionUrl"), ""); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "CheckBoxes", ScriptHelper.GetScript(@" function check(txtId,chk,inhV) { txt = document.getElementById(txtId); if ((txt != null)&&(chk != null)) { if (chk.checked) { txt.disabled = 'disabled'; txt.value = inhV; } else { txt.disabled = ''; } } } ")); // Force output filter to not resolve URLs in textboxes OutputFilterContext.CanResolveAllUrls = false; if (chkInheritBaseUrl.Checked) { txtForumBaseUrl.Text = baseUrl; txtForumBaseUrl.Enabled = false; } else { txtForumBaseUrl.Enabled = true; } if (chkInheritUnsubUrl.Checked) { txtUnsubscriptionUrl.Text = unsubscriptionUrl; txtUnsubscriptionUrl.Enabled = false; } else { txtUnsubscriptionUrl.Enabled = true; } chkInheritBaseUrl.Attributes.Add("onclick", "check('" + txtForumBaseUrl.ClientID + "', this,'" + baseUrl + "')"); chkInheritUnsubUrl.Attributes.Add("onclick", "check('" + txtUnsubscriptionUrl.ClientID + "', this,'" + unsubscriptionUrl + "')"); }
/// <summary> /// Attempts to create page Identity data based on the old Information we have and returns it in a typed object /// representing the page identity /// </summary> /// <param name="site">Object representing current site. (NOT Facebook site!!!) Needed because of siteName to get the correct settings.</param> /// <returns>Facebook PageIDData in correct format on success, null otherwise</returns> private static FacebookPageIdentityData?GetPageIdentity(SiteInfo site) { string siteName = site.SiteName; string pageId = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSFacebookPageId"); string pageUrl = null; if (!TryGetFacebookPageURL(pageId, out pageUrl)) { return(null); } return(new FacebookPageIdentityData(pageUrl, pageId)); }
/// <summary> /// Returns true if user control is valid. /// </summary> public override bool IsValid() { // Check allow empty if ((FieldInfo != null) && !FieldInfo.AllowEmpty && ((Form == null) || Form.CheckFieldEmptiness)) { if (String.IsNullOrEmpty(uploader.CurrentFileName) && (uploader.PostedFile == null)) { // Error empty ValidationError += ResHelper.GetString("BasicForm.ErrorEmptyValue"); return(false); } } // Test if file has allowed file-type if ((uploader.PostedFile != null) && (!String.IsNullOrEmpty(uploader.PostedFile.FileName.Trim()))) { string customExtension = ValidationHelper.GetString(GetValue("extensions"), String.Empty); string extensions = null; if (CMSString.Compare(customExtension, "custom", true) == 0) { extensions = ValidationHelper.GetString(GetValue("allowed_extensions"), String.Empty); } string ext = Path.GetExtension(uploader.PostedFile.FileName); if (!IsFileTypeAllowed(ext, extensions)) { // Add global allowed file extensions from Settings if (extensions == null) { extensions += ";" + SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSUploadExtensions"); } extensions = (extensions.TrimStart(';')).TrimEnd(';').ToLowerCSafe(); // Remove forbidden extensions var allowedExtensions = new List <string>(extensions.Split(';')); foreach (string extension in FORBIDDEN_EXTENSIONS.Split(';')) { if (allowedExtensions.Contains(extension)) { allowedExtensions.Remove(extension); } } ValidationError += string.Format(ResHelper.GetString("BasicForm.ErrorWrongFileType"), ext.TrimStart('.'), string.Join(", ", allowedExtensions)); return(false); } } return(true); }
/// <summary> /// Changes permission inheritance for documents filtered by permission 'Modify permissions' /// </summary> private bool FilterDataSet() { // Create an instance of the Tree provider TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); // Set the parameters for getting documents string siteName = SiteContext.CurrentSiteName; string aliasPath = "/%"; string culture = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSDefaultCultureCode"); bool combineWithDefaultCulture = true; // Get data set with documents DataSet documents = tree.SelectNodes(siteName, aliasPath, culture, combineWithDefaultCulture); // Get the user UserInfo user = UserInfoProvider.GetUserInfo("Andy"); if (user != null) { // Filter the data set by the user permissions TreeSecurityProvider.FilterDataSetByPermissions(documents, NodePermissionsEnum.ModifyPermissions, user); if (!DataHelper.DataSourceIsEmpty(documents)) { // Loop through filtered documents foreach (DataRow documentRow in documents.Tables[0].Rows) { // Create a new Tree node from the data row TreeNode node = TreeNode.New("CMS.MenuItem", documentRow, tree); // Break permission inheritance (with copying parent permissions) AclInfoProvider.BreakInherintance(node, true); } // Data set filtered successfully - permission inheritance broken for filtered items apiFilterDataSet.InfoMessage = "Data set with all pages filtered successfully by permission 'Modify permissions' for user 'Andy'. Permission inheritance broken for filtered items."; } else { // Data set filtered successfully - no items left in data set apiFilterDataSet.InfoMessage = "Data set with all pages filtered successfully by permission 'Modify permissions' for user 'Andy'. No items left in data set."; } return(true); } return(false); }
protected void Page_Load(object sender, EventArgs e) { // Validate query string if (!QueryHelper.ValidateHash("hash", "containerid")) { fileUploaderElem.StopProcessing = true; } else { // Ensure additional styles CurrentMaster.HeadElements.Visible = true; CurrentMaster.HeadElements.Text += CSSHelper.GetStyle("*{direction:ltr !important;}body{background:transparent !important;}input,input:focus,input:hover,input:active{border:none;border-color:transparent;outline:none;}"); // Initialize uploader control properties by query string values fileUploaderElem.ImageWidth = 16; fileUploaderElem.ImageHeight = 18; fileUploaderElem.ImageUrl = "~/CMSAdminControls/CKeditor/plugins/CMSPlugins/images/QuicklyInsertImage.gif"; fileUploaderElem.Text = HTMLHelper.RemoveScripts(QueryHelper.GetString("innerdivhtml", String.Empty)); fileUploaderElem.InnerElementClass = QueryHelper.GetText("innerdivclass", String.Empty); fileUploaderElem.AdditionalStyle = QueryHelper.GetText("additionalstyle", String.Empty); fileUploaderElem.LoadingImageUrl = GetImageUrl("Design/Preloaders/preload16.gif"); fileUploaderElem.FormGUID = QueryHelper.GetGuid("formguid", Guid.Empty); fileUploaderElem.NodeParentNodeID = QueryHelper.GetInteger("parentid", 0); fileUploaderElem.DocumentID = QueryHelper.GetInteger("documentid", 0); fileUploaderElem.SourceType = MediaSourceEnum.DocumentAttachments; string siteName = SiteContext.CurrentSiteName; string allowed = QueryHelper.GetString("allowedextensions", String.Empty); if (String.IsNullOrEmpty(allowed)) { allowed = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSUploadExtensions"); } fileUploaderElem.AllowedExtensions = allowed; fileUploaderElem.ResizeToWidth = QueryHelper.GetInteger("autoresize_width", 0); fileUploaderElem.ResizeToHeight = QueryHelper.GetInteger("autoresize_height", 0); fileUploaderElem.ResizeToMaxSideSize = QueryHelper.GetInteger("autoresize_maxsidesize", 0); fileUploaderElem.AfterSaveJavascript = "InsertImageOrMedia"; fileUploaderElem.InsertMode = true; fileUploaderElem.IsLiveSite = false; ScriptHelper.RegisterStartupScript(this, typeof(String), "DirectFileUpload_" + ClientID, "window.uploaderFocused = false;", true); } }
public override void ReloadData(bool forceLoad) { TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); DocTreeNode nd = tree.SelectSingleNode(EventID, LocalizationContext.PreferredCultureCode, tree.CombineWithDefaultCulture, false); if (nd == null) { ShowInformation(GetString("editedobject.notexists")); plcSend.Visible = false; lblTitle.Visible = false; return; } //Enable controls txtSenderName.Enabled = true; txtSenderEmail.Enabled = true; txtSubject.Enabled = true; htmlEmail.Enabled = true; btnSend.Enabled = true; if (forceLoad) { string siteName = SiteContext.CurrentSiteName; txtSenderEmail.Text = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSEventManagerInvitationFrom"); txtSenderName.Text = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSEventManagerSenderName"); txtSubject.Text = SettingsKeyInfoProvider.GetStringValue(siteName + ".CMSEventManagerInvitationSubject"); } // Disable form if no attendees present or user doesn't have modify permission if (MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.eventmanager", "Modify")) { DataSet ds = EventAttendeeInfoProvider.GetEventAttendees(EventID, null, null, "AttendeeID", 1); if (DataHelper.DataSourceIsEmpty(ds)) { DisableForm(); lblInfo.Text = GetString("Events_List.NoAttendees"); lblInfo.Visible = true; } } else { DisableForm(); ShowWarning(GetString("events_sendemail.modifypermission"), null, null); } }
/// <summary> /// Page Load. /// </summary> protected void Page_Load(object sender, EventArgs e) { Guid userGuid = QueryHelper.GetGuid("userguid", Guid.Empty); // If StopProcessing flag is set or userguid is empty, do nothing if (StopProcessing || (userGuid == Guid.Empty)) { Visible = false; return; } // Validate hash if (!QueryHelper.ValidateHash("hash", "aliaspath", false)) { URLHelper.Redirect(ResolveUrl("~/CMSMessages/Error.aspx?title=" + ResHelper.GetString("dialogs.badhashtitle") + "&text=" + ResHelper.GetString("dialogs.badhashtext"))); } // Get registered user RegisteredUser = UserInfoProvider.GetUserInfoByGUID(userGuid); // Get default alias path where user will be redirected to string defaultAliasPath = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSDefaultAliasPath"); string url = DocumentURLProvider.GetUrl(defaultAliasPath); // Set default url DefaultUrl = ResolveUrl(DataHelper.GetNotEmpty(url, "~/")); bool controlPb = false; if (RequestHelper.IsPostBack()) { Control pbCtrl = ControlsHelper.GetPostBackControl(Page); if (pbCtrl == btnConfirm) { controlPb = true; } } SetupControls(!controlPb); if (!controlPb) { CheckUserStatus(); } }
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); ScriptHelper.RegisterDialogScript(Page); HeaderAction updateAction = new HeaderAction { OnClientClick = ControlsHelper.GetPostBackEventReference(btnUpdateStatuses), Tooltip = GetString("translationservice.updatestatusestooltip"), Text = GetString("translationservice.updatestatuses"), Enabled = MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.TranslationServices", "Modify") && !listElem.Grid.IsEmpty }; string translateUrl = AuthenticationHelper.ResolveDialogUrl("~/CMSModules/Translations/Pages/TranslateDocuments.aspx") + "?select=1&dialog=1"; translateUrl = URLHelper.AddParameterToUrl(translateUrl, "hash", QueryHelper.GetHash(URLHelper.GetQuery(translateUrl))); // Check if any human translation is enabled bool enabled = TranslationServiceInfoProvider.GetTranslationServices("(TranslationServiceEnabled = 1) AND (TranslationServiceIsMachine = 0)", null, 0, "TranslationServiceID, TranslationServiceName").Any(t => TranslationServiceHelper.IsServiceAvailable(t.TranslationServiceName, SiteContext.CurrentSiteName)); HeaderAction submitAction = new HeaderAction { OnClientClick = "modalDialog('" + translateUrl + "', 'SubmitTranslation', 988, 634);", Tooltip = GetString(enabled ? "translationservice.submittranslationtooltip" : "translationservice.noenabledservices"), Text = GetString("translationservice.submittranslation"), Enabled = enabled && MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("CMS.Content", "SubmitForTranslation") }; AddHeaderAction(submitAction); AddHeaderAction(updateAction); CurrentMaster.HeaderActions.ReloadData(); if (!listElem.Grid.IsEmpty) { string statusCheck = SettingsKeyInfoProvider.GetStringValue("CMSTranslationsLastStatusCheck"); if (string.IsNullOrEmpty(statusCheck)) { statusCheck = GetString("general.notavailable"); } ShowInformation(string.Format(GetString("translationservice.laststatuscheck"), statusCheck)); } }
private void SendMailOld(string customerEmail) { try { string tbody = "test"; EmailMessage email = new EmailMessage(); email.EmailFormat = EmailFormatEnum.Html; email.Recipients = customerEmail; email.From = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSite.SiteName + ".CMSAdminEmailAddress"); email.Body = string.Format(tbody, SiteContext.CurrentSite.SiteName); EmailSender.SendEmail(SiteContext.CurrentSite.SiteName, email, true); } catch (Exception ex) { ev.LogEvent("E", DateTime.Now, "SendMail", ex.Message); } }
/// <summary> /// Redirects user to blog post page. /// </summary> private void RedirectToBlogPost() { TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser); TreeNode node = tree.SelectSingleNode(postGuid, culture, SiteContext.CurrentSiteName); string path = null; // Check that requested blog post exists if (node != null) { path = DocumentURLProvider.GetUrl(node.NodeAliasPath); URLHelper.Redirect(path); } else { path = SettingsKeyInfoProvider.GetStringValue(SiteContext.CurrentSiteName + ".CMSDefaultAliasPath"); URLHelper.Redirect(DocumentURLProvider.GetUrl(path)); } }