protected void Page_Load(object sender, EventArgs e)
    {
        // Check hash
        if (!QueryHelper.ValidateHash("hash"))
        {
            RedirectToAccessDenied(ResHelper.GetString("dialogs.badhashtitle"));
        }

        userId      = QueryHelper.GetInteger("userId", 0);
        currentUser = CMSContext.CurrentUser;

        // Check 'read' permissions
        if (!currentUser.IsAuthorizedPerResource("CMS.Friends", "Read") && (currentUser.UserID != userId))
        {
            RedirectToAccessDenied("CMS.Friends", "Read");
        }

        // Check license
        if (DataHelper.GetNotEmpty(URLHelper.GetCurrentDomain(), string.Empty) != string.Empty)
        {
            LicenseHelper.CheckFeatureAndRedirect(URLHelper.GetCurrentDomain(), FeatureEnum.Friends);
        }

        if (userId > 0)
        {
            // Check that only global administrator can edit global administrator's accounts
            UserInfo ui = UserInfoProvider.GetUserInfo(userId);
            EditedObject = ui;

            if (!CheckGlobalAdminEdit(ui))
            {
                plcTable.Visible = false;
                lblError.Text    = GetString("Administration-User_List.ErrorGlobalAdmin");
                lblError.Visible = true;
            }
            else
            {
                string imagePath = GetImageUrl("Objects/CMS_Friend/");
                ScriptHelper.RegisterDialogScript(this);
                FriendsListRequested.UserID              = userId;
                FriendsListRequested.OnCheckPermissions += CheckPermissions;
                FriendsListRequested.ZeroRowsText        = GetString("friends.nouserrequestedfriends");

                // Request friend link
                string script =
                    "function displayRequest(){ \n" +
                    "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Friends/Dialogs/Friends_Request.aspx") + "?userid=" + userId + "&siteid=" + SiteID + "', 'rejectDialog', 480, 350);}";

                ScriptHelper.RegisterStartupScript(this, GetType(), "displayModalRequest", ScriptHelper.GetScript(script));
                string[,] actions = new string[1, 6];
                actions[0, 0]     = HeaderActions.TYPE_HYPERLINK;
                actions[0, 1]     = GetString("Friends_List.NewItemCaption");
                actions[0, 2]     = null;
                actions[0, 3]     = "javascript:displayRequest();";
                actions[0, 4]     = null;
                actions[0, 5]     = imagePath + "add.png";
                CurrentMaster.HeaderActions.Actions = actions;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        currentUser = CMSContext.CurrentUser;
        string imagePath = URLHelper.ResolveUrl(GetImageUrl("Objects/CMS_Friend/"));

        ScriptHelper.RegisterDialogScript(this);
        FriendsList.UserID              = currentUser.UserID;
        FriendsList.OnCheckPermissions += CheckPermissions;
        FriendsList.ZeroRowsText        = GetString("friends.nofriends");

        // Request friend link
        string script =
            "function displayRequest(){ \n" +
            "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Friends/Dialogs/Friends_Request.aspx") + "?userid=" + currentUser.UserID + "', 'rejectDialog', 480, 350);}";

        ScriptHelper.RegisterStartupScript(this, GetType(), "displayModalRequest", ScriptHelper.GetScript(script));

        string[,] actions = new string[1, 6];
        actions[0, 0]     = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1]     = GetString("Friends_List.NewItemCaption");
        actions[0, 2]     = null;
        actions[0, 3]     = "javascript:displayRequest();";
        actions[0, 4]     = null;
        actions[0, 5]     = imagePath + "add.png";
        CurrentMaster.HeaderActions.Actions = actions;
    }
Beispiel #3
0
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // Set control style and css class
        if (!string.IsNullOrEmpty(this.ControlStyle))
        {
            txtMacro.Editor.Attributes.Add("style", this.ControlStyle);
        }
        if (!string.IsNullOrEmpty(this.CssClass))
        {
            txtMacro.Editor.CssClass = this.CssClass;
        }

        this.txtMacro.ShowAutoCompletionAbove = this.ShowAutoCompletionAbove;
        this.txtMacro.Editor.UseSmallFonts    = true;
        this.txtMacro.Editor.Height           = new Unit("50px");
        this.txtMacro.MixedMode              = false;
        this.txtMacro.Editor.ShowToolbar     = false;
        this.txtMacro.Editor.ShowLineNumbers = false;
        ContextResolver resolver = (ContextResolver)GetValue("Resolver");

        if (resolver != null)
        {
            txtMacro.Resolver = resolver;
        }

        ScriptHelper.RegisterClientScriptBlock(this.Page, typeof(string), "InsertMacroCondition", "function InsertMacroCondition(text) {" + this.txtMacro.Editor.EditorID + ".setValue(text);}", true);
        ScriptHelper.RegisterDialogScript(this.Page);

        btnEdit.ImageUrl      = GetImageUrl("Design/Controls/UniGrid/Actions/Edit.png");
        btnEdit.OnClientClick = "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSFormControls/Inputs/ConditionBuilder.aspx") + "?condition=' + encodeURIComponent(" + this.txtMacro.Editor.EditorID + ".getValue()) , 'editmacrocondition', 900, 700); return false;";
    }
Beispiel #4
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        if (Visible)
        {
            ScriptHelper.RegisterScriptFile(Page, @"~/CMSModules/Content/CMSDesk/Edit/EditMenu.js");

            if (RenderScript)
            {
                string script = "function " + FunctionsPrefix + "LocalSave(nodeId) { " + Page.ClientScript.GetPostBackEventReference(btnSave, null) + "; } \n" +
                                "function " + FunctionsPrefix + "LocalApprove(nodeId) { " + Page.ClientScript.GetPostBackEventReference(btnApprove, null) + "; } \n" +
                                "function " + FunctionsPrefix + "LocalReject(nodeId) { " + Page.ClientScript.GetPostBackEventReference(btnReject, null) + "; } \n" +
                                "function " + FunctionsPrefix + "CheckOut(nodeId) { " + Page.ClientScript.GetPostBackEventReference(btnCheckOut, null) + "; } \n" +
                                "function " + FunctionsPrefix + "LocalCheckIn(nodeId) { " + Page.ClientScript.GetPostBackEventReference(btnCheckIn, null) + "; } \n" +
                                "function " + FunctionsPrefix + "UndoCheckOut(nodeId) { if(!confirm(" + ScriptHelper.GetString(GetString("EditMenu.UndoCheckOutConfirmation")) + ")) return false; " + Page.ClientScript.GetPostBackEventReference(btnUndoCheckout, null) + "; } \n";

                // Add control frame name
                script += "var controlFrame = 'editview'; \n";
                script += "var spellURL = '" + ((CMSContext.ViewMode == ViewModeEnum.LiveSite) ?
                                                CMSContext.ResolveDialogUrl("~/CMSFormControls/LiveSelectors/SpellCheck.aspx") :
                                                CMSContext.ResolveDialogUrl("~/CMSModules/Content/CMSDesk/Edit/SpellCheck.aspx")) + "'; \n";
                script += "var controlFrame = '" + controlFrame + "';\n";

                AddScript(script);
            }
        }
    }
Beispiel #5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        UIFormControl.OnCheckPermissions += new EventHandler(UIFormControl_OnCheckPermissions);
        UIFormControl.OnBeforeValidate   += new EventHandler(UIFormOnOnBeforeValidate);

        ScriptHelper.RegisterDialogScript(Page);

        ChatUserInfo user = TypedEditedObject;

        // Setting attributes of controls
        if (user != null)
        {
            if (user.IsAnonymous)
            {
                RedirectToInformation(ResHelper.GetString("chat.user.cannoteditanonymoususer"));
                return;
            }

            UserInfo cmsUser = UserInfoProvider.GetUserInfo(user.ChatUserUserID.Value);

            pnlStaticUser.Visible = true;
            fUserSelector.Visible = false;
            fUserSelector.Value   = user.ChatUserUserID;

            txtUserNameStaticValue.Text = HTMLHelper.HTMLEncode(cmsUser.FullName);
            btnEditUser.OnClientClick   = "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Membership/Pages/Users/User_Edit_Dialog.aspx") + "?userid=" + user.ChatUserUserID + "', 'UserEdit', 950, 800); return false;";
            btnEditUser.Text            = GetString("general.edit");
        }
        else
        {
            // New object
            pnlStaticUser.Visible = false;
            fUserSelector.Visible = true;
        }
    }
Beispiel #6
0
    protected object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        bool approve = false;

        switch (sourceName.ToLower())
        {
        case "messageapproved":
            return(UniGridFunctions.ColoredSpanYesNo(parameter));

        case "messageisspam":
            return(UniGridFunctions.ColoredSpanYesNoReversed(parameter));

        case "messagetext":
            string text = parameter.ToString();
            if (text.Length > 30)
            {
                text = text.Substring(0, 30) + "...";
            }
            return(HTMLHelper.HTMLEncode(text));

        case "messagetooltip":
            return(HTMLHelper.HTMLEncodeLineBreaks(parameter.ToString()));

        case "edit":
            ImageButton editButton = ((ImageButton)sender);
            int         boardID    = ValidationHelper.GetInteger(((DataRowView)((GridViewRow)parameter).DataItem).Row["BoardID"], 0);

            string url = "~/CMSModules/MessageBoards/Tools/Messages/Message_Edit.aspx";
            if (this.IsLiveSite)
            {
                url = "~/CMSModules/MessageBoards/CMSPages/Message_Edit.aspx";
            }

            editButton.OnClientClick = "modalDialog('" + CMSContext.ResolveDialogUrl(((this.EditPageUrl == "") ? url : this.EditPageUrl)) +
                                       "?messageboardid=" + boardID + "&messageId=" + editButton.CommandArgument + "', 'MessageEdit', 500, 400); return false;";
            break;

        case "approve":
            approve = ValidationHelper.GetBoolean(((DataRowView)((GridViewRow)parameter).DataItem).Row["MessageApproved"], false);
            if (!approve)
            {
                ImageButton button = ((ImageButton)sender);
                button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Approve.png");
                button.ToolTip  = GetString("general.approve");
            }
            else
            {
                ImageButton button = ((ImageButton)sender);
                button.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Reject.png");
                button.ToolTip  = GetString("general.reject");
            }
            break;

        case "messageinserted":
            return(CMSContext.ConvertDateTime(ValidationHelper.GetDateTime(parameter, DataHelper.DATETIME_NOT_SELECTED), this).ToString());
        }
        return(parameter);
    }
    /// <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);
    }
