Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
Developer's Guide - EPiServer World
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
46 | Developer’s <strong>Guide</strong> <strong>EPiServer</strong> Community 3.1<br />
2.12 Club<br />
Clubs are mini-communities within a community. A club has a separate member list, club news, forums and image<br />
galleries etc. Clubs can be treated in different ways; they can be hidden, which means that only people who know about<br />
them can become members. It can have different security states: closed or open. Closed clubs require approval from its<br />
owner before allowing more members, while open clubs are free to join by anyone. Clubs can also be created and wait<br />
for subsequent approval from an administrator, or the community can allow for free creation of clubs.<br />
2.12.1 Adding a Club<br />
Adding a club through the API is useful when users want to create their own clubs based on topics.<br />
Import Necessary Namespaces<br />
First import the necessary namespaces that will be used to add a club. The namespaces StarCommunity.Modules.Club,<br />
StarCommunity.Cre.Modules.Security and StarCommunity.Core are described by clicking on their respective names.<br />
Make sure you add the assemblies as references, as mentioned in section 1.1.1.<br />
using StarCommunity.Core;<br />
using StarCommunity.Core.Modules.Security;<br />
using StarCommunity.Modules.Club;<br />
Creating the Club<br />
In this example we start by getting the User object instances of the users we want as the creator and owner of the club.<br />
Secondly we have decided to set this club as approved, visible and with security status set to SecurityStatus.Closed.<br />
//Get the creator by id<br />
IUser creator = (IUser)StarCommunitySystem.<br />
CurrentContext.DefaultSecurity.GetUser(1234);<br />
//Get the owner by id<br />
IUser owner = (IUser)StarCommunitySystem.<br />
CurrentContext.DefaultSecurity.GetUser(12345);<br />
bool isApproved = false;<br />
bool isHidden = false;<br />
Club club = new Club("Club name",<br />
"Club description", isApproved,<br />
null, null, SecurityStatus.Closed,<br />
"Reason for creation", creator, owner,<br />
null, isHidden);<br />
club = ClubHandler.AddClub(club);<br />
Finally we add the club to database by calling the AddClub method. The new Club object instance with its ID property<br />
set is returned.<br />
© <strong>EPiServer</strong> AB