×
Kunena 5.1.5 Released - Security Release (14 Oct 2018)

The Kunena team has announce the arrival of Kunena 5.1.5 [K 5.1.5] which is now available for download as a native Joomla extension for J! 3.8.x. This version addresses most of the issues that were discovered in K 5.1 and issues discovered during the development stages of K 5.1. This is a Security release.

× Please note: The Kunena project team takes NO responsibility for maintaining nor supporting anything in this category.

Loved Subscribe button on front page

More
5 years 2 months ago - 5 years 2 months ago #1 by MusicInMe
Well, hope I get help because this is getting on top of me. I added Subscribe button on the front page to allow user do this without open category where this button is usualy placed.
<?php if ($this->category->authorise ( 'subscribe', null, true )) :
  $subscribed = $this->category->getSubscribed($this->me->userid);
  if (!$subscribed) { ?>
 
 <a class="hasTooltip" href="index.php?option=com_kunena&view=category&task=subscribe&catid=<?php echo $category->id; ?><?php echo $token; ?>" title="<?php echo JText::_('COM_KUNENA_TEMPLATE_SUBSCRIBE_NOW'); ?>" >
  <button class="btn btn-warning btn-small">
    <i class="icon-white icon-envelope"></i>
  </button>
 </a> 
 
<?php }; ?>
<?php else: ?>
 
 <a class="hasTooltip" href="index.php?option=com_kunena&view=category&task=unsubscribe&catid=<?php echo $category->id; ?><?php echo $token; ?>" title="<?php echo JText::_('COM_KUNENA_TEMPLATE_UNSUBSCRIBE'); ?>">
  <button class="btn btn-warning btn-small">
    <i class="icon-white icon-envelope"></i>
  </button>
 </a>
 
<?php endif; ?>

This only show second option, as every category is already subscribed. At the beginning of file I placed
$token = '&' . JSession::getFormToken() . '=1';

but it doesn't help to identify user is alowed to su/unsubscribe. When I enter to category I am able to subscribe to any childforum this category contain. So need to figure out only front page.
Last edit: 5 years 2 months ago by MusicInMe.

Please Log in or Create an account to join the conversation.

More
5 years 2 months ago #2 by xillibit

MusicInMe wrote:
This only show second option, as every category is already subscribed. At the beginning of file I placed

$token = '&' . JSession::getFormToken() . '=1';

but it doesn't help to identify user is alowed to su/unsubscribe. When I enter to category I am able to subscribe to any childforum this category contain. So need to figure out only front page.

Hello,

The JSession::getFormToken() just set a token to avoid security problems.

To get the user id you can use by example :
JFactory::getUser()->id;

I don't provide support by PM, because this can be useful for someone else.

Please Log in or Create an account to join the conversation.

More
5 years 2 months ago #3 by MusicInMe
Wasn't easy but finaly got the solution:
Added code (just after
defined ( '_JEXEC' ) or die ();
at the top of let say in template/my_template/html/category/default.php
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}";
	$substitle = "Subscribe";
	$tiptile = "Subscribe to category";
	} else {
	$subscription = "index.php?option=com_kunena&view=category&task=unsubscribe&catid={$this->category->id}{$token}";
	$substitle = "Unubscribe";
	$tiptitle = "Unsubscribe from category";
  }
}

and then, where the code must be shown
<a href="<?php echo $subscription; ?>" class="hasTooltip" title="<?php echo $tiptitle; ?>"><i class="icon-envelope"></i> <?php echo $substitle; ?></a>

Please Log in or Create an account to join the conversation.

  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to add attachements.
  • Not Allowed: to edit your message.
Time to create page: 0.174 seconds