Beispiel #8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        #region "Security"

        memberListElem.OnCheckPermissions += new CheckPermissionsEventHandler(memberListElem_OnCheckPermissions);
        memberEditElem.OnCheckPermissions += memberEditElem_OnCheckPermissions;

        #endregion


        if (!Visible)
        {
            EnableViewState = false;
        }

        if (StopProcessing)
        {
            actionsElem.StopProcessing    = true;
            memberListElem.StopProcessing = true;
            memberEditElem.StopProcessing = true;
        }
        else
        {
            if ((GroupID == 0) && HideWhenGroupIsNotSupplied)
            {
                Visible = false;
                return;
            }

            memberListElem.OnAction += new CommandEventHandler(memberListElem_GridOnAction);

            lnkEditBack.Click += lnkEditBack_Click;
            lnkEditBack.Text   = GetString("group.members");

            // Initialize the invite customer element
            string[,] actions   = new string[1, 7];
            actions[0, 0]       = HeaderActions.TYPE_LINKBUTTON;
            actions[0, 1]       = GetString("groupinvitation.invite");
            actions[0, 2]       = "OpenInvite(); return false;";
            actions[0, 5]       = GetImageUrl("CMSModules/CMS_Groups/invitemember.png");
            actions[0, 6]       = "invitemember";
            actionsElem.Actions = actions;

            string script = "function OpenInvite() {\n" +
                            "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?groupid=" + GroupID + "','inviteToGroup', 500, 310); \n" +
                            " } \n";

            // Register menu management scripts
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Members", ScriptHelper.GetScript(script));

            // Register the dialog script
            ScriptHelper.RegisterDialogScript(Page);
        }
    }
    /// <summary>
    /// Registers action scripts
    /// </summary>
    private void RegisterActionScripts()
    {
        StringBuilder sb = new StringBuilder();

        // Register spell checker script
        ScriptHelper.RegisterSpellChecker(Page);

        sb.Append("var spellURL = '", CMSContext.ResolveDialogUrl("~/CMSModules/Content/CMSDesk/Edit/SpellCheck.aspx"), "'; \n");
        sb.Append("function SpellCheck_", ClientID, "() { checkSpelling(spellURL); }");

        ControlsHelper.RegisterClientScriptBlock(this, Page, typeof(string), "SpellCheckAction" + ClientID, ScriptHelper.GetScript(sb.ToString()));
    }
Beispiel #10
0
    protected void btnEdit_Click(object sender, ImageClickEventArgs e)
    {
        SessionHelper.SetValue("ConditionBuilderCondition" + this.ClientID, EditorValue);

        string dialogUrl = String.Format("{0}?clientid={1}&module={2}&ruletype={3}", CMSContext.ResolveDialogUrl("~/CMSFormControls/Macros/ConditionBuilder.aspx"), ClientID, RuleCategoryNames, DisplayRuleType);

        if (!string.IsNullOrEmpty(ResolverName))
        {
            SessionHelper.SetValue("ConditionBuilderResolver" + this.ClientID, ResolverName);
        }

        ScriptHelper.RegisterStartupScript(this.Page, typeof(string), "ConditionBuilderDialog", "modalDialog('" + dialogUrl + "', 'editmacrocondition', '95%', 700);", true);
    }
Beispiel #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Add styles
        RegisterDialogCSSLink();

        CurrentMaster.Title.TitleText      = GetString("Messaging.MessageUserSelector.HeaderCaption");
        CurrentMaster.Title.TitleImage     = GetImageUrl("Objects/CMS_User/object.png");
        CurrentMaster.FrameResizer.Visible = false;

        if (!CMSContext.CurrentUser.IsPublic())
        {
            string[,] tabs = new string[3, 4];
            int selectedTab = 2;
            CurrentMaster.Tabs.Visible = true;

            if (QueryHelper.GetString("showtab", String.Empty).ToLower() != "search")
            {
                selectedTab = 0;
                // ContactList tab
                tabs[0, 0] = GetString("Messaging.MessageUserSelector.ContactList");
                tabs[0, 2] = CMSContext.ResolveDialogUrl("~/CMSModules/Messaging/CMSPages/MessageUserSelector_ContactList.aspx") + "?hidid=" +
                             QueryHelper.GetText("hidid", String.Empty) +
                             "&mid=" +
                             QueryHelper.GetText("mid", String.Empty);

                // Show only if community module is present
                if (ModuleEntry.IsModuleLoaded(ModuleEntry.COMMUNITY) && UIHelper.IsFriendsModuleEnabled(CMSContext.CurrentSiteName))
                {
                    // Friends tab
                    tabs[1, 0] = GetString("friends.friends");
                    tabs[1, 2] = CMSContext.ResolveDialogUrl("~/CMSModules/Friends/CMSPages/MessageUserSelector_FriendsList.aspx") + "?hidid=" +
                                 QueryHelper.GetText("hidid", String.Empty) +
                                 "&mid=" +
                                 QueryHelper.GetText("mid", String.Empty);
                }
            }

            // Search tab
            tabs[2, 0] = GetString("general.search");
            tabs[2, 2] = CMSContext.ResolveDialogUrl("~/CMSModules/Messaging/CMSPages/MessageUserSelector_Search.aspx") + "?refresh=" +
                         QueryHelper.GetText("refresh", String.Empty) +
                         "&hidid=" +
                         QueryHelper.GetText("hidid", String.Empty) +
                         "&mid=" +
                         QueryHelper.GetText("mid", String.Empty);

            CurrentMaster.Tabs.Tabs        = tabs;
            CurrentMaster.Tabs.SelectedTab = selectedTab;
            CurrentMaster.Tabs.UrlTarget   = "MessageUserSelectorContent";
        }
    }
    /// <summary>
    /// Initializes New message action for group message board.
    /// </summary>
    private void InitializeGroupNewMessage()
    {
        plcNewMessageGroups.Visible = true;

        // New message link
        string[,] actions = new string[1, 6];
        actions[0, 0]     = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1]     = GetString("Board.MessageList.NewMessage");
        actions[0, 2]     = "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/Message_Edit.aspx") + "?boardId=" + BoardID + "&groupid=" + GroupID + "&changemaster=" + QueryHelper.GetBoolean("changemaster", false) + "', 'MessageEdit', 500, 400); return false;";
        actions[0, 3]     = "#";
        actions[0, 4]     = null;
        actions[0, 5]     = GetImageUrl("Objects/Board_Message/add.png");

        headerActions.Actions = actions;
    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            lblError.Visible = (lblError.Text != "");
            lblInfo.Visible  = (lblInfo.Text != "");

            // Ensure uploader button
            plcUploader.Visible         = Enabled;
            plcUploaderDisabled.Visible = !Enabled;

            // Hide actions
            gridAttachments.GridView.Columns[0].Visible = !HideActions;
            gridAttachments.GridView.Columns[1].Visible = !HideActions;
            newAttachmentElem.Visible   = !HideActions && Enabled;
            plcUploaderDisabled.Visible = !HideActions && !Enabled && (attachmentGuid == Guid.Empty);

            // Ensure correct layout
            bool gridHasData = !DataHelper.DataSourceIsEmpty(gridAttachments.DataSource);
            Visible         = gridHasData || !HideActions;
            pnlGrid.Visible = gridHasData;

            // Initialize button for adding attachments
            plcUploader.Visible = (attachmentGuid == Guid.Empty) || !gridHasData;

            // Dialog for editing attachment
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("function Edit_" + ClientID + "(attachmentGUID, formGUID, versionHistoryID, parentId, hash, image) { ");
            sb.AppendLine("var form = '';");
            sb.AppendLine("if (formGUID != '') { form = '&formguid=' + formGUID + '&parentid=' + parentId; }");
            sb.AppendLine(((Node != null) ? "else{form = '&siteid=' + " + Node.NodeSiteID + ";}" : ""));
            sb.AppendLine("if (image) {");
            sb.AppendLine("modalDialog('" + ResolveUrl((IsLiveSite ? "~/CMSFormControls/LiveSelectors/ImageEditor.aspx" : "~/CMSModules/Content/CMSDesk/Edit/ImageEditor.aspx") + "?attachmentGUID=' + attachmentGUID + '&refresh=1&versionHistoryID=' + versionHistoryID + form + '&clientid=" + ClientID + "&hash=' + hash") + ", 'editorDialog', 905, 670); }");
            sb.AppendLine("else {");
            sb.AppendLine("modalDialog('" + CMSContext.ResolveDialogUrl((IsLiveSite ? "~/CMSModules/Content/Attachments/CMSPages/MetaDataEditor.aspx" : "~/CMSModules/Content/Attachments/Dialogs/MetaDataEditor.aspx") + "?attachmentGUID=' + attachmentGUID + '&refresh=1&versionHistoryID=' + versionHistoryID + form + '&clientid=" + ClientID + "&hash=' + hash") + ", 'editorDialog', 500, 350); }");
            sb.AppendLine("return false; }");

            // Register script for editing attachment
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "AttachmentEditScripts_" + ClientID, ScriptHelper.GetScript(sb.ToString()));
        }
    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        ScriptHelper.RegisterDialogScript(this.Page);

        HeaderAction updateAction = new HeaderAction()
        {
            OnClientClick = ControlsHelper.GetPostBackEventReference(btnUpdateStatuses, null),
            Tooltip       = GetString("translationservice.updatestatusestooltip"),
            Text          = GetString("translationservice.updatestatuses"),
            Enabled       = CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.TranslationServices", "Modify") && !listElem.Grid.IsEmpty
        };

        updateAction.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/Approve" + (updateAction.Enabled ? "" : "Disabled") + ".png");

        string translateUrl = CMSContext.ResolveDialogUrl("~/CMSModules/Translations/Pages/TranslateDocuments.aspx") + "?select=1&modal=1";

        translateUrl = URLHelper.AddParameterToUrl(translateUrl, "hash", QueryHelper.GetHash(URLHelper.GetQuery(translateUrl)));

        HeaderAction submitAction = new HeaderAction()
        {
            OnClientClick = "modalDialog('" + translateUrl + "', 'SubmitTranslation', 600, 570);",
            Tooltip       = GetString("translationservice.submittranslationtooltip"),
            Text          = GetString("translationservice.submittranslation"),
            Enabled       = CMSContext.CurrentUser.IsAuthorizedPerResource("CMS.Content", "SubmitForTranslation")
        };

        submitAction.ImageUrl = GetImageUrl("Design/Controls/UniGrid/Actions/AddPost" + (submitAction.Enabled ? "" : "Disabled") + ".png");

        this.AddHeaderAction(submitAction);
        this.AddHeaderAction(updateAction);

        CurrentMaster.HeaderActions.ReloadData();

        if (!listElem.Grid.IsEmpty)
        {
            string statusCheck = SettingsKeyProvider.GetStringValue("CMSTranslationsLastStatusCheck");
            if (string.IsNullOrEmpty(statusCheck))
            {
                statusCheck = GetString("general.notavailable");
            }

            ShowInformation(string.Format(GetString("translationservice.laststatuscheck"), statusCheck));
        }
    }
    protected void Page_PreRender(object sender, EventArgs e)
    {
        ScriptHelper.RegisterDialogScript(Page);
        string url = IsLiveSite
                         ? CMSContext.ResolveDialogUrl("~/CMSModules/AbuseReport/CMSPages/ReportAbuse.aspx")
                         : CMSContext.ResolveDialogUrl("~/CMSModules/AbuseReport/Dialogs/ReportAbuse.aspx");

        url = URLHelper.AddParameterToUrl(url, "params", Identifier);

        parameters.Add("confirmationtext", ConfirmationText);
        parameters.Add("reporttitle", ReportTitle);
        parameters.Add("reportdialogtitle", ReportDialogTitle);
        parameters.Add("reportobjectid", ReportObjectID);
        parameters.Add("reportobjecttype", ReportObjectType);
        parameters.Add("reporturl", URLHelper.CurrentURL);
        WindowHelper.Add(Identifier, parameters);

        lnkText.NavigateUrl = "javascript:modalDialog('" + url + "', 'reportDialog', 425, 370);";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        messageList.IsLiveSite = false;
        messageList.BoardID    = mBoardId;
        messageList.GroupID    = mGroupId;
        messageList.OnAction  += messageList_OnAction;

        if (mBoardId > 0)
        {
            // New message link
            string[,] actions = new string[1, 6];
            actions[0, 0]     = HeaderActions.TYPE_HYPERLINK;
            actions[0, 1]     = GetString("Board.MessageList.NewMessage");
            actions[0, 2]     = "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/MessageBoards/Tools/Messages/Message_Edit.aspx") + "?boardId=" + mBoardId + "&changemaster=" + QueryHelper.GetBoolean("changemaster", false) + "', 'MessageEdit', 500, 400); return false;";
            actions[0, 3]     = "#";
            actions[0, 4]     = null;
            actions[0, 5]     = GetImageUrl("CMSModules/CMS_MessageBoards/addmessage.png");
            CurrentMaster.HeaderActions.Actions = actions;
        }
    }
    /// <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 = "";

        // Join the group
        script += "function ContextJoinTheGroup(id) { \n" +
                  "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/JoinTheGroup.aspx") + "?groupid=' + id, 'joinTheGroup', 500, 180); \n" +
                  " } \n";
        // Leave the group
        script += "function ContextLeaveTheGroup(id) { \n" +
                  "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/LeaveTheGroup.aspx") + "?groupid=' + id , 'leaveTheGroup', 500, 180); \n" +
                  " } \n";

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

        if (!string.IsNullOrEmpty(signInUrl))
        {
            signInUrl = "window.location.replace('" + URLHelper.AddParameterToUrl(ResolveUrl(signInUrl), "ReturnURL", Server.UrlEncode(URLRewriter.CurrentURL)) + "');";
        }
        script += "function ContextRedirectToSignInUrl() { \n" + signInUrl + "} \n";

        string manageGroupUrl = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSGroupManagementPath");

        if (!string.IsNullOrEmpty(manageGroupUrl))
        {
            manageGroupUrl = "window.location.replace('" + ResolveUrl(manageGroupUrl) + "');";
        }

        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(this.Page);
    }
