Aswath’s Blog

Idea away with wings..

Archive for the ‘Sharepoint Customization’ Category

Designing Conference Rooms Reservation Application Template with SharePoint

Posted by aswatharamadaka on April 8, 2009

I had a business Requirement where my users should able to create Meeting Request through SharePoint

Business Scenario:

I have set up the Room and Equipment Reservations application template. Some resources are created, for example:

· Resource Name: Conference Room 1; Resource Type:Conference Room

· Resource Name: Conference Room 2; Resource Type:Conference Room


Some of your end-users start creating reservations, for example:

· Start Date: 24-03-2008 1 PM 00

· End Date: 24-03-2008 3 PM 30

· Resource: Conference Room 1,Review Room1,Lotus,


Those users would like to send out an appointment with Microsoft Outlook right away from within SharePoint, taking into account the data they have already provided upon creation of the reservation in SharePoint.

The Solution I Approached Goes:

To achieve this, I combined some of my SharePoint knowledge, with a JavaScript snippet I found on the web written by Brian White.

As prerequisite for the solution, Microsoft Outlook should be installed on the client machine with which the SharePoint site is being accessed.

Create a SharePoint custom list  named “OutlookReservation“with the below specified columns,

fig-1

Which Some Things Looks like below


fig-2

1. Create the MyReservations.aspx page with Microsoft SharePoint Designer 2007. In the SharePoint site.Which should includes web part zone implemented,

2. Go to Reservation page & go to site Actions and click on Edit Page Add  web part   select Outlook Reservation List  to the page. Which results looks below.

fig-41

3. Access the web part Registered page in SharePoint Designer select web part  placeholder

4. Right-click the ListViewWebPart and choose Convert to XSLT Data View

5. Right-click the last column of the created grid, and choose Insert -> Column to the Right

6. Give the column the title Outlook Appointment.

7. Go to the code view.

8. Insert right after the PlaceHolderMain tag following code snippet:

<script type=”text/javascript”>

function createOutlookAppointment(title,meetinglocation,startdate,enddate)

{

newAppt = new appt(title, meetinglocation, formatIncomingDateTime(startdate),

formatIncomingDateTime(enddate));

saveAppt( newAppt );

}

function formatIncomingDateTime(incomingDateTime){

var datePart = incomingDateTime.substring(0,10);

var timePartHours = incomingDateTime.substring(11,13);

var timePartMinSecs = incomingDateTime.substring(13,16);

timePartHoursInt = parseInt(timePartHours,10) + 1;

timePartHours = timePartHoursInt.toString();

return datePart.concat(‘ ‘.concat(timePartHours).concat(timePartMinSecs));

}

function appt( Subject, Location, Start, End){

this.Subject = Location;

this.Location = Location;

this.Start = Start;

this.End = End;

this.ReminderMinutesBeforeStart = 15;

}

function saveAppt( obj ){

var olAppointmentItem = 1;

out = new ActiveXObject( “Outlook.Application” );

appt = out.CreateItem( olAppointmentItem );

appt.Subject = obj.Subject;

appt.Location = obj.Location;

appt.Start = obj.Start;

appt.End = obj.End;

appt.ReminderMinutesBeforeStart = obj.ReminderMinutesBeforeStart;

appt.Display();

return null;

}

</script>

9. Go to the <td> tag of your newly created column (search for Reserved By, it will be a couple of lines beneath it).

