Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

  • 4/7/2015
  • 7710 Views

Comments

7710 Views

Journal

Last updated long time ago

Comments

Common

(Enter the content of this article below)

Advanced

 
DotNetNuke 6.2.0 introduced the journal - an activity feed which enables community members to interact by posting and replying to status updates, following users and sharing links, files, photos and videos.



API

This section explains ways developers can interact with the journal module in their own modules.

Journal Types

Journal types are a way of associating a content object or action with a localized user interface template exposed by the journal (meaning, the formatting of the individual posts in a journal’s activity stream). As of DotNetNuke 6.2 the core ships with 32 pre-defined journal types (located in the Journal_Types table) which include content objects and actions such as: photo, file, video added, video updated, etc.

The reason for limiting the journal types is because each journal type needs a corresponding template. For site administrators, the task of maintaining even the default number of templates is probably higher than they care it to be so limiting the number of types limits the number of templates to manage. It should also be noted that the journal module's SharedResources.resx is where these templates are stored and that one named journal_generic.Text is used when a corresponding journal_type.Text is not found.

The sample code below is used for determining the proper journal type id necessary when posting to the journal via module integration.


/// <summary>
/// Returns a journal type associated with adding a task.
/// </summary>
/// <param name="portalId"></param>
/// <returns></returns>
private static int GetTaskAddJournalTypeId(int portalId)
{
var colJournalTypes = (from t in JournalController.Instance.GetJournalTypes(portalId) where t.JournalType == Constants.JournalTaskAddName select t);
int journalTypeId;

if (colJournalTypes.Count() > 0)
{
var journalType = colJournalTypes.Single();
journalTypeId = journalType.JournalTypeId;
}
else
{
journalTypeId = 28;
}

return journalTypeId;
}

Posting to the Journal

Once you have decided which journal types will be utilized in your own module you will need to determine when you should be posting to the journal. Depending on the functionality provided in your own module, this will vary but a few things to consider:
  • The journal module permits filtering by journal type
  • Each journal entry is associated with a creator user plus a group or profile user (or all 3, but at least 2 of the 3)
  • Journal entries can be associated with a content item but it is not required

Object Key

The object key allows you to create a unique identifier for each item you post to the journal. This is important for two reasons: It provides a way to update/remove the journal entry (there is technically no update method for journal posts), it can be used to store additional information (such as additional ‘keys’) to avoid extra trips to the data store.

Security Set

The security set, along with which ‘profile’ the journal entry is being posted to, determines who can view the journal entry. In the sample Boards module, we are utilizing “E” which represents everyone (which means anyone that can see the user’s journal can see this particular entry). Other options include:
  • F = Friend
  • P = Profile
  • U = User
  • R = Role

The code sample below is called from another part of the module once a new task has been submitted. This utilizes the journal type retrieval method outlined above. You should also note that it deletes any journal entry w/ the same object key since there is no 'update' method available. Developers should also delete journal entries on their own when any content is deleted that has a corresponding journal entry.


/// <summary>
/// Informs the core journal that the user has added a new task.
/// </summary>
/// <param name="objCard"></param>
/// <param name="title"></param>
/// <param name="summary"></param>
/// <param name="portalId"></param>
/// <param name="journalUserId"></param>
/// <param name="url"></param>
internal void AddTaskToJournal(Card objCard, string title, string summary, int portalId, int journalUserId, string url)
{
var objectKey = Constants.ContentTypeName + "_" + Constants.JournalTaskAddName + "_" + string.Format("{0}:{1}", objCard.ModuleID, objCard.CardId);
var ji = JournalController.Instance.GetJournalItemByKey(portalId, objectKey);

if ((ji != null))
{
JournalController.Instance.DeleteJournalItemByKey(portalId, objectKey);
}

ji = new JournalItem
{
PortalId = portalId,
ProfileId = journalUserId,
UserId = journalUserId,
ContentItemId = objCard.ContentItemId,
Title = title,
ItemData = new ItemData {Url = url},
Summary = summary,
Body = null,
JournalTypeId = GetTaskAddJournalTypeId(portalId),
ObjectKey = objectKey,
SecuritySet = "E,"
};

JournalController.Instance.SaveJournalItem(ji, objCard.TabID);
}


Integrated Modules

Contents
No sections defined
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out