Sunday, November 13, 2011

Extend SharePoint 2010 User Interface for Lists - Ribbon, Menus & Toolbars

In my previous post, I demonstrated how to customise the User Interface for Libraries in SharePoint 2010 by adding links / custom actions in existing Menus, the Ribbon and Document Library Settings pages.
This post follows on by demonstrating how to customise the interface for different types of lists built into SharePoint 2010 by adding new custom actions to the menus and existing groups in the Ribbon.

Contents:

1. Extending the User Interface for Items
  • 1.1 Add a custom link to the List Item Menu (ECB / LIM) for an Announcements list
  • 1.2 Add a Custom Action to the “Manage” group in the Events tab of a Calendar / Events List
2. Customise the “New” menu and “New” Group on Ribbon for a Task List in SharePoint 2010
  • 2.1 Add a Link to the New menu for a Task List
  • 2.2 Add a Custom Control to the existing New Group in the Items tab on the Ribbon for a Task List
3. Add a link to the Custom Actions Group for a Links List in SharePoint 2010
  • 3.1 Add a Custom Action to the Actions Menu and “Custom Actions” tab for a Links list in SharePoint 2010
  • 3.2 Add A Custom Link to the existing “Share & Track” group on the List tab of the Ribbon for a Links List
  • 3.3 Add A Custom Link to the Manage Views Group on the List tab of the Ribbon
4. Add a link to the Settings Groups for a Calendar / Events List in SharePoint 2010
  • 4.1 Add a custom link to the Settings menu for a Calendar list in SharePoint 2010
  • 4.2 Add a Custom Action to the Settings Group on the Ribbon for a Calendar in SharePoint 2010
  • 4.3 Add a Custom Button / Link to the “Customize List” group in the Calendar tab on the Ribbon
5. Add custom links to the Settings page for a Discussion Board in SharePoint 2010
  • 5.1 Add a custom link to an existing group/heading on the Settings page for a Discussion Board in SharePoint 2010



Monday, November 7, 2011

SharePoint 2010: Extend the Document Library Menus, Ribbon and Settings Interface

In this tutorial I demonstrate how to customise the interface for Document Libraries in SharePoint 2010 using Custom Actions. I explain how to target specific types of Libraries built-in to SharePoint, and how to include additional links/actions to menus, the Server Ribbon and settings pages associated with Document Libraries.

This tutorial covers the following:

RegistrationId’s for Document Library types in SharePoint 2010
A list of Registration ID used to target specific types of Document Libraries built-in to SharePoint 2010 when adding new links / controls to the built in Interface.

1. Customise the Interface for the New Menu and Ribbon Group
  • 1.1 Add a link to the New Menu for a Document Library in SharePoint 2010
  • 1.2 Add a control to the “New” Group on the Ribbon for a Document Library in SharePoint 2010

2. Customise the Interface for the Actions Menu and Library Action Groups on the Ribbon
  • 2.1 Add a link to the Actions menu for a Document Library in SharePoint 2010
  • 2.2 Add a Control to the View Format Group on the Ribbon for a Document Library
  • 2.3 Add a Control to the “Connect & Export” group on the Ribbon for a Document Library (Document Library Actions)
  • 2.4 Customise the Share & Track Group

3. Customise the Settings Menu and Library Management / Settings Groups on the Ribbon
  • 3.1 Add a link to the Settings Menu for a Document Library in SharePoint 2010
  • 3.2 Add A Control to the Customise Library Group on the Ribbon for a Document Library
  • 3.3 Add A Control to the Settings Group on the Ribbon for a Document Library

4. Item Level Customisations to the Interface and Ribbon
  • 4.1 Add a link to the Edit Control Block (item drop-down) menu for a Document
  • 4.2 Add a Control to the “Manage” group on the Ribbon for Documents
  • 4.3 Add a Control to the “Share & Track” (Share) Group on the Ribbon for a Document Library
  • 4.4 Add a Control to the “Workflows” Group on the Ribbon for a Document Library

5. Customise the Document Library Settings Page
  • 5.1 Add a link to the Settings Page for a Document Library in SharePoint 2010



Wednesday, October 26, 2011