10. Add a button which will execute previously created code snippet: <input type=”button” value=”Outlook” onclick=”javascript:createOutlookAppointment(‘{@Title}’,'{@Resource}’,'{@StartTime}’,'{@EndTime}’);return true;”/>

11.

fig-5

As a result the users will have next to each reservation a button.

fig-6

12 , Clicking on the button will create a Microsoft Outlook appointment with the data previously entered upon creation of the reservation in Microsoft SharePoint.

fig-7

13 . You can extend the Reservations list, by adding additional columns, whose data could be added upon creation of the Microsoft Outlook appointment.

Posted in Sharepoint Customization | Leave a Comment »

Hide the Sign In link for the anonymous access user in anonymous access enabled site – Bend the Welcome.ascx – SharePoint MOSS

Posted by aswatharamadaka on December 16, 2008

Lots of thing can be done by playing around the Welcome.ascx user control. I have came across one of the interesting thing on hiding the “Sign In” link for anonymous access users in the public facing internet site and thought of sharing with you.

 

Following are the two steps to implement this requirement in the supported way and its quite easy, thanks to master page and the SharePoint Application Page link control.

 

1.    Create a custom user control based on the OOB “WelCome.ascx” control. Override the “OnLoad” event and hide the “Sign In” application page link for the anonymous access user.

 

2.    Create a custom master page based on the any OOB parent master page with respect to your requirement and site definition. Render the Custom welcome control in the place of OOB welcome control.

 

 

You can find the Welcome.ascx user control under the “Control Templates” folder. Bunch of menu items are available for the authenticated user like My Settings, Sign in as different user, Log Out and Personalize the page. All these menu items are available as feature menu template and will be available only if the user was authenticated successfully. Following is the structure of the feature menu template and all the menu items are available under the ID “ExplicitLogOut”. You can see that the visibility of this Personal Actions control is false and the visibility will be made to true when the user is successfully authenticated.

 <SharePoint:PersonalActions AccessKey=”<%$Resources:wss,personalactions_menu_ak%> ToolTip=”<%$Resources:wss,open_menu%> runat=”server” id=”ExplicitLogout Visible=”false“>

      <CustomTemplate>

       <SharePoint:FeatureMenuTemplate runat=”server”

             FeatureScope=”Site”

             Location=”Microsoft.SharePoint.StandardMenu”

             GroupId=”PersonalActions”

             id=”ID_PersonalActionMenu”

             UseShortId=”true”

             >

             <SharePoint:MenuItemTemplate runat=”server” id=”ID_PersonalInformation”

                         Text=”<%$Resources:wss,personalactions_personalinformation%>

                         Description=”<%$Resources:wss,personalactions_personalinformationdescription%>

                         MenuGroupId=”100″

                         Sequence=”100″

                         ImageUrl=”/_layouts/images/menuprofile.gif”

                         UseShortId=”true”

                         />

             <SharePoint:MenuItemTemplate runat=”server” id=”ID_LoginAsDifferentUser”

                         Text=”<%$Resources:wss,personalactions_loginasdifferentuser%>

                         Description=”<%$Resources:wss,personalactions_loginasdifferentuserdescription%>

                         MenuGroupId=”200″

                         Sequence=”100″

                         UseShortId=”true”

                         />

             <SharePoint:MenuItemTemplate runat=”server” id=”ID_RequestAccess”

                         Text=”<%$Resources:wss,personalactions_requestaccess%>

                         Description=”<%$Resources:wss,personalactions_requestaccessdescription%>

                         MenuGroupId=”200″

                         UseShortId=”true”

                         Sequence=”200″

                         />

             <SharePoint:MenuItemTemplate runat=”server” id=”ID_Logout”

                         Text=”<%$Resources:wss,personalactions_logout%>

                         Description=”<%$Resources:wss,personalactions_logoutdescription%>

                         MenuGroupId=”200″

                         Sequence=”300″

                         UseShortId=”true”

                         />

             <SharePoint:MenuItemTemplate runat=”server” id=”ID_PersonalizePage”

                         Text=”<%$Resources:wss,personalactions_personalizepage%>

                         Description=”<%$Resources:wss,personalactions_personalizepagedescription%>

                         ImageUrl=”/_layouts/images/menupersonalize.gif”

                         ClientOnClickScript=”javascript:MSOLayout_ChangeLayoutMode(true);”

                         PermissionsString=”AddDelPrivateWebParts,UpdatePersonalWebParts”

                         PermissionMode=”Any”

                         MenuGroupId=”300″

                         Sequence=”100″

                         UseShortId=”true”

                         />

             <SharePoint:MenuItemTemplate runat=”server” id=”ID_SwitchView”

                         MenuGroupId=”300″

                         Sequence=”200″

                         UseShortId=”true”

                         />

             <SharePoint:MenuItemTemplate runat=”server” id=”MSOMenu_RestoreDefaults”

                         Text=”<%$Resources:wss,personalactions_restorepagedefaults%>

                         Description=”<%$Resources:wss,personalactions_restorepagedefaultsdescription%>

                         ClientOnClickNavigateUrl=”javascript:MSOWebPartPage_RestorePageDefault()”

                         MenuGroupId=”300″

                         Sequence=”300″

                         UseShortId=”true”

                         />

       </SharePoint:FeatureMenuTemplate>

      </CustomTemplate>

</SharePoint:PersonalActions>

 

 

The another part of the welcome user control is “ExplicitLogin” which has been rendered as the SharePoint Application Page Link as follows.

 

<SharePoint:ApplicationPageLink runat=”server” id=”ExplicitLogin

      ApplicationPageFileName=”Authenticate.aspx” AppendCurrentPageUrl=true

      Text=”<%$Resources:wss,login_pagetitle%> style=”display:none” Visible=”false />

 

 

This is the link which we need to concentrate for this requirement. By default this link visibility is false and will come alive when the user is not authenticated. This is what happens with the anonymous access user. When the anonymous user access the site this link is visible so that the unauthenticated user can sign in.

 

Fair enough on the post mortem of the welcome user control. Now copy this welcome user control and paste it under the Control templates folder as “CustomWelcome.ascx” control. In the “CustomWelcome.ascx” control add an In Line script and override the “OnLoad” event. In the “OnLoad” event for the unauthenticated user hide the  “ExplicitLogin” link.

 

protected override void OnLoad(EventArgs e)

    {

        //base.OnLoad(e);

        base.OnLoad(e);

        if (HttpContext.Current.User.Identity.IsAuthenticated)

        {

            this.ExplicitLogout.Visible = true;

        }

        else

        {

            this.ExplicitLogin.Visible = false;

            this.ExplicitLogin.Attributes.CssStyle.Add(“display”, “block”);

        }

 

    }

 

Now we are done with the custom welcome user control. Let us have a look on rendering it through the custom master page based on the “default.master” master page. Copy the default.master page and add the Tag prefix reference for the “CustomWelcom.ascx” control as follows in the custom master page :

 

<%@ Register TagPrefix=”wssuc” TagName=”CustomWelcome src=”~/_controltemplates/CustomWelcome.ascx” %>

 

Find the following entry in the master page :

 

<wssuc:Welcome id=”IdWelcome” runat=”server” EnableViewState=”false”>

                  </wssuc:Welcome>

 

Replace the above entry with the following entry to replace the OOB welcome user control with your custom welcome user control :

 

<wssuc:CustomWelcome id=”IdWelcome” runat=”server” EnableViewState=”false”>

                  </wssuc:Welcome>

 

Save the custom master page and use it for the public facing internet site and now “Sign In” link will not be available for the unauthenticated anonymous access user.

 

If you are aware of the whole welcome.ascx control and its structure then you can play with it for bending its behavior through custom user control. Happy customizing J

Posted in Sharepoint Customization | Leave a Comment »

WSS request lifetime

Posted by aswatharamadaka on December 15, 2008

When a request enters IIS then IIS looks up in its application map for the requested web site or virtual directory for an ISAPI extension.

Following figure shows a site, that is not WSS enabled.

When an IIS web site is converted to a WSS application then several other mappings will be added such as .doc and .docx, which also will be assigned to the ASP.NET ISAPI (aspnet_isapi.dll).

When a request is then made for a WSS resource then aspnet_isapi.dll will create a new App Domain in a worker process (w3wp.exe, if IIS6 or more). It will launch the CLR (see http://rasor.wordpress.com/2008/08/21/net-roadmaps/) and create a HttpRuntime in the App Domain.

 

The Runtime will host the request.

The Runtime will look for an idle pooled SPHttpApplication. If none is found it will create a new one from the global.asax file in the WSS site. WSS creates its own version of global.asax, which instructs the runtime to use a WSS customized application class:

<% @ Application Inherits=”…..SPHttpApplication %>

WSS also modified web.config to insert a WSS HttpModule of its own:

  1. <httpModules>  
  2. <add name=“SPRequest” type=“…..SPRequestModule, ….”/>  
  3. </httpModules>  

Modules are code that intercept the call. There can be several modules. ASP.NET have build in modules for caching and authentication. The WSS module, SPRequestModule, is inserted in front of the ASP.NET modules.

The SPRequestModule registers a SPVirtualPathProvider.
http://support.microsoft.com/kb/910441
Now the WSS runtime can choose to fetch some of the content in a database instead of the file system depending on the path of the requested URL.
Q1: Why isn’t the VirtualPathProvider registered in a global.asax event instead of a module?
Q2: After registering the VirtualPathProvider, where does the fetching of the content get initiated?

The SPVirtualPathProvider uses SPPageParserFilter to determine if the content should be parsed and compiled. The SPPageParserFilter looksup settings for the filter in web.config under <sharepoint>…
Q3:and what more is the path and values?
SPPageParserFilter will then instruct ASP.NET page parser with processing instructions. Instruction could be to process the content in a no-compile mode.

Q4: What is WSS runtime? Opposed to ASP.NET runtime?

Furthermore WSS also changed web.config with file mappings like in IIS to attach a special WSS HttpHandler:

  1. <httpHandlers>  
  2. <remove verb=“*” path=“*”/>  
  3. <add verb=“*” path=“*” type=“….SPHttpHandler, ….”/>  
  4. </httpHandlers>  

Q5: What is the relationship between ASP.NET page parser and SPHttpHandler?
Q6: Where is ASP.NET page parser kicked into action?
Q5: Does ASP.NET page parser both parse and compile? Or does SPHttpHandler do parts of that?
I have a clue that it seem like the ASP.NET parser is an object before the SPHttpHandler.

To be continued, when I learn more about what WSS does to the request……………. 

 

 

Posted in Sharepoint Customization | Leave a Comment »

Hello world!

Posted by aswatharamadaka on December 15, 2008

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!

Posted in Sharepoint Customization | Leave a Comment »