Beispiel #18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Turn sorting off
        gridSteps.GridView.AllowSorting = false;
        ReloadData();

        string viewVersionUrl = null;

        if (IsLiveSite)
        {
            viewVersionUrl = CMSContext.ResolveDialogUrl("~/CMSModules/Content/CMSPages/Versions/ViewVersion.aspx");
        }
        else
        {
            viewVersionUrl = ResolveUrl("~/CMSModules/Content/CMSDesk/Properties/ViewVersion.aspx");
        }

        string viewVersionScript = ScriptHelper.GetScript("function ViewVersion(versionHistoryId) {window.open('" + viewVersionUrl + "?versionHistoryId=' + versionHistoryId)}");

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "viewVersionScript", viewVersionScript);
    }
Beispiel #19
0
    /// <summary>
    /// Hides/displays parts of the form according edited customer.
    /// </summary>
    private void InitForm()
    {
        // Display site discount level only for registered customers
        plcSiteDiscount.Visible = Customer.CustomerIsRegistered;
        if (Customer.CustomerIsRegistered)
        {
            UserInfo ui = UserInfoProvider.GetUserInfo(Customer.CustomerUserID);
            if (ui != null)
            {
                pnlEdit.Visible             = false;
                pnlStatic.Visible           = true;
                lblUserNameStaticValue.Text = HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(ui.UserName));
                if (AllowEditUser)
                {
                    btnEditUser.OnClientClick = "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Membership/Pages/Users/User_Edit_Dialog.aspx") + "?userid=" + Customer.CustomerUserID + "', 'UserEdit', 950, 800); return false;";
                    btnEditUser.Visible       = true;
                }
            }

            // Hide global discount level selector when global levels not allowed
            plcGlobalDiscount.Visible = allowGlobalDiscountLevels;
        }
        else
        {
            // Hide fields requiring registered customer
            plcDiscounts.Visible   = false;
            plcPreferences.Visible = false;
            pnlEdit.Visible        = true;
            pnlStatic.Visible      = false;
        }

        // Set up discount level selector
        string emptyRecordText = GetString(allowGlobalDiscountLevels ? "general.UseGlobal" : "general.empty");

        drpDiscountLevel.SpecialFields = new string[, ] {
            { emptyRecordText, "0" }
        };
        drpGlobalDiscountLevel.SiteID = 0;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            btnSelect.Text = GetString("General.Select");

            ScriptHelper.RegisterDialogScript(Page);
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "fillScript", ScriptHelper.GetScript("function FillUserName(userId, mText, mId, mId2) {document.getElementById(mId).value = mText;document.getElementById(mId2).value = userId;}"));

            string showTab = CMSContext.CurrentUser.IsPublic() ? "Search" : "ContactList";
            string url     = CMSContext.ResolveDialogUrl("~/CMSModules/Messaging/Dialogs/MessageUserSelector_Frameset.aspx");
            if (IsLiveSite)
            {
                if (!CMSContext.CurrentUser.IsPublic())
                {
                    url = CMSContext.ResolveDialogUrl("~/CMSModules/Messaging/CMSPages/MessageUserSelector_Frameset.aspx");
                }
                else
                {
                    url = CMSContext.ResolveDialogUrl("~/CMSModules/Messaging/CMSPages/PublicMessageUserSelector.aspx");
                }
            }

            btnSelect.OnClientClick = "modalDialog('" + url + "?refresh=false&showtab=" + showTab + "&hidid=" +
                                      hiddenField.ClientID + "&mid=" + txtUser.ClientID +
                                      "','MessageUserSelector',600, 510); return false;";

            if (!RequestHelper.IsPostBack())
            {
                txtUser.Text = SelectedUserName;
            }
        }
    }
