SharePoint, XBOX, .NET, Technology - What I am reading

    [Home] [Recent] [Site Map] [SharePoint] [XBOX]

   

SharePoint Blogs

5/30/2007 MOSS2007 – JavaScript Item Menus Part 1 (Real World Examples)

I have had quite a few emails recently about ways of either hiding, showing, adding or modifying the item level menu items that appear within lists and document library. In this post I thought I would examine what you can do and what the best approach would be (in my opinion anyway). Firstly the bulk of the menu items are drawn from the “CORE.JS” file that resides in the “12” hive.

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\1033

This file is a few thousand lines long so can be slightly cumbersome to work with. However the easiest way to find what you are after is to look at the name of the menu item you wish to change in UI and use this to search through the “CORE.JS”. For example I want to hide the “Send To” menu on all document libraries. To do this I would simply search the “CORE.JS” for the text “Send To”.

Notice when I do it highlights the variable called “L_Send_Text”.

Now call we have to do is search for that variable and hey presto we have found the function that is called when creating the menus.

So using this example let’s look at completely hiding the send to menu items. This is quite a simple request but has to be done in a certain way. There are really a couple of ways of doing this. They are:

1.       Comment out the functions that are called within the CORE.JS

2.       Use a content editor web part and add this to the relevant pages (all of them)

3.       Use inline script within the Master Page

Option 1 will work well, however where possible it is not best to modify the underline files when modifying MOSS2007. Option 2 is a favourite of mine but is very hard to maintain unless you are building custom list definitions for all your content. Also it is very hard to ensure that the web part is added to every list or library. Option 3 is the best option here, simply adding the functions as inline script code will mean that any page that calls this function will automatically call the function in the Master Page, not the CORE.JS.

So let’s take option 2 for now just so we can see how this option works. The steps to take are:

1.       Comment out the “AddSendSubMenu” in the CORE.JS

2.       Add Content Editor Web Part to the “AllItems.aspx” page for the relevant list or library

3.       Add the “AddSendSubMenu” function to the Content Editor Web Part

To comment out the function simply use the following at the beginning and the top of the function.

Now we need to add the content editor web part to the relevant pages. We will open up a document library for this and select the “Edit Page” option from the site actions menu. Once the page is edit mode press the “Add a Web Part” button.

Now we need to select the “Content Editor Web Part” to the page.

Once it is on the page press the “Open Tool Pane” link within the web part and then press the “Source Editor” button. When the dialog opens add the following code:

Once this added, if you select the item menu the “Send To” menu items will not appear.

Ok, so not everyone will want to hide functionality but the principle is the same for each menu item. I have worked on a few projects where the “DELETE” menu item has either been moved or removed from the item menu and the list or library menu bar. So let’s look at adding it back but only the email link menu item. To do this we will change the code that exists in the content editor web part to be the following:

When we now run the page the menu should then render as below:

Let’s say we wanted to have an external process run from the menu item when we click a custom link. For example we might want to send the document to another system for processing or even copy the document somewhere else. This can be done quite easy by creating a new menu item and making the link a custom “aspx” page that contains our custom code. For this example we will simply pass a few query strings to custom page. To begin with let’s modify our code slightly.

Now when we load the page it should render as below:

I won’t show the code for the other page here, as you can really do whatever you want. The URL that we constructed in the JavaScript should now look as below:

http://intranet.labs.local/StaffDirectory/_layouts/custompages/QueryStringExample.aspx?FileID=2&FileURL=http%3A%2F%2Fintranet%2Elabs%2Elocal/StaffDirectory/Team%20Documents/DemoDoc1.doc

Notice that the variables that we created have now been populated. As you can see without knowing lots of complex c# or VB.Net you can create highly customisable menus within MOSS2007.

5/29/2007 Building a Site Creation Webpart - How do you get a list of templates?
I am playing around with a webpart in my new VPC that will inevitably create a site based on what a user inputs to a combo box and a couple text boxes.  I can get the user to create the site if I hardcode in the id for the template name, however I want to get all the template codes and shove them into a combo box.  Then the user can choose which template they want.  My problem comes when I need to figure out what code is used to actually pull in the template code list to the combo box.  Has anyone experimented with the object model at all?  If so does anyone know how I would go about solving the problem I have or at least know of some website with some sample code?  After I am done with the template part I am going to work on a couple textboxes, where the user can input a couple usernames to add to this site.  Thanks for any help in advance.  If anyone would like me to post the code when I am done I will most definitely do so.
5/29/2007 MOSS2007 – My "HttpHandler" more work!!

