Exemple #1
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="sourceName"></param>
    /// <param name="parameter"></param>
    /// <returns></returns>
    object gridElem_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLower())
        {
            case "documentname":
                DataRowView dr = (DataRowView)parameter;

                if (CMSContext.CurrentSite != null)
                {
                    string url = ResolveUrl(TreePathUtils.GetUrl(ValidationHelper.GetString(dr["NodeAliasPath"], ""), null, mSiteName));
                    string lang = ValidationHelper.GetString(dr["DocumentCulture"], "");
                    if (!String.IsNullOrEmpty(lang))
                    {
                        url += "?" + URLHelper.LanguageParameterName + "=" + lang;
                    }

                    return "<a target=\"_blank\" href=\"" + url + "\">" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr["DocumentName"], "")) + "</a>";
                }
                else
                {
                    return HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr["DocumentName"], ""));
                }
        }

        return parameter;
    }
    /// <summary>
    /// Handles the UniGrid's OnExternalDataBound event.
    /// </summary>
    private object boardSubscriptions_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "displayname":
            DataRowView dr   = (DataRowView)parameter;
            string      url  = ResolveUrl(TreePathUtils.GetUrl(ValidationHelper.GetString(dr["NodeAliasPath"], ""), null, mSiteName));
            string      lang = ValidationHelper.GetString(dr["DocumentCulture"], "");
            if (!String.IsNullOrEmpty(lang))
            {
                url += "?" + URLHelper.LanguageParameterName + "=" + lang;
            }

            return("<a target=\"_blank\" href=\"" + url + "\">" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr["BoardDisplayName"], "")) + "</a>");

        case "approved":
            return(UniGridFunctions.ColoredSpanYesNo(parameter, true));

        case "approve":
            ImageButton button = ((ImageButton)sender);
            if (button != null)
            {
                bool isApproved = ValidationHelper.GetBoolean(((DataRowView)((GridViewRow)parameter).DataItem).Row["SubscriptionApproved"], true);

                if (isApproved)
                {
                    button.Visible = false;
                }
            }
            break;
        }

        return(parameter);
    }
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData()
    {
        requestedGroupId = ValidationHelper.GetInteger(ContextMenu.Parameter, 0);

        DataTable table = new DataTable();

        table.Columns.Add("ActionIcon");
        table.Columns.Add("ActionDisplayName");
        table.Columns.Add("ActionScript");

        // Add only if community is present
        if (CommunityPresent)
        {
            // Get resource strings prefix
            string resourcePrefix = ContextMenu.ResourcePrefix;

            // View group profile
            string profileUrl = "";

            // Get group profile URL
            GeneralizedInfo infoObj = ModuleCommands.CommunityGetGroupInfo(requestedGroupId);
            if (infoObj != null)
            {
                profileUrl = ResolveUrl(CMSContext.GetUrl(ModuleCommands.CommunityGetGroupProfilePath(infoObj.ObjectCodeName, CMSContext.CurrentSiteName)));
            }

            table.Rows.Add(new object[] { "groupprofile.png", ResHelper.GetString(resourcePrefix + ".viewgroup|group.viewgroup"), "window.location.replace('" + profileUrl + "');" });
            if (!currentUser.IsGroupMember(requestedGroupId))
            {
                table.Rows.Add(new object[] { "jointhegroup.png", ResHelper.GetString(resourcePrefix + ".joingroup|group.joingroup"), !currentUser.IsPublic() ? "ContextJoinTheGroup(GetContextMenuParameter('" + ContextMenu.MenuID + "'))" : "ContextRedirectToSignInUrl()" });
            }
            else
            {
                table.Rows.Add(new object[] { "leavethegroup.png", ResHelper.GetString(resourcePrefix + ".leavegroup|group.leavegroup"), !currentUser.IsPublic() ? "ContextLeaveTheGroup(GetContextMenuParameter('" + ContextMenu.MenuID + "'))" : "ContextRedirectToSignInUrl()" });
            }

            if (infoObj != null)
            {
                // Display Manage the group link if user is logged as group administrator and user is visiting a group page
                if (currentUser.IsGroupAdministrator(requestedGroupId) || currentUser.IsGlobalAdministrator)
                {
                    string managementUrl = ResolveUrl(TreePathUtils.GetUrl(ModuleCommands.CommunityGetGroupManagementPath(infoObj.ObjectCodeName, CMSContext.CurrentSiteName)));

                    table.Rows.Add(new object[] { "managegroup.png", ResHelper.GetString(resourcePrefix + ".managegroup|group.managegroup"), !currentUser.IsPublic() ? " window.location.replace('" +
                                                  managementUrl + "');" : "ContextRedirectToSignInUrl()" });
                }
            }
        }

        // Add count column
        DataColumn countColumn = new DataColumn();

        countColumn.ColumnName   = "Count";
        countColumn.DefaultValue = table.Rows.Count;

        table.Columns.Add(countColumn);
        repItem.DataSource = table;
        repItem.DataBind();
    }
