Example #1
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (!StopProcessing)
        {
            plcError.Visible = false;

            // Check renamed DLL library
            if (!SystemContext.IsFullTrustLevel)
            {
                // Error label is displayed when OpenID library is not enabled
                lblError.ResourceString = "socialnetworking.fulltrustrequired";
                plcError.Visible        = true;
                plcContent.Visible      = false;
            }

            // Check if LinkedIn module is enabled
            if (!LinkedInHelper.LinkedInIsAvailable(SiteContext.CurrentSiteName) && !plcError.Visible)
            {
                // Error label is displayed only in Design mode
                if (PortalContext.IsDesignMode(PortalContext.ViewMode))
                {
                    StringBuilder parameter = new StringBuilder();
                    parameter.Append(UIElementInfoProvider.GetApplicationNavigationString("cms", "Settings") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsmembership") + " -> ");
                    parameter.Append(GetString("settingscategory.cmsmembershipauthentication") + " -> ");
                    parameter.Append(GetString("settingscategory.cmslinkedin"));
                    if (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin))
                    {
                        // Make it link for Admin
                        parameter.Insert(0, "<a href=\"" + URLHelper.GetAbsoluteUrl(ApplicationUrlHelper.GetApplicationUrl("cms", "settings")) + "\" target=\"_top\">");
                        parameter.Append("</a>");
                    }

                    lblError.Text      = String.Format(GetString("mem.linkedin.disabled"), parameter);
                    plcError.Visible   = true;
                    plcContent.Visible = false;
                }
                // In other modes is web part hidden
                else
                {
                    Visible = false;
                }
            }

            // Display web part when no error occurred
            if (!plcError.Visible && Visible)
            {
                // Hide web part if user is authenticated
                if (AuthenticationHelper.IsAuthenticated())
                {
                    Visible = false;
                    return;
                }

                plcPasswordNew.Visible  = AllowFormsAuthentication;
                pnlExistingUser.Visible = AllowExistingUser;

                // Load LinkedIn data from session
                linkedInHelper = new LinkedInHelper();
                string linkedInData = ValidationHelper.GetString(SessionHelper.GetValue(SESSION_NAME_USERDATA), string.Empty);
                if (!string.IsNullOrEmpty(linkedInData))
                {
                    var doc = new XmlDocument();
                    doc.LoadXml(linkedInData);
                    linkedInHelper.Initialize(doc);
                }

                // There is no LinkedIn user ID stored in session - hide all
                if (string.IsNullOrEmpty(linkedInHelper.MemberId) && HideForNoLinkedInUserID)
                {
                    Visible = false;
                }
                else if (!RequestHelper.IsPostBack())
                {
                    LoadData();
                }
            }
        }
        else
        {
            Visible = false;
        }
    }
    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);
            if (tmpObjectSettings != null)
            {
                tmpInfo = ProviderHelper.GetInfoById(tmpObjectSettings.ObjectSettingsObjectType, tmpObjectSettings.ObjectSettingsObjectID);
            }
        }

        if ((tmpInfo != null) && (tmpObjectSettings != null))
        {
            contextResolver.SetNamedSourceData("EditedObject", tmpInfo);

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

                var url = tmpInfo.Generalized.GetEditingPageURL();

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

                    // Resolve dialog relative url
                    if (url.StartsWith("~/", StringComparison.Ordinal))
                    {
                        url = ApplicationUrlHelper.ResolveDialogUrl(url);
                    }

                    string queryString = URLHelper.GetQuery(url);
                    if (queryString.IndexOfCSafe("&hash=", true) < 0)
                    {
                        url = URLHelper.AddParameterToUrl(url, "hash", QueryHelper.GetHash(queryString));
                    }

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

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

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

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

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

        return(parameter);
    }
    /// <summary>
    /// Sets buttons actions.
    /// </summary>
    protected void Initialize()
    {
        ScriptHelper.RegisterDialogScript(Page);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "GetSelectedItem" + ItemType, ScriptHelper.GetScript(@"
            function getSelectedItem_" + ItemType + @"() { 
				if (document.getElementById('"                 + brsItems.UniSelectorClientID + @"') != null) {
					return document.getElementById('"                     + brsItems.UniSelectorClientID + @"').value;
				}
				return 0;
			}

            function DeleteItem_" + ItemType + @"() {
				if ((document.getElementById('"                 + brsItems.UniSelectorClientID + @"') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + @"').value != '0')) {
					if (confirm("                     + ScriptHelper.GetLocalizedString("general.confirmdelete") + @")) {
						document.getElementById('"                         + hdnItemId.ClientID + @"').value = getSelectedItem_" + ItemType + @"(); 
						"                         + Page.ClientScript.GetPostBackEventReference(btnHdnDelete, null) + @" 
					}
				} else { 
					alert("                     + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + @"); 
				}
			}

            function InserMacro_" + ItemType + @"() {
				if ((document.getElementById('"                 + brsItems.UniSelectorClientID + @"') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + @"').value != '0')) {
					PageMethods.GetReportItemName('"                     + ReportInfoProvider.ReportItemTypeToString(ItemType) + "',getSelectedItem_" + ItemType + "(),OnComplete_" + ItemType + @");
				} else { 
					alert("                     + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + @"); 
				}
            }

			function OnComplete_"             + ItemType + @"(result, response, context) {
				InsertHTML('%%control:Report"                 + ItemType + "?" + Report.ReportName + @".' + result +'%%');
            }

            function CloneItem_" + ItemType + @"(id) {
				if ((document.getElementById('"                 + brsItems.UniSelectorClientID + @"') != null) && (document.getElementById('" + brsItems.UniSelectorClientID + @"').value != '0')) { 
					modalDialog('"                     + UrlResolver.ResolveUrl("~/CMSModules/Objects/Dialogs/CloneObjectDialog.aspx?objectType=" + GetObjectType() + @"&objectId=' + id") + @", 'CloneObject', 750, 470);
				} else { 
					alert("                     + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + @"); 
				}
            }"));


        const string MODAL_HEIGHT = "'85%'";
        const string MODAL_WIDTH  = "950";


        if (Report != null)
        {
            string baseUrl = URLHelper.AddParameterToUrl(ResolveUrl(EditUrl), "reportId", Report.ReportID.ToString());
            string fullUrl = ApplicationUrlHelper.AppendDialogHash(baseUrl);

            btnAdd.Actions.Add(new CMSButtonAction()
            {
                OnClientClick = "modalDialog('" + fullUrl + "','ReportItemEdit'," + MODAL_WIDTH + "," + MODAL_HEIGHT + ");return false;",
                Text          = GetString("general.new")
            });

            fullUrl = URLHelper.AddParameterToUrl(baseUrl, "preview", "true");
            fullUrl = ApplicationUrlHelper.AppendDialogHash(fullUrl);

            btnAdd.Actions.Add(new CMSButtonAction()
            {
                OnClientClick = "if (getSelectedItem_" + ItemType + "() != '0') { modalDialog('" + fullUrl + "&objectid='+ getSelectedItem_" + ItemType + "(),'ReportItemEdit'," + MODAL_WIDTH + "," + MODAL_HEIGHT + "); } else { alert(" + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + ");} return false;",
                Text          = GetString("general.preview")
            });

            fullUrl = ApplicationUrlHelper.AppendDialogHash(baseUrl);

            btnAdd.Actions.Add(new CMSButtonAction()
            {
                OnClientClick = "if (getSelectedItem_" + ItemType + "() != '0') { modalDialog('" + fullUrl + "&objectid='+ getSelectedItem_" + ItemType + "(),'ReportItemEdit'," + MODAL_WIDTH + "," + MODAL_HEIGHT + "); } else { alert(" + ScriptHelper.GetLocalizedString("Reporting_General.SelectObjectFirst") + ");} return false;",
                Text          = GetString("general.edit")
            });

            btnAdd.Actions.Add(new CMSButtonAction()
            {
                OnClientClick = "DeleteItem_" + ItemType + "(); return false;",
                Text          = GetString("general.delete")
            });

            btnAdd.Actions.Add(new CMSButtonAction()
            {
                OnClientClick = "CloneItem_" + ItemType + @"(getSelectedItem_" + ItemType + "()); return false;",
                Text          = GetString("general.clone")
            });

            btnInsert.OnClientClick = "InserMacro_" + ItemType + "(); return false;";
        }
    }
    /// <summary>
    /// Registers helper scripts.
    /// </summary>
    private void RegisterScripts()
    {
        // Register dialog script
        string resolvedAvatarsPage;

        if (IsLiveSite)
        {
            resolvedAvatarsPage = ApplicationUrlHelper.ResolveDialogUrl(AuthenticationHelper.IsAuthenticated() ? "~/CMSModules/Avatars/CMSPages/AvatarsGallery.aspx" : "~/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', 680, 270); return false;}"));
        ltlScript.Text = ScriptHelper.GetScript("function UpdateForm(){ ; } \n");

        // Setup btnShowGallery action
        btnShowGallery.Attributes.Add("onclick", "SelectAvatar('" + AvatarInfoProvider.GetAvatarTypeString(AvatarTypeEnum.Group) + "', '" + 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;
        }

        string getAvatarPath = ResolveUrl("~/CMSPages/GetAvatar.aspx");

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

        // Javascript which creates selected image preview and saves image guid  to hidden field
        StringBuilder sbScript = new StringBuilder();

        sbScript.Append(@"
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';
            }
        } 
    }
}");
        ControlsHelper.RegisterClientScriptBlock(this, Page, typeof(string), ClientID + "updateHidden", ScriptHelper.GetScript(sbScript.ToString()));
        sbScript.Clear();

        sbScript.Append(@"
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 = '';
    }
}");
        // JavaScript which deletes image preview
        ControlsHelper.RegisterClientScriptBlock(this, Page, typeof(string), "deleteImagePreviewScript", ScriptHelper.GetScript(sbScript.ToString()));
        sbScript.Clear();

        sbScript.Append(@"
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;
}");
        // JavaScript which pseudo deletes avatar
        ControlsHelper.RegisterClientScriptBlock(this, Page, typeof(string), "deleteAvatar", ScriptHelper.GetScript(sbScript.ToString()));
    }
