Sunday, January 16, 2011

Missing the open button when opening PDF files from SharePoint 2010.

By the default setting of a SharePoint 2010, a users can’t open PDF files and many other files types (see the bottom of the post for all default file type allowed to download http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.allowedinlinedownloadedmimetypes.aspx) direct from SharePoint, neither “Display PDF in browser” mode or in the download popup, where the “open” button is missing.
clip_image001

The thing is SharePoint 2010 adds an additional security header to force the file to be saved to the disk before the users can open it. To fix this the BrowserFileHandling property should be set to “permissive” http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbrowserfilehandling.aspx. This property exist both on a webapplication level http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spwebapplication.browserfilehandling.aspx and a on document library level http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.browserfilehandling.aspx.

To fix this on a webapplication level, by using the GUI.

  1. Open Central Administration
  2. Application Management
  3. Manage Web Applications
  4. Select the webapplication to change
  5. Click General Settings in the ribbon
  6. Scroll down to Browser File Handling and select Permissive
  7. Click on the OK button

clip_image003

To fix this with PowerShell on a webapplication level

Get-SPWebApplication http://vsitsp01 | % { $_.BrowserFileHandling = "permissive"; $_.update() }

To fix this with PowerShell on a document library level

$spweb = Get-spweb http://vsitsp01

$doclib = $spweb.Lists["Documents"]

$doclib.BrowserFileHandling

$doclib.BrowserFileHandling = "permissive"

$doclib.Update()

File types allowed to be download:

application/directx
application/envoy
application/fractals
application/internet-property-stream
application/liquidmotion
application/mac-binhex40
application/ms-infopath.xml
application/msaccess
application/msword
application/oda
application/oleobject
application/onenote
application/pics-rules
application/pkcs10
application/pkcs7-mime
application/pkcs7-signature
application/pkix-crl
application/postscript
application/rtf
application/set-payment-initiation
application/set-registration-initiation
application/streamingmedia
application/vnd.fdf
application/vnd.ms-excel
application/vnd.ms-excel.12
application/vnd.ms-excel.addin.12
application/vnd.ms-excel.binary.12
application/vnd.ms-excel.macroEnabled.12
application/vnd.ms-excel.macroEnabledTemplate.12
application/vnd.ms-excel.template.12
application/vnd.ms-office.calx
application/vnd.ms-officetheme
application/vnd.ms-pki.certstore
application/vnd.ms-pki.pko
application/vnd.ms-pki.seccat
application/vnd.ms-pki.stl
application/vnd.ms-powerpoint
application/vnd.ms-powerpoint.12
application/vnd.ms-powerpoint.addin.12
application/vnd.ms-powerpoint.macroEnabled.12
application/vnd.ms-powerpoint.presentation.12
application/vnd.ms-powerpoint.show.12
application/vnd.ms-powerpoint.show.macroEnabled.12
application/vnd.ms-powerpoint.slide.macroEnabled.12
application/vnd.ms-powerpoint.template.12
application/vnd.ms-powerpoint.template.macroEnabled.12
application/vnd.ms-project
application/vnd.ms-visio.viewer
application/vnd.ms-word.document.12
application/vnd.ms-word.document.macroEnabled.12
application/vnd.ms-word.template.12
application/vnd.ms-word.template.macroEnabled.12
application/vnd.ms-works
application/vnd.ms-xpsdocument
application/vnd.oasis.opendocument.presentation
application/vnd.oasis.opendocument.spreadsheet
application/vnd.oasis.opendocument.text
application/vnd.openxmlformats-officedocument.presentationml.slide
application/vnd.rn-realmedia
application/vnd.visio
application/vnd.visio.webdrawing
application/winhlp
application/x-bcpio
application/x-compress
application/x-cpio
application/x-csh
application/x-dvi
application/x-gtar
application/x-gzip
application/x-hdf
application/x-internet-signup
application/x-iphone
application/x-latex
application/x-miva-compiled
application/x-ms-application
application/x-ms-manifest
application/x-ms-reader
application/x-ms-vsto
application/x-ms-wmd
application/x-ms-wmz
application/x-msaccess
application/x-mscardfile
application/x-msclip
application/x-msdownload
application/x-msmediaview
application/x-msmetafile
application/x-msmoney
application/x-mspublisher
application/x-msschedule
application/x-msterminal
application/x-mswrite
application/x-netcdf
application/x-oleobject
application/x-perfmon
application/x-pkcs12
application/x-pkcs7-certificates
application/x-pkcs7-certreqresp
application/x-sh
application/x-shar
application/x-smaf
application/x-stuffit
application/x-sv4cpio
application/x-sv4crc
application/x-tar
application/x-tcl
application/x-tex
application/x-texinfo
application/x-troff
application/x-troff-man
application/x-troff-me
application/x-troff-ms
application/x-ustar
application/x-wais-source
application/x-x509-ca-cert
audio/aiff
audio/basic
audio/mid
audio/mpeg
audio/wav
audio/x-aiff
audio/x-mpegurl
audio/x-ms-wax
audio/x-ms-wma
audio/x-pn-realaudio
audio/x-pn-realaudio-plugin
audio/x-smd
drawing/x-dwf
image/bmp
image/cis-cod
image/gif
image/ief
image/jpeg
image/pjpeg
image/png
image/tiff
image/vnd.wap.wbmp
image/x-cmu-raster
image/x-cmx
image/x-icon
image/x-jg
image/x-portable-anymap
image/x-portable-bitmap
image/x-portable-graymap
image/x-portable-pixmap
image/x-rgb
image/x-xbitmap
image/x-xpixmap
image/x-xwindowdump
text/calendar
text/css
text/dlm
text/h323
text/iuls
text/plain
text/richtext
text/setext
text/tab-separated-values
text/x-ms-iqy
text/x-setext
text/x-vcard
video/mpeg
video/quicktime
video/x-ivf
video/x-la-asf
video/x-ms-wm
video/x-ms-wmp
video/x-ms-wmv
video/x-ms-wmx
video/x-ms-wvx
video/x-msvideo
video/x-sgi-movie

