Hello,
Below code works perfect with drop down menu in topics list (category layout)
Code:
if ($this->me->exists()) {
$token = '&' . JSession::getFormToken() . '=1';
$markread = "index.php?option=com_kunena&view=category&task=markread&catid={$this->section->id}{$token}";
}
if ($this->category->authorise ( 'subscribe', null, true )) {
$subscribed = $this->category->getSubscribed($this->me->userid);
if (!$subscribed) {
$subscription = "index.php?option=com_kunena&view=category&task=subscribe&catid={$this->category->id}{$token}";
$subtitle = "Subscribe";
$subtiptile = "Subscribe to category";
} else {
$subscription = "index.php?option=com_kunena&view=category&task=unsubscribe&catid={$this->category->id}{$token}";
$subtitle = "Unubscribe";
$subtiptile = "Unsubscribe from this category";
}
}
-----------
<ul class="dropdown-menu">
<li>
<a href="<?php echo $newtopic; ?>" class="hasTooltip" title="Create a new topic"><i class="icon-pencil"></i> New Topic</a>
<a href="<?php echo $markread; ?>" class="hasTooltip" title="Mark all topics in this categeory as read"><i class="icon-check"></i> Mark Topics Read</a>
<a href="<?php echo $subscription; ?>" class="hasTooltip" title="<?php echo $subtiptile; ?>"><i class="icon-envelope"></i> <?php echo $subtitle; ?></a>
</li>
</ul>
But when I adjust it to topic view (insted of topic buttons)
Code:
if ($this->topic->authorise ( 'subscribe', null, true )) {
$subscribed = $this->topic->getUserTopic($this->me->userid);
if (!$subscribed) {
$subscription = "index.php?option=com_kunena&view=topic&task=subscribe&catid={$this->category->id}{$token}";
$subtitle = "Subscribe";
$subtiptitle = "Subscribe to this topic";
} else {
$subscription = "index.php?option=com_kunena&view=topic&task=unsubscribe&catid={$this->category->id}{$token}";
$subtitle = "Unubscribe";
$subtiptitle = "Unsubscribe from this topic";
}
}
if ($this->usertopic->favorite) {
$favorited = $this->topic->getUserTopic($this->me->userid);
if (!$favorited) {
$favorites = "index.php?option=com_kunena&view=topic&task=favorite&catid={$this->category->id}{$token}";
$favtitle = "Favorite";
$favtiptitle = "Favorite this topic";
} elseif ($this->topic->authorise('subscribe')) {
$favorites = "index.php?option=com_kunena&view=topic&task=unfavorite&catid={$this->category->id}{$token}";
$favtitle = "Unfavorite";
$favtiptitle = "Remove this topic from favorites";
}
}
and trying to unsubscribe I get error
This topic has NOT been removed from your subscriptions. You do not have permissions to access this page.
I have tried many combinations, but none of them work properly. Oddly enough token is correct because I checked it with the URL of normal button.
Any suggestions for a URL to subscribe to topic or to add it to favorites?