예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        TreeNode currentDocument = CMSContext.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           = CMSContext.CurrentSiteName;
            ucAttachments.Path         = currentDocument.NodeAliasPath;
            ucAttachments.CultureCode  = currentDocument.DocumentCulture;
            ucAttachments.OrderBy      = "AttachmentOrder, AttachmentName";
            ucAttachments.PageSize     = 0;
            ucAttachments.GetBinary    = false;
            ucAttachments.CacheMinutes = SettingsKeyProvider.GetIntValue(CMSContext.CurrentSite + ".CMSCacheMinutes");
        }
    }
예제 #2
0
 private static void UpdateContactsIPandUserAgent(string siteName)
 {
     if (SettingsKeyProvider.GetBoolValue(siteName + ".CMSEnableOnlineMarketing"))
     {
         ModuleCommands.OnlineMarketingUpdateContactInformation(siteName);
     }
 }
예제 #3
0
    /// <summary>
    /// Gets selected captcha from settings.
    /// </summary>
    /// <param name="siteName">Site name</param>
    protected CaptchaEnum CaptchaSetting(string siteName)
    {
        CaptchaEnum selectedCaptcha = CaptchaEnum.Default;

        selectedCaptcha = (CaptchaEnum)SettingsKeyProvider.GetIntValue(siteName + ".CMSCaptchaControl");
        return(selectedCaptcha);
    }
예제 #4
0
    /// <summary>
    /// Initializes header action control.
    /// </summary>
    private void InitHeaderActions()
    {
        // Find out if current account is merged into another site or global account
        if (ai != null)
        {
            mergedIntoSite    = (ai.AccountMergedWithAccountID != 0);
            mergedIntoGlobal  = (ai.AccountGlobalAccountID != 0);
            mergedIntoGlobal &= AccountHelper.AuthorizedReadAccount(UniSelector.US_GLOBAL_RECORD, false);

            if (!ContactHelper.IsSiteManager)
            {
                mergedIntoGlobal &= SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSCMGlobalAccounts");
            }
        }

        HeaderActions.AddAction(new SaveAction(Page));

        if (mergedIntoSite || mergedIntoGlobal)
        {
            HeaderActions.AddAction(new HeaderAction
            {
                ControlType = HeaderActionTypeEnum.Hyperlink,
                Text        = GetString("om.contact.splitfromparent"),
                ImageUrl    = GetImageUrl("CMSModules/CMS_ContactManagement/split.png"),
                CommandName = "split"
            });
        }

        HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;
    }
예제 #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        siteId = CMSContext.CurrentSiteID;

        emailsEnabled  = EmailHelper.Settings.EmailsEnabled(CMSContext.CurrentSiteName);
        emailsEnabled |= SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSGenerateNewsletters");

        // Display disabled information
        if (!emailsEnabled)
        {
            ShowWarning(GetString("NewsletterEmailQueue_List.EmailsDisabled"), null, null);
        }

        // Initialize unigrid
        gridElem.OnAction            += new OnActionEventHandler(gridElem_OnAction);
        gridElem.OnExternalDataBound += new OnExternalDataBoundEventHandler(gridElem_OnExternalDataBound);
        gridElem.WhereCondition       = "EmailSiteID = @SiteID";

        QueryDataParameters parameters = new QueryDataParameters();

        parameters.Add("@SiteID", siteId);

        gridElem.QueryParameters = parameters;

        InitializeActionMenu();
    }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Show panel with message how to enable indexing
        if (!SettingsKeyProvider.GetBoolValue("CMSSearchIndexingEnabled"))
        {
            pnlDisabled.Visible = true;
        }

        indexId = QueryHelper.GetInteger("indexid", 0);

        // Add sites filter
        uniSelector.FilterControl = "~/CMSFormControls/Filters/SiteFilter.ascx";
        uniSelector.SetValue("DefaultFilterValue", CMSContext.CurrentSiteID);
        uniSelector.SetValue("FilterMode", "cultures");

        // Get the active sites
        DataSet ds = SearchIndexCultureInfoProvider.GetSearchIndexCultures("IndexID = " + indexId, null, 0, "IndexID, IndexCultureID");

        if (!DataHelper.DataSourceIsEmpty(ds))
        {
            currentValues = TextHelper.Join(";", SqlHelperClass.GetStringValues(ds.Tables[0], "IndexCultureID"));
        }

        if (!URLHelper.IsPostback())
        {
            uniSelector.Value = currentValues;
        }

        lblInfo.Text    = String.Format(GetString("general.changessaved") + " " + GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>");
        lblInfo.Visible = false;
    }
