The IBookmarkableContentType interface provides support for bookmarking content.
[toc]
Why should I make my content bookmarkable?
It can be important for users to save content. If you are creating a schedule users may want to return to this content and review it for changes.
Creating an IBookmarkableContentType plugin
IBookmarkableContentType is defined in the Telligent.Evolution.Extensibility.Content.Version1
namespace of Telligent.Evolution.Core.dll
.
It is important to note that one or more Core Services can be implemented in the same IContentType class.
This interface is similar to the others, it requires you to define whether a user can bookmark or unbookmark content. It also should return if the content supports bookmarks. In this sample we arbitrarily selected the Read Group Members permission but any permission can be defined here.
public bool CanBookmark(Guid contentId, int userId) { return CanUseBookmarks(contentId, userId); } public bool CanUnBookmark(Guid contentId, int userId) { return CanUseBookmarks(contentId, userId); } public bool SupportsBookmarks { get { return true; } } private bool CanUseBookmarks(Guid contentId, int userId) { var content = LinksData.GetLink(contentId); if (content == null) { return false; } var read = new Guid("4F692E0C-9CAB-4d09-9126-684FAF41A085"); var permission = Apis.Get<IPermissions>().Get(read, userId, content.ContentId, content.ContentTypeId); return permission.IsAllowed; }
Here is the full sample.
using System; using System.Collections.Generic; using System.Linq; using Telligent.Evolution.Extensibility; using Telligent.Evolution.Extensibility.Api.Entities.Version1; using Telligent.Evolution.Extensibility.Api.Version1; using Telligent.Evolution.Extensibility.Content.Version1; using IContent = Telligent.Evolution.Extensibility.Content.Version1.IContent; namespace Samples.Links { public class LinkItemContentType : IContentType, IBookmarkableContentType { IContentStateChanges _contentState = null; #region IPlugin Members public string Description { get { return "Items in a Links collection"; } } public void Initialize() { } public string Name { get { return "Link Items"; } } #endregion #region IContentType Members public Guid[] ApplicationTypes { get { return new Guid[] { ContentTypes.LinksApplicationId }; } } public void AttachChangeEvents(IContentStateChanges stateChanges) { _contentState = stateChanges; } public Guid ContentTypeId { get { return ContentTypes.LinksItemId; } } public string ContentTypeName { get { return "Links Item"; } } public IContent Get(Guid contentId) { return LinksData.GetLink(contentId); } #endregion #region IBookmarkableContentType public bool CanBookmark(Guid contentId, int userId) { return CanUseBookmarks(contentId, userId); } public bool CanUnBookmark(Guid contentId, int userId) { return CanUseBookmarks(contentId, userId); } public bool SupportsBookmarks { get { return true; } } private bool CanUseBookmarks(Guid contentId, int userId) { var content = LinksData.GetLink(contentId); if (content == null) { return false; } var read = new Guid("4F692E0C-9CAB-4d09-9126-684FAF41A085"); var permission = Apis.Get<IPermissions>().Get(read, userId, content.ContentId, content.ContentTypeId); return permission.IsAllowed; } #endregion } }