Tutorial: Add Custom List actions using SharePoint Designer 2010

One of the new features of SharePoint 2010 is the ability to easily add Custom Actions buttons to the Ribbon, List item menu and the built-in forms (Display, Edit and New).  This can be done with SharePoint Designer 2010 and the “Custom Actions” functionality.  In this tutorial I explain how to use this feature to add custom action buttons to various parts of the UI for lists and libraries in SharePoint 2010.

There are a number of ways which you can access this functionality, which all require SharePoint Designer 2010.  Depending on the method used to add a Custom Action to a list, certain options may or may not be available to customise what the Custom Action does when clicked, or where it appears in the Interface for the list.  

For example, when you are viewing a list or library in your web browser, there is a “New Quick Step” button on the Ribbon in the “Customize List” group.



(Add a Quick Step to start a Workflow)
Using this option will add a Custom Action to the list, but limits the functionality to starting an existing or new Workflow associated with the list.  Once the Custom Actions has been configured, it will be added to the Ribbon on the “Items” tab in a group called “Quick Steps” (Button Location = View Ribbon).



When viewing the list using SharePoint Designer 2010, there are two places that can be used to add Custom actions to the list.  One is using the “Custom Action” drop-down option on the Ribbon, and the other is by pressing the “New...” button on the Custom Actions Section on the List Settings page.

(Add a Custom Action to the List Item Menu)
When you use the “New...” button from the Custom Actions section on the settings page, this will add the Custom Action to the List Item Menu / LIM (The List Item Menu in SharePoint 2010 was known as the ECB menu (Edit Control Block) in earlier versions of SharePoint).  Once the Custom Action has been created, it will be accessible from the drop-down menu of items in the list or library.  When using this option to add a Custom Action, there are additional fields included to specify the “Rights Mask” and “Sequence Number” for the action.

Add a Custom Action from the settings page:


Using the “New...” button, the Custom Action is able to navigate to one of the Forms associated with the list, Start a new or existing Workflow or Navigate to a URL.








Custom Action Rights Mask (Display a Custom Action to users based on their Permissions):
The Rights Mask accepts one or more base (built-in) permissions for SharePoint which are used to control which users will see the Custom Action.  For example, entering “EditListItems” into the Rights Mask field will result in the Custom Action being displayed to only users with access to edit items in the lust.  A full list of the accepted values for the Rights Mask can be viewed here: SPBasePermissions.  

Sequence Number Field for Custom Actions
The sequence number field is a little more self explanatory, where it accepts a whole number (integer) which is used to determine the order in which the action will be displayed on the List Item Menu.

Adding a Custom Action to New, Edit and Display Forms, the View Menu or List Item Menu
Using the “Custom Action” drop-down on the Ribbon when viewing the settings of a list in SharePoint Designer 2010 gives much greater control over where the action will be displayed on the interface for the list or list items, as well as the what the action itself can do.

Add Custom Action From the Ribbon




On the Custom Action Dropdown, there are additional areas listed for where the action will be displayed, which include adding to the LIM and View Ribbon, but are not limited to one of these similar the previous methods explained:
  • List Item Menu - Adds a Custom Action to the item menu similar to using the “New...” button.
  • Display Form Ribbon - Adds the custom action to the Ribbon for the display form when viewing the properties of a list item or document.
  • Edit Form Ribbon - Adds the Custom Action to the Ribbon when editing the properties of a list item or document
  • New Form Ribbon - Adds the Custom Action to the Ribbon when adding a new item to the list.
  • View Ribbon - Adds the Custom Action to the Ribbon when viewing the list if items in the List or Library, similar to using the “Add a Quick Step” option explained earlier.

When adding a Custom Action to a list or library using this drop-down menu on the SharePoint Designer Ribbon, the functions available for the action is the same as using the “New...’ button (navigate to one of the Forms associated with the list, Start a new or existing Workflow or Navigate to a URL).  Using this method to create a Custom Action, there is also an additional field called “Ribbon Location (Tab.Group ID)” available, which is used to specify where in the Interface the button or link will appear.  The value in this field is set automatically based on selection of the where the action is to be added.  The “Rights Mask” and “Sequence Number” fields explained earlier are also included when using this method.  