예제 #7
0
    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(this.Form.Data.GetValue("allowed_extensions"), null);
            }
        }
        // Site extensions
        else
        {
            txtAllowedExtensions.Text = SettingsKeyProvider.GetStringValue(CMSContext.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 " + this.Page.ClientScript.GetCallbackEventReference(this, "txtAllowedExtensions", "ReceiveExtensions", null) + " } \n"));

        // Initialize form
        chkInehrit.Attributes.Add("onclick", GetEnableDisableFormDefinition());
        EnableDisableForm();
    }
예제 #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CMSContext.ViewMode != ViewModeEnum.EditLive)
        {
            // Try skip IIS http errors
            Response.TrySkipIisCustomErrors = true;

            // Set page not found state
            Response.StatusCode = 404;

            // Set preferred content culture
            SetLiveCulture();
        }
        else if (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSAllowOnSiteEditing"))
        {
            CMSAbstractPortalUserControl editToolbar = (CMSAbstractPortalUserControl)Page.LoadUserControl("~/CMSModules/PortalEngine/Controls/OnsiteEdit/EditToolbar.ascx");
            editToolbar.ID      = "editToolbar";
            editToolbar.ShortID = "et";
            plcMain.Controls.Add(editToolbar);
        }

        titleElem.TitleText  = GetString("404.Header");
        titleElem.TitleImage = GetImageUrl("Others/Messages/error.png");

        lblInfo.Text    = String.Format(GetString("404.Info"), URLHelper.CurrentURL + " (" + CMSContext.PreferredCultureCode + ")");
        lblRootDoc.Text = "<a href=\"" + URLHelper.GetApplicationUrl() + "\" target=\"_self\">" + HTMLHelper.HTMLEncode(GetString("onsiteedit.rootredirect")) + "<a>";
    }
예제 #9
0
    /// <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(CMSContext.CurrentUser);

        // Get default culture code
        string culture = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");

        // Get the API Example document
        TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example", culture);

        if (node != null)
        {
            // Get the user
            UserInfo user = UserInfoProvider.GetUserInfo("CMSEditor");

            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 'CMSEditor' is allowed to modify permissions for document 'API Example'.";
                }
                else
                {
                    apiCheckDocumentPermissions.InfoMessage = "User 'CMSEditor' is not allowed to modify permissions for document 'API Example'.";
                }

                return(true);
            }
        }

        return(false);
    }
예제 #10
0
    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 = SettingsKeyProvider.GetStringValue(CMSContext.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;
        }
    }
예제 #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check read permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.searchindex", CMSAdminControl.PERMISSION_READ))
        {
            RedirectToAccessDenied("cms.searchindex", CMSAdminControl.PERMISSION_READ);
        }

        // Show panel with message how to enable indexing
        if (!SettingsKeyProvider.GetBoolValue("CMSSearchIndexingEnabled"))
        {
            pnlDisabled.Visible = true;
        }

        lblAvialable.Text = GetString("SearchIndex_Sites.Available");

        indexId = QueryHelper.GetInteger("indexid", 0);

        // Get the user sites
        currentValues = GetIndexSites();

        if (!RequestHelper.IsPostBack())
        {
            usSites.Value = currentValues;
        }


        lblInfo.Text = String.Format(GetString("general.changessaved") + " " + GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>");

        usSites.OnSelectionChanged += usSites_OnSelectionChanged;
    }
