Free SharePoint webparts!

Hi

It was a long pending idea to introduce a series of free webparts, which we think will help you achieve more.
We are open to ideas, please feel free to suggest what sort of webparts will you like here?
All the products will be placed at http://webparts.pointsharepoint.com/
The first one coming out of the factory  is a "Join a Group" webpart, which enables the end user to join a Group (Where "Allow requests to join/leave" this group is enabled). Here is the teaser :
Join a Group Webpart

Sharepoint Feature : Update the web.config

What will you do when you need to update the web.config from a feature?
The first thought will be to read the xml. 
Please don't go through the pain, simply follow me for a few more lines where I'll increase the truset level to Full in web.config

In the feature activated method, Use SPWebConfigModification

public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
    // Obtain Site
            SPSite site = properties.Feature.Parent as SPSite;
    // Obtain Web application
            SPWebApplication webApp = site.WebApplication;
            System.Collections.ObjectModel.Collection allModifications = webApp.WebConfigModifications;
           // Specify the node
            SPWebConfigModification myModification = new SPWebConfigModification("level", "configuration/system.web/trust");
 // And the custom value, finally !
            myModification.Value = "Full"; // the value of the item to set.

 // owner of the web.config modification
 myModification.Owner = strUserName; 
// Sequence number the modification if more than one modification to be done increase this by one in each modification
          myModification.Sequence = 1; 
          myModification.Type = SPWebConfigModification.SPWebConfigModificationType.EnsureAttribute; 
       
 allModifications.Add(myModification);
         SPFarm.Local.Services.GetValue().ApplyWebConfigModifications();
         webApp.Update(); 
            
        }

I hope, it'll save some time of yours.

Sharepoint Feature : Uploading a site template in "Site Template Gallery"

When we try to upload a Site Template file (.stp) to the "Site Template Gallery" through a feature, it doesn't behave the way it should.
It adds the file in gallery, but it doesn't appears in "Create New Site" page.
For this purpose, you need to add a few properties for the newly added site template

In the feature activated:

 public override void FeatureActivated(SPFeatureReceiverProperties properties)
        {
            SPSite site = properties.Feature.Parent as SPSite;
            SPWeb web = site.RootWeb;
           // try
            {
                #region Fix the Site Collection Template
                SPDocumentLibrary templates = (SPDocumentLibrary)web.Lists["Site Template Gallery"];
                foreach (SPListItem item in templates.Items)
                {
                    if (item.File.Name.Equals("Template_Name.stp"))
                    {
                        item["Title"] = "Template Title";
                        item.Properties.Add("Language", "1033");
                        item.Properties.Add("TemplateTitle", "Custom Template");
                        item.Properties.Add("vti_parserversion", "12.0.0.6219");
                        item.Properties.Add("ContentTypeId", "0x00428892DDF7841D4693B8095E5D3AEDCD");
                        item.Properties.Add("TemplateID", "1");
                        item.Update();
                    }
                }
                #endregion
            }

and volla, everything should be smooth now.
--------------------------------------------------------------------
6 Feb 2009

A better method is to add the language and version in the feature, like this

'<'Module Name="SiteRequestListTemplate" Url="_catalogs/lt" RootWebOnly="TRUE" Path="Templates"'>' 

    '<'File Url="Site.stp" Type="GhostableInLibrary" IgnoreIfAlreadyExists="TRUE"'>' 

      '<'Property Name="LanguageDisplay" Value="English" /'>' 

      '<'Property Name="Version" Value="3" /'>' 

    '<'/File'>' 

  '<'/Module'>'