protected void Page_Load(object sender, EventArgs e) { TreeNode currentDocument = DocumentContext.CurrentDocument; if (currentDocument != null) { // Get document type transformation string transformationName = currentDocument.NodeClassName + ".attachment"; TransformationInfo ti = TransformationInfoProvider.GetTransformation(transformationName); // If transformation not present, use default from the Root document type if (ti == null) { transformationName = "cms.root.attachment"; ti = TransformationInfoProvider.GetTransformation(transformationName); } if (ti == null) { throw new Exception("[DocumentAttachments]: Default transformation '" + transformationName + "' doesn't exist!"); } ucAttachments.TransformationName = transformationName; ucAttachments.SiteName = SiteContext.CurrentSiteName; ucAttachments.Path = currentDocument.NodeAliasPath; ucAttachments.CultureCode = currentDocument.DocumentCulture; ucAttachments.OrderBy = "AttachmentOrder, AttachmentName"; ucAttachments.PageSize = 0; ucAttachments.GetBinary = false; ucAttachments.CacheMinutes = SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSite + ".CMSCacheMinutes"); } }
public DynamicOutputCacheAttribute() : base() { bool isOutputCacheEnabled = ValidationHelper.GetBoolean(ConfigurationManager.AppSettings["cache:output:is-enabled"], false); if (!isOutputCacheEnabled) { CacheProfile = "Disabled"; return; } CacheProfile = "Default"; bool isOverrideEnabled = SettingsKeyInfoProvider.GetBoolValue(SettingsKeys.SANDBOX_OUTPUT_CACHE_OVERRIDE_IS_ENABLED); if (!isOverrideEnabled) { return; } string profileSettingValue = SettingsKeyInfoProvider.GetValue(SettingsKeys.SANDBOX_OUTPUT_CACHE_PROFILE_NAME); if (!string.IsNullOrEmpty(profileSettingValue)) { CacheProfile = profileSettingValue; } int durationSettingValue = SettingsKeyInfoProvider.GetIntValue(SettingsKeys.SANDBOX_OUTPUT_CACHE_DURATION); if (durationSettingValue >= 0) { Duration = durationSettingValue; } }
/// <summary> /// Replaces existing avatar by the new one /// </summary> /// <param name="ai">Existing avatar info</param> private void ReplaceExistingAvatar(AvatarInfo ai) { AvatarInfoProvider.UploadAvatar(ai, uplFilePicture.PostedFile, SettingsKeyInfoProvider.GetIntValue(site.SiteName + ".CMSGroupAvatarWidth"), SettingsKeyInfoProvider.GetIntValue(site.SiteName + ".CMSGroupAvatarHeight"), SettingsKeyInfoProvider.GetIntValue(site.SiteName + ".CMSGroupAvatarMaxSideSize")); }
/// <summary> /// Gets selected captcha from settings. /// </summary> /// <param name="siteName">Site name</param> protected CaptchaEnum CaptchaSetting(string siteName) { CaptchaEnum selectedCaptcha = CaptchaEnum.Default; selectedCaptcha = (CaptchaEnum)SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSCaptchaControl"); return(selectedCaptcha); }
protected void Page_Load(object sender, EventArgs e) { titleElem.TitleText = GetString("kicked.header"); Page.Title = GetString("kicked.header"); lblInfo.Text = String.Format(GetString("kicked.info"), SettingsKeyInfoProvider.GetIntValue("CMSDenyLoginInterval")); // Back link lnkBack.Text = GetString("general.Back"); lnkBack.NavigateUrl = "~/"; }
/// <summary> /// Creates invitation for specified user. /// </summary> /// <param name="groupInfo">Inviting group</param> /// <param name="invitedUser">User info</param> private InvitationInfo InviteUser(GroupInfo groupInfo, UserInfo invitedUser) { // Check whether group exists if (groupInfo == null) { return(null); } int userId = (invitedUser != null) ? invitedUser.UserID : 0; int currentUserId = MembershipContext.AuthenticatedUser.UserID; // User cannot invite herself if (userId == currentUserId) { return(null); } // Check whether user is in group or is invited if ((!GroupMemberInfoProvider.IsMemberOfGroup(userId, Group.GroupID) && !InvitationInfoProvider.InvitationExists(userId, Group.GroupID)) || radNewUser.Checked) { // Create new info object var invitation = new InvitationInfo { InvitationComment = txtComment.Text, InvitationCreated = DateTime.Now, InvitationGroupID = GroupID, InvitationGUID = new Guid(), InvitationLastModified = DateTime.Now, InvitedByUserID = currentUserId }; // Create 'Valid to' value if set in settings var validTo = SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSInvitationValidity"); if (validTo > 0) { invitation.InvitationValidTo = DateTime.Now.AddDays(validTo); } if (radSiteMember.Checked) { invitation.InvitedUserID = userId; } else { invitation.InvitationUserEmail = txtEmail.Text; } InvitationInfoProvider.SetInvitationInfo(invitation); return(invitation); } return(null); }
protected void Page_Load(object sender, EventArgs e) { ucAttachments = Page.LoadUserControl("~/CMSModules/Content/Controls/Attachments/AttachmentLightboxGallery.ascx") as CMSUserControl; ucAttachments.ID = "ctrlAttachments"; plcAttachmentLightBox.Controls.Add(ucAttachments); TreeNode currentDocument = DocumentContext.CurrentDocument; if (currentDocument != null) { // Get document type transformation string transformationName = currentDocument.NodeClassName + ".AttachmentLightbox"; string selectedTransformationName = currentDocument.NodeClassName + ".AttachmentLightboxDetail"; TransformationInfo ti = TransformationInfoProvider.GetTransformation(transformationName); // If transformation not present, use default from the Root document type if (ti == null) { transformationName = "cms.root.AttachmentLightbox"; ti = TransformationInfoProvider.GetTransformation(transformationName); } if (ti == null) { throw new Exception("[DocumentAttachments]: Default transformation '" + transformationName + "' doesn't exist!"); } ti = TransformationInfoProvider.GetTransformation(selectedTransformationName); // If transformation not present, use default from the Root document type if (ti == null) { selectedTransformationName = "cms.root.AttachmentLightboxDetail"; ti = TransformationInfoProvider.GetTransformation(selectedTransformationName); } if (ti == null) { throw new Exception("[DocumentAttachments]: Default transformation '" + selectedTransformationName + "' doesn't exist!"); } ucAttachments.SetValue("TransformationName", transformationName); ucAttachments.SetValue("SelectedItemTransformationName", selectedTransformationName); ucAttachments.SetValue("SiteName", SiteContext.CurrentSiteName); ucAttachments.SetValue("Path", currentDocument.NodeAliasPath); ucAttachments.SetValue("CultureCode", currentDocument.DocumentCulture); ucAttachments.SetValue("OrderBy", "AttachmentOrder, AttachmentName"); ucAttachments.SetValue("PageSize", 0); ucAttachments.SetValue("GetBinary", false); ucAttachments.SetValue("CacheMinutes", SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSite + ".CMSCacheMinutes")); } }
private void UpdateNooshEvent(SiteInfo site) { if (site != null) { var url = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_configuratorSettingKey}"); var ruleName = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_ruleNameSettingKey}"); if (!string.IsNullOrWhiteSpace(url) && !string.IsNullOrWhiteSpace(ruleName)) { var nooshRule = new RuleDto { RuleName = ruleName, Rate = SettingsKeyInfoProvider.GetIntValue($"{site.SiteName}.{_rateSettingKey}"), TargetId = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_targetIdSettingKey}") }; var nooshSettings = new NooshDto { WorkgroupName = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_workgroupNameSettingKey}"), NooshUrl = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_nooshApiSettingKey}"), NooshToken = SettingsKeyInfoProvider.GetValue($"{site.SiteName}.{_nooshTokenSettingKey}") }; nooshRule.Enabled = nooshRule.Rate > 0 && !string.IsNullOrWhiteSpace(nooshRule.TargetId) && !string.IsNullOrWhiteSpace(nooshSettings.WorkgroupName) && !string.IsNullOrWhiteSpace(nooshSettings.NooshToken) && !string.IsNullOrWhiteSpace(nooshSettings.NooshUrl); try { var client = DIContainer.Resolve <ICloudEventConfiguratorClient>(); var result = client.UpdateNooshRule(nooshRule, nooshSettings).Result; if (!result.Success) { throw new InvalidOperationException(result.ErrorMessages); } else { EventLogProvider.LogInformation("UPDATE - NOOSH EVENT SETTINGS", "MICROREQUEST", result.Payload); } } catch (Exception e) { EventLogProvider.LogException("UPDATE - NOOSH EVENT SETTINGS", "EXCEPTION", e, site.SiteID); } } } }
/// <summary> /// Creates a new avatar object. /// </summary> /// <param name="ui"> Username of given user is used for avatar name.</param> private AvatarInfo CreateAvatar(UserInfo ui) { AvatarInfo ai = new AvatarInfo(uplFilePicture.PostedFile.ToUploadedFile(), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarWidth"), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarHeight"), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize")); if ((ui == null) && (MembershipContext.AuthenticatedUser != null) && AuthenticationHelper.IsAuthenticated() && PortalContext.ViewMode.IsLiveSite()) { ui = MembershipContext.AuthenticatedUser; } ai.AvatarName = AvatarInfoProvider.GetUniqueAvatarName($"custom {ui.UserName}"); ai.AvatarGUID = Guid.NewGuid(); return(ai); }
protected void Page_Load(object sender, EventArgs e) { if (StopProcessing) { Visible = false; return; } // Get setting values string siteName = SiteContext.CurrentSiteName; var currentUser = MembershipContext.AuthenticatedUser; int expDays; if (AuthenticationHelper.IsAuthenticated() && AuthenticationHelper.IsPasswordExpirationEnabled(siteName, out expDays)) { int dayDiff = (DateTime.Now - currentUser.UserPasswordLastChanged).Days - expDays; int warningDays = SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSPasswordExpirationWarningPeriod"); string changePwdLink = string.Format(@"<a href=""#"" onclick=""modalDialog('{0}','ChangePassword','720','350',null,null,true);"">{1}</a>", ResolveUrl("~/CMSModules/Membership/" + (IsLiveSite ? "CMSPages" : "Pages") + "/ChangePassword.aspx"), DataHelper.GetNotEmpty(ChangePasswordLinkText, GetString("passwordexpiration.changepassword"))); // Check if account password expired if (dayDiff >= 0) { lblExpText.Text = string.Format("{0}{1}{2}", ExpirationTextBefore, (ShowChangePasswordLink ? changePwdLink : ""), ExpirationTextAfter); } // Check for password expiration warning else if ((warningDays > 0) && (Math.Abs(dayDiff) <= warningDays)) { lblExpText.Text = string.Format("{0}{1}{2}", ExpirationWarningTextBefore, (ShowChangePasswordLink ? changePwdLink : ""), ExpirationWarningTextAfter); } else { Visible = false; } } else { Visible = false; } // Ensure dialog script ScriptHelper.RegisterDialogScript(Page); }
public TimeSpan DefaultCacheItemDuration() { var value = Configuration["RepositoryCacheItemDuration"]; if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out int seconds) && seconds > 0) { return(TimeSpan.FromSeconds(seconds)); } else { try { return(TimeSpan.FromMinutes(SettingsKeyInfoProvider.GetIntValue("CMSCacheMinutes", new SiteInfoIdentifier(SiteContext.CurrentSiteName)))); } catch (Exception) { return(TimeSpan.Zero); } } }
/// <summary> /// Creates a new avatar object. /// </summary> /// <param name="ui"> Username of given user is used for avatar name.</param> private AvatarInfo CreateAvatar(UserInfo ui) { AvatarInfo ai = new AvatarInfo(uplFilePicture.PostedFile, SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarWidth"), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarHeight"), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize")); if ((ui == null) && (MembershipContext.AuthenticatedUser != null) && AuthenticationHelper.IsAuthenticated() && PortalContext.ViewMode.IsLiveSite()) { ui = MembershipContext.AuthenticatedUser; } string avatarName = ui != null ? (GetString("avat.custom") + " " + ui.UserName) : ai.AvatarFileName.Substring(0, ai.AvatarFileName.LastIndexOfCSafe(".")); ai.AvatarName = AvatarInfoProvider.GetUniqueAvatarName(avatarName); ai.AvatarIsCustom = true; ai.AvatarGUID = Guid.NewGuid(); ai.AvatarType = AvatarTypeEnum.User.ToString(); return(ai); }
/// <summary> /// Creates new avatar object /// </summary> private AvatarInfo CreateNewAvatar() { AvatarInfo ai = new AvatarInfo(uplFilePicture.PostedFile, SettingsKeyInfoProvider.GetIntValue(site.SiteName + ".CMSGroupAvatarWidth"), SettingsKeyInfoProvider.GetIntValue(site.SiteName + ".CMSGroupAvatarHeight"), SettingsKeyInfoProvider.GetIntValue(site.SiteName + ".CMSGroupAvatarMaxSideSize")); if (CommunityContext.CurrentGroup != null) { ai.AvatarName = AvatarInfoProvider.GetUniqueAvatarName(GetString("avat.custom") + " " + CommunityContext.CurrentGroup.GroupName); } else { ai.AvatarName = AvatarInfoProvider.GetUniqueAvatarName(ai.AvatarFileName.Substring(0, ai.AvatarFileName.LastIndexOfCSafe("."))); } ai.AvatarType = AvatarTypeEnum.Group.ToString(); ai.AvatarIsCustom = true; ai.AvatarGUID = Guid.NewGuid(); return(ai); }
/// <summary> /// Stores uploaded picture in the system. Old avatar info is changed if its identifier is given. /// </summary> /// <param name="avatarId">Old avatar identifier (avatar picture is changed only).</param> /// <param name="user">User's username is used for new avatar name.</param> /// <returns>Stored avatar info.</returns> private AvatarInfo StoreUploadedPicture(int avatarId, UserInfo user) { // Check if avatar exists and if so check if is custom AvatarInfo avatar = AvatarInfoProvider.GetAvatarInfoWithoutBinary(avatarId); if (avatar != null) { // Replace old custom avatar AvatarInfoProvider.UploadAvatar(avatar, uplFilePicture.PostedFile.ToUploadedFile(), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarWidth"), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarHeight"), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize")); } else { // Old avatar is not custom, so create new custom avatar avatar = CreateAvatar(user); } AvatarInfo.Provider.Set(avatar); return(avatar); }
protected override void OnInit() { base.OnInit(); var s3BucketName = SettingsKeyInfoProvider.GetValue(SettingsKeyNames.AmazonS3BucketName); if (!string.IsNullOrWhiteSpace(s3BucketName)) { var environmentId = SettingsKeyInfoProvider.GetIntValue(SelectedEnvironment); try { var environment = CustomTableItemProvider.GetItem <EnvironmentItem>(environmentId); if (environment != null) { if (!string.IsNullOrWhiteSpace(environment.AmazonS3ExcludedPaths)) { var excludedPaths = environment.AmazonS3ExcludedPaths.Split(';'); foreach (var path in excludedPaths) { StorageHelper.UseLocalFileSystemForPath(path); } } var customAmazonProvider = new StorageProvider("CustomAmazon", "Kadena.AmazonFileSystemProvider", true) { CustomRootPath = s3BucketName, CustomRootUrl = Path.EnsureSlashes(Path.Combine(environment.AmazonS3Folder ?? string.Empty, "media")) }; StorageHelper.MapStoragePath("~/", customAmazonProvider); } } catch (Exception exc) { EventLogProvider.LogException(GetType().Name, "EXCEPTION", exc); } } MacroContext.GlobalResolver.SetNamedSourceData("KadenaNamespace", KadenaMacroNamespace.Instance); }
/// <summary> /// Loads product options. /// </summary> private void LoadProductOptions() { DataSet dsCategories = null; if (IsLiveSite) { // Get cache minutes int cacheMinutes = SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSCacheMinutes"); // Try to get data from cache using (CachedSection <DataSet> cs = new CachedSection <DataSet>(ref dsCategories, cacheMinutes, true, null, "skuoptioncategories", SKUID)) { if (cs.LoadData) { // Get the data dsCategories = OptionCategoryInfoProvider.GetSKUOptionCategories(SKUID, true); // Save to the cache if (cs.Cached) { // Get dependencies List <string> dependencies = new List <string>(); dependencies.Add("ecommerce.sku|byid|" + SKUID); dependencies.Add("ecommerce.optioncategory|all"); // Set dependencies cs.CacheDependency = CacheHelper.GetCacheDependency(dependencies); } cs.Data = dsCategories; } } } else { // Get the data dsCategories = OptionCategoryInfoProvider.GetSKUOptionCategories(SKUID, true); } // Initialize product option selectors if (!DataHelper.DataSourceIsEmpty(dsCategories)) { mProductOptions = new Hashtable(); foreach (DataRow dr in dsCategories.Tables[0].Rows) { try { // Load control for selection product options ProductOptionSelector selector = (ProductOptionSelector)LoadUserControl("~/CMSModules/Ecommerce/Controls/ProductOptions/ProductOptionSelector.ascx"); // Add control to the collection selector.ID = "opt" + ValidationHelper.GetInteger(dr["CategoryID"], 0); // Init selector selector.LocalShoppingCartObj = ShoppingCart; selector.ShowPriceIncludingTax = ShowPriceIncludingTax; selector.IsLiveSite = IsLiveSite; selector.SKUID = SKUID; selector.OptionCategory = new OptionCategoryInfo(dr); // Load all product options foreach (DictionaryEntry entry in selector.ProductOptions) { mProductOptions[entry.Key] = entry.Value; } if (AlwaysShowTotalPrice || ShowTotalPrice) { ListControl lc = selector.SelectionControl as ListControl; if (lc != null) { // Add Index change handler lc.AutoPostBack = true; lc.SelectedIndexChanged += new EventHandler(Selector_SelectedIndexChanged); } } pnlSelectors.Controls.Add(selector); } catch { } } } }
/// <summary> /// Sets image url, width and height. /// </summary> protected void SetImage() { Visible = false; // Only if display picture is allowed if (DisplayPicture) { string imageUrl = ResolveUrl("~/CMSModules/Avatars/CMSPages/GetAvatar.aspx?avatarguid="); bool isGravatar = false; // Is user id set? => Get user info if (mUserId > 0) { // Get user info UserInfo ui = UserInfoProvider.GetUserInfo(mUserId); if (ui != null) { switch (UserAvatarType) { case AvatarInfoProvider.AVATAR: AvatarID = ui.UserAvatarID; if (AvatarID <= 0) // Backward compatibility { if (ui.UserPicture != "") { // Get picture filename string filename = ui.UserPicture.Remove(ui.UserPicture.IndexOfCSafe('/')); string ext = Path.GetExtension(filename); imageUrl += filename.Substring(0, (filename.Length - ext.Length)); imageUrl += "&extension=" + ext; Visible = true; } else if (UseDefaultAvatar) { UserGenderEnum gender = (UserGenderEnum)ValidationHelper.GetInteger(ui.UserSettings.UserGender, 0); AvatarInfo ai = AvatarInfoProvider.GetDefaultAvatar(gender); if (ai != null) { AvatarID = ai.AvatarID; } } } break; case AvatarInfoProvider.GRAVATAR: int sideSize = mWidth > 0 ? mWidth : SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize"); imageUrl = AvatarInfoProvider.CreateGravatarLink(ui.Email, ui.UserSettings.UserGender, sideSize, SiteContext.CurrentSiteName); isGravatar = true; Visible = true; AvatarID = 0; break; } } } else { // If user is public try get his gravatar if (UserAvatarType == AvatarInfoProvider.GRAVATAR) { int sideSize = mWidth > 0 ? mWidth : SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize"); imageUrl = AvatarInfoProvider.CreateGravatarLink(UserEmail, (int)UserGenderEnum.Unknown, sideSize, SiteContext.CurrentSiteName); isGravatar = true; Visible = true; AvatarID = 0; } } // Is group id set? => Get group info if (mGroupId > 0) { // Get group info trough module commands GeneralizedInfo gi = ModuleCommands.CommunityGetGroupInfo(mGroupId); if (gi != null) { AvatarID = ValidationHelper.GetInteger(gi.GetValue("GroupAvatarID"), 0); } if ((AvatarID <= 0) && UseDefaultAvatar) { AvatarInfo ai = AvatarInfoProvider.GetDefaultAvatar(DefaultAvatarTypeEnum.Group); if (ai != null) { AvatarID = ai.AvatarID; } } } if (AvatarID > 0) { AvatarInfo ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(AvatarID); if (ai != null) { imageUrl += ai.AvatarGUID.ToString(); Visible = true; } } // If item was found if (Visible) { if (!isGravatar) { if (KeepAspectRatio) { imageUrl += "&maxsidesize=" + (Width > Height ? Width : Height); } else { imageUrl += "&width=" + Width + "&height=" + Height; } } imageUrl = URLHelper.EncodeQueryString(imageUrl); ltlImage.Text = "<img alt=\"" + GetString("general.avatar") + "\" src=\"" + imageUrl + "\" />"; // Render outer div with specific CSS class if (RenderOuterDiv) { ltlImage.Text = "<div class=\"" + OuterDivCSSClass + "\">" + ltlImage.Text + "</div>"; } } } }
/// <summary> /// Updates picture of current user. /// </summary> /// <param name="ui">User info object</param> public void UpdateUserPicture(UserInfo ui) { AvatarInfo ai = null; if (ui != null) { // Save Avatar type setting ui.UserSettings.UserAvatarType = rdbMode.SelectedValue; // Check if some avatar should be deleted if (hiddenDeleteAvatar.Value == "true") { DeleteOldUserPicture(ui); } // If some file was uploaded if (IsNewPictureUploaded()) { // Check if this user has some avatar and if so check if is custom ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(ui.UserAvatarID); bool isCustom = false; if ((ai != null) && ai.AvatarIsCustom) { isCustom = true; } if (isCustom) { AvatarInfoProvider.UploadAvatar(ai, uplFilePicture.PostedFile, SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarWidth"), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarHeight"), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize")); } // Old avatar is not custom, so crate new custom avatar else { ai = new AvatarInfo(uplFilePicture.PostedFile, SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarWidth"), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarHeight"), SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSAvatarMaxSideSize")); ai.AvatarName = AvatarInfoProvider.GetUniqueAvatarName(GetString("avat.custom") + " " + ui.UserName); ai.AvatarType = AvatarTypeEnum.User.ToString(); ai.AvatarIsCustom = true; ai.AvatarGUID = Guid.NewGuid(); } AvatarInfoProvider.SetAvatarInfo(ai); // Update user info ui.UserAvatarID = ai.AvatarID; UserInfoProvider.SetUserInfo(ui); pnlAvatarImage.Visible = true; btnDeleteImage.Visible = true; } // If predefined was chosen else if (!string.IsNullOrEmpty(hiddenAvatarGuid.Value)) { // Delete old picture DeleteOldUserPicture(ui); Guid guid = ValidationHelper.GetGuid(hiddenAvatarGuid.Value, Guid.NewGuid()); ai = AvatarInfoProvider.GetAvatarInfoWithoutBinary(guid); // Update user info if (ai != null) { ui.UserAvatarID = ai.AvatarID; UserInfoProvider.SetUserInfo(ui); } pnlAvatarImage.Visible = true; btnDeleteImage.Visible = true; } else { pnlAvatarImage.Visible = true; picUser.Visible = true; if (rdbMode.SelectedValue != AvatarInfoProvider.GRAVATAR) { btnDeleteImage.Visible = true; } UserInfoProvider.SetUserInfo(ui); } } }
/// <summary> /// OK click event handler. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { if ((uploadAvatar.PostedFile == null) && (ai == null)) { ShowError(GetString("avat.fileinputerror")); } else { SiteInfo site = SiteContext.CurrentSite; int width = 0; int height = 0; int sidesize = 0; // Get resize values if (drpAvatarType.SelectedValue != "all") { // Get right settings key string siteName = ((site != null) ? (site.SiteName + ".") : ""); string prefix = "CMSAvatar"; if (drpAvatarType.SelectedValue == "group") { prefix = "CMSGroupAvatar"; } width = SettingsKeyInfoProvider.GetIntValue(siteName + prefix + "Width"); height = SettingsKeyInfoProvider.GetIntValue(siteName + prefix + "Height"); sidesize = SettingsKeyInfoProvider.GetIntValue(siteName + prefix + "MaxSideSize"); } // Check if avatar name is unique string newAvatarName = txtAvatarName.Text.Trim(); AvatarInfo avatarWithSameName = AvatarInfoProvider.GetAvatarInfoWithoutBinary(newAvatarName); if (avatarWithSameName != null) { if (ai != null) { // Check unique avatar name of existing avatar if (avatarWithSameName.AvatarID != ai.AvatarID) { ShowError(GetString("avat.uniqueavatarname")); return; } } // Check unique avatar name of new avatar else { ShowError(GetString("avat.uniqueavatarname")); return; } } // Process form in these cases: // 1 - creating new avatar and uploaded file is not empty and it is image file // 2 - updating existing avatar and not uploading new image file // 3 - updating existing avatar and uploading image file if (((ai == null) && (uploadAvatar.PostedFile != null) && (uploadAvatar.PostedFile.ContentLength > 0) && (ImageHelper.IsImage(Path.GetExtension(uploadAvatar.PostedFile.FileName)))) || ((ai != null) && ((uploadAvatar.PostedFile == null) || (uploadAvatar.PostedFile.ContentLength == 0))) || ((ai != null) && (uploadAvatar.PostedFile != null) && (uploadAvatar.PostedFile.ContentLength > 0) && (ImageHelper.IsImage(Path.GetExtension(uploadAvatar.PostedFile.FileName))))) { if (ai == null) { switch (drpAvatarType.SelectedValue) { case "user": ai = new AvatarInfo(uploadAvatar.PostedFile, width, height, sidesize); break; case "group": ai = new AvatarInfo(uploadAvatar.PostedFile, width, height, sidesize); break; case "all": ai = new AvatarInfo(uploadAvatar.PostedFile, 0, 0, 0); break; default: ai = new AvatarInfo(uploadAvatar.PostedFile, 0, 0, 0); break; } ai.AvatarIsCustom = false; ai.AvatarGUID = Guid.NewGuid(); } else if ((uploadAvatar.PostedFile != null) && (uploadAvatar.PostedFile.ContentLength > 0) && (ImageHelper.IsMimeImage(uploadAvatar.PostedFile.ContentType))) { AvatarInfoProvider.DeleteAvatarFile(ai.AvatarGUID.ToString(), ai.AvatarFileExtension, false, false); AvatarInfoProvider.UploadAvatar(ai, uploadAvatar.PostedFile, width, height, sidesize); } // Set new avatar name ai.AvatarName = newAvatarName; imgAvatar.Visible = true; imgAvatar.ImageUrl = ResolveUrl("~/CMSModules/Avatars/CMSPages/GetAvatar.aspx?maxsidesize=250&avatarguid=" + ai.AvatarGUID); // Set new type ai.AvatarType = drpAvatarType.SelectedValue; // If avatar is not global, can't be default any default avatar if (ai.AvatarIsCustom) { // Set all default avatar options to false ai.DefaultUserAvatar = ai.DefaultMaleUserAvatar = ai.DefaultFemaleUserAvatar = ai.DefaultGroupAvatar = false; } else { // If user default avatar is changing if (ai.DefaultUserAvatar ^ chkDefaultUserAvatar.Checked) { AvatarInfoProvider.ClearDefaultAvatar(DefaultAvatarTypeEnum.User); } // If male default avatar is changing if (ai.DefaultMaleUserAvatar ^ chkDefaultMaleUserAvatar.Checked) { AvatarInfoProvider.ClearDefaultAvatar(DefaultAvatarTypeEnum.Male); } // If female default avatar is changing if (ai.DefaultFemaleUserAvatar ^ chkDefaultFemaleUserAvatar.Checked) { AvatarInfoProvider.ClearDefaultAvatar(DefaultAvatarTypeEnum.Female); } // If group default avatar is changing if (ai.DefaultGroupAvatar ^ chkDefaultGroupAvatar.Checked) { AvatarInfoProvider.ClearDefaultAvatar(DefaultAvatarTypeEnum.Group); } // Set new default avatar settings ai.DefaultUserAvatar = chkDefaultUserAvatar.Checked; ai.DefaultMaleUserAvatar = chkDefaultMaleUserAvatar.Checked; ai.DefaultFemaleUserAvatar = chkDefaultFemaleUserAvatar.Checked; ai.DefaultGroupAvatar = chkDefaultGroupAvatar.Checked; } AvatarInfoProvider.SetAvatarInfo(ai); avatarId = ai.AvatarID; URLHelper.Redirect("Avatar_Edit.aspx?saved=1&avatarid=" + avatarId); } else { // If given file is not valid if ((uploadAvatar.PostedFile != null) && (uploadAvatar.PostedFile.ContentLength > 0) && !ImageHelper.IsImage(Path.GetExtension(uploadAvatar.PostedFile.FileName))) { ShowError(GetString("avat.filenotvalid")); } else { // If posted file is not given ShowError(GetString("avat.fileinputerror")); } } } }
/// <summary> /// Loads product options. /// </summary> private void LoadProductOptions() { DataSet dsCategories = null; if (IsLiveSite) { // Get cache minutes int cacheMinutes = SettingsKeyInfoProvider.GetIntValue(SiteContext.CurrentSiteName + ".CMSCacheMinutes"); // Try to get data from cache using (var cs = new CachedSection <DataSet>(ref dsCategories, cacheMinutes, true, null, "skuoptioncategories", SKUID)) { if (cs.LoadData) { // Get all option categories for SKU dsCategories = OptionCategoryInfoProvider.GetProductOptionCategories(SKUID, false); // Save to the cache if (cs.Cached) { // Get dependencies var dependencies = new List <string> { "ecommerce.sku|byid|" + SKUID, "ecommerce.optioncategory|all" }; // Set dependencies cs.CacheDependency = CacheHelper.GetCacheDependency(dependencies); } cs.Data = dsCategories; } } } else { // Get all option categories for SKU dsCategories = OptionCategoryInfoProvider.GetProductOptionCategories(SKUID, false); } // Initialize product option selectors if (!DataHelper.DataSourceIsEmpty(dsCategories)) { mProductOptions = new Hashtable(); // Is only one option category available for variants? var variantCategories = Variants.Any() ? Variants.First().ProductAttributes.CategoryIDs.ToList() : null; mOneCategoryUsed = variantCategories != null && variantCategories.Count == 1; foreach (DataRow dr in dsCategories.Tables[0].Rows) { try { // Load control for selection product options ProductOptionSelector selector = (ProductOptionSelector)LoadUserControl("~/CMSModules/Ecommerce/Controls/ProductOptions/ProductOptionSelector.ascx"); // Add control to the collection var categoryID = ValidationHelper.GetInteger(dr["CategoryID"], 0); selector.ID = "opt" + categoryID; // Init selector selector.LocalShoppingCartObj = ShoppingCart; selector.IsLiveSite = IsLiveSite; selector.CssClassFade = CssClassFade; selector.CssClassNormal = CssClassNormal; selector.SKUID = SKUID; selector.OptionCategory = new OptionCategoryInfo(dr); // If one category is used, fix the one selector with options to use only options which are not in disabled variants if (mOneCategoryUsed && variantCategories.Contains(categoryID)) { var disabled = from variant in Variants where !variant.Variant.SKUEnabled from productAttributes in variant.ProductAttributes select productAttributes.SKUID; var disabledList = disabled.ToList(); selector.ProductOptionsInDisabledVariants = disabledList.Any() ? disabledList : null; } // Load all product options foreach (DictionaryEntry entry in selector.ProductOptions) { mProductOptions[entry.Key] = entry.Value; } var lc = selector.SelectionControl as ListControl; if (lc != null) { // Add Index change handler lc.AutoPostBack = true; } pnlSelectors.Controls.Add(selector); } catch { } } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (StopProcessing) { // Do nothing ucGoogleMap.Visible = false; } else { #region "Data source properties" // Set Documents data source control ucDocumentSource.Path = Path; ucDocumentSource.ClassNames = ClassNames; ucDocumentSource.CombineWithDefaultCulture = CombineWithDefaultCulture; ucDocumentSource.CultureCode = CultureCode; ucDocumentSource.MaxRelativeLevel = MaxRelativeLevel; ucDocumentSource.OrderBy = OrderBy; ucDocumentSource.SelectOnlyPublished = SelectOnlyPublished; ucDocumentSource.SelectTopN = SelectTopN; ucDocumentSource.SiteName = SiteName; ucDocumentSource.WhereCondition = WhereCondition; ucDocumentSource.FilterOutDuplicates = FilterOutDuplicates; ucDocumentSource.CheckPermissions = CheckPermissions; ucDocumentSource.RelationshipName = RelationshipName; ucDocumentSource.RelationshipWithNodeGuid = RelationshipWithNodeGUID; ucDocumentSource.RelatedNodeIsOnTheLeftSide = RelatedNodeIsOnTheLeftSide; ucDocumentSource.CacheDependencies = CacheDependencies; ucDocumentSource.CacheMinutes = CacheMinutes; ucDocumentSource.CacheItemName = CacheItemName; ucDocumentSource.EnableSelectedItem = EnableSelectedItem; #endregion #region "Google map caching options" // Set caching options if server processing is enabled if (ucDocumentSource != null && EnableServerProcessing) { ucGoogleMap.CacheItemName = ucDocumentSource.CacheItemName; if (ucDocumentSource.CacheMinutes <= 0) { // If zero or less, get from the site settings ucGoogleMap.CacheMinutes = SettingsKeyInfoProvider.GetIntValue(CurrentSiteName + ".CMSCacheMinutes"); } else { ucGoogleMap.CacheMinutes = ucDocumentSource.CacheMinutes; } // Cache depends on data source and properties of web part ucGoogleMap.CacheDependencies = CacheHelper.GetCacheDependencies(CacheDependencies, ucDocumentSource.GetDefaultCacheDependencies()); } #endregion #region "Map properties" // Set BasicGoogleMaps control CMSMapProperties mp = new CMSMapProperties(); mp.EnableKeyboardShortcuts = EnableKeyboardShortcuts; mp.EnableMapDragging = EnableMapDragging; mp.EnableServerProcessing = EnableServerProcessing; mp.Height = Height; mp.Latitude = Latitude; mp.LatitudeField = LatitudeField; mp.Location = DefaultLocation; mp.LocationField = LocationField; mp.Longitude = Longitude; mp.LongitudeField = LongitudeField; mp.IconField = IconField; mp.MapId = ClientID; mp.MapType = MapType; mp.NavigationControlType = NavigationControlType; mp.Scale = Scale; mp.ShowNavigationControl = ShowNavigationControl; mp.ShowScaleControl = ShowScaleControl; mp.ShowMapTypeControl = ShowMapTypeControl; mp.ToolTipField = ToolTipField; mp.Width = Width; mp.ZoomScale = ZoomScale; ucGoogleMap.DataBindByDefault = false; ucGoogleMap.MapProperties = mp; ucGoogleMap.ItemTemplate = CMSDataProperties.LoadTransformation(this, TransformationName); ucGoogleMap.MainScriptPath = "~/CMSWebParts/Maps/Documents/GoogleMaps_files/GoogleMaps.js"; ucGoogleMap.HideControlForZeroRows = HideControlForZeroRows; if (!String.IsNullOrEmpty(ZeroRowsText)) { ucGoogleMap.ZeroRowsText = ZeroRowsText; } #endregion if (reloadData) { ucDocumentSource.DataSource = null; } // Connects Google map with data source ucGoogleMap.DataSource = ucDocumentSource.DataSource; ucGoogleMap.RelatedData = ucDocumentSource.RelatedData; if (HasData) { ucGoogleMap.DataBind(); } } }
/// <summary> /// Initializes the control properties. /// </summary> protected void SetupControl() { if (!StopProcessing) { #region "Caching options" // Set caching options if server processing is enabled if (DataSourceControl != null && EnableServerProcessing) { BasicBingMaps.CacheItemName = DataSourceControl.CacheItemName; if (DataSourceControl.CacheMinutes <= 0) { // If zero or less, get from the site settings BasicBingMaps.CacheMinutes = SettingsKeyInfoProvider.GetIntValue(CurrentSiteName + ".CMSCacheMinutes"); } else { BasicBingMaps.CacheMinutes = DataSourceControl.CacheMinutes; } // Cache depends only on data source and properties of data source web part string cacheDependencies = CacheHelper.GetCacheDependencies(DataSourceControl.CacheDependencies, DataSourceControl.GetDefaultCacheDependencies()); // All view modes, except LiveSite mode if (PortalContext.ViewMode != ViewModeEnum.LiveSite) { // Cache depends on data source, properties of data source web part and properties of BasicBingMaps web part cacheDependencies += "webpartinstance|" + InstanceGUID.ToString().ToLowerCSafe(); } BasicBingMaps.CacheDependencies = cacheDependencies; } #endregion #region "Map properties" CMSMapProperties mp = new CMSMapProperties(); mp.Location = DefaultLocation; mp.EnableKeyboardShortcuts = EnableKeyboardShortcuts; mp.EnableMapDragging = EnableMapDragging; mp.Height = Height; mp.Width = Width; mp.EnableServerProcessing = EnableServerProcessing; mp.Longitude = Longitude; mp.Latitude = Latitude; mp.LatitudeField = LatitudeField; mp.LongitudeField = LongitudeField; mp.LocationField = LocationField; mp.MapKey = MapKey; mp.MapType = MapType; mp.Scale = Scale; mp.ShowNavigationControl = ShowNavigationControl; mp.ShowScaleControl = ShowScaleControl; mp.ToolTipField = ToolTipField; mp.IconField = IconField; mp.ZoomScale = ZoomScale; mp.MapId = ClientID; #endregion BasicBingMaps.MapProperties = mp; BasicBingMaps.HideControlForZeroRows = HideControlForZeroRows; BasicBingMaps.DataBindByDefault = false; BasicBingMaps.MainScriptPath = "~/CMSWebParts/Maps/Basic/BasicBingMaps_files/BingMaps.js"; // Add basic maps control to the filter collection EnsureFilterControl(); if (!String.IsNullOrEmpty(ZeroRowsText)) { BasicBingMaps.ZeroRowsText = ZeroRowsText; } } }
protected void Page_Load(object sender, EventArgs e) { // Validate query string if (!QueryHelper.ValidateHash("hash")) { // Do nothing } else { String identifier = QueryHelper.GetString("identifier", null); if (String.IsNullOrEmpty(identifier)) { return; } properties = WindowHelper.GetItem(identifier) as Hashtable; if (properties == null) { return; } // Get information on current source type string sourceType = ValidationHelper.GetString(GetProp("source"), "attachments"); SourceType = CMSDialogHelper.GetMediaSource(sourceType); // 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;}"); // Get uploader control based on the current source type string uploaderPath = ""; if (SourceType == MediaSourceEnum.MediaLibraries) { // If media library module is running if (ModuleManager.IsModuleLoaded(ModuleName.MEDIALIBRARY)) { uploaderPath = "~/CMSModules/MediaLibrary/Controls/Dialogs/DirectFileUploader/DirectMediaFileUploaderControl.ascx"; } } else { uploaderPath = "~/CMSModules/Content/Controls/Attachments/DirectFileUploader/DirectFileUploaderControl.ascx"; } // Load direct file uploader if (uploaderPath != "") { DirectFileUploader fileUploaderElem = this.LoadUserControl(uploaderPath) as DirectFileUploader; if (fileUploaderElem != null) { // Insert uploader to parent container pnlUploaderElem.Controls.Add(fileUploaderElem); // Initialize uploader control properties by query string values fileUploaderElem.AttachmentGUID = ValidationHelper.GetGuid(GetProp("attachmentguid"), Guid.Empty); fileUploaderElem.AttachmentGroupGUID = ValidationHelper.GetGuid(GetProp("attachmentgroupguid"), Guid.Empty); fileUploaderElem.AttachmentGUIDColumnName = ValidationHelper.GetString(GetProp("attachmentguidcolumnname"), null); fileUploaderElem.FormGUID = ValidationHelper.GetGuid(GetProp("formguid"), Guid.Empty); fileUploaderElem.DocumentID = ValidationHelper.GetInteger(GetProp("documentid"), 0); fileUploaderElem.NodeParentNodeID = ValidationHelper.GetInteger(GetProp("parentid"), 0); fileUploaderElem.NodeClassName = ValidationHelper.GetString(GetProp("classname"), ""); fileUploaderElem.InsertMode = ValidationHelper.GetBoolean(GetProp("insertmode"), false); fileUploaderElem.OnlyImages = ValidationHelper.GetBoolean(GetProp("onlyimages"), false); fileUploaderElem.ParentElemID = QueryHelper.GetString("parentelemid", String.Empty); fileUploaderElem.CheckPermissions = ValidationHelper.GetBoolean(GetProp("checkperm"), true); fileUploaderElem.IsLiveSite = false; fileUploaderElem.RaiseOnClick = ValidationHelper.GetBoolean(GetProp("click"), false); fileUploaderElem.NodeSiteName = ValidationHelper.GetString(GetProp("sitename"), null); fileUploaderElem.SourceType = SourceType; // Metafile upload fileUploaderElem.SiteID = ValidationHelper.GetInteger(GetProp("siteid"), 0); fileUploaderElem.Category = ValidationHelper.GetString(GetProp("category"), String.Empty); fileUploaderElem.ObjectID = ValidationHelper.GetInteger(GetProp("objectid"), 0); fileUploaderElem.ObjectType = ValidationHelper.GetString(GetProp("objecttype"), String.Empty); fileUploaderElem.MetaFileID = ValidationHelper.GetInteger(GetProp("metafileid"), 0); // Library info initialization; fileUploaderElem.LibraryID = ValidationHelper.GetInteger(GetProp("libraryid"), 0); fileUploaderElem.MediaFileID = ValidationHelper.GetInteger(GetProp("mediafileid"), 0); fileUploaderElem.MediaFileName = ValidationHelper.GetString(GetProp("filename"), null); fileUploaderElem.IsMediaThumbnail = ValidationHelper.GetBoolean(GetProp("ismediathumbnail"), false); fileUploaderElem.LibraryFolderPath = ValidationHelper.GetString(GetProp("path"), ""); fileUploaderElem.IncludeNewItemInfo = ValidationHelper.GetBoolean(GetProp("includeinfo"), false); string siteName = SiteContext.CurrentSiteName; string allowed = ValidationHelper.GetString(GetProp("allowedextensions"), null); if (allowed == null) { if (fileUploaderElem.SourceType == MediaSourceEnum.MediaLibraries) { allowed = SettingsKeyInfoProvider.GetValue(siteName + ".CMSMediaFileAllowedExtensions"); } else { allowed = SettingsKeyInfoProvider.GetValue(siteName + ".CMSUploadExtensions"); } } fileUploaderElem.AllowedExtensions = allowed; // Auto resize width int autoResizeWidth = ValidationHelper.GetInteger(GetProp("autoresize_width"), -1); if (autoResizeWidth == -1) { autoResizeWidth = SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSAutoResizeImageWidth"); } fileUploaderElem.ResizeToWidth = autoResizeWidth; // Auto resize height int autoResizeHeight = ValidationHelper.GetInteger(GetProp("autoresize_height"), -1); if (autoResizeHeight == -1) { autoResizeHeight = SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSAutoResizeImageHeight"); } fileUploaderElem.ResizeToHeight = autoResizeHeight; // Auto resize max side size int autoResizeMaxSideSize = ValidationHelper.GetInteger(GetProp("autoresize_maxsidesize"), -1); if (autoResizeMaxSideSize == -1) { autoResizeMaxSideSize = SettingsKeyInfoProvider.GetIntValue(siteName + ".CMSAutoResizeImageMaxSideSize"); } fileUploaderElem.ResizeToMaxSideSize = autoResizeMaxSideSize; fileUploaderElem.AfterSaveJavascript = ValidationHelper.GetString(GetProp("aftersave"), String.Empty); fileUploaderElem.TargetFolderPath = ValidationHelper.GetString(GetProp("targetfolder"), String.Empty); fileUploaderElem.TargetFileName = ValidationHelper.GetString(GetProp("targetfilename"), String.Empty); } } } }
public int GetIntSettingValue(string SiteName, string SettingsKeyCode) { return(SettingsKeyInfoProvider.GetIntValue(SettingsKeyCode, new SiteInfoIdentifier(SiteName))); }