예제 #12
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.StatusCode = 404;

        // Use javascript redirect if custom 404 page is used at pagenotfoundpath
        if (useRedirect)
        {
            string notFoundUrl = ValidationHelper.GetString(SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSPageNotFoundUrl"), "");

            notFoundUrl = URLHelper.ResolveUrl(notFoundUrl);

            string paramValue = QueryHelper.GetString("aspxerrorpath", String.Empty);

            // Escape special characters
            paramValue = ScriptHelper.GetString(paramValue, false);

            // Add parameter about what page was originaly not found
            notFoundUrl = URLHelper.AddParameterToUrl(notFoundUrl, "aspxerrorpath", paramValue);

            this.Header.Controls.Add(new LiteralControl(ScriptHelper.GetScript("document.location.replace('" + notFoundUrl + "');")));
        }

        // Set preferred content culture
        SetLiveCulture();

        this.titleElem.TitleText  = GetString("404.Header");
        this.titleElem.TitleImage = GetImageUrl("Others/Messages/error.png");

        this.lblInfo.Text = String.Format(GetString("404.Info"), QueryHelper.GetText("aspxerrorpath", String.Empty));

        this.lnkBack.Text        = GetString("404.Back");
        this.lnkBack.NavigateUrl = "~/";
    }
예제 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check read permission
        ContactHelper.AuthorizedReadContact(CMSContext.CurrentSiteID, true);

        string siteName = CMSContext.CurrentSiteName;

        // Get bounce limit
        mBounceLimit = SettingsKeyProvider.GetIntValue(siteName + ".CMSBouncedEmailsLimit");
        // Get info if bounced e-mail tracking is available
        mBounceInfoAvailable = SettingsKeyProvider.GetBoolValue(siteName + ".CMSMonitorBouncedEmails") &&
                               NewsletterProvider.OnlineMarketingEnabled(siteName);

        CurrentMaster.HeaderActions.HelpTopicName = "subscribercontacts_tab";
        CurrentMaster.HeaderActions.HelpName      = "helpTopic";

        // Check if parent object exist
        Subscriber sb = SubscriberProvider.GetSubscriber(QueryHelper.GetInteger("subscriberid", 0));

        EditedObject = sb;

        // Initialize unigrid
        UniGrid.OnAction            += uniGrid_OnAction;
        UniGrid.OnExternalDataBound += uniGrid_OnExternalDataBound;
        UniGrid.WhereCondition       = "ContactID IN (SELECT ContactGroupMemberRelatedID FROM OM_ContactGroupMember WHERE ContactGroupMemberContactGroupID = "
                                       + QueryHelper.GetInteger("groupid", 0) + " AND ContactGroupMemberType = 0) AND ContactSiteID = " + CMSContext.CurrentSiteID
                                       + " AND ContactMergedWithContactID IS NULL";
        UniGrid.ShowObjectMenu = false;
    }
예제 #14
0
    /// <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 = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");
            CultureInfo culture     = CultureInfoProvider.GetCultureInfo(cultureCode);

            // Get root document type class ID
            int classID = DataClassInfoProvider.GetDataClass("CMS.Root").ClassID;

            // Set the properties
            newScope.ScopeStartingPath = "/";
            newScope.ScopeCultureID    = culture.CultureID;
            newScope.ScopeClassID      = classID;

            newScope.ScopeWorkflowID = workflow.WorkflowID;
            newScope.ScopeSiteID     = CMSContext.CurrentSiteID;

            // Save the workflow scope
            WorkflowScopeInfoProvider.SetWorkflowScopeInfo(newScope);

            return(true);
        }

        return(false);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Show panel with message how to enable indexing
        if (!SettingsKeyProvider.GetBoolValue("CMSSearchIndexingEnabled"))
        {
            // Set disabled module info
            ucDisabledModule.SettingsKeys = "CMSSearchIndexingEnabled";
            ucDisabledModule.InfoText     = GetString("srch.searchdisabledinfo");
            disableActions = true;
        }

        // Setup the grid
        UniGrid.OnAction            += new OnActionEventHandler(UniGrid_OnAction);
        UniGrid.OnExternalDataBound += new OnExternalDataBoundEventHandler(UniGrid_OnExternalDataBound);
        UniGrid.ZeroRowsText         = GetString("general.nodatafound");
        UniGrid.OrderBy              = "IndexDisplayName";

        string indexPath = Path.Combine(SettingsKeyProvider.WebApplicationPhysicalPath, "App_Data\\CMSModules\\SmartSearch\\");

        if (indexPath.Length > SearchHelper.MAX_INDEX_PATH)
        {
            pnlPathTooLong.Visible = true;
            disableActions         = true;
        }
    }