Sunday, December 12, 2010

Install/Uninstall User Solution Application Wide

Build on this blog post on how to get sandboxed on the farm, I also need to be able to install/uninstall sandboxed solution farm wide. There for I made they have two functions to wrap the install and Uninstall-SPUserSolution SPUserSolution.

The core code is when a call (a version 2) of the Get-UserSolution filter to get the deactiveated solutions and then call the build-in cmdlet Install-SPUserSolution

  1. $gc = Start-SPAssignment
  2. Get-UserSolution -SiteCollection $SiteCollection -Filter $Filter -Verboses:$Verboses | `
  3. Where-Object -FilterScript { $_.Status -eq "Deactivated" } | `
  4. Install-SPUserSolution -Site $SiteCollection -AssignmentCollection $gc
  5. Stop-SPAssignment $gc


The code:

Get sandboxed solution on the farm

How to get all sandboxed (user solution) installed on the SharePoint farm.

  1. $gc = Start-SPAssignment
  2. $gc | Get-SPSite | Get-SPUserSolution
  3. Stop-SPAssignment $gc


The output:



Name                                SolutionId                                                      Status

----                                     ----------                                                         ------


Contacts.wsp                   3089ef04-527e-4b35-a0a2-af5f4df8a71b     Activated


Sandboxed1.wsp              a9240922-c794-433c-acf7-0ce7863b46d0 Deactivated


Sandboxed1.1.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Activated


Sandboxed1.1.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Activated


Sandboxed1.2.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Deactivated


Sandboxed1.wsp              a9240922-c794-433c-acf7-0ce7863b46d0 Activated



It is really simple to get a full list of sandboxed solutions, but the output is not useful, because we can see which site collection the sandboxed solution is store in.