Exemple #4
0
    /// <summary>
    /// Returns URL of the media item according site settings.
    /// </summary>
    /// <param name="nodeGuid">Node GUID of the current attachment node</param>
    /// <param name="documentUrlPath">URL path of the current attachment document</param>
    /// <param name="maxSideSize">Maximum dimension for images displayed for tile and thumbnails view</param>
    /// <param name="nodeAlias">Node alias of the current attachment node</param>
    /// <param name="nodeAliasPath">Node alias path of the current attachment node</param>
    /// <param name="nodeIsLink">Indicates if node is linked node.</param>
    public string GetContentItemUrl(Guid nodeGuid, string documentUrlPath, string nodeAlias, string nodeAliasPath, bool nodeIsLink, int height, int width, int maxSideSize, bool notAttachment, string documentExtension)
    {
        string result = "";

        if (documentExtension.Contains(";"))
        {
            documentExtension = documentExtension.Split(';')[0];
        }

        // Generate URL
        if (UsePermanentUrls)
        {
            bool isLink = ((OutputFormat == OutputFormatEnum.BBLink) || (OutputFormat == OutputFormatEnum.HTMLLink)) ||
                          ((OutputFormat == OutputFormatEnum.URL) && (SelectableContent == SelectableContentEnum.AllContent));

            if (String.IsNullOrEmpty(nodeAlias))
            {
                nodeAlias = "default";
            }

            if (notAttachment || isLink)
            {
                result = TreePathUtils.GetPermanentDocUrl(nodeGuid, nodeAlias, SiteObj.SiteName, null, documentExtension);
            }
            else
            {
                result = AttachmentInfoProvider.GetPermanentAttachmentUrl(nodeGuid, nodeAlias, documentExtension);
            }
        }
        else
        {
            string docUrlPath = nodeIsLink ? null : documentUrlPath;

            // Ensure live site view mode for URLs edited in on-site edit mode
            if (PortalContext.ViewMode == ViewModeEnum.EditLive)
            {
                PortalContext.SetRequestViewMode(ViewModeEnum.LiveSite);
            }

            result = TreePathUtils.GetUrl(nodeAliasPath, docUrlPath, SiteObj.SiteName, null, documentExtension);
        }

        // Make URL absolute if required
        int currentSiteId = CMSContext.CurrentSiteID;

        if (Config.UseFullURL || (currentSiteId != SiteObj.SiteID) || (currentSiteId != GetCurrentSiteId()))
        {
            result = URLHelper.GetAbsoluteUrl(result, SiteObj.DomainName, URLHelper.GetApplicationUrl(SiteObj.DomainName), null);
        }

        return(AddURLDimensionsAndResolve(result, height, width, maxSideSize));
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="sourceName"></param>
    /// <param name="parameter"></param>
    object boardSubscriptions_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLower())
        {
        case "displayname":
            DataRowView dr   = (DataRowView)parameter;
            string      url  = ResolveUrl(TreePathUtils.GetUrl(ValidationHelper.GetString(dr["NodeAliasPath"], ""), null, mSiteName));
            string      lang = ValidationHelper.GetString(dr["DocumentCulture"], "");
            if (!String.IsNullOrEmpty(lang))
            {
                url += "?" + URLHelper.LanguageParameterName + "=" + lang;
            }

            return("<a target=\"_blank\" href=\"" + url + "\">" + HTMLHelper.HTMLEncode(ValidationHelper.GetString(dr["BoardDisplayName"], "")) + "</a>");
        }

        return(parameter);
    }