Beispiel #21
0
    public void SetupControl()
    {
        gridHistory.ZeroRowsText = GetString("workflowproperties.documenthasnohistory");
        gridHistory.IsLiveSite   = IsLiveSite;
        if (Node != null)
        {
            // Prepare the query parameters
            QueryDataParameters parameters = new QueryDataParameters();
            parameters.Add("@DocumentID", Node.DocumentID);

            gridHistory.QueryParameters = parameters;

            ScriptHelper.RegisterStartupScript(this, typeof(string), "confirmDestroyMessage", ScriptHelper.GetScript("var varConfirmDestroy='" + ResHelper.GetString("VersionProperties.ConfirmDestroy") + "'; \n"));

            gridHistory.GridName             = "~/CMSModules/Content/Controls/VersionHistory.xml";
            gridHistory.OnExternalDataBound += gridHistory_OnExternalDataBound;
            gridHistory.OnAction            += gridHistory_OnAction;

            string viewVersionUrl = null;
            if (IsLiveSite)
            {
                viewVersionUrl = CMSContext.ResolveDialogUrl("~/CMSModules/Content/CMSPages/Versions/ViewVersion.aspx");
            }
            else
            {
                viewVersionUrl = ResolveUrl("~/CMSModules/Content/CMSDesk/Properties/ViewVersion.aspx");
            }

            string viewVersionScript = ScriptHelper.GetScript("function ViewVersion(versionHistoryId) {window.open('" + viewVersionUrl + "?versionHistoryId=' + versionHistoryId)}");
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "viewVersionScript", viewVersionScript);
        }
        else
        {
            gridHistory.GridName = string.Empty;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        rfvTemplateDisplayName.ErrorMessage = GetString("general.requiresdisplayname");
        rfvTemplateName.ErrorMessage        = GetString("NewsletterTemplate_Edit.ErrorEmptyName");

        ScriptHelper.RegisterSpellChecker(this);

        // Control initializations
        string varsScript = string.Format("var emptyNameMsg = '{0}'; \nvar emptyWidthMsg = '{1}'; \nvar emptyHeightMsg = '{2}'; \nvar spellURL = '{3}'; \n",
                                          GetString("NewsletterTemplate_Edit.EmptyNameMsg"),
                                          GetString("NewsletterTemplate_Edit.EmptyWidthMsg"),
                                          GetString("NewsletterTemplate_Edit.EmptyHeightMsg"),
                                          CMSContext.ResolveDialogUrl("~/CMSModules/Content/CMSDesk/Edit/SpellCheck.aspx"));

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Script_" + ClientID, ScriptHelper.GetScript(varsScript));

        // Set fields to be checked by Spell Checker
        string spellCheckScript = string.Format("if (typeof(spellCheckFields)==='undefined') {{var spellCheckFields = new Array();}} spellCheckFields.push('{0}');",
                                                htmlTemplateBody.ClientID);

        ScriptHelper.RegisterStartupScript(this, typeof(string), ClientID, ScriptHelper.GetScript(spellCheckScript));

        string currentEmailTemplate = GetString("NewsletterTemplate_Edit.NewItemCaption");

        // Get edited object and its existence
        EmailTemplateInfo emailTemplateObj = (EmailTemplateInfo)EditedObject;

        templateid = emailTemplateObj.TemplateID;

        currentEmailTemplate = emailTemplateObj.TemplateDisplayName;

        // Display editable region section only for e-mail templates of type "Issue template"
        if (emailTemplateObj.TemplateType == EmailTemplateType.Issue)
        {
            pnlEditableRegion.Visible = true;
            plcThumb.Visible          = true;
            ucThumbnail.Visible       = true;
            ucThumbnail.ObjectID      = emailTemplateObj.TemplateID;
            ucThumbnail.ObjectType    = NewsletterObjectType.NEWSLETTERTEMPLATE;
            ucThumbnail.Category      = MetaFileInfoProvider.OBJECT_CATEGORY_THUMBNAIL;
            ucThumbnail.SiteID        = emailTemplateObj.TemplateSiteID;
        }
        else
        {
            plcSubject.Visible = true;
        }

        // Init CSS styles every time during page load
        htmlTemplateBody.EditorAreaCSS = EmailTemplateInfoProvider.GetStylesheetUrl(emailTemplateObj.TemplateName) + "&timestamp=" + DateTime.Now.Millisecond;

        // Initialize header actions
        InitHeaderActions(emailTemplateObj.TemplateID);

        // Initialize HTML editor
        InitHTMLEditor(emailTemplateObj);

        if (!RequestHelper.IsPostBack())
        {
            // Initialize dialog
            LoadData(emailTemplateObj);

            // Show that the emailTemplate was created successfully
            if (QueryHelper.GetBoolean("saved", false))
            {
                ShowChangesSaved();
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // Initialize properties
            string script = "";

            // Set current user
            currentUser = CMSContext.CurrentUser;

            // Get Enable Friends setting
            bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(CMSContext.CurrentSiteName);

            // Initialize strings
            lnkSignIn.Text                 = SignInText;
            lnkJoinCommunity.Text          = JoinCommunityText;
            lnkMyProfile.Text              = MyProfileText;
            lnkEditMyProfile.Text          = EditMyProfileText;
            btnSignOut.Text                = SignOutText;
            lnkCreateNewGroup.Text         = CreateNewGroupText;
            lnkCreateNewBlog.Text          = CreateNewBlogText;
            lnkJoinGroup.Text              = JoinGroupText;
            lnkLeaveGroup.Text             = LeaveGroupText;
            lnkRejectFriendship.Text       = RejectFriendshipText;
            requestFriendshipElem.LinkText = RequestFriendshipText;
            lnkSendMessage.Text            = SendMessageText;
            lnkAddToContactList.Text       = AddToContactListText;
            lnkAddToIgnoreList.Text        = AddToIgnoreListText;
            lnkInviteToGroup.Text          = InviteGroupText;
            lnkManageGroup.Text            = ManageGroupText;
            lnkMyMessages.Text             = MyMessagesText;
            lnkMyFriends.Text              = MyFriendsText;
            lnkMyInvitations.Text          = MyInvitationsText;
            lnkMyTasks.Text                = MyTasksText;

            // If current user is public...
            if (currentUser.IsPublic())
            {
                // Display Sign In link if set so
                if (DisplaySignIn)
                {
                    // SignInPath returns URL - because of settings value
                    lnkSignIn.NavigateUrl = CMSContext.ResolveCurrentPath(SignInPath);
                    pnlSignIn.Visible     = true;
                    pnlSignInOut.Visible  = true;
                }

                // Display Join the community link if set so
                if (DisplayJoinCommunity)
                {
                    lnkJoinCommunity.NavigateUrl = GetUrl(JoinCommunityPath);
                    pnlJoinCommunity.Visible     = true;
                    pnlPersonalLinks.Visible     = true;
                }
            }
            // If user is logged in
            else
            {
                // Display Sign out link if set so
                if (DisplaySignOut && !RequestHelper.IsWindowsAuthentication())
                {
                    pnlSignOut.Visible   = true;
                    pnlSignInOut.Visible = true;
                }

                // Display Edit my profile link if set so
                if (DisplayEditMyProfileLink)
                {
                    lnkEditMyProfile.NavigateUrl = URLHelper.ResolveUrl(TreePathUtils.GetUrl(GroupMemberInfoProvider.GetMemberManagementPath(currentUser.UserName, CMSContext.CurrentSiteName)));
                    pnlEditMyProfile.Visible     = true;
                    pnlProfileLinks.Visible      = true;
                }

                // Display My profile link if set so
                if (DisplayMyProfileLink)
                {
                    lnkMyProfile.NavigateUrl = URLHelper.ResolveUrl(TreePathUtils.GetUrl(GroupMemberInfoProvider.GetMemberProfilePath(currentUser.UserName, CMSContext.CurrentSiteName)));
                    pnlMyProfile.Visible     = true;
                    pnlProfileLinks.Visible  = true;
                }

                // Display Create new group link if set so
                if (DisplayCreateNewGroup)
                {
                    lnkCreateNewGroup.NavigateUrl = GetUrl(CreateNewGroupPath);
                    pnlCreateNewGroup.Visible     = true;
                    pnlGroupLinks.Visible         = true;
                }

                // Display Create new blog link if set so
                if (DisplayCreateNewBlog)
                {
                    // Check that Community Module is present
                    ModuleEntry entry = ModuleEntry.GetModuleEntry(ModuleEntry.BLOGS);
                    if (entry != null)
                    {
                        lnkCreateNewBlog.NavigateUrl = GetUrl(CreateNewBlogPath);
                        pnlCreateNewBlog.Visible     = true;
                        pnlBlogLinks.Visible         = true;
                    }
                }

                // Display My messages link
                if (DisplayMyMessages)
                {
                    lnkMyMessages.NavigateUrl = GetUrl(MyMessagesPath);
                    pnlMyMessages.Visible     = true;
                    pnlPersonalLinks.Visible  = true;
                }

                // Display My friends link
                if (DisplayMyFriends && friendsEnabled)
                {
                    lnkMyFriends.NavigateUrl = GetUrl(MyFriendsPath);
                    pnlMyFriends.Visible     = true;
                    pnlPersonalLinks.Visible = true;
                }

                // Display My invitations link
                if (DisplayMyInvitations)
                {
                    lnkMyInvitations.NavigateUrl = GetUrl(MyInvitationsPath);
                    pnlMyInvitations.Visible     = true;
                    pnlPersonalLinks.Visible     = true;
                }

                // Display My tasks link
                if (DisplayMyTasks)
                {
                    lnkMyTasks.NavigateUrl   = GetUrl(MyTasksPath);
                    pnlMyTasks.Visible       = true;
                    pnlPersonalLinks.Visible = true;
                }

                GroupMemberInfo gmi = null;

                if (CommunityContext.CurrentGroup != null)
                {
                    // Get group info from community context
                    GroupInfo currentGroup = CommunityContext.CurrentGroup;

                    if (DisplayGroupLinks)
                    {
                        script += "function ReloadPage(){" + ControlsHelper.GetPostBackEventReference(this, "") + "}";

                        // Display Join group link if set so and user is visiting a group page
                        gmi = GetGroupMember(CMSContext.CurrentUser.UserID, currentGroup.GroupID);
                        if (gmi == null)
                        {
                            if (String.IsNullOrEmpty(JoinGroupPath))
                            {
                                script += "function JoinToGroupRequest() {\n" +
                                          "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/JoinTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestJoinToGroup', 500, 180); \n" +
                                          " } \n";

                                lnkJoinGroup.Attributes.Add("onclick", "JoinToGroupRequest();return false;");
                                lnkJoinGroup.NavigateUrl = URLHelper.CurrentURL;
                            }
                            else
                            {
                                lnkJoinGroup.NavigateUrl = GetUrl(JoinGroupPath);
                            }
                            pnlJoinGroup.Visible  = true;
                            pnlGroupLinks.Visible = true;
                        }
                        else if ((gmi.MemberStatus == GroupMemberStatus.Approved) || (CMSContext.CurrentUser.IsGlobalAdministrator))
                        // Display Leave the group link if user is the group member
                        {
                            if (String.IsNullOrEmpty(LeaveGroupPath))
                            {
                                script += "function LeaveTheGroupRequest() {\n" +
                                          "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/LeaveTheGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','requestLeaveThGroup', 500, 180); \n" +
                                          " } \n";

                                lnkLeaveGroup.Attributes.Add("onclick", "LeaveTheGroupRequest();return false;");
                                lnkLeaveGroup.NavigateUrl = URLHelper.CurrentURL;
                            }
                            else
                            {
                                lnkLeaveGroup.NavigateUrl = GetUrl(LeaveGroupPath);
                            }

                            pnlLeaveGroup.Visible = true;
                            pnlGroupLinks.Visible = true;
                        }
                    }

                    // Display Manage the group link if set so and user is logged as group administrator and user is visiting a group page
                    if (DisplayManageGroup && (currentUser.IsGroupAdministrator(currentGroup.GroupID) || (currentUser.IsGlobalAdministrator)))
                    {
                        lnkManageGroup.NavigateUrl = ResolveUrl(TreePathUtils.GetUrl(GroupInfoProvider.GetGroupManagementPath(currentGroup.GroupName, CMSContext.CurrentSiteName)));
                        pnlManageGroup.Visible     = true;
                        pnlGroupLinks.Visible      = true;
                    }
                }

                if (DisplayInviteToGroup)
                {
                    // Get group info from community context
                    GroupInfo currentGroup = CommunityContext.CurrentGroup;
                    // Get user info from site context
                    UserInfo siteContextUser = SiteContext.CurrentUser;

                    // Display invite to group link for user who is visiting a group page
                    if (currentGroup != null)
                    {
                        // Get group user
                        if (gmi == null)
                        {
                            gmi = GetGroupMember(CMSContext.CurrentUser.UserID, currentGroup.GroupID);
                        }

                        if (((gmi != null) && (gmi.MemberStatus == GroupMemberStatus.Approved)) || (CMSContext.CurrentUser.IsGlobalAdministrator))
                        {
                            pnlInviteToGroup.Visible = true;

                            if (String.IsNullOrEmpty(InviteGroupPath))
                            {
                                script += "function InviteToGroup() {\n modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','inviteToGroup', 500, 345); \n } \n";
                                lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;");
                                lnkInviteToGroup.NavigateUrl = URLHelper.CurrentURL;
                            }
                            else
                            {
                                lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath);
                            }
                        }
                    }
                    // Display invite to group link for user who is visiting another user's page
                    else if ((siteContextUser != null) && (siteContextUser.UserName != currentUser.UserName) && (GroupInfoProvider.GetUserGroupsCount(currentUser, CMSContext.CurrentSite) != 0))
                    {
                        pnlInviteToGroup.Visible = true;

                        if (String.IsNullOrEmpty(InviteGroupPath))
                        {
                            script += "function InviteToGroup() {\n modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?invitedid=" + siteContextUser.UserID + "','inviteToGroup', 500, 310); \n } \n";
                            lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;");
                            lnkInviteToGroup.NavigateUrl = URLHelper.CurrentURL;
                        }
                        else
                        {
                            lnkInviteToGroup.NavigateUrl = GetUrl(InviteGroupPath);
                        }
                    }
                }

                if (SiteContext.CurrentUser != null)
                {
                    // Get user info from site context
                    UserInfo siteContextUser = SiteContext.CurrentUser;

                    // Display Friendship link if set so and user is visiting an user's page
                    if (DisplayFriendshipLinks && (currentUser.UserID != siteContextUser.UserID) && friendsEnabled)
                    {
                        FriendshipStatusEnum status = CMSContext.CurrentUser.HasFriend(siteContextUser.UserID);
                        switch (status)
                        {
                        case FriendshipStatusEnum.Approved:
                            // Friendship rejection
                            script += "function ShortcutFriendshipReject(id) { \n" +
                                      "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Friends/CMSPages/Friends_Reject.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'rejectFriend', 410, 270); \n" +
                                      " } \n";

                            lnkRejectFriendship.Attributes.Add("onclick", "ShortcutFriendshipReject('" + siteContextUser.UserID + "');return false;");
                            lnkRejectFriendship.NavigateUrl = URLHelper.CurrentURL;
                            pnlRejectFriendship.Visible     = true;
                            pnlFriendshipLinks.Visible      = true;
                            break;

                        case FriendshipStatusEnum.None:
                            requestFriendshipElem.UserID          = currentUser.UserID;
                            requestFriendshipElem.RequestedUserID = siteContextUser.UserID;
                            pnlFriendshipLink.Visible             = true;
                            pnlFriendshipLinks.Visible            = true;
                            break;
                        }
                    }

                    // Show messaging links if enabled
                    if (MessagingPresent && (currentUser.UserID != siteContextUser.UserID))
                    {
                        // Display Send message link if user is visiting an user's page
                        if (DisplaySendMessage)
                        {
                            // Send private message
                            script += "function ShortcutPrivateMessage(id) { \n" +
                                      "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Messaging/CMSPages/SendMessage.aspx") + "?userid=" + currentUser.UserID + "&requestid=' + id , 'sendMessage', 390, 390); \n" +
                                      " } \n";

                            lnkSendMessage.Attributes.Add("onclick", "ShortcutPrivateMessage('" + siteContextUser.UserID + "');return false;");
                            lnkSendMessage.NavigateUrl = URLHelper.CurrentURL;
                            pnlSendMessage.Visible     = true;
                            pnlMessageLinks.Visible    = true;
                        }

                        // Display Add to contact list link if user is visiting an user's page
                        if (DisplayAddToContactList)
                        {
                            // Check if user is in contact list
                            bool isInContactList = ModuleCommands.MessagingIsInContactList(currentUser.UserID, siteContextUser.UserID);

                            // Add to actions
                            if (!isInContactList)
                            {
                                lnkAddToContactList.Attributes.Add("onclick", "return ShortcutAddToContactList('" + siteContextUser.UserID + "')");
                                lnkAddToContactList.NavigateUrl = URLHelper.CurrentURL;
                                pnlAddToContactList.Visible     = true;
                                pnlMessageLinks.Visible         = true;

                                // Add to contact list
                                script += "function ShortcutAddToContactList(usertoadd) { \n" +
                                          "var confirmation = confirm(" + ScriptHelper.GetString(GetString("messaging.contactlist.addconfirmation")) + ");" +
                                          "if(confirmation)" +
                                          "{" +
                                          "selectedIdElem = document.getElementById('" + hdnSelectedId.ClientID + "'); \n" +
                                          "if (selectedIdElem != null) { selectedIdElem.value = usertoadd;}" +
                                          ControlsHelper.GetPostBackEventReference(this, "addtocontactlist", false) +
                                          "} return false;}\n";
                            }
                        }

                        // Display Add to ignore list link if user is visiting an user's page
                        if (DisplayAddToIgnoreList)
                        {
                            // Check if user is in ignore list
                            bool isInIgnoreList = ModuleCommands.MessagingIsInIgnoreList(currentUser.UserID, siteContextUser.UserID);

                            // Add to ignore list
                            if (!isInIgnoreList)
                            {
                                lnkAddToIgnoreList.Attributes.Add("onclick", "return ShortcutAddToIgnoretList('" + siteContextUser.UserID + "')");
                                lnkAddToIgnoreList.NavigateUrl = URLHelper.CurrentURL;
                                pnlAddToIgnoreList.Visible     = true;
                                pnlMessageLinks.Visible        = true;

                                // Add to ignore list
                                script += "function ShortcutAddToIgnoretList(usertoadd) { \n" +
                                          "var confirmation = confirm(" + ScriptHelper.GetString(GetString("messaging.ignorelist.addconfirmation")) + ");" +
                                          "if(confirmation)" +
                                          "{" +
                                          "selectedIdElem = document.getElementById('" + hdnSelectedId.ClientID + "'); \n" +
                                          "if (selectedIdElem != null) { selectedIdElem.value = usertoadd;}" +
                                          ControlsHelper.GetPostBackEventReference(this, "addtoignorelist", false) +
                                          "} return false; } \n";
                            }
                        }
                    }
                }
            }

            // Register menu management scripts
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Shortcuts_" + ClientID, ScriptHelper.GetScript(script));

            // Register the dialog script
            ScriptHelper.RegisterDialogScript(Page);
        }
    }
    /// <summary>
    /// Page load.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get resource strings
        lblUploader.Text = GetString("filelist.btnupload") + ResHelper.Colon;

        // Setup site info
        site = CMSContext.CurrentSite;

        // Create id for div with selected image preview
        divId         = ClientID + "imgDiv";
        placeholderId = plcImageActions.ClientID;

        // Setup delete image properties
        btnDeleteImage.ImageUrl      = GetImageUrl("Design/Controls/UniGrid/Actions/delete.png");
        btnDeleteImage.OnClientClick = "return deleteAvatar('" + hiddenDeleteAvatar.ClientID + "', '" + hiddenAvatarGuid.ClientID + "', '" + placeholderId + "' );";
        btnDeleteImage.AlternateText = GetString("general.delete");

        // Setup show gallery button
        btnShowGallery.Text    = GetString("avat.selector.select");
        btnShowGallery.Visible = SettingsKeyProvider.GetBoolValue(site.SiteName + ".CMSEnableDefaultAvatars");

        // Register dialog script
        string resolvedAvatarsPage = string.Empty;

        if (IsLiveSite)
        {
            if (CMSContext.CurrentUser.IsAuthenticated())
            {
                resolvedAvatarsPage = CMSContext.ResolveDialogUrl("~/CMSModules/Avatars/CMSPages/AvatarsGallery.aspx");
            }
            else
            {
                resolvedAvatarsPage = CMSContext.ResolveDialogUrl("~/CMSModules/Avatars/CMSPages/PublicAvatarsGallery.aspx");
            }
        }
        else
        {
            resolvedAvatarsPage = ResolveUrl("~/CMSModules/Avatars/Dialogs/AvatarsGallery.aspx");
        }

        ScriptHelper.RegisterDialogScript(Page);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectAvatar",
                                               ScriptHelper.GetScript("function SelectAvatar(avatarType, clientId) { " +
                                                                      "modalDialog('" + resolvedAvatarsPage + "?avatartype=' + avatarType + '&clientid=' + clientId, 'permissionDialog', 600, 270); return false;}"));
        ltlScript.Text = ScriptHelper.GetScript("function UpdateForm(){ ; } \n");

        // Setup btnShowGallery action
        btnShowGallery.Attributes.Add("onclick", "SelectAvatar('" + AvatarInfoProvider.GetAvatarTypeString(avatarType) + "', '" + ClientID + "'); return false;");

        // Get image size param(s) for preview
        string sizeParams = string.Empty;

        // Keep aspect ratio is set - property was set directly or indirectly by max side size property.
        if (KeepAspectRatio)
        {
            sizeParams += "&maxsidesize=" + (MaxPictureWidth > MaxPictureHeight ? MaxPictureWidth : MaxPictureHeight);
        }
        else
        {
            sizeParams += "&width=" + MaxPictureWidth + "&height=" + MaxPictureHeight;
        }

        // Javascript which creates selected image preview and saves image guid  to hidden field
        string getAvatarPath      = ResolveUrl("~/CMSModules/Avatars/CMSPages/GetAvatar.aspx");
        string updateHiddenScript = ScriptHelper.GetScript("function " + ClientID + "updateHidden(guidPrefix, clientId)" +
                                                           "{" +
                                                           "if ( clientId == '" + ClientID + "')" +
                                                           "{" +
                                                           "avatarGuid = guidPrefix.substring(4);" +
                                                           "if ( avatarGuid != '')" +
                                                           "{" +
                                                           "hidden = document.getElementById('" + hiddenAvatarGuid.ClientID + "');" +
                                                           "hidden.value = avatarGuid ;" +
                                                           "div = document.getElementById('" + divId + "');" +
                                                           "div.style.display='';" +
                                                           "div.innerHTML = '<img src=\"" + getAvatarPath + "?avatarguid=" + "'+ avatarGuid + '" + sizeParams + "\" />" +
                                                           "&#13;&#10;&nbsp;<img src=\"" + btnDeleteImage.ImageUrl + "\" border=\"0\" onclick=\"deleteImagePreview(\\'" + hiddenAvatarGuid.ClientID + "\\',\\'" + divId + "\\')\" style=\"cursor:pointer\"/>';" +
                                                           "placeholder = document.getElementById('" + plcImageActions.ClientID + "');" +
                                                           "if ( placeholder != null)" +
                                                           "{" +
                                                           "placeholder.style.display='none';" +
                                                           "}" +
                                                           "}" +
                                                           "}" +
                                                           "}");

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), ClientID + "updateHidden", updateHiddenScript);

        // Javascript which deletes image preview
        string deleteImagePreviewScript = ScriptHelper.GetScript("function deleteImagePreview(hiddenId, divId)" +
                                                                 "{" +
                                                                 "if( confirm(" + ScriptHelper.GetString(GetString("myprofile.pictdeleteconfirm")) + "))" +
                                                                 "{" +
                                                                 "hidden = document.getElementById(hiddenId);" +
                                                                 "hidden.value = '' ;" +
                                                                 "div = document.getElementById(divId);" +
                                                                 "div.style.display='none';" +
                                                                 "div.innerHTML = ''; " +
                                                                 "}" +
                                                                 "}");

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "deleteImagePreviewScript", deleteImagePreviewScript);

        // Javascript which pseudo deletes avatar
        string deleteAvatarScript = ScriptHelper.GetScript("function deleteAvatar(hiddenDeleteId, hiddenGuidId, placeholderId)" +
                                                           "{" +
                                                           "if( confirm(" + ScriptHelper.GetString(GetString("myprofile.pictdeleteconfirm")) + "))" +
                                                           "{" +
                                                           "hidden = document.getElementById(hiddenDeleteId);" +
                                                           "hidden.value = 'true' ;" +
                                                           "placeholder = document.getElementById(placeholderId);" +
                                                           "placeholder.style.display='none';" +
                                                           "hidden = document.getElementById(hiddenGuidId);" +
                                                           "hidden.value = '' ;" +
                                                           "}" +
                                                           "return false; " +
                                                           "}");

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "deleteAvatar", deleteAvatarScript);

        // Try to load avatar
        if ((GroupInfo == null) && (!RequestHelper.IsPostBack()))
        {
            if (avatarID != 0)
            {
                plcImageActions.Visible = true;
                picGroup.AvatarID       = avatarID;
            }
        }
    }
