Kentico CMS 7.0 Developer's Guide

Managing forum groups

Managing forum groups

Previous topic Next topic Mail us feedback on this topic!  

Managing forum groups

Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic!  

Arrow


API examples for newer versions


Please visit the latest API Examples documentation to view API examples for newer versions of Kentico.



The following example creates a forum group.

 

private void CreateForumGroup()
{
    // Create new forum group object
    ForumGroupInfo newGroup = new ForumGroupInfo();
 
    // Set the properties
    newGroup.GroupDisplayName = "My new group";
    newGroup.GroupName = "MyNewGroup";
    newGroup.GroupSiteID = CMSContext.CurrentSiteID;
    newGroup.GroupAuthorDelete = true;
    newGroup.GroupAuthorEdit = true;
    newGroup.GroupDisplayEmails = true;
 
    // Save the forum group
    ForumGroupInfoProvider.SetForumGroupInfo(newGroup);
}

 

The following example gets and updates a forum group.

 

private bool GetAndUpdateForumGroup()
{

  // Get the forum group
  ForumGroupInfo updateGroup = ForumGroupInfoProvider.GetForumGroupInfo("MyNewGroup", CMSContext.CurrentSiteID);

    if (updateGroup != null)
    {
        // Update the properties
        updateGroup.GroupDisplayName = updateGroup.GroupDisplayName.ToLower();
 
        // Save the changes
        ForumGroupInfoProvider.SetForumGroupInfo(updateGroup);
 
        return true;
    }
 
    return false;
}

 

The following example gets and bulk updates forum groups.

 

private bool GetAndBulkUpdateForumGroups()
{
    // Prepare the parameters
    string where = "GroupName LIKE N'MyNewGroup%'";
    string orderBy = "";
    string columns = "";
    int topN = 10;

 
  // Get the data
  DataSet groups = ForumGroupInfoProvider.GetGroups(where, orderBy, topN, columns);

    if (!DataHelper.DataSourceIsEmpty(groups))
    {
        // Loop through the individual items
        foreach (DataRow groupDr in groups.Tables[0].Rows)
        {
            // Create object from DataRow
            ForumGroupInfo modifyGroup = new ForumGroupInfo(groupDr);
 
            // Update the properties
            modifyGroup.GroupDisplayName = modifyGroup.GroupDisplayName.ToUpper();
 
            // Save the changes
            ForumGroupInfoProvider.SetForumGroupInfo(modifyGroup);
        }
 
        return true;
    }
 
    return false;
}

 

The following example deletes a forum group.

 

private bool DeleteForumGroup()
{

  // Get the forum group
  ForumGroupInfo deleteGroup = ForumGroupInfoProvider.GetForumGroupInfo("MyNewGroup", CMSContext.CurrentSiteID);

 
    // Delete the forum group
    ForumGroupInfoProvider.DeleteForumGroupInfo(deleteGroup);
 
    return (deleteGroup != null);
}