So after some quick and dirty code I decided on the following approach, create a custom web part that can be added to a site and simply allow the "System Administrator" to set the allowable times and days that the site will show, then hey presto. This sounds very simple but actually became a little more taxing. If you think how many different links you have within a SharePoint site, you realize that if you are good SharePoint user you will probably have memorised the actual URL that you need. (Geeks!! Myself included).
Anyway I looked into this and decided that for this basic example simple homepage redirection would suffice and I would look at more scalable solution, possibly using HTTP Modules etc.
So the web part I am working on is very simple. Firstly add the web part to the relative page as shown below:
When the web part is added to the page simply choose to open the tool pane.
Next we need to enable the redirection function, be selecting the checkbox.
Once you have selected to enable the redirection, you can then type the URL to the redirection page that you wish to load in its place. Mine is a custom page that is stored within the 12 Hive.
You will also see that a panel with all the days of the week becomes visible.
When a day is selected you are then asked to specify a time range that you wish the site to be available.
The above shows that we have set it so the site is available from 9am to 6pm. The current time on my Virtual Machine is:
This means that in design mode the web part shows the following:
In the live rendered view it does not show anything on the page at all, completely hidden to the user. Now if I change the time to let's say 17:00, this should then block me accessing the site.
The custom page should then be rendered as shown below, in my page I am passing some values to the page so the user can see that yes it is an "Access Denied" and what the allowable hours are:
This is just the first version of my solution, the idea is to have a HTTP Module and some custom administration pages that allow for the dates and times to be set. The next incarnation of this will be the following:
- HTTP Module
- HTTP Redirection Feature
- Redirection Administration Pages
- Allow for Date Range Redirection
- Multiple Day Redirection based on Date range
- Multiple Time Redirection (Currently One Time Range Only)
This is just an idea of where things could go.