Beispiel #25
0
    protected object grid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        DataRowView drv = null;

        if (parameter is DataRowView)
        {
            drv = (DataRowView)parameter;
        }
        else if (parameter is GridViewRow)
        {
            drv = (DataRowView)((GridViewRow)parameter).DataItem;
        }

        var objectSettingsId = ValidationHelper.GetInteger(drv["ObjectSettingsID"], 0);

        if ((tmpObjectSettings == null) || (tmpObjectSettings.ObjectSettingsID != objectSettingsId))
        {
            tmpObjectSettings = ObjectSettingsInfoProvider.GetObjectSettingsInfo(objectSettingsId);
            tmpInfo           = CMSObjectHelper.GetObjectById(tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID);
        }

        contextResolver.SetNamedSourceData("EditedObject", tmpInfo);

        switch (sourceName.ToLowerCSafe())
        {
        case "edit":
            var editButton = (CMSImageButton)sender;

            var url = tmpInfo.Generalized.GetEditingPageURL();

            if (!string.IsNullOrEmpty(url))
            {
                url = contextResolver.ResolveMacros(url);
                url = CMSContext.ResolveDialogUrl(url);

                var queryString = URLHelper.GetQuery(url);
                url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(queryString));

                editButton.OnClientClick = string.Format("modalDialog('{0}', 'objectEdit', '85%', '85%');", url);
            }
            else
            {
                editButton.Enabled = false;
            }
            break;

        case "checkin":
            var checkinButton = (CMSImageButton)sender;

            checkinButton.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/checkin.png");

            if (tmpInfo.TypeInfo.SupportsLocking)
            {
                checkinButton.Attributes["onclick"] = GetConfirmScript(GetString("ObjectEditMenu.CheckInConfirmation"), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnCheckIn);
            }
            else
            {
                checkinButton.Enabled = false;
            }
            break;

        case "undocheckout":
            var undoCheckoutButton = (CMSImageButton)sender;

            undoCheckoutButton.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/16/undocheckout.png");

            if (tmpInfo.TypeInfo.SupportsLocking)
            {
                undoCheckoutButton.Attributes["onclick"] = GetConfirmScript(CMSObjectManager.GetUndoCheckOutConfirmation(tmpInfo, null), tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID, btnUndoCheckOut);
            }
            else
            {
                undoCheckoutButton.Enabled = false;
            }
            break;
        }

        return(parameter);
    }
