/// <summary> /// Provision all pending customizations to specified web. /// Customizations will be shown on specified list pages, for lists with specified ID (this can be your custom list template ID), /// to users with appropriate rights. /// </summary> /// <param name="featureUniqueGuid">Guid, needed for feature-scoped cleanup in FeatureDeactivating using <see cref="RibbonCustomAction.RemoveAllCustomizations"/> method.</param> /// <param name="userCustomActions">Collection of custom actions of web or list (web.UserCustomActions or list.UserCustomActions)</param> /// <param name="templateId">Custom list template Id, for which ribbon elements will be registered</param> /// <param name="whichForms">List forms, which will display the ribbon</param> /// <param name="rights">Rights user needs to access the ribbon</param> /// <returns>Id of provisioned custom action</returns> // Overloads for this method are in "RibbonCustomAction/ProvisionOverloads.cs" public Guid Provision(Guid featureUniqueGuid, SPUserCustomActionCollection userCustomActions, string templateId, ListForms whichForms, SPBasePermissions?rights) { var customAction = userCustomActions.Add(); customAction.Name = "Hemrika.SharePresence.Common.Ribbon._" + featureUniqueGuid.ToString().Replace("-", "") + "._" + Guid.NewGuid().ToString().Replace("-", ""); customAction.Location = GetRibbonLocationByListForms(whichForms); customAction.CommandUIExtension = XmlGenerator.Current.GetCommandUIExtensionXML(RibbonXML, RibbonCommandsXML, RibbonTemplatesXML); if (customAction.Scope != SPUserCustomActionScope.List) { if (String.IsNullOrEmpty(templateId) || templateId == ((int)ListTypes.All).ToString()) { customAction.RegistrationType = SPUserCustomActionRegistrationType.ContentType; customAction.RegistrationId = "0x"; } else if (templateId != ((int)ListTypes.None).ToString()) { customAction.RegistrationType = SPUserCustomActionRegistrationType.List; customAction.RegistrationId = templateId; } } if (rights.HasValue) { customAction.Rights = rights.Value; } customAction.Update(); return(customAction.Id); }
public SPUserCustomActionInstance Add() { var result = m_userCustomActionCollection.Add(); return(result == null ? null : new SPUserCustomActionInstance(Engine.Object.InstancePrototype, result)); }
public static void AddECBMenu(this SPList list, string title, string location, string url, SPBasePermissions basePermission) { SPUserCustomActionCollection spUserCustomActionCollection = list.UserCustomActions; var spUserCustomAction = spUserCustomActionCollection.FirstOrDefault(p => p.Title == title); if (spUserCustomAction == null) { spUserCustomAction = spUserCustomActionCollection.Add(); spUserCustomAction.Location = location; spUserCustomAction.Sequence = 100; spUserCustomAction.Title = title; if (basePermission != null) { spUserCustomAction.Rights = basePermission; } spUserCustomAction.Url = url; spUserCustomAction.Update(); } }
private void DeploySiteCustomAction( object modelHost, UserCustomActionDefinition customActionModel) { SPUserCustomActionCollection userCustomActions = null; var existingAction = GetCurrentCustomUserAction(modelHost, customActionModel, out userCustomActions); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioning, Object = existingAction, ObjectType = typeof(SPUserCustomAction), ObjectDefinition = customActionModel, ModelHost = modelHost }); if (existingAction == null) { TraceService.Information((int)LogEventId.ModelProvisionProcessingNewObject, "Processing new user custom action"); existingAction = userCustomActions.Add(); } else { TraceService.Information((int)LogEventId.ModelProvisionProcessingExistingObject, "Processing existing user custom action"); } MapCustomAction(existingAction, customActionModel); InvokeOnModelEvent(this, new ModelEventArgs { CurrentModelNode = null, Model = null, EventType = ModelEventType.OnProvisioned, Object = existingAction, ObjectType = typeof(SPUserCustomAction), ObjectDefinition = customActionModel, ModelHost = modelHost }); existingAction.Update(); }