예제 #16
0
    protected void SiteSelector_OnSelectionChanged(object sender, EventArgs e)
    {
        // Create url
        int      siteId = ValidationHelper.GetInteger(siteSelector.Value, 0);
        SiteInfo si     = SiteInfoProvider.GetSiteInfo(siteId);

        if (si != null)
        {
            string domain = si.DomainName.TrimEnd('/');
            string url    = "~" + VirtualContext.CurrentURLPrefix + "/CMSDesk/default.aspx";

            if (domain.Contains("/"))
            {
                // Resolve application path
                url = url.Substring(1);
            }

            url = URLHelper.GetAbsoluteUrl(url, domain, null, null);

            // Check if single sign-on is turned on
            if (SettingsKeyProvider.GetBoolValue("CMSAutomaticallySignInUser"))
            {
                url = UserInfoProvider.GetUserAuthenticationUrl(CMSContext.CurrentUser, url);
            }
            ScriptHelper.RegisterStartupScript(Page, typeof(Page), "selectSite", ScriptHelper.GetScript("SiteRedirect('" + url + "');"));
        }
    }
    /// <summary>
    /// Rejects and deletes user.
    /// </summary>
    /// <param name="userID">User to be rejected</param>
    protected void DeleteUser(int userID)
    {
        // Find user
        UserInfo user = UserInfoProvider.GetFullUserInfo(userID);

        // Send e-mail if requested
        if (hdnSendEmail.Value == "true")
        {
            EmailMessage em = new EmailMessage();

            // Set message content
            em.From        = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSNoreplyEmailAddress");
            em.Recipients  = user.Email;
            em.Subject     = GetString("administration.users.rejected");
            em.EmailFormat = EmailFormatEnum.Default;

            string emailBody = this.hdnReason.Value.Trim();

            em.Body          = HTMLHelper.HTMLEncode(emailBody);
            em.PlainTextBody = emailBody;

            // Send message
            EmailSender.SendEmail(em);
        }

        // Delete user
        SessionManager.RemoveUser(userID);
        UserInfoProvider.DeleteUser(userID);
    }
예제 #18
0
    /// <summary>
    /// Expects the "CreateDocumentStructure" method to be run first.
    /// </summary>
    private bool BreakPermissionInheritance()
    {
        // Create an instance of the Tree provider
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Get default culture code
        string culture = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");

        // Get the API Example document
        TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example/API-Example-subpage", culture);

        if (node != null)
        {
            // Create an instance of ACL provider
            AclProvider acl = new AclProvider(tree);

            // Break permission inheritance (without copying parent permissions)
            bool copyParentPermissions = false;
            acl.BreakInherintance(node, copyParentPermissions);

            return(true);
        }

        return(false);
    }