Beispiel #26
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            lblWf.Visible = (lblWf.Text != string.Empty);

            // Ensure uploader button
            plcUploader.Visible         = Enabled;
            plcUploaderDisabled.Visible = !Enabled;

            // Hide actions
            gridAttachments.GridView.Columns[0].Visible = !HideActions;
            gridAttachments.GridView.Columns[1].Visible = !HideActions;
            newAttachmentElem.Visible   = !HideActions && Enabled;
            plcUploaderDisabled.Visible = !HideActions && !Enabled;

            if (!RequestHelper.IsPostBack())
            {
                // Hide filter
                if ((FilterLimit > 0) && (gridAttachments.RowsCount <= FilterLimit))
                {
                    pnlFilter.Visible = false;
                }
                else
                {
                    pnlFilter.Visible = true;
                }
            }

            // Ensure correct layout
            bool gridHasData = !DataHelper.DataSourceIsEmpty(gridAttachments.DataSource);
            Visible = !HideActions || pnlFilter.Visible;

            lblNoData.Visible = (!gridHasData && pnlFilter.Visible);

            // Dialog for editing attachment
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(String.Format(@"
function Edit_{0}(attachmentGUID, formGUID, versionHistoryID, parentId, hash, image) {{ 
  var form = '';
  if (formGUID != '') {{ 
      form = '&formguid=' + formGUID + '&parentid=' + parentId; 
  }}
  {1}
  if (image) {{
      modalDialog('{2}, 'editorDialog', 905, 670); 
  }}
  else {{
      modalDialog('{3}, 'editorDialog', 500, 350); 
  }}
  return false; 
}}",
                                        ClientID,
                                        (((Node != null) ? String.Format("else{{ form = '&siteid=' + {0}; }}", Node.NodeSiteID) : string.Empty)),
                                        ResolveUrl((IsLiveSite ? "~/CMSFormControls/LiveSelectors/ImageEditor.aspx" : "~/CMSModules/Content/CMSDesk/Edit/ImageEditor.aspx") + "?attachmentGUID=' + attachmentGUID + '&versionHistoryID=' + versionHistoryID + form + '&clientid=" + ClientID + "&refresh=1&hash=' + hash"),
                                        CMSContext.ResolveDialogUrl(String.Format("{0}?attachmentGUID=' + attachmentGUID + '&versionHistoryID=' + versionHistoryID + form + '&clientid={1}&refresh=1&hash=' + hash", (IsLiveSite ? "~/CMSModules/Content/Attachments/CMSPages/MetaDataEditor.aspx" : "~/CMSModules/Content/Attachments/Dialogs/MetaDataEditor.aspx"), ClientID))));

            // Register script for editing attachment
            ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "AttachmentEditScripts_" + ClientID, ScriptHelper.GetScript(sb.ToString()));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!StopProcessing)
        {
            string script = "function displayRequest_" + ClientID + "(){ \n" + "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Friends/CMSPages/Friends_Request.aspx") + "?userid=" + UserID + "&requestid= " + RequestedUserID + "' ,'requestFriend', 480, 350); \n} \n";

            ScriptHelper.RegisterStartupScript(this, GetType(), "displayModalRequest_" + ClientID, ScriptHelper.GetScript(script));
            ScriptHelper.RegisterDialogScript(this.Page);

            lnkFriendsRequest.Attributes.Add("onclick", "javascript:displayRequest_" + ClientID + "();");
            lnkFriendsRequest.Style.Add("cursor", "pointer");
            lnkFriendsRequest.Text = LinkText;
        }
    }