This small PowerShell script will display the site collection url



  1. function Get-UserSolution
  2. {
  3. param(
  4. [Parameter(
  5. Position=0,
  6. Mandatory=$true,
  7. ValueFromPipeline=$true,
  8. ValueFromPipelineByPropertyName=$true)
  9. ]
  10. $SiteCollection
  11. )
  12. process
  13. {
  14. Write-host "Site Collection:" $SiteCollection.Url
  15. $gc = Start-SPAssignment
  16. $SiteCollection | Get-SPUserSolution -AssignmentCollection $gc
  17. Stop-SPAssignment $gc
  18. }
  19. }
  20. Get-SPSite | Get-UserSolution


The output:



Site Collection: http://win-ugka6ujlm21



Name                               SolutionId                                                       Status               
----                                    ----------                                                          ------               
Contacts.wsp                   3089ef04-527e-4b35-a0a2-af5f4df8a71b     Activated            
Sandboxed1.wsp              a9240922-c794-433c-acf7-0ce7863b46d0 Deactivated          
Sandboxed1.1.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Activated            
Sandboxed1.1.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Activated            
Sandboxed1.2.wsp           a9240922-c794-433c-acf7-0ce7863b46d0 Deactivated          
Site Collection: http://win-ugka6ujlm21/my


Site Collection: http://win-ugka6ujlm21/sites/sandbox


Sandboxed1.wsp              a9240922-c794-433c-acf7-0ce7863b46d0 Activated  



The code:

Saturday, November 6, 2010

Windows 7 Favorites and SharePoint

One of the many cool features in Windows 7 is the Favorites

This is a list of “shortcut” that is display in the Windows Explore and in the “save as” dialog in programs like Word.

clip_image001

clip_image003

The Windows 7 Favorites works by creating a shortcut to folder and this goes for WebDav folders to.

To setup the a shortcut to a SharePoint site

To setup the shortcut and you only need to do this one time. Open Word and to go “save as” (the shortcut for this is F12), enter the url for the SharePoint site in the file name (Only the url!) and click enter or click on the save button. Then right click on the clip_image004 and select “Add current location to Farvorites” and wola your SharePoint is add and it is easy to browse next time when you want to save a document. clip_image006

Monday, November 1, 2010

IE 9, site pinning, overlay icons and SharePoint

One of the new thing in IE 9 is the site pinning. A cool new feature that allows a users to add a tab in IE9 to the taskbar. After the tab is added to the taskbar we can, from IE 9, interact with it, like overlay icons and ther is it where SharePoint comes in, as the data provider. I create an announcements list and read the current count from it and set the overlay icons to match the count all through JavaScript.

The results of adding two list items to announcements list image

My code

This is the code in the PlaceHolderAdditionalPageHead content placeholder

  1. <script src="http://ajax.Microsoft.com/ajax/jQuery/jquery-1.4.2.min.js" type="text/javascript"></script>




This is the code in the PlaceHolderMain content placeholder



  1. <span id="statusInfomation">Loading...</span>
  2. <script type="text/javascript">
  3. var loadingIcon = "/_layouts/images/jumplist/search.ico"
  4.  
  5. var getData = function()
  6. {
  7. $.getJSON("/ie9test/_vti_bin/listdata.svc/Ie9TestAnno()/$count", function (data)
  8. {
  9. if(data != 0 && data < 6)
  10. {
  11. var icon = "/_layouts/images/jumplist/num_" + data + ".ico";
  12. setOverlayIcon(icon, "Now got " + data);
  13. }
  14. else if(data == 0)
  15. {
  16. setOverlayIcon("", "Now got " + data);
  17. }
  18. });
  19. }
  20.  
  21. function setOverlayIcon(url, text)
  22. {
  23. $("#statusInfomation").html(text);
  24. if(url != "")
  25. {
  26. window.external.msSiteModeSetIconOverlay(url, text);
  27. }
  28. else
  29. {
  30. window.external.msSiteModeClearIconOverlay();
  31. }
  32. }
  33.  
  34. $(document).ready(function()
  35. {
  36. setOverlayIcon(loadingIcon, "Loading...");
  37. setInterval(getData, 5000);
  38. });
  39. </script>




In function in line 21, is where I interact with the overlay icons, pure magic :D



- Happy IE 9 coding