예제 #19
0
    /// <summary>
    /// Expects the "CreateDocumentStructure" method to be run first.
    /// </summary>
    private bool SetRolePermissions()
    {
        // Create an instance of the Tree provider
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Get default culture code
        string culture = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");

        // Get the API Example document
        TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example", culture);

        if (node != null)
        {
            // Get the role ID
            RoleInfo role = RoleInfoProvider.GetRoleInfo("CMSEditor", CMSContext.CurrentSiteName);

            if (role != null)
            {
                // Prepare allowed / denied permissions
                int allowed = 0;
                int denied  = 0;
                allowed += Convert.ToInt32(Math.Pow(2, Convert.ToInt32(NodePermissionsEnum.Modify)));

                // Create an instance of ACL provider
                AclProvider acl = new AclProvider(tree);

                // Set role permissions
                acl.SetRolePermissions(node, allowed, denied, role.RoleID);

                return(true);
            }
        }

        return(false);
    }
예제 #20
0
    /// <summary>
    /// Expects the "CreateDocumentStructure" method to be run first.
    /// </summary>
    private bool DeletePermissions()
    {
        // Create an instance of the Tree provider
        TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

        // Get default culture code
        string culture = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSDefaultCultureCode");

        // Get the API Example document
        TreeNode node = tree.SelectSingleNode(CMSContext.CurrentSiteName, "/API-Example", culture);

        if (node != null)
        {
            // Create an instance of ACL provider
            AclProvider acl = new AclProvider(tree);

            // Get ID of ACL used on API Example document
            int nodeACLID = ValidationHelper.GetInteger(node.GetValue("NodeACLID"), 0);

            // Delete all ACL items
            acl.ClearACLItems(nodeACLID);

            return(true);
        }

        return(false);
    }
예제 #21
0
    /// <summary>
    /// Gets and bulk updates settings keys. Called when the "Get and bulk update keys" button is pressed.
    /// Expects the CreateSettingsKey method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateSettingsKeys()
    {
        // Prepare the parameters
        string where = "KeyName LIKE N'MyNew%'";

        // Get the data
        DataSet keys = SettingsKeyProvider.GetSettingsKeys(where, null, 0, null);

        if (!DataHelper.DataSourceIsEmpty(keys))
        {
            // Loop through the individual items
            foreach (DataRow keyDr in keys.Tables[0].Rows)
            {
                // Create object from DataRow
                SettingsKeyInfo modifyKey = new SettingsKeyInfo(keyDr);

                // Update the property
                modifyKey.KeyDisplayName = modifyKey.KeyDisplayName.ToUpper();

                // Update the settings key
                SettingsKeyProvider.SetValue(modifyKey);
            }

            return(true);
        }

        return(false);
    }
예제 #22
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         RestoreParameters();
         if (RequestHelper.IsPostBack() && Page.Request.Params["__EVENTTARGET"] == "SaveButton")
         {
             // The access to the Settings page was lost, it might happen as the Internet Explorer opens the target URL of SalesForce redirection in a new window.
             if (CurrentUser.IsGlobalAdministrator)
             {
                 // The current user is a global administrator, so it is safe to proceed.
                 // Without this check there is a security vulnerability as any CMS Desk user could choose a site and authorize access to his or her Sales Cloud organization.
                 string name = "CMSSalesForceCredentials";
                 if (!String.IsNullOrEmpty(SourceSiteName))
                 {
                     name = String.Format("{0}.{1}", SourceSiteName, name);
                 }
                 CloseDialog(GetString("sf.authorization.partialsuccess"));
                 SettingsKeyProvider.SetValue(name, CredentialsHiddenField.Value);
                 CredentialsHiddenField.Value = String.Empty;
             }
         }
         else
         {
             RedirectUrlLiteral.Text = HTMLHelper.HTMLEncode(RedirectUrl);
             string authorizationCode = QueryHelper.GetString("code", null);
             if (!String.IsNullOrEmpty(authorizationCode))
             {
                 SalesForceAuthorizationHelper   authorizationHelper = new SalesForceAuthorizationHelper(Credentials.ClientId, Credentials.ClientSecret, RedirectUrl);
                 GetAuthenticationTokensResponse response            = authorizationHelper.GetAuthenticationTokens(authorizationCode);
                 Identity identity = authorizationHelper.GetIdentity(response);
                 Credentials.RefreshToken        = response.RefreshToken;
                 Credentials.OrganizationBaseUrl = response.InstanceBaseUrl;
                 Credentials.UserName            = identity.UserName;
                 Credentials.OrganizationName    = GetOrganizationName(Credentials, identity.OrganizationId);
                 StoreParameters();
                 if (URLHelper.Url.Scheme != SourceUrlScheme)
                 {
                     RedirectToScheme(SourceUrlScheme, SourceUrlPort);
                 }
                 else
                 {
                     CloseDialog(GetString("sf.authorization.success"));
                 }
             }
             else
             {
                 string state = QueryHelper.GetString("state", null);
                 if (!String.IsNullOrEmpty(state))
                 {
                     CloseDialog(GetString("sf.authorization.success"));
                 }
             }
         }
     }
     catch (Exception exception)
     {
         HandleError(exception);
     }
 }
