using System;
using CMS.CMSHelper;
using CMS.Forums;
using CMS.GlobalHelper;
using CMS.DocumentEngine;
///
/// Forum functions static class.
///
public static class ForumFunctions
{
///
/// Returns link to selected post.
///
/// Post id path
/// Forum id
public static string GetPostURL(object postIdPath, object forumId)
{
string pIdPath = ValidationHelper.GetString(postIdPath, string.Empty);
int fId = ValidationHelper.GetInteger(forumId, 0);
return ForumPostInfoProvider.GetPostURL(pIdPath, fId, true);
}
///
/// Returns link to selected post.
///
/// Post id path
/// Forum id
/// Alias path
public static string GetPostURL(object aliasPath, object postIdPath, object forumId)
{
string alPath = ValidationHelper.GetString(aliasPath, string.Empty);
string pIdPath = ValidationHelper.GetString(postIdPath, string.Empty);
int fId = ValidationHelper.GetInteger(forumId, 0);
if (!String.IsNullOrEmpty(pIdPath) && (fId > 0))
{
// Get thread id from post id path
int threadId = ForumPostInfoProvider.GetPostRootFromIDPath(pIdPath);
if (threadId > 0)
{
string url = URLHelper.ResolveUrl(CMSContext.CurrentResolver.ResolveMacros(TreePathUtils.GetUrl(alPath)));
url = URLHelper.UpdateParameterInUrl(url, "ForumId", fId.ToString());
url = URLHelper.UpdateParameterInUrl(url, "ThreadId", threadId.ToString());
url = URLHelper.EncodeQueryString(url);
return url;
}
}
return string.Empty;
}
}