Beispiel #28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!CMSContext.CurrentUser.IsAuthorizedPerUIElement("CMS.Ecommerce", "Customers.General"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Ecommerce", "Customers.General");
        }

        // Figure out if site allows using global discount levels
        allowGlobalDiscountLevels = ECommerceSettings.AllowGlobalDiscountLevels(CMSContext.CurrentSiteName);

        this.pnlGeneral.GroupingText  = GetString("com.customeredit.general");
        this.pnlContacts.GroupingText = GetString("com.customeredit.contacts");
        this.pnlUserInfo.GroupingText = GetString("com.customeredit.userinfo");

        chkHasLogin.Text          = GetString("Customer_Edit_Login_Edit.lblHasLogin");
        rqvUserName.ErrorMessage  = GetString("Customer_Edit_Login_Edit.rqvUserName");
        rqvPassword2.ErrorMessage = GetString("Customer_Edit_Login_Edit.rqvPassword2");

        // Control initializations
        lblPassword1.Text = GetString("Customer_Edit_Login_Edit.lblPassword1");
        lblPassword2.Text = GetString("Customer_Edit_Login_Edit.lblPassword2");

        btnEditUser.Text = GetString("general.edit");

        // Init controls
        btnOk.Text = GetString("General.OK");
        lblCustomerLastName.Text                = GetString("Customers_Edit.CustomerLastNameLabel");
        lblCustomerFirstName.Text               = GetString("Customers_Edit.CustomerFirstNameLabel");
        lblCustomerCompany.Text                 = GetString("Customers_Edit.CustomerCompanyLabel");
        lblCustomerFax.Text                     = GetString("customers_edit.CustomerFax");
        lblCustomerPhone.Text                   = GetString("customers_edit.CustomerPhone");
        lblCustomerPreferredCurrency.Text       = GetString("customers_edit.CustomerCurrency");
        lblCustomerPreferredShippingOption.Text = GetString("customers_edit.CustomerShipping");
        lblCustomerPrefferedPaymentOption.Text  = GetString("customers_edit.CustomerPayment");
        lblCustomerEmail.Text                   = GetString("general.email");
        lblCustomerCountry.Text                 = GetString("Customers_Edit.CustomerCountry");
        lblTaxRegistrationID.Text               = GetString("Customers_Edit.lblTaxRegistrationID");
        lblOrganizationID.Text                  = GetString("Customers_Edit.lblOrganizationID");
        lblCustomerGlobalDiscountLevel.Text     = GetString("Customers_Edit.lblCustomerGlobalDiscountLevel");
        lblCustomerDiscountLevel.Text           = GetString("Customers_Edit.lblCustomerDiscountLevel");

        string emptyRecordText = GetString(allowGlobalDiscountLevels ? "general.UseGlobal" : "general.empty");

        drpDiscountLevel.SpecialFields = new string[, ] {
            { emptyRecordText, "0" }
        };

        // Init current site id
        currentSiteId = CMSContext.CurrentSiteID;

        customerid = QueryHelper.GetInteger("customerid", 0);
        if (customerid > 0)
        {
            customerObj = CustomerInfoProvider.GetCustomerInfo(customerid);
            // Check if customer belongs to current site
            if (!CheckCustomerSiteID(customerObj))
            {
                customerObj = null;
            }

            EditedObject = customerObj;

            if (customerObj != null)
            {
                // Display site discount level only for reistered customers
                plcSiteDiscount.Visible = customerObj.CustomerIsRegistered;
                if (customerObj.CustomerIsRegistered)
                {
                    UserInfo ui = UserInfoProvider.GetUserInfo(customerObj.CustomerUserID);
                    if (ui != null)
                    {
                        pnlEdit.Visible             = false;
                        pnlStatic.Visible           = true;
                        lblUserNameStaticValue.Text = HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(ui.UserName));
                        btnEditUser.OnClientClick   = "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Membership/Pages/Users/User_Edit_Frameset.aspx") + "?userid=" + customerObj.CustomerUserID + "&siteId=" + ConfiguredSiteID + "', 'UserEdit', 950, 700); return false;";
                    }

                    // Hide global discount level selector when global levels not allowed
                    plcGlobalDiscount.Visible = allowGlobalDiscountLevels;
                }
                else
                {
                    plcDiscounts.Visible   = false;
                    plcPreferences.Visible = false;
                    pnlEdit.Visible        = true;
                    pnlStatic.Visible      = false;
                }

                // Fill editing form
                if (!RequestHelper.IsPostBack())
                {
                    // Fill form
                    txtCustomerCompany.Text    = customerObj.CustomerCompany;
                    txtCustomerEmail.Text      = customerObj.CustomerEmail;
                    txtCustomerFax.Text        = customerObj.CustomerFax;
                    txtCustomerFirstName.Text  = customerObj.CustomerFirstName;
                    txtCustomerLastName.Text   = customerObj.CustomerLastName;
                    txtCustomerPhone.Text      = customerObj.CustomerPhone;
                    txtOraganizationID.Text    = customerObj.CustomerOrganizationID;
                    txtTaxRegistrationID.Text  = customerObj.CustomerTaxRegistrationID;
                    chkCustomerEnabled.Checked = customerObj.CustomerEnabled;

                    if (customerObj.CustomerCountryID > 0)
                    {
                        drpCountry.CountryID = customerObj.CustomerCountryID;
                    }
                    if (customerObj.CustomerStateID > 0)
                    {
                        drpCountry.StateID = customerObj.CustomerStateID;
                    }

                    // show that the customer was created or updated successfully
                    if (QueryHelper.GetString("saved", "") == "1")
                    {
                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");

                        int hideBreadcrumbs = QueryHelper.GetInteger("hidebreadcrumbs", 0);
                        if (hideBreadcrumbs > 0)
                        {
                            // Refresh the parent page when called from Orders section
                            string javaScript = @"if(window.parent.wopener != null)
                                                  {{
                                                        window.parent.wopener.location.replace(window.parent.wopener.location);
                                                  }}";
                            ScriptHelper.RegisterClientScriptBlock(this.Page, typeof(string), "RefreshParentScript", ScriptHelper.GetScript(javaScript));
                        }
                    }
                }
            }

            LoadDataSelectors(customerObj);
        }

        chkHasLogin.Attributes["onclick"] = "ShowHideLoginControls()";

        // Register script to show / hide SKU controls
        string script = @"
function ShowHideLoginControls() {{ 
   checkbox = document.getElementById('" + this.chkHasLogin.ClientID + @"');
   line1 = document.getElementById('loginLine1');
   line2 = document.getElementById('loginLine2');
   line3 = document.getElementById('loginLine3');
   if ((checkbox != null) && (checkbox.checked)) {{
       line1.style.display = '';
       line2.style.display = '';
       line3.style.display = '';
   }} else {{
       line1.style.display = 'none';
       line2.style.display = 'none';
       line3.style.display = 'none';
   }}
}}";

        this.ltlScript.Text = ScriptHelper.GetScript(script);

        if (pnlEdit.Visible)
        {
            this.ltlScript.Text += ScriptHelper.GetScript("ShowHideLoginControls()");
        }

        if (QueryHelper.GetBoolean("refreshHeader", false))
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("if (window.parent.frames['CustomerHeader'] != null) {");
            sb.Append("var loc = window.parent.frames['CustomerHeader'].location; if(!(/onlyRefresh=1/.test(loc))) {loc += '&onlyRefresh=1';} window.parent.frames['CustomerHeader'].location.replace(loc);");
            sb.Append("}");
            ScriptHelper.RegisterStartupScript(this, typeof(string), "RefreshHeaderScript", sb.ToString(), true);
        }
    }