예제 #23
0
    /// <summary>
    /// Creates settings key. Called when the "Create key" button is pressed.
    /// </summary>
    private bool CreateSettingsKey()
    {
        // Get the settings group
        SettingsCategoryInfo settingsGroup = SettingsCategoryInfoProvider.GetSettingsCategoryInfoByName("MyNewSettingsGroup");

        if (settingsGroup != null)
        {
            // Create new settings key object
            SettingsKeyInfo newKey = new SettingsKeyInfo();

            // Set the properties
            newKey.KeyDisplayName  = "My new key";
            newKey.KeyName         = "MyNewKey";
            newKey.KeyDescription  = "My new key description";
            newKey.KeyType         = "string";
            newKey.KeyValue        = "My new value";
            newKey.KeyCategoryID   = settingsGroup.CategoryID;
            newKey.KeyDefaultValue = null;

            // Set Site ID for site specific settings key (for global settings key is default value 0).
            newKey.SiteID = CMSContext.CurrentSiteID;

            // Create the settings key
            SettingsKeyProvider.SetValue(newKey);

            return(true);
        }

        return(false);
    }
예제 #24
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            this.Visible = false;
        }
        else
        {
            // Check renamed DLL library
            if (CMSOpenIDHelper.CheckOpenIdDLL())
            {
                // Check if OpenID module is enabled
                if (SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".CMSEnableOpenID"))
                {
                    ltlScript.Text = ScriptHelper.GetIncludeScript(PROVIDERS_LOCATION + "OpenIDSelector.js");
                    lblError.Text  = GetString("openid.invalidid");

                    SetProviders();
                    DisplayButtons();

                    openIDhelper = new CMSOpenIDHelper();
                    CheckStatus();
                }
                else
                {
                    // Error label is displayed in Design mode when OpenID is disabled
                    if (CMSContext.ViewMode == ViewModeEnum.Design)
                    {
                        StringBuilder parameter = new StringBuilder();
                        parameter.Append(GetString("header.sitemanager") + " -> ");
                        parameter.Append(GetString("settingscategory.cmssettings") + " -> ");
                        parameter.Append(GetString("settingscategory.cmsmembership") + " -> ");
                        parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> ");
                        parameter.Append(GetString("settingscategory.cmsopenid"));
                        if (CMSContext.CurrentUser.UserSiteManagerAdmin)
                        {
                            // Make it link for SiteManager Admin
                            parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl("~/CMSSiteManager/default.aspx?section=settings") + "\" target=\"_top\">");
                            parameter.Append("</a>");
                        }

                        lblError.Text    = String.Format(GetString("mem.openid.disabled"), parameter.ToString());
                        lblError.Visible = true;
                        txtInput.Visible = false;
                    }
                    else
                    {
                        this.Visible = false;
                    }
                }
            }
            // Error label is displayed in Design mode when OpenID library is not enabled
            else
            {
                lblError.Text    = ResHelper.GetString("mem.openid.library");
                lblError.Visible = true;
                txtInput.Visible = false;
            }
        }
    }