Example #5
0
    protected object gridLanguages_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        TranslationStatusEnum status;
        DataRowView           drv;

        sourceName = sourceName.ToLowerCSafe();

        if (currentUserInfo == null)
        {
            currentUserInfo = MembershipContext.AuthenticatedUser;
        }
        if (currentSiteInfo == null)
        {
            currentSiteInfo = SiteContext.CurrentSite;
        }

        switch (sourceName)
        {
        case "translate":
        case "action":
            CMSGridActionButton img = sender as CMSGridActionButton;
            if (img != null)
            {
                if ((sourceName == "translate") && !TranslationEnabled)
                {
                    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.IconCssClass = "icon-plus";
                            img.IconStyle    = GridIconStyle.Allow;
                            img.ToolTip      = GetString("transman.createnewculture");
                            break;

                        default:
                            img.IconCssClass = "icon-edit";
                            img.IconStyle    = GridIconStyle.Allow;
                            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);
                                var url = ResolveUrl(DocumentURLProvider.GetUrl(Node));
                                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(RequestContext.CurrentDomain, FeatureEnum.TranslationServices))
                        {
                            string returnUrl = ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Translations/Pages/TranslateDocuments.aspx") + "?targetculture=" + culture + "&dialog=1&nodeid=" + NodeID;
                            returnUrl = URLHelper.AddParameterToUrl(returnUrl, "hash", QueryHelper.GetHash(URLHelper.GetQuery(returnUrl)));

                            img.ToolTip       = GetString("transman.translate");
                            img.OnClientClick = "modalDialog('" + returnUrl + "', 'TranslateDocument', 988, 634); ";
                        }
                        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>";
            return(statusHtml);

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

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

            if (sourceName.EqualsCSafe("documentmodifiedwhen", StringComparison.InvariantCultureIgnoreCase))
            {
                DateTime modifiedWhen = ValidationHelper.GetDateTime(parameter, DateTimeHelper.ZERO_TIME);
                return(TimeZoneHelper.ConvertToUserTimeZone(modifiedWhen, true, currentUserInfo, currentSiteInfo));
            }

            return(TimeZoneHelper.GetUTCLongStringOffset(CurrentUser, currentSiteInfo));

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

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

        return(parameter);
    }