Hi, everyone. Hope you are all well. Since my last post on the Http Handler I am writing, I have not been able to fix the issue I get with the constant looping within the code and lack of attaching the “PreInit” method to the page. Crying However it works really well for normal team sites and site collections, well basically Windows SharePoint Services (WSS). I have had a little more time to work on this and have decided to expand it slightly. My original idea behind this was to simply change the master page upon loading the page and overwrite any master page selections done via the UI. Now however it has changed to the following:

1.       Overwrite Master Page selections done through the UI

2.       Show different Master Pages based on Group Membership to the sites

3.       Show different Master Pages based on the URL that is used to access the site

For a project I am working on this is a key requirement for an Intranet / Extranet solution. Firstly the code I used before is the same but now has a few changes. The first change is that I am capturing the current site collection URL and checking this against an “AppSettings” in the “Web.Config” file. If this matches then I move onto the next code block. If the code fails the test then it must be coming in from one of the other Alternate Access Mapping (AAM) URL’s and then applies a “defaultGuest.master” page.

ActualURL = site.Url.ToString();

 

if (ActualURL.ToString() == InternalSCURL.ToString())

{

      {Code here to check the user group membership}

}

else

{

page.MasterPageFile = "/_catalogs/masterpage/defaultGuest.master";

}

The second change is that I am now checking the group membership of the current user, by using the inbuilt method:

site.IsCurrentUserMemberOfGroup

I am not looping through the groups, I already know that anyone who is an Owner or Member belongs to the “Members” group and should get Master Page one and anyone else should get Master Page 2. Once I have worked out what membership the current user has I then apply the relevant master page. As I know that all the groups in the various sites will have the following format “{Site Title} {Group Name}” I can simply check using the following code and concatenate the “site.Title” and the custom variable “siteGroup” together as shown below.

bool isMember;

string siteGroup = " Members";

 

isMember = site.IsCurrentUserMemberOfGroup(site.Groups[site.Title.ToString() + siteGroup.ToString()].ID);

 

if (isMember == true)

{

page.MasterPageFile = "/_catalogs/masterpage/defaultMember.master";

}

else

{

page.MasterPageFile = "/_catalogs/masterpage/defaultReader.master";

}

The master pages simply have been edited to display the name of the master page as part of the title, so Member, Reader or Guest. With this code in place and the enabled I get the following:

1.       User Accessing site using Extranet URL Only

 

2.       User (Member) using Internal URL

 

3.       User (Reader) using the Internal URL

 

With a little more code and a nice interface (which I am working on) you are able to map user groups, URL’s and master pages all together to create a simple system for managing look and feel across your Windows SharePoint Services (WSS) Sites.

5/29/2007 STP files, under the hood

Maybe the title here should be called "Hacking STP files", but there may be some reasons you would like to know how to accomplish this.

WARNING: Any details here are for educational purposes only, making changes to .STP files is not recommended, probably not supported, and generally is a bad idea. Why not instead restore the STP file, make a few tweaks, then re-save as a new template?  It"s much more simple, it"s supported with tools, and it"s going to be faster in any case.

Basically there are very few circumstances ("almost none") when actually using any of the information from this file autopsy would be a good idea. But I like to take things apart and see how they work, so here"s the results of my investigation. 

The .STP files created by SharePoint whenever you save a site as a template are, surprise, actually .CAB files! So, to explore the contents of an .STP file, do the following:

  • Save a SharePoint site as a Template
  • Go to the Site Template gallery in the top level Web
  • Find the template you want to explore, save it locally
  • Rename the file from [filename].stp to [filename].cab
  • Double click the CAB to see the contents.

Inside you will see one manifest.xml file, which is the key item in the template. You may see a number of other files with .000 extensions; these are other templates contained in the site, for example, if you had a document library containing user-customized default templates, they would be contained inside your .stp file with the .000 extension. If you trace the relationships between these files and your manifest.xml file you may just be able to replace a document template.

