何小碩's profileGet More... ExperiencePhotosBlogListsMore ![]() | Help |
|
January 31 Colour (color) Calendar(2)The in-built calendar view is SharePoint 2007 is a heck of a lot better than the one in 2003 but it still lacks a feature requested by many customers - the ability to colour (or color for our US friends) code the entries like you can in Outlook. <script> You should now have a coloured calendar! Month, week and day views should appear coloured. Remember that if you place a calendar web part on a site that you will need a hidden content editor web part containing the javascript as well. comes from:http://planetwilson.blogspot.com/2007/09/sharepoint-2007-colour-color-calendar.html Colour (color) Calendar(1)I have finished working on what I hope is the final version of the colour calendar. ref:http://planetwilson.blogspot.com/2008/02/version-2-of-colour-calendar-released.html January 29 在 MOSS 中新增一變更密碼頁面來供使用者進行密碼變更
January 12 Convert Sub-Site To Site CollectionI finally figured it out! This was supposed to be one of those very simple tasks that I should have been able to do without any custom code. Turning a sub-site (or web) into a site collection (or top level site) turned out to be the most difficult task I've yet to face with SharePoint 2007. In theory you should be able to do this using the following commands which could be put into a batch file: REM Create a test web for exporting stsadm -o createweb -url "http://intranet/testweb" -sitetemplate "SPSTOPIC#0" REM Export the test web to the filesystem stsadm -o export -url "http://intranet/testweb" -filename "c:\testweb" -includeusersecurity -versions 4 -nofilecompression -quiet REM Create a managed path for the new top level site stsadm -o addpath -url "http://intranet/testsite" -type explicitinclusion REM Create an empty site with a default site template (note that if you don't specify a template you have to manually activate the required features) stsadm -o createsite -url "http://intranet/testsite" -owneremail "someone@example.com" -ownerlogin "domain\username" -sitetemplate "SPSTOPIC#0" REM Import the site stsadm -o import -url "http://intranet/testsite" -filename "c:\testweb" -includeusersecurity -nofilecompression -quiet Unfortunately what you get is only a partially functional site (and in some case not functional at all). There are several errors that you are likely to encounter after running the above using the created testweb or your own existing web. The first and most obvious error is that when you load the default.aspx page of the new site you may get a File Not Found error (note that running the above as is will not give you this error). This is the result of the publishing pages PageLayout URL getting messed up (effectively still pointing to an old value). I addressed this specific issue with a separate command (http://stsadm.blogspot.com/2007/08/fix-publishing-pages-page-layout-url.html) and the I've encapsulated that functionality into the new commands I've created which are detailed below. The next error you're likely to see is on the Area Template Settings page (Site Settings -> Page layouts and site templates). The specific error is "Data at the root level is invalid. Line 1, position 1".
For a top level site collection this value should always be either an empty string (all page layouts are available) or XML describing which layouts are available. The import operation does not consider this and leaves the value as is thus resulting in the XML error when attempting to parse "__inherit" as XML. The fix for this is simple enough - change the value to an empty string. Unfortunately that's not all we have to do. Fixing the above error results in the page loading without errors, however, the page layouts section does not load. There's still several issues that need to be resolved. If you now go and view the master gallery (Site Settings -> Master pages and page layouts) you should see all the default page layouts. If you have any custom page layouts those won't exist and will cause problems. Also, if you attempt to edit a file you'll notice that even though we used a publishing template it doesn't prompt you to check the file out. What's more is that once you view the form for a layout you should see that only the core fields are present (no Content Type, Associated Content Type, Variations, etc.).
Third we have to change the ContentType field from being a Text field to being a Choice field (more about this in a minute). Fourth we need to re-associate each file as a Page Layout file by setting all the necessary properties (Content Type, Associated Content Type, etc.). In regards to changing the ContentType field this is the one that caused me the most headache to figure out. For some reason during the import of the site this field gets a bit messed up (note that I'm not referring to the ContentType field that is linked in from the Page content type which is associated with the library but rather another field that is part of the gallery definition itself). The field should be a Choice field with options such as "Page Layout", "Publishing Mater Page", "Master Page", and "Folder". However, during the import the field is converted to a Text field - don't ask me why. The result is that when you query for the list of available page layouts the unmanaged code that Microsoft uses to do the actual query chokes because it can't find a matching value in the list so it produces an invalid query which will always return no results back. Unfortunately there's no way to programmatically change this back to a Choice field using the provided API as going from a Text field to a Choice field is unsupported (I don't really understand why - seems it should be supported so long as the Choice field allows fill-ins). To fix this I had to hack the database - there's a table called AllLists which stores the definition of the gallery in a field called tp_fields - the definition is an XML file so I simply had to figure out what the XML should be and set it accordingly. UPDATE 9/4/2007: I just discovered that another issue is related to the global navigation. If you view the navigation via the browser it will look as though everything is just peachy but if you attempt to manipulate the navigation programmatically you'll find that the PublishingWeb's GlobalNavigationNodes property is empty (no items are present). This is because the global navigation is stored at the site collection level so when you import the web it does not take the global navigation with it, just the current. The fix is simple enough - just loop through the current navigation collection and copy it to the global navigation collection. This will help to allow other programmatic manipulations of the global navigation to succeed. So, to summarize the things that need to be repaired after importing into your empty site collection:
Some of the above can be done via the browser but most of it requires programmatic changes. In order to solve all these problems I've created two custom stsadm commands - the first will take a site make all the repairs identified above (so it assumes you've already imported the site). The second basically just abstracts the whole process of exporting a web, creating a site, importing into the site, and then repairing the site (this way the entire process can be done with just one command). The commands I created are detailed below (forgive the verbosity of the names - I had trouble coming up with something shorter). 1. gl-repairsitecollectionimportedfromsubsite The code is fairly well documented so rather than discuss it all (there's a lot of it) I've linked it to this post here. The syntax of the command can be seen below: C:\>stsadm -help gl-repairsitecollectionimportedfromsubsite
stsadm -o gl-repairsitecollectionimportedfromsubsite
Repairs a site collection that has been imported from an exported sub-site. Note that the sourceurl can be the actual source site or any site collection that can be used as a model for the target.
Parameters:
-sourceurl <source location of the existing sub-site or model site collection>
-targeturl <target location for the new site collection>
Here’s an example of how to repair the site created using the batch file above:
2. gl-convertsubsitetositecollection As stated above, this command is just an abstraction of other commands - it simply calls out to stsadm to do export the site (note that you can provide a previously exported site file/folder), create the managed path, create the empty site, import the site, and finally repair the imported site. As there's nothing spectacular going on here I didn't bother culling the code out in this post (download the project if you're interested in the details). The syntax of the command can be seen below: C:\>stsadm -help gl-convertsubsitetositecollection
stsadm -o gl-convertsubsitetositecollection
Converts a sub-site to a top level site collection via a managed path.
Parameters:
-sourceurl <source location of the existing sub-site or model site collection>
-targeturl <target location for the new site collection>
[-createmanagedpath]
[-exportedfile <filename of exported site if previously exported>]
[-nofilecompression]
[-ownerlogin <DOMAIN\Name>]
[-ownername <display name>]
[-secondaryemail <someone@example.com>]
[-secondarylogin <DOMAIN\Name>]
[-secondaryname <display name>]
[-lcid <language>]
[-sitetemplate <site template if exportedfile is specified - must match the template of the exported site>]
[-nositetemplate][-title <site title>]
[-donotcreatesite (specify if the site to import to already exists)]
[-description <site description>]
[-hostheaderwebapplicationurl <web application url>]
[-quota <quota template>]
[-deletesource]
Here's an example of how to do all that the batch file above is doing (minus the creation of the testweb) as well as the repair operation all with one command:
One area of improvement may be to pull the owner and secondary owner information from the source site collection so that this information does not have to be provided - maybe I'll do that if I feel I have the time or if people express enough interest. Note that you can specify a title and description but they'll be overwritten during the import - I only included them so that if the import fails and you're left with an incomplete site you'll at least have a name for it if you should forget to delete it and stumble upon it a year later. Figuring out how to solve all the issues surrounding converting a web to a site collection was a real pain the a$$ so any feedback that people have on this would be greatly appreciated - hopefully if there are others out there that have stumbled on this then they'll benefit from it as well. Keep in mind also that though I think I've solved all the errors related to the conversion it's possible that different implementations may have additional errors that I have not seen - if that's the case please let me know (especially if you've solved the problems) so that I can share with others. Please note that because these commands update the database directly using them could, according to Microsoft, put your environment into an un-supported state. Please make sure you understand what the commands are doing and what your support options with Microsoft are. Update 9/21/2007: I've fixed a couple minor bugs that pop up when converting a non-publishing site. I've also enhanced the command to take advantage of another new command I created: gl-updatev2tov3upgradeareaurlmappings (updates the url mapping of V2 bucket webs to V3 webs thereby reflecting the change of url as a result of the move so if a user tries to hit the V2 url it will redirect to the new and updated V3 url). Update 10/2/2007: I've enhanced the command to take advantage of another new command I created: gl-retargetcontentquerywebpart (fixes Grouped Listings web parts that remained pointed at the old list rather than the newly imported list). Update 10/12/2007: I've removed the retainobjectidentity parameter. If you attempt to use this parameter you will receive a syntax error. Turns out that retaining the object identity when going from a sub-site to a site collection just created a nightmare. However, because I still had to handle these web parts that were broken I decided to enhance the repair routines to manually retarget the DataFormWebPart and ContentByQueryWebPart web parts. So if a matching list can be found on the source then any of these web parts on your pages should be fixed so that you don't have to manually fix them (the gl-repairsitecollectionimportedfromsubsite command will do the same). Posted by Gary Lapointe at 9:11 AM 子網站的 Quota 怎麼設... 這樣設...SharePoint Site Quota Web PartIn SharePoint all user content i.e. documents, list items etc is stored in the Content Database associated with a Site Collection. One question that administrators always ask is if they can restrict the database\disk usage for a given Site Collection. This is really usefull for My Sites and the good news is that this functionality is provided OOTB using Quotas. The concept is that you create a Quota template by using UI elements in Central Administration, the template collection is available as a drop down list when ever you are provisioning a new Site Collection on the New Site Collection page. Adding and removing quotas can also be done any time after the site is created. So far so good, today my colleague Joshua (Joshua Tan) relayed the requirements of a current project where the customer wanted to keep the users informed of thier quota use and I put on my code churn cap. To restate, the problem is how to communicate quota usage to users so they know if they have space remaining on thier MySites or any other Site for that matter. Showing the user the amount of quota left/used should not be too hard? I asked my self and it turned out to be easier then I thought! In less then 30 minutes I had a basic working prototype. Given below are glory shots of the Site Quota web part in action. You can always add additional details like the amount of disk space available and maybe other improvements which I have listed at the end.
Here is the code I wrote with the usefull parts highlighed. It is provided as-is, use at your own risk: using System; using Microsoft.SharePoint; namespace SiteQuotaWebPart A number of improvements come to mind and will be added in the final production release:
comes from 這個人 http://raiumair.wordpress.com/2007/07/12/site-quota-web-part/ |
||||||||||||||
|
|