Exemple #6
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        // WAI validation
        lblSearch.ResourceString = "ForumSearch.SearchWord";
        lblSearch.Attributes.Add("style", "display: none;");

        btnGo.Text = GetString("ForumSearch.Go");
        if (!String.IsNullOrEmpty(AdvancedSearchPath))
        {
            lnkAdvanceSearch.NavigateUrl = ResolveUrl(TreePathUtils.GetUrl(CMSContext.ResolveCurrentPath(AdvancedSearchPath)));
            lnkAdvanceSearch.Visible     = true;
            lnkAdvanceSearch.Text        = GetString("ForumSearch.AdvanceSearch");
            if (!RequestHelper.IsPostBack())
            {
                txtSearch.Text = QueryHelper.GetString("searchtext", txtSearch.Text);
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (this.StopProcessing)
        {
            // Do nothing
        }
        else
        {
            string siteName = CMSContext.CurrentSiteName;

            // If there is only one culture on site and hiding is enabled hide webpart
            if (HideIfOneCulture && !CultureInfoProvider.IsSiteMultilignual(siteName))
            {
                this.Visible = false;
                return;
            }

            DataSet ds = null;

            // Try to get data from cache
            using (CachedSection <DataSet> cs = new CachedSection <DataSet>(ref ds, this.CacheMinutes, true, this.CacheItemName, "languageselection", siteName))
            {
                if (cs.LoadData)
                {
                    // Get the data
                    ds = CultureInfoProvider.GetSiteCultures(siteName);

                    // Save to the cache
                    if (cs.Cached)
                    {
                        cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { "cms.culturesite|all", "cms.culture|all" });
                        cs.Data            = ds;
                    }
                }
            }

            // Add CSS Stylesheet
            string cssUrl = URLHelper.ResolveUrl("~/CMSWebparts/Localization/languageselectiondropdown_files/langselector.css");
            this.Page.Header.Controls.Add(new LiteralControl("<link href=\"" + cssUrl + "\" type=\"text/css\" rel=\"stylesheet\" />"));

            // Build current URL
            string url = URLHelper.CurrentURL;
            url = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
            url = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);

            string imgFlagIcon = "";

            StringBuilder result = new StringBuilder();
            result.Append("<ul class=\"langselector\">");

            // Current language
            CultureInfo culture = CultureInfoProvider.GetCultureInfo(CMSContext.CurrentUser.PreferredCultureCode);
            if (culture != null)
            {
                // Drop down imitating icon
                string dropIcon = ResolveUrl("~/CMSWebparts/Localization/languageselectiondropdown_files/dd_arrow.gif");

                // Current language
                imgFlagIcon = this.GetImageUrl("Flags/16x16/" + HTMLHelper.HTMLEncode(culture.CultureCode) + ".png");

                string currentCultureShortName = "";
                if (this.ShowCultureNames)
                {
                    currentCultureShortName = HTMLHelper.HTMLEncode(culture.CultureShortName);
                }

                result.AppendFormat("<li class=\"lifirst\" style=\"background-image:url('{0}'); background-repeat: no-repeat\"><a class=\"first\" style=\"background-image:url({1}); background-repeat: no-repeat\" href=\"{2}\">{3}</a>",
                                    dropIcon, imgFlagIcon, HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, culture.CultureCode)), currentCultureShortName);
            }

            // List of languages
            if (!DataHelper.DataSourceIsEmpty(ds) && (ds.Tables[0].Rows.Count > 1))
            {
                // Collection of available documents in culture
                Dictionary <string, string> documentCultures = null;
                // Check whether hiding is required or URLs should be generated with lang prefix
                if (this.HideUnavailableCultures || this.UseURLsWithLangPrefix)
                {
                    string cacheItemName = this.CacheItemName;
                    if (!String.IsNullOrEmpty(cacheItemName))
                    {
                        cacheItemName += "prefix";
                    }

                    // Current page info
                    PageInfo currentPageInfo = CMSContext.CurrentPageInfo;

                    if (currentPageInfo != null)
                    {
                        // Try to get data from cache
                        using (CachedSection <Dictionary <string, string> > cs = new CachedSection <Dictionary <string, string> >(ref documentCultures, this.CacheMinutes, true, cacheItemName, "languageselectionprefix", siteName, currentPageInfo.NodeAliasPath.ToLower()))
                        {
                            if (cs.LoadData)
                            {
                                // Initialize tree provider object
                                TreeProvider tp = new TreeProvider(CMSContext.CurrentUser);
                                tp.FilterOutDuplicates       = false;
                                tp.CombineWithDefaultCulture = false;

                                // Get all language versions
                                DataSet culturesDs = tp.SelectNodes(siteName, "/%", TreeProvider.ALL_CULTURES, false, null, "NodeID = " + currentPageInfo.NodeId, null, -1, true, 0, "DocumentCulture, DocumentUrlPath");

                                // Create culture/UrlPath collection
                                if (!DataHelper.DataSourceIsEmpty(culturesDs))
                                {
                                    documentCultures = new Dictionary <string, string>();
                                    foreach (DataRow dr in culturesDs.Tables[0].Rows)
                                    {
                                        string docCulture = ValidationHelper.GetString(dr["DocumentCulture"], String.Empty).ToLower();
                                        string urlPath    = ValidationHelper.GetString(dr["DocumentUrlPath"], String.Empty);
                                        documentCultures.Add(docCulture, urlPath);
                                    }
                                }

                                // Add to the cache
                                if (cs.Cached)
                                {
                                    cs.CacheDependency = this.GetCacheDependency();
                                    cs.Data            = documentCultures;
                                }
                            }
                        }
                    }
                }

                result.Append("<ul>");

                // Create options for other culture
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string cultureCode      = dr["CultureCode"].ToString();
                    string cultureShortName = dr["CultureShortName"].ToString();
                    string cultureAlias     = dr["CultureAlias"].ToString();

                    bool documentCultureExists = true;

                    // Check whether exists document in specified culture
                    if ((documentCultures != null) && (this.HideUnavailableCultures))
                    {
                        documentCultureExists = documentCultures.ContainsKey(cultureCode.ToLower());
                    }

                    if (documentCultureExists)
                    {
                        if (CMSContext.CurrentDocument != null && !string.IsNullOrEmpty(CMSContext.CurrentDocument.DocumentCulture) && !((HideCurrentCulture) && (String.Compare(CMSContext.CurrentDocument.DocumentCulture, cultureCode, true) == 0)))
                        {
                            url = null;
                            string lang = cultureCode;
                            // Check whether culture alias is defined and if so use it
                            if (!String.IsNullOrEmpty(cultureAlias))
                            {
                                lang = cultureAlias;
                            }

                            // Get specific url with language prefix
                            if (this.UseURLsWithLangPrefix && documentCultures != null)
                            {
                                string urlPath = String.Empty;
                                if (documentCultures.ContainsKey(cultureCode.ToLower()))
                                {
                                    urlPath = documentCultures[cultureCode.ToLower()];
                                }
                                url  = TreePathUtils.GetUrl(CMSContext.CurrentAliasPath, urlPath, siteName, lang);
                                url += URLHelper.GetQuery(URLHelper.CurrentURL);
                                url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                            }
                            // Get URL with lang parameter
                            else
                            {
                                // Build current URL
                                url = URLHelper.CurrentURL;
                                url = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                url = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                                url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, lang);
                            }

                            // Language icon
                            imgFlagIcon = this.GetImageUrl("Flags/16x16/" + HTMLHelper.HTMLEncode(cultureCode) + ".png");

                            if (this.ShowCultureNames)
                            {
                                cultureShortName = HTMLHelper.HTMLEncode(cultureShortName);
                            }
                            else
                            {
                                cultureShortName = "";
                            }
                            result.AppendFormat("<li><a style=\"background-image:url({0}); background-repeat: no-repeat\" href=\"{1}\">{2}</a></li>\r\n",
                                                imgFlagIcon, HTMLHelper.HTMLEncode(URLHelper.ResolveUrl(url)), cultureShortName);
                        }
                    }
                }
                result.Append("</ul>");
            }
            result.Append("</li></ul>");
            ltlLanguages.Text = result.ToString();
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            SetContext();

            GroupInfo group = CommunityContext.CurrentGroup;
            if (group != null)
            {
                string path = (GroupsSecurityAccessPath == "") ? GroupInfoProvider.GetGroupSecurityAccessPath(group.GroupName, CMSContext.CurrentSiteName) : GroupsSecurityAccessPath;
                string url  = URLHelper.ResolveUrl(TreePathUtils.GetUrl(CMSContext.ResolveCurrentPath(path)));
                if (UseQueryString)
                {
                    url = URLHelper.UpdateParameterInUrl(url, "groupid", group.GroupID.ToString());
                }

                // Check whether group is approved
                if (!group.GroupApproved)
                {
                    URLHelper.Redirect(url);
                }
                else
                {
                    // Check permissions for current user
                    switch (group.GroupAccess)
                    {
                    // Anybody can view the content
                    default:
                    case SecurityAccessEnum.AllUsers:
                        break;

                    // Site members can view the content
                    case SecurityAccessEnum.AuthenticatedUsers:
                        if (!CMSContext.CurrentUser.IsAuthenticated())
                        {
                            URLHelper.Redirect(url);
                        }
                        break;

                    // Only group members can view the content
                    case SecurityAccessEnum.GroupMembers:
                        if (!CMSContext.CurrentUser.IsGroupMember(group.GroupID))
                        {
                            URLHelper.Redirect(url);
                        }
                        break;
                    }
                }
            }
            else
            {
                Visible = false;
            }

            ReleaseContext();
        }
    }
    /// <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>
 /// Gets URL from given path.
 /// </summary>
 /// <param name="path">Node alias path</param>
 private string GetUrl(string path)
 {
     return(ResolveUrl(TreePathUtils.GetUrl(CMSContext.ResolveCurrentPath(path))));
 }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            mLayoutSeparator = DisplayLayout.ToLower() == "vertical" ? "<br />" : " ";

            DataSet ds = null;

            // Try to get data from cache
            using (CachedSection <DataSet> cs = new CachedSection <DataSet>(ref ds, this.CacheMinutes, true, this.CacheItemName, "languageselection", CMSContext.CurrentSiteName))
            {
                if (cs.LoadData)
                {
                    // Get the data
                    ds = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);

                    // Save to the cache
                    if (cs.Cached)
                    {
                        cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { "cms.culturesite|all", "cms.culture|all" });
                        cs.Data            = ds;
                    }
                }
            }

            if (!DataHelper.DataSourceIsEmpty(ds) && (ds.Tables[0].Rows.Count > 1))
            {
                // Collection of available documents in culture
                Dictionary <string, string> documentCultures = null;
                // Check whether hiding is required or URLs should be generated with lang prefix
                if (this.HideUnavailableCultures || this.UseURLsWithLangPrefix)
                {
                    string cacheItemName = this.CacheItemName;
                    if (!String.IsNullOrEmpty(cacheItemName))
                    {
                        cacheItemName += "prefix";
                    }

                    // Current page info
                    PageInfo currentPageInfo = CMSContext.CurrentPageInfo;

                    // Try to get data from cache
                    using (CachedSection <Dictionary <string, string> > cs = new CachedSection <Dictionary <string, string> >(ref documentCultures, this.CacheMinutes, true, cacheItemName, "languageselectionprefix", CMSContext.CurrentSiteName, currentPageInfo.NodeAliasPath.ToLower()))
                    {
                        if (cs.LoadData)
                        {
                            // Initialize tree provider object
                            TreeProvider tp = new TreeProvider(CMSContext.CurrentUser);
                            tp.FilterOutDuplicates       = false;
                            tp.CombineWithDefaultCulture = false;

                            // Get all language versions
                            DataSet culturesDs = tp.SelectNodes(CMSContext.CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, false, null, "NodeID = " + currentPageInfo.NodeId, null, -1, true, 0, "DocumentCulture, DocumentUrlPath");

                            // Create culture/UrlPath collection
                            if (!DataHelper.DataSourceIsEmpty(culturesDs))
                            {
                                documentCultures = new Dictionary <string, string>();
                                foreach (DataRow dr in culturesDs.Tables[0].Rows)
                                {
                                    string docCulture = ValidationHelper.GetString(dr["DocumentCulture"], String.Empty).ToLower();
                                    string urlPath    = ValidationHelper.GetString(dr["DocumentUrlPath"], String.Empty);
                                    documentCultures.Add(docCulture, urlPath);
                                }
                            }

                            // Add to the cache
                            if (cs.Cached)
                            {
                                cs.CacheDependency = this.GetCacheDependency();
                                cs.Data            = documentCultures;
                            }
                        }
                    }
                }

                // Render the cultures
                ltlHyperlinks.Text = "";

                int count = 0;
                int rows  = ds.Tables[0].Rows.Count;

                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string cultureCode      = dr["CultureCode"].ToString();
                    string cultureShortName = dr["CultureShortName"].ToString();
                    string cultureAlias     = Convert.ToString(dr["CultureAlias"]);

                    bool documentCultureExists = true;

                    // Check whether exists document in specified culture
                    if ((documentCultures != null) && (this.HideUnavailableCultures))
                    {
                        documentCultureExists = documentCultures.ContainsKey(cultureCode.ToLower());
                    }

                    if (documentCultureExists)
                    {
                        if (!((HideCurrentCulture) && (String.Compare(CMSContext.CurrentDocument.DocumentCulture, cultureCode, true) == 0)))
                        {
                            // Get flag icon URL
                            imgFlagIcon = UIHelper.GetFlagIconUrl(this.Page, cultureCode, "16x16");

                            string url  = null;
                            string lang = cultureCode;
                            // Check whether culture alias is defined and if so use it
                            if (!String.IsNullOrEmpty(cultureAlias))
                            {
                                lang = cultureAlias;
                            }

                            // Get specific url with language prefix
                            if (this.UseURLsWithLangPrefix && documentCultures != null)
                            {
                                string urlPath = String.Empty;
                                if (documentCultures.ContainsKey(cultureCode.ToLower()))
                                {
                                    urlPath = documentCultures[cultureCode.ToLower()];
                                }
                                url  = TreePathUtils.GetUrl(CMSContext.CurrentAliasPath, urlPath, CMSContext.CurrentSiteName, lang);
                                url += URLHelper.GetQuery(URLHelper.CurrentURL);
                                url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                            }
                            // Get URL with lang parameter
                            else
                            {
                                // Build current URL
                                url = URLHelper.CurrentURL;
                                url = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                url = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                                url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, lang);
                            }

                            if (ShowCultureNames)
                            {
                                // Add flag icon before the link text
                                ltlHyperlinks.Text += "<img src=\"" + imgFlagIcon + "\" alt=\"" + HTMLHelper.HTMLEncode(cultureShortName) + "\" />";
                                ltlHyperlinks.Text += "<a href=\"" + url + "\">";
                                ltlHyperlinks.Text += HTMLHelper.HTMLEncode(cultureShortName);

                                // Set surrounding div css class
                                selectionClass = "languageSelectionWithCultures";
                            }
                            else
                            {
                                ltlHyperlinks.Text += "<a href=\"" + url + "\">" + "<img src=\"" + imgFlagIcon + "\" alt=\"" + HTMLHelper.HTMLEncode(cultureShortName) + "\" />";

                                // Set surrounding div css class
                                selectionClass = "languageSelection";
                            }

                            count++;

                            // Check last item
                            if (count == rows)
                            {
                                ltlHyperlinks.Text += "</a>";
                            }
                            else
                            {
                                ltlHyperlinks.Text += "</a>" + Separator + mLayoutSeparator;
                            }
                        }
                    }
                }
            }
            else
            {
                // Hide if less than two cultures
                Visible = false;
            }

            if (string.IsNullOrEmpty(selectionClass))
            {
                ltrDivOpen.Text = "<div>";
            }
            else
            {
                ltrDivOpen.Text = "<div class=\"" + selectionClass + "\">";
            }
            ltrDivClose.Text = "</div>";

            // Check if RTL hack must be applied
            if (CultureHelper.IsPreferredCultureRTL())
            {
                ltrDivOpen.Text += "<span style=\"visibility:hidden;\">a</span>";
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do not process
        }
        else
        {
            string culture = CMSContext.PreferredCultureCode;

            mSeparator = DisplayLayout.ToLower() == "vertical" ? "<br />" : " ";

            DataSet ds = null;

            // Try to get data from cache
            using (CachedSection <DataSet> cs = new CachedSection <DataSet>(ref ds, this.CacheMinutes, true, this.CacheItemName, "languageselection", CMSContext.CurrentSiteName))
            {
                if (cs.LoadData)
                {
                    // Get the data
                    ds = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName);

                    // Add to the cache
                    if (cs.Cached)
                    {
                        cs.CacheDependency = this.GetCacheDependency();
                        cs.Data            = ds;
                    }
                }
            }

            if (!DataHelper.DataSourceIsEmpty(ds) && (ds.Tables[0].Rows.Count > 1))
            {
                // Collection of available documents in culture
                Dictionary <string, string> documentCultures = null;
                // Check whether hiding is required or URLs should be generated with lang prefix
                if (this.HideUnavailableCultures || this.UseURLsWithLangPrefix)
                {
                    string cacheItemName = this.CacheItemName;
                    if (!String.IsNullOrEmpty(cacheItemName))
                    {
                        cacheItemName += "prefix";
                    }

                    // Current page info
                    PageInfo currentPageInfo = CMSContext.CurrentPageInfo;

                    // Try to get data from cache
                    using (CachedSection <Dictionary <string, string> > cs = new CachedSection <Dictionary <string, string> >(ref documentCultures, this.CacheMinutes, true, cacheItemName, "languageselectionprefix", CMSContext.CurrentSiteName, currentPageInfo.NodeAliasPath.ToLower()))
                    {
                        if (cs.LoadData)
                        {
                            // Initialize tree provider object
                            TreeProvider tp = new TreeProvider(CMSContext.CurrentUser);
                            tp.FilterOutDuplicates       = false;
                            tp.CombineWithDefaultCulture = false;

                            // Get all language versions
                            DataSet culturesDs = tp.SelectNodes(CMSContext.CurrentSiteName, "/%", TreeProvider.ALL_CULTURES, false, null, "NodeID = " + currentPageInfo.NodeId, null, -1, true, 0, "DocumentCulture, DocumentUrlPath");

                            // Create culture/UrlPath collection
                            if (!DataHelper.DataSourceIsEmpty(culturesDs))
                            {
                                documentCultures = new Dictionary <string, string>();
                                foreach (DataRow dr in culturesDs.Tables[0].Rows)
                                {
                                    string docCulture = ValidationHelper.GetString(dr["DocumentCulture"], String.Empty).ToLower();
                                    string urlPath    = ValidationHelper.GetString(dr["DocumentUrlPath"], String.Empty);
                                    documentCultures.Add(docCulture, urlPath);
                                }
                            }

                            // Add to the cache
                            if (cs.Cached)
                            {
                                cs.CacheDependency = CacheHelper.GetCacheDependency(new string[] { "cms.culturesite|all", "cms.culture|all", "node|" + CurrentSiteName.ToLower() + "|" + currentPageInfo.NodeAliasPath.ToLower() });
                                cs.Data            = documentCultures;
                            }
                        }
                    }
                }

                // Render the cultures
                ltlHyperlinks.Text = "";
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string cultureCode      = Convert.ToString(dr["CultureCode"]);
                    string cultureAlias     = Convert.ToString(dr["CultureAlias"]);
                    string cultureShortName = Convert.ToString(dr["CultureShortName"]);
                    // Indicates whether exists document in specific culture
                    bool documentCultureExists = true;

                    // Check whether exists document in specified culture
                    if ((documentCultures != null) && (this.HideUnavailableCultures))
                    {
                        documentCultureExists = documentCultures.ContainsKey(cultureCode.ToLower());
                    }

                    if (documentCultureExists)
                    {
                        if (!(HideCurrentCulture && (String.Compare(CMSContext.CurrentDocument.DocumentCulture, cultureCode, true) == 0)))
                        {
                            if (String.Compare(culture, cultureCode, StringComparison.InvariantCultureIgnoreCase) != 0)
                            {
                                string url  = null;
                                string lang = cultureCode;
                                // Check whether culture alias is defined and if so use it
                                if (!String.IsNullOrEmpty(cultureAlias))
                                {
                                    lang = cultureAlias;
                                }

                                // Get specific url with language prefix
                                if (this.UseURLsWithLangPrefix && documentCultures != null)
                                {
                                    string urlPath = String.Empty;
                                    if (documentCultures.ContainsKey(cultureCode.ToLower()))
                                    {
                                        urlPath = documentCultures[cultureCode.ToLower()];
                                    }
                                    url  = TreePathUtils.GetUrl(CMSContext.CurrentAliasPath, urlPath, CMSContext.CurrentSiteName, lang);
                                    url += URLHelper.GetQuery(URLHelper.CurrentURL);
                                    url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                    url  = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                                }
                                // Get URL with lang parameter
                                else
                                {
                                    // Build current URL
                                    url = URLHelper.CurrentURL;
                                    url = URLHelper.RemoveParameterFromUrl(url, URLHelper.LanguageParameterName);
                                    url = URLHelper.RemoveParameterFromUrl(url, URLHelper.AliasPathParameterName);
                                    url = URLHelper.AddParameterToUrl(url, URLHelper.LanguageParameterName, lang);
                                }



                                ltlHyperlinks.Text += "<a href=\"" + url + "\">" + HTMLHelper.HTMLEncode(cultureShortName) + "</a>";
                            }
                            else
                            {
                                ltlHyperlinks.Text += cultureShortName;
                            }
                            ltlHyperlinks.Text += mSeparator;
                        }
                    }
                }
            }
            else
            {
                Visible = false;
            }
        }
    }
    /// <summary>
    /// Updates the current Group or creates new if no GroupID is present.
    /// </summary>
    public void SaveData()
    {
        // Check banned ip
        if (!BannedIPInfoProvider.IsAllowed(CMSContext.CurrentSiteName, BanControlEnum.AllNonComplete))
        {
            lblError.Visible = true;
            lblError.Text    = GetString("General.BannedIP");
            return;
        }

        // Validate form entries
        string errorMessage = ValidateForm();

        if (errorMessage == "")
        {
            try
            {
                codeName = GetSafeCodeName();
                codeName = GetUniqueCodeName(codeName);

                GroupInfo group = new GroupInfo();
                group.GroupDisplayName    = this.txtDisplayName.Text;
                group.GroupName           = codeName;
                group.GroupDescription    = this.txtDescription.Text;
                group.GroupAccess         = GetGroupAccess();
                group.GroupSiteID         = this.mSiteId;
                group.GroupApproveMembers = GetGroupApproveMembers();

                // Set columns GroupCreatedByUserID and GroupApprovedByUserID to current user
                CurrentUserInfo user = CMSContext.CurrentUser;

                if (user != null)
                {
                    group.GroupCreatedByUserID = user.UserID;

                    if ((!this.RequireApproval) || (CurrentUserIsAdmin()))
                    {
                        group.GroupApprovedByUserID = user.UserID;
                        group.GroupApproved         = true;
                    }
                }

                // Save Group in the database
                GroupInfoProvider.SetGroupInfo(group);

                // Create group admin role
                RoleInfo roleInfo = new RoleInfo();
                roleInfo.DisplayName = "Group admin";
                roleInfo.RoleName    = group.GroupName + "_groupadmin";
                roleInfo.RoleGroupID = group.GroupID;
                roleInfo.RoleIsGroupAdministrator = true;
                roleInfo.SiteID = this.mSiteId;
                // Save group admin role
                RoleInfoProvider.SetRoleInfo(roleInfo);

                if (user != null)
                {
                    // Set user as member of group
                    GroupMemberInfo gmi = new GroupMemberInfo();
                    gmi.MemberUserID           = user.UserID;
                    gmi.MemberGroupID          = group.GroupID;
                    gmi.MemberJoined           = DateTime.Now;
                    gmi.MemberStatus           = GroupMemberStatus.Approved;
                    gmi.MemberApprovedWhen     = DateTime.Now;
                    gmi.MemberApprovedByUserID = user.UserID;

                    // Save user as member of group
                    GroupMemberInfoProvider.SetGroupMemberInfo(gmi);

                    // Set user as member of admin group role
                    UserRoleInfo userRole = new UserRoleInfo();
                    userRole.UserID = user.UserID;
                    userRole.RoleID = roleInfo.RoleID;

                    // Save user as member of admin group role
                    UserRoleInfoProvider.SetUserRoleInfo(userRole);
                }

                // Clear user session a request
                CMSContext.CurrentUser.Invalidate();
                CMSContext.CurrentUser = null;

                string culture = CultureHelper.EnglishCulture.ToString();
                if (CMSContext.CurrentDocument != null)
                {
                    culture = CMSContext.CurrentDocument.DocumentCulture;
                }

                // Copy document
                errorMessage = GroupInfoProvider.CopyGroupDocument(group, CMSContext.ResolveCurrentPath(GroupTemplateSourceAliasPath), CMSContext.ResolveCurrentPath(GroupTemplateTargetAliasPath), GroupProfileURLPath, culture, this.CombineWithDefaultCulture, CMSContext.CurrentUser, roleInfo);

                if (errorMessage != "")
                {
                    // Display error message
                    this.lblError.Text    = errorMessage;
                    this.lblError.Visible = true;
                    return;
                }

                // Create group forum
                if (CreateForum)
                {
                    CreateGroupForum(group);

                    // Create group forum search index
                    if (CreateSearchIndexes)
                    {
                        CreateGroupForumSearchIndex(group);
                    }
                }

                // Create group media library
                if (CreateMediaLibrary)
                {
                    CreateGroupMediaLibrary(group);
                }

                // Create search index for group documents
                if (CreateSearchIndexes)
                {
                    CreateGroupContentSearchIndex(group);
                }

                // Display information on success
                this.lblInfo.Text    = GetString("group.group.createdinfo");
                this.lblInfo.Visible = true;

                // If URL is set, redirect user to specified page
                if (!String.IsNullOrEmpty(this.RedirectToURL))
                {
                    URLHelper.Redirect(ResolveUrl(CMSContext.GetUrl(this.RedirectToURL)));
                }

                // After registration message
                if ((this.RequireApproval) && (!CurrentUserIsAdmin()))
                {
                    this.lblInfo.Text = this.SuccessfullRegistrationWaitingForApprovalText;

                    // Send approval email to admin
                    if (!String.IsNullOrEmpty(SendWaitingForApprovalEmailTo))
                    {
                        // Create the message
                        EmailTemplateInfo eti = EmailTemplateProvider.GetEmailTemplate("Groups.WaitingForApproval", CMSContext.CurrentSiteName);
                        if (eti != null)
                        {
                            EmailMessage message = new EmailMessage();
                            if (String.IsNullOrEmpty(eti.TemplateFrom))
                            {
                                message.From = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSSendEmailNotificationsFrom");
                            }
                            else
                            {
                                message.From = eti.TemplateFrom;
                            }

                            MacroResolver resolver = CMSContext.CurrentResolver;
                            resolver.SourceData = new object[] { group };
                            resolver.SetNamedSourceData("Group", group);

                            message.Recipients = SendWaitingForApprovalEmailTo;
                            message.Subject    = resolver.ResolveMacros(eti.TemplateSubject);
                            message.Body       = resolver.ResolveMacros(eti.TemplateText);

                            resolver.EncodeResolvedValues = false;
                            message.PlainTextBody         = resolver.ResolveMacros(eti.TemplatePlainText);

                            // Send the message using email engine
                            EmailSender.SendEmail(message);
                        }
                    }
                }
                else
                {
                    string groupPath = SettingsKeyProvider.GetStringValue(CMSContext.CurrentSiteName + ".CMSGroupProfilePath");
                    string url       = String.Empty;

                    if (!String.IsNullOrEmpty(groupPath))
                    {
                        url = TreePathUtils.GetUrl(groupPath.Replace("{GroupName}", group.GroupName));
                    }
                    this.lblInfo.Text = String.Format(this.SuccessfullRegistrationText, url);
                }

                // Hide form
                if (this.HideFormAfterRegistration)
                {
                    this.plcForm.Visible = false;
                }
                else
                {
                    ClearForm();
                }
            }
            catch (Exception ex)
            {
                // Display error message
                this.lblError.Text    = GetString("general.erroroccurred") + ex.Message;
                this.lblError.Visible = true;
            }
        }
        else
        {
            // Display error message
            this.lblError.Text    = errorMessage;
            this.lblError.Visible = true;
        }
    }