The manifest.xml file is the really interesting part of this, though. At the top level, these are the nodes:

  • Web
    • MetaInfo
    • Details (contains defaults for all these)
      • TemplateDescription
      • TemplateTitle
      • ProductVersion
      • Language
      • TemplateID
      • Configuration
      • Title
      • Description
      • CalendarType
      • AlternateCSS
      • CustomJSUrl
      • AlternateHeader
      • Subweb
      • Locale
      • Collation
      • TimeZone
      • EnableTreeView
      • EnableQuickLaunch
    • WebFeatures
      • Feature (repeats with the ID GUID of each SharePoint Feature used in the template)
    • Structure
      • Element (repeats with each structural element, such as Quick Launch and SharePoint Top Navigation)
    • Files
      • Folder and File nodes define the file structure under the site, including Lists, Shared Documents, _catalogs, _private, _vti_pvt, images, etc. Each File node has a src="" mce_src="" attribute that corresponds to the .000 files contained in the .stp along with the manifest.xml
    • UserLists
      • This is metadata about each of the SharePoint Lists on the site, such as Announcements, Calendars, and any other Lists
    • WorkflowAssociations
Many of the attributes and tags seem to follow the naming conventions used in Front Page
5/28/2007 Restore Production SharePoint 2003 Databases to Test Servers

This entry is designed to walk through the steps needed to backup and restore production SharePoint 2003 databases to test servers.  These steps have worked well for me especially when preparing for a SharePoint 2003 to MOSS 2007 Upgrade.  (This example is based on Microsoft SQL Server 2000.)  See the attached file for a PDF with screenshots.

  1. In production, backup the primary Inetpub directory used by IIS.
  2. Backup C:\Program Files\Common Files\Microsoft Shared\web server extensions\60
  3. Copy SQL database backups (typically *.bak files) and the Inetpub and 60 folders to a temporary area on the target test server for use later.
  4. Log out of Production.
  5. Launch ‘Enterprise Manager’ on the target test SQL server.
  6. Expand Microsoft SQL Servers à SQL Server Group à (local) (Windows NT).  Right click on “Databases” and select “All Tasks” à “Restore Database…”
  7. Choose “From device”.
  8. Click on “Select Devices…”
  9. Click on “Add…”
  10. Click on the button with the three dots to browse.
  11. Browse to the temporary location where the database backup, Inetpub directory, and 60 directories were copied to from Production.
  12. Select the Profiles database.
  13. Select the name of the database embedded in the backup filename and copy it to the clipboard.
  14. Click ‘OK’ three times.
  15. Paste the name of the database into the “Restore as database:” field.
  16. Click on the options tab.
  17. Set the physical filename and path to the new target destination (i.e. d:\MSSQL\data\”Servername”.mdf and d:\MSSQL\data\”Servername”.ldf.)
  18. Click ‘OK’ to begin restore.
  19. When complete, the following message will appear:
  20. Repeat Steps 6 – 19 for the Services and Sites databases.
  21. Log back into the web front-end.
  22. Shutdown all SharePoint and IIS Services.
  23. Rename or move the existing Inetpub directory on test.
  24. Copy the backed up InetPub directory from Production to the location on test that was moved or renamed.
  25. Rename or move the existing C:\Program Files\Common Files\Microsoft Shared\web server extensions\60 directory on test.
  26. Copy the backed up 60 directory from Production into test.
  27. Restart the services stopped in Step 22 or just reboot the server.
  28. Open SharePoint Central Administration.
  29. Click on ‘Create portal site’ under ‘Portal Site and Virtual Server Configuration’.
  30. Choose “Restore a portal”.
  31. Set the names of the databases and select “Default Web Site”.  Click ‘OK’ to continue.
  32. Click ‘OK’ to begin creation.
  33. A successful creation will cause a message resembling the following to appear:
  34. Click on Go to SharePoint Portal Server central administration.
  35. Click on Configure virtual server settings from the Virtual Server List page.
  36. Click on Default Web Site.
  37. Click on Manage content databases.
  38. Click on Add a content database.
  39. Choose “Specify database server settings” and enter the additional content database name (i.e. DB2_SITE).
  40. Set the number of site before a warning to a high number initially (i.e. 90000).  Set the max number of sites to a high number as well (i.e. 100000).
  41. Click Ok to restore the additional database and attach it to SharePoint.
  42. Repeat for all additional content databases.
  43. Reset IIS.
  44. Reinstall any custom web parts that may not be functioning.
