I need to get a users authentication ticket in order to do a specific action. Basically, the system does not allow users to 'mark all as read' from the 'unread posts' page without marking the entire...
Even though I was unable to get the authentication via api, I have instead just used jquery to look at existing links on the page and get that authentication ticket from that instead. Bit of a dirty hack but it does what I need it to do.
For anyone interested, I have editted the unreadposts page by adding these two components to the unreadpage quilt:
And then I created a custom component and added it to that page:
<#if !user.anonymous>
<@liaAddScript>
;(function($) {
var url = ($('.mark-community-read-link').attr('href'));
var ticket = getURLParameter(url, 'ticket');
var actionMenuDropDown = $('#actionMenuDropDown .lia-menu-dropdown-items');
var buttonSeperator = '<li aria-hidden="true"><span class="lia-separator lia-component-common-widget-link-separator"><span class="lia-separator-post"></span><span class="lia-separator-pre"></span></span></li>';
var pathname = window.location.pathname;
function getURLParameter(url, name) {
return (RegExp(name + '=' + '(.+?)(&|$)').exec(url)||[,null])[1];
}
if($('body').hasClass('lia-board')){
var buttonMarkRead = '<li><a id="boardMarkRead" class="lia-link-navigation mark-board-read-link lia-component-board-widget-mark-read" href="/t5/forums/forumpage.markread/board-id/${coreNode.id}?t:ac=board-id/${coreNode.id}/tab/message&t:cp=boards/contributions/markedactions&ticket=' + ticket + '">Mark all posts in this Board as Read</a></li>';
var buttonMarkNew = '<li><a id="boardMarkNew" class="lia-link-navigation mark-category-read-link lia-component-category-widget-mark-read" href="/t5/forums/forumpage.marknew/board-id/${coreNode.id}?t:ac=board-id/${coreNode.id}/tab/message&t:cp=boards/contributions/markedactions&ticket=' + ticket + '">Mark all Posts in this Board as New</a></li>';
$(actionMenuDropDown)
.append(buttonSeperator)
.append(buttonMarkNew)
.append(buttonMarkRead);
if ($('.lia-panel-status-banner-note').length){
$('#boardMarkRead').addClass('lia-link-disabled').removeAttr('href');
};
} else {
if ($('.lia-component-category-widget-mark-read').length){
var categoryMarkRead = $('.lia-component-category-widget-mark-read');
var categoryMarkNew = $('.lia-component-category-widget-mark-new');
var buttonMarkRead = '<li>'+ $(categoryMarkRead).outerHTML() +'</li>';
var buttonMarkNew = '<li>'+ $(categoryMarkNew).outerHTML() +'</li>';
$(actionMenuDropDown)
.append(buttonSeperator)
.append(buttonMarkNew)
.append(buttonMarkRead);
categoryMarkRead.remove();
categoryMarkNew.remove();
if ($('.lia-panel-status-banner-note').length){
$('#categoryMarkRead').addClass('lia-link-disabled').removeAttr('href');
};
}
};
if ($('.lia-panel-status-banner-note').length && (pathname == '/t5/forums/unreadpostspage/tab/message' || pathname == '/t5/forums/unreadpostspage/tab/thread')){
$('#communityMarkRead').addClass('lia-link-disabled').removeAttr('href');
};
})(LITHIUM.jQuery);
</@liaAddScript>
</#if>
And what you end up with is this on community, category and board level:
There is probably a much better way of doing this but this works for me. I could probably do the IF statement a bit more elegantly by using the API to detect the page type (board, category or community level) but I'm unsure how to do that.