Exemple #14
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            if (CMSContext.CurrentUser.IsAuthenticated())
            {
                // Get requested action
                action     = (FriendsActionEnum)Enum.Parse(typeof(FriendsActionEnum), QueryHelper.GetString("action", "request"), true);
                friendship = CommunityContext.CurrentFriendship;
                friend     = CommunityContext.CurrentFriend;

                // Prepare My Friends link
                lnkMyFriends.Text = MyFriendsCaption;
                if (MyFriendsPath != string.Empty)
                {
                    lnkMyFriends.NavigateUrl = URLHelper.GetAbsoluteUrl(TreePathUtils.GetUrl(MyFriendsPath));
                }
                else
                {
                    lnkMyFriends.Visible = false;
                }

                // Validate requested action
                if (!ValidateAction())
                {
                    return;
                }

                btnApprove.Click += btnApprove_Click;
                btnReject.Click  += btnReject_Click;

                if (friendship != null)
                {
                    // If friendship is rejected -> display error
                    switch (friendship.FriendStatus)
                    {
                    case FriendshipStatusEnum.Rejected:
                        plcMessage.Visible = true;
                        plcConfirm.Visible = false;
                        lblInfo.Text       = AlreadyRejectedCaption;
                        lblInfo.ForeColor  = Color.Red;
                        break;

                    case FriendshipStatusEnum.Approved:
                        plcMessage.Visible = true;
                        plcConfirm.Visible = false;
                        lblInfo.Text       = AlreadyApprovedCaption;
                        lblInfo.ForeColor  = Color.Red;
                        break;

                    default:
                        plcMessage.Visible = false;
                        plcConfirm.Visible = true;
                        btnApprove.Text    = GetString("general.approve");
                        btnReject.Text     = GetString("general.reject");

                        string profilePath = GroupMemberInfoProvider.GetMemberProfilePath(friend.UserName, CMSContext.CurrentSiteName);
                        string profileUrl  = ResolveUrl(TreePathUtils.GetUrl(profilePath));
                        string link        = "<a href=\"" + profileUrl + "\" >" + HTMLHelper.HTMLEncode(Functions.GetFormattedUserName(friend.UserName, friend.FullName, true)) + "</a>";
                        lblConfirm.Text = string.Format(GetString("friends.approvaltext"), link);
                        break;
                    }
                }
                else
                {
                    Visible = false;
                }
            }
            else
            {
                plcMessage.Visible = true;
                plcConfirm.Visible = false;
                lblInfo.ForeColor  = Color.Red;
                lblInfo.Text       = GetString("friends.notloggedin");
            }
        }
    }