Example #6
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            // Initialize properties
            string script = "";

            // Set current user
            currentUser = MembershipContext.AuthenticatedUser;

            // 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;
            lnkInviteToGroup.Text  = InviteGroupText;
            lnkManageGroup.Text    = ManageGroupText;
            lnkMyInvitations.Text  = MyInvitationsText;

            // 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 = MacroResolver.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 && !AuthenticationMode.IsWindowsAuthentication())
                {
                    pnlSignOut.Visible   = true;
                    pnlSignInOut.Visible = true;
                }

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

                // Display My profile link if set so
                if (DisplayMyProfileLink)
                {
                    lnkMyProfile.NavigateUrl = UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(GroupMemberInfoProvider.GetMemberProfilePath(currentUser.UserName, SiteContext.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
                    var entry = ModuleManager.GetModule(ModuleName.BLOGS);
                    if (entry != null)
                    {
                        lnkCreateNewBlog.NavigateUrl = GetUrl(CreateNewBlogPath);
                        pnlCreateNewBlog.Visible     = true;
                        pnlBlogLinks.Visible         = true;
                    }
                }

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

                GroupMemberInfo gmi = null;

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

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

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

                                lnkLeaveGroup.Attributes.Add("onclick", "LeaveTheGroupRequest();return false;");
                                lnkLeaveGroup.NavigateUrl = RequestContext.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.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin))))
                    {
                        lnkManageGroup.NavigateUrl = ResolveUrl(DocumentURLProvider.GetUrl(GroupInfoProvider.GetGroupManagementPath(currentGroup.GroupName, SiteContext.CurrentSiteName)));
                        pnlManageGroup.Visible     = true;
                        pnlGroupLinks.Visible      = true;
                    }
                }

                // Get user info from site context
                UserInfo siteContextUser = MembershipContext.CurrentUserProfile;

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

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

                        if (((gmi != null) && (gmi.MemberStatus == GroupMemberStatus.Approved)) || (MembershipContext.AuthenticatedUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin)))
                        {
                            pnlInviteToGroup.Visible = true;

                            if (String.IsNullOrEmpty(InviteGroupPath))
                            {
                                script += "function InviteToGroup() {\n modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Groups/CMSPages/InviteToGroup.aspx") + "?groupid=" + currentGroup.GroupID + "','inviteToGroup', 800, 450); \n } \n";
                                lnkInviteToGroup.Attributes.Add("onclick", "InviteToGroup();return false;");
                                lnkInviteToGroup.NavigateUrl = RequestContext.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, SiteContext.CurrentSite) != 0))
                    {
                        pnlInviteToGroup.Visible = true;

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

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

            // Register the dialog script
            ScriptHelper.RegisterDialogScript(Page);
        }
    }