Related:
Add Custom Links to the Interface as a Site Feature with or without using Visual Studio - This post explains how to add custom actions to the interface in SharePoint 2010 using a Feature added to a project in Visual Studio 2010, or by manually creating the feature xml file using a text editor and enabling using PowerShell or STSADM.





Restrict Custom Links in the User Interface based on Permissions - This post explains how to apply restrictions to Custom Actions based on user permissions.  The custom links are the displayed only to users with the specified permission level on the site, list or item.


Add User Control to Master Page Using SharePoint Designer 2010 - This article explains how to add a custom User Control to pages in SharePoint 2010 such as a Master Page or, Page Layout or Application page.



SharePoint Master Page: Include Title of a Site as a link to the Site’s Homepage - This article explains how to add a link to a Master Page or page in SharePoint 2010 that points to the Homepage of the current site with the title of the site as the link/anchor text.   This can be done using SharePoint Designer or Visual Studio when editing the source of the page.

Monday, October 24, 2011

Add Custom Links to the SharePoint 2010 UI as a Feature with or without using Visual Studio

In this article, I demonstrate the process of adding a custom link and group to the UI in SharePoint as a Site Feature without using Visual Studio, as well as using Visual Studio.  

In some cases you may not have Visual Studio installed on a Server running SharePoint, or may just want to quickly add a custom link in the interface such as on the Site Settings page, or the Actions or Settings menu for a Document Library or List.  In other cases you may have a project in Visual Studio containing new functionality to be deployed to a SharePoint environment, that needs to be accessed through adding custom links to the UI.  It makes sense to deploy the custom links as part of the solution feature, so I also explain how to achieve this from a Visual Studio Project.


Apply Permissions to Custom UI Links / Actions in SharePoint Menus and Settings Pages

This post explains how to incorporate permissions into custom links and actions added to the UI on menus, toolbars and default layout pages such as the Site Settings page in SharePoint 2010.  



 
Examples included in the post are:
  • Restricting custom links on list settings pages to only site collection administrators
  • Adding custom actions to the Document Library dropdown menu (ECB - Edit Control Block) that are displayed only to users with edit permissions on the document.
  • Displaying a link on the Site Actions menu only to users with access to manage  permissions for the current site.
  • Displaying a custom link on the List Actions menu for users with access to manage the list.
  • Display a link on the Site Settings page of a site to users with access to add and customise pages on the site, as well as apply themes and stylesheets to the site (Site Designers).

Saturday, October 22, 2011

SharePoint Application Page Security

This article covers information relating to security for Application pages and page components in SharePoint:
  • Selecting the correct base class to inherit from when developing Application Pages in SharePoint
  • Securing Application pages with user permissions
  • Specifying when the CheckRights method is called to determine if a user has access to the page.
  • Programmatically check if the user has permission to access the page
  • Code Access Security (CAS) Policy for SharePoint Components

Tuesday, October 18, 2011

SPBasePermissions Usage With (Programmatic) and Without Code

In this post, I list some of the properties and methods that return a SPBasePermissions enum, and some methods that take SPBasePermissions as a parameter when checking if a user has certain rights on an object in SharePoint.  Later in the post I also explain how the permission masks with SPBasePermissions can be used to customise (show / hide ) content and custom UI actions / links without using code.

Programmatic uses of SPBasePermissions to check for or set permissions on various objects in SharePoint


The following are some of the more common components in SharePoint that can be used to get or set permissions, or check if certain permissions are effective for a user on the object.

Get or set the Base Permissions for a Role Definition in a Web
SPWeb.RoleDefinitions.BasePermissions

Get the current or specified user’s effective SPBasePermissions on an object (SPWeb, SPList, SPListItem, etc.) Username passed as String to GetUserEffectivePermissions():
SPSite
SPSite.EffectiveBasePermissions
SPSite.GetEffectiveRightsForAcl(SPReusableAcl)

SPWeb
SPWeb.EffectiveBasePermissions
SPWeb.GetUserEffectivePermissions(String)

SPList
SPList.EffectiveBasePermissions
SPList.EffectiveFolderPermissions
SPList.GetUserEffectivePermissions(String)