Exemple #15
0
    /// <summary>
    /// Returns URL of the media item according site settings.
    /// </summary>
    /// <param name="nodeGuid">Node GUID of the current attachment node</param>
    /// <param name="documentUrlPath">URL path of the current attachment document</param>
    /// <param name="maxSideSize">Maximum dimension for images displayed for tile and thumbnails view</param>
    /// <param name="nodeAlias">Node alias of the current attachment node</param>
    /// <param name="nodeAliasPath">Node alias path of the current attachment node</param>
    /// <param name="nodeIsLink">Indicates if node is linked node.</param>
    public string GetContentItemUrl(Guid nodeGuid, string documentUrlPath, string nodeAlias, string nodeAliasPath, bool nodeIsLink, int height, int width, int maxSideSize, bool notAttachment, string documentExtension)
    {
        string result = "";

        if (documentExtension.Contains(";"))
        {
            documentExtension = documentExtension.Split(';')[0];
        }

        // Generate URL
        if (UsePermanentUrls)
        {
            bool isLink = ((OutputFormat == OutputFormatEnum.BBLink) || (OutputFormat == OutputFormatEnum.HTMLLink)) ||
                          ((OutputFormat == OutputFormatEnum.URL) && (SelectableContent == SelectableContentEnum.AllContent));

            if (String.IsNullOrEmpty(nodeAlias))
            {
                nodeAlias = "default";
            }

            if (notAttachment || isLink)
            {
                result = TreePathUtils.GetPermanentDocUrl(nodeGuid, nodeAlias, SiteObj.SiteName, null, documentExtension);
            }
            else
            {
                result = AttachmentManager.GetPermanentAttachmentUrl(nodeGuid, nodeAlias, documentExtension);
            }
        }
        else
        {
            string docUrlPath = nodeIsLink ? null : documentUrlPath;
            result = TreePathUtils.GetUrl(nodeAliasPath, docUrlPath, null, null, documentExtension);
        }

        // Make URL absolute if required
        int currentSiteId = CMSContext.CurrentSiteID;

        if (Config.UseFullURL || (currentSiteId != SiteObj.SiteID) || (currentSiteId != GetCurrentSiteId()))
        {
            result = URLHelper.GetAbsoluteUrl(result, SiteObj.DomainName, URLHelper.GetApplicationUrl(SiteObj.DomainName), null);
        }

        // Image dimensions to URL
        if (maxSideSize > 0)
        {
            result = URLHelper.AddParameterToUrl(result, "maxsidesize", maxSideSize.ToString());
        }
        if (height > 0)
        {
            result = URLHelper.AddParameterToUrl(result, "height", height.ToString());
        }
        if (width > 0)
        {
            result = URLHelper.AddParameterToUrl(result, "width", width.ToString());
        }

        // Media selctor should returns non-resolved URL in all cases
        bool isMediaSelector = (OutputFormat == OutputFormatEnum.URL) && (SelectableContent == SelectableContentEnum.OnlyMedia);

        return(isMediaSelector ? result : URLHelper.ResolveUrl(result, true, false));
    }
Exemple #16
0
    /// <summary>
    /// Returns link to selected post.
    /// </summary>
    /// <param name="postIdPath">Post id path</param>
    /// <param name="forumId">Forum id</param>
    /// <param name="aliasPath">Alias path</param>
    public static string GetPostURL(object aliasPath, object postIdPath, object forumId)
    {
        string alPath  = ValidationHelper.GetString(aliasPath, string.Empty);
        string pIdPath = ValidationHelper.GetString(postIdPath, string.Empty);
        int    fId     = ValidationHelper.GetInteger(forumId, 0);

        if (!String.IsNullOrEmpty(pIdPath) && (fId > 0))
        {
            // Get thread id from post id path
            int threadId = ForumPostInfoProvider.GetPostRootFromIDPath(pIdPath);

            if (threadId > 0)
            {
                string url = URLHelper.ResolveUrl(CMSContext.CurrentResolver.ResolveMacros(TreePathUtils.GetUrl(alPath)));
                url = URLHelper.UpdateParameterInUrl(url, "ForumId", fId.ToString());
                url = URLHelper.UpdateParameterInUrl(url, "ThreadId", threadId.ToString());
                url = URLHelper.EncodeQueryString(url);
                return(url);
            }
        }

        return(string.Empty);
    }