Example #7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        gridElem.WhereCondition       = "SubmissionItemSubmissionID = " + SubmissionID;
        gridElem.OnExternalDataBound += gridElem_OnExternalDataBound;

        btnImportFromZip.OnClientClick = "ShowUploadDialog(" + SubmissionID + ", 0);";
        btnExportToZip.OnClientClick   = "window.open('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Translations/CMSPages/DownloadTranslation.aspx?submissionid=" + SubmissionID) + "'); return false;";


        string script = "function ShowUploadDialog(submissionId, submissionItemTd) { modalDialog('" + ApplicationUrlHelper.ResolveDialogUrl("~/CMSModules/Translations/Pages/UploadTranslation.aspx") + "?itemid=' + submissionItemTd + '&submissionid=' + submissionId, 'Upload translation', 500, 225); }";

        ScriptHelper.RegisterClientScriptBlock(Page, typeof(string), "ShowUploadDialog", script, true);
    }
    /// <summary>
    /// Reloads the controls on the page to the appropriate state
    /// </summary>
    protected void ReloadControls()
    {
        node = Node;

        if (node.NodeAliasPath == "/")
        {
            // For root, inherit option means no page template
            radInherit.ResourceString = "Template.NoTemplate";
        }

        // Get the template ID
        int    templateId = SelectedTemplateID;
        string suffix     = null;
        bool   inherit    = radInherit.Checked;

        plcUIClone.Visible = false;
        plcUIEdit.Visible  = false;
        plcUISave.Visible  = false;

        if (inherit)
        {
            // Inherited
            selectorEnabled = false;

            // Inherit
            templateId = GetInheritedPageTemplateId(node);

            if (templateId > 0)
            {
                suffix = " " + GetString("Template.Inherited");
            }
        }
        else
        {
            // Standard selection
            selectorEnabled = true;
        }

        // Set modal dialogs
        string modalScript = String.Format("modalDialog('{0}?startingpath=/&templateId={1}&siteid={2}&documentid={3}&inherits={4}', 'SaveNewTemplate', 720, 430); return false;", ResolveUrl("~/CMSModules/PortalEngine/UI/Layout/SaveNewPageTemplate.aspx"), templateId, SiteContext.CurrentSiteID, Node.DocumentID, radInherit.Checked);

        btnSave.OnClientClick = modalScript;

        String url = ApplicationUrlHelper.GetElementDialogUrl("cms.design", "PageTemplate.EditPageTemplate", templateId, String.Format("aliaspath={0}", node.NodeAliasPath));

        btnEditTemplateProperties.OnClientClick = "modalDialog('" + url + "', 'Template edit', '95%', '95%');return false;";

        // Load the page template name
        pageTemplateInfo = PageTemplateInfoProvider.GetPageTemplateInfo(templateId);
        if (pageTemplateInfo != null)
        {
            txtTemplate.Text = ResHelper.LocalizeString(pageTemplateInfo.DisplayName);

            plcUISave.Visible  = true;
            plcUIEdit.Visible  = (!pageTemplateInfo.IsReusable || currentUser.IsAuthorizedPerUIElement("CMS.Content", "Template.ModifySharedTemplates"));
            plcUIClone.Visible = pageTemplateInfo.IsReusable || inherit;
        }
        else
        {
            txtTemplate.Text = GetString("Template.SelectorNoTemplate");
        }

        txtTemplate.Text += suffix;
    }