I’ve no idea what the deal was, but a client’s SharePoint site lost all of the Content Editor Web Parts in their My Sites.
The thing about My Sites is that each individual one is a site collection–so it’s not as though populating the gallery in the parent site will help restore the web parts.
Thanks to these two articles, I wrote a quick program to re-populate the gallery:
http://jasear.wordpress.com/2008/07/06/programmatically-adding-a-web-par…
http://blog.rafelo.com/2008/07/iterating-through-sharepoint-web.html
The code was pretty simple with that help:
SPWebApplication webApp = SPWebApplication.Lookup(new Uri(sSite));
FileInfo f = new FileInfo(sDWPFileLocation);
FileStream s = f.Open(FileMode.Open, FileAccess.Read);
//Execute any logic you need to against the web application
//Iterate through each site collection
foreach (SPSite siteCollection in webApp.Sites)
{
foreach (SPWeb _web in siteCollection.AllWebs)
{
using (_web)
{
try
{
TextFileWriter(_web.Title.ToString());
_web.AllowUnsafeUpdates = true;
siteCollection.AllowUnsafeUpdates = true;
SPList _list = _web.Lists[“Web Part Gallery”];
SPFolder _root = _list.RootFolder;
SPFile _spFile = _root.Files.Add(sFileName, s);
_spFile.Update();
}
catch (Exception ex)
{
TextFileWriter(ex.ToString());
}
}
}
}
s.Close();
s.Dispose();