Beispiel #29
0
    /// <summary>
    /// Saves data to DB without validation and permissions check.
    /// </summary>
    private void SaveData()
    {
        // If customer does not already exist, create new one
        if (Customer == null)
        {
            Customer = new CustomerInfo();
            Customer.CustomerSiteID  = currentSiteId;
            Customer.CustomerEnabled = true;
        }

        Customer.CustomerEmail             = txtCustomerEmail.Text.Trim().Truncate(100);
        Customer.CustomerFax               = txtCustomerFax.Text.Trim();
        Customer.CustomerLastName          = txtCustomerLastName.Text.Trim();
        Customer.CustomerPhone             = txtCustomerPhone.Text.Trim();
        Customer.CustomerFirstName         = txtCustomerFirstName.Text.Trim();
        Customer.CustomerCompany           = txtCustomerCompany.Text.Trim();
        Customer.CustomerCountryID         = drpCountry.CountryID;
        Customer.CustomerStateID           = drpCountry.StateID;
        Customer.CustomerOrganizationID    = txtOraganizationID.Text.Trim();
        Customer.CustomerTaxRegistrationID = txtTaxRegistrationID.Text.Trim();

        // Set customer's preferences
        Customer.CustomerPreferredCurrencyID       = drpCurrency.CurrencyID;
        Customer.CustomerPreferredPaymentOptionID  = drpPayment.PaymentID;
        Customer.CustomerPreferredShippingOptionID = drpShipping.ShippingID;

        if (plcDiscounts.Visible && plcGlobalDiscount.Visible)
        {
            Customer.CustomerDiscountLevelID = drpGlobalDiscountLevel.DiscountLevel;
        }

        // Only registered customer can be enabled/disabled
        if (Customer.CustomerIsRegistered)
        {
            Customer.CustomerEnabled = chkCustomerEnabled.Checked;
        }

        using (CMSTransactionScope tr = new CMSTransactionScope())
        {
            bool newUserCreated = false;

            // Create user for customer
            if (chkHasLogin.Checked)
            {
                UserInfo ui = new UserInfo();
                ui.UserName = txtUserName.Text.Trim();
                ui.FullName = Customer.CustomerFirstName + " " + Customer.CustomerLastName;
                ui.IsGlobalAdministrator = false;
                ui.UserEnabled           = true;

                UserInfoProvider.SetPassword(ui, passStrength.Text);
                UserInfoProvider.AddUserToSite(ui.UserName, CMSContext.CurrentSiteName);

                Customer.CustomerEnabled = true;
                Customer.CustomerUserID  = ui.UserID;

                chkCustomerEnabled.Checked = Customer.CustomerEnabled;

                newUserCreated = true;

                // Show fields requiring registered customer
                pnlEdit.Visible             = false;
                pnlStatic.Visible           = true;
                plcDiscounts.Visible        = true;
                plcPreferences.Visible      = true;
                chkHasLogin.Checked         = false;
                plcSiteDiscount.Visible     = true;
                lblUserNameStaticValue.Text = HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(ui.UserName));
                if (AllowEditUser)
                {
                    btnEditUser.OnClientClick = "modalDialog('" + CMSContext.ResolveDialogUrl("~/CMSModules/Membership/Pages/Users/User_Edit_Frameset.aspx") + "?userid=" + Customer.CustomerUserID + "', 'UserEdit', 950, 700); return false;";
                    btnEditUser.Visible       = true;
                }

                // Hide global discount level selector when global levels not allowed
                plcGlobalDiscount.Visible = allowGlobalDiscountLevels;
            }

            // Save customer
            CustomerInfoProvider.SetCustomerInfo(Customer);

            // Enable/disable corresponding registered user
            if (Customer.CustomerIsRegistered && !newUserCreated)
            {
                UserInfo ui = UserInfoProvider.GetUserInfo(Customer.CustomerUserID);

                // If the customer already has the record in the CMS_User table, update email
                if (ui != null)
                {
                    ui.Email = Customer.CustomerEmail;
                    UserInfoProvider.SetUserInfo(ui);
                }

                // Save site specific values
                UserSiteInfo userSite = UserSiteInfoProvider.GetUserSiteInfo(Customer.CustomerUserID, currentSiteId);
                if (userSite != null)
                {
                    userSite.UserPreferredCurrencyID       = drpCurrency.CurrencyID;
                    userSite.UserPreferredPaymentOptionID  = drpPayment.PaymentID;
                    userSite.UserPreferredShippingOptionID = drpShipping.ShippingID;
                    userSite.UserDiscountLevelID           = drpDiscountLevel.DiscountLevel;

                    UserSiteInfoProvider.SetUserSiteInfo(userSite);
                }
            }

            // Commit transaction
            tr.Commit();

            // Raise OnSaved event
            RaiseOnSaved();
        }
    }
Beispiel #30
0
    protected object gridLanguages_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        TranslationStatusEnum status = TranslationStatusEnum.NotAvailable;
        DataRowView           drv    = null;

        sourceName = sourceName.ToLowerCSafe();

        if (currentUserInfo == null)
        {
            currentUserInfo = CMSContext.CurrentUser;
        }
        if (currentSiteInfo == null)
        {
            currentSiteInfo = CMSContext.CurrentSite;
        }

        switch (sourceName)
        {
        case "translate":
        case "action":
            ImageButton img = sender as CMSImageButton;
            if (img != null)
            {
                if ((sourceName == "translate") &&
                    (!CMS.TranslationServices.TranslationServiceHelper.AnyServiceAvailable(CurrentSiteName) ||
                     !CMS.TranslationServices.TranslationServiceHelper.IsTranslationAllowed(CurrentSiteName)))
                {
                    img.Visible = false;
                    return(img);
                }

                GridViewRow gvr = parameter as GridViewRow;
                if (gvr != null)
                {
                    // Get datarowview
                    drv = gvr.DataItem as DataRowView;

                    if ((drv != null) && (drv.Row["TranslationStatus"] != DBNull.Value))
                    {
                        // Get translation status
                        status = (TranslationStatusEnum)drv.Row["TranslationStatus"];
                    }
                    else
                    {
                        status = TranslationStatusEnum.NotAvailable;
                    }

                    string culture = (drv != null) ? ValidationHelper.GetString(drv.Row["DocumentCulture"], string.Empty) : string.Empty;

                    // Set appropriate icon
                    if (sourceName == "action")
                    {
                        switch (status)
                        {
                        case TranslationStatusEnum.NotAvailable:
                            img.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/addculture.png");
                            img.ToolTip  = GetString("transman.createnewculture");
                            break;

                        default:
                            img.ImageUrl = GetImageUrl("CMSModules/CMS_Content/Properties/editculture.png");
                            img.ToolTip  = GetString("transman.editculture");
                            break;
                        }

                        // Register redirect script
                        if (RequiresDialog)
                        {
                            if ((sourceName == "action") && (status == TranslationStatusEnum.NotAvailable))
                            {
                                // New culture version
                                img.OnClientClick = "parent.parent.parent.NewDocumentCulture(" + NodeID + ",'" + culture + "');";
                            }
                            else
                            {
                                // Existing culture version
                                ScriptHelper.RegisterWOpenerScript(Page);
                                string url = ResolveUrl(CMSContext.GetUrl(Node.NodeAliasPath, Node.DocumentUrlPath, currentSiteInfo.SiteName));
                                url = URLHelper.AppendQuery(url, "lang=" + culture);
                                img.OnClientClick = "window.refreshPageOnClose = true; window.reloadPageUrl = " + ScriptHelper.GetString(url) + "; if (wopener.RefreshWOpener) { wopener.RefreshWOpener(window); } CloseDialog();";
                            }
                        }
                        else
                        {
                            img.OnClientClick = "RedirectItem(" + NodeID + ", '" + culture + "');";
                        }

                        img.ID = "imgAction";
                    }
                    else
                    {
                        // Add parameters identifier and hash, encode query string
                        if (LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.TranslationServices))
                        {
                            string returnUrl = CMSContext.ResolveDialogUrl("~/CMSModules/Translations/Pages/TranslateDocuments.aspx") + "?targetculture=" + culture + "&modal=1&nodeid=" + NodeID;
                            returnUrl = URLHelper.AddParameterToUrl(returnUrl, "hash", QueryHelper.GetHash(URLHelper.GetQuery(returnUrl)));

                            img.ImageUrl      = GetImageUrl("CMSModules/CMS_Content/Properties/translate.png");
                            img.ToolTip       = GetString("transman.translate");
                            img.OnClientClick = "modalDialog('" + returnUrl + "', 'TranslateDocument', 550, 440); ";
                        }
                        else
                        {
                            img.Visible = false;
                        }
                        break;
                    }
                }
            }
            return(img);

        case "translationstatus":
            if (parameter == DBNull.Value)
            {
                status = TranslationStatusEnum.NotAvailable;
            }
            else
            {
                status = (TranslationStatusEnum)parameter;
            }
            string statusName = GetString("transman." + status);
            string statusHtml = "<span class=\"" + status + "\">" + statusName + "</span>";
            // .Outdated
            return(statusHtml);

        case "documentculturedisplayname":
            drv = (DataRowView)parameter;
            // Add icon
            return(UniGridFunctions.DocumentCultureFlag(drv, Page));

        case "documentmodifiedwhen":
        case "documentmodifiedwhentooltip":
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                return("-");
            }
            else
            {
                DateTime modifiedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME);
                bool     displayGMT   = (sourceName == "documentmodifiedwhentooltip");
                return(TimeZoneHelper.ConvertToUserTimeZone(modifiedWhen, displayGMT, currentUserInfo, currentSiteInfo));
            }

        case "versionnumber":
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                return("-");
            }
            break;

        case "documentname":
            if (string.IsNullOrEmpty(parameter.ToString()))
            {
                parameter = "-";
            }
            return(HTMLHelper.HTMLEncode(parameter.ToString()));

        case "published":
            bool published = ValidationHelper.GetBoolean(parameter, false);
            if (published)
            {
                return("<span class=\"DocumentPublishedYes\">" + GetString("General.Yes") + "</span>");
            }
            else
            {
                return("<span class=\"DocumentPublishedNo\">" + GetString("General.No") + "</span>");
            }
        }
        return(parameter);
    }