SPFolder
SPFolder.EffectiveRawPermissions

SPFile
SPFile.EffectiveRawPermissions

SPListItem
SPListItem.EffectiveBasePermissions
SPListItem.GetUserEffectivePermissions(String)


Check if the current or specified user has the specified permissions and throws UnauthorizedAccessException if not:
SPSite.CheckForPermissions(SPReusableAcl, SPBasePermissions)
SPWeb.CheckPermissions(SPBasePermissions)
SPList.CheckPermissions(SPBasePermissions)
SPListItem.CheckPermissions(SPBasePermissions)

Returns true/false indicating if the user has the specified permission(s)
SPSite
SPSite.DoesUserHavePermissions(SPReusableAcl, SPBasePermissions)
SPSite.DoesUserHavePermissions(SPReusableAcl, SPBasePermissions, SPWeb)

SPWeb
SPWeb.DoesUserHavePermissions(SPBasePermissions)
SPWeb.DoesUserHavePermissions(String, SPBasePermissions)

SPList
SPList.DoesUserHavePermissions(SPBasePermissions)
SPList.DoesUserHavePermissions(SPUser, SPBasePermissions)

SPListItem
SPListItem.DoesUserHavePermissions(SPBasePermissions)
SPListItem.DoesUserHavePermissions(SPUser, SPBasePermissions)

Layout Page Base - Permissions required to access a LayoutPageBase
LayoutsPageBase.RightsRequired
LayoutsPageBase.DefaultLayoutsRights

Trimmed Content on a Page (Get or set permissions)
SPSecurityTrimmedControl.Permissions

Base permissions associated with a SPPermission object
SPPermission.BasePermissions

Get base permissions required to use a ConsoleAction object or ConsoleNode
ConsoleAction.UserRights
ConsoleNode.UserRights

Get permissions required to see the developer dashboard
SPDeveloperDashboardSettings.RequiredPermissions

Get or set the permissions for a web application
SPWebApplication.RightsMask
SPSite.ApplicationRightsMask

Permissions required to access a Mobile Page
SPMobilePage.RightsRequired

Toolbar Menu Button
ToolBarMenuButton.CallbackVisibilityPermission

Others:
SPSecurableObject.GetUserEffectivePermissions(String UserName)
SPRibbon.Permissions
MenuItemTemplate.Permissions
SPUserCustomAction.Rights


Show / Hide content in SharePoint based on the built-in permissions in SharePoint without code.


The SPBasePermissions Enum contains a number of built-in permissions that can be used in a number of ways, including showing or hiding content for a user based on their access level to a site, list or item, restricting custom links and actions added to the UI, securing application pages and much more.  When creating a .aspx page or Master Page in SharePoint SPSecurityTrimmedControl class has a PermissionsString parameter that accepts a comma separated list of SPBasePermissions which a user must have for the child content or controls to be displayed to the user.

SharePoint: Show or Hide Content based on Permissions provides an example usage of the SPSecurityTrimmedControl class with various permissions from the SPBasePermissions enum to include content on a Master Page that is visible to users with full access to a site, or a user with access to manage lists on the site.  The example includes a “View All Site Content: link as content near the top of the page, which is visible only to users with the matching permissions.  References to the relevant documentation

For additional examples for a number of specific scenarios, the article Permission Based Content in SharePoint (With Examples) provides configuration of the SPSecurityTrimmedControl class and various SPBasePermissions to achieve each.  Some of the examples include displaying content or controls only to users with full access to a site, showing content for users with access to manage permissions on a site and displaying content to uses with add, edit and modify permissions on list items in a list.  The article also demonstrates usage of the SPSecurityTrimmedControl class and the AuthenticationRestrictions attribute to show or hide content to users who are authenticated or anonymous.

SPBasePermissions are also used when adding custom links and actions to the User Interface in SharePoint such as the Site or List Settings page, the Actions or Settings menu on lists and libraries and the list item dropdown (ECB Edit Control Block) menu.  Associating one or more of the built-in permissions with these custom actions will mean that a user much have each of the permissions on the item, list or site for the Custom action to be displayed.