Category Archives: Telligent Community Server

Filter GroupList Based on Permissions of a Role

In a past project i was asked to build a Grouplist like widget for Community Server. This Grouplist widget was different from the existing because the data should be filtered by the permissions of a role (in my case Members). i have searched for a standard way to do this with the existing controls but eventually i had to write my own  <CSControl:CustomCondition />. i implemented the widget as follows (staying closely to the existing widget implementation in CS 5.5).

<%@ Control Language=”C#” AutoEventWireup=”true” %>

<%@ Import Namespace=”System.Collections.Generic” %>
<%@ Import Namespace=”System.Collections.ObjectModel” %>

<script runat=”server” language=”C#”>

    public bool IsApproved(CommunityServer.Components.Group group)
     CommunityServer.Components.ISecurityService securityService = Telligent.Common.Services.Get<CommunityServer.Components.ISecurityService>();
     CommunityServer.Components.IRoleService roleService = Telligent.Common.Services.Get<CommunityServer.Components.IRoleService>();

        IEnumerable<CommunityServer.Components.Role> roles = roleService.GetRolesForGroup(group.ID);
     CommunityServer.Components.Role member = null;
     foreach(CommunityServer.Components.Role role in roles)
      if(role.Name == “Members”)
       member = role;
     if(member != null)
      CommunityServer.Components.PermissionList p = securityService.GetImmediatePermissions(group.NodeId);
      foreach(CommunityServer.Components.PermissionEntry m in p)
       if(m.Name == “Community – Create New Communities” && m.RoleId == member.Id && m.IsAllowed)
        return true;
        return false;

<CSControl:GroupData runat=”server” CssClass=”content-item simple” Tag=”Li”>
 <DisplayConditions Operator=”And”>
     CustomResult=”<%# IsApproved(CSControlUtility.Instance().GetCurrentGroup(Container)) %>” 
     runat=”server” />
        <CSControl:GroupData runat=”server” 
           LinkTo=”HomePage” />



Randomize Userlist for Telligent Community Server

Recently i was asked to build a UserControl that uses the UserList of Community Server and randomizes the order of the items. I guess the best solution would be extending the QueryOverrides and provide a Randomizer QueryType. Sometimes this solution is not an option and you need a workaround. In this solution we ta into the PreRender event of the UserList and shuffle the datasource and call on databind. I do realize that calling DataBind in the prerender event of a control can cause serious problems but for the UserList this will not be the case.