예제 #25
0
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        // Register script files
        ScriptHelper.RegisterSpellChecker(this);
        ScriptHelper.RegisterScriptFile(this, "cmsedit.js");
        ScriptHelper.RegisterScriptFile(this, "~/CMSModules/Content/CMSDesk/Edit/Edit.js");
        ScriptHelper.RegisterSaveChanges(this);
        ScriptHelper.RegisterTooltip(this);

        // Register js synchronization script for split mode
        if (!newculture && !newdocument && displaySplitMode)
        {
            RegisterSplitModeSync(true, false);
        }

        formElem.lblInfo.Text = "";

        if (newdocument && SettingsKeyProvider.GetBoolValue(CMSContext.CurrentSiteName + ".ProductTabEnabled"))
        {
            InitializeProductControls();
        }
        else
        {
            // Hide all product controls
            plcNewProduct.Visible = false;
        }
    }
예제 #26
0
    public void RaiseCallbackEvent(string eventArgument)
    {
        // Get site settings
        extensions = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSUploadExtensions");

        // Returns site settings back to the client
        extensions = string.Format("{0}|{1}", extensions, eventArgument);
    }
예제 #27
0
    /// <summary>
    /// OnLoad event.
    /// </summary>
    /// <param name="e">Event arguments</param>
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);

        repItem.ItemDataBound += repItem_ItemDataBound;

        currentUser = CMSContext.CurrentUser;
        string script = "";

        // Friendship request
        script += "function ContextFriendshipRequest(id) { \n" +
                  "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Friends/CMSPages/Friends_Request.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id,'requestFriend', 480, 350); \n" +
                  " } \n";

        // Friendship rejection
        script += "function ContextFriendshipReject(id) { \n" +
                  "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Friends/CMSPages/Friends_Reject.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'rejectFriend', 410, 270); \n" +
                  " } \n";

        // Send private message
        script += "function ContextPrivateMessage(id) { \n" +
                  "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Messaging/CMSPages/SendMessage.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'sendMessage', 390, 390); \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('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?invitedid=' + id , 'inviteToGroup', 500, 300); \n } \n";

        // Redirect to sign in URL
        string signInUrl = CMSContext.CurrentResolver.ResolveMacros(SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSSecuredAreasLogonPage"));

        if (signInUrl != "")
        {
            signInUrl = "window.location.replace('" + URLHelper.AddParameterToUrl(ResolveUrl(signInUrl), "ReturnURL", Server.UrlEncode(URLRewriter.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 Page_Load(object sender, EventArgs e)
    {
        mBounceLimit = SettingsKeyProvider.GetIntValue(CMSContext.CurrentSiteName + ".CMSBouncedEmailsLimit");

        if (!RequestHelper.IsPostBack())
        {
            Reload();
        }
    }
예제 #29
0
        private void SettingsKeyUpdate_After(object sender, ObjectEventArgs e)
        {
            SettingsKeyInfo setting = e.Object as SettingsKeyInfo;

            if (setting.KeyName == "CMSSalesForceLeadReplicationMapping")
            {
                SettingsKeyProvider.SetValue("CMSSalesForceLeadReplicationMappingDateTime", DateTime.Now.ToString("s"));
            }
        }
예제 #30
0
    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 = CMSContext.CurrentSiteName;
            ResizeToWidth       = ImageHelper.GetAutoResizeToWidth(siteName);
            ResizeToHeight      = ImageHelper.GetAutoResizeToHeight(siteName);
            ResizeToMaxSideSize = ImageHelper.GetAutoResizeToMaxSideSize(siteName);
        }

        if (UseFileUploader)
        {
            string siteName         = CMSContext.CurrentSiteName;
            string siteExtensions   = SettingsKeyProvider.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 = CMSContext.CurrentSiteName;
                AllowedExtensions = SettingsKeyProvider.GetStringValue(siteName + ".CMSUploadExtensions");
            }
        }
    }