Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

With SharePoint 2010 SP1 the Site Recycle Bin feature was introduced. When a site is deleted it appears in this recycle bin. From there the user can restore the site.
Now, my problem is that I need to get programmatically informed when a site is restored out of this recycle bin by a user. Actually, if have to modify some properties on this restored site.

Any hints?
Thanks!

share|improve this question
add comment

4 Answers

up vote 1 down vote accepted
+50

There is a post which details about a custom web part which can search the recycle bin items-

http://allaboutmoss.com/2011/11/04/recycle-bin-search-webpart-for-sharepoint/

  1. Add this web part into a custom page and the results could be displayed in a grid, where each site or entity could be checked(using a checkbox) and restored by click of a button.

  2. While restoring, an email alert could be used to acknowledge that the site is restored.

share|improve this answer
add comment

I think you will need to have some algorithm for it. Below is one which may help:

  1. Maintain the deleted sites Url and GUID in a list.You can do it using SPWebEventReceiver.WebDeleted.Also,Before it gets deleted, modify its home page to a new html like page that says "Under Construction".

  2. Create a job and monitor the list for deleted site restoration. To do this, Go over the Urls(in the list) one by one and check if the any site comes into existence at that Url.

  3. If Yes, check if the GUID of the existing site equals to the GUID you stored for the deleted site at that URL.
  4. If Yes, this site is restored from recycle bin. Process the site further as you want.Restore its home page back to original so that user can access it.Remove its URL from the list that the job monitors.

Edit : You can also provide a custom page which will be used to restore from SPSite.RecycleBin .In code you can use SPDeletedSite.Restore() followed by your code to process the site.

share|improve this answer
    
Thank's for your suggestion. I will check this out. There are some considerations about performance and avoiding having artifacts in the list. –  Matthias Dec 2 '11 at 9:31
    
How should I monitor the SPDeletedSite objects in the SPSite.RecycleBin? How do I get the restored sites, since they won't be there anymore. –  Matthias Dec 2 '11 at 9:32
    
Regarding performance via lists, I don't think it is problem if you design the solution properly.Regarding,SPDeletedSite see my edit above –  Amit Kumawat Dec 2 '11 at 10:01
add comment

The Recycle bin is a list Item? Probably get a workflow to kick off to send you an email or can you create alerts to changes to the list?

Cheers

Aben

share|improve this answer
    
No it is not a list item. It is a site (SPWeb). –  Matthias Dec 1 '11 at 10:07
add comment

How about using an EventReceiver? You can catch several SPWeb events with it, I know that it works for creating a new Site and deleting it. Further information can be found here:

http://msdn.microsoft.com/en-us/library/gg252010.aspx

Im currently testing if the event will also be thrown if you restore a site from the recycle bin and give you a feedback in a few minutes.

share|improve this answer
    
I have already checked this out, but no luck. I did attach an SPWebEventReceiver to the SPWeb, but there was no event fired as far as I could see. –  Matthias Dec 1 '11 at 10:42
    
How about WebProvisioned and yes it should be attached at site collection level as that's where the addition happens. –  Nitin Rastogi Dec 1 '11 at 19:31
    
WebProvisioned happens when a site is provisioned, i.e. created. Restoring a site creates nothing, just restores the content as it was without applying any web templates or activating any features. –  James Love Dec 6 '11 at 8:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.