5/28/2007 How do i get Word Macros to Work in MOSS/WSS 3.0

Hello

Recently i have installed quite a few MOSS and WSS3.0 servers, and have ran into this problem more than once.

The company has several word templates and quite a few contains differnt macros. They all worked in SPS2003 where you uploaded them to the FORM folder overwriting the template.doc file there - and.... it worked like a charm.

 Today more likely than not you will use content types for templates and the forms library trick dosnt do no more.  But I dont se no reason why the macros shouldnt work.--- well ... but they dont.

I have a working template.doc with macroes and everything, but assigning them as a template from the content type advanced options dosnt work. I DO get the warning - " this doc. contains macroes - you want do run them or disable them" (or something close to that) . and agreeing to load macroes lets the doc load - BUT the macros dosnt work - dont throw no errors either ,but dosnt work.

I found that if i upload the template.doc directely into the doc. library  and start it as any other item the macros works fine Veeeery strange.

I have seen Tods article about writing VSTO-documents - but - comeon - the company in focus has already used a fortune gettin the existing macros done. So rewriting them is not an option.

 Any ideas - anyone?

5/28/2007 Meeting Content Rollup

I have a team site that has a blank meeting site below it.  The blank meeting site contains links to all meetings below it.  I would like a content rollup that takes all major version of documents from the meeting sites and shows them in the shared documents at the team site level.  I also want the same for contacts.  Any attendees of the meetings should rollup into project contacts.  Any action items get rolled up into project tasks.  So the team site will be able to be managed as a project site with Contacts, Team Members, Tasks can be rolled up from Meeting sites.

 Has this been done before?  Are there any web parts that can do this?

5/27/2007 Changing Custom Site Definition Template IDs - SharePoint 2003

The following steps walk through changing custom template IDs so they are greater than 10000 per documented best practices.  Always make sure to backup all databases and files prior to making any changes.

NOTE: This method is not backed by Microsoft.  Use at your own risk.

  • Make a backup copy of all %programfiles%\common files\microsoft shared\web server extensions\60\Template\1033\XML\webtempXXX.xml on all front-end web servers.
  • Open each webtempXXX.xml.  Below is an example webtempXXX.xml file with custom templates.

<Templates>

<Template Name="SPSCONTOSOSERVICES" ID="37">

    <Configuration ID="0" Title="Area Template" Type="0" Hidden="TRUE" ImageUrl="../images/spshome.gif" Description="Contoso Services Template."><!-- _locID@Title="webtemp_title_spstopic0" _locComment="{StringCategory=HTX}" --> <!-- _locID@Description="webtemp_desc_spstopic0" _locComment="{StringCategory=HTX}" --></Configuration>

 </Template>   

 <Template Name="SPSCONTOSOBUSINESSES" ID="38">

    <Configuration ID="0" Title="Contoso Businesses Template" Type="0" Hidden="TRUE" ImageUrl="../images/spshome.gif" Description="Area Template."><!-- _locID@Title="webtemp_title_spstopic0" _locComment="{StringCategory=HTX}" --> <!-- _locID@Description="webtemp_desc_spstopic0" _locComment="{StringCategory=HTX}" --></Configuration>

 </Template>   

 <Template Name="SPSCONTOSOTOPICS" ID="39">

    <Configuration ID="0" Title="Contoso Topics Template" Type="0" Hidden="TRUE" ImageUrl="../images/spshome.gif" Description="Area Template."><!-- _locID@Title="webtemp_title_spstopic0" _locComment="{StringCategory=HTX}" --> <!-- _locID@Description="webtemp_desc_spstopic0" _locComment="{StringCategory=HTX}" --></Configuration>

 </Template>   

</Templates>

  • Replace the IDs with numbers over 10000.  It is easiest just to add a 1 and 0 or 00 in front of the existing template IDs.

<Templates>

