protected void Page_Load(object sender, EventArgs e) { RoleInfo role = RoleController.Instance.GetRole(PortalId, r => r.SecurityMode != SecurityMode.SecurityRole && r.RoleID == GroupId); if (role == null && GroupId > 0) { UI.Skins.Skin.AddModuleMessage(this, Localization.GetString("GroupIdNotFound", Constants.SharedResourcesPath), ModuleMessage.ModuleMessageType.YellowWarning); } if (role == null && (UserInfo.IsInRole(PortalSettings.AdministratorRoleName) || UserInfo.IsSuperUser)) { role = new RoleInfo(); role.RoleID = -1; role.RoleName = Localization.GetString("Sample_RoleName", LocalResourceFile); role.Description = Localization.GetString("Sample_RoleDescription", LocalResourceFile); } if (role == null) { litOutput.Text = string.Empty; } else { var resxPath = Constants.SharedResourcesPath; var template = GroupViewTemplate; template = template.Replace("{resx:posts}", Localization.GetString("posts", resxPath)); template = template.Replace("{resx:members}", Localization.GetString("members", resxPath)); template = template.Replace("{resx:photos}", Localization.GetString("photos", resxPath)); template = template.Replace("{resx:documents}", Localization.GetString("documents", resxPath)); template = template.Replace("{resx:Join}", Localization.GetString("Join", resxPath)); template = template.Replace("{resx:JoinGroup}", Localization.GetString("JoinGroup", resxPath)); template = template.Replace("{resx:Pending}", Localization.GetString("Pending", resxPath)); template = template.Replace("{resx:LeaveGroup}", Localization.GetString("LeaveGroup", resxPath)); template = template.Replace("{resx:EditGroup}", Localization.GetString("EditGroup", resxPath)); template = template.Replace("[GroupViewTabId]", GroupViewTabId.ToString()); var groupParser = new GroupViewParser(PortalSettings, role, UserInfo, template, TabId); groupParser.GroupEditUrl = GetEditUrl(); litOutput.Text = groupParser.ParseView(); } }
protected override void Render(HtmlTextWriter output) { var rc = new RoleController(); var whereCls = new List <Func <RoleInfo, bool> >(); whereCls.Add(grp => grp.SecurityMode != SecurityMode.SecurityRole); if (RoleGroupId >= -1) { whereCls.Add(grp => grp.RoleGroupID == RoleGroupId); } whereCls.Add(grp => grp.Status == RoleStatus.Approved); if (DisplayCurrentUserGroups) { whereCls.Add(grp => currentUser.IsInRole(grp.RoleName)); } else { whereCls.Add(grp => grp.IsPublic || currentUser.IsInRole(grp.RoleName)); } if (!string.IsNullOrEmpty(SearchFilter)) { whereCls.Add(grp => grp.RoleName.ToLower().Contains(SearchFilter.ToLower()) || grp.Description.ToLower().Contains(SearchFilter.ToLower())); } var roles = TestableRoleController.Instance.GetRoles(PortalSettings.PortalId, grp => TestPredicateGroup(whereCls, grp)); if (SortDirection.ToLower() == "asc") { roles = roles.OrderBy(info => GetOrderByProperty(info, SortField)).ToList(); } else { roles = roles.OrderByDescending(info => GetOrderByProperty(info, SortField)).ToList(); } decimal pages = (decimal)roles.Count / (decimal)PageSize; output.Write(HeaderTemplate); ItemTemplate = ItemTemplate.Replace("{resx:posts}", Localization.GetString("posts", Constants.SharedResourcesPath)); ItemTemplate = ItemTemplate.Replace("{resx:members}", Localization.GetString("members", Constants.SharedResourcesPath)); ItemTemplate = ItemTemplate.Replace("{resx:photos}", Localization.GetString("photos", Constants.SharedResourcesPath)); ItemTemplate = ItemTemplate.Replace("{resx:documents}", Localization.GetString("documents", Constants.SharedResourcesPath)); ItemTemplate = ItemTemplate.Replace("{resx:Join}", Localization.GetString("Join", Constants.SharedResourcesPath)); ItemTemplate = ItemTemplate.Replace("{resx:Pending}", Localization.GetString("Pending", Constants.SharedResourcesPath)); ItemTemplate = ItemTemplate.Replace("{resx:LeaveGroup}", Localization.GetString("LeaveGroup", Constants.SharedResourcesPath)); ItemTemplate = ItemTemplate.Replace("[GroupViewTabId]", GroupViewTabId.ToString()); if (roles.Count == 0) { output.Write(String.Format("<div class=\"dnnFormMessage dnnFormInfo\"><span>{0}</span></div>", Localization.GetString("NoGroupsFound", Constants.SharedResourcesPath))); } if (!string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["page"])) { CurrentIndex = Convert.ToInt32(HttpContext.Current.Request.QueryString["page"].ToString()); CurrentIndex = CurrentIndex - 1; } int rowItem = 0; int recordStart = (CurrentIndex * PageSize); if (CurrentIndex == 0) { recordStart = 0; } for (int x = recordStart; x < (recordStart + PageSize); x++) { if (x > roles.Count - 1) { break; } var role = roles[x]; string rowTemplate = ItemTemplate; if (rowItem == 0) { output.Write(RowHeaderTemplate); } var groupParser = new GroupViewParser(PortalSettings, role, currentUser, rowTemplate, GroupViewTabId); output.Write(groupParser.ParseView()); rowItem += 1; if (rowItem == ItemsPerRow) { output.Write(RowFooterTemplate); rowItem = 0; } } if (rowItem > 0) { output.Write(RowFooterTemplate); } output.Write(FooterTemplate); int TotalPages = Convert.ToInt32(System.Math.Ceiling(pages)); if (TotalPages == 0) { TotalPages = 1; } string sUrlFormat = "<a href=\"{0}\" class=\"{1}\">{2}</a>"; string[] currParams = new string[] { }; StringBuilder sb = new StringBuilder(); if (TotalPages > 1) { for (int x = 1; x <= TotalPages; x++) { string[] @params = new string[] { }; if (currParams.Length > 0 & x > 1) { @params = Utilities.AddParams("page=" + x.ToString(), currParams); } else if (currParams.Length > 0 & x == 1) { @params = currParams; } else if (x > 1) { @params = new string[] { "page=" + x.ToString() }; } string sUrl = Utilities.NavigateUrl(TabId, @params); string cssClass = "pagerItem"; if (x - 1 == CurrentIndex) { cssClass = "pagerItemSelected"; } sb.AppendFormat(sUrlFormat, sUrl, cssClass, x.ToString()); } } output.Write("<div class=\"dnnClear groupPager\">"); output.Write(sb.ToString()); output.Write("</div>"); }