<Template Name="SPSCONTOSOSERVICES" ID="10037">

    <Configuration ID="0" Title="Area Template" Type="0" Hidden="TRUE" ImageUrl="../images/spshome.gif" Description="Contoso Services Template."><!-- _locID@Title="webtemp_title_spstopic0" _locComment="{StringCategory=HTX}" --> <!-- _locID@Description="webtemp_desc_spstopic0" _locComment="{StringCategory=HTX}" --></Configuration>

 </Template>   

 <Template Name="SPSCONTOSOBUSINESSES" ID="10038">

    <Configuration ID="0" Title="Contoso Businesses Template" Type="0" Hidden="TRUE" ImageUrl="../images/spshome.gif" Description="Area Template."><!-- _locID@Title="webtemp_title_spstopic0" _locComment="{StringCategory=HTX}" --> <!-- _locID@Description="webtemp_desc_spstopic0" _locComment="{StringCategory=HTX}" --></Configuration>

 </Template>   

 <Template Name="SPSCONTOSOTOPICS" ID="10039">

    <Configuration ID="0" Title="Contoso Topics Template" Type="0" Hidden="TRUE" ImageUrl="../images/spshome.gif" Description="Area Template."><!-- _locID@Title="webtemp_title_spstopic0" _locComment="{StringCategory=HTX}" --> <!-- _locID@Description="webtemp_desc_spstopic0" _locComment="{StringCategory=HTX}" --></Configuration>

 </Template>   

</Templates>

 

  • Open Query Analyzer on the SQL Backend and perform a query resembling the following on all Content Databases:

update webs set webtemplate = 10038 where webtemplate = 37;

update webs set webtemplate = 10038 where webtemplate = 38;

update webs set webtemplate = 10039 where webtemplate = 39;

GO

Replace the numbers in the query with ones specific to the environment.  These numbers must match the ones included in the webtempXXX.xml file(s).

  • Perform an iisreset /noforce on all front-end servers.
  • Launch the portal to verify that the templates are still working properly.

 

5/27/2007 Biometric Authentication for SharePoint

Adam Buenz has gone over the edge with Forms Based Authentication by creating a provider for finger print authentication.

http://www.sharepointsecurity.com/blog/sharepoint/sharepoint-2007-development/biometric-authentication-for-sharepoint/

 

5/27/2007 Personal Sites / Differen Quotas/ Differnet Content DBs

A customer of mine wanted to have the personal sites of the Students and the Teachers separated in different content databases as he wants to provide better operation services for the Teachers.
He also requested to have different sites qouta for students and teachers personal sites.

"In your dreams !!!!", I"d say if we are working on SPS 2003. Backed up with MOSS, I said "What you wish is what you get".

I"ve documented the solution in a .doc and attached it

 Tell me what you think

 

Mohammdu Khalilo

上一页 1 2 3 4 5 6 7 8 9 10 下一页

   

Site List:
>>Xbox Live_s Major Nelson
>>Xbox 360 & SharePoint 2007 Weblog
>>Carsten Keutmann_s Blog
>>Mohamed Zaki_s Blog [Sharepoint MVP]
>>The Mit_s Blog
>>Mart Muller_s Sharepoint Weblog
>>Microsoft SharePoint Products and Technologies Team Blog
>>SharePoint Solutions Blog
>>4GuysFromRolla.com Headlines
>>ASP.NET Blogs
>>SharePoint Blogs
>>SharePoint Blogs
>>Joel on Software
>>ADO Guy_s Rants and Raves
>>Microsoft Live Labs
>>GadgetNews
>>Windows Vista Team Blog
>>VoIP & Gadgets Blog
>>schrankmonster blog
>>Via Virtual Earth Blog
>>Feed
>>MSDN Blogs
>>Mashable!

Links:
Jack's Readings

Month Archives:
Oct 2007
Sep 2007

Top Tags:
social software social networking .NET mashable Sharepoint ASP.NET Web 2.0 Web2.0 Startups Community News Search Marketplace General Software Development AJAX Windows Vista Visual Studio Microsoft myspace Silverlight People Powered! YouTube Vista MOSS Featured News C# Events MOSS 2007 Google WPF Office 2007 Web Community Security General Personal Xbox 360 facebook Tools development SharePoint 2007 Fun Atlas Architecture ASP.NET AJAX myspace codes TheLongTail IIS SQL Server Developers Revenue Sharing Video Pictures WCF Mobile 2.0 Announcements Orcas MIX07 Arcade Team System JavaScript News



@2007 All rights Reserved